@flowgram.ai/i18n-plugin 0.1.0-alpha.10

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,33 @@
1
+ // src/index.ts
2
+ import { I18n as I18n2 } from "@flowgram.ai/i18n";
3
+
4
+ // src/create-i18n-plugin.ts
5
+ import { I18n } from "@flowgram.ai/i18n";
6
+ import { definePluginCreator } from "@flowgram.ai/core";
7
+ var createI18nPlugin = definePluginCreator({
8
+ onInit: (ctx, _opts) => {
9
+ if (_opts.onLanguageChange) {
10
+ ctx.playground.toDispose.push(I18n.onLanguageChange(_opts.onLanguageChange));
11
+ }
12
+ if (_opts.languages) {
13
+ if (Array.isArray(_opts.languages)) {
14
+ I18n.addLanguages(_opts.languages);
15
+ } else {
16
+ I18n.addLanguages(
17
+ Object.keys(_opts.languages).map((key) => ({
18
+ languageId: key,
19
+ contents: _opts.languages[key]
20
+ }))
21
+ );
22
+ }
23
+ }
24
+ if (_opts.locale || _opts.localLanguage) {
25
+ I18n.locale = _opts.locale || _opts.localLanguage;
26
+ }
27
+ }
28
+ });
29
+ export {
30
+ I18n2 as I18n,
31
+ createI18nPlugin
32
+ };
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts","../../src/create-i18n-plugin.ts"],"sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nexport { I18n, type I18nLanguage } from '@flowgram.ai/i18n';\nexport { createI18nPlugin, type I18nPluginOptions } from './create-i18n-plugin';\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { I18n, type I18nLanguage } from '@flowgram.ai/i18n';\nimport { definePluginCreator } from '@flowgram.ai/core';\n\nexport interface I18nPluginOptions {\n locale?: string;\n /**\n * use `locale` instead\n * @deprecated\n */\n localLanguage?: string;\n /**\n * if missingStrictMode is true\n * expect(I18n.t('Unknown')).toEqual('[missing \"en-US.Unknown\" translation]')\n * else\n * expect(I18n.t('Unknown')).toEqual('Unknown')\n */\n missingStrictMode?: boolean;\n languages?: I18nLanguage[] | Record<string, Record<string, any>>;\n onLanguageChange?: (languageId: string) => void;\n}\n/**\n * I18n Plugin\n */\nexport const createI18nPlugin = definePluginCreator<I18nPluginOptions>({\n onInit: (ctx, _opts) => {\n if (_opts.onLanguageChange) {\n ctx.playground.toDispose.push(I18n.onLanguageChange(_opts.onLanguageChange));\n }\n if (_opts.languages) {\n if (Array.isArray(_opts.languages)) {\n I18n.addLanguages(_opts.languages);\n } else {\n I18n.addLanguages(\n Object.keys(_opts.languages).map((key) => ({\n languageId: key,\n contents: (_opts.languages as any)![key],\n }))\n );\n }\n }\n if (_opts.locale || _opts.localLanguage) {\n I18n.locale = (_opts.locale || _opts.localLanguage)!;\n }\n },\n});\n"],"mappings":";AAKA,SAAS,QAAAA,aAA+B;;;ACAxC,SAAS,YAA+B;AACxC,SAAS,2BAA2B;AAsB7B,IAAM,mBAAmB,oBAAuC;AAAA,EACrE,QAAQ,CAAC,KAAK,UAAU;AACtB,QAAI,MAAM,kBAAkB;AAC1B,UAAI,WAAW,UAAU,KAAK,KAAK,iBAAiB,MAAM,gBAAgB,CAAC;AAAA,IAC7E;AACA,QAAI,MAAM,WAAW;AACnB,UAAI,MAAM,QAAQ,MAAM,SAAS,GAAG;AAClC,aAAK,aAAa,MAAM,SAAS;AAAA,MACnC,OAAO;AACL,aAAK;AAAA,UACH,OAAO,KAAK,MAAM,SAAS,EAAE,IAAI,CAAC,SAAS;AAAA,YACzC,YAAY;AAAA,YACZ,UAAW,MAAM,UAAmB,GAAG;AAAA,UACzC,EAAE;AAAA,QACJ;AAAA,MACF;AAAA,IACF;AACA,QAAI,MAAM,UAAU,MAAM,eAAe;AACvC,WAAK,SAAU,MAAM,UAAU,MAAM;AAAA,IACvC;AAAA,EACF;AACF,CAAC;","names":["I18n"]}
@@ -0,0 +1,27 @@
1
+ import { I18nLanguage } from '@flowgram.ai/i18n';
2
+ export { I18n, I18nLanguage } from '@flowgram.ai/i18n';
3
+ import * as _flowgram_ai_core from '@flowgram.ai/core';
4
+
5
+ interface I18nPluginOptions {
6
+ locale?: string;
7
+ /**
8
+ * use `locale` instead
9
+ * @deprecated
10
+ */
11
+ localLanguage?: string;
12
+ /**
13
+ * if missingStrictMode is true
14
+ * expect(I18n.t('Unknown')).toEqual('[missing "en-US.Unknown" translation]')
15
+ * else
16
+ * expect(I18n.t('Unknown')).toEqual('Unknown')
17
+ */
18
+ missingStrictMode?: boolean;
19
+ languages?: I18nLanguage[] | Record<string, Record<string, any>>;
20
+ onLanguageChange?: (languageId: string) => void;
21
+ }
22
+ /**
23
+ * I18n Plugin
24
+ */
25
+ declare const createI18nPlugin: _flowgram_ai_core.PluginCreator<I18nPluginOptions>;
26
+
27
+ export { type I18nPluginOptions, createI18nPlugin };
@@ -0,0 +1,27 @@
1
+ import { I18nLanguage } from '@flowgram.ai/i18n';
2
+ export { I18n, I18nLanguage } from '@flowgram.ai/i18n';
3
+ import * as _flowgram_ai_core from '@flowgram.ai/core';
4
+
5
+ interface I18nPluginOptions {
6
+ locale?: string;
7
+ /**
8
+ * use `locale` instead
9
+ * @deprecated
10
+ */
11
+ localLanguage?: string;
12
+ /**
13
+ * if missingStrictMode is true
14
+ * expect(I18n.t('Unknown')).toEqual('[missing "en-US.Unknown" translation]')
15
+ * else
16
+ * expect(I18n.t('Unknown')).toEqual('Unknown')
17
+ */
18
+ missingStrictMode?: boolean;
19
+ languages?: I18nLanguage[] | Record<string, Record<string, any>>;
20
+ onLanguageChange?: (languageId: string) => void;
21
+ }
22
+ /**
23
+ * I18n Plugin
24
+ */
25
+ declare const createI18nPlugin: _flowgram_ai_core.PluginCreator<I18nPluginOptions>;
26
+
27
+ export { type I18nPluginOptions, createI18nPlugin };
package/dist/index.js ADDED
@@ -0,0 +1,59 @@
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
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ I18n: () => import_i18n2.I18n,
24
+ createI18nPlugin: () => createI18nPlugin
25
+ });
26
+ module.exports = __toCommonJS(src_exports);
27
+ var import_i18n2 = require("@flowgram.ai/i18n");
28
+
29
+ // src/create-i18n-plugin.ts
30
+ var import_i18n = require("@flowgram.ai/i18n");
31
+ var import_core = require("@flowgram.ai/core");
32
+ var createI18nPlugin = (0, import_core.definePluginCreator)({
33
+ onInit: (ctx, _opts) => {
34
+ if (_opts.onLanguageChange) {
35
+ ctx.playground.toDispose.push(import_i18n.I18n.onLanguageChange(_opts.onLanguageChange));
36
+ }
37
+ if (_opts.languages) {
38
+ if (Array.isArray(_opts.languages)) {
39
+ import_i18n.I18n.addLanguages(_opts.languages);
40
+ } else {
41
+ import_i18n.I18n.addLanguages(
42
+ Object.keys(_opts.languages).map((key) => ({
43
+ languageId: key,
44
+ contents: _opts.languages[key]
45
+ }))
46
+ );
47
+ }
48
+ }
49
+ if (_opts.locale || _opts.localLanguage) {
50
+ import_i18n.I18n.locale = _opts.locale || _opts.localLanguage;
51
+ }
52
+ }
53
+ });
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ I18n,
57
+ createI18nPlugin
58
+ });
59
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/create-i18n-plugin.ts"],"sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nexport { I18n, type I18nLanguage } from '@flowgram.ai/i18n';\nexport { createI18nPlugin, type I18nPluginOptions } from './create-i18n-plugin';\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { I18n, type I18nLanguage } from '@flowgram.ai/i18n';\nimport { definePluginCreator } from '@flowgram.ai/core';\n\nexport interface I18nPluginOptions {\n locale?: string;\n /**\n * use `locale` instead\n * @deprecated\n */\n localLanguage?: string;\n /**\n * if missingStrictMode is true\n * expect(I18n.t('Unknown')).toEqual('[missing \"en-US.Unknown\" translation]')\n * else\n * expect(I18n.t('Unknown')).toEqual('Unknown')\n */\n missingStrictMode?: boolean;\n languages?: I18nLanguage[] | Record<string, Record<string, any>>;\n onLanguageChange?: (languageId: string) => void;\n}\n/**\n * I18n Plugin\n */\nexport const createI18nPlugin = definePluginCreator<I18nPluginOptions>({\n onInit: (ctx, _opts) => {\n if (_opts.onLanguageChange) {\n ctx.playground.toDispose.push(I18n.onLanguageChange(_opts.onLanguageChange));\n }\n if (_opts.languages) {\n if (Array.isArray(_opts.languages)) {\n I18n.addLanguages(_opts.languages);\n } else {\n I18n.addLanguages(\n Object.keys(_opts.languages).map((key) => ({\n languageId: key,\n contents: (_opts.languages as any)![key],\n }))\n );\n }\n }\n if (_opts.locale || _opts.localLanguage) {\n I18n.locale = (_opts.locale || _opts.localLanguage)!;\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,IAAAA,eAAwC;;;ACAxC,kBAAwC;AACxC,kBAAoC;AAsB7B,IAAM,uBAAmB,iCAAuC;AAAA,EACrE,QAAQ,CAAC,KAAK,UAAU;AACtB,QAAI,MAAM,kBAAkB;AAC1B,UAAI,WAAW,UAAU,KAAK,iBAAK,iBAAiB,MAAM,gBAAgB,CAAC;AAAA,IAC7E;AACA,QAAI,MAAM,WAAW;AACnB,UAAI,MAAM,QAAQ,MAAM,SAAS,GAAG;AAClC,yBAAK,aAAa,MAAM,SAAS;AAAA,MACnC,OAAO;AACL,yBAAK;AAAA,UACH,OAAO,KAAK,MAAM,SAAS,EAAE,IAAI,CAAC,SAAS;AAAA,YACzC,YAAY;AAAA,YACZ,UAAW,MAAM,UAAmB,GAAG;AAAA,UACzC,EAAE;AAAA,QACJ;AAAA,MACF;AAAA,IACF;AACA,QAAI,MAAM,UAAU,MAAM,eAAe;AACvC,uBAAK,SAAU,MAAM,UAAU,MAAM;AAAA,IACvC;AAAA,EACF;AACF,CAAC;","names":["import_i18n"]}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@flowgram.ai/i18n-plugin",
3
+ "version": "0.1.0-alpha.10",
4
+ "homepage": "https://flowgram.ai/",
5
+ "repository": "https://github.com/bytedance/flowgram.ai",
6
+ "license": "MIT",
7
+ "exports": {
8
+ "types": "./dist/index.d.ts",
9
+ "import": "./dist/esm/index.js",
10
+ "require": "./dist/index.js"
11
+ },
12
+ "main": "./dist/index.js",
13
+ "module": "./dist/esm/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "dependencies": {
19
+ "@flowgram.ai/core": "0.1.0-alpha.10",
20
+ "@flowgram.ai/i18n": "0.1.0-alpha.10"
21
+ },
22
+ "devDependencies": {
23
+ "@types/bezier-js": "4.1.3",
24
+ "@types/lodash": "^4.14.137",
25
+ "@types/react": "^18",
26
+ "@types/react-dom": "^18",
27
+ "@types/styled-components": "^5",
28
+ "@vitest/coverage-v8": "^0.32.0",
29
+ "eslint": "^8.54.0",
30
+ "react": "^18",
31
+ "react-dom": "^18",
32
+ "reflect-metadata": "~0.2.2",
33
+ "styled-components": "^5",
34
+ "tsup": "^8.0.1",
35
+ "vitest": "^0.34.6",
36
+ "@flowgram.ai/eslint-config": "0.1.0-alpha.10",
37
+ "@flowgram.ai/ts-config": "0.1.0-alpha.10"
38
+ },
39
+ "peerDependencies": {},
40
+ "publishConfig": {
41
+ "access": "public",
42
+ "registry": "https://registry.npmjs.org/"
43
+ },
44
+ "scripts": {
45
+ "build": "npm run build:fast -- --dts-resolve",
46
+ "build:fast": "tsup src/index.ts --format cjs,esm --sourcemap --legacy-output",
47
+ "build:watch": "npm run build:fast -- --dts-resolve",
48
+ "clean": "rimraf dist",
49
+ "test": "exit 0",
50
+ "test:cov": "exit 0",
51
+ "watch": "npm run build:fast -- --dts-resolve --watch --ignore-watch dist"
52
+ }
53
+ }