vue-intlayer 5.7.7 → 5.8.0-canary.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.
Files changed (106) hide show
  1. package/README.md +1 -1
  2. package/dist/ContentSelector.vue_vue_type_script_setup_true_lang-87sjUiJI.js +1 -0
  3. package/dist/ContentSelector.vue_vue_type_script_setup_true_lang-pC3olEPG.mjs +73 -0
  4. package/dist/ContentSelectorWrapper.vue_vue_type_script_setup_true_lang-CBP8x_i1.mjs +62 -0
  5. package/dist/ContentSelectorWrapper.vue_vue_type_script_setup_true_lang-kiSW4cfM.js +1 -0
  6. package/dist/EditedContentRenderer.vue_vue_type_script_setup_true_lang-CilQuo_6.js +1 -0
  7. package/dist/EditedContentRenderer.vue_vue_type_script_setup_true_lang-GmacOkG4.mjs +36 -0
  8. package/dist/cjs/UI/ContentSelector.cjs +1 -1
  9. package/dist/cjs/client/useDictionary.cjs +1 -1
  10. package/dist/cjs/client/useDictionaryAsync.cjs +1 -1
  11. package/dist/cjs/client/useDictionaryDynamic.cjs +1 -1
  12. package/dist/cjs/client/useIntlayer.cjs +1 -1
  13. package/dist/cjs/client/useLocale.cjs +1 -1
  14. package/dist/cjs/editor/ContentSelectorWrapper.cjs +1 -1
  15. package/dist/cjs/editor/EditedContentRenderer.cjs +1 -1
  16. package/dist/cjs/editor/EditorSelectorRenderer.cjs +1 -1
  17. package/dist/cjs/editor/communicator.cjs +1 -1
  18. package/dist/cjs/editor/createSharedComposable.cjs +1 -1
  19. package/dist/cjs/editor/editedContent.cjs +1 -1
  20. package/dist/cjs/editor/index.cjs +1 -1
  21. package/dist/cjs/editor/useCrossFrameMessageListener.cjs +1 -1
  22. package/dist/cjs/editor/useEditedContentRenderer.cjs +1 -1
  23. package/dist/cjs/format/index.cjs +1 -0
  24. package/dist/cjs/format/useCompact.cjs +1 -0
  25. package/dist/cjs/format/useCurrency.cjs +1 -0
  26. package/dist/cjs/format/useDate.cjs +1 -0
  27. package/dist/cjs/format/useList.cjs +1 -0
  28. package/dist/cjs/format/useNumber.cjs +1 -0
  29. package/dist/cjs/format/usePercentage.cjs +1 -0
  30. package/dist/cjs/format/useRelativeTime.cjs +1 -0
  31. package/dist/cjs/format/useUnit.cjs +1 -0
  32. package/dist/cjs/plugins.cjs +1 -1
  33. package/dist/esm/UI/ContentSelector.mjs +1 -1
  34. package/dist/esm/client/useDictionary.mjs +13 -16
  35. package/dist/esm/client/useDictionaryAsync.mjs +10 -13
  36. package/dist/esm/client/useDictionaryDynamic.mjs +13 -16
  37. package/dist/esm/client/useIntlayer.mjs +12 -12
  38. package/dist/esm/client/useLocale.mjs +12 -16
  39. package/dist/esm/editor/ContentSelectorWrapper.mjs +1 -1
  40. package/dist/esm/editor/EditedContentRenderer.mjs +1 -1
  41. package/dist/esm/editor/EditorSelectorRenderer.mjs +2 -2
  42. package/dist/esm/editor/communicator.mjs +10 -10
  43. package/dist/esm/editor/createSharedComposable.mjs +1 -1
  44. package/dist/esm/editor/editedContent.mjs +22 -23
  45. package/dist/esm/editor/index.mjs +1 -1
  46. package/dist/esm/editor/useCrossFrameMessageListener.mjs +21 -22
  47. package/dist/esm/editor/useEditedContentRenderer.mjs +7 -7
  48. package/dist/esm/format/index.mjs +18 -0
  49. package/dist/esm/format/useCompact.mjs +16 -0
  50. package/dist/esm/format/useCurrency.mjs +16 -0
  51. package/dist/esm/format/useDate.mjs +16 -0
  52. package/dist/esm/format/useList.mjs +16 -0
  53. package/dist/esm/format/useNumber.mjs +16 -0
  54. package/dist/esm/format/usePercentage.mjs +16 -0
  55. package/dist/esm/format/useRelativeTime.mjs +16 -0
  56. package/dist/esm/format/useUnit.mjs +16 -0
  57. package/dist/esm/plugins.mjs +15 -15
  58. package/dist/types/format/index.d.ts +9 -0
  59. package/dist/types/format/index.d.ts.map +1 -0
  60. package/dist/types/format/useCompact.d.ts +14 -0
  61. package/dist/types/format/useCompact.d.ts.map +1 -0
  62. package/dist/types/format/useCurrency.d.ts +25 -0
  63. package/dist/types/format/useCurrency.d.ts.map +1 -0
  64. package/dist/types/format/useDate.d.ts +23 -0
  65. package/dist/types/format/useDate.d.ts.map +1 -0
  66. package/dist/types/format/useList.d.ts +22 -0
  67. package/dist/types/format/useList.d.ts.map +1 -0
  68. package/dist/types/format/useNumber.d.ts +23 -0
  69. package/dist/types/format/useNumber.d.ts.map +1 -0
  70. package/dist/types/format/usePercentage.d.ts +17 -0
  71. package/dist/types/format/usePercentage.d.ts.map +1 -0
  72. package/dist/types/format/useRelativeTime.d.ts +21 -0
  73. package/dist/types/format/useRelativeTime.d.ts.map +1 -0
  74. package/dist/types/format/useUnit.d.ts +19 -0
  75. package/dist/types/format/useUnit.d.ts.map +1 -0
  76. package/package.json +23 -28
  77. package/dist/ContentSelector.vue_vue_type_script_setup_true_lang-Df1Nt4x_.mjs +0 -75
  78. package/dist/ContentSelector.vue_vue_type_script_setup_true_lang-RwUsyBxL.js +0 -1
  79. package/dist/ContentSelectorWrapper.vue_vue_type_script_setup_true_lang-CcDEyAOE.mjs +0 -68
  80. package/dist/ContentSelectorWrapper.vue_vue_type_script_setup_true_lang-DJRF1I6m.js +0 -1
  81. package/dist/EditedContentRenderer.vue_vue_type_script_setup_true_lang-CvPgk7Z3.mjs +0 -39
  82. package/dist/EditedContentRenderer.vue_vue_type_script_setup_true_lang-Yqrgst_y.js +0 -1
  83. package/dist/cjs/server/IntlayerServerProvider.cjs +0 -1
  84. package/dist/cjs/server/index.cjs +0 -1
  85. package/dist/cjs/server/serverContext.cjs +0 -1
  86. package/dist/cjs/server/t.cjs +0 -1
  87. package/dist/cjs/server/useDictionary.cjs +0 -1
  88. package/dist/cjs/server/useIntlayer.cjs +0 -1
  89. package/dist/esm/server/IntlayerServerProvider.mjs +0 -12
  90. package/dist/esm/server/index.mjs +0 -16
  91. package/dist/esm/server/serverContext.mjs +0 -34
  92. package/dist/esm/server/t.mjs +0 -10
  93. package/dist/esm/server/useDictionary.mjs +0 -10
  94. package/dist/esm/server/useIntlayer.mjs +0 -10
  95. package/dist/types/server/IntlayerServerProvider.d.ts +0 -38
  96. package/dist/types/server/IntlayerServerProvider.d.ts.map +0 -1
  97. package/dist/types/server/index.d.ts +0 -6
  98. package/dist/types/server/index.d.ts.map +0 -1
  99. package/dist/types/server/serverContext.d.ts +0 -35
  100. package/dist/types/server/serverContext.d.ts.map +0 -1
  101. package/dist/types/server/t.d.ts +0 -24
  102. package/dist/types/server/t.d.ts.map +0 -1
  103. package/dist/types/server/useDictionary.d.ts +0 -19
  104. package/dist/types/server/useDictionary.d.ts.map +0 -1
  105. package/dist/types/server/useIntlayer.d.ts +0 -16
  106. package/dist/types/server/useIntlayer.d.ts.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-intlayer",
