svelte-intlayer 8.6.1 → 8.6.3

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.
@@ -1,6 +1,7 @@
1
1
  import { isEnabled } from '@intlayer/editor/isEnabled';
2
2
  import { onDestroy, onMount } from 'svelte';
3
3
  import { intlayerStore } from '../client/intlayerStore';
4
+ const TREE_SHAKE_EDITOR = process.env['INTLAYER_EDITOR_ENABLED'] === 'false';
4
5
  /**
5
6
  * Initialises the Intlayer editor client singleton when the editor is enabled.
6
7
  * Syncs the current locale from intlayerStore into the editor manager so the
@@ -11,7 +12,7 @@ import { intlayerStore } from '../client/intlayerStore';
11
12
  * direct access to the Svelte 5 rune state.
12
13
  */
13
14
  export const useEditor = () => {
14
- if (process.env.INTLAYER_EDITOR_ENABLED === 'false' || !isEnabled)
15
+ if (TREE_SHAKE_EDITOR || !isEnabled)
15
16
  return;
16
17
  let unsubscribeLocale = null;
17
18
  onMount(() => {
package/dist/plugins.js CHANGED
@@ -4,6 +4,29 @@ import * as NodeTypes from '@intlayer/types/nodeType';
4
4
  import { default as ContentSelector } from './editor/ContentSelector.svelte';
5
5
  import { HTMLRenderer } from './html/index';
6
6
  import { renderIntlayerNode } from './renderIntlayerNode';
7
+ // ── Tree-shake constants ──────────────────────────────────────────────────────
8
+ // When these env vars are injected at build time, bundlers eliminate the
9
+ // branches guarded by these constants.
10
+ /**
11
+ * True when the intlayer node type is explicitly disabled at build time.
12
+ */
13
+ const TREE_SHAKE_INTLAYER_NODE = process.env['INTLAYER_NODE_TYPE_INTLAYER_NODE'] === 'false';
14
+ /**
15
+ * True when the markdown node type is explicitly disabled at build time.
16
+ */
17
+ const TREE_SHAKE_MARKDOWN = process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false';
18
+ /**
19
+ * True when the HTML node type is explicitly disabled at build time.
20
+ */
21
+ const TREE_SHAKE_HTML = process.env['INTLAYER_NODE_TYPE_HTML'] === 'false';
22
+ /**
23
+ * True when the insertion node type is explicitly disabled at build time.
24
+ */
25
+ const TREE_SHAKE_INSERTION = process.env['INTLAYER_NODE_TYPE_INSERTION'] === 'false';
26
+ /**
27
+ * True when the editor is explicitly disabled at build time.
28
+ */
29
+ const TREE_SHAKE_EDITOR = process.env['INTLAYER_EDITOR_ENABLED'] === 'false';
7
30
  // Lazy pre-load heavy modules — creates separate code-split chunks
8
31
  let _getMarkdownMetadata = null;
9
32
  let _compile = null;
@@ -27,7 +50,7 @@ void Promise.all([
27
50
  * Basic Intlayer node plugins for content handling
28
51
  * These handle the core content transformation logic
29
52
  */
30
- export const intlayerNodePlugins = process.env.INTLAYER_NODE_TYPE_INTLAYER_NODE === 'false'
53
+ export const intlayerNodePlugins = TREE_SHAKE_INTLAYER_NODE
31
54
  ? fallbackPlugin
32
55
  : {
33
56
  id: 'intlayer-node-plugin',
@@ -36,7 +59,7 @@ export const intlayerNodePlugins = process.env.INTLAYER_NODE_TYPE_INTLAYER_NODE
36
59
  typeof node === 'number',
37
60
  transform: (node, { children, ...rest }) => renderIntlayerNode({
38
61
  value: children ?? node,
39
- component: configuration.editor.enabled
62
+ component: !TREE_SHAKE_EDITOR && configuration.editor.enabled
40
63
  ? ContentSelector
41
64
  : undefined,
42
65
  props: rest,
@@ -97,7 +120,7 @@ const splitAndJoinInsertion = (template, values) => {
97
120
  return parts;
98
121
  };
99
122
  /** Insertion plugin for Svelte. Handles component insertion. */
100
- export const insertionPlugin = process.env.INTLAYER_NODE_TYPE_INSERTION === 'false'
123
+ export const insertionPlugin = TREE_SHAKE_INSERTION
101
124
  ? fallbackPlugin
102
125
  : {
103
126
  id: 'insertion-plugin',
@@ -155,7 +178,7 @@ export const insertionPlugin = process.env.INTLAYER_NODE_TYPE_INSERTION === 'fal
155
178
  },
156
179
  };
157
180
  /** Markdown string plugin. Replaces string node with a component that render the markdown. */
158
- export const markdownStringPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === 'false'
181
+ export const markdownStringPlugin = TREE_SHAKE_MARKDOWN
159
182
  ? fallbackPlugin
160
183
  : {
161
184
  id: 'markdown-string-plugin',
@@ -171,7 +194,7 @@ export const markdownStringPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN ===
171
194
  !metadataNode,
172
195
  transform: (metadataNode, props) => renderIntlayerNode({
173
196
  value: metadataNode,
174
- component: configuration.editor.enabled
197
+ component: !TREE_SHAKE_EDITOR && configuration.editor.enabled
175
198
  ? (_MarkdownMetadataWithSelector ?? _MarkdownMetadataRenderer)
176
199
  : _MarkdownMetadataRenderer,
177
200
  props: {
@@ -190,7 +213,7 @@ export const markdownStringPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN ===
190
213
  const render = (components) => {
191
214
  const nodeResult = renderIntlayerNode({
192
215
  value: node,
193
- component: configuration.editor.enabled
216
+ component: !TREE_SHAKE_EDITOR && configuration.editor.enabled
194
217
  ? (_MarkdownWithSelector ?? _MarkdownRenderer)
195
218
  : _MarkdownRenderer,
196
219
  props: {
@@ -223,7 +246,7 @@ export const markdownStringPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN ===
223
246
  return render();
224
247
  },
225
248
  };
226
- export const markdownPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === 'false'
249
+ export const markdownPlugin = TREE_SHAKE_MARKDOWN
227
250
  ? fallbackPlugin
228
251
  : {
229
252
  id: 'markdown-plugin',
@@ -245,7 +268,7 @@ export const markdownPlugin = process.env.INTLAYER_NODE_TYPE_MARKDOWN === 'false
245
268
  },
246
269
  };
247
270
  /** HTML plugin. Replaces node with a function that takes components => HTMLElement[]. */
248
- export const htmlPlugin = process.env.INTLAYER_NODE_TYPE_HTML === 'false'
271
+ export const htmlPlugin = TREE_SHAKE_HTML
249
272
  ? fallbackPlugin
250
273
  : {
251
274
  id: 'html-plugin',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-intlayer",
3
- "version": "8.6.1",
3
+ "version": "8.6.3",
4
4
  "description": "Easily internationalize i18n your Svelte applications with type-safe multilingual content management.",
5
5
  "keywords": [
6
6
  "intlayer",
@@ -82,11 +82,11 @@
82
82
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
83
83
  },
84
84
  "dependencies": {
85
- "@intlayer/api": "8.6.1",
86
- "@intlayer/config": "8.6.1",
87
- "@intlayer/core": "8.6.1",
88
- "@intlayer/editor": "8.6.1",
89
- "@intlayer/types": "8.6.1"
85
+ "@intlayer/api": "8.6.3",
86
+ "@intlayer/config": "8.6.3",
87
+ "@intlayer/core": "8.6.3",
88
+ "@intlayer/editor": "8.6.3",
89
+ "@intlayer/types": "8.6.3"
90
90
  },
91
91
  "devDependencies": {
92
92
  "@sveltejs/adapter-auto": "7.0.1",