solid-intlayer 5.5.5 → 5.5.7
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/index.cjs +29 -0
- package/dist/cjs/client/index.cjs.map +1 -0
- package/dist/cjs/client/installIntlayer.cjs +53 -0
- package/dist/cjs/client/installIntlayer.cjs.map +1 -0
- package/dist/cjs/client/useDictionary.cjs +41 -0
- package/dist/cjs/client/useDictionary.cjs.map +1 -0
- package/dist/cjs/client/useIntlayer.cjs +44 -0
- package/dist/cjs/client/useIntlayer.cjs.map +1 -0
- package/dist/cjs/client/useLocale.cjs +33 -0
- package/dist/cjs/client/useLocale.cjs.map +1 -0
- package/dist/cjs/getDictionary.cjs +42 -0
- package/dist/cjs/getDictionary.cjs.map +1 -0
- package/dist/cjs/getIntlayer.cjs +38 -0
- package/dist/cjs/getIntlayer.cjs.map +1 -0
- package/dist/cjs/index.cjs +10 -4
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/markdown/index.cjs +36 -0
- package/dist/cjs/markdown/index.cjs.map +1 -0
- package/dist/cjs/plugins.cjs +53 -0
- package/dist/cjs/plugins.cjs.map +1 -0
- package/dist/esm/client/index.mjs +5 -0
- package/dist/esm/client/index.mjs.map +1 -0
- package/dist/esm/client/installIntlayer.mjs +26 -0
- package/dist/esm/client/installIntlayer.mjs.map +1 -0
- package/dist/esm/client/useDictionary.mjs +17 -0
- package/dist/esm/client/useDictionary.mjs.map +1 -0
- package/dist/esm/client/useIntlayer.mjs +19 -0
- package/dist/esm/client/useIntlayer.mjs.map +1 -0
- package/dist/esm/client/useLocale.mjs +9 -0
- package/dist/esm/client/useLocale.mjs.map +1 -0
- package/dist/esm/getDictionary.mjs +23 -0
- package/dist/esm/getDictionary.mjs.map +1 -0
- package/dist/esm/getIntlayer.mjs +19 -0
- package/dist/esm/getIntlayer.mjs.map +1 -0
- package/dist/esm/index.mjs +5 -2
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/markdown/index.mjs +12 -0
- package/dist/esm/markdown/index.mjs.map +1 -0
- package/dist/esm/plugins.mjs +27 -0
- package/dist/esm/plugins.mjs.map +1 -0
- package/dist/types/client/index.d.ts +5 -0
- package/dist/types/client/index.d.ts.map +1 -0
- package/dist/types/client/installIntlayer.d.ts +11 -0
- package/dist/types/client/installIntlayer.d.ts.map +1 -0
- package/dist/types/client/useDictionary.d.ts +4 -0
- package/dist/types/client/useDictionary.d.ts.map +1 -0
- package/dist/types/client/useIntlayer.d.ts +8 -0
- package/dist/types/client/useIntlayer.d.ts.map +1 -0
- package/dist/types/client/useLocale.d.ts +4 -0
- package/dist/types/client/useLocale.d.ts.map +1 -0
- package/dist/types/getDictionary.d.ts +5 -0
- package/dist/types/getDictionary.d.ts.map +1 -0
- package/dist/types/getIntlayer.d.ts +5 -0
- package/dist/types/getIntlayer.d.ts.map +1 -0
- package/dist/types/index.d.ts +10 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/markdown/index.d.ts +4 -0
- package/dist/types/markdown/index.d.ts.map +1 -0
- package/dist/types/plugins.d.ts +32 -0
- package/dist/types/plugins.d.ts.map +1 -0
- package/package.json +10 -7
- package/dist/cjs/intlayerMiddlewarePlugin.cjs +0 -224
- package/dist/cjs/intlayerMiddlewarePlugin.cjs.map +0 -1
- package/dist/cjs/intlayerPlugin.cjs +0 -76
- package/dist/cjs/intlayerPlugin.cjs.map +0 -1
- package/dist/esm/intlayerMiddlewarePlugin.mjs +0 -200
- package/dist/esm/intlayerMiddlewarePlugin.mjs.map +0 -1
- package/dist/esm/intlayerPlugin.mjs +0 -52
- package/dist/esm/intlayerPlugin.mjs.map +0 -1
- package/dist/types/intlayerMiddlewarePlugin.d.ts +0 -6
- package/dist/types/intlayerMiddlewarePlugin.d.ts.map +0 -1
- package/dist/types/intlayerPlugin.d.ts +0 -16
- package/dist/types/intlayerPlugin.d.ts.map +0 -1
|
@@ -0,0 +1,29 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var client_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(client_exports);
|
|
18
|
+
__reExport(client_exports, require('./installIntlayer.cjs'), module.exports);
|
|
19
|
+
__reExport(client_exports, require('./useDictionary.cjs'), module.exports);
|
|
20
|
+
__reExport(client_exports, require('./useIntlayer.cjs'), module.exports);
|
|
21
|
+
__reExport(client_exports, require('./useLocale.cjs'), module.exports);
|
|
22
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
23
|
+
0 && (module.exports = {
|
|
24
|
+
...require('./installIntlayer.cjs'),
|
|
25
|
+
...require('./useDictionary.cjs'),
|
|
26
|
+
...require('./useIntlayer.cjs'),
|
|
27
|
+
...require('./useLocale.cjs')
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export * from './installIntlayer';\nexport * from './useDictionary';\nexport * from './useIntlayer';\nexport * from './useLocale';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,2BAAc,8BAAd;AACA,2BAAc,4BADd;AAEA,2BAAc,0BAFd;AAGA,2BAAc,wBAHd;","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 installIntlayer_exports = {};
|
|
20
|
+
__export(installIntlayer_exports, {
|
|
21
|
+
INTLAYER_SYMBOL: () => INTLAYER_SYMBOL,
|
|
22
|
+
IntlayerContext: () => IntlayerContext,
|
|
23
|
+
createIntlayerProvider: () => createIntlayerProvider,
|
|
24
|
+
useIntlayerContext: () => useIntlayerContext
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(installIntlayer_exports);
|
|
27
|
+
var import_solid_js = require("solid-js");
|
|
28
|
+
const INTLAYER_SYMBOL = Symbol("intlayer");
|
|
29
|
+
const IntlayerContext = (0, import_solid_js.createContext)();
|
|
30
|
+
const useIntlayerContext = () => {
|
|
31
|
+
const context = (0, import_solid_js.useContext)(IntlayerContext);
|
|
32
|
+
if (!context) {
|
|
33
|
+
throw new Error(
|
|
34
|
+
"useIntlayerContext must be used within an IntlayerProvider"
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
return context;
|
|
38
|
+
};
|
|
39
|
+
const createIntlayerProvider = (initialLocale) => {
|
|
40
|
+
const [locale, setLocale] = (0, import_solid_js.createSignal)(initialLocale);
|
|
41
|
+
return {
|
|
42
|
+
locale,
|
|
43
|
+
setLocale
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
+
0 && (module.exports = {
|
|
48
|
+
INTLAYER_SYMBOL,
|
|
49
|
+
IntlayerContext,
|
|
50
|
+
createIntlayerProvider,
|
|
51
|
+
useIntlayerContext
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=installIntlayer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport { Accessor, createContext, createSignal, useContext } from 'solid-js';\n\nexport interface IntlayerProvider {\n locale: Accessor<LocalesValues>;\n setLocale: (locale: LocalesValues) => void;\n}\n\nexport const INTLAYER_SYMBOL = Symbol('intlayer');\n\nexport const IntlayerContext = createContext<IntlayerProvider>();\n\nexport const useIntlayerContext = (): IntlayerProvider => {\n const context = useContext(IntlayerContext);\n if (!context) {\n throw new Error(\n 'useIntlayerContext must be used within an IntlayerProvider'\n );\n }\n return context;\n};\n\nexport const createIntlayerProvider = (\n initialLocale: LocalesValues\n): IntlayerProvider => {\n const [locale, setLocale] = createSignal<LocalesValues>(initialLocale);\n\n return {\n locale,\n setLocale,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAkE;AAO3D,MAAM,kBAAkB,OAAO,UAAU;AAEzC,MAAM,sBAAkB,+BAAgC;AAExD,MAAM,qBAAqB,MAAwB;AACxD,QAAM,cAAU,4BAAW,eAAe;AAC1C,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAEO,MAAM,yBAAyB,CACpC,kBACqB;AACrB,QAAM,CAAC,QAAQ,SAAS,QAAI,8BAA4B,aAAa;AAErE,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
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 useDictionary_exports = {};
|
|
20
|
+
__export(useDictionary_exports, {
|
|
21
|
+
useDictionary: () => useDictionary
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useDictionary_exports);
|
|
24
|
+
var import_solid_js = require("solid-js");
|
|
25
|
+
var import_getDictionary = require('../getDictionary.cjs');
|
|
26
|
+
var import_installIntlayer = require('./installIntlayer.cjs');
|
|
27
|
+
const useDictionary = (dictionary, locale) => {
|
|
28
|
+
const intlayer = (0, import_installIntlayer.useIntlayerContext)();
|
|
29
|
+
const localeTarget = (0, import_solid_js.createMemo)(() => locale ?? intlayer.locale());
|
|
30
|
+
const [content, setContent] = (0, import_solid_js.createSignal)({});
|
|
31
|
+
(0, import_solid_js.createEffect)(() => {
|
|
32
|
+
const next = (0, import_getDictionary.getDictionary)(dictionary, localeTarget());
|
|
33
|
+
setContent(next);
|
|
34
|
+
});
|
|
35
|
+
return content();
|
|
36
|
+
};
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
useDictionary
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=useDictionary.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport { Dictionary } from '@intlayer/core';\nimport { createEffect, createMemo, createSignal } from 'solid-js';\nimport { getDictionary } from '../getDictionary';\nimport { useIntlayerContext } from './installIntlayer';\n\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n): any => {\n const intlayer = useIntlayerContext();\n\n /** which locale should we use right now? */\n const localeTarget = createMemo(() => locale ?? intlayer.locale());\n\n /** a reactive signal for the content */\n const [content, setContent] = createSignal<any>({});\n\n /** whenever `dictionary` or `locale` change, refresh the content */\n createEffect(() => {\n const next = getDictionary(dictionary, localeTarget());\n setContent(next as any);\n });\n\n return content();\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,sBAAuD;AACvD,2BAA8B;AAC9B,6BAAmC;AAE5B,MAAM,gBAAgB,CAC3B,YACA,WACQ;AACR,QAAM,eAAW,2CAAmB;AAGpC,QAAM,mBAAe,4BAAW,MAAM,UAAU,SAAS,OAAO,CAAC;AAGjE,QAAM,CAAC,SAAS,UAAU,QAAI,8BAAkB,CAAC,CAAC;AAGlD,oCAAa,MAAM;AACjB,UAAM,WAAO,oCAAc,YAAY,aAAa,CAAC;AACrD,eAAW,IAAW;AAAA,EACxB,CAAC;AAED,SAAO,QAAQ;AACjB;","names":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
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 useIntlayer_exports = {};
|
|
20
|
+
__export(useIntlayer_exports, {
|
|
21
|
+
isUpdatableNode: () => isUpdatableNode,
|
|
22
|
+
useIntlayer: () => useIntlayer
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useIntlayer_exports);
|
|
25
|
+
var import_solid_js = require("solid-js");
|
|
26
|
+
var import_getIntlayer = require('../getIntlayer.cjs');
|
|
27
|
+
var import_installIntlayer = require('./installIntlayer.cjs');
|
|
28
|
+
const isUpdatableNode = (val) => !!val && typeof val === "object" && typeof val.__update === "function";
|
|
29
|
+
const useIntlayer = (key, locale) => {
|
|
30
|
+
const intlayer = (0, import_installIntlayer.useIntlayerContext)();
|
|
31
|
+
const localeTarget = (0, import_solid_js.createMemo)(() => locale ?? intlayer.locale());
|
|
32
|
+
const [content, setContent] = (0, import_solid_js.createSignal)({});
|
|
33
|
+
(0, import_solid_js.createEffect)(() => {
|
|
34
|
+
const next = (0, import_getIntlayer.getIntlayer)(key, localeTarget());
|
|
35
|
+
setContent(next);
|
|
36
|
+
});
|
|
37
|
+
return content();
|
|
38
|
+
};
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
isUpdatableNode,
|
|
42
|
+
useIntlayer
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=useIntlayer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport { DictionaryKeys } from '@intlayer/core';\nimport { createEffect, createMemo, createSignal } from 'solid-js';\n// @ts-ignore intlayer declared for module augmentation\nimport { getIntlayer } from '../getIntlayer';\nimport { useIntlayerContext } from './installIntlayer';\n\n/** guard utility — true only for objects generated by `renderIntlayerNode()` */\nexport const isUpdatableNode = (\n val: unknown\n): val is { __update: (n: unknown) => void } =>\n !!val &&\n typeof val === 'object' &&\n typeof (val as any).__update === 'function';\n\nexport const useIntlayer = <T extends DictionaryKeys>(\n key: T,\n locale?: LocalesValues\n): any => {\n const intlayer = useIntlayerContext();\n\n /** which locale should we use right now? */\n const localeTarget = createMemo(() => locale ?? intlayer.locale());\n\n /** a reactive signal for the content */\n const [content, setContent] = createSignal<any>({});\n\n /** whenever `key` or `locale` change, refresh the dictionary */\n createEffect(() => {\n const next = getIntlayer(key, localeTarget());\n setContent(next as any);\n });\n\n return content();\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,sBAAuD;AAEvD,yBAA4B;AAC5B,6BAAmC;AAG5B,MAAM,kBAAkB,CAC7B,QAEA,CAAC,CAAC,OACF,OAAO,QAAQ,YACf,OAAQ,IAAY,aAAa;AAE5B,MAAM,cAAc,CACzB,KACA,WACQ;AACR,QAAM,eAAW,2CAAmB;AAGpC,QAAM,mBAAe,4BAAW,MAAM,UAAU,SAAS,OAAO,CAAC;AAGjE,QAAM,CAAC,SAAS,UAAU,QAAI,8BAAkB,CAAC,CAAC;AAGlD,oCAAa,MAAM;AACjB,UAAM,WAAO,gCAAY,KAAK,aAAa,CAAC;AAC5C,eAAW,IAAW;AAAA,EACxB,CAAC;AAED,SAAO,QAAQ;AACjB;","names":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
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 useLocale_exports = {};
|
|
20
|
+
__export(useLocale_exports, {
|
|
21
|
+
useLocale: () => useLocale
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useLocale_exports);
|
|
24
|
+
var import_installIntlayer = require('./installIntlayer.cjs');
|
|
25
|
+
const useLocale = () => {
|
|
26
|
+
const intlayer = (0, import_installIntlayer.useIntlayerContext)();
|
|
27
|
+
return [intlayer.locale, intlayer.setLocale];
|
|
28
|
+
};
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
useLocale
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=useLocale.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport { Accessor } from 'solid-js';\nimport { useIntlayerContext } from './installIntlayer';\n\nexport const useLocale = (): [\n Accessor<LocalesValues>,\n (locale: LocalesValues) => void,\n] => {\n const intlayer = useIntlayerContext();\n\n return [intlayer.locale, intlayer.setLocale];\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,6BAAmC;AAE5B,MAAM,YAAY,MAGpB;AACH,QAAM,eAAW,2CAAmB;AAEpC,SAAO,CAAC,SAAS,QAAQ,SAAS,SAAS;AAC7C;","names":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
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 getDictionary_exports = {};
|
|
20
|
+
__export(getDictionary_exports, {
|
|
21
|
+
getDictionary: () => getDictionary
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(getDictionary_exports);
|
|
24
|
+
var import_core = require("@intlayer/core");
|
|
25
|
+
var import_plugins = require('./plugins.cjs');
|
|
26
|
+
const getDictionary = (dictionary, locale, additionalPlugins) => {
|
|
27
|
+
const plugins = [
|
|
28
|
+
import_plugins.intlayerNodePlugins,
|
|
29
|
+
import_plugins.markdownPlugin,
|
|
30
|
+
...additionalPlugins ?? []
|
|
31
|
+
];
|
|
32
|
+
return (0, import_core.getDictionary)(
|
|
33
|
+
dictionary,
|
|
34
|
+
locale,
|
|
35
|
+
plugins
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
getDictionary
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=getDictionary.cjs.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} from './plugins';\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 markdownPlugin,\n ...(additionalPlugins ?? []),\n ];\n\n return getDictionaryCore(\n dictionary,\n locale,\n plugins\n ) as any as DeepTransformContent<T['content']>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAIO;AACP,qBAIO;AAEA,MAAM,gBAAgB,CAI3B,YACA,QACA,sBACG;AACH,QAAM,UAAqB;AAAA,IACzB;AAAA,IACA;AAAA,IACA,GAAI,qBAAqB,CAAC;AAAA,EAC5B;AAEA,aAAO,YAAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["getDictionaryCore"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
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 getIntlayer_exports = {};
|
|
20
|
+
__export(getIntlayer_exports, {
|
|
21
|
+
getIntlayer: () => getIntlayer
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(getIntlayer_exports);
|
|
24
|
+
var import_core = require("@intlayer/core");
|
|
25
|
+
var import_plugins = require('./plugins.cjs');
|
|
26
|
+
const getIntlayer = (key, locale, additionalPlugins) => {
|
|
27
|
+
const plugins = [
|
|
28
|
+
import_plugins.intlayerNodePlugins,
|
|
29
|
+
import_plugins.markdownPlugin,
|
|
30
|
+
...additionalPlugins ?? []
|
|
31
|
+
];
|
|
32
|
+
return (0, import_core.getIntlayer)(key, locale, plugins);
|
|
33
|
+
};
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
getIntlayer
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=getIntlayer.cjs.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} from './plugins';\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 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;AAAA;AAAA;AAAA;AAAA,kBAIO;AAGP,qBAIO;AAEA,MAAM,cAAc,CACzB,KACA,QACA,sBACG;AACH,QAAM,UAAqB;AAAA,IACzB;AAAA,IACA;AAAA,IACA,GAAI,qBAAqB,CAAC;AAAA,EAC5B;AAEA,aAAO,YAAAA,aAAgB,KAAK,QAAQ,OAAO;AAG7C;","names":["getIntlayerCore"]}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -15,11 +15,17 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
16
|
var index_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(index_exports);
|
|
18
|
-
__reExport(index_exports, require('./
|
|
19
|
-
__reExport(index_exports, require('./
|
|
18
|
+
__reExport(index_exports, require('./client/index.cjs'), module.exports);
|
|
19
|
+
__reExport(index_exports, require('./getDictionary.cjs'), module.exports);
|
|
20
|
+
__reExport(index_exports, require('./getIntlayer.cjs'), module.exports);
|
|
21
|
+
__reExport(index_exports, require('./markdown/index.cjs'), module.exports);
|
|
22
|
+
__reExport(index_exports, require('./plugins.cjs'), module.exports);
|
|
20
23
|
// Annotate the CommonJS export names for ESM import in node:
|
|
21
24
|
0 && (module.exports = {
|
|
22
|
-
...require('./
|
|
23
|
-
...require('./
|
|
25
|
+
...require('./client/index.cjs'),
|
|
26
|
+
...require('./getDictionary.cjs'),
|
|
27
|
+
...require('./getIntlayer.cjs'),
|
|
28
|
+
...require('./markdown/index.cjs'),
|
|
29
|
+
...require('./plugins.cjs')
|
|
24
30
|
});
|
|
25
31
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import { IInterpreterPluginSolid } from './plugins';\n\ndeclare module '@intlayer/core' {\n interface IInterpreterPlugin<T, S> extends IInterpreterPluginSolid<T> {}\n}\n\nexport * from './client';\nexport * from './getDictionary';\nexport * from './getIntlayer';\nexport * from './markdown';\nexport * from './plugins';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAMA,0BAAc,qBANd;AAOA,0BAAc,4BAPd;AAQA,0BAAc,0BARd;AASA,0BAAc,uBATd;AAUA,0BAAc,sBAVd;","names":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 markdown_exports = {};
|
|
20
|
+
__export(markdown_exports, {
|
|
21
|
+
useMarkdown: () => useMarkdown
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(markdown_exports);
|
|
24
|
+
const useMarkdown = () => {
|
|
25
|
+
const renderMarkdown = (content) => {
|
|
26
|
+
return content;
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
renderMarkdown
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
useMarkdown
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/markdown/index.ts"],"sourcesContent":["export const useMarkdown = () => {\n const renderMarkdown = (content: string): string => {\n // Basic markdown rendering - in a real implementation, you'd use a markdown parser\n return content;\n };\n\n return {\n renderMarkdown,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,cAAc,MAAM;AAC/B,QAAM,iBAAiB,CAAC,YAA4B;AAElD,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL;AAAA,EACF;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
|
+
solidNodePlugins: () => solidNodePlugins
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(plugins_exports);
|
|
26
|
+
const solidNodePlugins = {
|
|
27
|
+
id: "solid-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
|
+
solidNodePlugins
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=plugins.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/plugins.tsx"],"sourcesContent":["import type { Plugins } from '@intlayer/core';\n\n/**\n * Interface for Solid-specific plugin functionality\n * This interface can be augmented to add more Solid-specific transformations\n */\nexport interface IInterpreterPluginSolid<T> {\n /** Any Solid-specific properties can be added here */\n solidRendered?: T;\n}\n\n/**\n * Type that represents the deep transformation of content for Solid\n * This applies Solid-specific transformations recursively to all content\n */\nexport type DeepTransformContent<T> = T extends object\n ? {\n [K in keyof T]: DeepTransformContent<T[K]>;\n } & IInterpreterPluginSolid<T>\n : T;\n\n/**\n * Solid-specific node plugins for handling basic content types\n * These plugins handle strings, numbers, and bigints in Solid applications\n */\nexport const solidNodePlugins: Plugins = {\n id: 'solid-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (node, { children, ...rest }) => {\n // For Solid, we can return the raw content as Solid handles reactivity automatically\n // In more complex scenarios, you might want to wrap content in Solid 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 Solid\n * This can be extended to integrate with Solid 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,mBAA4B;AAAA,EACvC,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 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export * from './installIntlayer';\nexport * from './useDictionary';\nexport * from './useIntlayer';\nexport * from './useLocale';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createContext, createSignal, useContext } from "solid-js";
|
|
2
|
+
const INTLAYER_SYMBOL = Symbol("intlayer");
|
|
3
|
+
const IntlayerContext = createContext();
|
|
4
|
+
const useIntlayerContext = () => {
|
|
5
|
+
const context = useContext(IntlayerContext);
|
|
6
|
+
if (!context) {
|
|
7
|
+
throw new Error(
|
|
8
|
+
"useIntlayerContext must be used within an IntlayerProvider"
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
return context;
|
|
12
|
+
};
|
|
13
|
+
const createIntlayerProvider = (initialLocale) => {
|
|
14
|
+
const [locale, setLocale] = createSignal(initialLocale);
|
|
15
|
+
return {
|
|
16
|
+
locale,
|
|
17
|
+
setLocale
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
INTLAYER_SYMBOL,
|
|
22
|
+
IntlayerContext,
|
|
23
|
+
createIntlayerProvider,
|
|
24
|
+
useIntlayerContext
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=installIntlayer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport { Accessor, createContext, createSignal, useContext } from 'solid-js';\n\nexport interface IntlayerProvider {\n locale: Accessor<LocalesValues>;\n setLocale: (locale: LocalesValues) => void;\n}\n\nexport const INTLAYER_SYMBOL = Symbol('intlayer');\n\nexport const IntlayerContext = createContext<IntlayerProvider>();\n\nexport const useIntlayerContext = (): IntlayerProvider => {\n const context = useContext(IntlayerContext);\n if (!context) {\n throw new Error(\n 'useIntlayerContext must be used within an IntlayerProvider'\n );\n }\n return context;\n};\n\nexport const createIntlayerProvider = (\n initialLocale: LocalesValues\n): IntlayerProvider => {\n const [locale, setLocale] = createSignal<LocalesValues>(initialLocale);\n\n return {\n locale,\n setLocale,\n };\n};\n"],"mappings":"AACA,SAAmB,eAAe,cAAc,kBAAkB;AAO3D,MAAM,kBAAkB,OAAO,UAAU;AAEzC,MAAM,kBAAkB,cAAgC;AAExD,MAAM,qBAAqB,MAAwB;AACxD,QAAM,UAAU,WAAW,eAAe;AAC1C,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAEO,MAAM,yBAAyB,CACpC,kBACqB;AACrB,QAAM,CAAC,QAAQ,SAAS,IAAI,aAA4B,aAAa;AAErE,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createEffect, createMemo, createSignal } from "solid-js";
|
|
2
|
+
import { getDictionary } from "../getDictionary.mjs";
|
|
3
|
+
import { useIntlayerContext } from "./installIntlayer.mjs";
|
|
4
|
+
const useDictionary = (dictionary, locale) => {
|
|
5
|
+
const intlayer = useIntlayerContext();
|
|
6
|
+
const localeTarget = createMemo(() => locale ?? intlayer.locale());
|
|
7
|
+
const [content, setContent] = createSignal({});
|
|
8
|
+
createEffect(() => {
|
|
9
|
+
const next = getDictionary(dictionary, localeTarget());
|
|
10
|
+
setContent(next);
|
|
11
|
+
});
|
|
12
|
+
return content();
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
useDictionary
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=useDictionary.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport { Dictionary } from '@intlayer/core';\nimport { createEffect, createMemo, createSignal } from 'solid-js';\nimport { getDictionary } from '../getDictionary';\nimport { useIntlayerContext } from './installIntlayer';\n\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n): any => {\n const intlayer = useIntlayerContext();\n\n /** which locale should we use right now? */\n const localeTarget = createMemo(() => locale ?? intlayer.locale());\n\n /** a reactive signal for the content */\n const [content, setContent] = createSignal<any>({});\n\n /** whenever `dictionary` or `locale` change, refresh the content */\n createEffect(() => {\n const next = getDictionary(dictionary, localeTarget());\n setContent(next as any);\n });\n\n return content();\n};\n"],"mappings":"AAEA,SAAS,cAAc,YAAY,oBAAoB;AACvD,SAAS,qBAAqB;AAC9B,SAAS,0BAA0B;AAE5B,MAAM,gBAAgB,CAC3B,YACA,WACQ;AACR,QAAM,WAAW,mBAAmB;AAGpC,QAAM,eAAe,WAAW,MAAM,UAAU,SAAS,OAAO,CAAC;AAGjE,QAAM,CAAC,SAAS,UAAU,IAAI,aAAkB,CAAC,CAAC;AAGlD,eAAa,MAAM;AACjB,UAAM,OAAO,cAAc,YAAY,aAAa,CAAC;AACrD,eAAW,IAAW;AAAA,EACxB,CAAC;AAED,SAAO,QAAQ;AACjB;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createEffect, createMemo, createSignal } from "solid-js";
|
|
2
|
+
import { getIntlayer } from "../getIntlayer.mjs";
|
|
3
|
+
import { useIntlayerContext } from "./installIntlayer.mjs";
|
|
4
|
+
const isUpdatableNode = (val) => !!val && typeof val === "object" && typeof val.__update === "function";
|
|
5
|
+
const useIntlayer = (key, locale) => {
|
|
6
|
+
const intlayer = useIntlayerContext();
|
|
7
|
+
const localeTarget = createMemo(() => locale ?? intlayer.locale());
|
|
8
|
+
const [content, setContent] = createSignal({});
|
|
9
|
+
createEffect(() => {
|
|
10
|
+
const next = getIntlayer(key, localeTarget());
|
|
11
|
+
setContent(next);
|
|
12
|
+
});
|
|
13
|
+
return content();
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
isUpdatableNode,
|
|
17
|
+
useIntlayer
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=useIntlayer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport { DictionaryKeys } from '@intlayer/core';\nimport { createEffect, createMemo, createSignal } from 'solid-js';\n// @ts-ignore intlayer declared for module augmentation\nimport { getIntlayer } from '../getIntlayer';\nimport { useIntlayerContext } from './installIntlayer';\n\n/** guard utility — true only for objects generated by `renderIntlayerNode()` */\nexport const isUpdatableNode = (\n val: unknown\n): val is { __update: (n: unknown) => void } =>\n !!val &&\n typeof val === 'object' &&\n typeof (val as any).__update === 'function';\n\nexport const useIntlayer = <T extends DictionaryKeys>(\n key: T,\n locale?: LocalesValues\n): any => {\n const intlayer = useIntlayerContext();\n\n /** which locale should we use right now? */\n const localeTarget = createMemo(() => locale ?? intlayer.locale());\n\n /** a reactive signal for the content */\n const [content, setContent] = createSignal<any>({});\n\n /** whenever `key` or `locale` change, refresh the dictionary */\n createEffect(() => {\n const next = getIntlayer(key, localeTarget());\n setContent(next as any);\n });\n\n return content();\n};\n"],"mappings":"AAEA,SAAS,cAAc,YAAY,oBAAoB;AAEvD,SAAS,mBAAmB;AAC5B,SAAS,0BAA0B;AAG5B,MAAM,kBAAkB,CAC7B,QAEA,CAAC,CAAC,OACF,OAAO,QAAQ,YACf,OAAQ,IAAY,aAAa;AAE5B,MAAM,cAAc,CACzB,KACA,WACQ;AACR,QAAM,WAAW,mBAAmB;AAGpC,QAAM,eAAe,WAAW,MAAM,UAAU,SAAS,OAAO,CAAC;AAGjE,QAAM,CAAC,SAAS,UAAU,IAAI,aAAkB,CAAC,CAAC;AAGlD,eAAa,MAAM;AACjB,UAAM,OAAO,YAAY,KAAK,aAAa,CAAC;AAC5C,eAAW,IAAW;AAAA,EACxB,CAAC;AAED,SAAO,QAAQ;AACjB;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/config/client';\nimport { Accessor } from 'solid-js';\nimport { useIntlayerContext } from './installIntlayer';\n\nexport const useLocale = (): [\n Accessor<LocalesValues>,\n (locale: LocalesValues) => void,\n] => {\n const intlayer = useIntlayerContext();\n\n return [intlayer.locale, intlayer.setLocale];\n};\n"],"mappings":"AAEA,SAAS,0BAA0B;AAE5B,MAAM,YAAY,MAGpB;AACH,QAAM,WAAW,mBAAmB;AAEpC,SAAO,CAAC,SAAS,QAAQ,SAAS,SAAS;AAC7C;","names":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getDictionary as getDictionaryCore
|
|
3
|
+
} from "@intlayer/core";
|
|
4
|
+
import {
|
|
5
|
+
intlayerNodePlugins,
|
|
6
|
+
markdownPlugin
|
|
7
|
+
} from "./plugins.mjs";
|
|
8
|
+
const getDictionary = (dictionary, locale, additionalPlugins) => {
|
|
9
|
+
const plugins = [
|
|
10
|
+
intlayerNodePlugins,
|
|
11
|
+
markdownPlugin,
|
|
12
|
+
...additionalPlugins ?? []
|
|
13
|
+
];
|
|
14
|
+
return getDictionaryCore(
|
|
15
|
+
dictionary,
|
|
16
|
+
locale,
|
|
17
|
+
plugins
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
getDictionary
|
|
22
|
+
};
|
|
23
|
+
//# 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} from './plugins';\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 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,OACK;AAEA,MAAM,gBAAgB,CAI3B,YACA,QACA,sBACG;AACH,QAAM,UAAqB;AAAA,IACzB;AAAA,IACA;AAAA,IACA,GAAI,qBAAqB,CAAC;AAAA,EAC5B;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getIntlayer as getIntlayerCore
|
|
3
|
+
} from "@intlayer/core";
|
|
4
|
+
import {
|
|
5
|
+
intlayerNodePlugins,
|
|
6
|
+
markdownPlugin
|
|
7
|
+
} from "./plugins.mjs";
|
|
8
|
+
const getIntlayer = (key, locale, additionalPlugins) => {
|
|
9
|
+
const plugins = [
|
|
10
|
+
intlayerNodePlugins,
|
|
11
|
+
markdownPlugin,
|
|
12
|
+
...additionalPlugins ?? []
|
|
13
|
+
];
|
|
14
|
+
return getIntlayerCore(key, locale, plugins);
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
getIntlayer
|
|
18
|
+
};
|
|
19
|
+
//# 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} from './plugins';\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 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,OACK;AAEA,MAAM,cAAc,CACzB,KACA,QACA,sBACG;AACH,QAAM,UAAqB;AAAA,IACzB;AAAA,IACA;AAAA,IACA,GAAI,qBAAqB,CAAC;AAAA,EAC5B;AAEA,SAAO,gBAAgB,KAAK,QAAQ,OAAO;AAG7C;","names":[]}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
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
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import { IInterpreterPluginSolid } from './plugins';\n\ndeclare module '@intlayer/core' {\n interface IInterpreterPlugin<T, S> extends IInterpreterPluginSolid<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":[]}
|