3
- "version": "5.7.7",
3
+ "version": "5.8.0-canary.0",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your Vue applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -41,15 +41,10 @@
41
41
  "require": "./dist/cjs/index.cjs",
42
42
  "import": "./dist/esm/index.mjs"
43
43
  },
44
- "./server": {
45
- "types": "./dist/types/server/index.d.ts",
46
- "require": "./dist/cjs/server/index.cjs",
47
- "import": "./dist/esm/server/index.mjs"
48
- },
49
- "./editor": {
50
- "types": "./dist/types/editor/index.d.ts",
51
- "require": "./dist/cjs/editor/index.cjs",
52
- "import": "./dist/esm/editor/index.mjs"
44
+ "./format": {
45
+ "types": "./dist/types/format/index.d.ts",
46
+ "require": "./dist/cjs/format/index.cjs",
47
+ "import": "./dist/esm/format/index.mjs"
53
48
  },
54
49
  "./package.json": "./package.json"
55
50
  },
@@ -70,40 +65,40 @@
70
65
  "dependencies": {
71
66
  "js-cookie": "^3.0.5",
72
67
  "uuid": "^11.1.0",
73
- "@intlayer/core": "5.7.7",
74
- "@intlayer/config": "5.7.7",
75
- "@intlayer/editor": "5.7.7",
76
- "@intlayer/dictionaries-entry": "5.7.7",
77
- "@intlayer/api": "5.7.7"
68
+ "@intlayer/config": "5.8.0-canary.0",
69
+ "@intlayer/core": "5.8.0-canary.0",
70
+ "@intlayer/editor": "5.8.0-canary.0",
71
+ "@intlayer/api": "5.8.0-canary.0",
72
+ "@intlayer/dictionaries-entry": "5.8.0-canary.0"
78
73
  },
