@korioinc/next-core 1.0.5 → 1.0.7

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.
@@ -1 +1 @@
1
- {"version":3,"file":"lingui.setup.d.ts","sourceRoot":"","sources":["../../src/i18n/lingui.setup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAa,MAAM,cAAc,CAAC;AAI/C,OAAO,aAAa,CAAC;AAIrB,KAAK,gBAAgB,GAAG,MAAM,CAAC;AAS/B,KAAK,eAAe,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAA;CAAE,CAAC;AAGnD,eAAO,MAAM,WAAW,EAAE,eAKzB,CAAC;AAEF,KAAK,gBAAgB,GAAG;KAAG,CAAC,IAAI,gBAAgB,GAAG,IAAI;CAAE,CAAC;AAE1D,eAAO,MAAM,gBAAgB,EAAE,gBAQL,CAAC;AAE3B,eAAO,MAAM,eAAe,GAAI,QAAQ,gBAAgB,KAAG,IAM1D,CAAC"}
1
+ {"version":3,"file":"lingui.setup.d.ts","sourceRoot":"","sources":["../../src/i18n/lingui.setup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAa,MAAM,cAAc,CAAC;AAG/C,OAAO,aAAa,CAAC;AAIrB,KAAK,gBAAgB,GAAG,MAAM,CAAC;AAe/B,KAAK,eAAe,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAA;CAAE,CAAC;AAGnD,eAAO,MAAM,WAAW,EAAE,eAKzB,CAAC;AAEF,KAAK,gBAAgB,GAAG;KAAG,CAAC,IAAI,gBAAgB,GAAG,IAAI;CAAE,CAAC;AAE1D,eAAO,MAAM,gBAAgB,EAAE,gBAQL,CAAC;AAE3B,eAAO,MAAM,eAAe,GAAI,QAAQ,gBAAgB,KAAG,IAM1D,CAAC"}
@@ -1,10 +1,12 @@
1
1
  import { setupI18n } from '@lingui/core';
2
2
  import linguiConfig from 'lingui.config';
3
- import { loadCatalog as loadCatalogFromApp } from 'lingui.locales';
4
3
  import 'server-only';
5
4
  const { locales } = linguiConfig;
6
5
  async function loadCatalog(locale) {
7
- return loadCatalogFromApp(locale);
6
+ const { messages } = await import(`lang/${locale}.po`);
7
+ return {
8
+ [locale]: messages,
9
+ };
8
10
  }
9
11
  const catalogs = await Promise.all(locales.map(loadCatalog));
10
12
  // transform array of catalogs into a single object
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@korioinc/next-core",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./ads": {
@@ -94,7 +94,7 @@
94
94
  "pretendard": "^1.3.9",
95
95
  "tailwind-merge": "^3.3.1",
96
96
  "valtio": "^2.0.0",
97
- "@korioinc/next-conf": "1.0.3"
97
+ "@korioinc/next-conf": "1.0.5"
98
98
  },
99
99
  "publishConfig": {
100
100
  "access": "public",
@@ -1,41 +0,0 @@
1
- /**
2
- * App initialization helper for Korio Next Core
3
- * This file should be imported at the root of your Next.js application
4
- *
5
- * @example Create a file `app/init.ts`:
6
- * ```typescript
7
- * import linguiConfig from '../lingui.config';
8
- * import { createAppInitializer } from '@korioinc/next-core/app-init';
9
- *
10
- * export const initializeApp = createAppInitializer({
11
- * linguiConfig,
12
- * loadCatalog: async (locale) => {
13
- * const { messages } = await import(`../lang/${locale}.po`);
14
- * return { messages };
15
- * },
16
- * });
17
- * ```
18
- *
19
- * Then in your root layout or _app.tsx:
20
- * ```typescript
21
- * import { initializeApp } from './init';
22
- *
23
- * // Call this before using any i18n features
24
- * await initializeApp();
25
- * ```
26
- */
27
- import type { LinguiConfig } from '@lingui/conf';
28
- import { type LoadCatalogFunction } from './i18n/lingui-server';
29
- export interface AppInitOptions {
30
- linguiConfig: LinguiConfig;
31
- loadCatalog: LoadCatalogFunction;
32
- }
33
- /**
34
- * Create an app initializer function
35
- */
36
- export declare function createAppInitializer(options: AppInitOptions): () => Promise<void>;
37
- /**
38
- * Direct initialization function
39
- */
40
- export declare function initializeKorioApp(options: AppInitOptions): Promise<void>;
41
- //# sourceMappingURL=app-init.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"app-init.d.ts","sourceRoot":"","sources":["../src/app-init.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD,OAAO,EAA0B,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAExF,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,YAAY,CAAC;IAC3B,WAAW,EAAE,mBAAmB,CAAC;CAClC;AAID;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,cAAc,uBAU3D;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,cAAc,iBAQ/D"}
package/dist/app-init.js DELETED
@@ -1,53 +0,0 @@
1
- /**
2
- * App initialization helper for Korio Next Core
3
- * This file should be imported at the root of your Next.js application
4
- *
5
- * @example Create a file `app/init.ts`:
6
- * ```typescript
7
- * import linguiConfig from '../lingui.config';
8
- * import { createAppInitializer } from '@korioinc/next-core/app-init';
9
- *
10
- * export const initializeApp = createAppInitializer({
11
- * linguiConfig,
12
- * loadCatalog: async (locale) => {
13
- * const { messages } = await import(`../lang/${locale}.po`);
14
- * return { messages };
15
- * },
16
- * });
17
- * ```
18
- *
19
- * Then in your root layout or _app.tsx:
20
- * ```typescript
21
- * import { initializeApp } from './init';
22
- *
23
- * // Call this before using any i18n features
24
- * await initializeApp();
25
- * ```
26
- */
27
- import { initializeLinguiConfig } from './config/lingui-config';
28
- import { initializeLinguiServer } from './i18n/lingui-server';
29
- let initialized = false;
30
- /**
31
- * Create an app initializer function
32
- */
33
- export function createAppInitializer(options) {
34
- return async function initializeApp() {
35
- if (initialized) {
36
- return;
37
- }
38
- initializeLinguiConfig(options.linguiConfig);
39
- initializeLinguiServer(options.loadCatalog);
40
- initialized = true;
41
- };
42
- }
43
- /**
44
- * Direct initialization function
45
- */
46
- export async function initializeKorioApp(options) {
47
- if (initialized) {
48
- return;
49
- }
50
- initializeLinguiConfig(options.linguiConfig);
51
- initializeLinguiServer(options.loadCatalog);
52
- initialized = true;
53
- }
@@ -1,2 +0,0 @@
1
- export { getFallbackLocalesFromConfig, getLocalesFromConfig, getLinguiConfig, initializeLinguiConfig, } from './lingui-config';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,4BAA4B,EAC5B,oBAAoB,EACpB,eAAe,EACf,sBAAsB,GACvB,MAAM,iBAAiB,CAAC"}
@@ -1,2 +0,0 @@
1
- // Export all configuration related functions
2
- export { getFallbackLocalesFromConfig, getLocalesFromConfig, getLinguiConfig, initializeLinguiConfig, } from './lingui-config';
@@ -1,23 +0,0 @@
1
- import type { LinguiConfig } from '@lingui/conf';
2
- /**
3
- * Initialize the lingui configuration with user's config
4
- * This should be called once at the application startup
5
- */
6
- export declare function initializeLinguiConfig(config: LinguiConfig): void;
7
- /**
8
- * Get the current lingui configuration
9
- * Returns user's config if initialized, otherwise returns default config
10
- */
11
- export declare function getLinguiConfig(): LinguiConfig;
12
- /**
13
- * Get the locales from the configuration
14
- */
15
- export declare function getLocalesFromConfig(): string[];
16
- /**
17
- * Get the fallback locales from the configuration
18
- */
19
- export declare function getFallbackLocalesFromConfig(): false | {
20
- [locale: string]: string | string[];
21
- default?: string;
22
- } | undefined;
23
- //# sourceMappingURL=lingui-config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lingui-config.d.ts","sourceRoot":"","sources":["../../src/config/lingui-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAcjD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,YAAY,QAE1D;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAE9C;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,EAAE,CAG/C;AAED;;GAEG;AACH,wBAAgB,4BAA4B;;;cAG3C"}
@@ -1,38 +0,0 @@
1
- // Default configuration
2
- const defaultLinguiConfig = {
3
- locales: ['en', 'ko'],
4
- sourceLocale: 'en',
5
- fallbackLocales: {
6
- default: 'en',
7
- },
8
- };
9
- // This will be set by the initialization function
10
- let userLinguiConfig = null;
11
- /**
12
- * Initialize the lingui configuration with user's config
13
- * This should be called once at the application startup
14
- */
15
- export function initializeLinguiConfig(config) {
16
- userLinguiConfig = config;
17
- }
18
- /**
19
- * Get the current lingui configuration
20
- * Returns user's config if initialized, otherwise returns default config
21
- */
22
- export function getLinguiConfig() {
23
- return userLinguiConfig || defaultLinguiConfig;
24
- }
25
- /**
26
- * Get the locales from the configuration
27
- */
28
- export function getLocalesFromConfig() {
29
- const config = getLinguiConfig();
30
- return config.locales || ['en'];
31
- }
32
- /**
33
- * Get the fallback locales from the configuration
34
- */
35
- export function getFallbackLocalesFromConfig() {
36
- const config = getLinguiConfig();
37
- return config.fallbackLocales;
38
- }
@@ -1,24 +0,0 @@
1
- import type { LinguiConfig } from '@lingui/conf';
2
- import { type LoadCatalogFunction } from './lingui-server';
3
- /**
4
- * Initialize the Korio Next Core i18n system
5
- * This should be called once at application startup
6
- *
7
- * @param config - Your Lingui configuration
8
- * @param loadCatalog - Function to load message catalogs
9
- *
10
- * @example
11
- * ```typescript
12
- * import linguiConfig from './lingui.config';
13
- * import { initializeI18n } from '@korioinc/next-core/i18n/init';
14
- *
15
- * initializeI18n(linguiConfig, async (locale) => {
16
- * const { messages } = await import(`./lang/${locale}.po`);
17
- * return { messages };
18
- * });
19
- * ```
20
- */
21
- export declare function initializeI18n(config: LinguiConfig, loadCatalog: LoadCatalogFunction): void;
22
- export type { LoadCatalogFunction } from './lingui-server';
23
- export type { LinguiConfig } from '@lingui/conf';
24
- //# sourceMappingURL=init.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/i18n/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAIjD,OAAO,EAA0B,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEnF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,mBAAmB,QAGpF;AAGD,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC"}
package/dist/i18n/init.js DELETED
@@ -1,24 +0,0 @@
1
- import { initializeLinguiConfig } from '../config/lingui-config';
2
- import { initializeLinguiServer } from './lingui-server';
3
- /**
4
- * Initialize the Korio Next Core i18n system
5
- * This should be called once at application startup
6
- *
7
- * @param config - Your Lingui configuration
8
- * @param loadCatalog - Function to load message catalogs
9
- *
10
- * @example
11
- * ```typescript
12
- * import linguiConfig from './lingui.config';
13
- * import { initializeI18n } from '@korioinc/next-core/i18n/init';
14
- *
15
- * initializeI18n(linguiConfig, async (locale) => {
16
- * const { messages } = await import(`./lang/${locale}.po`);
17
- * return { messages };
18
- * });
19
- * ```
20
- */
21
- export function initializeI18n(config, loadCatalog) {
22
- initializeLinguiConfig(config);
23
- initializeLinguiServer(loadCatalog);
24
- }
@@ -1,32 +0,0 @@
1
- import type { Messages } from '@lingui/core';
2
- import { I18n } from '@lingui/core';
3
- import 'server-only';
4
- /**
5
- * Load message catalog for a specific locale
6
- * This function should be implemented by the consumer application
7
- */
8
- export type LoadCatalogFunction = (locale: string) => Promise<{
9
- messages: Messages;
10
- }>;
11
- /**
12
- * Initialize the lingui server with a catalog loader function
13
- * This should be called once at application startup
14
- */
15
- export declare function initializeLinguiServer(loadCatalog: LoadCatalogFunction): void;
16
- /**
17
- * Get all message catalogs
18
- */
19
- export declare function getAllMessages(): Promise<{
20
- [key: string]: Messages;
21
- }>;
22
- /**
23
- * Get all i18n instances
24
- */
25
- export declare function getAllI18nInstances(): Promise<{
26
- [key: string]: I18n;
27
- }>;
28
- /**
29
- * Get i18n instance for a specific locale
30
- */
31
- export declare function getI18nInstance(locale: string): Promise<I18n>;
32
- //# sourceMappingURL=lingui-server.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lingui-server.d.ts","sourceRoot":"","sources":["../../src/i18n/lingui-server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAa,MAAM,cAAc,CAAC;AAI/C,OAAO,aAAa,CAAC;AAMrB;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAC;AAItF;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,mBAAmB,QAKtE;AAED;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAA;CAAE,CAAC,CAyB3E;AAED;;GAEG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,CAmB5E;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAWnE"}
@@ -1,74 +0,0 @@
1
- import { setupI18n } from '@lingui/core';
2
- import { getLocalesFromConfig } from '../config/lingui-config';
3
- import 'server-only';
4
- // Cache for loaded catalogs and i18n instances
5
- let catalogsCache = null;
6
- let i18nInstancesCache = null;
7
- let loadCatalogFunction = null;
8
- /**
9
- * Initialize the lingui server with a catalog loader function
10
- * This should be called once at application startup
11
- */
12
- export function initializeLinguiServer(loadCatalog) {
13
- loadCatalogFunction = loadCatalog;
14
- // Reset caches when re-initializing
15
- catalogsCache = null;
16
- i18nInstancesCache = null;
17
- }
18
- /**
19
- * Get all message catalogs
20
- */
21
- export async function getAllMessages() {
22
- if (catalogsCache) {
23
- return catalogsCache;
24
- }
25
- if (!loadCatalogFunction) {
26
- console.warn('Lingui server not initialized. Using empty catalogs.');
27
- return {};
28
- }
29
- const locales = getLocalesFromConfig();
30
- const catalogs = await Promise.all(locales.map(async (locale) => {
31
- try {
32
- const { messages } = await loadCatalogFunction(locale);
33
- return { [locale]: messages };
34
- }
35
- catch (error) {
36
- console.warn(`Failed to load catalog for locale "${locale}":`, error);
37
- return { [locale]: {} };
38
- }
39
- }));
40
- catalogsCache = catalogs.reduce((acc, catalog) => ({ ...acc, ...catalog }), {});
41
- return catalogsCache;
42
- }
43
- /**
44
- * Get all i18n instances
45
- */
46
- export async function getAllI18nInstances() {
47
- if (i18nInstancesCache) {
48
- return i18nInstancesCache;
49
- }
50
- const allMessages = await getAllMessages();
51
- const locales = getLocalesFromConfig();
52
- i18nInstancesCache = locales.reduce((acc, locale) => {
53
- const messages = allMessages[locale] ?? {};
54
- const i18n = setupI18n({
55
- locale,
56
- messages: { [locale]: messages },
57
- });
58
- return { ...acc, [locale]: i18n };
59
- }, {});
60
- return i18nInstancesCache;
61
- }
62
- /**
63
- * Get i18n instance for a specific locale
64
- */
65
- export async function getI18nInstance(locale) {
66
- const instances = await getAllI18nInstances();
67
- if (!instances[locale]) {
68
- console.warn(`No i18n instance found for locale "${locale}"`);
69
- // Fallback to 'en' or first available locale
70
- const fallbackLocale = instances['en'] ? 'en' : Object.keys(instances)[0];
71
- return instances[fallbackLocale];
72
- }
73
- return instances[locale];
74
- }
@@ -1,37 +0,0 @@
1
- import type { Messages } from '@lingui/core';
2
- /**
3
- * Load lingui catalogs and initialize the i18n setup
4
- * This function should be called by the app at startup
5
- *
6
- * @example
7
- * ```typescript
8
- * // In your app's initialization (e.g., next.config.ts or app layout)
9
- * import { loadLinguiCatalogs } from '@korioinc/next-core/i18n/lingui.loader';
10
- *
11
- * // Load all catalogs
12
- * await loadLinguiCatalogs(async (locale) => {
13
- * const { messages } = await import(`./lang/${locale}.po`);
14
- * return messages;
15
- * }, ['en', 'ko', 'pseudo']);
16
- * ```
17
- */
18
- export declare function loadLinguiCatalogs(loader: (locale: string) => Promise<Messages>, locales: string[]): Promise<void>;
19
- /**
20
- * Alternative: Load catalogs with a static import map
21
- * This is useful when you know all locales at build time
22
- *
23
- * @example
24
- * ```typescript
25
- * import enMessages from './lang/en.po';
26
- * import koMessages from './lang/ko.po';
27
- *
28
- * loadLinguiCatalogsStatic({
29
- * en: enMessages.messages,
30
- * ko: koMessages.messages,
31
- * });
32
- * ```
33
- */
34
- export declare function loadLinguiCatalogsStatic(messages: {
35
- [locale: string]: Messages;
36
- }): void;
37
- //# sourceMappingURL=lingui.loader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lingui.loader.d.ts","sourceRoot":"","sources":["../../src/i18n/lingui.loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG7C;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,CAAC,EAC7C,OAAO,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,IAAI,CAAC,CAcf;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE;IAAE,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAA;CAAE,GAAG,IAAI,CAEvF"}
@@ -1,49 +0,0 @@
1
- import { setAllMessages } from './lingui.setup';
2
- /**
3
- * Load lingui catalogs and initialize the i18n setup
4
- * This function should be called by the app at startup
5
- *
6
- * @example
7
- * ```typescript
8
- * // In your app's initialization (e.g., next.config.ts or app layout)
9
- * import { loadLinguiCatalogs } from '@korioinc/next-core/i18n/lingui.loader';
10
- *
11
- * // Load all catalogs
12
- * await loadLinguiCatalogs(async (locale) => {
13
- * const { messages } = await import(`./lang/${locale}.po`);
14
- * return messages;
15
- * }, ['en', 'ko', 'pseudo']);
16
- * ```
17
- */
18
- export async function loadLinguiCatalogs(loader, locales) {
19
- const allMessages = {};
20
- for (const locale of locales) {
21
- try {
22
- const messages = await loader(locale);
23
- allMessages[locale] = messages;
24
- }
25
- catch (error) {
26
- console.error(`Failed to load messages for locale "${locale}":`, error);
27
- // Continue loading other locales
28
- }
29
- }
30
- setAllMessages(allMessages);
31
- }
32
- /**
33
- * Alternative: Load catalogs with a static import map
34
- * This is useful when you know all locales at build time
35
- *
36
- * @example
37
- * ```typescript
38
- * import enMessages from './lang/en.po';
39
- * import koMessages from './lang/ko.po';
40
- *
41
- * loadLinguiCatalogsStatic({
42
- * en: enMessages.messages,
43
- * ko: koMessages.messages,
44
- * });
45
- * ```
46
- */
47
- export function loadLinguiCatalogsStatic(messages) {
48
- setAllMessages(messages);
49
- }
@@ -1,4 +0,0 @@
1
- declare module 'lingui.locales' {
2
- import type { Messages } from '@lingui/core';
3
- export function loadCatalog(locale: string): Promise<{ [k: string]: Messages }>;
4
- }