svelte-intlayer 8.7.14 → 8.9.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/plugins.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { editor, internationalization } from '@intlayer/config/built';
|
|
2
|
-
import { conditionPlugin, enumerationPlugin, fallbackPlugin, filePlugin, genderPlugin, nestedPlugin, translationPlugin, } from '@intlayer/core/interpreter';
|
|
2
|
+
import { conditionPlugin, enumerationPlugin, fallbackPlugin, filePlugin, genderPlugin, nestedPlugin, pluralPlugin, translationPlugin, } from '@intlayer/core/interpreter';
|
|
3
3
|
import * as NodeTypes from '@intlayer/types/nodeType';
|
|
4
4
|
import { default as ContentSelector } from './editor/ContentSelector.svelte';
|
|
5
5
|
import { HTMLRenderer } from './html/index';
|
|
@@ -296,6 +296,7 @@ export const getPlugins = (locale, fallback = true) => {
|
|
|
296
296
|
const plugins = [
|
|
297
297
|
translationPlugin(locale ?? internationalization.defaultLocale, fallback ? internationalization.defaultLocale : undefined),
|
|
298
298
|
enumerationPlugin,
|
|
299
|
+
pluralPlugin(locale ?? internationalization.defaultLocale),
|
|
299
300
|
conditionPlugin,
|
|
300
301
|
nestedPlugin(locale ?? internationalization.defaultLocale),
|
|
301
302
|
filePlugin,
|
|
@@ -4,10 +4,10 @@ type IntlayerNodeProps = {
|
|
|
4
4
|
props: Record<string, any>;
|
|
5
5
|
additionalProps?: Record<string, any>;
|
|
6
6
|
};
|
|
7
|
-
export type IntlayerNode<T
|
|
7
|
+
export type IntlayerNode<T, AdditionalProps = Record<string, any>> = {
|
|
8
8
|
new (...args: any[]): any;
|
|
9
9
|
(anchor: any, props: any): any;
|
|
10
10
|
value: T;
|
|
11
|
-
} &
|
|
12
|
-
export declare const renderIntlayerNode: <T
|
|
11
|
+
} & AdditionalProps & T;
|
|
12
|
+
export declare const renderIntlayerNode: <T, AdditionalProps = Record<string, any>>(args: IntlayerNodeProps) => IntlayerNode<T, AdditionalProps>;
|
|
13
13
|
export {};
|
|
@@ -34,10 +34,37 @@ export const renderIntlayerNode = (args) => {
|
|
|
34
34
|
configurable: true,
|
|
35
35
|
});
|
|
36
36
|
Object.defineProperty(Node, 'toString', {
|
|
37
|
-
value: () => args.value
|
|
37
|
+
value: () => String(args.value ?? ''),
|
|
38
38
|
writable: true,
|
|
39
39
|
configurable: true,
|
|
40
40
|
});
|
|
41
|
+
Object.defineProperty(Node, 'valueOf', {
|
|
42
|
+
value: () => args.value,
|
|
43
|
+
writable: true,
|
|
44
|
+
configurable: true,
|
|
45
|
+
});
|
|
46
|
+
Object.defineProperty(Node, Symbol.toPrimitive, {
|
|
47
|
+
value: () => args.value ?? '',
|
|
48
|
+
writable: true,
|
|
49
|
+
configurable: true,
|
|
50
|
+
});
|
|
51
|
+
// Delegate native methods from the underlying value to Node (any type).
|
|
52
|
+
if (args.value !== null && args.value !== undefined) {
|
|
53
|
+
const valObj = Object(args.value); // Safely boxes primitives (e.g., 50 -> Number object)
|
|
54
|
+
const proto = Object.getPrototypeOf(valObj);
|
|
55
|
+
for (const prop of Object.getOwnPropertyNames(proto)) {
|
|
56
|
+
if (prop === 'constructor' || prop in Node)
|
|
57
|
+
continue;
|
|
58
|
+
const valProp = valObj[prop]; // read from instance so length/index values are correct
|
|
59
|
+
if (typeof valProp === 'function') {
|
|
60
|
+
Object.defineProperty(Node, prop, {
|
|
61
|
+
value: valProp.bind(args.value),
|
|
62
|
+
writable: true,
|
|
63
|
+
configurable: true,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
41
68
|
if (args.additionalProps) {
|
|
42
69
|
Object.assign(Node, args.additionalProps);
|
|
43
70
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-intlayer",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.9.0",
|
|
4
4
|
"description": "Easily internationalize i18n your Svelte applications with type-safe multilingual content management.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"intlayer",
|
|
@@ -82,11 +82,11 @@
|
|
|
82
82
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@intlayer/api": "8.
|
|
86
|
-
"@intlayer/config": "8.
|
|
87
|
-
"@intlayer/core": "8.
|
|
88
|
-
"@intlayer/editor": "8.
|
|
89
|
-
"@intlayer/types": "8.
|
|
85
|
+
"@intlayer/api": "8.9.0",
|
|
86
|
+
"@intlayer/config": "8.9.0",
|
|
87
|
+
"@intlayer/core": "8.9.0",
|
|
88
|
+
"@intlayer/editor": "8.9.0",
|
|
89
|
+
"@intlayer/types": "8.9.0"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@sveltejs/adapter-auto": "7.0.1",
|