vlite3 1.4.16 → 1.4.17

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.
Files changed (26) hide show
  1. package/components/CategoryManager/CategoryManager.vue2.js +3 -3
  2. package/components/ColorPicker/ColorIro.vue3.js +2 -2
  3. package/components/ColorPicker/ColorPicker.vue.js +2 -2
  4. package/components/Dropdown/DropdownMenu.vue.js +1 -1
  5. package/components/RichTextEditor/RichTextEditor.vue.js +4 -4
  6. package/components/RichTextEditor/RichTextLinkPopover.vue3.js +2 -2
  7. package/components/RichTextEditor/RichTextToolbar.vue3.js +2 -2
  8. package/components/Screen/ScreenFilter.vue.js +3 -3
  9. package/components/SeoProvider/SeoProvider.vue.d.ts +70 -0
  10. package/components/SeoProvider/SeoProvider.vue.js +52 -0
  11. package/components/SeoProvider/SeoProvider.vue2.js +4 -0
  12. package/components/SeoProvider/domAdapter.d.ts +6 -0
  13. package/components/SeoProvider/domAdapter.js +68 -0
  14. package/components/SeoProvider/index.d.ts +4 -0
  15. package/components/SeoProvider/normalizeSeo.d.ts +61 -0
  16. package/components/SeoProvider/normalizeSeo.js +195 -0
  17. package/components/SeoProvider/types.d.ts +146 -0
  18. package/composables/useSeo.d.ts +34 -0
  19. package/composables/useSeo.js +28 -0
  20. package/index.d.ts +2 -0
  21. package/index.js +230 -219
  22. package/package.json +1 -1
  23. /package/components/ColorPicker/{ColorIro.vue.js → ColorIro.vue2.js} +0 -0
  24. /package/components/Dropdown/{DropdownMenu.vue2.js → DropdownMenu.vue3.js} +0 -0
  25. /package/components/RichTextEditor/{RichTextLinkPopover.vue.js → RichTextLinkPopover.vue2.js} +0 -0
  26. /package/components/RichTextEditor/{RichTextToolbar.vue.js → RichTextToolbar.vue2.js} +0 -0
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Generic, framework-agnostic SEO contract.
3
+ *
4
+ * The goal of this layer is to keep SEO **normalization** (turning
5
+ * "store config + route context + page-specific overrides" into one
6
+ * canonical object) reusable, while letting the **application**
7
+ * (Nuxt, plain Vue + DOM, server-rendered HTML, …) decide **how** the
8
+ * data is actually emitted to the document head.
9
+ *
10
+ * The split is:
11
+ *
12
+ * 1. `SeoData` — the final shape every consumer (Nuxt
13
+ * `useSeoMeta`, Open Graph crawler, plain
14
+ * `<meta>` injection) understands.
15
+ * 2. `SeoAdapter` — a tiny interface the host app provides
16
+ * to apply `SeoData` to the document. In
17
+ * Nuxt this wraps `useSeoMeta` / `useHead`;
18
+ * in a Vue admin preview it mutates
19
+ * `document.head` directly. The provider
20
+ * itself never imports Nuxt or DOM APIs.
21
+ * 3. `useSeo` — a Vue composable for components that
22
+ * want to declare per-page SEO context
23
+ * (page type, dynamic replacements, image).
24
+ * 4. `SeoProvider` — the Vue component that owns the
25
+ * lifecycle: it merges the current page
26
+ * context, runs the normalizer, and calls
27
+ * the adapter on every change.
28
+ *
29
+ * Keeping the layer UI-agnostic means `vlite3` can ship SEO support
30
+ * without forcing every consumer onto Nuxt — and tests can run with
31
+ * a stub adapter that just records the last call.
32
+ */
33
+ /**
34
+ * Final, fully-resolved SEO payload.
35
+ *
36
+ * Every field is **already normalized** — null vs empty string,
37
+ * fallbacks applied, dynamic tokens replaced. Consumers (Nuxt
38
+ * `useSeoMeta`, DOM mutation, SSR string templating) should be
39
+ * able to read this object and emit `<meta>` tags without further
40
+ * computation.
41
+ */
42
+ export interface SeoData {
43
+ /** Page title, ready to feed `useSeoMeta({ title })` / `<title>`. */
44
+ title: string;
45
+ /**
46
+ * Optional title template, e.g. `"%s · Acme"`. Falsy → leave the
47
+ * host app's default behaviour in place.
48
+ */
49
+ titleTemplate?: string | null;
50
+ /** Meta description, 1–2 sentences, crawler-friendly. */
51
+ description: string;
52
+ /** Comma- or space-separated keywords. Empty string if unset. */
53
+ keywords: string;
54
+ /** Absolute canonical URL. Falsy → host decides (use `useRequestURL` etc.). */
55
+ canonicalUrl?: string | null;
56
+ /** Robots directive, e.g. `"index, follow"` or `"noindex, nofollow"`. */
57
+ robots?: string | null;
58
+ /** Absolute favicon URL (`.ico` / `.png`). */
59
+ favicon?: string | null;
60
+ /** Absolute share-image URL (used for both OG and Twitter by default). */
61
+ image?: string | null;
62
+ ogTitle?: string | null;
63
+ ogDescription?: string | null;
64
+ ogImage?: string | null;
65
+ ogImageAlt?: string | null;
66
+ ogUrl?: string | null;
67
+ ogType?: string | null;
68
+ ogSiteName?: string | null;
69
+ ogLocale?: string | null;
70
+ twitterCard?: string | null;
71
+ twitterTitle?: string | null;
72
+ twitterDescription?: string | null;
73
+ twitterImage?: string | null;
74
+ twitterSite?: string | null;
75
+ twitterCreator?: string | null;
76
+ /**
77
+ * Site name used in OG `site_name`. Today the `ogSiteName` field
78
+ * carries the same value — `siteName` is exposed separately for
79
+ * adapters that prefer to render it as JSON-LD instead of a meta
80
+ * tag.
81
+ */
82
+ siteName?: string | null;
83
+ /** Free-form JSON-LD block. Adapter decides whether to render. */
84
+ jsonLd?: Record<string, unknown> | null;
85
+ }
86
+ /**
87
+ * The full, normalized context the `SeoProvider` hands to its
88
+ * adapter. Same as `SeoData` plus the canonical `pageType` key
89
+ * (used for analytics / structured data) and the unresolved raw
90
+ * inputs in case the adapter needs them.
91
+ */
92
+ export interface SeoPayload extends SeoData {
93
+ /**
94
+ * Logical page key, e.g. `"home"`, `"product"`, `"collection"`.
95
+ * Adapter can use it for breadcrumb JSON-LD, custom `<meta>`,
96
+ * or just logging.
97
+ */
98
+ pageType: string;
99
+ }
100
+ /**
101
+ * Partial SEO data a page (or any component) can push into the
102
+ * provider via `useSeo({ … })`. Anything not supplied is filled by
103
+ * the provider's defaults / store-level fallback. Keys with `null`
104
+ * explicitly clear the inherited value.
105
+ */
106
+ export interface SeoContextInput {
107
+ pageType?: string;
108
+ title?: string | null;
109
+ description?: string | null;
110
+ keywords?: string | null;
111
+ image?: string | null;
112
+ canonicalUrl?: string | null;
113
+ robots?: string | null;
114
+ /**
115
+ * Token replacements applied to every string field, e.g.
116
+ * `{ productName: 'Blue Tee' }` for `{{productName}}`.
117
+ */
118
+ replacements?: Record<string, string | number | null | undefined>;
119
+ /**
120
+ * Free-form extras merged on top of the resolved payload. Use
121
+ * sparingly — the canonical fields above are preferred.
122
+ */
123
+ overrides?: Partial<SeoData>;
124
+ }
125
+ /**
126
+ * The contract a host application (Nuxt app, Vue admin shell,
127
+ * SSR template) provides so the generic `SeoProvider` can emit
128
+ * the resolved SEO without depending on any specific framework.
129
+ *
130
+ * The adapter receives the final, normalized payload. The
131
+ * provider calls it whenever the merged SEO context changes.
132
+ */
133
+ export interface SeoAdapter {
134
+ /**
135
+ * Apply the SEO payload to the document. Called reactively on
136
+ * every change; may be called multiple times during a session
137
+ * (e.g. on route change, then on data load).
138
+ */
139
+ apply(payload: SeoPayload): void;
140
+ /**
141
+ * Optional cleanup hook, e.g. clearing injected meta tags when
142
+ * the provider unmounts. The default implementation in
143
+ * `normalizeSeo` no-ops.
144
+ */
145
+ reset?(): void;
146
+ }
@@ -0,0 +1,34 @@
1
+ import { InjectionKey, Ref } from 'vue';
2
+ import { SeoContextInput } from '../components/SeoProvider/types';
3
+ /**
4
+ * Mutable, reactive bag of SEO contexts. The provider owns the
5
+ * ref; pages push into it. We keep it as a `Map` so multiple
6
+ * pages on the same route (e.g. a checkout step embedded in a
7
+ * parent) can each contribute, and so `clear()` removes only
8
+ * the calling page's contribution.
9
+ */
10
+ export type SeoContextBag = Ref<Map<symbol, SeoContextInput>>;
11
+ export declare const SEO_CONTEXT_KEY: InjectionKey<SeoContextBag>;
12
+ /**
13
+ * Minimal interface the page-level composable needs from the
14
+ * provider. Exposed as a separate type so the provider component
15
+ * doesn't have to import Vue's `provide` / `inject` machinery
16
+ * from the composable side.
17
+ */
18
+ export interface SeoContextRegistrar {
19
+ register(input: SeoContextInput): SeoContextHandle;
20
+ }
21
+ /**
22
+ * Per-page handle. `update()` replaces the registered context
23
+ * in place; `clear()` removes it.
24
+ */
25
+ export interface SeoContextHandle {
26
+ update(next: SeoContextInput): void;
27
+ clear(): void;
28
+ }
29
+ /**
30
+ * Public composable. Safe to call outside a provider — falls
31
+ * back to a no-op registrar so admin shells and one-off tests
32
+ * don't have to wire the provider up just to render.
33
+ */
34
+ export declare const useSeo: (input?: SeoContextInput) => SeoContextHandle;
@@ -0,0 +1,28 @@
1
+ import { inject as r, onBeforeUnmount as u } from "vue";
2
+ const a = /* @__PURE__ */ Symbol("vlite3:seo-context"), s = (o = {}) => {
3
+ const e = r(a, null);
4
+ if (!e)
5
+ return {
6
+ update: () => {
7
+ },
8
+ clear: () => {
9
+ }
10
+ };
11
+ const t = /* @__PURE__ */ Symbol("vlite3:seo-context-entry");
12
+ e.value.set(t, o);
13
+ const n = {
14
+ update(l) {
15
+ e.value.set(t, l);
16
+ },
17
+ clear() {
18
+ e.value.delete(t);
19
+ }
20
+ };
21
+ return u(() => {
22
+ e.value.delete(t);
23
+ }), n;
24
+ };
25
+ export {
26
+ a as SEO_CONTEXT_KEY,
27
+ s as useSeo
28
+ };
package/index.d.ts CHANGED
@@ -63,8 +63,10 @@ export * from './components/AsyncSelect';
63
63
  export * from './components/ImageComparison';
64
64
  export { default as ImageMagnifier } from './components/ImageMagnifier.vue';
65
65
  export * from './components/ThemeProvider';
66
+ export * from './components/SeoProvider';
66
67
  export * from './components/ScaleGenerator';
67
68
  export { THEME_STYLES_KEY, useThemeStyles } from './composables/useThemeStyles';
69
+ export { useSeo, SEO_CONTEXT_KEY, type SeoContextBag, type SeoContextHandle } from './composables/useSeo';
68
70
  export { default as Icon } from './components/Icon.vue';
69
71
  export { default as Logo } from './components/Logo.vue';
70
72
  export { default as Alert } from './components/Alert.vue';