@umituz/web-seo 2.1.0 → 2.2.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.
Files changed (85) hide show
  1. package/dist/domains/seo/components/JsonLd.d.ts +0 -9
  2. package/dist/domains/seo/components/JsonLd.js +0 -7
  3. package/dist/domains/seo/components/SEO.d.ts +0 -7
  4. package/dist/domains/seo/components/SEO.js +0 -7
  5. package/dist/domains/seo/components/index.d.ts +0 -5
  6. package/dist/domains/seo/components/index.js +0 -5
  7. package/dist/domains/seo/core/constants.d.ts +0 -6
  8. package/dist/domains/seo/core/constants.js +1 -7
  9. package/dist/domains/seo/core/deep-equal.d.ts +0 -7
  10. package/dist/domains/seo/core/deep-equal.js +0 -7
  11. package/dist/domains/seo/core/dom-queue.d.ts +0 -7
  12. package/dist/domains/seo/core/dom-queue.js +0 -10
  13. package/dist/domains/seo/core/escape.d.ts +0 -10
  14. package/dist/domains/seo/core/escape.js +0 -10
  15. package/dist/domains/seo/core/hash.d.ts +0 -8
  16. package/dist/domains/seo/core/hash.js +0 -8
  17. package/dist/domains/seo/core/init.d.ts +0 -11
  18. package/dist/domains/seo/core/init.js +0 -11
  19. package/dist/domains/seo/core/seo-strategies.d.ts +0 -10
  20. package/dist/domains/seo/core/seo-strategies.js +4 -75
  21. package/dist/domains/seo/core/seo-strategy.d.ts +1 -21
  22. package/dist/domains/seo/core/seo-strategy.js +0 -13
  23. package/dist/domains/seo/hooks/index.d.ts +0 -5
  24. package/dist/domains/seo/hooks/index.js +0 -5
  25. package/dist/domains/seo/hooks/useJsonLd.d.ts +0 -7
  26. package/dist/domains/seo/hooks/useJsonLd.js +0 -7
  27. package/dist/domains/seo/hooks/useSEO.d.ts +0 -6
  28. package/dist/domains/seo/hooks/useSEO.js +0 -6
  29. package/dist/domains/seo/ssr/helmet.d.ts +0 -7
  30. package/dist/domains/seo/ssr/helmet.js +0 -7
  31. package/dist/domains/seo/ssr/index.d.ts +0 -5
  32. package/dist/domains/seo/ssr/index.js +0 -5
  33. package/dist/domains/seo/ssr/renderer.d.ts +0 -21
  34. package/dist/domains/seo/ssr/renderer.js +0 -21
  35. package/dist/domains/seo/ssr/serializer.d.ts +0 -11
  36. package/dist/domains/seo/ssr/serializer.js +0 -11
  37. package/dist/domains/seo/types/schema.d.ts +0 -2
  38. package/dist/domains/seo/types/schema.js +0 -3
  39. package/dist/domains/seo/utils/dom/dom-context.d.ts +0 -11
  40. package/dist/domains/seo/utils/dom/dom-context.js +15 -15
  41. package/dist/domains/seo/utils/dom/dom-mutator.d.ts +0 -22
  42. package/dist/domains/seo/utils/dom/dom-mutator.js +1 -25
  43. package/dist/domains/seo/utils/index.d.ts +0 -5
  44. package/dist/domains/seo/utils/index.js +0 -8
  45. package/dist/domains/seo/utils/schema-generators/base.d.ts +0 -11
  46. package/dist/domains/seo/utils/schema-generators/base.js +0 -11
  47. package/dist/domains/seo/utils/schema-generators/factory.d.ts +0 -7
  48. package/dist/domains/seo/utils/schema-generators/factory.js +0 -7
  49. package/dist/domains/seo/utils/schema-generators/generators/article.js +1 -1
  50. package/dist/domains/seo/utils/schema-generators/index.d.ts +0 -6
  51. package/dist/domains/seo/utils/schema-generators/index.js +0 -6
  52. package/dist/domains/seo/utils/schema-generators/types.d.ts +0 -4
  53. package/dist/domains/seo/utils/schema-generators/types.js +0 -4
  54. package/dist/domains/seo/utils/validation/hreflang-validator.d.ts +0 -3
  55. package/dist/domains/seo/utils/validation/hreflang-validator.js +0 -3
  56. package/dist/domains/seo/utils/validation/image-validator.d.ts +0 -6
  57. package/dist/domains/seo/utils/validation/image-validator.js +0 -6
  58. package/dist/domains/seo/utils/validation/index.d.ts +0 -6
  59. package/dist/domains/seo/utils/validation/index.js +0 -6
  60. package/dist/domains/seo/utils/validation/jsonld-validator.d.ts +0 -7
  61. package/dist/domains/seo/utils/validation/jsonld-validator.js +0 -7
  62. package/dist/domains/seo/utils/validation/language-code.d.ts +0 -6
  63. package/dist/domains/seo/utils/validation/language-code.js +0 -6
  64. package/dist/domains/seo/utils/validation/length-validator.d.ts +0 -6
  65. package/dist/domains/seo/utils/validation/length-validator.js +0 -6
  66. package/dist/domains/seo/utils/validation/seo-auditor.d.ts +0 -14
  67. package/dist/domains/seo/utils/validation/seo-auditor.js +0 -24
  68. package/dist/domains/seo/utils/validation/text-helpers.d.ts +0 -6
  69. package/dist/domains/seo/utils/validation/text-helpers.js +0 -6
  70. package/dist/domains/seo/utils/validation/url-validator.d.ts +0 -6
  71. package/dist/domains/seo/utils/validation/url-validator.js +0 -6
  72. package/dist/domains/seo/vite/index.d.ts +1 -7
  73. package/dist/domains/seo/vite/index.js +0 -6
  74. package/dist/domains/seo/vite/plugin.d.ts +0 -6
  75. package/dist/domains/seo/vite/plugin.js +22 -14
  76. package/dist/domains/seo/vite/presets.d.ts +0 -6
  77. package/dist/domains/seo/vite/presets.js +0 -5
  78. package/dist/domains/seo/vite/robots-generator.d.ts +0 -3
  79. package/dist/domains/seo/vite/robots-generator.js +0 -3
  80. package/dist/domains/seo/vite/sitemap-generator.d.ts +0 -7
  81. package/dist/domains/seo/vite/sitemap-generator.js +0 -7
  82. package/dist/domains/seo/vite/types.d.ts +9 -11
  83. package/dist/domains/seo/vite/types.js +0 -3
  84. package/dist/index.js +0 -9
  85. package/package.json +1 -1
