@kevlns/xlmerge 2.0.3 → 2.0.5
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/AGENTS.md +25 -169
- package/LICENSE +21 -21
- package/README.md +111 -111
- package/bin/xlmerge.js +152 -152
- package/package.json +3 -2
- package/python/xlsx_merge_engine/__init__.py +2 -2
- package/python/xlsx_merge_engine/xlsx_git_merge_bridge.py +1614 -1614
- package/python/xlsx_resolver/__init__.py +2 -2
- package/python/xlsx_resolver/__main__.py +4 -4
- package/python/xlsx_resolver/formula_values.py +677 -660
- package/python/xlsx_resolver/merge_server.py +24 -0
- package/python/xlsx_resolver/merge_ui.html +1635 -1634
- package/python/xlsx_resolver/recalculate_workbook.ps1 +140 -141
- package/python/xlsx_resolver/resolve_xlsx_conflict.py +9 -0
- package/python/xlsx_resolver/session.py +49 -0
- package/python/xlsx_resolver/xlsx_conflict.py +2381 -2317
- package/skills/xlmerge/SKILL.md +8 -0
- package/skills/xlmerge/references/project.md +171 -0
- package/v-cli.plugin.json +305 -248
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import json
|
|
6
|
+
import os
|
|
7
|
+
import uuid
|
|
6
8
|
import sys
|
|
7
9
|
import threading
|
|
8
10
|
import webbrowser
|
|
@@ -16,6 +18,7 @@ if str(SCRIPT_DIR) not in sys.path:
|
|
|
16
18
|
sys.path.insert(0, str(SCRIPT_DIR))
|
|
17
19
|
|
|
18
20
|
from xlsx_conflict import ConflictError, _build_commit_message, apply_manifest, load_manifest
|
|
21
|
+
from session import save_session
|
|
19
22
|
from prepare_progress import preparation_context, PreparationCancelled, checkpoint
|
|
20
23
|
|
|
21
24
|
|
|
@@ -73,6 +76,9 @@ def serve(manifest_path: Path | str, *, open_browser: bool = True, port: int = 0
|
|
|
73
76
|
status = {'state': 'preparing' if prepare_repo else 'ready', 'phase': '开始解析',
|
|
74
77
|
'file': '', 'fileDone': 0, 'fileTotal': 0, 'sheet': '', 'sheetDone': 0, 'sheetTotal': 0, 'side': ''}
|
|
75
78
|
|
|
79
|
+
receipt = {"sessionId": uuid.uuid4().hex, "pid": os.getpid(), "manifest": str(manifest_path), "state": "running"}
|
|
80
|
+
receipt_file = manifest_path.parent / "session.json"
|
|
81
|
+
|
|
76
82
|
def report(progress):
|
|
77
83
|
with lock:
|
|
78
84
|
status.update(progress)
|
|
@@ -109,6 +115,11 @@ def serve(manifest_path: Path | str, *, open_browser: bool = True, port: int = 0
|
|
|
109
115
|
with lock:
|
|
110
116
|
return _json(dict(status))
|
|
111
117
|
|
|
118
|
+
@app.get("/api/session")
|
|
119
|
+
def session_status():
|
|
120
|
+
with lock:
|
|
121
|
+
return _json({**receipt, "progress": dict(status)})
|
|
122
|
+
|
|
112
123
|
@app.get("/api/diff")
|
|
113
124
|
def diff():
|
|
114
125
|
if manifest is None:
|
|
@@ -141,6 +152,7 @@ def serve(manifest_path: Path | str, *, open_browser: bool = True, port: int = 0
|
|
|
141
152
|
message=(payload.get("message") or "").strip() or None,
|
|
142
153
|
)
|
|
143
154
|
if result["success"]:
|
|
155
|
+
receipt.update(state="completed", result=result)
|
|
144
156
|
state["resolved"] = True
|
|
145
157
|
threading.Timer(2.0, state["server"].shutdown).start()
|
|
146
158
|
return _json(result, 200 if result["success"] else 500)
|
|
@@ -153,6 +165,10 @@ def serve(manifest_path: Path | str, *, open_browser: bool = True, port: int = 0
|
|
|
153
165
|
|
|
154
166
|
@app.post("/api/shutdown")
|
|
155
167
|
def shutdown():
|
|
168
|
+
_payload()
|
|
169
|
+
identity = request.headers.get("X-Xlmerge-Session")
|
|
170
|
+
if identity is not None and identity != receipt["sessionId"]:
|
|
171
|
+
return _json({"success": False, "error": "审阅身份不一致"}, 409)
|
|
156
172
|
with lock:
|
|
157
173
|
if status['state'] == 'preparing':
|
|
158
174
|
cancelled.set()
|
|
@@ -169,11 +185,19 @@ def serve(manifest_path: Path | str, *, open_browser: bool = True, port: int = 0
|
|
|
169
185
|
if worker:
|
|
170
186
|
worker.start()
|
|
171
187
|
url = f"http://127.0.0.1:{server.server_port}"
|
|
188
|
+
receipt["url"] = url
|
|
189
|
+
save_session(receipt_file, receipt)
|
|
172
190
|
print(f"MERGE_SERVER_URL={url}", flush=True)
|
|
173
191
|
if open_browser:
|
|
174
192
|
webbrowser.open(url)
|
|
175
193
|
try:
|
|
176
194
|
server.serve_forever()
|
|
177
195
|
finally:
|
|
196
|
+
cancelled.set()
|
|
197
|
+
if worker:
|
|
198
|
+
worker.join()
|
|
178
199
|
server.server_close()
|
|
200
|
+
if receipt["state"] != "completed":
|
|
201
|
+
receipt["state"] = "failed" if status["state"] == "failed" else "cancelled"
|
|
202
|
+
save_session(receipt_file, receipt)
|
|
179
203
|
return bool(state["resolved"])
|