onelaraveljs 1.1.8 → 1.2.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/package.json
CHANGED
|
@@ -16,22 +16,37 @@ class WrapperParser:
|
|
|
16
16
|
self.wrapper_function_content = ""
|
|
17
17
|
self.wrapper_config_content = ""
|
|
18
18
|
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
# Logic tìm kiếm file template:
|
|
20
|
+
# 1. Tìm theo đường dẫn được cung cấp (thường là User Custom Override trong project)
|
|
21
|
+
# 2. Nếu không thấy, tìm file mặc định trong thư mục templates của library (onejs/templates/wraper.js)
|
|
22
|
+
|
|
23
|
+
found_path = None
|
|
24
|
+
|
|
25
|
+
# 1. Check đường dẫn user cung cấp (relative to Project Root)
|
|
26
|
+
if os.path.exists(file_path):
|
|
27
|
+
found_path = file_path
|
|
28
|
+
else:
|
|
29
|
+
# 2. Check đường dẫn mặc định trong library
|
|
30
|
+
# __file__ = .../onejs/scripts/compiler/wrapper_parser.py
|
|
31
|
+
script_dir = os.path.dirname(os.path.abspath(__file__))
|
|
32
|
+
# library_root = .../onejs
|
|
33
|
+
# template_path = .../onejs/templates/wraper.js
|
|
34
|
+
lib_template_path = os.path.normpath(os.path.join(script_dir, "..", "..", "templates", "wraper.js"))
|
|
35
|
+
|
|
36
|
+
if os.path.exists(lib_template_path):
|
|
37
|
+
found_path = lib_template_path
|
|
38
|
+
else:
|
|
39
|
+
# 3. Fallback: check alt_path (giữ tương thích cũ)
|
|
40
|
+
alt_path = os.path.normpath(os.path.join(script_dir, "..", "..", file_path))
|
|
26
41
|
if os.path.exists(alt_path):
|
|
27
|
-
|
|
42
|
+
found_path = alt_path
|
|
28
43
|
|
|
29
|
-
if not
|
|
30
|
-
print(f"Warning: Wrapper file not found: {file_path}")
|
|
44
|
+
if not found_path:
|
|
45
|
+
print(f"Warning: Wrapper file not found. Checked: {file_path} and library defaults.")
|
|
31
46
|
return "", ""
|
|
32
47
|
|
|
33
48
|
try:
|
|
34
|
-
with open(
|
|
49
|
+
with open(found_path, 'r', encoding='utf-8') as f:
|
|
35
50
|
content = f.read()
|
|
36
51
|
except Exception as e:
|
|
37
52
|
print(f"Error reading wrapper file: {e}")
|