Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ assignees: ''

يرجى توضيح البيئة التي كنت تستخدمها عند حدوث المشكلة. يمكن ذلك أن يشمل:

- نسخة لغة البرمجة (مثل Python 3.8)
- نظام التشغيل (مثل Windows 10 أو Ubuntu 20.04)
- المكتبات البرمجية المعنية وإصداراتها
- بيئة التشغيل (مثل Node.js 22.x، أو المتصفح Chrome، أو Next.js / Vite)
- إصدار الحزمة arabic-services (مثل 1.1.0)
- نظام التشغيل (مثل Windows أو Linux أو macOS)

## السلوك المتوقع (Expected Behavior)

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: CI

on:
push:
Expand All @@ -10,7 +10,7 @@ jobs:

strategy:
matrix:
node-version: [22.x]
node-version: [22.x, 24.x]

steps:
- name: Checkout repository
Expand All @@ -32,5 +32,5 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Run build and tests
run: npm run build && npm test
- name: Run lint, build, and tests
run: npm run lint && npm run build && npm test
2 changes: 2 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:

# Step 4: Build package and bundles
- name: Build package and bundles
id: build
run: npm run build

# Step 5: Publish the package to npm using Trusted Publishing (OIDC)
Expand All @@ -39,6 +40,7 @@ jobs:

# Step 6: Upload bundle assets to release
- name: Upload bundle assets to release
if: always() && steps.build.outcome == 'success'
uses: softprops/action-gh-release@v2
with:
files: |
Expand Down
7 changes: 5 additions & 2 deletions AGENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ This repository contains `arabic-services`: a zero-runtime-dependency TypeScript
- `src/utils/`:
- `string.util.ts`: Internal string manipulation and regex utility functions.
- `tests/`:
- `scripts.test.ts`: Jest unit tests covering all text operations.
- `scripts.test.ts`: Vitest unit tests covering all text operations.
- `constants.test.ts`: Sanity checks for character mappings and constants.
- `artifacts.test.ts`: Module integrity tests for CJS, ESM, and browser UMD bundles.
- `edge-cases.test.ts`: Boundary values, orthography variations, and ReDoS resilience tests.
- `tree-shaking.test.ts`: Verification of named exports and dead code elimination.
- `webpack.config.cjs`: Bundler configuration generating UMD (`dist/umd/`) and ESM (`dist/esm/`) bundles for browser distribution.
- `tsconfig.json`: TypeScript compiler configuration targeting ES5 / CommonJS for the main npm distribution.

Expand All @@ -54,7 +57,7 @@ This repository contains `arabic-services`: a zero-runtime-dependency TypeScript
## Build, Test, and Development Commands

- `npm run build`: Compile TypeScript into `dist/` (generates `.js` and `.d.ts`).
- `npm test`: Run Jest unit tests and generate coverage report. **Note**: Run `npm run build` before `npm test`, as tests import from the compiled `./dist` directory.
- `npm test`: Run Vitest test suite and generate coverage report. **Note**: Run `npm run build` before `npm test`, as tests import from the compiled `./dist` directory.
- `npm test -- -t "test name"`: Run a specific test case by name.
- `npm run dev`: Quick execution runner using `ts-node src/index.ts`.
- `npm run bundle`: Run Webpack to bundle production UMD (`arabic-services.umd.js`) and ESM (`arabic-services.esm.js`) files for browser/CDN distribution.
Expand Down
63 changes: 38 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@ Can be used in Node.js and the browser.
<a href="https://github.com/Seen-Arabic/Arabic-Services-JavaScript/blob/master/LICENSE">
<img src="https://img.shields.io/github/license/Seen-Arabic/Arabic-Services-JavaScript"/>
</a>
<a href="https://github.com/Seen-Arabic/Arabic-Services-JavaScript/actions/workflows/test.yml">
<img src="https://github.com/Seen-Arabic/Arabic-Services-JavaScript/actions/workflows/test.yml/badge.svg" alt="workflows">
<a href="https://github.com/Seen-Arabic/Arabic-Services-JavaScript/actions/workflows/ci.yml">
<img src="https://github.com/Seen-Arabic/Arabic-Services-JavaScript/actions/workflows/ci.yml/badge.svg" alt="workflows">
</a>
</div>

## 📋 Features

