@extend-ai/react-xlsx 0.10.2 → 0.10.3
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/README.md +63 -0
- package/dist/duke_sheets_wasm_bg.wasm +0 -0
- package/dist/index.cjs +58 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +56 -7
- package/dist/index.js.map +1 -1
- package/dist/xlsx-worker.js +43 -4
- package/dist/xlsx-worker.js.map +1 -1
- package/package.json +5 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import * as _dukelib_sheets_wasm from '@dukelib/sheets-wasm';
|
|
2
3
|
import { Workbook, Worksheet } from '@dukelib/sheets-wasm';
|
|
3
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
5
|
|
|
@@ -1064,6 +1065,10 @@ declare class XlsxFileSizeLimitExceededError extends Error {
|
|
|
1064
1065
|
}
|
|
1065
1066
|
declare function useXlsxViewerController(options: UseXlsxViewerControllerOptions): XlsxViewerController;
|
|
1066
1067
|
|
|
1068
|
+
type XlsxWasmSource = string | URL | Request | Response | BufferSource | WebAssembly.Module;
|
|
1069
|
+
declare function setWasmSource(source: XlsxWasmSource): void;
|
|
1070
|
+
declare function initWasm(source?: XlsxWasmSource): Promise<typeof _dukelib_sheets_wasm>;
|
|
1071
|
+
|
|
1067
1072
|
declare function XlsxViewerProvider({ children, controller, isDark, ...options }: XlsxViewerProviderProps): react_jsx_runtime.JSX.Element;
|
|
1068
1073
|
declare function useXlsxViewer(): XlsxViewerController;
|
|
1069
1074
|
declare function useXlsxViewerSelection(): XlsxViewerSelection;
|
|
@@ -1076,4 +1081,4 @@ declare function useXlsxViewerThumbnails(options?: UseXlsxViewerThumbnailsOption
|
|
|
1076
1081
|
declare function XlsxViewer(props: XlsxViewerProps): react_jsx_runtime.JSX.Element;
|
|
1077
1082
|
declare function DefaultXlsxToolbar(): react_jsx_runtime.JSX.Element;
|
|
1078
1083
|
|
|
1079
|
-
export { DefaultXlsxToolbar, type UseXlsxViewerControllerOptions, type UseXlsxViewerThumbnailsOptions, type XlsxCellAddress, type XlsxCellRange, type XlsxChart, type XlsxChartAxis, type XlsxChartDataLabels, type XlsxChartLoadingRenderProps, type XlsxChartReference, type XlsxChartSeries, type XlsxChartsheet, XlsxFileSizeLimitExceededError, type XlsxFileTooLargeRenderProps, type XlsxImage, type XlsxImageAnchor, type XlsxImageRect, type XlsxImageRenderProps, type XlsxImageResizeHandlePosition, type XlsxImageSelectionRenderProps, type XlsxScrollerRenderProps, type XlsxShape, type XlsxShapeFill, type XlsxShapeParagraph, type XlsxShapeStroke, type XlsxShapeTextBox, type XlsxShapeTextRun, type XlsxSheetData, type XlsxSheetThumbnail, type XlsxSheetThumbnailResolution, type XlsxSheetVisibility, type XlsxTable, type XlsxTableColumn, type XlsxTableHeaderMenuRenderProps, type XlsxTableSortDirection, type XlsxTableSortState, type XlsxThemePalette, XlsxViewer, type XlsxViewerCharts, type XlsxViewerController, type XlsxViewerEditing, type XlsxViewerImages, type XlsxViewerProps, XlsxViewerProvider, type XlsxViewerProviderProps, type XlsxViewerSelection, type XlsxViewerTables, type XlsxViewerThumbnails, type XlsxViewerZoom, type XlsxWorkbookTab, useXlsxViewer, useXlsxViewerCharts, useXlsxViewerController, useXlsxViewerEditing, useXlsxViewerImages, useXlsxViewerSelection, useXlsxViewerTables, useXlsxViewerThumbnails, useXlsxViewerZoom };
|
|
1084
|
+
export { DefaultXlsxToolbar, type UseXlsxViewerControllerOptions, type UseXlsxViewerThumbnailsOptions, type XlsxCellAddress, type XlsxCellRange, type XlsxChart, type XlsxChartAxis, type XlsxChartDataLabels, type XlsxChartLoadingRenderProps, type XlsxChartReference, type XlsxChartSeries, type XlsxChartsheet, XlsxFileSizeLimitExceededError, type XlsxFileTooLargeRenderProps, type XlsxImage, type XlsxImageAnchor, type XlsxImageRect, type XlsxImageRenderProps, type XlsxImageResizeHandlePosition, type XlsxImageSelectionRenderProps, type XlsxScrollerRenderProps, type XlsxShape, type XlsxShapeFill, type XlsxShapeParagraph, type XlsxShapeStroke, type XlsxShapeTextBox, type XlsxShapeTextRun, type XlsxSheetData, type XlsxSheetThumbnail, type XlsxSheetThumbnailResolution, type XlsxSheetVisibility, type XlsxTable, type XlsxTableColumn, type XlsxTableHeaderMenuRenderProps, type XlsxTableSortDirection, type XlsxTableSortState, type XlsxThemePalette, XlsxViewer, type XlsxViewerCharts, type XlsxViewerController, type XlsxViewerEditing, type XlsxViewerImages, type XlsxViewerProps, XlsxViewerProvider, type XlsxViewerProviderProps, type XlsxViewerSelection, type XlsxViewerTables, type XlsxViewerThumbnails, type XlsxViewerZoom, type XlsxWasmSource, type XlsxWorkbookTab, initWasm, setWasmSource, useXlsxViewer, useXlsxViewerCharts, useXlsxViewerController, useXlsxViewerEditing, useXlsxViewerImages, useXlsxViewerSelection, useXlsxViewerTables, useXlsxViewerThumbnails, useXlsxViewerZoom };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import * as _dukelib_sheets_wasm from '@dukelib/sheets-wasm';
|
|
2
3
|
import { Workbook, Worksheet } from '@dukelib/sheets-wasm';
|
|
3
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
5
|
|
|
@@ -1064,6 +1065,10 @@ declare class XlsxFileSizeLimitExceededError extends Error {
|
|
|
1064
1065
|
}
|
|
1065
1066
|
declare function useXlsxViewerController(options: UseXlsxViewerControllerOptions): XlsxViewerController;
|
|
1066
1067
|
|
|
1068
|
+
type XlsxWasmSource = string | URL | Request | Response | BufferSource | WebAssembly.Module;
|
|
1069
|
+
declare function setWasmSource(source: XlsxWasmSource): void;
|
|
1070
|
+
declare function initWasm(source?: XlsxWasmSource): Promise<typeof _dukelib_sheets_wasm>;
|
|
1071
|
+
|
|
1067
1072
|
declare function XlsxViewerProvider({ children, controller, isDark, ...options }: XlsxViewerProviderProps): react_jsx_runtime.JSX.Element;
|
|
1068
1073
|
declare function useXlsxViewer(): XlsxViewerController;
|
|
1069
1074
|
declare function useXlsxViewerSelection(): XlsxViewerSelection;
|
|
@@ -1076,4 +1081,4 @@ declare function useXlsxViewerThumbnails(options?: UseXlsxViewerThumbnailsOption
|
|
|
1076
1081
|
declare function XlsxViewer(props: XlsxViewerProps): react_jsx_runtime.JSX.Element;
|
|
1077
1082
|
declare function DefaultXlsxToolbar(): react_jsx_runtime.JSX.Element;
|
|
1078
1083
|
|
|
1079
|
-
export { DefaultXlsxToolbar, type UseXlsxViewerControllerOptions, type UseXlsxViewerThumbnailsOptions, type XlsxCellAddress, type XlsxCellRange, type XlsxChart, type XlsxChartAxis, type XlsxChartDataLabels, type XlsxChartLoadingRenderProps, type XlsxChartReference, type XlsxChartSeries, type XlsxChartsheet, XlsxFileSizeLimitExceededError, type XlsxFileTooLargeRenderProps, type XlsxImage, type XlsxImageAnchor, type XlsxImageRect, type XlsxImageRenderProps, type XlsxImageResizeHandlePosition, type XlsxImageSelectionRenderProps, type XlsxScrollerRenderProps, type XlsxShape, type XlsxShapeFill, type XlsxShapeParagraph, type XlsxShapeStroke, type XlsxShapeTextBox, type XlsxShapeTextRun, type XlsxSheetData, type XlsxSheetThumbnail, type XlsxSheetThumbnailResolution, type XlsxSheetVisibility, type XlsxTable, type XlsxTableColumn, type XlsxTableHeaderMenuRenderProps, type XlsxTableSortDirection, type XlsxTableSortState, type XlsxThemePalette, XlsxViewer, type XlsxViewerCharts, type XlsxViewerController, type XlsxViewerEditing, type XlsxViewerImages, type XlsxViewerProps, XlsxViewerProvider, type XlsxViewerProviderProps, type XlsxViewerSelection, type XlsxViewerTables, type XlsxViewerThumbnails, type XlsxViewerZoom, type XlsxWorkbookTab, useXlsxViewer, useXlsxViewerCharts, useXlsxViewerController, useXlsxViewerEditing, useXlsxViewerImages, useXlsxViewerSelection, useXlsxViewerTables, useXlsxViewerThumbnails, useXlsxViewerZoom };
|
|
1084
|
+
export { DefaultXlsxToolbar, type UseXlsxViewerControllerOptions, type UseXlsxViewerThumbnailsOptions, type XlsxCellAddress, type XlsxCellRange, type XlsxChart, type XlsxChartAxis, type XlsxChartDataLabels, type XlsxChartLoadingRenderProps, type XlsxChartReference, type XlsxChartSeries, type XlsxChartsheet, XlsxFileSizeLimitExceededError, type XlsxFileTooLargeRenderProps, type XlsxImage, type XlsxImageAnchor, type XlsxImageRect, type XlsxImageRenderProps, type XlsxImageResizeHandlePosition, type XlsxImageSelectionRenderProps, type XlsxScrollerRenderProps, type XlsxShape, type XlsxShapeFill, type XlsxShapeParagraph, type XlsxShapeStroke, type XlsxShapeTextBox, type XlsxShapeTextRun, type XlsxSheetData, type XlsxSheetThumbnail, type XlsxSheetThumbnailResolution, type XlsxSheetVisibility, type XlsxTable, type XlsxTableColumn, type XlsxTableHeaderMenuRenderProps, type XlsxTableSortDirection, type XlsxTableSortState, type XlsxThemePalette, XlsxViewer, type XlsxViewerCharts, type XlsxViewerController, type XlsxViewerEditing, type XlsxViewerImages, type XlsxViewerProps, XlsxViewerProvider, type XlsxViewerProviderProps, type XlsxViewerSelection, type XlsxViewerTables, type XlsxViewerThumbnails, type XlsxViewerZoom, type XlsxWasmSource, type XlsxWorkbookTab, initWasm, setWasmSource, useXlsxViewer, useXlsxViewerCharts, useXlsxViewerController, useXlsxViewerEditing, useXlsxViewerImages, useXlsxViewerSelection, useXlsxViewerTables, useXlsxViewerThumbnails, useXlsxViewerZoom };
|
package/dist/index.js
CHANGED
|
@@ -6373,13 +6373,58 @@ function tryRecalculate(workbook) {
|
|
|
6373
6373
|
|
|
6374
6374
|
// src/wasm.ts
|
|
6375
6375
|
var wasmModulePromise = null;
|
|
6376
|
+
var hasConfiguredWasmSource = false;
|
|
6377
|
+
var configuredWasmSource;
|
|
6378
|
+
var configuredWorkerWasmSource;
|
|
6379
|
+
function bufferSourceToArrayBuffer(source) {
|
|
6380
|
+
if (source instanceof ArrayBuffer) {
|
|
6381
|
+
return source.slice(0);
|
|
6382
|
+
}
|
|
6383
|
+
const bytes = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
6384
|
+
const copy = new Uint8Array(bytes);
|
|
6385
|
+
return copy.buffer;
|
|
6386
|
+
}
|
|
6387
|
+
function sourceToWorkerSource(source) {
|
|
6388
|
+
if (typeof source === "string") {
|
|
6389
|
+
return source;
|
|
6390
|
+
}
|
|
6391
|
+
if (typeof URL !== "undefined" && source instanceof URL) {
|
|
6392
|
+
return source.href;
|
|
6393
|
+
}
|
|
6394
|
+
if (typeof Request !== "undefined" && source instanceof Request) {
|
|
6395
|
+
return source.url;
|
|
6396
|
+
}
|
|
6397
|
+
if (source instanceof ArrayBuffer || ArrayBuffer.isView(source)) {
|
|
6398
|
+
return bufferSourceToArrayBuffer(source);
|
|
6399
|
+
}
|
|
6400
|
+
if (typeof WebAssembly !== "undefined" && source instanceof WebAssembly.Module) {
|
|
6401
|
+
return source;
|
|
6402
|
+
}
|
|
6403
|
+
return void 0;
|
|
6404
|
+
}
|
|
6405
|
+
function setWasmSource(source) {
|
|
6406
|
+
hasConfiguredWasmSource = true;
|
|
6407
|
+
configuredWasmSource = source;
|
|
6408
|
+
configuredWorkerWasmSource = sourceToWorkerSource(source);
|
|
6409
|
+
}
|
|
6410
|
+
function initWasm(source) {
|
|
6411
|
+
if (source !== void 0) {
|
|
6412
|
+
setWasmSource(source);
|
|
6413
|
+
}
|
|
6414
|
+
return getSheetsWasmModule();
|
|
6415
|
+
}
|
|
6416
|
+
function canUseConfiguredWasmSourceInWorker() {
|
|
6417
|
+
return !hasConfiguredWasmSource || configuredWorkerWasmSource !== void 0;
|
|
6418
|
+
}
|
|
6419
|
+
function getConfiguredWorkerWasmSource() {
|
|
6420
|
+
return configuredWorkerWasmSource;
|
|
6421
|
+
}
|
|
6376
6422
|
function getSheetsWasmModule() {
|
|
6377
6423
|
if (!wasmModulePromise) {
|
|
6378
6424
|
wasmModulePromise = import("@dukelib/sheets-wasm").then(async (mod) => {
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
} catch {
|
|
6425
|
+
if (configuredWasmSource !== void 0) {
|
|
6426
|
+
await mod.default(configuredWasmSource);
|
|
6427
|
+
} else {
|
|
6383
6428
|
await mod.default();
|
|
6384
6429
|
}
|
|
6385
6430
|
return mod;
|
|
@@ -6428,7 +6473,8 @@ var XlsxWorkerClient = class {
|
|
|
6428
6473
|
payload: {
|
|
6429
6474
|
buffer: workerBuffer,
|
|
6430
6475
|
showHiddenSheets,
|
|
6431
|
-
skipXmlParsing
|
|
6476
|
+
skipXmlParsing,
|
|
6477
|
+
wasmSource: getConfiguredWorkerWasmSource()
|
|
6432
6478
|
},
|
|
6433
6479
|
type: "load"
|
|
6434
6480
|
}, [workerBuffer]);
|
|
@@ -6447,7 +6493,8 @@ var XlsxWorkerClient = class {
|
|
|
6447
6493
|
payload: {
|
|
6448
6494
|
buffer: workerBuffer,
|
|
6449
6495
|
showHiddenSheets,
|
|
6450
|
-
skipXmlParsing
|
|
6496
|
+
skipXmlParsing,
|
|
6497
|
+
wasmSource: getConfiguredWorkerWasmSource()
|
|
6451
6498
|
},
|
|
6452
6499
|
type: "parseCharts"
|
|
6453
6500
|
}, [workerBuffer]);
|
|
@@ -7794,7 +7841,7 @@ function useXlsxViewerController(options) {
|
|
|
7794
7841
|
const shouldDeferLoading = deferLoadingAboveBytes > 0;
|
|
7795
7842
|
const readOnly = requestedReadOnly || forcedReadOnly;
|
|
7796
7843
|
const canResizeReadOnly = requestedReadOnly && allowResizeInReadOnly && !forcedReadOnly;
|
|
7797
|
-
const workerSupported = useWorker && typeof Worker !== "undefined";
|
|
7844
|
+
const workerSupported = useWorker && typeof Worker !== "undefined" && canUseConfiguredWasmSourceInWorker();
|
|
7798
7845
|
const shouldUseWorker = workerSupported && forcedReadOnly;
|
|
7799
7846
|
const shouldForceReadOnlyForBuffer = React.useCallback((bufferByteLength) => !requestedReadOnly && readOnlyAboveBytes > 0 && bufferByteLength > readOnlyAboveBytes, [readOnlyAboveBytes, requestedReadOnly]);
|
|
7800
7847
|
const disposeWorkerClient = React.useCallback(() => {
|
|
@@ -29740,6 +29787,8 @@ export {
|
|
|
29740
29787
|
XlsxFileSizeLimitExceededError,
|
|
29741
29788
|
XlsxViewer,
|
|
29742
29789
|
XlsxViewerProvider,
|
|
29790
|
+
initWasm,
|
|
29791
|
+
setWasmSource,
|
|
29743
29792
|
useXlsxViewer,
|
|
29744
29793
|
useXlsxViewerCharts,
|
|
29745
29794
|
useXlsxViewerController,
|