svelte-intlayer 8.3.0-canary.3 → 8.3.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.
|
@@ -26,7 +26,7 @@ type useLocaleProps = {
|
|
|
26
26
|
export declare const useLocale: ({ isCookieEnabled, onLocaleChange, }?: useLocaleProps) => {
|
|
27
27
|
locale: import("svelte/store").Readable<LocalesValues>;
|
|
28
28
|
setLocale: (locale: LocalesValues) => void;
|
|
29
|
-
defaultLocale: import("
|
|
30
|
-
availableLocales: import("
|
|
29
|
+
defaultLocale: import("intlayer").Locale;
|
|
30
|
+
availableLocales: import("intlayer").Locale[];
|
|
31
31
|
};
|
|
32
32
|
export {};
|
|
@@ -2,13 +2,13 @@ import type { LocalesValues } from '@intlayer/types/module_augmentation';
|
|
|
2
2
|
/**
|
|
3
3
|
* Get the locale cookie
|
|
4
4
|
*/
|
|
5
|
-
export declare const localeInStorage: import("
|
|
5
|
+
export declare const localeInStorage: import("intlayer").Locale | undefined;
|
|
6
6
|
/**
|
|
7
7
|
* @deprecated Use localeInStorage instead
|
|
8
8
|
*
|
|
9
9
|
* Get the locale cookie
|
|
10
10
|
*/
|
|
11
|
-
export declare const localeCookie: import("
|
|
11
|
+
export declare const localeCookie: import("intlayer").Locale | undefined;
|
|
12
12
|
/**
|
|
13
13
|
* Set the locale cookie
|
|
14
14
|
*/
|
package/dist/plugins.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import configuration from '@intlayer/config/built';
|
|
1
2
|
import { getHTML, } from '@intlayer/core/interpreter';
|
|
2
3
|
import { compile, getMarkdownMetadata } from '@intlayer/core/markdown';
|
|
3
4
|
import { HTML_TAGS, } from '@intlayer/core/transpiler';
|
|
@@ -18,7 +19,9 @@ export const intlayerNodePlugins = {
|
|
|
18
19
|
typeof node === 'number',
|
|
19
20
|
transform: (node, { children, ...rest }) => renderIntlayerNode({
|
|
20
21
|
value: children ?? node,
|
|
21
|
-
component:
|
|
22
|
+
component: configuration?.editor.enabled
|
|
23
|
+
? ContentSelectorWrapper
|
|
24
|
+
: (children ?? node),
|
|
22
25
|
props: rest,
|
|
23
26
|
}),
|
|
24
27
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
// ---------------------------------------------------------------------------
|
|
3
|
+
// Mocks – must be declared before any import that transitively loads them.
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
const mockConfig = vi.hoisted(() => ({ editor: { enabled: false } }));
|
|
6
|
+
vi.mock('@intlayer/config/built', () => ({ default: mockConfig }));
|
|
7
|
+
// Mock the Svelte wrapper component so vitest doesn't try to parse it.
|
|
8
|
+
vi.mock('./IntlayerNodeWrapper.svelte', () => ({
|
|
9
|
+
default: () => null,
|
|
10
|
+
}));
|
|
11
|
+
// Mock the editor module (exports Svelte components).
|
|
12
|
+
vi.mock('./editor', () => ({
|
|
13
|
+
ContentSelectorWrapper: () => null,
|
|
14
|
+
}));
|
|
15
|
+
// Mock Svelte markdown components.
|
|
16
|
+
vi.mock('./markdown/MarkdownMetadataWithSelector.svelte', () => ({
|
|
17
|
+
default: () => null,
|
|
18
|
+
}));
|
|
19
|
+
vi.mock('./markdown/MarkdownWithSelector.svelte', () => ({
|
|
20
|
+
default: () => null,
|
|
21
|
+
}));
|
|
22
|
+
vi.mock('./markdown/runtime', () => ({
|
|
23
|
+
svelteHtmlRuntime: {},
|
|
24
|
+
}));
|
|
25
|
+
import { getDictionary } from './getDictionary';
|
|
26
|
+
import { renderIntlayerNode } from './renderIntlayerNode';
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
// Fixture dictionary
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
const dict = {
|
|
31
|
+
key: 'test',
|
|
32
|
+
content: { greeting: 'Hello World', count: 42 },
|
|
33
|
+
};
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
// renderIntlayerNode – unit tests
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
describe('renderIntlayerNode', () => {
|
|
38
|
+
it('exposes .value with the raw string', () => {
|
|
39
|
+
const node = renderIntlayerNode({
|
|
40
|
+
value: 'Hello',
|
|
41
|
+
component: 'Hello',
|
|
42
|
+
props: {},
|
|
43
|
+
});
|
|
44
|
+
expect(node.value).toBe('Hello');
|
|
45
|
+
});
|
|
46
|
+
it('exposes .value with a raw number', () => {
|
|
47
|
+
const node = renderIntlayerNode({
|
|
48
|
+
value: 42,
|
|
49
|
+
component: 42,
|
|
50
|
+
props: {},
|
|
51
|
+
});
|
|
52
|
+
expect(node.value).toBe(42);
|
|
53
|
+
});
|
|
54
|
+
it('toString() returns the string representation', () => {
|
|
55
|
+
const node = renderIntlayerNode({
|
|
56
|
+
value: 'Hello',
|
|
57
|
+
component: 'Hello',
|
|
58
|
+
props: {},
|
|
59
|
+
});
|
|
60
|
+
expect(node.toString()).toBe('Hello');
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
// ---------------------------------------------------------------------------
|
|
64
|
+
// getDictionary – editor disabled (default)
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
describe('getDictionary – editor disabled', () => {
|
|
67
|
+
beforeEach(() => {
|
|
68
|
+
mockConfig.editor.enabled = false;
|
|
69
|
+
});
|
|
70
|
+
it('field.value returns the raw string', () => {
|
|
71
|
+
const result = getDictionary(dict, 'en');
|
|
72
|
+
expect(result.greeting.value).toBe('Hello World');
|
|
73
|
+
});
|
|
74
|
+
it('field.value returns the raw number', () => {
|
|
75
|
+
const result = getDictionary(dict, 'en');
|
|
76
|
+
expect(result.count.value).toBe(42);
|
|
77
|
+
});
|
|
78
|
+
it('field.toString() returns the raw string', () => {
|
|
79
|
+
const result = getDictionary(dict, 'en');
|
|
80
|
+
expect(result.greeting.toString()).toBe('Hello World');
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
// ---------------------------------------------------------------------------
|
|
84
|
+
// getDictionary – editor enabled
|
|
85
|
+
// ---------------------------------------------------------------------------
|
|
86
|
+
describe('getDictionary – editor enabled', () => {
|
|
87
|
+
beforeEach(() => {
|
|
88
|
+
mockConfig.editor.enabled = true;
|
|
89
|
+
});
|
|
90
|
+
it('field.value still returns the raw string', () => {
|
|
91
|
+
const result = getDictionary(dict, 'en');
|
|
92
|
+
expect(result.greeting.value).toBe('Hello World');
|
|
93
|
+
});
|
|
94
|
+
it('field.toString() still returns the raw string', () => {
|
|
95
|
+
const result = getDictionary(dict, 'en');
|
|
96
|
+
expect(result.greeting.toString()).toBe('Hello World');
|
|
97
|
+
});
|
|
98
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-intlayer",
|
|
3
|
-
"version": "8.3.0
|
|
3
|
+
"version": "8.3.0",
|
|
4
4
|
"description": "Easily internationalize i18n your Svelte applications with type-safe multilingual content management.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"intlayer",
|
|
@@ -72,12 +72,12 @@
|
|
|
72
72
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@intlayer/api": "8.3.0
|
|
76
|
-
"@intlayer/config": "8.3.0
|
|
77
|
-
"@intlayer/core": "8.3.0
|
|
78
|
-
"@intlayer/editor": "8.3.0
|
|
79
|
-
"@intlayer/types": "8.3.0
|
|
80
|
-
"@intlayer/unmerged-dictionaries-entry": "8.3.0
|
|
75
|
+
"@intlayer/api": "8.3.0",
|
|
76
|
+
"@intlayer/config": "8.3.0",
|
|
77
|
+
"@intlayer/core": "8.3.0",
|
|
78
|
+
"@intlayer/editor": "8.3.0",
|
|
79
|
+
"@intlayer/types": "8.3.0",
|
|
80
|
+
"@intlayer/unmerged-dictionaries-entry": "8.3.0"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
83
|
"@sveltejs/adapter-auto": "7.0.0",
|