svelte-intlayer 8.4.4 → 8.4.6

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 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
- [NodeType.Insertion]: string;
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
- [NodeType.Markdown]: infer _M;
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
- [NodeType.HTML]: infer I;
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
@@ -1,15 +1,28 @@
1
1
  import configuration from '@intlayer/config/built';
2
2
  import { conditionPlugin, enumerationPlugin, filePlugin, genderPlugin, getHTML, nestedPlugin, translationPlugin, } from '@intlayer/core/interpreter';
3
- import { compile, getMarkdownMetadata } from '@intlayer/core/markdown';
4
3
  import { HTML_TAGS, } from '@intlayer/core/transpiler';
5
- import { NodeType } from '@intlayer/types/nodeType';
4
+ import * as NodeTypes from '@intlayer/types/nodeType';
6
5
  import { default as ContentSelector } from './editor/ContentSelector.svelte';
7
- import MarkdownMetadataRenderer from './markdown/MarkdownMetadataRenderer.svelte';
8
- import MarkdownMetadataWithSelector from './markdown/MarkdownMetadataWithSelector.svelte';
9
- import MarkdownRenderer from './markdown/MarkdownRenderer.svelte';
10
- import MarkdownWithSelector from './markdown/MarkdownWithSelector.svelte';
11
- import { svelteHtmlRuntime } from './markdown/runtime';
12
6
  import { renderIntlayerNode } from './renderIntlayerNode';
7
+ // Lazy pre-load heavy modules — creates separate code-split chunks
8
+ let _getMarkdownMetadata = null;
9
+ let _compile = null;
10
+ void import('@intlayer/core/markdown').then((m) => {
11
+ _getMarkdownMetadata = m.getMarkdownMetadata;
12
+ _compile = m.compile;
13
+ });
14
+ let _MarkdownMetadataRenderer = null;
15
+ let _MarkdownMetadataWithSelector = null;
16
+ let _MarkdownRenderer = null;
17
+ let _MarkdownWithSelector = null;
18
+ let _svelteHtmlRuntime = null;
19
+ void Promise.all([
20
+ import('./markdown/MarkdownMetadataRenderer.svelte').then((m) => (_MarkdownMetadataRenderer = m.default)),
21
+ import('./markdown/MarkdownMetadataWithSelector.svelte').then((m) => (_MarkdownMetadataWithSelector = m.default)),
22
+ import('./markdown/MarkdownRenderer.svelte').then((m) => (_MarkdownRenderer = m.default)),
23
+ import('./markdown/MarkdownWithSelector.svelte').then((m) => (_MarkdownWithSelector = m.default)),
24
+ import('./markdown/runtime').then((m) => (_svelteHtmlRuntime = m.svelteHtmlRuntime)),
25
+ ]);
13
26
  /**
14
27
  * Basic Intlayer node plugins for content handling
15
28
  * These handle the core content transformation logic
@@ -84,15 +97,15 @@ const splitAndJoinInsertion = (template, values) => {
84
97
  /** Insertion plugin for Svelte. Handles component insertion. */
