svelte-intlayer 5.5.4 → 5.5.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.
Files changed (97) hide show
  1. package/dist/cjs/client/getBrowserLocale.cjs +39 -0
  2. package/dist/cjs/client/getBrowserLocale.cjs.map +1 -0
  3. package/dist/cjs/client/index.cjs +52 -0
  4. package/dist/cjs/client/index.cjs.map +1 -0
  5. package/dist/cjs/client/intlayerContext.cjs +38 -0
  6. package/dist/cjs/client/intlayerContext.cjs.map +1 -0
  7. package/dist/cjs/client/intlayerStore.cjs +42 -0
  8. package/dist/cjs/client/intlayerStore.cjs.map +1 -0
  9. package/dist/cjs/client/useDictionary.cjs +39 -0
  10. package/dist/cjs/client/useDictionary.cjs.map +1 -0
  11. package/dist/cjs/client/useDictionaryDynamic.cjs +57 -0
  12. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -0
  13. package/dist/cjs/client/useIntlayer.cjs +39 -0
  14. package/dist/cjs/client/useIntlayer.cjs.map +1 -0
  15. package/dist/cjs/client/useIntlayerAsync.cjs +63 -0
  16. package/dist/cjs/client/useIntlayerAsync.cjs.map +1 -0
  17. package/dist/cjs/client/useLocale.cjs +47 -0
  18. package/dist/cjs/client/useLocale.cjs.map +1 -0
  19. package/dist/cjs/getDictionary.cjs +43 -0
  20. package/dist/cjs/getDictionary.cjs.map +1 -0
  21. package/dist/cjs/getIntlayer.cjs +39 -0
  22. package/dist/cjs/getIntlayer.cjs.map +1 -0
  23. package/dist/cjs/index.cjs +10 -4
  24. package/dist/cjs/index.cjs.map +1 -1
  25. package/dist/cjs/markdown/index.cjs +39 -0
  26. package/dist/cjs/markdown/index.cjs.map +1 -0
  27. package/dist/cjs/plugins.cjs +53 -0
  28. package/dist/cjs/plugins.cjs.map +1 -0
  29. package/dist/esm/client/getBrowserLocale.mjs +15 -0
  30. package/dist/esm/client/getBrowserLocale.mjs.map +1 -0
  31. package/dist/esm/client/index.mjs +20 -0
  32. package/dist/esm/client/index.mjs.map +1 -0
  33. package/dist/esm/client/intlayerContext.mjs +13 -0
  34. package/dist/esm/client/intlayerContext.mjs.map +1 -0
  35. package/dist/esm/client/intlayerStore.mjs +18 -0
  36. package/dist/esm/client/intlayerStore.mjs.map +1 -0
  37. package/dist/esm/client/useDictionary.mjs +15 -0
  38. package/dist/esm/client/useDictionary.mjs.map +1 -0
  39. package/dist/esm/client/useDictionaryDynamic.mjs +33 -0
  40. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -0
  41. package/dist/esm/client/useIntlayer.mjs +15 -0
  42. package/dist/esm/client/useIntlayer.mjs.map +1 -0
  43. package/dist/esm/client/useIntlayerAsync.mjs +29 -0
  44. package/dist/esm/client/useIntlayerAsync.mjs.map +1 -0
  45. package/dist/esm/client/useLocale.mjs +23 -0
  46. package/dist/esm/client/useLocale.mjs.map +1 -0
  47. package/dist/esm/getDictionary.mjs +25 -0
  48. package/dist/esm/getDictionary.mjs.map +1 -0
  49. package/dist/esm/getIntlayer.mjs +21 -0
  50. package/dist/esm/getIntlayer.mjs.map +1 -0
  51. package/dist/esm/index.mjs +5 -2
  52. package/dist/esm/index.mjs.map +1 -1
  53. package/dist/esm/markdown/index.mjs +14 -0
  54. package/dist/esm/markdown/index.mjs.map +1 -0
  55. package/dist/esm/plugins.mjs +27 -0
  56. package/dist/esm/plugins.mjs.map +1 -0
  57. package/dist/types/client/getBrowserLocale.d.ts +7 -0
  58. package/dist/types/client/getBrowserLocale.d.ts.map +1 -0
  59. package/dist/types/client/index.d.ts +10 -0
  60. package/dist/types/client/index.d.ts.map +1 -0
  61. package/dist/types/client/intlayerContext.d.ts +8 -0
  62. package/dist/types/client/intlayerContext.d.ts.map +1 -0
  63. package/dist/types/client/intlayerStore.d.ts +12 -0
  64. package/dist/types/client/intlayerStore.d.ts.map +1 -0
  65. package/dist/types/client/useDictionary.d.ts +12 -0
  66. package/dist/types/client/useDictionary.d.ts.map +1 -0
  67. package/dist/types/client/useDictionaryDynamic.d.ts +12 -0
  68. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -0
  69. package/dist/types/client/useIntlayer.d.ts +13 -0
  70. package/dist/types/client/useIntlayer.d.ts.map +1 -0
  71. package/dist/types/client/useIntlayerAsync.d.ts +13 -0
  72. package/dist/types/client/useIntlayerAsync.d.ts.map +1 -0
  73. package/dist/types/client/useLocale.d.ts +9 -0
  74. package/dist/types/client/useLocale.d.ts.map +1 -0
  75. package/dist/types/getDictionary.d.ts +12 -0
  76. package/dist/types/getDictionary.d.ts.map +1 -0
  77. package/dist/types/getIntlayer.d.ts +12 -0
  78. package/dist/types/getIntlayer.d.ts.map +1 -0
  79. package/dist/types/index.d.ts +10 -2
  80. package/dist/types/index.d.ts.map +1 -1
  81. package/dist/types/markdown/index.d.ts +28 -0
  82. package/dist/types/markdown/index.d.ts.map +1 -0
  83. package/dist/types/plugins.d.ts +32 -0
  84. package/dist/types/plugins.d.ts.map +1 -0
  85. package/package.json +12 -9
  86. package/dist/cjs/intlayerMiddlewarePlugin.cjs +0 -224
  87. package/dist/cjs/intlayerMiddlewarePlugin.cjs.map +0 -1
  88. package/dist/cjs/intlayerPlugin.cjs +0 -76
  89. package/dist/cjs/intlayerPlugin.cjs.map +0 -1
  90. package/dist/esm/intlayerMiddlewarePlugin.mjs +0 -200
  91. package/dist/esm/intlayerMiddlewarePlugin.mjs.map +0 -1
  92. package/dist/esm/intlayerPlugin.mjs +0 -52
  93. package/dist/esm/intlayerPlugin.mjs.map +0 -1
  94. package/dist/types/intlayerMiddlewarePlugin.d.ts +0 -6
  95. package/dist/types/intlayerMiddlewarePlugin.d.ts.map +0 -1
  96. package/dist/types/intlayerPlugin.d.ts +0 -16
  97. package/dist/types/intlayerPlugin.d.ts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/markdown/index.ts"],"sourcesContent":["/**\n * Markdown support for Svelte Intlayer\n * This module provides markdown rendering capabilities for Svelte applications\n */\n\nexport interface MarkdownProps {\n children: string;\n [key: string]: any;\n}\n\n/**\n * Basic markdown processor for Svelte\n * This can be extended to use more sophisticated markdown libraries\n * @param content Markdown content to process\n * @returns Processed content (for now, returns as-is)\n */\nexport const processMarkdown = (content: string): string => {\n // Basic markdown processing - can be extended with a proper markdown parser\n // For example, you could integrate with marked, markdown-it, or similar libraries\n return content;\n};\n\n/**\n * Markdown renderer component interface for Svelte\n * This defines the expected interface for a markdown component\n */\nexport interface MarkdownRenderer {\n render: (content: string) => string;\n configure?: (options: any) => void;\n}\n\n/**\n * Default markdown renderer implementation\n */\nexport const defaultMarkdownRenderer: MarkdownRenderer = {\n render: processMarkdown,\n configure: (options: any) => {\n // Configuration logic for markdown rendering\n console.log('Configuring markdown renderer with options:', options);\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBO,MAAM,kBAAkB,CAAC,YAA4B;AAG1D,SAAO;AACT;AAcO,MAAM,0BAA4C;AAAA,EACvD,QAAQ;AAAA,EACR,WAAW,CAAC,YAAiB;AAE3B,YAAQ,IAAI,+CAA+C,OAAO;AAAA,EACpE;AACF;","names":[]}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var plugins_exports = {};
20
+ __export(plugins_exports, {
21
+ intlayerNodePlugins: () => intlayerNodePlugins,
22
+ markdownPlugin: () => markdownPlugin,
23
+ svelteNodePlugins: () => svelteNodePlugins
24
+ });
25
+ module.exports = __toCommonJS(plugins_exports);
26
+ const svelteNodePlugins = {
27
+ id: "svelte-node-plugin",
28
+ canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
29
+ transform: (node, { children, ...rest }) => {
30
+ return children ?? node;
31
+ }
32
+ };
33
+ const intlayerNodePlugins = {
34
+ id: "intlayer-node-plugin",
35
+ canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
36
+ transform: (node, { children, ...rest }) => {
37
+ return children ?? node;
38
+ }
39
+ };
40
+ const markdownPlugin = {
41
+ id: "markdown-plugin",
42
+ canHandle: (node) => typeof node === "string",
43
+ transform: (node, props) => {
44
+ return node;
45
+ }
46
+ };
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ intlayerNodePlugins,
50
+ markdownPlugin,
51
+ svelteNodePlugins
52
+ });
53
+ //# sourceMappingURL=plugins.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/plugins.ts"],"sourcesContent":["import type { Plugins } from '@intlayer/core';\n\n/**\n * Interface for Svelte-specific plugin functionality\n * This interface can be augmented to add more Svelte-specific transformations\n */\nexport interface IInterpreterPluginSvelte<T> {\n /** Any Svelte-specific properties can be added here */\n svelteRendered?: T;\n}\n\n/**\n * Type that represents the deep transformation of content for Svelte\n * This applies Svelte-specific transformations recursively to all content\n */\nexport type DeepTransformContent<T> = T extends object\n ? {\n [K in keyof T]: DeepTransformContent<T[K]>;\n } & IInterpreterPluginSvelte<T>\n : T;\n\n/**\n * Svelte-specific node plugins for handling basic content types\n * These plugins handle strings, numbers, and bigints in Svelte applications\n */\nexport const svelteNodePlugins: Plugins = {\n id: 'svelte-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (node, { children, ...rest }) => {\n // For Svelte, we can return the raw content as Svelte handles reactivity automatically\n // In more complex scenarios, you might want to wrap content in Svelte components\n return children ?? node;\n },\n};\n\n/**\n * Basic Intlayer node plugins for content handling\n * These handle the core content transformation logic\n */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (node, { children, ...rest }) => {\n // Return the processed children or the node itself\n return children ?? node;\n },\n};\n\n/**\n * Markdown plugin for handling markdown content in Svelte\n * This can be extended to integrate with Svelte markdown processors\n */\nexport const markdownPlugin: Plugins = {\n id: 'markdown-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node, props) => {\n // Basic markdown handling - can be extended with proper markdown parser\n return node;\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyBO,MAAM,oBAA6B;AAAA,EACxC,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;AAAA,EAClB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,KAAK,MAAM;AAG1C,WAAO,YAAY;AAAA,EACrB;AACF;AAMO,MAAM,sBAA+B;AAAA,EAC1C,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;AAAA,EAClB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,KAAK,MAAM;AAE1C,WAAO,YAAY;AAAA,EACrB;AACF;AAMO,MAAM,iBAA0B;AAAA,EACrC,IAAI;AAAA,EACJ,WAAW,CAAC,SAAS,OAAO,SAAS;AAAA,EACrC,WAAW,CAAC,MAAM,UAAU;AAE1B,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -0,0 +1,15 @@
1
+ const getBrowserLocale = () => {
2
+ if (typeof navigator === "undefined") {
3
+ return "en";
4
+ }
5
+ const browserLocale = navigator.language || navigator.languages?.[0];
6
+ if (!browserLocale) {
7
+ return "en";
8
+ }
9
+ const languageCode = browserLocale.split("-")[0];
10
+ return languageCode || "en";
11
+ };
12
+ export {
13
+ getBrowserLocale
14
+ };
15
+ //# sourceMappingURL=getBrowserLocale.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/getBrowserLocale.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\n\n/**\n * Gets the user's preferred locale from browser settings\n * @returns The detected browser locale or 'en' as fallback\n */\nexport const getBrowserLocale = (): LocalesValues => {\n if (typeof navigator === 'undefined') {\n return 'en' as LocalesValues;\n }\n\n // Get the first preferred language\n const browserLocale = navigator.language || navigator.languages?.[0];\n\n if (!browserLocale) {\n return 'en' as LocalesValues;\n }\n\n // Extract language code (e.g., 'en-US' -> 'en')\n const languageCode = browserLocale.split('-')[0];\n\n return (languageCode || 'en') as LocalesValues;\n};\n"],"mappings":"AAMO,MAAM,mBAAmB,MAAqB;AACnD,MAAI,OAAO,cAAc,aAAa;AACpC,WAAO;AAAA,EACT;AAGA,QAAM,gBAAgB,UAAU,YAAY,UAAU,YAAY,CAAC;AAEnE,MAAI,CAAC,eAAe;AAClB,WAAO;AAAA,EACT;AAGA,QAAM,eAAe,cAAc,MAAM,GAAG,EAAE,CAAC;AAE/C,SAAQ,gBAAgB;AAC1B;","names":[]}
@@ -0,0 +1,20 @@
1
+ import { useDictionary } from "./useDictionary.mjs";
2
+ import { useDictionaryDynamic } from "./useDictionaryDynamic.mjs";
3
+ import { useIntlayer } from "./useIntlayer.mjs";
4
+ import { useIntlayerAsync } from "./useIntlayerAsync.mjs";
5
+ import { getIntlayerContext, setIntlayerContext } from "./intlayerContext.mjs";
6
+ import { intlayerStore } from "./intlayerStore.mjs";
7
+ import { getBrowserLocale } from "./getBrowserLocale.mjs";
8
+ import { useLocale } from "./useLocale.mjs";
9
+ export {
10
+ getBrowserLocale,
11
+ getIntlayerContext,
12
+ intlayerStore,
13
+ setIntlayerContext,
14
+ useDictionary,
15
+ useDictionaryDynamic,
16
+ useIntlayer,
17
+ useIntlayerAsync,
18
+ useLocale
19
+ };
20
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["// Export all client-side functionality for Svelte applications\n\n// Core hooks\nexport { useDictionary } from './useDictionary';\nexport { useDictionaryDynamic } from './useDictionaryDynamic';\nexport { useIntlayer } from './useIntlayer';\nexport { useIntlayerAsync } from './useIntlayerAsync';\n\n// Context and providers\nexport { getIntlayerContext, setIntlayerContext } from './intlayerContext';\nexport { intlayerStore } from './intlayerStore';\n\n// Locale management\nexport { getBrowserLocale } from './getBrowserLocale';\nexport { useLocale } from './useLocale';\n\n// Type exports\nexport type { IntlayerStoreType } from './intlayerStore';\n"],"mappings":"AAGA,SAAS,qBAAqB;AAC9B,SAAS,4BAA4B;AACrC,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AAGjC,SAAS,oBAAoB,0BAA0B;AACvD,SAAS,qBAAqB;AAG9B,SAAS,wBAAwB;AACjC,SAAS,iBAAiB;","names":[]}
@@ -0,0 +1,13 @@
1
+ import { getContext, setContext } from "svelte";
2
+ const INTLAYER_CONTEXT_KEY = Symbol("intlayer");
3
+ const setIntlayerContext = (context) => {
4
+ setContext(INTLAYER_CONTEXT_KEY, context);
5
+ };
6
+ const getIntlayerContext = () => {
7
+ return getContext(INTLAYER_CONTEXT_KEY);
8
+ };
9
+ export {
10
+ getIntlayerContext,
11
+ setIntlayerContext
12
+ };
13
+ //# sourceMappingURL=intlayerContext.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/intlayerContext.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport { getContext, setContext } from 'svelte';\n\nexport interface IntlayerContextType {\n locale: LocalesValues;\n setLocale: (locale: LocalesValues) => void;\n}\n\nconst INTLAYER_CONTEXT_KEY = Symbol('intlayer');\n\nexport const setIntlayerContext = (context: IntlayerContextType) => {\n setContext(INTLAYER_CONTEXT_KEY, context);\n};\n\nexport const getIntlayerContext = (): IntlayerContextType | undefined => {\n return getContext(INTLAYER_CONTEXT_KEY);\n};\n"],"mappings":"AACA,SAAS,YAAY,kBAAkB;AAOvC,MAAM,uBAAuB,OAAO,UAAU;AAEvC,MAAM,qBAAqB,CAAC,YAAiC;AAClE,aAAW,sBAAsB,OAAO;AAC1C;AAEO,MAAM,qBAAqB,MAAuC;AACvE,SAAO,WAAW,oBAAoB;AACxC;","names":[]}
@@ -0,0 +1,18 @@
1
+ import { derived, writable } from "svelte/store";
2
+ const createIntlayerStore = () => {
3
+ const { subscribe, set, update } = writable({
4
+ locale: "en"
5
+ // Default locale
6
+ });
7
+ return {
8
+ subscribe,
9
+ setLocale: (locale) => update((store) => ({ ...store, locale })),
10
+ getLocale: () => derived({ subscribe }, ($store) => $store.locale),
11
+ reset: () => set({ locale: "en" })
12
+ };
13
+ };
14
+ const intlayerStore = createIntlayerStore();
15
+ export {
16
+ intlayerStore
17
+ };
18
+ //# sourceMappingURL=intlayerStore.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/intlayerStore.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport { derived, writable, type Readable, type Writable } from 'svelte/store';\n\nexport interface IntlayerStoreType {\n locale: LocalesValues;\n}\n\n// Create the main intlayer store\nconst createIntlayerStore = () => {\n const { subscribe, set, update }: Writable<IntlayerStoreType> = writable({\n locale: 'en' as LocalesValues, // Default locale\n });\n\n return {\n subscribe,\n setLocale: (locale: LocalesValues) =>\n update((store) => ({ ...store, locale })),\n getLocale: (): Readable<LocalesValues> =>\n derived({ subscribe }, ($store) => $store.locale),\n reset: () => set({ locale: 'en' as LocalesValues }),\n };\n};\n\nexport const intlayerStore = createIntlayerStore();\n"],"mappings":"AACA,SAAS,SAAS,gBAA8C;AAOhE,MAAM,sBAAsB,MAAM;AAChC,QAAM,EAAE,WAAW,KAAK,OAAO,IAAiC,SAAS;AAAA,IACvE,QAAQ;AAAA;AAAA,EACV,CAAC;AAED,SAAO;AAAA,IACL;AAAA,IACA,WAAW,CAAC,WACV,OAAO,CAAC,WAAW,EAAE,GAAG,OAAO,OAAO,EAAE;AAAA,IAC1C,WAAW,MACT,QAAQ,EAAE,UAAU,GAAG,CAAC,WAAW,OAAO,MAAM;AAAA,IAClD,OAAO,MAAM,IAAI,EAAE,QAAQ,KAAsB,CAAC;AAAA,EACpD;AACF;AAEO,MAAM,gBAAgB,oBAAoB;","names":[]}
@@ -0,0 +1,15 @@
1
+ import { derived } from "svelte/store";
2
+ import { getDictionary } from "../getDictionary.mjs";
3
+ import { getIntlayerContext } from "./intlayerContext.mjs";
4
+ import { intlayerStore } from "./intlayerStore.mjs";
5
+ const useDictionary = (dictionary, locale) => {
6
+ const context = getIntlayerContext();
7
+ return derived([intlayerStore], ([$store]) => {
8
+ const targetLocale = locale ?? context?.locale ?? $store.locale;
9
+ return getDictionary(dictionary, targetLocale);
10
+ });
11
+ };
12
+ export {
13
+ useDictionary
14
+ };
15
+ //# sourceMappingURL=useDictionary.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport { type Dictionary } from '@intlayer/core';\nimport { derived, type Readable } from 'svelte/store';\nimport { getDictionary } from '../getDictionary';\nimport { DeepTransformContent } from '../plugins';\nimport { getIntlayerContext } from './intlayerContext';\nimport { intlayerStore } from './intlayerStore';\n\n/**\n * Svelte hook that transforms a dictionary and returns reactive content\n * @param dictionary The dictionary to transform\n * @param locale The target locale (optional, uses context or store locale)\n * @returns Reactive store with transformed dictionary content\n */\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n): Readable<DeepTransformContent<T['content']>> => {\n const context = getIntlayerContext();\n\n // Create a derived store that reactively updates when locale changes\n return derived([intlayerStore], ([$store]) => {\n const targetLocale = locale ?? context?.locale ?? $store.locale;\n return getDictionary<T, LocalesValues>(dictionary, targetLocale);\n });\n};\n"],"mappings":"AAEA,SAAS,eAA8B;AACvC,SAAS,qBAAqB;AAE9B,SAAS,0BAA0B;AACnC,SAAS,qBAAqB;AAQvB,MAAM,gBAAgB,CAC3B,YACA,WACiD;AACjD,QAAM,UAAU,mBAAmB;AAGnC,SAAO,QAAQ,CAAC,aAAa,GAAG,CAAC,CAAC,MAAM,MAAM;AAC5C,UAAM,eAAe,UAAU,SAAS,UAAU,OAAO;AACzD,WAAO,cAAgC,YAAY,YAAY;AAAA,EACjE,CAAC;AACH;","names":[]}
@@ -0,0 +1,33 @@
1
+ import { derived, writable } from "svelte/store";
2
+ import { getIntlayerContext } from "./intlayerContext.mjs";
3
+ import { intlayerStore } from "./intlayerStore.mjs";
4
+ const useDictionaryDynamic = (dictionaryPromise, key, locale) => {
5
+ const context = getIntlayerContext();
6
+ const dictionaryStore = writable(null);
7
+ return derived([intlayerStore], ([$store]) => {
8
+ const targetLocale = locale ?? context?.locale ?? $store.locale;
9
+ const loadDictionary = async () => {
10
+ try {
11
+ const dictionaryLoader = dictionaryPromise[targetLocale];
12
+ if (dictionaryLoader) {
13
+ const loadedDictionary = await dictionaryLoader();
14
+ dictionaryStore.set(loadedDictionary);
15
+ } else {
16
+ dictionaryStore.set(null);
17
+ }
18
+ } catch (error) {
19
+ console.error(
20
+ `Failed to load dictionary for key: ${String(key)}`,
21
+ error
22
+ );
23
+ dictionaryStore.set(null);
24
+ }
25
+ };
26
+ loadDictionary();
27
+ return null;
28
+ });
29
+ };
30
+ export {
31
+ useDictionaryDynamic
32
+ };
33
+ //# sourceMappingURL=useDictionaryDynamic.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport type {\n Dictionary,\n DictionaryKeys,\n LanguageContent,\n} from '@intlayer/core';\nimport { derived, writable, type Readable } from 'svelte/store';\nimport { getIntlayerContext } from './intlayerContext';\nimport { intlayerStore } from './intlayerStore';\n\n/**\n * Svelte hook for handling dynamic dictionary loading\n * @param dictionaryPromise Promise-based dictionary content\n * @param key Dictionary key for caching\n * @param locale Target locale (optional)\n * @returns Reactive store with loaded dictionary content\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: LanguageContent<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n): Readable<T | null> => {\n const context = getIntlayerContext();\n const dictionaryStore = writable<T | null>(null);\n\n // Create a derived store that loads the dictionary when locale changes\n return derived([intlayerStore], ([$store]) => {\n const targetLocale = locale ?? context?.locale ?? $store.locale;\n\n // Load dictionary for the target locale asynchronously\n const loadDictionary = async () => {\n try {\n const dictionaryLoader = dictionaryPromise[targetLocale];\n if (dictionaryLoader) {\n const loadedDictionary = await dictionaryLoader();\n dictionaryStore.set(loadedDictionary);\n } else {\n dictionaryStore.set(null);\n }\n } catch (error) {\n console.error(\n `Failed to load dictionary for key: ${String(key)}`,\n error\n );\n dictionaryStore.set(null);\n }\n };\n\n loadDictionary();\n\n // Return the current state, actual loading happens asynchronously\n return null;\n });\n};\n"],"mappings":"AAMA,SAAS,SAAS,gBAA+B;AACjD,SAAS,0BAA0B;AACnC,SAAS,qBAAqB;AASvB,MAAM,uBAAuB,CAIlC,mBACA,KACA,WACuB;AACvB,QAAM,UAAU,mBAAmB;AACnC,QAAM,kBAAkB,SAAmB,IAAI;AAG/C,SAAO,QAAQ,CAAC,aAAa,GAAG,CAAC,CAAC,MAAM,MAAM;AAC5C,UAAM,eAAe,UAAU,SAAS,UAAU,OAAO;AAGzD,UAAM,iBAAiB,YAAY;AACjC,UAAI;AACF,cAAM,mBAAmB,kBAAkB,YAAY;AACvD,YAAI,kBAAkB;AACpB,gBAAM,mBAAmB,MAAM,iBAAiB;AAChD,0BAAgB,IAAI,gBAAgB;AAAA,QACtC,OAAO;AACL,0BAAgB,IAAI,IAAI;AAAA,QAC1B;AAAA,MACF,SAAS,OAAO;AACd,gBAAQ;AAAA,UACN,sCAAsC,OAAO,GAAG,CAAC;AAAA,UACjD;AAAA,QACF;AACA,wBAAgB,IAAI,IAAI;AAAA,MAC1B;AAAA,IACF;AAEA,mBAAe;AAGf,WAAO;AAAA,EACT,CAAC;AACH;","names":[]}
@@ -0,0 +1,15 @@
1
+ import { derived } from "svelte/store";
2
+ import { getIntlayer } from "../getIntlayer.mjs";
3
+ import { getIntlayerContext } from "./intlayerContext.mjs";
4
+ import { intlayerStore } from "./intlayerStore.mjs";
5
+ const useIntlayer = (key, locale) => {
6
+ const context = getIntlayerContext();
7
+ return derived([intlayerStore], ([$store]) => {
8
+ const targetLocale = locale ?? context?.locale ?? $store.locale;
9
+ return getIntlayer(key, targetLocale);
10
+ });
11
+ };
12
+ export {
13
+ useIntlayer
14
+ };
15
+ //# sourceMappingURL=useIntlayer.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport type { DictionaryKeys } from '@intlayer/core';\nimport { derived, type Readable } from 'svelte/store';\n// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport { getIntlayer } from '../getIntlayer';\nimport { DeepTransformContent } from '../plugins';\nimport { getIntlayerContext } from './intlayerContext';\nimport { intlayerStore } from './intlayerStore';\n\n/**\n * Svelte hook that picks one dictionary by its key and returns reactive content\n * @param key The dictionary key to retrieve\n * @param locale The target locale (optional, uses context or store locale)\n * @returns Reactive store with transformed dictionary content\n */\nexport const useIntlayer = <T extends DictionaryKeys>(\n key: T,\n locale?: LocalesValues\n): Readable<\n DeepTransformContent<IntlayerDictionaryTypesConnector[T]['content']>\n> => {\n const context = getIntlayerContext();\n\n // Create a derived store that reactively updates when locale changes\n return derived([intlayerStore], ([$store]) => {\n const targetLocale = locale ?? context?.locale ?? $store.locale;\n return getIntlayer(key, targetLocale);\n });\n};\n"],"mappings":"AAEA,SAAS,eAA8B;AAGvC,SAAS,mBAAmB;AAE5B,SAAS,0BAA0B;AACnC,SAAS,qBAAqB;AAQvB,MAAM,cAAc,CACzB,KACA,WAGG;AACH,QAAM,UAAU,mBAAmB;AAGnC,SAAO,QAAQ,CAAC,aAAa,GAAG,CAAC,CAAC,MAAM,MAAM;AAC5C,UAAM,eAAe,UAAU,SAAS,UAAU,OAAO;AACzD,WAAO,YAAY,KAAK,YAAY;AAAA,EACtC,CAAC;AACH;","names":[]}
@@ -0,0 +1,29 @@
1
+ import { derived, writable } from "svelte/store";
2
+ import { getIntlayerContext } from "./intlayerContext.mjs";
3
+ import { intlayerStore } from "./intlayerStore.mjs";
4
+ const useIntlayerAsync = (key, locale) => {
5
+ const context = getIntlayerContext();
6
+ const contentStore = writable(null);
7
+ return derived([intlayerStore], ([$store]) => {
8
+ const targetLocale = locale ?? context?.locale ?? $store.locale;
9
+ const loadDictionary = async () => {
10
+ try {
11
+ const { getIntlayerAsync } = await import("@intlayer/core");
12
+ const content = await getIntlayerAsync(key, targetLocale);
13
+ contentStore.set(content);
14
+ } catch (error) {
15
+ console.error(
16
+ `Failed to load async dictionary for key: ${String(key)}`,
17
+ error
18
+ );
19
+ contentStore.set(null);
20
+ }
21
+ };
22
+ loadDictionary();
23
+ return null;
24
+ });
25
+ };
26
+ export {
27
+ useIntlayerAsync
28
+ };
29
+ //# sourceMappingURL=useIntlayerAsync.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/useIntlayerAsync.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport type { DictionaryKeys } from '@intlayer/core';\nimport { derived, writable, type Readable } from 'svelte/store';\n// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport { DeepTransformContent } from '../plugins';\nimport { getIntlayerContext } from './intlayerContext';\nimport { intlayerStore } from './intlayerStore';\n\n/**\n * Svelte hook for asynchronous dictionary loading by key\n * @param key The dictionary key to retrieve\n * @param locale Target locale (optional)\n * @returns Reactive store with loaded dictionary content\n */\nexport const useIntlayerAsync = <T extends DictionaryKeys>(\n key: T,\n locale?: LocalesValues\n): Readable<DeepTransformContent<\n IntlayerDictionaryTypesConnector[T]['content']\n> | null> => {\n const context = getIntlayerContext();\n const contentStore = writable<DeepTransformContent<\n IntlayerDictionaryTypesConnector[T]['content']\n > | null>(null);\n\n // Create a derived store that loads the dictionary when locale changes\n return derived([intlayerStore], ([$store]) => {\n const targetLocale = locale ?? context?.locale ?? $store.locale;\n\n // Load dictionary asynchronously\n const loadDictionary = async () => {\n try {\n // This would typically use getIntlayerAsync from core\n // For now, we'll simulate async loading\n const { getIntlayerAsync } = await import('@intlayer/core');\n const content = await getIntlayerAsync(key, targetLocale);\n contentStore.set(content);\n } catch (error) {\n console.error(\n `Failed to load async dictionary for key: ${String(key)}`,\n error\n );\n contentStore.set(null);\n }\n };\n\n loadDictionary();\n\n // Return the current state, actual loading happens asynchronously\n return null;\n });\n};\n"],"mappings":"AAEA,SAAS,SAAS,gBAA+B;AAIjD,SAAS,0BAA0B;AACnC,SAAS,qBAAqB;AAQvB,MAAM,mBAAmB,CAC9B,KACA,WAGW;AACX,QAAM,UAAU,mBAAmB;AACnC,QAAM,eAAe,SAEX,IAAI;AAGd,SAAO,QAAQ,CAAC,aAAa,GAAG,CAAC,CAAC,MAAM,MAAM;AAC5C,UAAM,eAAe,UAAU,SAAS,UAAU,OAAO;AAGzD,UAAM,iBAAiB,YAAY;AACjC,UAAI;AAGF,cAAM,EAAE,iBAAiB,IAAI,MAAM,OAAO,gBAAgB;AAC1D,cAAM,UAAU,MAAM,iBAAiB,KAAK,YAAY;AACxD,qBAAa,IAAI,OAAO;AAAA,MAC1B,SAAS,OAAO;AACd,gBAAQ;AAAA,UACN,4CAA4C,OAAO,GAAG,CAAC;AAAA,UACvD;AAAA,QACF;AACA,qBAAa,IAAI,IAAI;AAAA,MACvB;AAAA,IACF;AAEA,mBAAe;AAGf,WAAO;AAAA,EACT,CAAC;AACH;","names":[]}
@@ -0,0 +1,23 @@
1
+ import { derived } from "svelte/store";
2
+ import { getIntlayerContext } from "./intlayerContext.mjs";
3
+ import { intlayerStore } from "./intlayerStore.mjs";
4
+ const useLocale = () => {
5
+ const context = getIntlayerContext();
6
+ if (context) {
7
+ return {
8
+ locale: derived(
9
+ [intlayerStore],
10
+ ([$store]) => context.locale || $store.locale
11
+ ),
12
+ setLocale: context.setLocale
13
+ };
14
+ }
15
+ return {
16
+ locale: intlayerStore.getLocale(),
17
+ setLocale: intlayerStore.setLocale
18
+ };
19
+ };
20
+ export {
21
+ useLocale
22
+ };
23
+ //# sourceMappingURL=useLocale.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { derived } from 'svelte/store';\nimport { getIntlayerContext } from './intlayerContext';\nimport { intlayerStore } from './intlayerStore';\n\n/**\n * Hook to get and set the current locale in Svelte applications\n * @returns Readable store with current locale and setter function\n */\nexport const useLocale = () => {\n const context = getIntlayerContext();\n\n if (context) {\n // Use context if available\n return {\n locale: derived(\n [intlayerStore],\n ([$store]) => context.locale || $store.locale\n ),\n setLocale: context.setLocale,\n };\n }\n\n // Fallback to global store\n return {\n locale: intlayerStore.getLocale(),\n setLocale: intlayerStore.setLocale,\n };\n};\n"],"mappings":"AAAA,SAAS,eAAe;AACxB,SAAS,0BAA0B;AACnC,SAAS,qBAAqB;AAMvB,MAAM,YAAY,MAAM;AAC7B,QAAM,UAAU,mBAAmB;AAEnC,MAAI,SAAS;AAEX,WAAO;AAAA,MACL,QAAQ;AAAA,QACN,CAAC,aAAa;AAAA,QACd,CAAC,CAAC,MAAM,MAAM,QAAQ,UAAU,OAAO;AAAA,MACzC;AAAA,MACA,WAAW,QAAQ;AAAA,IACrB;AAAA,EACF;AAGA,SAAO;AAAA,IACL,QAAQ,cAAc,UAAU;AAAA,IAChC,WAAW,cAAc;AAAA,EAC3B;AACF;","names":[]}
@@ -0,0 +1,25 @@
1
+ import {
2
+ getDictionary as getDictionaryCore
3
+ } from "@intlayer/core";
4
+ import {
5
+ intlayerNodePlugins,
6
+ markdownPlugin,
7
+ svelteNodePlugins
8
+ } from "./plugins.mjs";
9
+ const getDictionary = (dictionary, locale, additionalPlugins) => {
10
+ const plugins = [
11
+ intlayerNodePlugins,
12
+ svelteNodePlugins,
13
+ markdownPlugin,
14
+ ...additionalPlugins ?? []
15
+ ];
16
+ return getDictionaryCore(
17
+ dictionary,
18
+ locale,
19
+ plugins
20
+ );
21
+ };
22
+ export {
23
+ getDictionary
24
+ };
25
+ //# sourceMappingURL=getDictionary.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/getDictionary.ts"],"sourcesContent":["import type { Locales, LocalesValues } from '@intlayer/config/client';\nimport {\n Dictionary,\n Plugins,\n getDictionary as getDictionaryCore,\n} from '@intlayer/core';\nimport {\n DeepTransformContent,\n intlayerNodePlugins,\n markdownPlugin,\n svelteNodePlugins,\n} from './plugins';\n\n/**\n * Get dictionary content for a specific locale in Svelte applications\n * @param dictionary The dictionary object to transform\n * @param locale The target locale (optional, defaults to current locale)\n * @param additionalPlugins Additional transformation plugins\n * @returns Transformed dictionary content optimized for Svelte\n */\nexport const getDictionary = <\n T extends Dictionary,\n L extends LocalesValues = Locales,\n>(\n dictionary: T,\n locale?: L,\n additionalPlugins?: Plugins[]\n) => {\n const plugins: Plugins[] = [\n intlayerNodePlugins,\n svelteNodePlugins,\n markdownPlugin,\n ...(additionalPlugins ?? []),\n ];\n\n return getDictionaryCore(\n dictionary,\n locale,\n plugins\n ) as any as DeepTransformContent<T['content']>;\n};\n"],"mappings":"AACA;AAAA,EAGE,iBAAiB;AAAA,OACZ;AACP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AASA,MAAM,gBAAgB,CAI3B,YACA,QACA,sBACG;AACH,QAAM,UAAqB;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAI,qBAAqB,CAAC;AAAA,EAC5B;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,21 @@
1
+ import {
2
+ getIntlayer as getIntlayerCore
3
+ } from "@intlayer/core";
4
+ import {
5
+ intlayerNodePlugins,
6
+ markdownPlugin,
7
+ svelteNodePlugins
8
+ } from "./plugins.mjs";
9
+ const getIntlayer = (key, locale, additionalPlugins) => {
10
+ const plugins = [
11
+ intlayerNodePlugins,
12
+ svelteNodePlugins,
13
+ markdownPlugin,
14
+ ...additionalPlugins ?? []
15
+ ];
16
+ return getIntlayerCore(key, locale, plugins);
17
+ };
18
+ export {
19
+ getIntlayer
20
+ };
21
+ //# sourceMappingURL=getIntlayer.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import {\n DictionaryKeys,\n getIntlayer as getIntlayerCore,\n Plugins,\n} from '@intlayer/core';\n// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector, LocalesValues } from 'intlayer';\nimport {\n DeepTransformContent,\n intlayerNodePlugins,\n markdownPlugin,\n svelteNodePlugins,\n} from './plugins';\n\n/**\n * Get dictionary content by key for Svelte applications\n * @param key The dictionary key to retrieve\n * @param locale The target locale (optional)\n * @param additionalPlugins Additional transformation plugins\n * @returns Transformed dictionary content optimized for Svelte\n */\nexport const getIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: L,\n additionalPlugins?: Plugins[]\n) => {\n const plugins: Plugins[] = [\n intlayerNodePlugins,\n svelteNodePlugins,\n markdownPlugin,\n ...(additionalPlugins ?? []),\n ];\n\n return getIntlayerCore(key, locale, plugins) as any as DeepTransformContent<\n IntlayerDictionaryTypesConnector[T]['content']\n >;\n};\n"],"mappings":"AAAA;AAAA,EAEE,eAAe;AAAA,OAEV;AAGP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AASA,MAAM,cAAc,CACzB,KACA,QACA,sBACG;AACH,QAAM,UAAqB;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAI,qBAAqB,CAAC;AAAA,EAC5B;AAEA,SAAO,gBAAgB,KAAK,QAAQ,OAAO;AAG7C;","names":[]}
@@ -1,3 +1,6 @@
1
- export * from "./intlayerPlugin.mjs";
2
- export * from "./intlayerMiddlewarePlugin.mjs";
1
+ export * from "./client/index.mjs";
2
+ export * from "./getDictionary.mjs";
3
+ export * from "./getIntlayer.mjs";
4
+ export * from "./markdown/index.mjs";
5
+ export * from "./plugins.mjs";
3
6
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './intlayerPlugin';\nexport * from './intlayerMiddlewarePlugin';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import { IInterpreterPluginSvelte } from './plugins';\n\ndeclare module '@intlayer/core' {\n interface IInterpreterPlugin<T, S> extends IInterpreterPluginSvelte<T> {}\n}\n\nexport * from './client';\nexport * from './getDictionary';\nexport * from './getIntlayer';\nexport * from './markdown';\nexport * from './plugins';\n"],"mappings":"AAMA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
@@ -0,0 +1,14 @@
1
+ const processMarkdown = (content) => {
2
+ return content;
3
+ };
4
+ const defaultMarkdownRenderer = {
5
+ render: processMarkdown,
6
+ configure: (options) => {
7
+ console.log("Configuring markdown renderer with options:", options);
8
+ }
9
+ };
10
+ export {
11
+ defaultMarkdownRenderer,
12
+ processMarkdown
13
+ };
14
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/markdown/index.ts"],"sourcesContent":["/**\n * Markdown support for Svelte Intlayer\n * This module provides markdown rendering capabilities for Svelte applications\n */\n\nexport interface MarkdownProps {\n children: string;\n [key: string]: any;\n}\n\n/**\n * Basic markdown processor for Svelte\n * This can be extended to use more sophisticated markdown libraries\n * @param content Markdown content to process\n * @returns Processed content (for now, returns as-is)\n */\nexport const processMarkdown = (content: string): string => {\n // Basic markdown processing - can be extended with a proper markdown parser\n // For example, you could integrate with marked, markdown-it, or similar libraries\n return content;\n};\n\n/**\n * Markdown renderer component interface for Svelte\n * This defines the expected interface for a markdown component\n */\nexport interface MarkdownRenderer {\n render: (content: string) => string;\n configure?: (options: any) => void;\n}\n\n/**\n * Default markdown renderer implementation\n */\nexport const defaultMarkdownRenderer: MarkdownRenderer = {\n render: processMarkdown,\n configure: (options: any) => {\n // Configuration logic for markdown rendering\n console.log('Configuring markdown renderer with options:', options);\n },\n};\n"],"mappings":"AAgBO,MAAM,kBAAkB,CAAC,YAA4B;AAG1D,SAAO;AACT;AAcO,MAAM,0BAA4C;AAAA,EACvD,QAAQ;AAAA,EACR,WAAW,CAAC,YAAiB;AAE3B,YAAQ,IAAI,+CAA+C,OAAO;AAAA,EACpE;AACF;","names":[]}
@@ -0,0 +1,27 @@
1
+ const svelteNodePlugins = {
2
+ id: "svelte-node-plugin",
3
+ canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
4
+ transform: (node, { children, ...rest }) => {
5
+ return children ?? node;
6
+ }
7
+ };
8
+ const intlayerNodePlugins = {
9
+ id: "intlayer-node-plugin",
10
+ canHandle: (node) => typeof node === "bigint" || typeof node === "string" || typeof node === "number",
11
+ transform: (node, { children, ...rest }) => {
12
+ return children ?? node;
13
+ }
14
+ };
15
+ const markdownPlugin = {
16
+ id: "markdown-plugin",
17
+ canHandle: (node) => typeof node === "string",
18
+ transform: (node, props) => {
19
+ return node;
20
+ }
21
+ };
22
+ export {
23
+ intlayerNodePlugins,
24
+ markdownPlugin,
25
+ svelteNodePlugins
26
+ };
27
+ //# sourceMappingURL=plugins.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/plugins.ts"],"sourcesContent":["import type { Plugins } from '@intlayer/core';\n\n/**\n * Interface for Svelte-specific plugin functionality\n * This interface can be augmented to add more Svelte-specific transformations\n */\nexport interface IInterpreterPluginSvelte<T> {\n /** Any Svelte-specific properties can be added here */\n svelteRendered?: T;\n}\n\n/**\n * Type that represents the deep transformation of content for Svelte\n * This applies Svelte-specific transformations recursively to all content\n */\nexport type DeepTransformContent<T> = T extends object\n ? {\n [K in keyof T]: DeepTransformContent<T[K]>;\n } & IInterpreterPluginSvelte<T>\n : T;\n\n/**\n * Svelte-specific node plugins for handling basic content types\n * These plugins handle strings, numbers, and bigints in Svelte applications\n */\nexport const svelteNodePlugins: Plugins = {\n id: 'svelte-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (node, { children, ...rest }) => {\n // For Svelte, we can return the raw content as Svelte handles reactivity automatically\n // In more complex scenarios, you might want to wrap content in Svelte components\n return children ?? node;\n },\n};\n\n/**\n * Basic Intlayer node plugins for content handling\n * These handle the core content transformation logic\n */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (node, { children, ...rest }) => {\n // Return the processed children or the node itself\n return children ?? node;\n },\n};\n\n/**\n * Markdown plugin for handling markdown content in Svelte\n * This can be extended to integrate with Svelte markdown processors\n */\nexport const markdownPlugin: Plugins = {\n id: 'markdown-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node, props) => {\n // Basic markdown handling - can be extended with proper markdown parser\n return node;\n },\n};\n"],"mappings":"AAyBO,MAAM,oBAA6B;AAAA,EACxC,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;AAAA,EAClB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,KAAK,MAAM;AAG1C,WAAO,YAAY;AAAA,EACrB;AACF;AAMO,MAAM,sBAA+B;AAAA,EAC1C,IAAI;AAAA,EACJ,WAAW,CAAC,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;AAAA,EAClB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,KAAK,MAAM;AAE1C,WAAO,YAAY;AAAA,EACrB;AACF;AAMO,MAAM,iBAA0B;AAAA,EACrC,IAAI;AAAA,EACJ,WAAW,CAAC,SAAS,OAAO,SAAS;AAAA,EACrC,WAAW,CAAC,MAAM,UAAU;AAE1B,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -0,0 +1,7 @@
1
+ import type { LocalesValues } from '@intlayer/config/client';
2
+ /**
3
+ * Gets the user's preferred locale from browser settings
4
+ * @returns The detected browser locale or 'en' as fallback
5
+ */
6
+ export declare const getBrowserLocale: () => LocalesValues;
7
+ //# sourceMappingURL=getBrowserLocale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getBrowserLocale.d.ts","sourceRoot":"","sources":["../../../src/client/getBrowserLocale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;;GAGG;AACH,eAAO,MAAM,gBAAgB,QAAO,aAgBnC,CAAC"}
@@ -0,0 +1,10 @@
1
+ export { useDictionary } from './useDictionary';
2
+ export { useDictionaryDynamic } from './useDictionaryDynamic';
3
+ export { useIntlayer } from './useIntlayer';
4
+ export { useIntlayerAsync } from './useIntlayerAsync';
5
+ export { getIntlayerContext, setIntlayerContext } from './intlayerContext';
6
+ export { intlayerStore } from './intlayerStore';
7
+ export { getBrowserLocale } from './getBrowserLocale';
8
+ export { useLocale } from './useLocale';
9
+ export type { IntlayerStoreType } from './intlayerStore';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { LocalesValues } from '@intlayer/config/client';
2
+ export interface IntlayerContextType {
3
+ locale: LocalesValues;
4
+ setLocale: (locale: LocalesValues) => void;
5
+ }
6
+ export declare const setIntlayerContext: (context: IntlayerContextType) => void;
7
+ export declare const getIntlayerContext: () => IntlayerContextType | undefined;
8
+ //# sourceMappingURL=intlayerContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intlayerContext.d.ts","sourceRoot":"","sources":["../../../src/client/intlayerContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG7D,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,aAAa,CAAC;IACtB,SAAS,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;CAC5C;AAID,eAAO,MAAM,kBAAkB,GAAI,SAAS,mBAAmB,SAE9D,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAAO,mBAAmB,GAAG,SAE3D,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { LocalesValues } from '@intlayer/config/client';
2
+ import { type Readable } from 'svelte/store';
3
+ export interface IntlayerStoreType {
4
+ locale: LocalesValues;
5
+ }
6
+ export declare const intlayerStore: {
7
+ subscribe: (this: void, run: import("svelte/store").Subscriber<IntlayerStoreType>, invalidate?: () => void) => import("svelte/store").Unsubscriber;
8
+ setLocale: (locale: LocalesValues) => void;
9
+ getLocale: () => Readable<LocalesValues>;
10
+ reset: () => void;
11
+ };
12
+ //# sourceMappingURL=intlayerStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intlayerStore.d.ts","sourceRoot":"","sources":["../../../src/client/intlayerStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAqB,KAAK,QAAQ,EAAiB,MAAM,cAAc,CAAC;AAE/E,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,aAAa,CAAC;CACvB;AAkBD,eAAO,MAAM,aAAa;;wBARF,aAAa;qBAElB,QAAQ,CAAC,aAAa,CAAC;;CAMQ,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { LocalesValues } from '@intlayer/config/client';
2
+ import { type Dictionary } from '@intlayer/core';
3
+ import { type Readable } from 'svelte/store';
4
+ import { DeepTransformContent } from '../plugins';
5
+ /**
6
+ * Svelte hook that transforms a dictionary and returns reactive content
7
+ * @param dictionary The dictionary to transform
8
+ * @param locale The target locale (optional, uses context or store locale)
9
+ * @returns Reactive store with transformed dictionary content
10
+ */
11
+ export declare const useDictionary: <T extends Dictionary>(dictionary: T, locale?: LocalesValues) => Readable<DeepTransformContent<T["content"]>>;
12
+ //# sourceMappingURL=useDictionary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDictionary.d.ts","sourceRoot":"","sources":["../../../src/client/useDictionary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAW,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAIlD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,UAAU,EAChD,YAAY,CAAC,EACb,SAAS,aAAa,KACrB,QAAQ,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAQ7C,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { LocalesValues } from '@intlayer/config/client';
2
+ import type { Dictionary, DictionaryKeys, LanguageContent } from '@intlayer/core';
3
+ import { type Readable } from 'svelte/store';
4
+ /**
5
+ * Svelte hook for handling dynamic dictionary loading
6
+ * @param dictionaryPromise Promise-based dictionary content
7
+ * @param key Dictionary key for caching
8
+ * @param locale Target locale (optional)
9
+ * @returns Reactive store with loaded dictionary content
10
+ */
11
+ export declare const useDictionaryDynamic: <T extends Dictionary, K extends DictionaryKeys>(dictionaryPromise: LanguageContent<() => Promise<T>>, key: K, locale?: LocalesValues) => Readable<T | null>;
12
+ //# sourceMappingURL=useDictionaryDynamic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDictionaryDynamic.d.ts","sourceRoot":"","sources":["../../../src/client/useDictionaryDynamic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,eAAe,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAqB,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAIhE;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,cAAc,EAExB,mBAAmB,eAAe,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,EACpD,KAAK,CAAC,EACN,SAAS,aAAa,KACrB,QAAQ,CAAC,CAAC,GAAG,IAAI,CAgCnB,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { LocalesValues } from '@intlayer/config/client';
2
+ import type { DictionaryKeys } from '@intlayer/core';
3
+ import { type Readable } from 'svelte/store';
4
+ import type { IntlayerDictionaryTypesConnector } from 'intlayer';
5
+ import { DeepTransformContent } from '../plugins';
6
+ /**
7
+ * Svelte hook that picks one dictionary by its key and returns reactive content
8
+ * @param key The dictionary key to retrieve
9
+ * @param locale The target locale (optional, uses context or store locale)
10
+ * @returns Reactive store with transformed dictionary content
11
+ */
12
+ export declare const useIntlayer: <T extends DictionaryKeys>(key: T, locale?: LocalesValues) => Readable<DeepTransformContent<IntlayerDictionaryTypesConnector[T]["content"]>>;
13
+ //# sourceMappingURL=useIntlayer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIntlayer.d.ts","sourceRoot":"","sources":["../../../src/client/useIntlayer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAW,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAEjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAIlD;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,cAAc,EAClD,KAAK,CAAC,EACN,SAAS,aAAa,KACrB,QAAQ,CACT,oBAAoB,CAAC,gCAAgC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CASrE,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { LocalesValues } from '@intlayer/config/client';
2
+ import type { DictionaryKeys } from '@intlayer/core';
3
+ import { type Readable } from 'svelte/store';
4
+ import type { IntlayerDictionaryTypesConnector } from 'intlayer';
5
+ import { DeepTransformContent } from '../plugins';
6
+ /**
7
+ * Svelte hook for asynchronous dictionary loading by key
8
+ * @param key The dictionary key to retrieve
9
+ * @param locale Target locale (optional)
10
+ * @returns Reactive store with loaded dictionary content
11
+ */
12
+ export declare const useIntlayerAsync: <T extends DictionaryKeys>(key: T, locale?: LocalesValues) => Readable<DeepTransformContent<IntlayerDictionaryTypesConnector[T]["content"]> | null>;
13
+ //# sourceMappingURL=useIntlayerAsync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIntlayerAsync.d.ts","sourceRoot":"","sources":["../../../src/client/useIntlayerAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAqB,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAIlD;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,cAAc,EACvD,KAAK,CAAC,EACN,SAAS,aAAa,KACrB,QAAQ,CAAC,oBAAoB,CAC9B,gCAAgC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAC/C,GAAG,IAAI,CAgCP,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Hook to get and set the current locale in Svelte applications
3
+ * @returns Readable store with current locale and setter function
4
+ */
5
+ export declare const useLocale: () => {
6
+ locale: import("svelte/store").Readable<import("intlayer").LocalesValues>;
7
+ setLocale: (locale: import("intlayer").LocalesValues) => void;
8
+ };
9
+ //# sourceMappingURL=useLocale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLocale.d.ts","sourceRoot":"","sources":["../../../src/client/useLocale.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,eAAO,MAAM,SAAS;;;CAmBrB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { Locales, LocalesValues } from '@intlayer/config/client';
2
+ import { Dictionary, Plugins } from '@intlayer/core';
3
+ import { DeepTransformContent } from './plugins';
4
+ /**
5
+ * Get dictionary content for a specific locale in Svelte applications
6
+ * @param dictionary The dictionary object to transform
7
+ * @param locale The target locale (optional, defaults to current locale)
8
+ * @param additionalPlugins Additional transformation plugins
9
+ * @returns Transformed dictionary content optimized for Svelte
10
+ */
11
+ export declare const getDictionary: <T extends Dictionary, L extends LocalesValues = Locales>(dictionary: T, locale?: L, additionalPlugins?: Plugins[]) => DeepTransformContent<T["content"]>;
12
+ //# sourceMappingURL=getDictionary.d.ts.map