- **Tashkeel Removal**: Easily remove Tashkeel from Arabic text.
- **Tatweel Removal**: Remove Tatweel character from Arabic phrases.
- **Convert To Old Arabic**: Transform Arabic text into old script.
- **Convert To Old Arabic And Tashfeer Banned Words**: Transform Arabic text into old script and replace Banned Arabic text with visually similar characters for encoding purposes. (Banned words are words that considered as hate speech in social media)
- **Tashfeer**: Replaces Arabic text with visually similar characters for encoding purposes.
- **Tashfeer Banned Words**: Replaces Banned Arabic text with visually similar characters for encoding purposes. (Banned words are words that considered as hate speech in social media)
- **Remove Arabic Affixes**: Removes predefined affixes (prefixes and suffixes) from an Arabic word if it starts or ends with those affixes.
- **Word To Letters**: Convert Arabic word to its pronounced letters.
- ... and more!
- **Tashkeel Removal**: Easily remove Tashkeel from Arabic text.
- **Tatweel Removal**: Remove Tatweel character from Arabic phrases.
- **Convert To Old Arabic**: Transform Arabic text into old script.
- **Convert To Old Arabic And Tashfeer Banned Words**: Transform Arabic text into old script and replace Banned Arabic text with visually similar characters for encoding purposes. (Banned words are words that considered as hate speech in social media)
- **Tashfeer**: Replaces Arabic text with visually similar characters for encoding purposes.
- **Tashfeer Banned Words**: Replaces Banned Arabic text with visually similar characters for encoding purposes. (Banned words are words that considered as hate speech in social media)
- **Remove Arabic Affixes**: Removes predefined affixes (prefixes and suffixes) from an Arabic word if it starts or ends with those affixes.
- **Word To Letters**: Convert Arabic word to its pronounced letters.
- ... and more!

<h3 align=center><a href="https://github.com/Seen-Arabic/Arabic-Services-JavaScript/wiki/Features-Documentation">➡️ Check out the usage and detailed documentation on each feature ⬅️</a></h3>

Expand All @@ -54,47 +54,60 @@ Arabic-Services was designed to work in both the browser and NodeJS applications

### Browser

