Skip to content

Commit 3fca4e1

Browse files
author
اسمك
committed
تحديث إجباري للتطبيق للإصدار 1.0.1 وإصلاح مشكلة r.nanoid
1 parent 26973eb commit 3fca4e1

3 files changed

Lines changed: 104 additions & 53 deletions

File tree

app/polyfills.ts

Lines changed: 87 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* ملف بدائل (polyfills) للمشروع
33
* يساعد في توفير بعض الدوال المطلوبة للتشغيل على الويب
44
*
5-
* v1.0.1 - بناء محسن للويب
5+
* v1.0.1 - 2024 - بناء محسن للويب
66
*/
77

88
// استيراد polyfill لـ URL
@@ -22,66 +22,104 @@ function createSimpleId(size = 21): string {
2222
return id;
2323
}
2424

25-
// إصلاح مشكلة nanoid
26-
if (typeof global !== 'undefined') {
27-
const g = global as any;
25+
// إصلاح مشكلة nanoid عالمياً
26+
try {
27+
// بيئة node/global
28+
if (typeof global !== 'undefined') {
29+
const g = global as any;
30+
31+
// تأكد من وجود nanoid في النطاق العالمي
32+
if (!g.nanoid) {
33+
g.nanoid = createSimpleId;
34+
}
35+
36+
// دعم كائن r مع nanoid
37+
if (!g.r) {
38+
g.r = {};
39+
}
40+
if (!g.r.nanoid) {
41+
g.r.nanoid = createSimpleId;
42+
}
43+
}
2844

29-
// تأكد من وجود nanoid في النطاق العالمي
30-
if (!g.nanoid) {
31-
g.nanoid = createSimpleId;
45+
// بيئة المتصفح/window
46+
if (typeof window !== 'undefined') {
47+
const w = window as any;
48+
49+
// إضافة nanoid للويب
50+
if (!w.nanoid) {
51+
w.nanoid = createSimpleId;
52+
}
53+
54+
// إضافة كائن r.nanoid - هذا تحديداً يصلح الخطأ من useRegisterNavigator.tsx
55+
if (!w.r) {
56+
w.r = {};
57+
}
58+
59+
if (!w.r.nanoid) {
60+
w.r.nanoid = createSimpleId;
61+
}
62+
63+
// إضافة لمودولات ES
64+
if (!w.module) {
65+
w.module = {};
66+
}
67+
68+
if (!w.module.exports) {
69+
w.module.exports = {};
70+
}
71+
72+
w.module.exports.nanoid = createSimpleId;
73+
74+
// إصلاح لـ ToastAndroid
75+
if (!w.ToastAndroid) {
76+
w.ToastAndroid = {
77+
show: function(message: string, duration: number) {
78+
console.log('[Toast]', message);
79+
setTimeout(() => {
80+
if (typeof alert === 'function') {
81+
alert(message);
82+
}
83+
}, 0);
84+
},
85+
SHORT: 0,
86+
LONG: 1
87+
};
88+
}
3289
}
90+
91+
// إصلاح لمشكلة document.currentScript.src - يستخدم في expo-router
92+
if (typeof document !== 'undefined' && !document.currentScript) {
93+
Object.defineProperty(document, 'currentScript', {
94+
get: function() {
95+
return { src: '/index.js' };
96+
}
97+
});
98+
}
99+
} catch (error) {
100+
console.error('فشل في تطبيق البدائل:', error);
33101
}
34102

35103
// بديل لـ nanoid للتصدير
36104
export const nanoid = createSimpleId;
37105

38-
// إصلاح للويب
39-
if (typeof window !== 'undefined') {
40-
const w = window as any;
41-
42-
// إضافة nanoid للويب
43-
if (!w.nanoid) {
44-
w.nanoid = createSimpleId;
45-
}
46-
47-
// إضافة كائن r.nanoid - هذا تحديداً يصلح الخطأ من useRegisterNavigator.tsx
48-
if (!w.r) {
49-
w.r = {};
50-
}
106+
// للفحص والتأكد من أن الكود يعمل
107+
try {
108+
// تأكد من أن nanoid متاح ويمكن تنفيذه
109+
const testId = typeof nanoid === 'function' ? nanoid() : createSimpleId();
51110

52-
if (!w.r.nanoid) {
53-
w.r.nanoid = createSimpleId;
54-
}
111+
// إضافة تعليق لإظهار أن الملف تم تحميله
112+
console.log('[polyfills] تم تحميل البدائل لدعم التشغيل على الويب | v1.0.1');
113+
console.log('[polyfills] اختبار nanoid:', testId);
55114

56-
// إصلاح لـ ToastAndroid
57-
if (!w.ToastAndroid) {
58-
w.ToastAndroid = {
59-
show: function(message: string, duration: number) {
60-
console.log('[Toast]', message);
61-
setTimeout(() => {
62-
if (typeof alert === 'function') {
63-
alert(message);
64-
}
65-
}, 0);
66-
},
67-
SHORT: 0,
68-
LONG: 1
69-
};
115+
// اختبار r.nanoid إذا كان متاحاً
116+
if (typeof window !== 'undefined' && (window as any).r && typeof (window as any).r.nanoid === 'function') {
117+
console.log('[polyfills] اختبار r.nanoid:', (window as any).r.nanoid());
70118
}
119+
} catch (error) {
120+
console.error('[polyfills] خطأ في الاختبار:', error);
71121
}
72122

73-
// إصلاح لمشكلة document.currentScript.src - يستخدم في expo-router
74-
if (typeof document !== 'undefined' && !document.currentScript) {
75-
Object.defineProperty(document, 'currentScript', {
76-
get: function() {
77-
return { src: '/index.js' };
78-
}
79-
});
80-
}
81-
82-
// إضافة تعليق لإظهار أن الملف تم تحميله
83-
console.log('[polyfills] تم تحميل البدائل لدعم التشغيل على الويب | v1.0.1');
84-
85123
// export للتوافق كـ module
86124
export default {
87125
nanoid: createSimpleId,

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"name": "yazcar",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"main": "expo-router/entry",
5-
"homepage": "https://yousefjaser.github.io/YazCarFaxWeb",
5+
"homepage": "https://yazcar.xyz",
66
"scripts": {
77
"start": "expo start",
88
"android": "expo start --android",
99
"ios": "expo start --ios",
1010
"web": "expo start --web",
1111
"ts:check": "tsc",
1212
"build": "npx expo export:web",
13-
"vercel-build": "npx expo export:web",
13+
"vercel-build": "bash -c 'echo \"Building YazCar v1.0.1\" && npx expo export:web'",
1414
"predeploy": "npm run build && npx copyfiles -f web-build/* dist && npx copyfiles -f web-build/static/**/* dist/static",
1515
"deploy": "gh-pages -d dist",
1616
"clean": "rm -rf dist web-build .expo"

vercel.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"version": 2,
3+
"name": "yazcar-webapp-v101",
4+
"framework": "create-react-app",
5+
"buildCommand": "npm run vercel-build",
36
"routes": [
47
{ "src": "/manifest.json", "dest": "/manifest.json" },
58
{ "handle": "filesystem" },
@@ -12,6 +15,16 @@
1215
{ "key": "Content-Type", "value": "application/manifest+json" },
1316
{ "key": "Access-Control-Allow-Origin", "value": "*" }
1417
]
18+
},
19+
{
20+
"source": "/(.*)",
21+
"headers": [
22+
{ "key": "Cache-Control", "value": "no-cache, no-store, must-revalidate" }
23+
]
1524
}
16-
]
25+
],
26+
"github": {
27+
"enabled": true,
28+
"silent": false
29+
}
1730
}

0 commit comments

Comments
 (0)