@craft-ts/i18n-effect 0.7.0-beta.15
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 +28 -0
- package/src/index.d.ts +2 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +2 -0
- package/src/index.js.map +1 -0
- package/src/lib/i18n-effect.d.ts +12 -0
- package/src/lib/i18n-effect.d.ts.map +1 -0
- package/src/lib/i18n-effect.js +16 -0
- package/src/lib/i18n-effect.js.map +1 -0
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@craft-ts/i18n-effect",
|
|
3
|
+
"version": "0.7.0-beta.15",
|
|
4
|
+
"description": "Effect v4 adapter for @craft-ts/i18n",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./src/index.js",
|
|
8
|
+
"types": "./src/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./src/index.d.ts",
|
|
12
|
+
"default": "./src/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./package.json": "./package.json"
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"@craft-ts/i18n": "^0.7.0-beta.0",
|
|
18
|
+
"effect": "^4.0.0-rc.110"
|
|
19
|
+
},
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=20.19.0"
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"module": "./src/index.js"
|
|
28
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../libs/i18n-effect/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,KAAK,eAAe,GACrB,MAAM,mBAAmB,CAAC"}
|
package/src/index.js
ADDED
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/i18n-effect/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,GAEhB,MAAM,mBAAmB,CAAC","sourcesContent":["export {\n I18nEffectService,\n provideI18nRuntime,\n translateEffect,\n type I18nEffectShape,\n} from './lib/i18n-effect';\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { I18nRuntime, LocaleDefinition, TranslationKey, TranslationParams } from '@craft-ts/i18n';
|
|
2
|
+
import { Context, Effect, Layer } from 'effect';
|
|
3
|
+
export type I18nEffectShape = {
|
|
4
|
+
readonly runtime: I18nRuntime<readonly LocaleDefinition[]>;
|
|
5
|
+
};
|
|
6
|
+
declare const I18nEffectService_base: Context.ServiceClass<I18nEffectService, "@craft-ts/i18n-effect/I18nEffectService", I18nEffectShape>;
|
|
7
|
+
export declare class I18nEffectService extends I18nEffectService_base {
|
|
8
|
+
}
|
|
9
|
+
export declare function provideI18nRuntime<const Locales extends readonly LocaleDefinition[]>(runtime: I18nRuntime<Locales>): Layer.Layer<I18nEffectService>;
|
|
10
|
+
export declare function translateEffect<const Locales extends readonly LocaleDefinition[], Key extends TranslationKey<Locales[number]>>(key: Key, ...params: keyof TranslationParams<Locales[number], Key & string> extends never ? [params?: TranslationParams<Locales[number], Key & string>] : [params: TranslationParams<Locales[number], Key & string>]): Effect.Effect<string, never, I18nEffectService>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=i18n-effect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n-effect.d.ts","sourceRoot":"","sources":["../../../../../libs/i18n-effect/src/lib/i18n-effect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACvG,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEhD,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,SAAS,gBAAgB,EAAE,CAAC,CAAC;CAC5D,CAAC;;AAEF,qBAAa,iBAAkB,SAAQ,sBAEtC;CAAG;AAEJ,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,OAAO,SAAS,SAAS,gBAAgB,EAAE,EAClF,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,GAC5B,KAAK,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAIhC;AAED,wBAAgB,eAAe,CAC7B,KAAK,CAAC,OAAO,SAAS,SAAS,gBAAgB,EAAE,EACjD,GAAG,SAAS,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAE3C,GAAG,EAAE,GAAG,EACR,GAAG,MAAM,EAAE,MAAM,iBAAiB,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,SAAS,KAAK,GAC3E,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,GAC3D,CAAC,MAAM,EAAE,iBAAiB,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,GAC7D,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAMjD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Context, Effect, Layer } from 'effect';
|
|
2
|
+
export class I18nEffectService extends Context.Service()('@craft-ts/i18n-effect/I18nEffectService') {
|
|
3
|
+
}
|
|
4
|
+
export function provideI18nRuntime(runtime) {
|
|
5
|
+
return Layer.succeed(I18nEffectService, {
|
|
6
|
+
runtime: runtime,
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
export function translateEffect(key, ...params) {
|
|
10
|
+
return Effect.gen(function* () {
|
|
11
|
+
const service = yield* I18nEffectService;
|
|
12
|
+
const translate = service.runtime.translate;
|
|
13
|
+
return translate(key, params[0]);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=i18n-effect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n-effect.js","sourceRoot":"","sources":["../../../../../libs/i18n-effect/src/lib/i18n-effect.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAMhD,MAAM,OAAO,iBAAkB,SAAQ,OAAO,CAAC,OAAO,EAAsC,CAC1F,yCAAyC,CAC1C;CAAG;AAEJ,MAAM,UAAU,kBAAkB,CAChC,OAA6B;IAE7B,OAAO,KAAK,CAAC,OAAO,CAAC,iBAAiB,EAAE;QACtC,OAAO,EAAE,OAA8D;KACxE,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,eAAe,CAI7B,GAAQ,EACR,GAAG,MAE2D;IAE9D,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACzB,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,iBAAiB,CAAC;QACzC,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,SAAiF,CAAC;QACpH,OAAO,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAwC,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { I18nRuntime, LocaleDefinition, TranslationKey, TranslationParams } from '@craft-ts/i18n';\nimport { Context, Effect, Layer } from 'effect';\n\nexport type I18nEffectShape = {\n readonly runtime: I18nRuntime<readonly LocaleDefinition[]>;\n};\n\nexport class I18nEffectService extends Context.Service<I18nEffectService, I18nEffectShape>()(\n '@craft-ts/i18n-effect/I18nEffectService',\n) {}\n\nexport function provideI18nRuntime<const Locales extends readonly LocaleDefinition[]>(\n runtime: I18nRuntime<Locales>,\n): Layer.Layer<I18nEffectService> {\n return Layer.succeed(I18nEffectService, {\n runtime: runtime as unknown as I18nRuntime<readonly LocaleDefinition[]>,\n });\n}\n\nexport function translateEffect<\n const Locales extends readonly LocaleDefinition[],\n Key extends TranslationKey<Locales[number]>,\n>(\n key: Key,\n ...params: keyof TranslationParams<Locales[number], Key & string> extends never\n ? [params?: TranslationParams<Locales[number], Key & string>]\n : [params: TranslationParams<Locales[number], Key & string>]\n): Effect.Effect<string, never, I18nEffectService> {\n return Effect.gen(function* () {\n const service = yield* I18nEffectService;\n const translate = service.runtime.translate as unknown as (key: string, params?: Record<string, unknown>) => string;\n return translate(key, params[0] as Record<string, unknown> | undefined);\n });\n}\n"]}
|