@x18n/builtins 0.0.0 → 0.0.2
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/package.json +2 -2
- package/dist/checks.d.mts +0 -19
- package/dist/checks.mjs +0 -330
- package/dist/extractors.d.mts +0 -51
- package/dist/extractors.mjs +0 -247
- package/dist/finders-Cf-IEaDm.mjs +0 -188
- package/dist/finders.d.mts +0 -29
- package/dist/finders.mjs +0 -3
- package/dist/formats-BAogSrvw.mjs +0 -1331
- package/dist/formats.d.mts +0 -34
- package/dist/formats.mjs +0 -1
- package/dist/index.d.mts +0 -5
- package/dist/index.mjs +0 -38
- package/dist/manifests.d.mts +0 -10
- package/dist/manifests.mjs +0 -49
- package/dist/placeholders.d.mts +0 -27
- package/dist/placeholders.mjs +0 -131
- package/dist/presets-CxJ8CsTD.mjs +0 -1096
- package/dist/presets.d.mts +0 -58
- package/dist/presets.mjs +0 -1
- package/dist/regex-350J_An-.mjs +0 -89
- package/dist/reporters.d.mts +0 -14
- package/dist/reporters.mjs +0 -203
- package/dist/scanners--prozYaE.mjs +0 -119
- package/dist/scanners.d.mts +0 -48
- package/dist/scanners.mjs +0 -4
- package/dist/sfc-blocks-CQhgEeT6.mjs +0 -161
- package/dist/vue-6FYzIrQl.mjs +0 -730
- package/dist/yaml-plugin.d.mts +0 -8
- package/dist/yaml-plugin.mjs +0 -67
package/dist/yaml-plugin.d.mts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Plugin, PluginFile, Preset } from "@x18n/core";
|
|
2
|
-
//#region src/yaml-plugin/index.d.ts
|
|
3
|
-
/**
|
|
4
|
-
* Compiles a validated YAML plugin into plugin objects. Each section maps to the
|
|
5
|
-
* options of a built-in factory, so moving to a TS plugin is a small change.
|
|
6
|
-
*/
|
|
7
|
-
export declare function compileYamlPlugin(data: PluginFile): Plugin | Preset;
|
|
8
|
-
//#endregion
|
package/dist/yaml-plugin.mjs
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { placeholderFromShape } from "./placeholders.mjs";
|
|
2
|
-
import { r as regexScopes } from "./regex-350J_An-.mjs";
|
|
3
|
-
//#region src/yaml-plugin/index.ts
|
|
4
|
-
/**
|
|
5
|
-
* Compiles a validated YAML plugin into plugin objects. Each section maps to the
|
|
6
|
-
* options of a built-in factory, so moving to a TS plugin is a small change.
|
|
7
|
-
*/
|
|
8
|
-
function compileYamlPlugin(data) {
|
|
9
|
-
const replacements = (data.normalizeKey ?? []).map((rule) => ({
|
|
10
|
-
from: new RegExp(rule.replace.pattern, "g"),
|
|
11
|
-
to: rule.replace.with
|
|
12
|
-
}));
|
|
13
|
-
const localeInfo = data.localeInfo;
|
|
14
|
-
const plugin = {
|
|
15
|
-
name: data.name,
|
|
16
|
-
config(draft) {
|
|
17
|
-
const defaults = data.config;
|
|
18
|
-
if (defaults?.sourceLocale) draft.sourceLocale = defaults.sourceLocale;
|
|
19
|
-
if (defaults?.locales) draft.locales = defaults.locales;
|
|
20
|
-
if (defaults?.resources && draft.resources.length === 0) draft.resources = defaults.resources;
|
|
21
|
-
if (defaults?.keyStyle) draft.keyStyle = defaults.keyStyle;
|
|
22
|
-
if (defaults?.namespace) draft.namespace = {
|
|
23
|
-
separator: defaults.namespace.separator ?? draft.namespace.separator,
|
|
24
|
-
default: defaults.namespace.default ?? draft.namespace.default
|
|
25
|
-
};
|
|
26
|
-
draft.usage = {
|
|
27
|
-
...draft.usage,
|
|
28
|
-
calls: [...draft.usage.calls, ...data.scanners?.calls ?? []],
|
|
29
|
-
regex: [...draft.usage.regex, ...data.scanners?.regex ?? []]
|
|
30
|
-
};
|
|
31
|
-
if (data.extract?.templates) draft.extract = {
|
|
32
|
-
...draft.extract,
|
|
33
|
-
templates: [...draft.extract.templates ?? [], ...data.extract.templates]
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
derivedKeys: data.derivedKeys,
|
|
37
|
-
placeholders: data.placeholders?.map(placeholderFromShape),
|
|
38
|
-
normalizeKey: replacements.length > 0 ? (raw) => replacements.reduce((text, rule) => text.replace(rule.from, rule.to), raw) : void 0,
|
|
39
|
-
localeInfo: localeInfo ? (code) => {
|
|
40
|
-
const info = localeInfo[code];
|
|
41
|
-
return info ? {
|
|
42
|
-
...info.flag ? { flag: info.flag } : {},
|
|
43
|
-
...info.displayName ? { displayName: info.displayName } : {}
|
|
44
|
-
} : void 0;
|
|
45
|
-
} : void 0
|
|
46
|
-
};
|
|
47
|
-
const plugins = [plugin, ...data.scopes ? [regexScopes(data.scopes.regex, `${data.name}-scopes`)] : []];
|
|
48
|
-
const detect = data.detect;
|
|
49
|
-
if (!detect) return plugins.length === 1 ? plugin : {
|
|
50
|
-
name: data.name,
|
|
51
|
-
plugins
|
|
52
|
-
};
|
|
53
|
-
return {
|
|
54
|
-
name: data.name,
|
|
55
|
-
exclusive: data.exclusive,
|
|
56
|
-
plugins,
|
|
57
|
-
async detect(ctx) {
|
|
58
|
-
const deps = detect.dependencies;
|
|
59
|
-
if (deps?.any && !ctx.hasAnyDependency(deps.any)) return false;
|
|
60
|
-
if (deps?.all && !deps.all.every(ctx.hasDependency)) return false;
|
|
61
|
-
for (const pattern of detect.files ?? []) if (!await ctx.fileExists(pattern)) return false;
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
//#endregion
|
|
67
|
-
export { compileYamlPlugin };
|