@@ -1,9 +1,3 @@
1
- /**
2
- * Text helpers used by SEO concerns.
3
- *
4
- * Slug generation lives here because it's a generic string utility
5
- * that the package's callers often reuse.
6
- */
7
1
  export const generateSlug = (text) => text
8
2
  .toLowerCase()
9
3
  .trim()
@@ -1,8 +1,2 @@
1
- /**
2
- * URL validation.
3
- *
4
- * Exposed at module scope so individual checks can be reused (e.g. the
5
- * image validator and the hreflang validator both need `isValidUrl`).
6
- */
7
1
  export declare const isValidUrl: (url: string) => boolean;
8
2
  export declare const validateUrl: (url: string, fieldName?: string) => string | null;
@@ -1,9 +1,3 @@
1
- /**
2
- * URL validation.
3
- *
4
- * Exposed at module scope so individual checks can be reused (e.g. the
5
- * image validator and the hreflang validator both need `isValidUrl`).
6
- */
7
1
  export const isValidUrl = (url) => {
8
2
  if (!url)
9
3
  return false;
@@ -1,9 +1,3 @@
1
- /**
2
- * Vite plugin entry point.
3
- *
4
- * Lives behind a subpath import (`@umituz/web-seo/vite`) to keep Node-only
5
- * dependencies out of the main browser bundle.
6
- */
7
1
  export { viteSEOPlugin } from "./plugin.js";
8
2
  export { quickSEOSetup } from "./presets.js";
9
- export type { ViteSEOPluginOptions } from "./types.js";
3
+ export type { ViteSEOPluginOptions, SitemapRouteItem, SitemapChangeFreq } from "./types.js";
@@ -1,8 +1,2 @@
1
- /**
2
- * Vite plugin entry point.
3
- *
4
- * Lives behind a subpath import (`@umituz/web-seo/vite`) to keep Node-only
5
- * dependencies out of the main browser bundle.
6
- */
7
1
  export { viteSEOPlugin } from "./plugin.js";
8
2
  export { quickSEOSetup } from "./presets.js";
@@ -1,9 +1,3 @@
1
- /**
2
- * Vite SEO Plugin
3
- *
4
- * Build-time SEO asset generator. Emits `sitemap.xml` and `robots.txt`
5
- * as Vite bundle assets so they land in the build output automatically.
6
- */
7
1
  import type { Plugin } from "vite";
8
2
  import type { ViteSEOPluginOptions } from "./types.js";
9
3
  export declare const viteSEOPlugin: (options: ViteSEOPluginOptions) => Plugin;
@@ -1,9 +1,3 @@
1
- /**
2
- * Vite SEO Plugin
3
- *
4
- * Build-time SEO asset generator. Emits `sitemap.xml` and `robots.txt`
5
- * as Vite bundle assets so they land in the build output automatically.
6
- */
7
1
  import { generateRobotsTxt } from "./robots-generator.js";
8
2
  import { discoverRoutesFromBuild, generateSitemapXML } from "./sitemap-generator.js";
9
3
  const PLUGIN_NAME = "umituz-web-seo";
@@ -22,19 +16,33 @@ export const viteSEOPlugin = (options) => {
22
16
  },
23
17
  generateBundle() {
24
18
  const outDir = pluginState.outDir ?? "dist";
25
- let routes = [...manualRoutes];
19
+ const routes = [...manualRoutes];
26
20
  if (discoverRoutes) {
27
21
  const discovered = discoverRoutesFromBuild(outDir);
28
- routes = Array.from(new Set([...routes, ...discovered]));
22
+ for (const item of discovered) {
23
+ const alreadyExists = routes.some((r) => (typeof r === "string" ? r === item : r.url === item));
24
+ if (!alreadyExists)
25
+ routes.push(item);
26
+ }
29
27
  }
30
28
  if (routes.length === 0)
31
29
  routes.push("/");
32
- const sitemapUrls = routes.map((route) => ({
33
- loc: `${normalizedSiteUrl}${route}`,
34
- lastmod: sitemapOptions.lastmod,
35
- changefreq: sitemapOptions.changefreq,
36
- priority: sitemapOptions.priority,
37
- }));
30
+ const sitemapUrls = routes.map((entry) => {
31
+ if (typeof entry === "string") {
32
+ return {
33
+ loc: `${normalizedSiteUrl}${entry}`,
34
+ lastmod: sitemapOptions.lastmod,
35
+ changefreq: sitemapOptions.changefreq,
36
+ priority: sitemapOptions.priority,
37
+ };
38
+ }
39
+ return {
40
+ loc: `${normalizedSiteUrl}${entry.url}`,
41
+ lastmod: entry.lastmod ?? sitemapOptions.lastmod,
42
+ changefreq: entry.changefreq ?? sitemapOptions.changefreq,
43
+ priority: entry.priority ?? sitemapOptions.priority,
44
+ };
45
+ });
38
46
  this.emitFile({
39
47
  type: "asset",
40
48
  fileName: sitemapFilename,
@@ -1,8 +1,3 @@
1
- /**
2
- * Convenience presets for common SEO setups.
3
- *
4
- * Each preset returns a fully-configured Vite plugin instance.
5
- */
6
1
  import type { ViteSEOPluginOptions } from "./types.js";
7
2
  export declare const quickSEOSetup: {
8
3
  readonly basic: (siteUrl: string, routes?: string[]) => import("vite").Plugin<any>;
@@ -10,5 +5,4 @@ export declare const quickSEOSetup: {
10
5
  readonly ecommerce: (siteUrl: string, routes?: string[]) => import("vite").Plugin<any>;
11
6
  };
12
7
  export type QuickSetupKey = keyof typeof quickSEOSetup;
13
- /** Re-export so plugin.ts can satisfy Vite's plugin shape without a circular import. */
14
8
  export type { ViteSEOPluginOptions };
@@ -1,8 +1,3 @@
1
- /**
2
- * Convenience presets for common SEO setups.
3
- *
4
- * Each preset returns a fully-configured Vite plugin instance.
5
- */
6
1
  import { viteSEOPlugin } from "./plugin.js";
7
2
  const baseDisallow = ["/api", "/admin"];
8
3
  const blogDisallow = [...baseDisallow, "/private"];
@@ -1,6 +1,3 @@
1
- /**
2
- * robots.txt generation.
3
- */
4
1
  import type { ViteSEOPluginOptions } from "./types.js";
5
2
  type RobotsOptions = ViteSEOPluginOptions["robotsTxt"] & {
6
3
  siteUrl: string;
@@ -1,6 +1,3 @@
1
- /**
2
- * robots.txt generation.
3
- */
4
1
  export const generateRobotsTxt = (options) => {
5
2
  if (!options)
6
3
  return "";
@@ -1,6 +1,3 @@
1
- /**
2
- * Sitemap XML generation.
3
- */
4
1
  export interface SitemapURL {
5
2
  loc: string;
6
3
  lastmod?: string;
@@ -8,8 +5,4 @@ export interface SitemapURL {
8
5
  priority?: number;
9
6
  }
10
7
  export declare const generateSitemapXML: (urls: SitemapURL[]) => string;
11
- /**
12
- * Walk the build output and collect every directory that produced an
13
- * `index.html`. Each one becomes a sitemap entry.
14
- */
15
8
  export declare const discoverRoutesFromBuild: (outDir: string) => string[];
@@ -1,6 +1,3 @@
1
- /**
2
- * Sitemap XML generation.
3
- */
4
1
  import * as fs from "fs";
5
2
  import * as path from "path";
6
3
  const escapeXML = (str) => str
@@ -23,10 +20,6 @@ export const generateSitemapXML = (urls) => {
23
20
  ${urlElements}
24
21
  </urlset>`;
25
22
  };
26
- /**
27
- * Walk the build output and collect every directory that produced an
28
- * `index.html`. Each one becomes a sitemap entry.
29
- */
30
23
  export const discoverRoutesFromBuild = (outDir) => {
31
24
  const routes = new Set("/");
32
25
  const traverse = (dir, basePath = "") => {
@@ -1,21 +1,20 @@
1
- /**
2
- * Public types for the Vite plugin.
3
- */
1
+ export type SitemapChangeFreq = "always" | "hourly" | "daily" | "weekly" | "monthly" | "yearly" | "never";
2
+ export interface SitemapRouteItem {
3
+ url: string;
4
+ priority?: number;
5
+ changefreq?: SitemapChangeFreq;
6
+ lastmod?: string;
7
+ }
4
8
  export interface ViteSEOPluginOptions {
5
- /** Base URL of your site (e.g., https://example.com) */
6
9
  siteUrl: string;
7
- /** Array of routes to include in sitemap */
8
- routes?: string[];
9
- /** Automatically discover routes from build output */
10
+ routes?: Array<string | SitemapRouteItem>;
10
11
  discoverRoutes?: boolean;
11
- /** Sitemap options */
12
12
  sitemap?: {
13
13
  filename?: string;
14
- changefreq?: "always" | "hourly" | "daily" | "weekly" | "monthly" | "yearly" | "never";
14
+ changefreq?: SitemapChangeFreq;
15
15
  priority?: number;
16
16
  lastmod?: string;
17
17
  };
18
- /** Robots.txt options */
19
18
  robotsTxt?: {
20
19
  filename?: string;
21
20
  userAgent?: string | Record<string, string[]>;
@@ -24,6 +23,5 @@ export interface ViteSEOPluginOptions {
24
23
  sitemap?: string;
25
24
  crawlDelay?: number;
26
25
  };
27
- /** Suppress console output */
28
26
  silent?: boolean;
29
27
  }
@@ -1,4 +1 @@
1
- /**
2
- * Public types for the Vite plugin.
3
- */
4
1
  export {};
package/dist/index.js CHANGED
@@ -1,18 +1,9 @@
1
- // ============================================================================
2
- // Main Package Entry Point
3
- // Domain-Driven Design structure
4
- // ============================================================================
5
- // Core SEO functionality
6
1
  export { SEO } from "./domains/seo/components/SEO.js";
7
2
  export { JsonLd } from "./domains/seo/components/JsonLd.js";
8
3
  export { useSEO } from "./domains/seo/hooks/useSEO.js";
9
4
  export { useJsonLd } from "./domains/seo/hooks/useJsonLd.js";
10
5
  export { initSEO } from "./domains/seo/core/init.js";
11
- // DOM operations
12
6
  export { updateSEO, clearSEO, getCurrentSEOState } from "./domains/seo/utils/dom/index.js";
13
- // Schema generators
14
7
  export { generateArticleSchema, generateProductSchema, generateOrganizationSchema, generateLocalBusinessSchema, generateBreadcrumbSchema, generateFAQSchema, generateWebSiteSchema, generatePersonSchema, generateVideoSchema, generateCourseSchema, schemaFactory, } from "./domains/seo/utils/schema-generators/index.js";
15
- // Validators + text helpers
16
8
  export { validateSEO, auditSEO, isValidUrl, validateUrl, validateTitleLength, validateDescriptionLength, validateOpenGraphImage, validateHreflangEntry, truncateToTitle, truncateToDescription, generateSlug, } from "./domains/seo/utils/validation/index.js";
17
- // SSR
18
9
  export { renderSEO, generateHead, extractSEOData, hydrateSEO, renderAsHelmet, serializeSEO, deserializeSEO, serializeSEOToBase64, deserializeSEOFromBase64, safeDeserializeSEO, } from "./domains/seo/ssr/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/web-seo",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Comprehensive SEO solution for React Vite applications with structured data, performance hints, and build-time optimization",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",