@siraj-works/naskh 0.1.0 → 0.1.1

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/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
1
  # Changelog
2
2
 
3
- ## 0.1.0 (unreleased)
3
+ ## 0.1.1 (2026-11-29)
4
+ - TypeScript declarations now match the published package name and both entry
5
+ points. Previously `index.d.ts` declared `module 'naskh'`, so TypeScript users
6
+ of `@siraj-works/naskh` got no types at all. Added `pdfkit.d.ts` and `types`
7
+ conditions to the `exports` map (works with `node`, `node16`/`nodenext` and
8
+ `bundler` resolution); verified with `tsc --strict` under all three.
9
+ - README: corrected the license note (the Amiri font does ship in `assets/`),
10
+ documented TypeScript support.
11
+
12
+ ## 0.1.0 (2026-11-28)
4
13
  - Initial release: UAX#9 bidi reordering (via bidi-js), contextual Arabic
5
14
  shaping (U+0621–U+064A, tatweel, lam-alef), visual piece decomposition for
6
15
  script-itemizing engines (pdfkit/fontkit, node-canvas/Pango), pdfkit
package/README.md CHANGED
@@ -81,6 +81,10 @@ const visual = naskh.prepare('مرحبا بالعالم', { renderer: 'generic'
81
81
  first strong character). Multiline input: `\n` splits paragraphs, each handled
82
82
  independently.
83
83
 
84
+ TypeScript types ship with the package for both entry points
85
+ (`@siraj-works/naskh` and `@siraj-works/naskh/pdfkit`); they resolve under
86
+ `node`, `node16`/`nodenext` and `bundler` module resolution.
87
+
84
88
  ## Fonts
85
89
 
86
90
  Shaped output and presentation forms need a font that covers Arabic Presentation
@@ -106,5 +110,5 @@ coverage first.
106
110
 
107
111
  ## License
108
112
 
109
- MIT. Dependencies: bidi-js (MIT). Example font Amiri is OFL-1.1 (font files are
110
- not part of the package).
113
+ MIT. Dependencies: bidi-js (MIT). The Amiri font in `assets/` is OFL-1.1 and
114
+ ships with the package; other fonts are your choice.
package/index.d.ts CHANGED
@@ -1,22 +1,33 @@
1
- declare module 'naskh' {
2
- export interface PrepareOptions {
3
- renderer?: 'pdfkit' | 'pdfmake' | 'generic';
4
- direction?: 'auto' | 'rtl' | 'ltr';
5
- assumeShaped?: boolean;
6
- }
7
- export interface Piece { text: string; rtl: boolean; neutral: boolean; }
8
- export interface Run { text: string; rtl: boolean; level: number; break?: boolean; }
9
- export function prepare(text: string, opts?: PrepareOptions): string;
10
- export function shape(text: string): string;
11
- export function unshape(text: string): string;
12
- export function isShaped(text: string): boolean;
13
- export function toVisual(text: string, opts?: { direction?: 'auto' | 'rtl' | 'ltr' }): string;
14
- export function visualRuns(text: string, opts?: { direction?: 'auto' | 'rtl' | 'ltr'; mirror?: boolean }): Run[];
15
- export function visualPieces(text: string, opts?: { direction?: 'auto' | 'rtl' | 'ltr'; mirror?: boolean; engine?: 'fontkit' | 'pango' }): Piece[];
16
- export function reorderForEngine(text: string, opts?: { direction?: 'auto' | 'rtl' | 'ltr' }): string;
17
- export const version: string;
1
+ export interface PrepareOptions {
2
+ renderer?: 'pdfkit' | 'pdfmake' | 'generic';
3
+ direction?: 'auto' | 'rtl' | 'ltr';
4
+ assumeShaped?: boolean;
18
5
  }
19
- declare module 'naskh/pdfkit' {
20
- export function drawText(doc: any, text: string, x: number, y: number, opts?: { direction?: 'auto' | 'rtl' | 'ltr'; align?: 'left' | 'right' }): number;
21
- export function drawParagraphs(doc: any, text: string, x: number, y: number, opts?: { direction?: 'auto' | 'rtl' | 'ltr'; align?: 'left' | 'right'; lineGap?: number }): number;
6
+
7
+ export interface Piece {
8
+ text: string;
9
+ rtl: boolean;
10
+ neutral: boolean;
22
11
  }
12
+
13
+ export interface Run {
14
+ text: string;
15
+ rtl: boolean;
16
+ level: number;
17
+ break?: boolean;
18
+ }
19
+
20
+ export type Direction = 'auto' | 'rtl' | 'ltr';
21
+
22
+ export function prepare(text: string, opts?: PrepareOptions): string;
23
+ export function shape(text: string): string;
24
+ export function unshape(text: string): string;
25
+ export function isShaped(text: string): boolean;
26
+ export function toVisual(text: string, opts?: { direction?: Direction }): string;
27
+ export function visualRuns(text: string, opts?: { direction?: Direction; mirror?: boolean }): Run[];
28
+ export function visualPieces(
29
+ text: string,
30
+ opts?: { direction?: Direction; mirror?: boolean; engine?: 'fontkit' | 'pango' }
31
+ ): Piece[];
32
+ export function reorderForEngine(text: string, opts?: { direction?: Direction }): string;
33
+ export const version: string;
package/package.json CHANGED
@@ -1,13 +1,20 @@
1
1
  {
2
2
  "name": "@siraj-works/naskh",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Arabic & RTL text preparation for PDF and canvas renderers: UAX#9 bidi reordering + contextual Arabic shaping. Logical in, renderer-ready out.",
5
5
  "main": "src/index.js",
6
6
  "types": "index.d.ts",
7
7
  "exports": {
8
- ".": "./src/index.js",
9
- "./pdfkit": "./src/integrations/pdfkit.js",
10
- "./assets/*": "./assets/*"
8
+ ".": {
9
+ "types": "./index.d.ts",
10
+ "default": "./src/index.js"
11
+ },
12
+ "./pdfkit": {
13
+ "types": "./pdfkit.d.ts",
14
+ "default": "./src/integrations/pdfkit.js"
15
+ },
16
+ "./assets/*": "./assets/*",
17
+ "./package.json": "./package.json"
11
18
  },
12
19
  "files": [
13
20
  "src",
@@ -18,10 +25,12 @@
18
25
  "LIMITATIONS.md",
19
26
  "CHANGELOG.md",
20
27
  "SECURITY.md",
21
- "LICENSE"
28
+ "LICENSE",
29
+ "pdfkit.d.ts"
22
30
  ],
23
31
  "scripts": {
24
- "test": "node --test && node test-robust.js && node test-verify.js"
32
+ "test": "node --test && node test-robust.js && node test-verify.js",
33
+ "prepublishOnly": "node scripts-preflight.js"
25
34
  },
26
35
  "keywords": [
27
36
  "arabic",
package/pdfkit.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ export interface PdfKitOptions {
2
+ direction?: 'auto' | 'rtl' | 'ltr';
3
+ align?: 'left' | 'right';
4
+ }
5
+
6
+ export interface PdfKitParagraphOptions extends PdfKitOptions {
7
+ lineGap?: number;
8
+ }
9
+
10
+ export function drawText(doc: any, text: string, x: number, y: number, opts?: PdfKitOptions): number;
11
+ export function drawParagraphs(
12
+ doc: any,
13
+ text: string,
14
+ x: number,
15
+ y: number,
16
+ opts?: PdfKitParagraphOptions
17
+ ): number;