@chenchaolong/plugin-trade-compliance-workbench 1.0.133 → 1.0.134
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/dist/lib/remote-components/trade-compliance-workbench/app.js +7 -7
- package/dist/lib/remote-components/trade-compliance-workbench/editor-source.mjs +14 -3
- package/dist/lib/remote-components/trade-compliance-workbench/editor.js +19 -19
- package/dist/lib/remote-components/trade-compliance-workbench/preview-source.mjs +42 -13
- package/dist/lib/remote-components/trade-compliance-workbench/preview.js +168 -168
- package/dist/lib/remote-ui/app-source.d.ts.map +1 -1
- package/dist/lib/remote-ui/app-source.js +23 -34
- package/dist/lib/remote-ui/app-source.js.map +1 -1
- package/dist/lib/remote-ui/components/source-file-preview.d.ts +18 -3
- package/dist/lib/remote-ui/components/source-file-preview.d.ts.map +1 -1
- package/dist/lib/remote-ui/components/source-file-preview.js +34 -17
- package/dist/lib/remote-ui/components/source-file-preview.js.map +1 -1
- package/dist/lib/remote-ui/customer-contract-contracts.d.ts +8 -0
- package/dist/lib/remote-ui/customer-contract-contracts.d.ts.map +1 -1
- package/dist/lib/remote-ui/isolated-runtime.d.ts +36 -0
- package/dist/lib/remote-ui/isolated-runtime.d.ts.map +1 -0
- package/dist/lib/remote-ui/isolated-runtime.js +158 -0
- package/dist/lib/remote-ui/isolated-runtime.js.map +1 -0
- package/dist/lib/remote-ui/model.d.ts +1 -0
- package/dist/lib/remote-ui/model.d.ts.map +1 -1
- package/dist/lib/remote-ui/model.js +17 -0
- package/dist/lib/remote-ui/model.js.map +1 -1
- package/dist/lib/remote-ui/procurement-contracts.d.ts +8 -0
- package/dist/lib/remote-ui/procurement-contracts.d.ts.map +1 -1
- package/dist/lib/workbench-view.provider.d.ts +27 -7
- package/dist/lib/workbench-view.provider.d.ts.map +1 -1
- package/dist/lib/workbench-view.provider.js +20 -1
- package/dist/lib/workbench-view.provider.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-source.d.ts","sourceRoot":"","sources":["../../../src/lib/remote-ui/app-source.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app-source.d.ts","sourceRoot":"","sources":["../../../src/lib/remote-ui/app-source.tsx"],"names":[],"mappings":"AAiCA,OAAO,cAAc,CAAA"}
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { createRoot } from 'react-dom/client';
|
|
4
4
|
import { createRemoteBridge } from './bridge.js';
|
|
5
|
+
import { createExcelEditorRuntime, createPreviewRuntime } from './isolated-runtime.js';
|
|
5
6
|
import { resolvePaginationPageSize } from './contracts.js';
|
|
6
7
|
import { clampPageAfterSingleDeletion, createBlobUrlOwner, createKeyedLatestRequestGate, createLatestCommittedRequest, createLatestRequestGate, generatedFileHistoryKey, isCurrentSettingsRouteRevision, normalizeWorkbenchData, routeDataRequest, runKeyedLatestRequest, unwrapResponse } from './model.js';
|
|
7
8
|
import { encodeViewFilters } from '../view-parameters.js';
|
|
@@ -47,9 +48,6 @@ const procurementPageMeta = {
|
|
|
47
48
|
const bridge = createRemoteBridge();
|
|
48
49
|
let sourcePreviewRuntimePromise = null;
|
|
49
50
|
async function ensureSourcePreviewRuntime() {
|
|
50
|
-
const runtimeWindow = window;
|
|
51
|
-
if (runtimeWindow.TradeComplianceSourcePreview)
|
|
52
|
-
return runtimeWindow.TradeComplianceSourcePreview;
|
|
53
51
|
if (sourcePreviewRuntimePromise)
|
|
54
52
|
return sourcePreviewRuntimePromise;
|
|
55
53
|
sourcePreviewRuntimePromise = (async () => {
|
|
@@ -59,14 +57,7 @@ async function ensureSourcePreviewRuntime() {
|
|
|
59
57
|
const script = asRecord(result.data).script;
|
|
60
58
|
if (typeof script !== 'string' || !script.trim())
|
|
61
59
|
throw new Error('文件预览运行时响应不完整');
|
|
62
|
-
|
|
63
|
-
element.dataset.tradeCompliancePreviewRuntime = 'true';
|
|
64
|
-
element.textContent = script;
|
|
65
|
-
document.body.appendChild(element);
|
|
66
|
-
const runtime = runtimeWindow.TradeComplianceSourcePreview;
|
|
67
|
-
if (!runtime)
|
|
68
|
-
throw new Error('文件预览运行时初始化失败');
|
|
69
|
-
return runtime;
|
|
60
|
+
return createPreviewRuntime(script);
|
|
70
61
|
})().catch(error => { sourcePreviewRuntimePromise = null; throw error; });
|
|
71
62
|
return sourcePreviewRuntimePromise;
|
|
72
63
|
}
|
|
@@ -489,6 +480,12 @@ function App() {
|
|
|
489
480
|
salesFilesPrototypeListenerCleanupRef.current?.();
|
|
490
481
|
salesFilesPrototypeListenerCleanupRef.current = null;
|
|
491
482
|
blobUrlOwnerRef.current.dispose();
|
|
483
|
+
const previewRuntime = sourcePreviewRuntimePromise;
|
|
484
|
+
sourcePreviewRuntimePromise = null;
|
|
485
|
+
void previewRuntime?.then(runtime => runtime.dispose?.(), () => undefined);
|
|
486
|
+
const editorRuntime = excelEditorRuntimePromise;
|
|
487
|
+
excelEditorRuntimePromise = null;
|
|
488
|
+
void editorRuntime?.then(runtime => runtime.dispose?.(), () => undefined);
|
|
492
489
|
bridge.destroy();
|
|
493
490
|
};
|
|
494
491
|
}, [configureSalesFilesPrototypeCapability, load]);
|
|
@@ -1742,6 +1739,8 @@ async function attachPurchaseSource(draft, task, owner) {
|
|
|
1742
1739
|
if (draft.sourcePreview || !task.sourceFileId)
|
|
1743
1740
|
return draft;
|
|
1744
1741
|
const preview = await loadSourcePreview(task.sourceFileId, 'purchase', owner);
|
|
1742
|
+
if (preview.previewKind === 'PDF_PAGES')
|
|
1743
|
+
return { ...draft, sourcePreview: { kind: 'PDF_PAGES', pages: preview.pages, pageCount: preview.pageCount, fileName: preview.fileName } };
|
|
1745
1744
|
if (preview.previewKind === 'BINARY')
|
|
1746
1745
|
return { ...draft, sourcePreview: { kind: 'BINARY', url: preview.url, fileName: preview.fileName, mimeType: preview.mimeType }, sourceFileUrl: preview.url };
|
|
1747
1746
|
if (preview.previewKind === 'URL')
|
|
@@ -1754,6 +1753,8 @@ async function attachCustomerSource(review, owner) {
|
|
|
1754
1753
|
if (review.sourcePreview.kind === 'URL' || !review.sourceFileId)
|
|
1755
1754
|
return review;
|
|
1756
1755
|
const preview = await loadSourcePreview(review.sourceFileId, 'customer', owner);
|
|
1756
|
+
if (preview.previewKind === 'PDF_PAGES')
|
|
1757
|
+
return { ...review, sourcePreview: { kind: 'PDF_PAGES', pages: preview.pages, pageCount: preview.pageCount, fileName: preview.fileName } };
|
|
1757
1758
|
if (preview.previewKind === 'URL')
|
|
1758
1759
|
return { ...review, sourcePreview: { kind: 'URL', url: preview.url } };
|
|
1759
1760
|
if (preview.previewKind === 'BINARY')
|
|
@@ -1772,6 +1773,16 @@ async function loadSourcePreview(sourceFileId, slot, owner) {
|
|
|
1772
1773
|
if (file.previewKind === 'BINARY' && typeof file.base64 === 'string' && typeof file.mimeType === 'string') {
|
|
1773
1774
|
return { previewKind: 'BINARY', url: owner.replace(slot, blobUrlFromBase64(file.base64, file.mimeType)), fileName: typeof file.fileName === 'string' ? file.fileName : '源文件', mimeType: file.mimeType };
|
|
1774
1775
|
}
|
|
1776
|
+
if (file.previewKind === 'PDF_PAGES' && Array.isArray(file.pages) && typeof file.pageCount === 'number' && typeof file.fileName === 'string') {
|
|
1777
|
+
const pages = file.pages.flatMap(page => {
|
|
1778
|
+
const item = asRecord(page);
|
|
1779
|
+
if (!Number.isInteger(item.pageNumber) || typeof item.base64 !== 'string' || typeof item.mimeType !== 'string')
|
|
1780
|
+
return [];
|
|
1781
|
+
return [{ pageNumber: Number(item.pageNumber), url: blobUrlFromBase64(item.base64, item.mimeType) }];
|
|
1782
|
+
});
|
|
1783
|
+
if (pages.length)
|
|
1784
|
+
return { previewKind: 'PDF_PAGES', pages: owner.replaceMany(slot, pages.map(page => page.url)).map((url, index) => ({ pageNumber: pages[index].pageNumber, url })), pageCount: file.pageCount, fileName: file.fileName };
|
|
1785
|
+
}
|
|
1775
1786
|
if (file.previewKind === 'UNAVAILABLE')
|
|
1776
1787
|
return { previewKind: 'UNAVAILABLE', message: typeof file.message === 'string' ? file.message : '源文件暂无法在线预览' };
|
|
1777
1788
|
throw new Error('源文件预览响应类型无效');
|
|
@@ -1799,9 +1810,6 @@ function asCustomerContractReanalysisResult(value) {
|
|
|
1799
1810
|
return payload;
|
|
1800
1811
|
}
|
|
1801
1812
|
async function ensureExcelEditorRuntime() {
|
|
1802
|
-
const runtimeWindow = window;
|
|
1803
|
-
if (runtimeWindow.TradeComplianceExcelEditor?.open)
|
|
1804
|
-
return runtimeWindow.TradeComplianceExcelEditor;
|
|
1805
1813
|
if (excelEditorRuntimePromise)
|
|
1806
1814
|
return excelEditorRuntimePromise;
|
|
1807
1815
|
excelEditorRuntimePromise = (async () => {
|
|
@@ -1812,27 +1820,8 @@ async function ensureExcelEditorRuntime() {
|
|
|
1812
1820
|
const css = result.data?.css;
|
|
1813
1821
|
if (typeof script !== 'string' || !script.trim() || typeof css !== 'string')
|
|
1814
1822
|
throw new Error('Excel 编辑器运行时响应不完整');
|
|
1815
|
-
|
|
1816
|
-
if (!styleElement) {
|
|
1817
|
-
styleElement = document.createElement('style');
|
|
1818
|
-
styleElement.dataset.tradeComplianceEditorStyles = 'true';
|
|
1819
|
-
styleElement.textContent = css;
|
|
1820
|
-
document.head.appendChild(styleElement);
|
|
1821
|
-
}
|
|
1822
|
-
let scriptElement = document.body.querySelector('script[data-trade-compliance-editor-runtime]');
|
|
1823
|
-
if (!scriptElement) {
|
|
1824
|
-
scriptElement = document.createElement('script');
|
|
1825
|
-
scriptElement.dataset.tradeComplianceEditorRuntime = 'true';
|
|
1826
|
-
scriptElement.textContent = script;
|
|
1827
|
-
document.body.appendChild(scriptElement);
|
|
1828
|
-
}
|
|
1829
|
-
const runtime = runtimeWindow.TradeComplianceExcelEditor;
|
|
1830
|
-
if (!runtime?.open)
|
|
1831
|
-
throw new Error('Excel 编辑器运行时初始化失败');
|
|
1832
|
-
return runtime;
|
|
1823
|
+
return createExcelEditorRuntime(script, css);
|
|
1833
1824
|
})().catch((error) => {
|
|
1834
|
-
document.querySelector('script[data-trade-compliance-editor-runtime]')?.remove();
|
|
1835
|
-
document.querySelector('style[data-trade-compliance-editor-styles]')?.remove();
|
|
1836
1825
|
excelEditorRuntimePromise = null;
|
|
1837
1826
|
throw error;
|
|
1838
1827
|
});
|