79
74
  "devDependencies": {
80
75
  "@types/js-cookie": "^3.0.6",
81
- "@types/node": "^22.15.30",
76
+ "@types/node": "^24.2.1",
82
77
  "@typescript-eslint/parser": "^8.33.1",
83
- "@vitejs/plugin-vue": "^5.2.2",
78
+ "@vitejs/plugin-vue": "^6.0.1",
84
79
  "concurrently": "^9.1.2",
85
- "eslint": "^9.28.0",
80
+ "eslint": "^9.33.0",
86
81
  "fast-glob": "^3.3.3",
87
82
  "prettier": "^3.5.3",
88
83
  "rimraf": "^6.0.1",
89
- "typescript": "^5.8.3",
90
- "vite": "^6.3.5",
84
+ "typescript": "^5.9.2",
85
+ "vite": "^7.1.2",
91
86
  "vite-plugin-dts": "^4.5.3",
92
87
  "vitest": "^3.2.2",
93
88
  "@utils/eslint-config": "1.0.4",
94
89
  "@utils/ts-config": "1.0.4",
95
- "@intlayer/backend": "5.7.7",
96
90
  "@utils/ts-config-types": "1.0.4",
97
- "@utils/tsup-config": "1.0.4"
91
+ "@utils/tsup-config": "1.0.4",
92
+ "@intlayer/backend": "5.8.0-canary.0"
98
93
  },
99
94
  "peerDependencies": {
100
95
  "vue": "^3.5.13",
101
- "@intlayer/api": "5.7.7",
102
- "@intlayer/config": "5.7.7",
103
- "@intlayer/core": "5.7.7",
104
- "@intlayer/dictionaries-entry": "5.7.7",
105
- "@intlayer/editor": "5.7.7",
106
- "intlayer": "5.7.7"
96
+ "@intlayer/api": "5.8.0-canary.0",
97
+ "@intlayer/core": "5.8.0-canary.0",
98
+ "@intlayer/config": "5.8.0-canary.0",
99
+ "@intlayer/dictionaries-entry": "5.8.0-canary.0",
100
+ "@intlayer/editor": "5.8.0-canary.0",
101
+ "intlayer": "5.8.0-canary.0"
107
102
  },