We provide both ESM and UMD bundles for use in the browser.
You can find it with the latest release files.
You can use the library directly in the browser via CDN using **jsdelivr** or **unpkg**, or download standalone bundle files from the latest [GitHub Releases](https://github.com/Seen-Arabic/Arabic-Services-JavaScript/releases):

```html
<script src="arabic-services.umd.js"></script>
<!-- Via jsdelivr (Recommended) -->
<script src="https://cdn.jsdelivr.net/npm/arabic-services@1/dist/umd/arabic-services.umd.js"></script>

<!-- Or via unpkg -->
<script src="https://unpkg.com/arabic-services@1/dist/umd/arabic-services.umd.js"></script>

<script>
console.log(ArabicServices.removeTashkeel('الخَيْلُ وَاللّيْلُ وَالبَيْداءُ تَعرِفُني'));
// Output: 'الخيل والليل والبيداء تعرفني'
</script>
```

### NodeJS
### NodeJS & Modern Bundlers

Both CommonJS and ES Module libraries are provided.
Install the package via npm:

```bash
npm install arabic-services
```

**CommonJS:**
#### ES Module & Tree Shaking (Recommended):

Import only the functions you need for maximum bundle size reduction:

```javascript
const { ArabicServices } = require('arabic-services');
console.log(ArabicServices.removeTashkeel('الخَيْلُ وَاللّيْلُ وَالبَيْداءُ تَعرِفُني'));
import { removeTashkeel, removeTatweel, toOldArabic } from 'arabic-services';

console.log(removeTashkeel('الخَيْلُ وَاللّيْلُ وَالبَيْداءُ تَعرِفُني'));
// Output: 'الخيل والليل والبيداء تعرفني'
```

**ES Module:**
Or import the full object:

```javascript
import { ArabicServices } from 'arabic-services';
console.log(ArabicServices.removeTashkeel('الخَيْلُ وَاللّيْلُ وَالبَيْداءُ تَعرِفُني'));
```

#### CommonJS:

```javascript
const { removeTashkeel, ArabicServices } = require('arabic-services');
console.log(removeTashkeel('الخَيْلُ وَاللّيْلُ وَالبَيْداءُ تَعرِفُني'));
// Output: 'الخيل والليل والبيداء تعرفني'
```

## 💡 Contributing

Arabic Services is made publicly available to provide a well tested and well documented library for processing and transforming Arabic text to all developers. We accept feature contributions provided that they are properly documented and include the appropriate unit tests.

- 🚀 If you want to contribute to this project and make it better with new ideas, your pull request is very welcomed.
- 📝 If you find any issue just put it in the repository issue section, thank you.
- 🚀 If you want to contribute to this project and make it better with new ideas, your pull request is very welcomed.
- 📝 If you find any issue just put it in the repository issue section, thank you.

## 🌟 Star this repository

Expand All @@ -106,5 +119,5 @@ This project is licensed under the GPL-3.0 License. See the [LICENSE](./LICENSE)

## 💬 Contact

- 📩 Email: [SeenDevelopment@gmail.com](mailto:SeenDevelopment@gmail.com)
- 🌎 [Website](https://seen-arabic.github.io/)
- 📩 Email: [SeenDevelopment@gmail.com](mailto:SeenDevelopment@gmail.com)
- 🌎 [Website](https://seen-arabic.github.io/)
64 changes: 39 additions & 25 deletions README_AR.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,71 +26,85 @@
<a href="https://github.com/Seen-Arabic/Arabic-Services-JavaScript/blob/master/LICENSE">
<img src="https://img.shields.io/github/license/Seen-Arabic/Arabic-Services-JavaScript"/>
</a>
<a href="https://github.com/Seen-Arabic/Arabic-Services-JavaScript/actions/workflows/test.yml">
<img src="https://github.com/Seen-Arabic/Arabic-Services-JavaScript/actions/workflows/test.yml/badge.svg" alt="workflows">
<a href="https://github.com/Seen-Arabic/Arabic-Services-JavaScript/actions/workflows/ci.yml">
<img src="https://github.com/Seen-Arabic/Arabic-Services-JavaScript/actions/workflows/ci.yml/badge.svg" alt="workflows">
</a>
</div>

## 📋 الميزات

- **إزالة التشكيل:** إزالة التشكيل من النص العربي.
- **إزالة التطويل:** إزالة أحرف التطويل غير الضرورية من العبارات العربية.
- **التحويل إلى العربية القديمة:** تحويل النص العربي إلى الخط العربي القديم.
- **التحويل إلى العربية القديمة وتشفير الكلمات المحظورة:** تحويل النص العربي إلى الخط العربي القديم واستبدال النصوص العربية المحظورة بأحرف مشابهة بصريًا لأغراض الترميز. (الكلمات المحظورة هي الكلمات التي تعتبر كلمات مسيئة في وسائل التواصل الاجتماعي)
- **التشفير:** استبدال النص العربي بأحرف مشابهة بصريًا لأغراض الترميز.
- **تشفير الكلمات المحظورة:** استبدال النصوص العربية المحظورة بأحرف مشابهة بصريًا لأغراض الترميز. (الكلمات المحظورة هي الكلمات التي تعتبر كلمات مسيئة في وسائل التواصل الاجتماعي)
- **إزالة اللواحق العربية:** إزالة اللواحق المحددة (البادئات واللاحقات) من كلمة عربية إذا بدأت أو انتهت بهذه اللواحق.
- **الكلمة إلى حروفها:** تحويل الكلمة العربية إلى حروفها المنطوقة.
- ...والمزيد!
- **إزالة التشكيل:** إزالة التشكيل من النص العربي.
- **إزالة التطويل:** إزالة أحرف التطويل غير الضرورية من العبارات العربية.
- **التحويل إلى العربية القديمة:** تحويل النص العربي إلى الخط العربي القديم.
- **التحويل إلى العربية القديمة وتشفير الكلمات المحظورة:** تحويل النص العربي إلى الخط العربي القديم واستبدال النصوص العربية المحظورة بأحرف مشابهة بصريًا لأغراض الترميز. (الكلمات المحظورة هي الكلمات التي تعتبر كلمات مسيئة في وسائل التواصل الاجتماعي)
- **التشفير:** استبدال النص العربي بأحرف مشابهة بصريًا لأغراض الترميز.
- **تشفير الكلمات المحظورة:** استبدال النصوص العربية المحظورة بأحرف مشابهة بصريًا لأغراض الترميز. (الكلمات المحظورة هي الكلمات التي تعتبر كلمات مسيئة في وسائل التواصل الاجتماعي)
- **إزالة اللواحق العربية:** إزالة اللواحق المحددة (البادئات واللاحقات) من كلمة عربية إذا بدأت أو انتهت بهذه اللواحق.
- **الكلمة إلى حروفها:** تحويل الكلمة العربية إلى حروفها المنطوقة.
- ...والمزيد!

<h3 align=center><a href="https://github.com/Seen-Arabic/Arabic-Services-JavaScript/wiki/Features%E2%80%90Documentation%E2%80%90AR">➡️ شاهد استخدام كل ميزة من المكتبة وطريقة استخدامها في الكود ⬅️</a></h3>

## 🚀 التثبيت

تم تصميم خدمات العربية لتعمل في كل من المتصفح وتطبيقات NodeJS.

### المتصفح
### المتصفح (Browser)

نوفر حزم ESM و UMD للاستخدام في المتصفح. يمكن العثور عليها مع ملفات الإصدار الأخير.
يمكنك استخدام المكتبة مباشرة في المتصفح عبر شبكات الـ CDN العالمية (**jsdelivr** أو **unpkg**)، أو تنزيل ملفات الـ Bundles الجاهزة من صفحة [GitHub Releases](https://github.com/Seen-Arabic/Arabic-Services-JavaScript/releases):

```html
<script src="arabic-services.umd.js"></script>
<!-- عبر jsdelivr (موصى به) -->
<script src="https://cdn.jsdelivr.net/npm/arabic-services@1/dist/umd/arabic-services.umd.js"></script>

<!-- أو عبر unpkg -->
<script src="https://unpkg.com/arabic-services@1/dist/umd/arabic-services.umd.js"></script>

<script>
console.log(ArabicServices.removeTashkeel('الخَيْلُ وَاللّيْلُ وَالبَيْداءُ تَعرِفُني'));
// Output: 'الخيل والليل والبيداء تعرفني'
</script>
```

### NodeJS
### NodeJS وحزم العمل الحديثة (Modern Bundlers)

تم توفير مكتبات CommonJS و ES Module.
تثبيت الحزمة عبر npm:

```bash
npm install arabic-services
```

**CommonJS:**
#### نظام ES Module ودعم Tree Shaking (موصى به):

استيراد الدوال التي تحتاجها فقط لتقليل حجم الحزمة إلى أدنى حد (أقل من 400 بايت للدالة):

```javascript
const { ArabicServices } = require('arabic-services');
console.log(ArabicServices.removeTashkeel('الخَيْلُ وَاللّيْلُ وَالبَيْداءُ تَعرِفُني'));
import { removeTashkeel, removeTatweel, toOldArabic } from 'arabic-services';

console.log(removeTashkeel('الخَيْلُ وَاللّيْلُ وَالبَيْداءُ تَعرِفُني'));
// Output: 'الخيل والليل والبيداء تعرفني'
```

**ES Module:**
أو استيراد الكائن كاملاً:

```javascript
import { ArabicServices } from 'arabic-services';
console.log(ArabicServices.removeTashkeel('الخَيْلُ وَاللّيْلُ وَالبَيْداءُ تَعرِفُني'));
```

#### نظام CommonJS:

```javascript
const { removeTashkeel, ArabicServices } = require('arabic-services');
console.log(removeTashkeel('الخَيْلُ وَاللّيْلُ وَالبَيْداءُ تَعرِفُني'));
// Output: 'الخيل والليل والبيداء تعرفني'
```

## 💡 المساهمة

تم إتاحة خدمات اللغة العربية للجمهور لتوفير مكتبة مُجربة جيدًا وموثقة بشكل جيد لمعالجة وتحويل النصوص العربية لجميع المطورين. نحن نقبل مساهمات الميزات بشرط أن تكون موثقة بشكل صحيح وتشمل الاختبارات المناسبة.

- 🚀 إذا كنت ترغب في المساهمة في هذا المشروع وتحسينه بأفكار جديدة، فبإمكانك عمل pull request وطلبك مرحب به للغاية.
- 📝 إذا وجدت أي مشكلة، فقط ضعها في قسم الـIssues في المستودع، شكرًا لك.
- 🚀 إذا كنت ترغب في المساهمة في هذا المشروع وتحسينه بأفكار جديدة، فبإمكانك عمل pull request وطلبك مرحب به للغاية.
- 📝 إذا وجدت أي مشكلة، فقط ضعها في قسم الـIssues في المستودع، شكرًا لك.

<div align=center>
<h2>🌟 ضع نجمة على هذا المستودع 🌟</h2>
Expand All @@ -107,5 +121,5 @@ console.log(ArabicServices.removeTashkeel('الخَيْلُ وَاللّيْلُ

## 💬 الاتصال

- 📩 البريد الإلكتروني: [SeenDevelopment@gmail.com](mailto:SeenDevelopment@gmail.com)
- 🌎 [الموقع الإلكتروني](https://seen-arabic.github.io/)
- 📩 البريد الإلكتروني: [SeenDevelopment@gmail.com](mailto:SeenDevelopment@gmail.com)
- 🌎 [الموقع الإلكتروني](https://seen-arabic.github.io/)
2 changes: 1 addition & 1 deletion example.html → examples/browser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</head>
<body>
<!-- run npm run bundle to get arabic-services.umd.js file -->
<script src="./dist/umd/arabic-services.umd.js"></script>
<script src="../../dist/umd/arabic-services.umd.js"></script>
<script>
console.log('ArabicServices:', ArabicServices);
console.log('-------- Functions --------');
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
"test:watch": "vitest",
"prepublishOnly": "npm run build",
"format": "npx prettier --write . --ignore-path .gitignore",
"lint": "eslint src --quiet",
"lint:fix": "eslint src --fix",
"lint": "eslint . --quiet",
"lint:fix": "eslint . --fix",
"bundle": "webpack"
},
"repository": {
Expand Down
Loading
Loading