85
98
  export const insertionPlugin = {
86
99
  id: 'insertion-plugin',
87
- canHandle: (node) => typeof node === 'object' && node?.nodeType === NodeType.Insertion,
100
+ canHandle: (node) => typeof node === 'object' && node?.nodeType === NodeTypes.INSERTION,
88
101
  transform: (node, props, deepTransformNode) => {
89
102
  const newKeyPath = [
90
103
  ...props.keyPath,
91
104
  {
92
- type: NodeType.Insertion,
105
+ type: NodeTypes.INSERTION,
93
106
  },
94
107
  ];
95
- const children = node[NodeType.Insertion];
108
+ const children = node[NodeTypes.INSERTION];
96
109
  /** Insertion string plugin. Replaces string node with a component that render the insertion. */
97
110
  const insertionStringPlugin = {
98
111
  id: 'insertion-string-plugin',
@@ -129,7 +142,7 @@ export const markdownStringPlugin = {
129
142
  canHandle: (node) => typeof node === 'string',
130
143
  transform: (node, props, deepTransformNode) => {
131
144
  const { ...rest } = props;
132
- const metadata = getMarkdownMetadata(node) ?? {};
145
+ const metadata = _getMarkdownMetadata?.(node) ?? {};
133
146
  const metadataPlugins = {
134
147
  id: 'markdown-metadata-plugin',
135
148
  canHandle: (metadataNode) => typeof metadataNode === 'string' ||
@@ -139,8 +152,8 @@ export const markdownStringPlugin = {
139
152
  transform: (metadataNode, props) => renderIntlayerNode({
140
153
  value: metadataNode,
141
154
  component: configuration?.editor.enabled
142
- ? MarkdownMetadataWithSelector
143
- : MarkdownMetadataRenderer,
155
+ ? (_MarkdownMetadataWithSelector ?? _MarkdownMetadataRenderer)
156
+ : _MarkdownMetadataRenderer,
144
157
  props: {
145
158
  ...rest,
146
159
  value: node, // The full markdown string
@@ -158,8 +171,8 @@ export const markdownStringPlugin = {
158
171
  const nodeResult = renderIntlayerNode({
159
172
  value: node,
160
173
  component: configuration?.editor.enabled
161
- ? MarkdownWithSelector
162
- : MarkdownRenderer,
174
+ ? (_MarkdownWithSelector ?? _MarkdownRenderer)
175
+ : _MarkdownRenderer,
163
176
  props: {
164
177
  ...rest,
165
178
  value: node,
@@ -181,7 +194,7 @@ export const markdownStringPlugin = {
181
194
  return (newComponents) => render(newComponents);
182
195
  }
183
196
  if (prop === 'toString') {
184
- return () => compile(node, { runtime: svelteHtmlRuntime, components: components }, {});
197
+ return () => _compile?.(node, { runtime: _svelteHtmlRuntime, components: components }, {}) ?? node;
185
198
  }
186
199
  return Reflect.get(target, prop, receiver);
187
200
  },
@@ -192,15 +205,15 @@ export const markdownStringPlugin = {
192
205
  };
193
206
  export const markdownPlugin = {
194
207
  id: 'markdown-plugin',
195
- canHandle: (node) => typeof node === 'object' && node?.nodeType === NodeType.Markdown,
208
+ canHandle: (node) => typeof node === 'object' && node?.nodeType === NodeTypes.MARKDOWN,
196
209
  transform: (node, props, deepTransformNode) => {
197
210
  const newKeyPath = [
198
211
  ...props.keyPath,
199
212
  {
200
- type: NodeType.Markdown,
213
+ type: NodeTypes.MARKDOWN,
201
214
  },
202
215
  ];
203
- const children = node[NodeType.Markdown];
216
+ const children = node[NodeTypes.MARKDOWN];
204
217
  return deepTransformNode(children, {
205
218
  ...props,
206
219
  children,
@@ -258,9 +271,9 @@ const getDefaultHTMLComponents = () => {
258
271
  /** HTML plugin. Replaces node with a function that takes components => HTMLElement[]. */
259
272
  export const htmlPlugin = {
260
273
  id: 'html-plugin',
261
- canHandle: (node) => typeof node === 'object' && node?.nodeType === NodeType.HTML,
274
+ canHandle: (node) => typeof node === 'object' && node?.nodeType === NodeTypes.HTML,
262
275
  transform: (node) => {
263
- const htmlString = node[NodeType.HTML];
276
+ const htmlString = node[NodeTypes.HTML];
264
277
  const _tags = node.tags ?? [];
265
278
  const render = (userComponents) => {
266
279
  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(() => ({ editor: { enabled: false } }));
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.4",
3
+ "version": "8.4.6",
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.4",
76
- "@intlayer/config": "8.4.4",
77
- "@intlayer/core": "8.4.4",
78
- "@intlayer/editor": "8.4.4",
79
- "@intlayer/types": "8.4.4"
75
+ "@intlayer/api": "8.4.6",
76
+ "@intlayer/config": "8.4.6",
77
+ "@intlayer/core": "8.4.6",
78
+ "@intlayer/editor": "8.4.6",
79
+ "@intlayer/types": "8.4.6"
80
80
  },
81
81
  "devDependencies": {
82
82
  "@sveltejs/adapter-auto": "7.0.1",
@@ -91,7 +91,7 @@
91
91
  "svelte-check": "4.4.5",
92
92
  "tsdown": "0.21.4",
93
93
  "typescript": "5.9.3",
94
- "vite": "8.0.0",
94
+ "vite": "8.0.1",
95
95
  "vitest": "4.1.0"
96
96
  },
97
97
  "peerDependencies": {