108
103
  "engines": {
109
104
  "node": ">=14.18"
@@ -1,75 +0,0 @@
1
- import { defineComponent as _, ref as i, computed as h, useSlots as D, onMounted as E, onBeforeUnmount as B, createElementBlock as O, openBlock as R, normalizeStyle as L, renderSlot as P } from "vue";
2
- const b = 250, x = /* @__PURE__ */ _({
3
- __name: "ContentSelector",
4
- props: {
5
- onClickOutside: { type: Function },
6
- pressDuration: {},
7
- isSelecting: { type: Boolean }
8
- },
9
- emits: ["click", "press", "hover", "unhover"],
10
- setup(S, { emit: T }) {
11
- const o = S, s = T, a = i(null), t = i(!1), l = i(o.isSelecting ?? !1), u = i(null), c = h(() => o.isSelecting ?? l.value), g = h(() => {
12
- var n, p;
13
- const e = (p = (n = D()).default) == null ? void 0 : p.call(n);
14
- return (e == null ? void 0 : e.length) === 1 && typeof e[0].children == "string";
15
- }), k = () => {
16
- l.value = !0, s("press");
17
- }, C = () => {
18
- u.value = setTimeout(() => {
19
- k();
20
- }, o.pressDuration ?? b);
21
- }, r = () => {
22
- u.value && (clearTimeout(u.value), u.value = null);
23
- }, d = () => {
24
- r(), C();
25
- }, v = () => {
26
- t.value && (t.value = !1, s("unhover")), r();
27
- }, f = () => {
28
- t.value && (t.value = !1, s("unhover")), r();
29
- }, m = (e) => {
30
- var n;
31
- a.value && !a.value.contains(e.target) && (l.value = !1, (n = o.onClickOutside) == null || n.call(o));
32
- }, y = (e) => {
33
- c.value && (e.preventDefault(), e.stopPropagation());
34
- }, M = () => {
35
- l.value = !1;
36
- };
37
- return E(() => {
38
- document.addEventListener("mousedown", m);
39
- }), B(() => {
40
- document.removeEventListener("mousedown", m), r();
41
- }), (e, n) => (R(), O("span", {
42
- ref_key: "containerRef",
43
- ref: a,
44
- role: "button",
45
- tabindex: "0",
46
- onClick: y,
47
- onMousedown: d,
48
- onMouseup: v,
49
- onMouseleave: f,
50
- onTouchstart: d,
51
- onTouchend: v,
52
- onTouchcancel: f,
53
- onBlur: M,
54
- onMouseenter: n[0] || (n[0] = () => {
55
- t.value = !0, s("hover");
56
- }),
57
- style: L({
58
- display: g.value ? "inline" : "inline-block",
59
- cursor: "pointer",
60
- userSelect: "none",
61
- borderRadius: "0.375rem",
62
- outlineWidth: "2px",
63
- outlineOffset: "4px",
64
- outlineStyle: "solid",
65
- outlineColor: c.value || t.value ? "inherit" : "transparent",
66
- transition: "all 100ms 50ms ease-in-out"
67
- })
68
- }, [
69
- P(e.$slots, "default")
70
- ], 36));
71
- }
72
- });
73
- export {
74
- x as _
75
- };
@@ -1 +0,0 @@
1
- "use strict";const e=require("vue"),y=250,M=e.defineComponent({__name:"ContentSelector",props:{onClickOutside:{type:Function},pressDuration:{},isSelecting:{type:Boolean}},emits:["click","press","hover","unhover"],setup(h,{emit:S}){const o=h,l=S,a=e.ref(null),s=e.ref(!1),u=e.ref(o.isSelecting??!1),r=e.ref(null),c=e.computed(()=>o.isSelecting??u.value),T=e.computed(()=>{var t,p;const n=(p=(t=e.useSlots()).default)==null?void 0:p.call(t);return(n==null?void 0:n.length)===1&&typeof n[0].children=="string"}),g=()=>{u.value=!0,l("press")},k=()=>{r.value=setTimeout(()=>{g()},o.pressDuration??y)},i=()=>{r.value&&(clearTimeout(r.value),r.value=null)},d=()=>{i(),k()},v=()=>{s.value&&(s.value=!1,l("unhover")),i()},f=()=>{s.value&&(s.value=!1,l("unhover")),i()},m=n=>{var t;a.value&&!a.value.contains(n.target)&&(u.value=!1,(t=o.onClickOutside)==null||t.call(o))},C=n=>{c.value&&(n.preventDefault(),n.stopPropagation())},_=()=>{u.value=!1};return e.onMounted(()=>{document.addEventListener("mousedown",m)}),e.onBeforeUnmount(()=>{document.removeEventListener("mousedown",m),i()}),(n,t)=>(e.openBlock(),e.createElementBlock("span",{ref_key:"containerRef",ref:a,role:"button",tabindex:"0",onClick:C,onMousedown:d,onMouseup:v,onMouseleave:f,onTouchstart:d,onTouchend:v,onTouchcancel:f,onBlur:_,onMouseenter:t[0]||(t[0]=()=>{s.value=!0,l("hover")}),style:e.normalizeStyle({display:T.value?"inline":"inline-block",cursor:"pointer",userSelect:"none",borderRadius:"0.375rem",outlineWidth:"2px",outlineOffset:"4px",outlineStyle:"solid",outlineColor:c.value||s.value?"inherit":"transparent",transition:"all 100ms 50ms ease-in-out"})},[e.renderSlot(n.$slots,"default")],36))}});exports._sfc_main=M;
@@ -1,68 +0,0 @@
1
- import { defineComponent as m, computed as u, createBlock as _, renderSlot as r, unref as E, openBlock as k, withCtx as C } from "vue";
2
- import { isSameKeyPath as f } from "@intlayer/core";
3
- import { _ as P } from "./ContentSelector.vue_vue_type_script_setup_true_lang-Df1Nt4x_.mjs";
4
- import { useEditorEnabled as v } from "./esm/editor/editorEnabled.mjs";
5
- import { useFocusDictionary as K } from "./esm/editor/focusDictionary.mjs";
6
- import { useEditor as N } from "./esm/editor/useEditor.mjs";
7
- import { MessageKey as d } from "@intlayer/editor";
8
- import { useCommunicator as g } from "./esm/editor/communicator.mjs";
9
- const M = /* @__PURE__ */ m({
10
- __name: "ContentSelectorWrapper",
11
- props: {
12
- dictionaryKey: {},
13
- keyPath: {},
14
- plugins: {},
15
- locale: {},
16
- dictionaryPath: {},
17
- children: {}
18
- },
19
- setup(l) {
20
- const t = l, e = K(), p = v(), o = g();
21
- N();
22
- const i = u(
23
- () => {
24
- var n, a;
25
- return ((n = e == null ? void 0 : e.focusedContent.value) == null ? void 0 : n.dictionaryKey) === t.dictionaryKey && (((a = e == null ? void 0 : e.focusedContent.value.keyPath) == null ? void 0 : a.length) ?? 0) > 0 && f(
26
- (e == null ? void 0 : e.focusedContent.value.keyPath) ?? [],
27
- t.keyPath
28
- );
29
- }
30
- ), y = () => {
31
- e == null || e.setFocusedContent({
32
- dictionaryKey: t.dictionaryKey,
33
- keyPath: t.keyPath
34
- });
35
- }, h = () => {
36
- o == null || o.postMessage({
37
- type: `${d.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,
38
- data: {
39
- dictionaryKey: t.dictionaryKey,
40
- keyPath: t.keyPath
41
- }
42
- });
43
- }, c = () => {
44
- o == null || o.postMessage({
45
- type: `${d.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,
46
- data: null
47
- });
48
- };
49
- return (n, a) => {
50
- var s;
51
- return (s = E(p)) != null && s.enabled.value ? (k(), _(P, {
52
- key: 0,
53
- onPress: y,
54
- isSelecting: i.value,
55
- onHover: h,
56
- onUnhover: c
57
- }, {
58
- default: C(() => [
59
- r(n.$slots, "default")
60
- ]),
61
- _: 3
62
- }, 8, ["isSelecting"])) : r(n.$slots, "default", { key: 1 });
63
- };
64
- }
65
- });
66
- export {
67
- M as _
68
- };
@@ -1 +0,0 @@
1
- "use strict";const t=require("vue"),p=require("@intlayer/core"),h=require("./ContentSelector.vue_vue_type_script_setup_true_lang-RwUsyBxL.js"),E=require("./cjs/editor/editorEnabled.cjs"),C=require("./cjs/editor/focusDictionary.cjs"),k=require("./cjs/editor/useEditor.cjs"),d=require("@intlayer/editor"),v=require("./cjs/editor/communicator.cjs"),P=t.defineComponent({__name:"ContentSelectorWrapper",props:{dictionaryKey:{},keyPath:{},plugins:{},locale:{},dictionaryPath:{},children:{}},setup(i){const n=i,e=C.useFocusDictionary(),c=E.useEditorEnabled(),o=v.useCommunicator();k.useEditor();const l=t.computed(()=>{var s,r;return((s=e==null?void 0:e.focusedContent.value)==null?void 0:s.dictionaryKey)===n.dictionaryKey&&(((r=e==null?void 0:e.focusedContent.value.keyPath)==null?void 0:r.length)??0)>0&&p.isSameKeyPath((e==null?void 0:e.focusedContent.value.keyPath)??[],n.keyPath)}),u=()=>{e==null||e.setFocusedContent({dictionaryKey:n.dictionaryKey,keyPath:n.keyPath})},y=()=>{o==null||o.postMessage({type:`${d.MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,data:{dictionaryKey:n.dictionaryKey,keyPath:n.keyPath}})},_=()=>{o==null||o.postMessage({type:`${d.MessageKey.INTLAYER_HOVERED_CONTENT_CHANGED}/post`,data:null})};return(s,r)=>{var a;return(a=t.unref(c))!=null&&a.enabled.value?(t.openBlock(),t.createBlock(h._sfc_main,{key:0,onPress:u,isSelecting:l.value,onHover:y,onUnhover:_},{default:t.withCtx(()=>[t.renderSlot(s.$slots,"default")]),_:3},8,["isSelecting"])):t.renderSlot(s.$slots,"default",{key:1})}}});exports._sfc_main=P;
@@ -1,39 +0,0 @@
1
- import { defineComponent as l, useSlots as p, computed as i, createBlock as u, openBlock as f, unref as m } from "vue";
2
- import { getContent as y } from "@intlayer/core";
3
- import { useEditedContentRenderer as C } from "./esm/editor/useEditedContentRenderer.mjs";
4
- const h = /* @__PURE__ */ l({
5
- __name: "EditedContentRenderer",
6
- props: {
7
- dictionaryKey: {},
8
- keyPath: {},
9
- locale: {}
10
- },
11
- setup(s) {
12
- const t = s, o = p(), c = i(() => {
13
- var r;
14
- return (((r = o.default) == null ? void 0 : r.call(o)) ?? []).map((a) => typeof a.children == "string" ? a.children : "").join("");
15
- }), n = C(
16
- t.dictionaryKey,
17
- t.keyPath,
18
- c
19
- ), d = i(() => {
20
- if (typeof n.value == "object" && n.value !== null) {
21
- const e = y(
22
- n.value,
23
- t,
24
- t.locale
25
- );
26
- return typeof e != "string" ? (console.error(
27
- `Incorrect edited content format. Content type: ${typeof e}. Expected string. Value ${JSON.stringify(
28
- e
29
- )}`
30
- ), c.value) : e;
31
- }
32
- return n.value;
33
- });
34
- return (e, r) => (f(), u(m(d)));
35
- }
36
- });
37
- export {
38
- h as _
39
- };
@@ -1 +0,0 @@
1
- "use strict";const e=require("vue"),a=require("@intlayer/core"),l=require("./cjs/editor/useEditedContentRenderer.cjs"),p=e.defineComponent({__name:"EditedContentRenderer",props:{dictionaryKey:{},keyPath:{},locale:{}},setup(i){const n=i,o=e.useSlots(),s=e.computed(()=>{var c;return(((c=o.default)==null?void 0:c.call(o))??[]).map(d=>typeof d.children=="string"?d.children:"").join("")}),r=l.useEditedContentRenderer(n.dictionaryKey,n.keyPath,s),u=e.computed(()=>{if(typeof r.value=="object"&&r.value!==null){const t=a.getContent(r.value,n,n.locale);return typeof t!="string"?(console.error(`Incorrect edited content format. Content type: ${typeof t}. Expected string. Value ${JSON.stringify(t)}`),s.value):t}return r.value});return(t,c)=>(e.openBlock(),e.createBlock(e.unref(u)))}});exports._sfc_main=p;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@intlayer/config/built"),n=require("./serverContext.cjs"),{defaultLocale:o}=(r==null?void 0:r.internationalization)??{},e=n.createServerContext(o),a=(t=o)=>{e.provide(t)},l=()=>n.getServerContext(e),c=t=>e.consume(t);exports.IntlayerServerContext=e;exports.getIntlayerLocale=l;exports.provideIntlayerLocale=a;exports.withIntlayerLocale=c;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./IntlayerServerProvider.cjs"),r=require("./serverContext.cjs"),t=require("./t.cjs"),n=require("./useDictionary.cjs"),o=require("./useIntlayer.cjs");exports.IntlayerServerContext=e.IntlayerServerContext;exports.getIntlayerLocale=e.getIntlayerLocale;exports.provideIntlayerLocale=e.provideIntlayerLocale;exports.withIntlayerLocale=e.withIntlayerLocale;exports.createServerContext=r.createServerContext;exports.getServerContext=r.getServerContext;exports.t=t.t;exports.useDictionary=n.useDictionary;exports.useIntlayer=o.useIntlayer;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=new Map,c=o=>{v();const t=Symbol("serverContext");s.set(t,{value:void 0});const e=()=>s.get(t)||{value:void 0};return{provide:n=>{const r=e();r.value=n,s.set(t,r)},consume:n=>{const r=e();return n(r?r.value:o)},_storage:e,_defaultValue:o}},a=({_storage:o,_defaultValue:t})=>{const e=o();return e?e.value:t},v=()=>{if(typeof window<"u")throw new Error("createServerContext only works in Server Components")};exports.createServerContext=c;exports.getServerContext=a;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@intlayer/core"),c=require("./IntlayerServerProvider.cjs"),s=require("./serverContext.cjs"),a=(e,r)=>{const t=s.getServerContext(c.IntlayerServerContext),o=r??t;return n.getTranslation(e,o)};exports.t=a;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../getDictionary.cjs"),n=require("./IntlayerServerProvider.cjs"),i=require("./serverContext.cjs"),c=(e,r)=>{const t=r??i.getServerContext(n.IntlayerServerContext);return o.getDictionary(e,t)};exports.useDictionary=c;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../getIntlayer.cjs"),o=require("./IntlayerServerProvider.cjs"),s=require("./serverContext.cjs"),l=(e,r)=>{const t=r??s.getServerContext(o.IntlayerServerContext);return n.getIntlayer(e,t)};exports.useIntlayer=l;
@@ -1,12 +0,0 @@
1
- import n from "@intlayer/config/built";
2
- import { createServerContext as a, getServerContext as c } from "./serverContext.mjs";
3
- var o;
4
- const { defaultLocale: r } = ((o = n) == null ? void 0 : o.internationalization) ?? {}, t = a(r), s = (e = r) => {
5
- t.provide(e);
6
- }, m = () => c(t), p = (e) => t.consume(e);
7
- export {
8
- t as IntlayerServerContext,
9
- m as getIntlayerLocale,
10
- s as provideIntlayerLocale,
11
- p as withIntlayerLocale
12
- };
@@ -1,16 +0,0 @@
1
- import { IntlayerServerContext as t, getIntlayerLocale as o, provideIntlayerLocale as a, withIntlayerLocale as n } from "./IntlayerServerProvider.mjs";
2
- import { createServerContext as x, getServerContext as p } from "./serverContext.mjs";
3
- import { t as c } from "./t.mjs";
4
- import { useDictionary as m } from "./useDictionary.mjs";
5
- import { useIntlayer as i } from "./useIntlayer.mjs";
6
- export {
7
- t as IntlayerServerContext,
8
- x as createServerContext,
9
- o as getIntlayerLocale,
10
- p as getServerContext,
11
- a as provideIntlayerLocale,
12
- c as t,
13
- m as useDictionary,
14
- i as useIntlayer,
15
- n as withIntlayerLocale
16
- };
@@ -1,34 +0,0 @@
1
- const s = /* @__PURE__ */ new Map(), v = (r) => {
2
- c();
3
- const t = Symbol("serverContext");
4
- s.set(t, { value: void 0 });
5
- const e = () => s.get(t) || { value: void 0 };
6
- return {
7
- // Method to provide a value to the context
8
- provide: (n) => {
9
- const o = e();
10
- o.value = n, s.set(t, o);
11
- },
12
- // Method to consume the context value with a callback
13
- consume: (n) => {
14
- const o = e();
15
- return n(o ? o.value : r);
16
- },
17
- // Internal storage access
18
- _storage: e,
19
- _defaultValue: r
20
- };
21
- }, u = ({
22
- _storage: r,
23
- _defaultValue: t
24
- }) => {
25
- const e = r();
26
- return e ? e.value : t;
27
- }, c = () => {
28
- if (typeof window < "u")
29
- throw new Error("createServerContext only works in Server Components");
30
- };
31
- export {
32
- v as createServerContext,
33
- u as getServerContext
34
- };
@@ -1,10 +0,0 @@
1
- import { getTranslation as o } from "@intlayer/core";
2
- import { IntlayerServerContext as n } from "./IntlayerServerProvider.mjs";
3
- import { getServerContext as a } from "./serverContext.mjs";
4
- const i = (t, r) => {
5
- const e = a(n);
6
- return o(t, r ?? e);
7
- };
8
- export {
9
- i as t
10
- };
@@ -1,10 +0,0 @@
1
- import { getDictionary as o } from "../getDictionary.mjs";
2
- import { IntlayerServerContext as n } from "./IntlayerServerProvider.mjs";
3
- import { getServerContext as i } from "./serverContext.mjs";
4
- const p = (r, t) => {
5
- const e = t ?? i(n);
6
- return o(r, e);
7
- };
8
- export {
9
- p as useDictionary
10
- };
@@ -1,10 +0,0 @@
1
- import { getIntlayer as o } from "../getIntlayer.mjs";
2
- import { IntlayerServerContext as n } from "./IntlayerServerProvider.mjs";
3
- import { getServerContext as m } from "./serverContext.mjs";
4
- const c = (r, t) => {
5
- const e = t ?? m(n);
6
- return o(r, e);
7
- };
8
- export {
9
- c as useIntlayer
10
- };
@@ -1,38 +0,0 @@
1
- import { LocalesValues } from '@intlayer/config/client';
2
- /**
3
- * Context that stores the current locale on the server side
4
- */
5
- export declare const IntlayerServerContext: {
6
- provide: (value: LocalesValues) => void;
7
- consume: (callback: (value: LocalesValues | undefined) => any) => any;
8
- _storage: () => {
9
- value: LocalesValues | undefined;
10
- };
11
- _defaultValue: LocalesValues | undefined;
12
- };
13
- /**
14
- * Helper function that provides the current locale to the server context
15
- *
16
- * @example
17
- * // In a server-side entry point
18
- * provideIntlayerLocale('en-US');
19
- */
20
- export declare const provideIntlayerLocale: (locale?: LocalesValues) => void;
21
- /**
22
- * Get the current locale from the server context
23
- *
24
- * @example
25
- * const currentLocale = getIntlayerLocale();
26
- */
27
- export declare const getIntlayerLocale: () => LocalesValues | undefined;
28
- /**
29
- * Helper that allows consuming the current locale with a callback
30
- *
31
- * @example
32
- * withIntlayerLocale((locale) => {
33
- * // Use locale here
34
- * return someFunction(locale);
35
- * });
36
- */
37
- export declare const withIntlayerLocale: <T>(callback: (locale: LocalesValues | undefined) => T) => T;
38
- //# sourceMappingURL=IntlayerServerProvider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IntlayerServerProvider.d.ts","sourceRoot":"","sources":["../../../src/server/IntlayerServerProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAK7D;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;CACiB,CAAC;AAEpD;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GAChC,SAAQ,aAA6B,SAGtC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,QAAO,aAAa,GAAG,SAEpD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAClC,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,KAAK,CAAC,KACjD,CAEF,CAAC"}
@@ -1,6 +0,0 @@
1
- export { IntlayerServerContext, getIntlayerLocale, provideIntlayerLocale, withIntlayerLocale, } from './IntlayerServerProvider';
2
- export * from './serverContext';
3
- export { t } from './t';
4
- export { useDictionary } from './useDictionary';
5
- export { useIntlayer } from './useIntlayer';
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
@@ -1,35 +0,0 @@
1
- /**
2
- * Creates a new datastore for a given server context.
3
- * Attempts to provide functionality similar to React's context API for Vue SSR.
4
- *
5
- * @example
6
- * const IntlayerServer = createServerContext<string | null>(null);
7
- *
8
- * // In a server component
9
- * IntlayerServer.provide(locale);
10
- *
11
- * // Retrieve the value
12
- * const localeValue = getServerContext(IntlayerServer);
13
- */
14
- export declare const createServerContext: <T>(defaultValue?: T) => ServerContext<T>;
15
- /**
16
- * Fetches a value present in a given server context.
17
- * Similar to Vue's inject, but for server components.
18
- *
19
- * @example
20
- * getServerContext(IntlayerServer);
21
- */
22
- export declare const getServerContext: <T>({ _storage, _defaultValue, }: ServerContext<T>) => T | undefined;
23
- /**
24
- * Type definition for the ServerContext
25
- */
26
- type ServerContext<T> = {
27
- provide: (value: T) => void;
28
- consume: (callback: (value: T | undefined) => any) => any;
29
- _storage: () => {
30
- value: T | undefined;
31
- };
32
- _defaultValue: T | undefined;
33
- };
34
- export {};
35
- //# sourceMappingURL=serverContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serverContext.d.ts","sourceRoot":"","sources":["../../../src/server/serverContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH,eAAO,MAAM,mBAAmB,GAAI,CAAC,EAAE,eAAe,CAAC,KAAG,aAAa,CAAC,CAAC,CAqCxE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,EAAE,8BAGjC,aAAa,CAAC,CAAC,CAAC,KAAG,CAAC,GAAG,SAKzB,CAAC;AAEF;;GAEG;AACH,KAAK,aAAa,CAAC,CAAC,IAAI;IACtB,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAC5B,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,SAAS,KAAK,GAAG,KAAK,GAAG,CAAC;IAC1D,QAAQ,EAAE,MAAM;QAAE,KAAK,EAAE,CAAC,GAAG,SAAS,CAAA;KAAE,CAAC;IACzC,aAAa,EAAE,CAAC,GAAG,SAAS,CAAC;CAC9B,CAAC"}
@@ -1,24 +0,0 @@
1
- import { LocalesValues } from '@intlayer/config/client';
2
- import { LanguageContent } from '@intlayer/core';
3
- /**
4
- * On the server side, function to get the translation content based on the locale
5
- *
6
- * If no locale is found, it will return the content related to the default locale.
7
- *
8
- * Returns either the content editor, or the content itself depending on the configuration.
9
- *
10
- * @example
11
- * ```ts
12
- * const content = t({
13
- * en: 'Hello',
14
- * fr: 'Bonjour',
15
- * }, 'fr');
16
- * // 'Bonjour'
17
- * ```
18
- *
19
- * Using TypeScript:
20
- * - This function will require each locale to be defined if defined in the project configuration.
21
- * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.
22
- */
23
- export declare const t: <Content = string>(multilangContent: LanguageContent<Content>, locale?: LocalesValues) => Content;
24
- //# sourceMappingURL=t.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"t.d.ts","sourceRoot":"","sources":["../../../src/server/t.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,KAAK,eAAe,EAAkB,MAAM,gBAAgB,CAAC;AAItE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,CAAC,GAAI,OAAO,GAAG,MAAM,EAChC,kBAAkB,eAAe,CAAC,OAAO,CAAC,EAC1C,SAAS,aAAa,YAMvB,CAAC"}
@@ -1,19 +0,0 @@
1
- import { LocalesValues } from '@intlayer/config/client';
2
- import { Dictionary } from '@intlayer/core';
3
- /**
4
- * On the server side, function that transforms a dictionary and returns the content
5
- *
6
- * If the locale is not provided, it will use the locale from the server context
7
- *
8
- * @example
9
- * // With a dictionary object
10
- * const dictionary = {
11
- * en: { title: 'Hello' },
12
- * fr: { title: 'Bonjour' }
13
- * };
14
- *
15
- * // Transform the dictionary for the current locale
16
- * const localizedDictionary = useDictionary(dictionary);
17
- */
18
- export declare const useDictionary: <T extends Dictionary>(dictionary: T, locale?: LocalesValues) => import('@intlayer/core').DeepTransformContent<T["content"], import('..').IInterpreterPluginState>;
19
- //# sourceMappingURL=useDictionary.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useDictionary.d.ts","sourceRoot":"","sources":["../../../src/server/useDictionary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAKjD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,UAAU,EAChD,YAAY,CAAC,EACb,SAAS,aAAa,sGAMvB,CAAC"}
@@ -1,16 +0,0 @@
1
- import { LocalesValues } from '@intlayer/config/client';
2
- import { DictionaryKeys } from '@intlayer/core';
3
- /**
4
- * On the server side, function that picks one dictionary by its key and returns the content
5
- *
6
- * If the locale is not provided, it will use the locale from the server context
7
- *
8
- * @example
9
- * // Server-side component or middleware
10
- * const dictionary = useIntlayer('homepage');
11
- *
12
- * // Access translated strings
13
- * const title = dictionary.title;
14
- */
15
- export declare const useIntlayer: <T extends DictionaryKeys, K extends LocalesValues>(key: T, locale?: K) => any;
16
- //# sourceMappingURL=useIntlayer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useIntlayer.d.ts","sourceRoot":"","sources":["../../../src/server/useIntlayer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAKrD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,cAAc,EAAE,CAAC,SAAS,aAAa,EAC3E,KAAK,CAAC,EACN,SAAS,CAAC,QAMX,CAAC"}