diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 0d2d0bc..1bba01b 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -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) diff --git a/.github/workflows/test.yml b/.github/workflows/ci.yml similarity index 82% rename from .github/workflows/test.yml rename to .github/workflows/ci.yml index 2955b3e..f71cd5a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Test +name: CI on: push: @@ -10,7 +10,7 @@ jobs: strategy: matrix: - node-version: [22.x] + node-version: [22.x, 24.x] steps: - name: Checkout repository @@ -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 diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 3588c22..2629d23 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -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) @@ -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: | diff --git a/AGENT.md b/AGENT.md index ed3ca6e..3f5597b 100644 --- a/AGENT.md +++ b/AGENT.md @@ -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. @@ -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. diff --git a/README.md b/README.md index ba4162b..8ba9230 100644 --- a/README.md +++ b/README.md @@ -29,22 +29,22 @@ Can be used in Node.js and the browser. - -workflows + +workflows ## 📋 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!

➡️ Check out the usage and detailed documentation on each feature ⬅️

@@ -54,38 +54,51 @@ 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 - + + + + + + ``` -### 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: 'الخيل والليل والبيداء تعرفني' ``` @@ -93,8 +106,8 @@ console.log(ArabicServices.removeTashkeel('الخَيْلُ وَاللّيْلُ 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 @@ -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/) diff --git a/README_AR.md b/README_AR.md index b8f3f44..c9bca3a 100644 --- a/README_AR.md +++ b/README_AR.md @@ -26,22 +26,22 @@ - -workflows + +workflows ## 📋 الميزات -- **إزالة التشكيل:** إزالة التشكيل من النص العربي. -- **إزالة التطويل:** إزالة أحرف التطويل غير الضرورية من العبارات العربية. -- **التحويل إلى العربية القديمة:** تحويل النص العربي إلى الخط العربي القديم. -- **التحويل إلى العربية القديمة وتشفير الكلمات المحظورة:** تحويل النص العربي إلى الخط العربي القديم واستبدال النصوص العربية المحظورة بأحرف مشابهة بصريًا لأغراض الترميز. (الكلمات المحظورة هي الكلمات التي تعتبر كلمات مسيئة في وسائل التواصل الاجتماعي) -- **التشفير:** استبدال النص العربي بأحرف مشابهة بصريًا لأغراض الترميز. -- **تشفير الكلمات المحظورة:** استبدال النصوص العربية المحظورة بأحرف مشابهة بصريًا لأغراض الترميز. (الكلمات المحظورة هي الكلمات التي تعتبر كلمات مسيئة في وسائل التواصل الاجتماعي) -- **إزالة اللواحق العربية:** إزالة اللواحق المحددة (البادئات واللاحقات) من كلمة عربية إذا بدأت أو انتهت بهذه اللواحق. -- **الكلمة إلى حروفها:** تحويل الكلمة العربية إلى حروفها المنطوقة. -- ...والمزيد! +- **إزالة التشكيل:** إزالة التشكيل من النص العربي. +- **إزالة التطويل:** إزالة أحرف التطويل غير الضرورية من العبارات العربية. +- **التحويل إلى العربية القديمة:** تحويل النص العربي إلى الخط العربي القديم. +- **التحويل إلى العربية القديمة وتشفير الكلمات المحظورة:** تحويل النص العربي إلى الخط العربي القديم واستبدال النصوص العربية المحظورة بأحرف مشابهة بصريًا لأغراض الترميز. (الكلمات المحظورة هي الكلمات التي تعتبر كلمات مسيئة في وسائل التواصل الاجتماعي) +- **التشفير:** استبدال النص العربي بأحرف مشابهة بصريًا لأغراض الترميز. +- **تشفير الكلمات المحظورة:** استبدال النصوص العربية المحظورة بأحرف مشابهة بصريًا لأغراض الترميز. (الكلمات المحظورة هي الكلمات التي تعتبر كلمات مسيئة في وسائل التواصل الاجتماعي) +- **إزالة اللواحق العربية:** إزالة اللواحق المحددة (البادئات واللاحقات) من كلمة عربية إذا بدأت أو انتهت بهذه اللواحق. +- **الكلمة إلى حروفها:** تحويل الكلمة العربية إلى حروفها المنطوقة. +- ...والمزيد!

➡️ شاهد استخدام كل ميزة من المكتبة وطريقة استخدامها في الكود ⬅️

@@ -49,39 +49,53 @@ تم تصميم خدمات العربية لتعمل في كل من المتصفح وتطبيقات NodeJS. -### المتصفح +### المتصفح (Browser) -نوفر حزم ESM و UMD للاستخدام في المتصفح. يمكن العثور عليها مع ملفات الإصدار الأخير. +يمكنك استخدام المكتبة مباشرة في المتصفح عبر شبكات الـ CDN العالمية (**jsdelivr** أو **unpkg**)، أو تنزيل ملفات الـ Bundles الجاهزة من صفحة [GitHub Releases](https://github.com/Seen-Arabic/Arabic-Services-JavaScript/releases): ```html - + + + + + + ``` -### 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: 'الخيل والليل والبيداء تعرفني' ``` @@ -89,8 +103,8 @@ console.log(ArabicServices.removeTashkeel('الخَيْلُ وَاللّيْلُ تم إتاحة خدمات اللغة العربية للجمهور لتوفير مكتبة مُجربة جيدًا وموثقة بشكل جيد لمعالجة وتحويل النصوص العربية لجميع المطورين. نحن نقبل مساهمات الميزات بشرط أن تكون موثقة بشكل صحيح وتشمل الاختبارات المناسبة. -- 🚀 إذا كنت ترغب في المساهمة في هذا المشروع وتحسينه بأفكار جديدة، فبإمكانك عمل pull request وطلبك مرحب به للغاية. -- 📝 إذا وجدت أي مشكلة، فقط ضعها في قسم الـIssues في المستودع، شكرًا لك. +- 🚀 إذا كنت ترغب في المساهمة في هذا المشروع وتحسينه بأفكار جديدة، فبإمكانك عمل pull request وطلبك مرحب به للغاية. +- 📝 إذا وجدت أي مشكلة، فقط ضعها في قسم الـIssues في المستودع، شكرًا لك.

🌟 ضع نجمة على هذا المستودع 🌟

@@ -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/) diff --git a/example.html b/examples/browser/index.html similarity index 97% rename from example.html rename to examples/browser/index.html index 2941132..fa671ae 100644 --- a/example.html +++ b/examples/browser/index.html @@ -12,7 +12,7 @@ - +