@medialane/ui 0.373.4 → 0.374.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.
@@ -0,0 +1,8 @@
1
+ interface Scan {
2
+ sentences: Set<string>;
3
+ plurals: Set<string>;
4
+ }
5
+ declare function scanSentences(files: Record<string, string>): Scan;
6
+ declare function readSources(dir: string, skip?: ReadonlySet<string>): Record<string, string>;
7
+
8
+ export { type Scan, readSources, scanSentences };
@@ -0,0 +1,8 @@
1
+ interface Scan {
2
+ sentences: Set<string>;
3
+ plurals: Set<string>;
4
+ }
5
+ declare function scanSentences(files: Record<string, string>): Scan;
6
+ declare function readSources(dir: string, skip?: ReadonlySet<string>): Record<string, string>;
7
+
8
+ export { type Scan, readSources, scanSentences };
@@ -0,0 +1,45 @@
1
+ import ts from "typescript";
2
+ import { readdirSync, readFileSync, statSync } from "node:fs";
3
+ import { join } from "node:path";
4
+ const literalText = (node) => node && (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)) ? node.text : null;
5
+ function scanSentences(files) {
6
+ const sentences = /* @__PURE__ */ new Set();
7
+ const plurals = /* @__PURE__ */ new Set();
8
+ for (const [name, text] of Object.entries(files)) {
9
+ const kind = name.endsWith("x") ? ts.ScriptKind.TSX : ts.ScriptKind.TS;
10
+ const source = ts.createSourceFile(name, text, ts.ScriptTarget.Latest, true, kind);
11
+ const visit = (node) => {
12
+ if (ts.isCallExpression(node)) {
13
+ const callee = node.expression;
14
+ if (ts.isIdentifier(callee) && (callee.text === "t" || callee.text === "msg")) {
15
+ const sentence = literalText(node.arguments[0]);
16
+ if (sentence !== null) sentences.add(sentence);
17
+ } else if (ts.isPropertyAccessExpression(callee) && ts.isIdentifier(callee.expression) && callee.expression.text === "t") {
18
+ const first = literalText(node.arguments[0]);
19
+ if (first !== null && callee.name.text === "plural") plurals.add(first);
20
+ if (first !== null && callee.name.text === "rich") sentences.add(first);
21
+ }
22
+ }
23
+ ts.forEachChild(node, visit);
24
+ };
25
+ visit(source);
26
+ }
27
+ return { sentences, plurals };
28
+ }
29
+ function readSources(dir, skip = /* @__PURE__ */ new Set(["catalog"])) {
30
+ const files = {};
31
+ for (const name of readdirSync(dir)) {
32
+ const path = join(dir, name);
33
+ if (statSync(path).isDirectory()) {
34
+ if (!skip.has(name) && name !== "node_modules") Object.assign(files, readSources(path, skip));
35
+ } else if (/\.tsx?$/.test(name) && !/\.test\.tsx?$/.test(name)) {
36
+ files[path] = readFileSync(path, "utf8");
37
+ }
38
+ }
39
+ return files;
40
+ }
41
+ export {
42
+ readSources,
43
+ scanSentences
44
+ };
45
+ //# sourceMappingURL=scan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/i18n/tools/scan.ts"],"sourcesContent":["import ts from \"typescript\";\nimport { readdirSync, readFileSync, statSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\nexport interface Scan {\n sentences: Set<string>;\n plurals: Set<string>;\n}\n\nconst literalText = (node: ts.Node | undefined): string | null =>\n node && (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)) ? node.text : null;\n\nexport function scanSentences(files: Record<string, string>): Scan {\n const sentences = new Set<string>();\n const plurals = new Set<string>();\n for (const [name, text] of Object.entries(files)) {\n const kind = name.endsWith(\"x\") ? ts.ScriptKind.TSX : ts.ScriptKind.TS;\n const source = ts.createSourceFile(name, text, ts.ScriptTarget.Latest, true, kind);\n const visit = (node: ts.Node) => {\n if (ts.isCallExpression(node)) {\n const callee = node.expression;\n if (ts.isIdentifier(callee) && (callee.text === \"t\" || callee.text === \"msg\")) {\n const sentence = literalText(node.arguments[0]);\n if (sentence !== null) sentences.add(sentence);\n } else if (ts.isPropertyAccessExpression(callee) && ts.isIdentifier(callee.expression) && callee.expression.text === \"t\") {\n const first = literalText(node.arguments[0]);\n if (first !== null && callee.name.text === \"plural\") plurals.add(first);\n if (first !== null && callee.name.text === \"rich\") sentences.add(first);\n }\n }\n ts.forEachChild(node, visit);\n };\n visit(source);\n }\n return { sentences, plurals };\n}\n\nexport function readSources(dir: string, skip: ReadonlySet<string> = new Set([\"catalog\"])): Record<string, string> {\n const files: Record<string, string> = {};\n for (const name of readdirSync(dir)) {\n const path = join(dir, name);\n if (statSync(path).isDirectory()) {\n if (!skip.has(name) && name !== \"node_modules\") Object.assign(files, readSources(path, skip));\n } else if (/\\.tsx?$/.test(name) && !/\\.test\\.tsx?$/.test(name)) {\n files[path] = readFileSync(path, \"utf8\");\n }\n }\n return files;\n}\n"],"mappings":"AAAA,OAAO,QAAQ;AACf,SAAS,aAAa,cAAc,gBAAgB;AACpD,SAAS,YAAY;AAOrB,MAAM,cAAc,CAAC,SACnB,SAAS,GAAG,gBAAgB,IAAI,KAAK,GAAG,gCAAgC,IAAI,KAAK,KAAK,OAAO;AAExF,SAAS,cAAc,OAAqC;AACjE,QAAM,YAAY,oBAAI,IAAY;AAClC,QAAM,UAAU,oBAAI,IAAY;AAChC,aAAW,CAAC,MAAM,IAAI,KAAK,OAAO,QAAQ,KAAK,GAAG;AAChD,UAAM,OAAO,KAAK,SAAS,GAAG,IAAI,GAAG,WAAW,MAAM,GAAG,WAAW;AACpE,UAAM,SAAS,GAAG,iBAAiB,MAAM,MAAM,GAAG,aAAa,QAAQ,MAAM,IAAI;AACjF,UAAM,QAAQ,CAAC,SAAkB;AAC/B,UAAI,GAAG,iBAAiB,IAAI,GAAG;AAC7B,cAAM,SAAS,KAAK;AACpB,YAAI,GAAG,aAAa,MAAM,MAAM,OAAO,SAAS,OAAO,OAAO,SAAS,QAAQ;AAC7E,gBAAM,WAAW,YAAY,KAAK,UAAU,CAAC,CAAC;AAC9C,cAAI,aAAa,KAAM,WAAU,IAAI,QAAQ;AAAA,QAC/C,WAAW,GAAG,2BAA2B,MAAM,KAAK,GAAG,aAAa,OAAO,UAAU,KAAK,OAAO,WAAW,SAAS,KAAK;AACxH,gBAAM,QAAQ,YAAY,KAAK,UAAU,CAAC,CAAC;AAC3C,cAAI,UAAU,QAAQ,OAAO,KAAK,SAAS,SAAU,SAAQ,IAAI,KAAK;AACtE,cAAI,UAAU,QAAQ,OAAO,KAAK,SAAS,OAAQ,WAAU,IAAI,KAAK;AAAA,QACxE;AAAA,MACF;AACA,SAAG,aAAa,MAAM,KAAK;AAAA,IAC7B;AACA,UAAM,MAAM;AAAA,EACd;AACA,SAAO,EAAE,WAAW,QAAQ;AAC9B;AAEO,SAAS,YAAY,KAAa,OAA4B,oBAAI,IAAI,CAAC,SAAS,CAAC,GAA2B;AACjH,QAAM,QAAgC,CAAC;AACvC,aAAW,QAAQ,YAAY,GAAG,GAAG;AACnC,UAAM,OAAO,KAAK,KAAK,IAAI;AAC3B,QAAI,SAAS,IAAI,EAAE,YAAY,GAAG;AAChC,UAAI,CAAC,KAAK,IAAI,IAAI,KAAK,SAAS,eAAgB,QAAO,OAAO,OAAO,YAAY,MAAM,IAAI,CAAC;AAAA,IAC9F,WAAW,UAAU,KAAK,IAAI,KAAK,CAAC,gBAAgB,KAAK,IAAI,GAAG;AAC9D,YAAM,IAAI,IAAI,aAAa,MAAM,MAAM;AAAA,IACzC;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
@@ -7,7 +7,7 @@ declare function useTokenBalance(symbol: string | null, holderAddress: string |
7
7
  rawBalance: bigint | null;
8
8
  isLoading: boolean;
9
9
  error: any;
10
- decimals: 8 | 6 | 18;
10
+ decimals: 6 | 8 | 18;
11
11
  };
