svelte-intlayer 8.4.4 → 8.4.5
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/dist/plugins.d.ts +5 -4
- package/dist/plugins.js +9 -9
- package/dist/renderIntlayerNode.test.js +4 -1
- package/package.json +6 -6
package/dist/plugins.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type DeepTransformContent as DeepTransformContentCore, type IInterpreterPluginState as IInterpreterPluginStateCore, type Plugins } from '@intlayer/core/interpreter';
|
|
2
2
|
import type { DeclaredLocales, LocalesValues } from '@intlayer/types/module_augmentation';
|
|
3
|
-
import { NodeType } from '@intlayer/types/nodeType';
|
|
3
|
+
import type { NodeType } from '@intlayer/types/nodeType';
|
|
4
|
+
import * as NodeTypes from '@intlayer/types/nodeType';
|
|
4
5
|
import type { HTMLComponents } from './html/types';
|
|
5
6
|
import { type IntlayerNode } from './renderIntlayerNode';
|
|
6
7
|
/**
|
|
@@ -33,7 +34,7 @@ export declare const svelteNodePlugins: Plugins;
|
|
|
33
34
|
* --------------------------------------------- */
|
|
34
35
|
export type InsertionCond<T, _S, _L> = T extends {
|
|
35
36
|
nodeType: NodeType | string;
|
|
36
|
-
[
|
|
37
|
+
[NodeTypes.INSERTION]: string;
|
|
37
38
|
fields: readonly string[];
|
|
38
39
|
} ? <V extends {
|
|
39
40
|
[K in T['fields'][number]]: any;
|
|
@@ -51,7 +52,7 @@ export type MarkdownStringCond<T> = T extends string ? IntlayerNode<string, {
|
|
|
51
52
|
export declare const markdownStringPlugin: Plugins;
|
|
52
53
|
export type MarkdownCond<T, _S, L extends LocalesValues> = T extends {
|
|
53
54
|
nodeType: NodeType | string;
|
|
54
|
-
[
|
|
55
|
+
[NodeTypes.MARKDOWN]: infer _M;
|
|
55
56
|
metadata?: infer U;
|
|
56
57
|
tags?: infer U;
|
|
57
58
|
} ? {
|
|
@@ -61,7 +62,7 @@ export type MarkdownCond<T, _S, L extends LocalesValues> = T extends {
|
|
|
61
62
|
export declare const markdownPlugin: Plugins;
|
|
62
63
|
export type HTMLPluginCond<T> = T extends {
|
|
63
64
|
nodeType: NodeType | string;
|
|
64
|
-
[
|
|
65
|
+
[NodeTypes.HTML]: infer I;
|
|
65
66
|
tags?: infer U;
|
|
66
67
|
} ? {
|
|
67
68
|
use: (components?: HTMLComponents<'permissive', U>) => IntlayerNode<I>;
|
package/dist/plugins.js
CHANGED
|
@@ -2,7 +2,7 @@ import configuration from '@intlayer/config/built';
|
|
|
2
2
|
import { conditionPlugin, enumerationPlugin, filePlugin, genderPlugin, getHTML, nestedPlugin, translationPlugin, } from '@intlayer/core/interpreter';
|
|
3
3
|
import { compile, getMarkdownMetadata } from '@intlayer/core/markdown';
|
|
4
4
|
import { HTML_TAGS, } from '@intlayer/core/transpiler';
|
|
5
|
-
import
|
|
5
|
+
import * as NodeTypes from '@intlayer/types/nodeType';
|
|
6
6
|
import { default as ContentSelector } from './editor/ContentSelector.svelte';
|
|
7
7
|
import MarkdownMetadataRenderer from './markdown/MarkdownMetadataRenderer.svelte';
|
|
8
8
|
import MarkdownMetadataWithSelector from './markdown/MarkdownMetadataWithSelector.svelte';
|
|
@@ -84,15 +84,15 @@ const splitAndJoinInsertion = (template, values) => {
|
|
|
84
84
|
/** Insertion plugin for Svelte. Handles component insertion. */
|
|
85
85
|
export const insertionPlugin = {
|
|
86
86
|
id: 'insertion-plugin',
|
|
87
|
-
canHandle: (node) => typeof node === 'object' && node?.nodeType ===
|
|
87
|
+
canHandle: (node) => typeof node === 'object' && node?.nodeType === NodeTypes.INSERTION,
|
|
88
88
|
transform: (node, props, deepTransformNode) => {
|
|
89
89
|
const newKeyPath = [
|
|
90
90
|
...props.keyPath,
|
|
91
91
|
{
|
|
92
|
-
type:
|
|
92
|
+
type: NodeTypes.INSERTION,
|
|
93
93
|
},
|
|
94
94
|
];
|
|
95
|
-
const children = node[
|
|
95
|
+
const children = node[NodeTypes.INSERTION];
|
|
96
96
|
/** Insertion string plugin. Replaces string node with a component that render the insertion. */
|
|
97
97
|
const insertionStringPlugin = {
|
|
98
98
|
id: 'insertion-string-plugin',
|
|
@@ -192,15 +192,15 @@ export const markdownStringPlugin = {
|
|
|
192
192
|
};
|
|
193
193
|
export const markdownPlugin = {
|
|
194
194
|
id: 'markdown-plugin',
|
|
195
|
-
canHandle: (node) => typeof node === 'object' && node?.nodeType ===
|
|
195
|
+
canHandle: (node) => typeof node === 'object' && node?.nodeType === NodeTypes.MARKDOWN,
|
|
196
196
|
transform: (node, props, deepTransformNode) => {
|
|
197
197
|
const newKeyPath = [
|
|
198
198
|
...props.keyPath,
|
|
199
199
|
{
|
|
200
|
-
type:
|
|
200
|
+
type: NodeTypes.MARKDOWN,
|
|
201
201
|
},
|
|
202
202
|
];
|
|
203
|
-
const children = node[
|
|
203
|
+
const children = node[NodeTypes.MARKDOWN];
|
|
204
204
|
return deepTransformNode(children, {
|
|
205
205
|
...props,
|
|
206
206
|
children,
|
|
@@ -258,9 +258,9 @@ const getDefaultHTMLComponents = () => {
|
|
|
258
258
|
/** HTML plugin. Replaces node with a function that takes components => HTMLElement[]. */
|
|
259
259
|
export const htmlPlugin = {
|
|
260
260
|
id: 'html-plugin',
|
|
261
|
-
canHandle: (node) => typeof node === 'object' && node?.nodeType ===
|
|
261
|
+
canHandle: (node) => typeof node === 'object' && node?.nodeType === NodeTypes.HTML,
|
|
262
262
|
transform: (node) => {
|
|
263
|
-
const htmlString = node[
|
|
263
|
+
const htmlString = node[NodeTypes.HTML];
|
|
264
264
|
const _tags = node.tags ?? [];
|
|
265
265
|
const render = (userComponents) => {
|
|
266
266
|
const mergedComponents = {
|
|
@@ -2,7 +2,10 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
|
2
2
|
// ---------------------------------------------------------------------------
|
|
3
3
|
// Mocks – must be declared before any import that transitively loads them.
|
|
4
4
|
// ---------------------------------------------------------------------------
|
|
5
|
-
const mockConfig = vi.hoisted(() => ({
|
|
5
|
+
const mockConfig = vi.hoisted(() => ({
|
|
6
|
+
editor: { enabled: false },
|
|
7
|
+
internationalization: { defaultLocale: 'en', locales: ['en'] },
|
|
8
|
+
}));
|
|
6
9
|
vi.mock('@intlayer/config/built', () => ({ default: mockConfig }));
|
|
7
10
|
// Mock the Svelte wrapper component so vitest doesn't try to parse it.
|
|
8
11
|
vi.mock('./IntlayerNodeWrapper.svelte', () => ({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-intlayer",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.5",
|
|
4
4
|
"description": "Easily internationalize i18n your Svelte applications with type-safe multilingual content management.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"intlayer",
|
|
@@ -72,11 +72,11 @@
|
|
|
72
72
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@intlayer/api": "8.4.
|
|
76
|
-
"@intlayer/config": "8.4.
|
|
77
|
-
"@intlayer/core": "8.4.
|
|
78
|
-
"@intlayer/editor": "8.4.
|
|
79
|
-
"@intlayer/types": "8.4.
|
|
75
|
+
"@intlayer/api": "8.4.5",
|
|
76
|
+
"@intlayer/config": "8.4.5",
|
|
77
|
+
"@intlayer/core": "8.4.5",
|
|
78
|
+
"@intlayer/editor": "8.4.5",
|
|
79
|
+
"@intlayer/types": "8.4.5"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@sveltejs/adapter-auto": "7.0.1",
|