@aldinn/next 0.1.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.
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -0
- package/package.json +24 -0
- package/src/index.ts +72 -0
- package/tsconfig.json +10 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface NextFontOptions {
|
|
2
|
+
weight?: string | number | (string | number)[];
|
|
3
|
+
style?: 'normal' | 'italic' | ('normal' | 'italic')[];
|
|
4
|
+
display?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';
|
|
5
|
+
variable?: string;
|
|
6
|
+
fallback?: string[];
|
|
7
|
+
preload?: boolean;
|
|
8
|
+
cdnBaseUrl?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface NextFontResult {
|
|
11
|
+
className: string;
|
|
12
|
+
variable: string;
|
|
13
|
+
style: {
|
|
14
|
+
fontFamily: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Creates a Next.js font loader instance for a given font ID
|
|
19
|
+
*/
|
|
20
|
+
export declare function sorobornoFont(fontId: string, options?: NextFontOptions): NextFontResult;
|
|
21
|
+
/**
|
|
22
|
+
* Predefined helper loaders for popular Bangla fonts
|
|
23
|
+
*/
|
|
24
|
+
export declare const SolaimanLipi: (options?: NextFontOptions) => NextFontResult;
|
|
25
|
+
export declare const Kalpurush: (options?: NextFontOptions) => NextFontResult;
|
|
26
|
+
export declare const Bornomala: (options?: NextFontOptions) => NextFontResult;
|
|
27
|
+
export declare const SiyamRupali: (options?: NextFontOptions) => NextFontResult;
|
|
28
|
+
export declare const AdorshoLipi: (options?: NextFontOptions) => NextFontResult;
|
|
29
|
+
export declare const TiroBangla: (options?: NextFontOptions) => NextFontResult;
|
|
30
|
+
export declare const NotoSerifBengali: (options?: NextFontOptions) => NextFontResult;
|
|
31
|
+
export declare const GoogleSans: (options?: NextFontOptions) => NextFontResult;
|
|
32
|
+
export declare const Shurjo: (options?: NextFontOptions) => NextFontResult;
|
|
33
|
+
export declare const Boshonto: (options?: NextFontOptions) => NextFontResult;
|
|
34
|
+
export declare const Chilekotha: (options?: NextFontOptions) => NextFontResult;
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC/C,KAAK,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC,EAAE,CAAC;IACtD,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,CAAC;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE;QACL,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAID;;GAEG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,eAAoB,GAC5B,cAAc,CA4BhB;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,GAAI,UAAU,eAAe,mBAA4C,CAAC;AACnG,eAAO,MAAM,SAAS,GAAI,UAAU,eAAe,mBAAwC,CAAC;AAC5F,eAAO,MAAM,SAAS,GAAI,UAAU,eAAe,mBAAwC,CAAC;AAC5F,eAAO,MAAM,WAAW,GAAI,UAAU,eAAe,mBAA2C,CAAC;AACjG,eAAO,MAAM,WAAW,GAAI,UAAU,eAAe,mBAA2C,CAAC;AACjG,eAAO,MAAM,UAAU,GAAI,UAAU,eAAe,mBAA0C,CAAC;AAC/F,eAAO,MAAM,gBAAgB,GAAI,UAAU,eAAe,mBAAiD,CAAC;AAC5G,eAAO,MAAM,UAAU,GAAI,UAAU,eAAe,mBAA0C,CAAC;AAC/F,eAAO,MAAM,MAAM,GAAI,UAAU,eAAe,mBAAqC,CAAC;AACtF,eAAO,MAAM,QAAQ,GAAI,UAAU,eAAe,mBAAuC,CAAC;AAC1F,eAAO,MAAM,UAAU,GAAI,UAAU,eAAe,mBAAyC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { getFontStylesheetUrl, getFont } from '@aldinn/core';
|
|
2
|
+
let styleSheetInjected = false;
|
|
3
|
+
/**
|
|
4
|
+
* Creates a Next.js font loader instance for a given font ID
|
|
5
|
+
*/
|
|
6
|
+
export function sorobornoFont(fontId, options = {}) {
|
|
7
|
+
const font = getFont(fontId);
|
|
8
|
+
const family = font?.family || fontId;
|
|
9
|
+
const variable = options.variable || `--font-${fontId}`;
|
|
10
|
+
const className = `__font_${fontId.replace(/[^a-zA-Z0-9]/g, '_')}`;
|
|
11
|
+
const fallbackArray = options.fallback || ['sans-serif'];
|
|
12
|
+
const fullFontFamily = `'${family}', ${fallbackArray.join(', ')}`;
|
|
13
|
+
// On client, ensure stylesheet is linked
|
|
14
|
+
if (typeof window !== 'undefined') {
|
|
15
|
+
const linkId = `soroborno-next-${fontId}`;
|
|
16
|
+
if (!document.getElementById(linkId)) {
|
|
17
|
+
const link = document.createElement('link');
|
|
18
|
+
link.id = linkId;
|
|
19
|
+
link.rel = 'stylesheet';
|
|
20
|
+
link.href = getFontStylesheetUrl(fontId, options.cdnBaseUrl);
|
|
21
|
+
document.head.appendChild(link);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
className,
|
|
26
|
+
variable,
|
|
27
|
+
style: {
|
|
28
|
+
fontFamily: fullFontFamily
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Predefined helper loaders for popular Bangla fonts
|
|
34
|
+
*/
|
|
35
|
+
export const SolaimanLipi = (options) => sorobornoFont('solaiman-lipi', options);
|
|
36
|
+
export const Kalpurush = (options) => sorobornoFont('kalpurush', options);
|
|
37
|
+
export const Bornomala = (options) => sorobornoFont('bornomala', options);
|
|
38
|
+
export const SiyamRupali = (options) => sorobornoFont('siyam-rupali', options);
|
|
39
|
+
export const AdorshoLipi = (options) => sorobornoFont('adorsho-lipi', options);
|
|
40
|
+
export const TiroBangla = (options) => sorobornoFont('tiro-bangla', options);
|
|
41
|
+
export const NotoSerifBengali = (options) => sorobornoFont('noto-serif-bengali', options);
|
|
42
|
+
export const GoogleSans = (options) => sorobornoFont('google-sans', options);
|
|
43
|
+
export const Shurjo = (options) => sorobornoFont('shurjo', options);
|
|
44
|
+
export const Boshonto = (options) => sorobornoFont('boshonto', options);
|
|
45
|
+
export const Chilekotha = (options) => sorobornoFont('chilekotha', options);
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAoB7D,IAAI,kBAAkB,GAAG,KAAK,CAAC;AAE/B;;GAEG;AACH,MAAM,UAAU,aAAa,CAC3B,MAAc,EACd,UAA2B,EAAE;IAE7B,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B,MAAM,MAAM,GAAG,IAAI,EAAE,MAAM,IAAI,MAAM,CAAC;IACtC,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,UAAU,M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AM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAyB,EAAE,EAAE,CAAC,aAAa,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;AACjG,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAyB,EAAE,EAAE,CAAC,aAAa,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;AACjG,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAyB,EAAE,EAAE,CAAC,aAAa,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAC/F,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAyB,EAAE,EAAE,CAAC,aAAa,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;AAC5G,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAyB,EAAE,EAAE,CAAC,aAAa,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAC/F,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,OAAyB,EAAE,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACtF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,OAAyB,EAAE,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC1F,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAyB,EAAE,EAAE,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aldinn/next",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Next.js font optimization helper and loaders for the Soroborno Bangla font ecosystem",
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.cjs",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@aldinn/core": "^0.1.0"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc"
|
|
20
|
+
},
|
|
21
|
+
"keywords": ["bangla", "fonts", "nextjs", "typography", "soroborno"],
|
|
22
|
+
"author": "Taraldinn",
|
|
23
|
+
"license": "MIT"
|
|
24
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { getFontStylesheetUrl, getFont } from '@aldinn/core';
|
|
2
|
+
|
|
3
|
+
export interface NextFontOptions {
|
|
4
|
+
weight?: string | number | (string | number)[];
|
|
5
|
+
style?: 'normal' | 'italic' | ('normal' | 'italic')[];
|
|
6
|
+
display?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';
|
|
7
|
+
variable?: string;
|
|
8
|
+
fallback?: string[];
|
|
9
|
+
preload?: boolean;
|
|
10
|
+
cdnBaseUrl?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface NextFontResult {
|
|
14
|
+
className: string;
|
|
15
|
+
variable: string;
|
|
16
|
+
style: {
|
|
17
|
+
fontFamily: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let styleSheetInjected = false;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Creates a Next.js font loader instance for a given font ID
|
|
25
|
+
*/
|
|
26
|
+
export function sorobornoFont(
|
|
27
|
+
fontId: string,
|
|
28
|
+
options: NextFontOptions = {}
|
|
29
|
+
): NextFontResult {
|
|
30
|
+
const font = getFont(fontId);
|
|
31
|
+
const family = font?.family || fontId;
|
|
32
|
+
const variable = options.variable || `--font-${fontId}`;
|
|
33
|
+
const className = `__font_${fontId.replace(/[^a-zA-Z0-9]/g, '_')}`;
|
|
34
|
+
|
|
35
|
+
const fallbackArray = options.fallback || ['sans-serif'];
|
|
36
|
+
const fullFontFamily = `'${family}', ${fallbackArray.join(', ')}`;
|
|
37
|
+
|
|
38
|
+
// On client, ensure stylesheet is linked
|
|
39
|
+
if (typeof window !== 'undefined') {
|
|
40
|
+
const linkId = `soroborno-next-${fontId}`;
|
|
41
|
+
if (!document.getElementById(linkId)) {
|
|
42
|
+
const link = document.createElement('link');
|
|
43
|
+
link.id = linkId;
|
|
44
|
+
link.rel = 'stylesheet';
|
|
45
|
+
link.href = getFontStylesheetUrl(fontId, options.cdnBaseUrl);
|
|
46
|
+
document.head.appendChild(link);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
className,
|
|
52
|
+
variable,
|
|
53
|
+
style: {
|
|
54
|
+
fontFamily: fullFontFamily
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Predefined helper loaders for popular Bangla fonts
|
|
61
|
+
*/
|
|
62
|
+
export const SolaimanLipi = (options?: NextFontOptions) => sorobornoFont('solaiman-lipi', options);
|
|
63
|
+
export const Kalpurush = (options?: NextFontOptions) => sorobornoFont('kalpurush', options);
|
|
64
|
+
export const Bornomala = (options?: NextFontOptions) => sorobornoFont('bornomala', options);
|
|
65
|
+
export const SiyamRupali = (options?: NextFontOptions) => sorobornoFont('siyam-rupali', options);
|
|
66
|
+
export const AdorshoLipi = (options?: NextFontOptions) => sorobornoFont('adorsho-lipi', options);
|
|
67
|
+
export const TiroBangla = (options?: NextFontOptions) => sorobornoFont('tiro-bangla', options);
|
|
68
|
+
export const NotoSerifBengali = (options?: NextFontOptions) => sorobornoFont('noto-serif-bengali', options);
|
|
69
|
+
export const GoogleSans = (options?: NextFontOptions) => sorobornoFont('google-sans', options);
|
|
70
|
+
export const Shurjo = (options?: NextFontOptions) => sorobornoFont('shurjo', options);
|
|
71
|
+
export const Boshonto = (options?: NextFontOptions) => sorobornoFont('boshonto', options);
|
|
72
|
+
export const Chilekotha = (options?: NextFontOptions) => sorobornoFont('chilekotha', options);
|