12
12
  declare function hasSufficientBalance(rawBalance: bigint | null, requiredHuman: string, decimals: number): boolean | null;
13
13
 
@@ -7,7 +7,7 @@ declare function useTokenBalance(symbol: string | null, holderAddress: string |
7
7
  rawBalance: bigint | null;
8
8
  isLoading: boolean;
9
9
  error: any;
10
- decimals: 8 | 6 | 18;
10
+ decimals: 6 | 8 | 18;
11
11
  };
12
12
  declare function hasSufficientBalance(rawBalance: bigint | null, requiredHuman: string, decimals: number): boolean | null;
13
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medialane/ui",
3
- "version": "0.373.4",
3
+ "version": "0.374.0",
4
4
  "description": "Shared UI components for Medialane apps",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -24,6 +24,11 @@
24
24
  "import": "./dist/i18n/index.js",
25
25
  "require": "./dist/i18n/index.cjs"
26
26
  },
27
+ "./i18n-tools": {
28
+ "types": "./dist/i18n/tools/scan.d.ts",
29
+ "import": "./dist/i18n/tools/scan.js",
30
+ "require": "./dist/i18n/tools/scan.cjs"
31
+ },
27
32
  "./utils/*": {
28
33
  "types": "./dist/utils/*.d.ts",
29
34
  "import": "./dist/utils/*.js",