vanilla-intlayer 9.6.0 → 9.7.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.
- package/dist/cjs/client/installIntlayer.cjs +1 -1
- package/dist/cjs/editor/useEditor.cjs +7 -0
- package/dist/cjs/editor/useEditor.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/esm/client/installIntlayer.mjs +1 -1
- package/dist/esm/editor/useEditor.mjs +7 -0
- package/dist/esm/editor/useEditor.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/types/editor/useEditor.d.ts.map +1 -1
- package/package.json +8 -8
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_editor_useEditor = require('../editor/useEditor.cjs');
|
|
3
2
|
const require_client_useLocaleStorage = require('./useLocaleStorage.cjs');
|
|
3
|
+
const require_editor_useEditor = require('../editor/useEditor.cjs');
|
|
4
4
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
5
5
|
let _intlayer_config_client = require("@intlayer/config/client");
|
|
6
6
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_client_useLocaleStorage = require('../client/useLocaleStorage.cjs');
|
|
2
3
|
const require_client_installIntlayer = require('../client/installIntlayer.cjs');
|
|
3
4
|
let _intlayer_editor_isEnabled = require("@intlayer/editor/isEnabled");
|
|
4
5
|
|
|
@@ -24,6 +25,7 @@ let _intlayer_editor_isEnabled = require("@intlayer/editor/isEnabled");
|
|
|
24
25
|
const useEditor = () => {
|
|
25
26
|
if (process.env.INTLAYER_EDITOR_ENABLED === "false" || !_intlayer_editor_isEnabled.isEnabled) return () => {};
|
|
26
27
|
let unsubscribeLocale = null;
|
|
28
|
+
let unsubscribeLocaleRequest = null;
|
|
27
29
|
let stopped = false;
|
|
28
30
|
import("@intlayer/editor").then(({ initEditorClient }) => {
|
|
29
31
|
if (stopped) return;
|
|
@@ -33,10 +35,15 @@ const useEditor = () => {
|
|
|
33
35
|
unsubscribeLocale = client.subscribe((newLocale) => {
|
|
34
36
|
manager.currentLocale.set(newLocale);
|
|
35
37
|
});
|
|
38
|
+
unsubscribeLocaleRequest = manager.onLocaleChangeRequested((requestedLocale) => {
|
|
39
|
+
client.setLocale(requestedLocale);
|
|
40
|
+
require_client_useLocaleStorage.setLocaleInStorage(requestedLocale, client.isCookieEnabled);
|
|
41
|
+
});
|
|
36
42
|
}).catch(() => {});
|
|
37
43
|
return () => {
|
|
38
44
|
stopped = true;
|
|
39
45
|
unsubscribeLocale?.();
|
|
46
|
+
unsubscribeLocaleRequest?.();
|
|
40
47
|
import("@intlayer/editor").then(({ stopEditorClient }) => {
|
|
41
48
|
stopEditorClient();
|
|
42
49
|
}).catch(() => {});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEditor.cjs","names":["isEnabled","getIntlayerClient"],"sources":["../../../src/editor/useEditor.ts"],"sourcesContent":["import type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { getIntlayerClient } from '../client/installIntlayer';\n\n/**\n * Initialises the Intlayer visual editor client.\n *\n * Does nothing when `INTLAYER_EDITOR_ENABLED` is `\"false\"` or the editor\n * package reports that it is disabled.\n *\n * Call this once at application startup.\n *\n * @returns A cleanup function that stops the editor.\n *\n * @example\n * ```ts\n * import { installIntlayer, useEditor } from 'vanilla-intlayer';\n *\n * installIntlayer('en');\n * const stopEditor = useEditor();\n * ```\n */\n\nexport const useEditor = (): (() => void) => {\n if (process.env.INTLAYER_EDITOR_ENABLED === 'false' || !isEnabled)\n return () => {};\n\n let unsubscribeLocale: (() => void) | null = null;\n let stopped = false;\n\n import('@intlayer/editor')\n .then(({ initEditorClient }) => {\n if (stopped) return;\n const manager: EditorStateManager = initEditorClient();\n const client = getIntlayerClient();\n\n manager.currentLocale.set(client.locale as Locale);\n\n unsubscribeLocale = client.subscribe((newLocale) => {\n manager.currentLocale.set(newLocale as Locale);\n });\n })\n .catch(() => {});\n\n return () => {\n stopped = true;\n unsubscribeLocale?.();\n import('@intlayer/editor')\n .then(({ stopEditorClient }) => {\n stopEditorClient();\n })\n .catch(() => {});\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useEditor.cjs","names":["isEnabled","getIntlayerClient"],"sources":["../../../src/editor/useEditor.ts"],"sourcesContent":["import type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { getIntlayerClient } from '../client/installIntlayer';\nimport { setLocaleInStorage } from '../client/useLocaleStorage';\n\n/**\n * Initialises the Intlayer visual editor client.\n *\n * Does nothing when `INTLAYER_EDITOR_ENABLED` is `\"false\"` or the editor\n * package reports that it is disabled.\n *\n * Call this once at application startup.\n *\n * @returns A cleanup function that stops the editor.\n *\n * @example\n * ```ts\n * import { installIntlayer, useEditor } from 'vanilla-intlayer';\n *\n * installIntlayer('en');\n * const stopEditor = useEditor();\n * ```\n */\n\nexport const useEditor = (): (() => void) => {\n if (process.env.INTLAYER_EDITOR_ENABLED === 'false' || !isEnabled)\n return () => {};\n\n let unsubscribeLocale: (() => void) | null = null;\n let unsubscribeLocaleRequest: (() => void) | null = null;\n let stopped = false;\n\n import('@intlayer/editor')\n .then(({ initEditorClient }) => {\n if (stopped) return;\n const manager: EditorStateManager = initEditorClient();\n const client = getIntlayerClient();\n\n manager.currentLocale.set(client.locale as Locale);\n\n unsubscribeLocale = client.subscribe((newLocale) => {\n manager.currentLocale.set(newLocale as Locale);\n });\n\n unsubscribeLocaleRequest = manager.onLocaleChangeRequested(\n (requestedLocale) => {\n client.setLocale(requestedLocale);\n setLocaleInStorage(requestedLocale, client.isCookieEnabled);\n }\n );\n })\n .catch(() => {});\n\n return () => {\n stopped = true;\n unsubscribeLocale?.();\n unsubscribeLocaleRequest?.();\n import('@intlayer/editor')\n .then(({ stopEditorClient }) => {\n stopEditorClient();\n })\n .catch(() => {});\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAa,kBAAgC;CAC3C,IAAI,QAAQ,IAAI,4BAA4B,WAAW,CAACA,sCACtD,aAAa,CAAC;CAEhB,IAAI,oBAAyC;CAC7C,IAAI,2BAAgD;CACpD,IAAI,UAAU;CAEd,OAAO,mBAAmB,CACvB,MAAM,EAAE,uBAAuB;EAC9B,IAAI,SAAS;EACb,MAAM,UAA8B,iBAAiB;EACrD,MAAM,SAASC,iDAAkB;EAEjC,QAAQ,cAAc,IAAI,OAAO,MAAgB;EAEjD,oBAAoB,OAAO,WAAW,cAAc;GAClD,QAAQ,cAAc,IAAI,SAAmB;EAC/C,CAAC;EAED,2BAA2B,QAAQ,yBAChC,oBAAoB;GACnB,OAAO,UAAU,eAAe;GAChC,mDAAmB,iBAAiB,OAAO,eAAe;EAC5D,CACF;CACF,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;CAEjB,aAAa;EACX,UAAU;EACV,oBAAoB;EACpB,2BAA2B;EAC3B,OAAO,mBAAmB,CACvB,MAAM,EAAE,uBAAuB;GAC9B,iBAAiB;EACnB,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;CACnB;AACF"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -2,8 +2,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
const require_plugins = require('./plugins.cjs');
|
|
3
3
|
const require_getDictionary = require('./getDictionary.cjs');
|
|
4
4
|
const require_getIntlayer = require('./getIntlayer.cjs');
|
|
5
|
-
const require_editor_useEditor = require('./editor/useEditor.cjs');
|
|
6
5
|
const require_client_useLocaleStorage = require('./client/useLocaleStorage.cjs');
|
|
6
|
+
const require_editor_useEditor = require('./editor/useEditor.cjs');
|
|
7
7
|
const require_client_installIntlayer = require('./client/installIntlayer.cjs');
|
|
8
8
|
const require_client_useDictionary = require('./client/useDictionary.cjs');
|
|
9
9
|
const require_client_useDictionaryDynamic = require('./client/useDictionaryDynamic.cjs');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useEditor } from "../editor/useEditor.mjs";
|
|
2
1
|
import { getLocaleInStorage } from "./useLocaleStorage.mjs";
|
|
2
|
+
import { useEditor } from "../editor/useEditor.mjs";
|
|
3
3
|
import { internationalization } from "@intlayer/config/built";
|
|
4
4
|
import { setIntlayerIdentifier } from "@intlayer/config/client";
|
|
5
5
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { setLocaleInStorage } from "../client/useLocaleStorage.mjs";
|
|
1
2
|
import { getIntlayerClient } from "../client/installIntlayer.mjs";
|
|
2
3
|
import { isEnabled } from "@intlayer/editor/isEnabled";
|
|
3
4
|
|
|
@@ -23,6 +24,7 @@ import { isEnabled } from "@intlayer/editor/isEnabled";
|
|
|
23
24
|
const useEditor = () => {
|
|
24
25
|
if (process.env.INTLAYER_EDITOR_ENABLED === "false" || !isEnabled) return () => {};
|
|
25
26
|
let unsubscribeLocale = null;
|
|
27
|
+
let unsubscribeLocaleRequest = null;
|
|
26
28
|
let stopped = false;
|
|
27
29
|
import("@intlayer/editor").then(({ initEditorClient }) => {
|
|
28
30
|
if (stopped) return;
|
|
@@ -32,10 +34,15 @@ const useEditor = () => {
|
|
|
32
34
|
unsubscribeLocale = client.subscribe((newLocale) => {
|
|
33
35
|
manager.currentLocale.set(newLocale);
|
|
34
36
|
});
|
|
37
|
+
unsubscribeLocaleRequest = manager.onLocaleChangeRequested((requestedLocale) => {
|
|
38
|
+
client.setLocale(requestedLocale);
|
|
39
|
+
setLocaleInStorage(requestedLocale, client.isCookieEnabled);
|
|
40
|
+
});
|
|
35
41
|
}).catch(() => {});
|
|
36
42
|
return () => {
|
|
37
43
|
stopped = true;
|
|
38
44
|
unsubscribeLocale?.();
|
|
45
|
+
unsubscribeLocaleRequest?.();
|
|
39
46
|
import("@intlayer/editor").then(({ stopEditorClient }) => {
|
|
40
47
|
stopEditorClient();
|
|
41
48
|
}).catch(() => {});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEditor.mjs","names":[],"sources":["../../../src/editor/useEditor.ts"],"sourcesContent":["import type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { getIntlayerClient } from '../client/installIntlayer';\n\n/**\n * Initialises the Intlayer visual editor client.\n *\n * Does nothing when `INTLAYER_EDITOR_ENABLED` is `\"false\"` or the editor\n * package reports that it is disabled.\n *\n * Call this once at application startup.\n *\n * @returns A cleanup function that stops the editor.\n *\n * @example\n * ```ts\n * import { installIntlayer, useEditor } from 'vanilla-intlayer';\n *\n * installIntlayer('en');\n * const stopEditor = useEditor();\n * ```\n */\n\nexport const useEditor = (): (() => void) => {\n if (process.env.INTLAYER_EDITOR_ENABLED === 'false' || !isEnabled)\n return () => {};\n\n let unsubscribeLocale: (() => void) | null = null;\n let stopped = false;\n\n import('@intlayer/editor')\n .then(({ initEditorClient }) => {\n if (stopped) return;\n const manager: EditorStateManager = initEditorClient();\n const client = getIntlayerClient();\n\n manager.currentLocale.set(client.locale as Locale);\n\n unsubscribeLocale = client.subscribe((newLocale) => {\n manager.currentLocale.set(newLocale as Locale);\n });\n })\n .catch(() => {});\n\n return () => {\n stopped = true;\n unsubscribeLocale?.();\n import('@intlayer/editor')\n .then(({ stopEditorClient }) => {\n stopEditorClient();\n })\n .catch(() => {});\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useEditor.mjs","names":[],"sources":["../../../src/editor/useEditor.ts"],"sourcesContent":["import type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { getIntlayerClient } from '../client/installIntlayer';\nimport { setLocaleInStorage } from '../client/useLocaleStorage';\n\n/**\n * Initialises the Intlayer visual editor client.\n *\n * Does nothing when `INTLAYER_EDITOR_ENABLED` is `\"false\"` or the editor\n * package reports that it is disabled.\n *\n * Call this once at application startup.\n *\n * @returns A cleanup function that stops the editor.\n *\n * @example\n * ```ts\n * import { installIntlayer, useEditor } from 'vanilla-intlayer';\n *\n * installIntlayer('en');\n * const stopEditor = useEditor();\n * ```\n */\n\nexport const useEditor = (): (() => void) => {\n if (process.env.INTLAYER_EDITOR_ENABLED === 'false' || !isEnabled)\n return () => {};\n\n let unsubscribeLocale: (() => void) | null = null;\n let unsubscribeLocaleRequest: (() => void) | null = null;\n let stopped = false;\n\n import('@intlayer/editor')\n .then(({ initEditorClient }) => {\n if (stopped) return;\n const manager: EditorStateManager = initEditorClient();\n const client = getIntlayerClient();\n\n manager.currentLocale.set(client.locale as Locale);\n\n unsubscribeLocale = client.subscribe((newLocale) => {\n manager.currentLocale.set(newLocale as Locale);\n });\n\n unsubscribeLocaleRequest = manager.onLocaleChangeRequested(\n (requestedLocale) => {\n client.setLocale(requestedLocale);\n setLocaleInStorage(requestedLocale, client.isCookieEnabled);\n }\n );\n })\n .catch(() => {});\n\n return () => {\n stopped = true;\n unsubscribeLocale?.();\n unsubscribeLocaleRequest?.();\n import('@intlayer/editor')\n .then(({ stopEditorClient }) => {\n stopEditorClient();\n })\n .catch(() => {});\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAa,kBAAgC;CAC3C,IAAI,QAAQ,IAAI,4BAA4B,WAAW,CAAC,WACtD,aAAa,CAAC;CAEhB,IAAI,oBAAyC;CAC7C,IAAI,2BAAgD;CACpD,IAAI,UAAU;CAEd,OAAO,mBAAmB,CACvB,MAAM,EAAE,uBAAuB;EAC9B,IAAI,SAAS;EACb,MAAM,UAA8B,iBAAiB;EACrD,MAAM,SAAS,kBAAkB;EAEjC,QAAQ,cAAc,IAAI,OAAO,MAAgB;EAEjD,oBAAoB,OAAO,WAAW,cAAc;GAClD,QAAQ,cAAc,IAAI,SAAmB;EAC/C,CAAC;EAED,2BAA2B,QAAQ,yBAChC,oBAAoB;GACnB,OAAO,UAAU,eAAe;GAChC,mBAAmB,iBAAiB,OAAO,eAAe;EAC5D,CACF;CACF,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;CAEjB,aAAa;EACX,UAAU;EACV,oBAAoB;EACpB,2BAA2B;EAC3B,OAAO,mBAAmB,CACvB,MAAM,EAAE,uBAAuB;GAC9B,iBAAiB;EACnB,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;CACnB;AACF"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getPlugins, htmlPlugin, insertionPlugin, intlayerNodePlugins, markdownPlugin, markdownStringPlugin } from "./plugins.mjs";
|
|
2
2
|
import { getDictionary } from "./getDictionary.mjs";
|
|
3
3
|
import { getIntlayer } from "./getIntlayer.mjs";
|
|
4
|
-
import { useEditor } from "./editor/useEditor.mjs";
|
|
5
4
|
import { getLocaleInStorage, localeCookie, localeInStorage, setLocaleCookie, setLocaleInStorage, useLocaleCookie, useLocaleStorage } from "./client/useLocaleStorage.mjs";
|
|
5
|
+
import { useEditor } from "./editor/useEditor.mjs";
|
|
6
6
|
import { IntlayerClient, createIntlayerClient, getIntlayerClient, installIntlayer } from "./client/installIntlayer.mjs";
|
|
7
7
|
import { useDictionary } from "./client/useDictionary.mjs";
|
|
8
8
|
import { useDictionaryDynamic } from "./client/useDictionaryDynamic.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEditor.d.ts","names":[],"sources":["../../../src/editor/useEditor.ts"],"mappings":";;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useEditor.d.ts","names":[],"sources":["../../../src/editor/useEditor.ts"],"mappings":";;;;;;;;;;;;;;;;;;;qBAyBa"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vanilla-intlayer",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.7.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your Vanilla JS, HTML, and PHP applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -102,14 +102,14 @@
|
|
|
102
102
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
103
103
|
},
|
|
104
104
|
"dependencies": {
|
|
105
|
-
"@intlayer/api": "9.
|
|
106
|
-
"@intlayer/config": "9.
|
|
107
|
-
"@intlayer/core": "9.
|
|
108
|
-
"@intlayer/editor": "9.
|
|
109
|
-
"@intlayer/types": "9.
|
|
105
|
+
"@intlayer/api": "9.7.0",
|
|
106
|
+
"@intlayer/config": "9.7.0",
|
|
107
|
+
"@intlayer/core": "9.7.0",
|
|
108
|
+
"@intlayer/editor": "9.7.0",
|
|
109
|
+
"@intlayer/types": "9.7.0"
|
|
110
110
|
},
|
|
111
111
|
"devDependencies": {
|
|
112
|
-
"@types/node": "^
|
|
112
|
+
"@types/node": "^26",
|
|
113
113
|
"@utils/ts-config": "1.0.4",
|
|
114
114
|
"@utils/ts-config-types": "1.0.4",
|
|
115
115
|
"@utils/tsdown-config": "1.0.4",
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
"vitest": "5.0.3"
|
|
120
120
|
},
|
|
121
121
|
"peerDependencies": {
|
|
122
|
-
"intlayer": "9.
|
|
122
|
+
"intlayer": "9.7.0"
|
|
123
123
|
},
|
|
124
124
|
"peerDependenciesMeta": {
|
|
125
125
|
"intlayer": {
|