@focus-reactive/payload-plugin-seo 1.3.0 → 1.5.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/README.md +242 -60
- package/dist/admin.css +2 -3
- package/dist/components/SeoButton/ScoreBadge.d.ts.map +1 -1
- package/dist/components/SeoButton/ScoreBadge.js +10 -7
- package/dist/components/SeoButton/ScoreBadge.js.map +1 -1
- package/dist/components/SeoButton/SeoButtonInner.d.ts +2 -2
- package/dist/components/SeoButton/SeoButtonInner.d.ts.map +1 -1
- package/dist/components/SeoButton/SeoButtonInner.js +11 -5
- package/dist/components/SeoButton/SeoButtonInner.js.map +1 -1
- package/dist/components/SeoDrawer/TabsNav/index.d.ts.map +1 -1
- package/dist/components/SeoDrawer/TabsNav/index.js +15 -4
- package/dist/components/SeoDrawer/TabsNav/index.js.map +1 -1
- package/dist/components/SeoDrawer/TabsNav/variants.d.ts.map +1 -1
- package/dist/components/SeoDrawer/TabsNav/variants.js +12 -9
- package/dist/components/SeoDrawer/TabsNav/variants.js.map +1 -1
- package/dist/components/SeoDrawer/analysisDecision.d.ts.map +1 -1
- package/dist/components/SeoDrawer/analysisDecision.js.map +1 -1
- package/dist/components/SeoDrawer/build-analysis-input.d.ts +3 -8
- package/dist/components/SeoDrawer/build-analysis-input.d.ts.map +1 -1
- package/dist/components/SeoDrawer/build-analysis-input.js +28 -12
- package/dist/components/SeoDrawer/build-analysis-input.js.map +1 -1
- package/dist/components/SeoDrawer/buildInput.d.ts +1 -1
- package/dist/components/SeoDrawer/buildInput.d.ts.map +1 -1
- package/dist/components/SeoDrawer/buildInput.js +13 -3
- package/dist/components/SeoDrawer/buildInput.js.map +1 -1
- package/dist/components/SeoDrawer/components/Header.d.ts.map +1 -1
- package/dist/components/SeoDrawer/components/Header.js +20 -2
- package/dist/components/SeoDrawer/components/Header.js.map +1 -1
- package/dist/components/SeoDrawer/components/HeadingsSection/HeadingLevelTiles.d.ts.map +1 -1
- package/dist/components/SeoDrawer/components/HeadingsSection/HeadingLevelTiles.js +23 -5
- package/dist/components/SeoDrawer/components/HeadingsSection/HeadingLevelTiles.js.map +1 -1
- package/dist/components/SeoDrawer/components/HeadingsSection/HeadingTree/Chevron.d.ts.map +1 -1
- package/dist/components/SeoDrawer/components/HeadingsSection/HeadingTree/Chevron.js +12 -1
- package/dist/components/SeoDrawer/components/HeadingsSection/HeadingTree/Chevron.js.map +1 -1
- package/dist/components/SeoDrawer/components/HeadingsSection/HeadingTree/HeadingTreeGroup.d.ts.map +1 -1
- package/dist/components/SeoDrawer/components/HeadingsSection/HeadingTree/HeadingTreeGroup.js +43 -4
- package/dist/components/SeoDrawer/components/HeadingsSection/HeadingTree/HeadingTreeGroup.js.map +1 -1
- package/dist/components/SeoDrawer/components/HeadingsSection/HeadingTree/HeadingTreeRow.d.ts +1 -1
- package/dist/components/SeoDrawer/components/HeadingsSection/HeadingTree/HeadingTreeRow.d.ts.map +1 -1
- package/dist/components/SeoDrawer/components/HeadingsSection/HeadingTree/HeadingTreeRow.js +45 -10
- package/dist/components/SeoDrawer/components/HeadingsSection/HeadingTree/HeadingTreeRow.js.map +1 -1
- package/dist/components/SeoDrawer/components/HeadingsSection/HeadingTree/index.d.ts.map +1 -1
- package/dist/components/SeoDrawer/components/HeadingsSection/HeadingTree/index.js.map +1 -1
- package/dist/components/SeoDrawer/components/HeadingsSection/HeadingTree/useHeadingRails.d.ts +1 -1
- package/dist/components/SeoDrawer/components/HeadingsSection/HeadingTree/useHeadingRails.d.ts.map +1 -1
- package/dist/components/SeoDrawer/components/HeadingsSection/HeadingTree/useHeadingRails.js +6 -1
- package/dist/components/SeoDrawer/components/HeadingsSection/HeadingTree/useHeadingRails.js.map +1 -1
- package/dist/components/SeoDrawer/components/HeadingsSection/index.d.ts.map +1 -1
- package/dist/components/SeoDrawer/components/HeadingsSection/index.js.map +1 -1
- package/dist/components/SeoDrawer/components/SerpPreview/highlight-keyphrase.d.ts.map +1 -1
- package/dist/components/SeoDrawer/components/SerpPreview/highlight-keyphrase.js +3 -1
- package/dist/components/SeoDrawer/components/SerpPreview/highlight-keyphrase.js.map +1 -1
- package/dist/components/SeoDrawer/components/SerpPreview/index.d.ts.map +1 -1
- package/dist/components/SeoDrawer/components/SerpPreview/index.js +8 -1
- package/dist/components/SeoDrawer/components/SerpPreview/index.js.map +1 -1
- package/dist/components/SeoDrawer/components/SerpPreview/serp-favicon.d.ts.map +1 -1
- package/dist/components/SeoDrawer/components/SerpPreview/serp-favicon.js.map +1 -1
- package/dist/components/SeoDrawer/components/SerpPreview/variants.d.ts.map +1 -1
- package/dist/components/SeoDrawer/components/SerpPreview/variants.js +9 -6
- package/dist/components/SeoDrawer/components/SerpPreview/variants.js.map +1 -1
- package/dist/components/SeoDrawer/index.d.ts.map +1 -1
- package/dist/components/SeoDrawer/index.js +50 -15
- package/dist/components/SeoDrawer/index.js.map +1 -1
- package/dist/components/SeoDrawer/keyphrasePending.d.ts.map +1 -1
- package/dist/components/SeoDrawer/keyphrasePending.js.map +1 -1
- package/dist/components/SeoDrawer/languagePacks.d.ts.map +1 -1
- package/dist/components/SeoDrawer/languagePacks.js.map +1 -1
- package/dist/components/SeoDrawer/tabs/InclusiveTab.d.ts.map +1 -1
- package/dist/components/SeoDrawer/tabs/InclusiveTab.js +31 -10
- package/dist/components/SeoDrawer/tabs/InclusiveTab.js.map +1 -1
- package/dist/components/SeoDrawer/tabs/KeyphraseTab.d.ts +1 -1
- package/dist/components/SeoDrawer/tabs/KeyphraseTab.d.ts.map +1 -1
- package/dist/components/SeoDrawer/tabs/KeyphraseTab.js +8 -1
- package/dist/components/SeoDrawer/tabs/KeyphraseTab.js.map +1 -1
- package/dist/components/SeoDrawer/tabs/SerpTab.d.ts +1 -1
- package/dist/components/SeoDrawer/tabs/SerpTab.d.ts.map +1 -1
- package/dist/components/SeoDrawer/tabs/SerpTab.js +5 -1
- package/dist/components/SeoDrawer/tabs/SerpTab.js.map +1 -1
- package/dist/components/SeoDrawer/tabs/VitalsTab.d.ts.map +1 -1
- package/dist/components/SeoDrawer/tabs/VitalsTab.js +32 -9
- package/dist/components/SeoDrawer/tabs/VitalsTab.js.map +1 -1
- package/dist/components/SeoDrawer/useAnalysis.d.ts +1 -1
- package/dist/components/SeoDrawer/useAnalysis.d.ts.map +1 -1
- package/dist/components/SeoDrawer/useAnalysis.js +6 -1
- package/dist/components/SeoDrawer/useAnalysis.js.map +1 -1
- package/dist/components/SeoDrawer/useLiveDocument.d.ts +3 -4
- package/dist/components/SeoDrawer/useLiveDocument.d.ts.map +1 -1
- package/dist/components/SeoDrawer/useLiveDocument.js +45 -48
- package/dist/components/SeoDrawer/useLiveDocument.js.map +1 -1
- package/dist/components/icons.d.ts.map +1 -1
- package/dist/components/icons.js +16 -1
- package/dist/components/icons.js.map +1 -1
- package/dist/constants/checkIds.d.ts.map +1 -1
- package/dist/constants/checkIds.js +18 -2
- package/dist/constants/checkIds.js.map +1 -1
- package/dist/content/index.d.ts +5 -0
- package/dist/content/index.d.ts.map +1 -0
- package/dist/content/index.js +15 -0
- package/dist/content/index.js.map +1 -0
- package/dist/content/registry.d.ts +4 -0
- package/dist/content/registry.d.ts.map +1 -0
- package/dist/content/registry.js +22 -0
- package/dist/content/registry.js.map +1 -0
- package/dist/content/resolve/resolve-docs.d.ts +3 -0
- package/dist/content/resolve/resolve-docs.d.ts.map +1 -0
- package/dist/content/resolve/resolve-docs.js +48 -0
- package/dist/content/resolve/resolve-docs.js.map +1 -0
- package/dist/content/schema/helpers.d.ts +10 -0
- package/dist/content/schema/helpers.d.ts.map +1 -0
- package/dist/content/schema/helpers.js +64 -0
- package/dist/content/schema/helpers.js.map +1 -0
- package/dist/content/schema/nodes.d.ts +26 -0
- package/dist/content/schema/nodes.d.ts.map +1 -0
- package/dist/content/schema/nodes.js +8 -0
- package/dist/content/schema/nodes.js.map +1 -0
- package/dist/content/schema/serialize.d.ts +3 -0
- package/dist/content/schema/serialize.d.ts.map +1 -0
- package/dist/content/schema/serialize.js +31 -0
- package/dist/content/schema/serialize.js.map +1 -0
- package/dist/engine/assessorAdapter.d.ts.map +1 -1
- package/dist/engine/assessorAdapter.js.map +1 -1
- package/dist/engine/extractCheckData.d.ts.map +1 -1
- package/dist/engine/extractCheckData.js +19 -5
- package/dist/engine/extractCheckData.js.map +1 -1
- package/dist/engine/helpers/title-progress.d.ts +1 -1
- package/dist/engine/helpers/title-progress.js.map +1 -1
- package/dist/engine/inclusiveScore.d.ts.map +1 -1
- package/dist/engine/inclusiveScore.js.map +1 -1
- package/dist/engine/recommendations.d.ts.map +1 -1
- package/dist/engine/recommendations.js.map +1 -1
- package/dist/engine/runAnalysis/services/derive-inclusive.js.map +1 -1
- package/dist/engine/runAnalysis/services/derive-readability.d.ts.map +1 -1
- package/dist/engine/runAnalysis/services/derive-readability.js +5 -1
- package/dist/engine/runAnalysis/services/derive-readability.js.map +1 -1
- package/dist/engine/runAnalysis/services/derive-vitals/heading-tree.d.ts.map +1 -1
- package/dist/engine/runAnalysis/services/derive-vitals/heading-tree.js.map +1 -1
- package/dist/engine/runAnalysis/services/derive-vitals/index.d.ts.map +1 -1
- package/dist/engine/runAnalysis/services/derive-vitals/index.js +9 -1
- package/dist/engine/runAnalysis/services/derive-vitals/index.js.map +1 -1
- package/dist/engine/runAnalysis/services/derive-vitals/researches.d.ts +1 -1
- package/dist/engine/runAnalysis/services/derive-vitals/researches.d.ts.map +1 -1
- package/dist/engine/runAnalysis/services/derive-vitals/researches.js +8 -2
- package/dist/engine/runAnalysis/services/derive-vitals/researches.js.map +1 -1
- package/dist/engine/runAnalysis/utils/enrich.d.ts.map +1 -1
- package/dist/engine/runAnalysis/utils/enrich.js.map +1 -1
- package/dist/engine/visualization/resolveVisualization/constants.d.ts.map +1 -1
- package/dist/engine/visualization/resolveVisualization/constants.js +9 -1
- package/dist/engine/visualization/resolveVisualization/constants.js.map +1 -1
- package/dist/engine/visualization/resolveVisualization/index.d.ts.map +1 -1
- package/dist/engine/visualization/resolveVisualization/index.js.map +1 -1
- package/dist/engine/visualization/resolveVisualization/resolves/resolveDrilldown.d.ts.map +1 -1
- package/dist/engine/visualization/resolveVisualization/resolves/resolveDrilldown.js.map +1 -1
- package/dist/engine/visualization/resolveVisualization/resolves/resolveLinks.d.ts.map +1 -1
- package/dist/engine/visualization/resolveVisualization/resolves/resolveLinks.js.map +1 -1
- package/dist/engine/visualization/resolveVisualization/resolves/resolveProportionCount.d.ts.map +1 -1
- package/dist/engine/visualization/resolveVisualization/resolves/resolveProportionCount.js.map +1 -1
- package/dist/engine/visualization/resolveVisualization/resolves/resolveValueRange.d.ts.map +1 -1
- package/dist/engine/visualization/resolveVisualization/resolves/resolveValueRange.js.map +1 -1
- package/dist/engine/visualization/resolveVisualization/utils/pluralize.d.ts.map +1 -1
- package/dist/engine/visualization/resolveVisualization/utils/pluralize.js.map +1 -1
- package/dist/engine/visualization/resolveVisualization/utils/readDrilldownItems.d.ts.map +1 -1
- package/dist/engine/visualization/resolveVisualization/utils/readDrilldownItems.js.map +1 -1
- package/dist/engine/visualization/resolveVisualization/utils/readNumber.d.ts.map +1 -1
- package/dist/engine/visualization/resolveVisualization/utils/readNumber.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +24 -4
- package/dist/plugin.js.map +1 -1
- package/dist/types/config.d.ts +42 -9
- package/dist/types/config.d.ts.map +1 -1
- package/dist/ui/CheckRow/CheckVisualization/visualizations/DensityGauge.d.ts.map +1 -1
- package/dist/ui/CheckRow/CheckVisualization/visualizations/DensityGauge.js +24 -5
- package/dist/ui/CheckRow/CheckVisualization/visualizations/DensityGauge.js.map +1 -1
- package/dist/ui/CheckRow/CheckVisualization/visualizations/DistributionBar.d.ts.map +1 -1
- package/dist/ui/CheckRow/CheckVisualization/visualizations/DistributionBar.js +8 -1
- package/dist/ui/CheckRow/CheckVisualization/visualizations/DistributionBar.js.map +1 -1
- package/dist/ui/CheckRow/CheckVisualization/visualizations/DrillDown.d.ts.map +1 -1
- package/dist/ui/CheckRow/CheckVisualization/visualizations/DrillDown.js +11 -4
- package/dist/ui/CheckRow/CheckVisualization/visualizations/DrillDown.js.map +1 -1
- package/dist/ui/CheckRow/CheckVisualization/visualizations/SegmentBar.d.ts.map +1 -1
- package/dist/ui/CheckRow/CheckVisualization/visualizations/SegmentBar.js +7 -1
- package/dist/ui/CheckRow/CheckVisualization/visualizations/SegmentBar.js.map +1 -1
- package/dist/ui/CheckRow/index.d.ts.map +1 -1
- package/dist/ui/CheckRow/index.js +23 -9
- package/dist/ui/CheckRow/index.js.map +1 -1
- package/dist/ui/FilterPills.d.ts.map +1 -1
- package/dist/ui/FilterPills.js +78 -19
- package/dist/ui/FilterPills.js.map +1 -1
- package/dist/ui/KpiCard.d.ts.map +1 -1
- package/dist/ui/KpiCard.js.map +1 -1
- package/dist/ui/Pill.d.ts.map +1 -1
- package/dist/ui/Pill.js +11 -8
- package/dist/ui/Pill.js.map +1 -1
- package/dist/ui/ScoreRing.d.ts.map +1 -1
- package/dist/ui/ScoreRing.js +12 -2
- package/dist/ui/ScoreRing.js.map +1 -1
- package/dist/ui/SectionWrapper.d.ts.map +1 -1
- package/dist/ui/SectionWrapper.js.map +1 -1
- package/dist/ui/SegmentedControl.d.ts +1 -1
- package/dist/ui/SegmentedControl.d.ts.map +1 -1
- package/dist/ui/SegmentedControl.js +49 -33
- package/dist/ui/SegmentedControl.js.map +1 -1
- package/dist/ui/Tooltip.d.ts +1 -1
- package/dist/ui/Tooltip.d.ts.map +1 -1
- package/dist/ui/Tooltip.js +8 -1
- package/dist/ui/Tooltip.js.map +1 -1
- package/dist/utils/config/overrideAdmin.js +1 -1
- package/dist/utils/config/overrideAdmin.js.map +1 -1
- package/dist/utils/style.d.ts.map +1 -1
- package/dist/utils/style.js.map +1 -1
- package/package.json +9 -7
- package/dist/content/extractContent.d.ts +0 -3
- package/dist/content/extractContent.d.ts.map +0 -1
- package/dist/content/extractContent.js +0 -31
- package/dist/content/extractContent.js.map +0 -1
- package/dist/content/uploads/collect-upload-refs.d.ts +0 -5
- package/dist/content/uploads/collect-upload-refs.d.ts.map +0 -1
- package/dist/content/uploads/collect-upload-refs.js +0 -19
- package/dist/content/uploads/collect-upload-refs.js.map +0 -1
- package/dist/content/uploads/hydrate-values.d.ts +0 -5
- package/dist/content/uploads/hydrate-values.d.ts.map +0 -1
- package/dist/content/uploads/hydrate-values.js +0 -15
- package/dist/content/uploads/hydrate-values.js.map +0 -1
- package/dist/content/uploads/media-resolver.d.ts +0 -7
- package/dist/content/uploads/media-resolver.d.ts.map +0 -1
- package/dist/content/uploads/media-resolver.js +0 -60
- package/dist/content/uploads/media-resolver.js.map +0 -1
- package/dist/content/uploads/transform-lexical-uploads.d.ts +0 -5
- package/dist/content/uploads/transform-lexical-uploads.d.ts.map +0 -1
- package/dist/content/uploads/transform-lexical-uploads.js +0 -34
- package/dist/content/uploads/transform-lexical-uploads.js.map +0 -1
- package/dist/content/uploads/transform-upload-values.d.ts +0 -10
- package/dist/content/uploads/transform-upload-values.d.ts.map +0 -1
- package/dist/content/uploads/transform-upload-values.js +0 -108
- package/dist/content/uploads/transform-upload-values.js.map +0 -1
- package/dist/content/uploads/types.d.ts +0 -8
- package/dist/content/uploads/types.d.ts.map +0 -1
- package/dist/content/uploads/types.js +0 -7
- package/dist/content/uploads/types.js.map +0 -1
- package/dist/content/walkValue.d.ts +0 -14
- package/dist/content/walkValue.d.ts.map +0 -1
- package/dist/content/walkValue.js +0 -62
- package/dist/content/walkValue.js.map +0 -1
|
@@ -2,36 +2,30 @@
|
|
|
2
2
|
import { useAllFormFields, useConfig, useDebounce, useLocale } from "@payloadcms/ui";
|
|
3
3
|
import { reduceFieldsToValues } from "payload/shared";
|
|
4
4
|
import { useCallback, useMemo, useRef } from "react";
|
|
5
|
-
import {
|
|
5
|
+
import { resolveContentExtractor } from "../../content/registry";
|
|
6
6
|
import { buildAnalysisInput } from "./build-analysis-input";
|
|
7
|
+
const erroredPaths = /* @__PURE__ */ new Set();
|
|
7
8
|
const DEBOUNCE_MS = 1e3;
|
|
8
|
-
function useLiveDocument({
|
|
9
|
+
function useLiveDocument({
|
|
10
|
+
collectionSlug: _collectionSlug,
|
|
11
|
+
fields,
|
|
12
|
+
site,
|
|
13
|
+
keyphrase,
|
|
14
|
+
enabled = true,
|
|
15
|
+
extractContentPath
|
|
16
|
+
}) {
|
|
9
17
|
const [formFields] = useAllFormFields();
|
|
10
18
|
const locale = useLocale();
|
|
11
|
-
const { config
|
|
19
|
+
const { config } = useConfig();
|
|
12
20
|
const debouncedFields = useDebounce(formFields, DEBOUNCE_MS);
|
|
13
21
|
const debouncedKeyphrase = useDebounce(keyphrase, DEBOUNCE_MS);
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
19
|
-
return entity?.fields ?? [];
|
|
20
|
-
}, [getEntityConfig, collectionSlug]);
|
|
21
|
-
const walkCtx = useMemo(
|
|
22
|
-
() => ({
|
|
23
|
-
isUploadCollection: (slug) => Boolean(config.collections?.find((c) => c.slug === slug)?.upload),
|
|
24
|
-
blocksBySlug: { ...config.blocksMap }
|
|
25
|
-
}),
|
|
26
|
-
[config]
|
|
22
|
+
const apiRoute = config.routes.api;
|
|
23
|
+
const values = useMemo(
|
|
24
|
+
() => enabled ? reduceFieldsToValues(debouncedFields, true) : {},
|
|
25
|
+
[enabled, debouncedFields]
|
|
27
26
|
);
|
|
28
|
-
const values = useMemo(() => enabled ? reduceFieldsToValues(debouncedFields, true) : {}, [enabled, debouncedFields]);
|
|
29
27
|
const signature = useMemo(
|
|
30
|
-
() => JSON.stringify({
|
|
31
|
-
values,
|
|
32
|
-
keyphrase: debouncedKeyphrase,
|
|
33
|
-
locale: locale?.code ?? null
|
|
34
|
-
}),
|
|
28
|
+
() => JSON.stringify({ values, keyphrase: debouncedKeyphrase, locale: locale?.code ?? null }),
|
|
35
29
|
[values, debouncedKeyphrase, locale]
|
|
36
30
|
);
|
|
37
31
|
const liveRef = useRef({
|
|
@@ -42,10 +36,8 @@ function useLiveDocument({ collectionSlug, fields, site, keyphrase, enabled = tr
|
|
|
42
36
|
locale,
|
|
43
37
|
fields,
|
|
44
38
|
site,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
walkCtx,
|
|
48
|
-
resolver
|
|
39
|
+
extractContentPath,
|
|
40
|
+
apiRoute
|
|
49
41
|
});
|
|
50
42
|
liveRef.current = {
|
|
51
43
|
formFields,
|
|
@@ -55,29 +47,34 @@ function useLiveDocument({ collectionSlug, fields, site, keyphrase, enabled = tr
|
|
|
55
47
|
locale,
|
|
56
48
|
fields,
|
|
57
49
|
site,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
walkCtx,
|
|
61
|
-
resolver
|
|
50
|
+
extractContentPath,
|
|
51
|
+
apiRoute
|
|
62
52
|
};
|
|
63
|
-
const getInput = useCallback(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
53
|
+
const getInput = useCallback(
|
|
54
|
+
async ({ live = false } = {}) => {
|
|
55
|
+
const s = liveRef.current;
|
|
56
|
+
const inputValues = live ? reduceFieldsToValues(s.formFields, true) : s.values;
|
|
57
|
+
const extractor = resolveContentExtractor(s.extractContentPath);
|
|
58
|
+
if (!extractor && !erroredPaths.has(s.extractContentPath)) {
|
|
59
|
+
erroredPaths.add(s.extractContentPath);
|
|
60
|
+
console.error(
|
|
61
|
+
`[payload-plugin-seo] extractContentPath "${s.extractContentPath}" is not registered; content analysis will be empty. Call registerContentExtractors from "@focus-reactive/payload-plugin-seo/content" in an admin-mounted client module.`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
return buildAnalysisInput({
|
|
65
|
+
values: inputValues,
|
|
66
|
+
locale: s.locale,
|
|
67
|
+
payloadLocale: s.locale?.code,
|
|
68
|
+
apiRoute: s.apiRoute,
|
|
69
|
+
keyphrase: live ? s.keyphrase : s.debouncedKeyphrase,
|
|
70
|
+
fields: s.fields,
|
|
71
|
+
site: s.site,
|
|
72
|
+
extractor
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
[]
|
|
76
|
+
);
|
|
77
|
+
return { signature, getInput };
|
|
81
78
|
}
|
|
82
79
|
export {
|
|
83
80
|
useLiveDocument
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/SeoDrawer/useLiveDocument.ts"],"sourcesContent":["\"use client\";\n\nimport { useAllFormFields, useConfig, useDebounce, useLocale } from \"@payloadcms/ui\";\nimport
|
|
1
|
+
{"version":3,"sources":["../../../src/components/SeoDrawer/useLiveDocument.ts"],"sourcesContent":["\"use client\";\n\nimport { useAllFormFields, useConfig, useDebounce, useLocale } from \"@payloadcms/ui\";\nimport { reduceFieldsToValues } from \"payload/shared\";\nimport { useCallback, useMemo, useRef } from \"react\";\nimport { resolveContentExtractor } from \"../../content/registry\";\nimport type { AnalysisInput } from \"../../engine/types/analysis\";\nimport type { SeoFieldPaths } from \"../../types/config\";\nimport { buildAnalysisInput } from \"./build-analysis-input\";\n\nconst erroredPaths = new Set<string>();\nconst DEBOUNCE_MS = 1000;\n\nexport interface LiveDocArgs {\n collectionSlug: string;\n fields: SeoFieldPaths;\n site: { name: string; baseUrl: string };\n keyphrase: string;\n enabled?: boolean;\n extractContentPath: string;\n}\n\nexport interface UseLiveDocumentResult {\n signature: string;\n getInput: (opts?: { live?: boolean }) => Promise<AnalysisInput>;\n}\n\nexport function useLiveDocument({\n collectionSlug: _collectionSlug,\n fields,\n site,\n keyphrase,\n enabled = true,\n extractContentPath,\n}: LiveDocArgs): UseLiveDocumentResult {\n const [formFields] = useAllFormFields();\n const locale = useLocale();\n const { config } = useConfig();\n\n const debouncedFields = useDebounce(formFields, DEBOUNCE_MS);\n const debouncedKeyphrase = useDebounce(keyphrase, DEBOUNCE_MS);\n const apiRoute = config.routes.api;\n\n const values = useMemo<Record<string, unknown>>(\n () => (enabled ? (reduceFieldsToValues(debouncedFields, true) as Record<string, unknown>) : {}),\n [enabled, debouncedFields]\n );\n\n const signature = useMemo(\n () => JSON.stringify({ values, keyphrase: debouncedKeyphrase, locale: locale?.code ?? null }),\n [values, debouncedKeyphrase, locale]\n );\n\n const liveRef = useRef({\n formFields,\n values,\n keyphrase,\n debouncedKeyphrase,\n locale,\n fields,\n site,\n extractContentPath,\n apiRoute,\n });\n liveRef.current = {\n formFields,\n values,\n keyphrase,\n debouncedKeyphrase,\n locale,\n fields,\n site,\n extractContentPath,\n apiRoute,\n };\n\n const getInput = useCallback(\n async ({ live = false }: { live?: boolean } = {}): Promise<AnalysisInput> => {\n const s = liveRef.current;\n const inputValues = live\n ? (reduceFieldsToValues(s.formFields, true) as Record<string, unknown>)\n : s.values;\n\n const extractor = resolveContentExtractor(s.extractContentPath);\n if (!extractor && !erroredPaths.has(s.extractContentPath)) {\n erroredPaths.add(s.extractContentPath);\n console.error(\n `[payload-plugin-seo] extractContentPath \"${s.extractContentPath}\" is not registered; content analysis will be empty. Call registerContentExtractors from \"@focus-reactive/payload-plugin-seo/content\" in an admin-mounted client module.`\n );\n }\n\n return buildAnalysisInput({\n values: inputValues,\n locale: s.locale,\n payloadLocale: s.locale?.code,\n apiRoute: s.apiRoute,\n keyphrase: live ? s.keyphrase : s.debouncedKeyphrase,\n fields: s.fields,\n site: s.site,\n extractor,\n });\n },\n []\n );\n\n return { signature, getInput };\n}\n"],"mappings":";AAEA,SAAS,kBAAkB,WAAW,aAAa,iBAAiB;AACpE,SAAS,4BAA4B;AACrC,SAAS,aAAa,SAAS,cAAc;AAC7C,SAAS,+BAA+B;AAGxC,SAAS,0BAA0B;AAEnC,MAAM,eAAe,oBAAI,IAAY;AACrC,MAAM,cAAc;AAgBb,SAAS,gBAAgB;AAAA,EAC9B,gBAAgB;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AACF,GAAuC;AACrC,QAAM,CAAC,UAAU,IAAI,iBAAiB;AACtC,QAAM,SAAS,UAAU;AACzB,QAAM,EAAE,OAAO,IAAI,UAAU;AAE7B,QAAM,kBAAkB,YAAY,YAAY,WAAW;AAC3D,QAAM,qBAAqB,YAAY,WAAW,WAAW;AAC7D,QAAM,WAAW,OAAO,OAAO;AAE/B,QAAM,SAAS;AAAA,IACb,MAAO,UAAW,qBAAqB,iBAAiB,IAAI,IAAgC,CAAC;AAAA,IAC7F,CAAC,SAAS,eAAe;AAAA,EAC3B;AAEA,QAAM,YAAY;AAAA,IAChB,MAAM,KAAK,UAAU,EAAE,QAAQ,WAAW,oBAAoB,QAAQ,QAAQ,QAAQ,KAAK,CAAC;AAAA,IAC5F,CAAC,QAAQ,oBAAoB,MAAM;AAAA,EACrC;AAEA,QAAM,UAAU,OAAO;AAAA,IACrB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACD,UAAQ,UAAU;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,WAAW;AAAA,IACf,OAAO,EAAE,OAAO,MAAM,IAAwB,CAAC,MAA8B;AAC3E,YAAM,IAAI,QAAQ;AAClB,YAAM,cAAc,OACf,qBAAqB,EAAE,YAAY,IAAI,IACxC,EAAE;AAEN,YAAM,YAAY,wBAAwB,EAAE,kBAAkB;AAC9D,UAAI,CAAC,aAAa,CAAC,aAAa,IAAI,EAAE,kBAAkB,GAAG;AACzD,qBAAa,IAAI,EAAE,kBAAkB;AACrC,gBAAQ;AAAA,UACN,4CAA4C,EAAE,kBAAkB;AAAA,QAClE;AAAA,MACF;AAEA,aAAO,mBAAmB;AAAA,QACxB,QAAQ;AAAA,QACR,QAAQ,EAAE;AAAA,QACV,eAAe,EAAE,QAAQ;AAAA,QACzB,UAAU,EAAE;AAAA,QACZ,WAAW,OAAO,EAAE,YAAY,EAAE;AAAA,QAClC,QAAQ,EAAE;AAAA,QACV,MAAM,EAAE;AAAA,QACR;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,CAAC;AAAA,EACH;AAEA,SAAO,EAAE,WAAW,SAAS;AAC/B;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../src/components/icons.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../src/components/icons.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG;IAChD,QAAQ,EAAE,UAAU,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,aAiCzB,CAAC"}
|
package/dist/components/icons.js
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
AlignLeft,
|
|
4
|
+
Crosshair,
|
|
5
|
+
Mail,
|
|
6
|
+
Link2,
|
|
7
|
+
BarChart3,
|
|
8
|
+
Type,
|
|
9
|
+
ArrowRight,
|
|
10
|
+
Image as ImageIcon,
|
|
11
|
+
Heading1,
|
|
12
|
+
Ruler,
|
|
13
|
+
ListOrdered,
|
|
14
|
+
Clock,
|
|
15
|
+
FileText,
|
|
16
|
+
Film
|
|
17
|
+
} from "lucide-react";
|
|
3
18
|
const CHECK_ICONS = {
|
|
4
19
|
// keyphrase (SeoAssessor)
|
|
5
20
|
introductionKeyword: AlignLeft,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/icons.tsx"],"sourcesContent":["\"use client\";\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/components/icons.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n AlignLeft,\n Crosshair,\n Mail,\n Link2,\n BarChart3,\n Type,\n ArrowRight,\n Image as ImageIcon,\n Heading1,\n Ruler,\n ListOrdered,\n Clock,\n FileText,\n Film,\n} from \"lucide-react\";\nimport type { LucideIcon } from \"lucide-react\";\n\ntype CheckIconsMap = Record<string, LucideIcon> & {\n _default: LucideIcon;\n};\n\nexport const CHECK_ICONS: CheckIconsMap = {\n // keyphrase (SeoAssessor)\n introductionKeyword: AlignLeft,\n keyphraseLength: Crosshair,\n keyphraseDensity: Crosshair,\n metaDescriptionKeyword: Mail,\n subheadingsKeyword: Type,\n textCompetingLinks: Link2,\n imageKeyphrase: ImageIcon,\n keyphraseInSEOTitle: Type,\n slugKeyword: ArrowRight,\n keyphraseDistribution: BarChart3,\n // on-page (SeoAssessor)\n textLength: AlignLeft,\n metaDescriptionLength: Mail,\n titleWidth: Ruler,\n images: ImageIcon,\n externalLinks: Link2,\n internalLinks: Link2,\n singleH1: Heading1,\n // readability (ContentAssessor)\n fleschReadingEase: FileText,\n subheadingsTooLong: Heading1,\n textParagraphTooLong: AlignLeft,\n textSentenceLength: AlignLeft,\n textTransitionWords: ArrowRight,\n passiveVoice: FileText,\n sentenceBeginnings: AlignLeft,\n listPresence: ListOrdered,\n // vitals\n readingTime: Clock,\n videoCount: Film,\n _default: FileText,\n};\n"],"mappings":";AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAOA,MAAM,cAA6B;AAAA;AAAA,EAExC,qBAAqB;AAAA,EACrB,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,EAClB,wBAAwB;AAAA,EACxB,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,gBAAgB;AAAA,EAChB,qBAAqB;AAAA,EACrB,aAAa;AAAA,EACb,uBAAuB;AAAA;AAAA,EAEvB,YAAY;AAAA,EACZ,uBAAuB;AAAA,EACvB,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,eAAe;AAAA,EACf,eAAe;AAAA,EACf,UAAU;AAAA;AAAA,EAEV,mBAAmB;AAAA,EACnB,oBAAoB;AAAA,EACpB,sBAAsB;AAAA,EACtB,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,cAAc;AAAA;AAAA,EAEd,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,UAAU;AACZ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkIds.d.ts","sourceRoot":"","sources":["../../src/constants/checkIds.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;;;;
|
|
1
|
+
{"version":3,"file":"checkIds.d.ts","sourceRoot":"","sources":["../../src/constants/checkIds.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;;;;CAgCZ,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,MAAM,OAAO,SAAS,CAAC;AAC9C,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -12,8 +12,24 @@ const CHECK_IDS = {
|
|
|
12
12
|
"functionWordsInKeyphrase",
|
|
13
13
|
"keyphraseDistribution"
|
|
14
14
|
],
|
|
15
|
-
onPage: [
|
|
16
|
-
|
|
15
|
+
onPage: [
|
|
16
|
+
"textLength",
|
|
17
|
+
"metaDescriptionLength",
|
|
18
|
+
"titleWidth",
|
|
19
|
+
"images",
|
|
20
|
+
"externalLinks",
|
|
21
|
+
"internalLinks",
|
|
22
|
+
"singleH1"
|
|
23
|
+
],
|
|
24
|
+
readability: [
|
|
25
|
+
"subheadingsTooLong",
|
|
26
|
+
"textParagraphTooLong",
|
|
27
|
+
"textSentenceLength",
|
|
28
|
+
"textTransitionWords",
|
|
29
|
+
"passiveVoice",
|
|
30
|
+
"sentenceBeginnings",
|
|
31
|
+
"fleschReadingEase"
|
|
32
|
+
]
|
|
17
33
|
};
|
|
18
34
|
export {
|
|
19
35
|
CHECK_IDS
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/constants/checkIds.ts"],"sourcesContent":["export const CHECK_IDS = {\n keyphrase: [\n \"introductionKeyword\",\n \"keyphraseLength\",\n \"keyphraseDensity\",\n \"metaDescriptionKeyword\",\n \"subheadingsKeyword\",\n \"textCompetingLinks\",\n \"imageKeyphrase\",\n \"keyphraseInSEOTitle\",\n \"slugKeyword\",\n \"functionWordsInKeyphrase\",\n \"keyphraseDistribution\",\n ],\n onPage: [\"textLength\"
|
|
1
|
+
{"version":3,"sources":["../../src/constants/checkIds.ts"],"sourcesContent":["export const CHECK_IDS = {\n keyphrase: [\n \"introductionKeyword\",\n \"keyphraseLength\",\n \"keyphraseDensity\",\n \"metaDescriptionKeyword\",\n \"subheadingsKeyword\",\n \"textCompetingLinks\",\n \"imageKeyphrase\",\n \"keyphraseInSEOTitle\",\n \"slugKeyword\",\n \"functionWordsInKeyphrase\",\n \"keyphraseDistribution\",\n ],\n onPage: [\n \"textLength\",\n \"metaDescriptionLength\",\n \"titleWidth\",\n \"images\",\n \"externalLinks\",\n \"internalLinks\",\n \"singleH1\",\n ],\n readability: [\n \"subheadingsTooLong\",\n \"textParagraphTooLong\",\n \"textSentenceLength\",\n \"textTransitionWords\",\n \"passiveVoice\",\n \"sentenceBeginnings\",\n \"fleschReadingEase\",\n ],\n} as const;\n\nexport type CheckTab = keyof typeof CHECK_IDS;\nexport type CheckId = (typeof CHECK_IDS)[CheckTab][number];\n"],"mappings":"AAAO,MAAM,YAAY;AAAA,EACvB,WAAW;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,QAAQ;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,aAAa;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { heading, paragraph, link, image, video, richText, html, compact } from "./schema/helpers";
|
|
2
|
+
export type { ContentNode, HeadingLevel } from "./schema/nodes";
|
|
3
|
+
export { registerContentExtractors, resolveContentExtractor } from "./registry";
|
|
4
|
+
export type { ContentExtractor, ExtractContext, ExtractToolkit, DocQuery, DocStore, ContentHelpers, } from "../types/config";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/content/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACnG,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAChF,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,cAAc,GACf,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { heading, paragraph, link, image, video, richText, html, compact } from "./schema/helpers";
|
|
2
|
+
import { registerContentExtractors, resolveContentExtractor } from "./registry";
|
|
3
|
+
export {
|
|
4
|
+
compact,
|
|
5
|
+
heading,
|
|
6
|
+
html,
|
|
7
|
+
image,
|
|
8
|
+
link,
|
|
9
|
+
paragraph,
|
|
10
|
+
registerContentExtractors,
|
|
11
|
+
resolveContentExtractor,
|
|
12
|
+
richText,
|
|
13
|
+
video
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/content/index.ts"],"sourcesContent":["export { heading, paragraph, link, image, video, richText, html, compact } from \"./schema/helpers\";\nexport type { ContentNode, HeadingLevel } from \"./schema/nodes\";\nexport { registerContentExtractors, resolveContentExtractor } from \"./registry\";\nexport type {\n ContentExtractor,\n ExtractContext,\n ExtractToolkit,\n DocQuery,\n DocStore,\n ContentHelpers,\n} from \"../types/config\";\n"],"mappings":"AAAA,SAAS,SAAS,WAAW,MAAM,OAAO,OAAO,UAAU,MAAM,eAAe;AAEhF,SAAS,2BAA2B,+BAA+B;","names":[]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ContentExtractor } from "../types/config";
|
|
2
|
+
export declare function registerContentExtractors(map: Record<string, ContentExtractor>): void;
|
|
3
|
+
export declare function resolveContentExtractor(key: string | null | undefined): ContentExtractor | undefined;
|
|
4
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/content/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAYxD,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAAG,IAAI,CAIrF;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,gBAAgB,GAAG,SAAS,CAIpG"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const STORE_KEY = "__FR_SEO_CONTENT_EXTRACTORS__";
|
|
2
|
+
function store() {
|
|
3
|
+
const g = globalThis;
|
|
4
|
+
if (!(g[STORE_KEY] instanceof Map))
|
|
5
|
+
g[STORE_KEY] = /* @__PURE__ */ new Map();
|
|
6
|
+
return g[STORE_KEY];
|
|
7
|
+
}
|
|
8
|
+
function registerContentExtractors(map) {
|
|
9
|
+
const s = store();
|
|
10
|
+
for (const [key, fn] of Object.entries(map))
|
|
11
|
+
s.set(key, fn);
|
|
12
|
+
}
|
|
13
|
+
function resolveContentExtractor(key) {
|
|
14
|
+
if (!key)
|
|
15
|
+
return void 0;
|
|
16
|
+
return store().get(key);
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
registerContentExtractors,
|
|
20
|
+
resolveContentExtractor
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/content/registry.ts"],"sourcesContent":["import type { ContentExtractor } from \"../types/config\";\n\nconst STORE_KEY = \"__FR_SEO_CONTENT_EXTRACTORS__\";\n\nfunction store(): Map<string, ContentExtractor> {\n const g = globalThis as Record<string, unknown>;\n\n if (!(g[STORE_KEY] instanceof Map)) g[STORE_KEY] = new Map<string, ContentExtractor>();\n\n return g[STORE_KEY] as Map<string, ContentExtractor>;\n}\n\nexport function registerContentExtractors(map: Record<string, ContentExtractor>): void {\n const s = store();\n\n for (const [key, fn] of Object.entries(map)) s.set(key, fn);\n}\n\nexport function resolveContentExtractor(key: string | null | undefined): ContentExtractor | undefined {\n if (!key) return undefined;\n\n return store().get(key);\n}\n"],"mappings":"AAEA,MAAM,YAAY;AAElB,SAAS,QAAuC;AAC9C,QAAM,IAAI;AAEV,MAAI,EAAE,EAAE,SAAS,aAAa;AAAM,MAAE,SAAS,IAAI,oBAAI,IAA8B;AAErF,SAAO,EAAE,SAAS;AACpB;AAEO,SAAS,0BAA0B,KAA6C;AACrF,QAAM,IAAI,MAAM;AAEhB,aAAW,CAAC,KAAK,EAAE,KAAK,OAAO,QAAQ,GAAG;AAAG,MAAE,IAAI,KAAK,EAAE;AAC5D;AAEO,SAAS,wBAAwB,KAA8D;AACpG,MAAI,CAAC;AAAK,WAAO;AAEjB,SAAO,MAAM,EAAE,IAAI,GAAG;AACxB;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-docs.d.ts","sourceRoot":"","sources":["../../../src/content/resolve/resolve-docs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAkD7D,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,OAAO,CAAC,QAAQ,CAAC,CAc5C"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
function key(collection, id) {
|
|
2
|
+
return `${collection}:${id}`;
|
|
3
|
+
}
|
|
4
|
+
async function fetchQuery(apiRoute, query, locale) {
|
|
5
|
+
const ids = [...new Set(query.ids.map(String))];
|
|
6
|
+
if (ids.length === 0)
|
|
7
|
+
return [];
|
|
8
|
+
const params = new URLSearchParams({
|
|
9
|
+
depth: String(query.depth ?? 0),
|
|
10
|
+
limit: String(ids.length)
|
|
11
|
+
});
|
|
12
|
+
if (locale)
|
|
13
|
+
params.set("locale", locale);
|
|
14
|
+
ids.forEach((id, i) => params.set(`where[id][in][${i}]`, id));
|
|
15
|
+
for (const field of query.select ?? [])
|
|
16
|
+
params.set(`select[${field}]`, "true");
|
|
17
|
+
try {
|
|
18
|
+
const res = await fetch(`${apiRoute}/${query.collection}?${params.toString()}`, {
|
|
19
|
+
credentials: "include"
|
|
20
|
+
});
|
|
21
|
+
if (!res.ok)
|
|
22
|
+
return [];
|
|
23
|
+
const body = await res.json();
|
|
24
|
+
return (body.docs ?? []).filter(
|
|
25
|
+
(d) => typeof d.id === "string" || typeof d.id === "number"
|
|
26
|
+
).map((d) => [key(query.collection, d.id), d]);
|
|
27
|
+
} catch {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function createResolveDocs(apiRoute, locale) {
|
|
32
|
+
return async function resolveDocs(queries) {
|
|
33
|
+
const store = /* @__PURE__ */ new Map();
|
|
34
|
+
if (apiRoute) {
|
|
35
|
+
const results = await Promise.all(queries.map((q) => fetchQuery(apiRoute, q, locale)));
|
|
36
|
+
for (const entries of results)
|
|
37
|
+
for (const [k, doc] of entries)
|
|
38
|
+
store.set(k, doc);
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
get: (collection, id) => store.get(key(collection, id))
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
createResolveDocs
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=resolve-docs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/content/resolve/resolve-docs.ts"],"sourcesContent":["import type { DocQuery, DocStore } from \"../../types/config\";\n\ntype Doc = Record<string, unknown>;\n\ninterface FindResponse {\n docs?: Array<Doc & { id?: unknown }>;\n}\n\nfunction key(collection: string, id: string | number): string {\n return `${collection}:${id}`;\n}\n\nasync function fetchQuery(\n apiRoute: string,\n query: DocQuery,\n locale: string | undefined\n): Promise<Array<[string, Doc]>> {\n const ids = [...new Set(query.ids.map(String))];\n if (ids.length === 0) return [];\n\n const params = new URLSearchParams({\n depth: String(query.depth ?? 0),\n limit: String(ids.length),\n });\n\n if (locale) params.set(\"locale\", locale);\n\n ids.forEach((id, i) => params.set(`where[id][in][${i}]`, id));\n\n for (const field of query.select ?? []) params.set(`select[${field}]`, \"true\");\n\n try {\n const res = await fetch(`${apiRoute}/${query.collection}?${params.toString()}`, {\n credentials: \"include\",\n });\n if (!res.ok) return [];\n\n const body = (await res.json()) as FindResponse;\n\n return (body.docs ?? [])\n .filter(\n (d): d is Doc & { id: string | number } =>\n typeof d.id === \"string\" || typeof d.id === \"number\"\n )\n .map((d) => [key(query.collection, d.id), d] as [string, Doc]);\n } catch {\n return [];\n }\n}\n\nexport function createResolveDocs(\n apiRoute: string | undefined,\n locale: string | undefined\n): (queries: DocQuery[]) => Promise<DocStore> {\n return async function resolveDocs(queries: DocQuery[]): Promise<DocStore> {\n const store = new Map<string, Doc>();\n\n if (apiRoute) {\n const results = await Promise.all(queries.map((q) => fetchQuery(apiRoute, q, locale)));\n\n for (const entries of results) for (const [k, doc] of entries) store.set(k, doc);\n }\n\n return {\n get: (collection, id) => store.get(key(collection, id)),\n };\n };\n}\n"],"mappings":"AAQA,SAAS,IAAI,YAAoB,IAA6B;AAC5D,SAAO,GAAG,UAAU,IAAI,EAAE;AAC5B;AAEA,eAAe,WACb,UACA,OACA,QAC+B;AAC/B,QAAM,MAAM,CAAC,GAAG,IAAI,IAAI,MAAM,IAAI,IAAI,MAAM,CAAC,CAAC;AAC9C,MAAI,IAAI,WAAW;AAAG,WAAO,CAAC;AAE9B,QAAM,SAAS,IAAI,gBAAgB;AAAA,IACjC,OAAO,OAAO,MAAM,SAAS,CAAC;AAAA,IAC9B,OAAO,OAAO,IAAI,MAAM;AAAA,EAC1B,CAAC;AAED,MAAI;AAAQ,WAAO,IAAI,UAAU,MAAM;AAEvC,MAAI,QAAQ,CAAC,IAAI,MAAM,OAAO,IAAI,iBAAiB,CAAC,KAAK,EAAE,CAAC;AAE5D,aAAW,SAAS,MAAM,UAAU,CAAC;AAAG,WAAO,IAAI,UAAU,KAAK,KAAK,MAAM;AAE7E,MAAI;AACF,UAAM,MAAM,MAAM,MAAM,GAAG,QAAQ,IAAI,MAAM,UAAU,IAAI,OAAO,SAAS,CAAC,IAAI;AAAA,MAC9E,aAAa;AAAA,IACf,CAAC;AACD,QAAI,CAAC,IAAI;AAAI,aAAO,CAAC;AAErB,UAAM,OAAQ,MAAM,IAAI,KAAK;AAE7B,YAAQ,KAAK,QAAQ,CAAC,GACnB;AAAA,MACC,CAAC,MACC,OAAO,EAAE,OAAO,YAAY,OAAO,EAAE,OAAO;AAAA,IAChD,EACC,IAAI,CAAC,MAAM,CAAC,IAAI,MAAM,YAAY,EAAE,EAAE,GAAG,CAAC,CAAkB;AAAA,EACjE,QAAQ;AACN,WAAO,CAAC;AAAA,EACV;AACF;AAEO,SAAS,kBACd,UACA,QAC4C;AAC5C,SAAO,eAAe,YAAY,SAAwC;AACxE,UAAM,QAAQ,oBAAI,IAAiB;AAEnC,QAAI,UAAU;AACZ,YAAM,UAAU,MAAM,QAAQ,IAAI,QAAQ,IAAI,CAAC,MAAM,WAAW,UAAU,GAAG,MAAM,CAAC,CAAC;AAErF,iBAAW,WAAW;AAAS,mBAAW,CAAC,GAAG,GAAG,KAAK;AAAS,gBAAM,IAAI,GAAG,GAAG;AAAA,IACjF;AAEA,WAAO;AAAA,MACL,KAAK,CAAC,YAAY,OAAO,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;AAAA,IACxD;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ContentNode, HeadingLevel } from "./nodes";
|
|
2
|
+
export declare function heading(level: HeadingLevel, text?: string | null): ContentNode | null;
|
|
3
|
+
export declare function paragraph(text?: string | null): ContentNode | null;
|
|
4
|
+
export declare function link(href?: string | null, text?: string | null): ContentNode | null;
|
|
5
|
+
export declare function image(src?: string | null, alt?: string | null): ContentNode | null;
|
|
6
|
+
export declare function video(src?: string | null, poster?: string | null): ContentNode | null;
|
|
7
|
+
export declare function richText(value: unknown): ContentNode | null;
|
|
8
|
+
export declare function html(raw?: string | null): ContentNode | null;
|
|
9
|
+
export declare function compact(nodes: (ContentNode | null | undefined)[]): ContentNode[];
|
|
10
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/content/schema/helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAQzD,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI,CAGrF;AAED,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI,CAGlE;AAED,wBAAgB,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI,CAInF;AAED,wBAAgB,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI,CAGlF;AAED,wBAAgB,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI,CAKrF;AAUD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAI3D;AAED,wBAAgB,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI,CAG5D;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,CAAC,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAAG,WAAW,EAAE,CAEhF"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { lexicalToHtml } from "../lexicalToHtml";
|
|
2
|
+
function clean(v) {
|
|
3
|
+
if (typeof v !== "string")
|
|
4
|
+
return void 0;
|
|
5
|
+
const t = v.trim();
|
|
6
|
+
return t ? v : void 0;
|
|
7
|
+
}
|
|
8
|
+
function heading(level, text) {
|
|
9
|
+
const t = clean(text);
|
|
10
|
+
return t ? { type: "heading", level, text: t } : null;
|
|
11
|
+
}
|
|
12
|
+
function paragraph(text) {
|
|
13
|
+
const t = clean(text);
|
|
14
|
+
return t ? { type: "paragraph", text: t } : null;
|
|
15
|
+
}
|
|
16
|
+
function link(href, text) {
|
|
17
|
+
const h = clean(href);
|
|
18
|
+
const t = clean(text);
|
|
19
|
+
return h && t ? { type: "link", href: h, text: t } : null;
|
|
20
|
+
}
|
|
21
|
+
function image(src, alt) {
|
|
22
|
+
const s = clean(src);
|
|
23
|
+
return s ? { type: "image", src: s, alt: clean(alt) ?? "" } : null;
|
|
24
|
+
}
|
|
25
|
+
function video(src, poster) {
|
|
26
|
+
const s = clean(src);
|
|
27
|
+
if (!s)
|
|
28
|
+
return null;
|
|
29
|
+
const p = clean(poster);
|
|
30
|
+
return p ? { type: "video", src: s, poster: p } : { type: "video", src: s };
|
|
31
|
+
}
|
|
32
|
+
function hasLexicalContent(value) {
|
|
33
|
+
if (typeof value !== "object" || value === null)
|
|
34
|
+
return false;
|
|
35
|
+
const root = value.root;
|
|
36
|
+
if (typeof root !== "object" || root === null)
|
|
37
|
+
return false;
|
|
38
|
+
const children = root.children;
|
|
39
|
+
return Array.isArray(children) && children.length > 0;
|
|
40
|
+
}
|
|
41
|
+
function richText(value) {
|
|
42
|
+
if (!hasLexicalContent(value))
|
|
43
|
+
return null;
|
|
44
|
+
const out = lexicalToHtml(value);
|
|
45
|
+
return out ? { type: "html", html: out } : null;
|
|
46
|
+
}
|
|
47
|
+
function html(raw) {
|
|
48
|
+
const r = clean(raw);
|
|
49
|
+
return r ? { type: "html", html: r } : null;
|
|
50
|
+
}
|
|
51
|
+
function compact(nodes) {
|
|
52
|
+
return nodes.filter((n) => n != null);
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
compact,
|
|
56
|
+
heading,
|
|
57
|
+
html,
|
|
58
|
+
image,
|
|
59
|
+
link,
|
|
60
|
+
paragraph,
|
|
61
|
+
richText,
|
|
62
|
+
video
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/content/schema/helpers.ts"],"sourcesContent":["import { lexicalToHtml } from \"../lexicalToHtml\";\nimport type { ContentNode, HeadingLevel } from \"./nodes\";\n\nfunction clean(v?: string | null): string | undefined {\n if (typeof v !== \"string\") return undefined;\n const t = v.trim();\n return t ? v : undefined;\n}\n\nexport function heading(level: HeadingLevel, text?: string | null): ContentNode | null {\n const t = clean(text);\n return t ? { type: \"heading\", level, text: t } : null;\n}\n\nexport function paragraph(text?: string | null): ContentNode | null {\n const t = clean(text);\n return t ? { type: \"paragraph\", text: t } : null;\n}\n\nexport function link(href?: string | null, text?: string | null): ContentNode | null {\n const h = clean(href);\n const t = clean(text);\n return h && t ? { type: \"link\", href: h, text: t } : null;\n}\n\nexport function image(src?: string | null, alt?: string | null): ContentNode | null {\n const s = clean(src);\n return s ? { type: \"image\", src: s, alt: clean(alt) ?? \"\" } : null;\n}\n\nexport function video(src?: string | null, poster?: string | null): ContentNode | null {\n const s = clean(src);\n if (!s) return null;\n const p = clean(poster);\n return p ? { type: \"video\", src: s, poster: p } : { type: \"video\", src: s };\n}\n\nfunction hasLexicalContent(value: unknown): boolean {\n if (typeof value !== \"object\" || value === null) return false;\n const root = (value as Record<string, unknown>).root;\n if (typeof root !== \"object\" || root === null) return false;\n const children = (root as Record<string, unknown>).children;\n return Array.isArray(children) && children.length > 0;\n}\n\nexport function richText(value: unknown): ContentNode | null {\n if (!hasLexicalContent(value)) return null;\n const out = lexicalToHtml(value as never);\n return out ? { type: \"html\", html: out } : null;\n}\n\nexport function html(raw?: string | null): ContentNode | null {\n const r = clean(raw);\n return r ? { type: \"html\", html: r } : null;\n}\n\nexport function compact(nodes: (ContentNode | null | undefined)[]): ContentNode[] {\n return nodes.filter((n): n is ContentNode => n != null);\n}\n"],"mappings":"AAAA,SAAS,qBAAqB;AAG9B,SAAS,MAAM,GAAuC;AACpD,MAAI,OAAO,MAAM;AAAU,WAAO;AAClC,QAAM,IAAI,EAAE,KAAK;AACjB,SAAO,IAAI,IAAI;AACjB;AAEO,SAAS,QAAQ,OAAqB,MAA0C;AACrF,QAAM,IAAI,MAAM,IAAI;AACpB,SAAO,IAAI,EAAE,MAAM,WAAW,OAAO,MAAM,EAAE,IAAI;AACnD;AAEO,SAAS,UAAU,MAA0C;AAClE,QAAM,IAAI,MAAM,IAAI;AACpB,SAAO,IAAI,EAAE,MAAM,aAAa,MAAM,EAAE,IAAI;AAC9C;AAEO,SAAS,KAAK,MAAsB,MAA0C;AACnF,QAAM,IAAI,MAAM,IAAI;AACpB,QAAM,IAAI,MAAM,IAAI;AACpB,SAAO,KAAK,IAAI,EAAE,MAAM,QAAQ,MAAM,GAAG,MAAM,EAAE,IAAI;AACvD;AAEO,SAAS,MAAM,KAAqB,KAAyC;AAClF,QAAM,IAAI,MAAM,GAAG;AACnB,SAAO,IAAI,EAAE,MAAM,SAAS,KAAK,GAAG,KAAK,MAAM,GAAG,KAAK,GAAG,IAAI;AAChE;AAEO,SAAS,MAAM,KAAqB,QAA4C;AACrF,QAAM,IAAI,MAAM,GAAG;AACnB,MAAI,CAAC;AAAG,WAAO;AACf,QAAM,IAAI,MAAM,MAAM;AACtB,SAAO,IAAI,EAAE,MAAM,SAAS,KAAK,GAAG,QAAQ,EAAE,IAAI,EAAE,MAAM,SAAS,KAAK,EAAE;AAC5E;AAEA,SAAS,kBAAkB,OAAyB;AAClD,MAAI,OAAO,UAAU,YAAY,UAAU;AAAM,WAAO;AACxD,QAAM,OAAQ,MAAkC;AAChD,MAAI,OAAO,SAAS,YAAY,SAAS;AAAM,WAAO;AACtD,QAAM,WAAY,KAAiC;AACnD,SAAO,MAAM,QAAQ,QAAQ,KAAK,SAAS,SAAS;AACtD;AAEO,SAAS,SAAS,OAAoC;AAC3D,MAAI,CAAC,kBAAkB,KAAK;AAAG,WAAO;AACtC,QAAM,MAAM,cAAc,KAAc;AACxC,SAAO,MAAM,EAAE,MAAM,QAAQ,MAAM,IAAI,IAAI;AAC7C;AAEO,SAAS,KAAK,KAAyC;AAC5D,QAAM,IAAI,MAAM,GAAG;AACnB,SAAO,IAAI,EAAE,MAAM,QAAQ,MAAM,EAAE,IAAI;AACzC;AAEO,SAAS,QAAQ,OAA0D;AAChF,SAAO,MAAM,OAAO,CAAC,MAAwB,KAAK,IAAI;AACxD;","names":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
2
|
+
export type ContentNode = {
|
|
3
|
+
type: "heading";
|
|
4
|
+
level: HeadingLevel;
|
|
5
|
+
text: string;
|
|
6
|
+
} | {
|
|
7
|
+
type: "paragraph";
|
|
8
|
+
text: string;
|
|
9
|
+
} | {
|
|
10
|
+
type: "link";
|
|
11
|
+
href: string;
|
|
12
|
+
text: string;
|
|
13
|
+
} | {
|
|
14
|
+
type: "image";
|
|
15
|
+
src: string;
|
|
16
|
+
alt?: string;
|
|
17
|
+
} | {
|
|
18
|
+
type: "video";
|
|
19
|
+
src: string;
|
|
20
|
+
poster?: string;
|
|
21
|
+
} | {
|
|
22
|
+
type: "html";
|
|
23
|
+
html: string;
|
|
24
|
+
};
|
|
25
|
+
export declare function isContentNode(value: unknown): value is ContentNode;
|
|
26
|
+
//# sourceMappingURL=nodes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../../src/content/schema/nodes.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEjD,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACtD;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC5C;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAC5C;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/C;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAInC,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAElE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const TYPES = /* @__PURE__ */ new Set(["heading", "paragraph", "link", "image", "video", "html"]);
|
|
2
|
+
function isContentNode(value) {
|
|
3
|
+
return typeof value === "object" && value !== null && TYPES.has(value.type ?? "");
|
|
4
|
+
}
|
|
5
|
+
export {
|
|
6
|
+
isContentNode
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=nodes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/content/schema/nodes.ts"],"sourcesContent":["export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;\n\nexport type ContentNode =\n | { type: \"heading\"; level: HeadingLevel; text: string }\n | { type: \"paragraph\"; text: string }\n | { type: \"link\"; href: string; text: string }\n | { type: \"image\"; src: string; alt?: string }\n | { type: \"video\"; src: string; poster?: string }\n | { type: \"html\"; html: string };\n\nconst TYPES = new Set([\"heading\", \"paragraph\", \"link\", \"image\", \"video\", \"html\"]);\n\nexport function isContentNode(value: unknown): value is ContentNode {\n return typeof value === \"object\" && value !== null && TYPES.has((value as { type?: string }).type ?? \"\");\n}\n"],"mappings":"AAUA,MAAM,QAAQ,oBAAI,IAAI,CAAC,WAAW,aAAa,QAAQ,SAAS,SAAS,MAAM,CAAC;AAEzE,SAAS,cAAc,OAAsC;AAClE,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,IAAK,MAA4B,QAAQ,EAAE;AACzG;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../src/content/schema/serialize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AA6B3C,wBAAgB,SAAS,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,MAAM,CAEtD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
function escapeText(s) {
|
|
2
|
+
return s.replace(/&/gu, "&").replace(/</gu, "<").replace(/>/gu, ">");
|
|
3
|
+
}
|
|
4
|
+
function escapeAttr(s) {
|
|
5
|
+
return s.replace(/&/gu, "&").replace(/</gu, "<").replace(/>/gu, ">").replace(/"/gu, """);
|
|
6
|
+
}
|
|
7
|
+
function serializeNode(node) {
|
|
8
|
+
switch (node.type) {
|
|
9
|
+
case "heading":
|
|
10
|
+
return `<h${node.level}>${escapeText(node.text)}</h${node.level}>`;
|
|
11
|
+
case "paragraph":
|
|
12
|
+
return `<p>${escapeText(node.text)}</p>`;
|
|
13
|
+
case "link":
|
|
14
|
+
return `<a href="${escapeAttr(node.href)}">${escapeText(node.text)}</a>`;
|
|
15
|
+
case "image":
|
|
16
|
+
return `<img src="${escapeAttr(node.src)}" alt="${escapeAttr(node.alt ?? "")}" />`;
|
|
17
|
+
case "video":
|
|
18
|
+
return node.poster ? `<video src="${escapeAttr(node.src)}" poster="${escapeAttr(node.poster)}"></video>` : `<video src="${escapeAttr(node.src)}"></video>`;
|
|
19
|
+
case "html":
|
|
20
|
+
return node.html;
|
|
21
|
+
default:
|
|
22
|
+
return "";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function serialize(nodes) {
|
|
26
|
+
return nodes.map(serializeNode).filter(Boolean).join("\n");
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
serialize
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=serialize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/content/schema/serialize.ts"],"sourcesContent":["import type { ContentNode } from \"./nodes\";\n\nfunction escapeText(s: string): string {\n return s.replace(/&/gu, \"&\").replace(/</gu, \"<\").replace(/>/gu, \">\");\n}\n\nfunction escapeAttr(s: string): string {\n return s.replace(/&/gu, \"&\").replace(/</gu, \"<\").replace(/>/gu, \">\").replace(/\"/gu, \""\");\n}\n\nfunction serializeNode(node: ContentNode): string {\n switch (node.type) {\n case \"heading\":\n return `<h${node.level}>${escapeText(node.text)}</h${node.level}>`;\n case \"paragraph\":\n return `<p>${escapeText(node.text)}</p>`;\n case \"link\":\n return `<a href=\"${escapeAttr(node.href)}\">${escapeText(node.text)}</a>`;\n case \"image\":\n return `<img src=\"${escapeAttr(node.src)}\" alt=\"${escapeAttr(node.alt ?? \"\")}\" />`;\n case \"video\":\n return node.poster ? `<video src=\"${escapeAttr(node.src)}\" poster=\"${escapeAttr(node.poster)}\"></video>` : `<video src=\"${escapeAttr(node.src)}\"></video>`;\n case \"html\":\n return node.html;\n default:\n return \"\";\n }\n}\n\nexport function serialize(nodes: ContentNode[]): string {\n return nodes.map(serializeNode).filter(Boolean).join(\"\\n\");\n}\n"],"mappings":"AAEA,SAAS,WAAW,GAAmB;AACrC,SAAO,EAAE,QAAQ,OAAO,OAAO,EAAE,QAAQ,OAAO,MAAM,EAAE,QAAQ,OAAO,MAAM;AAC/E;AAEA,SAAS,WAAW,GAAmB;AACrC,SAAO,EAAE,QAAQ,OAAO,OAAO,EAAE,QAAQ,OAAO,MAAM,EAAE,QAAQ,OAAO,MAAM,EAAE,QAAQ,OAAO,QAAQ;AACxG;AAEA,SAAS,cAAc,MAA2B;AAChD,UAAQ,KAAK,MAAM;AAAA,IACjB,KAAK;AACH,aAAO,KAAK,KAAK,KAAK,IAAI,WAAW,KAAK,IAAI,CAAC,MAAM,KAAK,KAAK;AAAA,IACjE,KAAK;AACH,aAAO,MAAM,WAAW,KAAK,IAAI,CAAC;AAAA,IACpC,KAAK;AACH,aAAO,YAAY,WAAW,KAAK,IAAI,CAAC,KAAK,WAAW,KAAK,IAAI,CAAC;AAAA,IACpE,KAAK;AACH,aAAO,aAAa,WAAW,KAAK,GAAG,CAAC,UAAU,WAAW,KAAK,OAAO,EAAE,CAAC;AAAA,IAC9E,KAAK;AACH,aAAO,KAAK,SAAS,eAAe,WAAW,KAAK,GAAG,CAAC,aAAa,WAAW,KAAK,MAAM,CAAC,eAAe,eAAe,WAAW,KAAK,GAAG,CAAC;AAAA,IAChJ,KAAK;AACH,aAAO,KAAK;AAAA,IACd;AACE,aAAO;AAAA,EACX;AACF;AAEO,SAAS,UAAU,OAA8B;AACtD,SAAO,MAAM,IAAI,aAAa,EAAE,OAAO,OAAO,EAAE,KAAK,IAAI;AAC3D;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assessorAdapter.d.ts","sourceRoot":"","sources":["../../src/engine/assessorAdapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,UAAU,qBAAqB;IAC7B,aAAa,CAAC,EAAE,MAAM,MAAM,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf;AACD,UAAU,aAAa;IACrB,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACjC,eAAe,EAAE,MAAM,qBAAqB,EAAE,CAAC;CAChD;AAMD,wBAAgB,WAAW,
|
|
1
|
+
{"version":3,"file":"assessorAdapter.d.ts","sourceRoot":"","sources":["../../src/engine/assessorAdapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,UAAU,qBAAqB;IAC7B,aAAa,CAAC,EAAE,MAAM,MAAM,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf;AACD,UAAU,aAAa;IACrB,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACjC,eAAe,EAAE,MAAM,qBAAqB,EAAE,CAAC;CAChD;AAMD,wBAAgB,WAAW,CACzB,QAAQ,EAAE,aAAa,EACvB,GAAG,EAAE,WAAW,EAChB,KAAK,CAAC,EAAE,OAAO,GACd,WAAW,EAAE,CAef"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/engine/assessorAdapter.ts"],"sourcesContent":["import { getRecommendation } from \"./recommendations\";\nimport type { RecoContext } from \"./recommendations\";\nimport { scoreToStatus } from \"./scoreStatus\";\nimport type { CheckResult } from \"./types/analysis\";\n\ninterface YoastAssessmentResult {\n getIdentifier?: () => string;\n _identifier?: string;\n score: number;\n}\ninterface YoastAssessor {\n assess: (paper: unknown) => void;\n getValidResults: () => YoastAssessmentResult[];\n}\n\nfunction identifierOf(r: YoastAssessmentResult): string {\n return r.getIdentifier?.() ?? r._identifier ?? \"unknown\";\n}\n\nexport function runAssessor(assessor: YoastAssessor
|
|
1
|
+
{"version":3,"sources":["../../src/engine/assessorAdapter.ts"],"sourcesContent":["import { getRecommendation } from \"./recommendations\";\nimport type { RecoContext } from \"./recommendations\";\nimport { scoreToStatus } from \"./scoreStatus\";\nimport type { CheckResult } from \"./types/analysis\";\n\ninterface YoastAssessmentResult {\n getIdentifier?: () => string;\n _identifier?: string;\n score: number;\n}\ninterface YoastAssessor {\n assess: (paper: unknown) => void;\n getValidResults: () => YoastAssessmentResult[];\n}\n\nfunction identifierOf(r: YoastAssessmentResult): string {\n return r.getIdentifier?.() ?? r._identifier ?? \"unknown\";\n}\n\nexport function runAssessor(\n assessor: YoastAssessor,\n ctx: RecoContext,\n paper?: unknown\n): CheckResult[] {\n assessor.assess(paper);\n\n return assessor.getValidResults().map((result) => {\n const id = identifierOf(result);\n const status = scoreToStatus(result.score);\n\n return {\n id,\n score: result.score,\n status,\n recommendation: getRecommendation(id, status, ctx),\n data: undefined,\n };\n });\n}\n"],"mappings":"AAAA,SAAS,yBAAyB;AAElC,SAAS,qBAAqB;AAa9B,SAAS,aAAa,GAAkC;AACtD,SAAO,EAAE,gBAAgB,KAAK,EAAE,eAAe;AACjD;AAEO,SAAS,YACd,UACA,KACA,OACe;AACf,WAAS,OAAO,KAAK;AAErB,SAAO,SAAS,gBAAgB,EAAE,IAAI,CAAC,WAAW;AAChD,UAAM,KAAK,aAAa,MAAM;AAC9B,UAAM,SAAS,cAAc,OAAO,KAAK;AAEzC,WAAO;AAAA,MACL;AAAA,MACA,OAAO,OAAO;AAAA,MACd;AAAA,MACA,gBAAgB,kBAAkB,IAAI,QAAQ,GAAG;AAAA,MACjD,MAAM;AAAA,IACR;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractCheckData.d.ts","sourceRoot":"","sources":["../../src/engine/extractCheckData.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"extractCheckData.d.ts","sourceRoot":"","sources":["../../src/engine/extractCheckData.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AA4C/C,wBAAgB,gBAAgB,CAC9B,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,SAAS,EAChB,UAAU,EAAE,eAAe,GAC1B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAiJrC"}
|