svelte-meta-tags 4.0.0 → 4.0.2

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.
@@ -2,12 +2,7 @@
2
2
  import type { JsonLdProps } from './types';
3
3
  import type { Thing, WithContext } from 'schema-dts';
4
4
 
5
- interface Props {
6
- output?: JsonLdProps['output'];
7
- schema?: JsonLdProps['schema'];
8
- }
9
-
10
- let { output = 'head', schema = undefined }: Props = $props();
5
+ let { output = 'head', schema = undefined }: Partial<JsonLdProps> = $props();
11
6
 
12
7
  type OmitContext<T> = Omit<T, '@context'>;
13
8
 
@@ -1,6 +1,3 @@
1
1
  import type { JsonLdProps } from './types';
2
- declare const JsonLd: import("svelte").Component<{
3
- output?: JsonLdProps["output"];
4
- schema?: JsonLdProps["schema"];
5
- }, {}, "">;
2
+ declare const JsonLd: import("svelte").Component<Partial<JsonLdProps>, {}, "">;
6
3
  export default JsonLd;
@@ -2,8 +2,8 @@
2
2
  import type { MetaTagsProps } from './types';
3
3
 
4
4
  let {
5
- title = '',
6
- titleTemplate = '',
5
+ title = undefined,
6
+ titleTemplate = undefined,
7
7
  robots = 'index,follow',
8
8
  additionalRobotsProps = undefined,
9
9
  description = undefined,
@@ -48,11 +48,9 @@
48
48
  </script>
49
49
 
50
50
  <svelte:head>
51
- {#key updatedTitle}
52
- {#if updatedTitle}
53
- <title>{updatedTitle}</title>
54
- {/if}
55
- {/key}
51
+ {#if updatedTitle}
52
+ <title>{updatedTitle}</title>
53
+ {/if}
56
54
 
57
55
  {#if robots !== false}
58
56
  <meta name="robots" content="{robots}{robotsParams}" />
@@ -1 +1 @@
1
- export declare function deepMerge(target: any, source: any): any;
1
+ export declare const deepMerge: <X extends Record<string | symbol | number, unknown>>(target: X, source: X) => X;
package/dist/deepMerge.js CHANGED
@@ -1,36 +1,26 @@
1
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2
- export function deepMerge(target, source) {
3
- const sourceKeys = Object.keys(source);
4
- for (let i = 0; i < sourceKeys.length; i++) {
5
- const key = sourceKeys[i];
6
- const sourceValue = source[key];
7
- const targetValue = target[key];
8
- if (Array.isArray(sourceValue)) {
9
- if (Array.isArray(targetValue)) {
10
- target[key] = deepMerge(targetValue, sourceValue);
11
- }
12
- else {
13
- target[key] = deepMerge([], sourceValue);
14
- }
15
- }
16
- else if (isPlainObject(sourceValue)) {
17
- if (isPlainObject(targetValue)) {
18
- target[key] = deepMerge(targetValue, sourceValue);
19
- }
20
- else {
21
- target[key] = deepMerge({}, sourceValue);
22
- }
23
- }
24
- else if (targetValue === undefined || sourceValue !== undefined) {
25
- target[key] = sourceValue;
26
- }
27
- }
28
- return target;
29
- }
30
- function isPlainObject(object) {
31
- if (typeof object !== 'object' || object === null) {
32
- return false;
33
- }
34
- const proto = Object.getPrototypeOf(object);
35
- return proto === Object.prototype || proto === null;
36
- }
1
+ export const deepMerge = (target, source) => {
2
+ if (!target || !source)
3
+ return target ?? source ?? {};
4
+ return Object.entries({ ...target, ...source }).reduce((acc, [key, value]) => {
5
+ return {
6
+ ...acc,
7
+ [key]: (() => {
8
+ if (target[key] instanceof Date || typeof target[key] === 'function') {
9
+ return target[key];
10
+ }
11
+ if (value instanceof Date || typeof value === 'function') {
12
+ return value;
13
+ }
14
+ if (isObject(target[key]) && isObject(value)) {
15
+ return deepMerge(target[key], value);
16
+ }
17
+ if (isArray(target[key]) && isArray(value)) {
18
+ return value;
19
+ }
20
+ return value !== undefined ? value : target[key];
21
+ })()
22
+ };
23
+ }, {});
24
+ };
25
+ const isObject = (obj) => obj !== null && typeof obj === 'object' && !Array.isArray(obj);
26
+ const isArray = (obj) => Array.isArray(obj);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-meta-tags",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "Svelte Meta Tags provides components designed to help you manage SEO for Svelte projects",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -27,7 +27,7 @@
27
27
  "@sveltejs/package": "^2.3.6",
28
28
  "@sveltejs/vite-plugin-svelte": "^4.0.0",
29
29
  "publint": "^0.2.11",
30
- "svelte": "^5.0.5",
30
+ "svelte": "^5.1.0",
31
31
  "svelte-check": "^4.0.5",
32
32
  "tslib": "^2.8.0",
33
33
  "typescript": "^5.6.3",