@intlayer/core
Version:
Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.
26 lines (24 loc) • 925 B
JavaScript
import { deepTransformNode } from "../interpreter/getContent/deepTransform.mjs";
//#region src/deepTransformPlugins/getMaskContent.ts
const passTypedNodePlugin = {
id: "pass-typed-node-plugin",
canHandle: (node) => typeof node === "object" && typeof node?.nodeType === "string",
transform: (node, props, deepTransformNode$1) => deepTransformNode$1(node[node.nodeType], props)
};
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
const buildMaskPlugin = {
id: "build-mask-plugin",
canHandle: (node) => typeof node === "string" || typeof node === "number",
transform: () => true
};
const getMaskContent = (source) => ({
...source,
content: deepTransformNode(source.content, {
dictionaryKey: source.key,
keyPath: [],
plugins: [passTypedNodePlugin, buildMaskPlugin]
})
});
//#endregion
export { buildMaskPlugin, getMaskContent };
//# sourceMappingURL=getMaskContent.mjs.map