@vmscloud/moz-ui-grid-vue 0.1.41
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 +71 -0
- package/dist/MozGrid.vue.d.ts +127 -0
- package/dist/bridge/VueRenderer.d.ts +37 -0
- package/dist/bridge/fieldBuilder.d.ts +9 -0
- package/dist/bridge/lifecycle.d.ts +6 -0
- package/dist/bridge/templateRegistry.d.ts +8 -0
- package/dist/chunks/index-BDQ0HlwR.js +3404 -0
- package/dist/chunks/index-D5KJLBGW.cjs +14 -0
- package/dist/chunks/notification.contract-BTOch6ed.js +16 -0
- package/dist/chunks/notification.contract-oFkBaE2U.cjs +1 -0
- package/dist/compat/MozGridVue.vue.d.ts +645 -0
- package/dist/compat/MozPivotVue.vue.d.ts +606 -0
- package/dist/compat/index.d.ts +9 -0
- package/dist/compat/legacyGridAliases.d.ts +8 -0
- package/dist/composables/useGridPreset.d.ts +19 -0
- package/dist/contracts/UserLayoutInstance.d.ts +38 -0
- package/dist/contracts/notification.contract.d.ts +41 -0
- package/dist/contracts/userLayout.contract.d.ts +16 -0
- package/dist/index.cjs +26 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +90599 -0
- package/dist/legacy/components/common/Dragging.d.ts +17 -0
- package/dist/legacy/components/common/Dragging.vue.d.ts +49 -0
- package/dist/legacy/components/common/custom-cell/FormulaEngine.d.ts +256 -0
- package/dist/legacy/components/common/custom-cell/FormulaInput.vue.d.ts +33 -0
- package/dist/legacy/components/common/custom-cell/GridCustomCell.vue.d.ts +23 -0
- package/dist/legacy/components/common/custom-cell/useFormulaAutocomplete.d.ts +44 -0
- package/dist/legacy/components/common/excel/ClientExcelUploadPopup.vue.d.ts +201 -0
- package/dist/legacy/components/common/excel/assets/IconDropZone.vue.d.ts +2 -0
- package/dist/legacy/components/common/excel/assets/IconFileUpload.vue.d.ts +2 -0
- package/dist/legacy/components/common/filter/GridFilter.vue.d.ts +23 -0
- package/dist/legacy/components/common/footer/GridFooter.vue.d.ts +29 -0
- package/dist/legacy/components/common/sort/GridSort.vue.d.ts +23 -0
- package/dist/legacy/components/common/toolbar/GridSearchInput.vue.d.ts +33 -0
- package/dist/legacy/components/grid/MozGridVue.vue.d.ts +2041 -0
- package/dist/legacy/components/grid/MozGridVueCore.vue.d.ts +118 -0
- package/dist/legacy/components/grid/bulk-editor/GridBulkEditor.vue.d.ts +10 -0
- package/dist/legacy/components/grid/column-settings/AlignPicker.vue.d.ts +10 -0
- package/dist/legacy/components/grid/column-settings/ColorSwatchPicker.vue.d.ts +11 -0
- package/dist/legacy/components/grid/column-settings/ColumnListItem.vue.d.ts +17 -0
- package/dist/legacy/components/grid/column-settings/ColumnOptionsPanel.vue.d.ts +32 -0
- package/dist/legacy/components/grid/column-settings/FontSizePicker.vue.d.ts +10 -0
- package/dist/legacy/components/grid/column-settings/FontStyleToggles.vue.d.ts +15 -0
- package/dist/legacy/components/grid/column-settings/MaskPresetPicker.vue.d.ts +14 -0
- package/dist/legacy/components/grid/context-menu/GridContextMenu.vue.d.ts +208 -0
- package/dist/legacy/components/grid/group-panel/GroupPanel.vue.d.ts +18 -0
- package/dist/legacy/components/grid/toolbar/ColumnPicker.vue.d.ts +17 -0
- package/dist/legacy/components/grid/toolbar/ColumnSettings.vue.d.ts +30 -0
- package/dist/legacy/components/grid/toolbar/GridOptionModal.vue.d.ts +211 -0
- package/dist/legacy/components/grid/toolbar/GridToolBox.vue.d.ts +69 -0
- package/dist/legacy/components/pivot/MozPivotVue.vue.d.ts +1868 -0
- package/dist/legacy/components/pivot/PivotContextMenu.vue.d.ts +634 -0
- package/dist/legacy/components/pivot/PivotFieldChip.vue.d.ts +16 -0
- package/dist/legacy/components/pivot/PivotFieldDropZone.vue.d.ts +26 -0
- package/dist/legacy/components/pivot/PivotFieldPanel.vue.d.ts +28 -0
- package/dist/legacy/components/pivot/PivotOptionModal.vue.d.ts +534 -0
- package/dist/legacy/components/pivot/PivotToolBox.vue.d.ts +79 -0
- package/dist/legacy/components/pivot/chart/EChart.vue.d.ts +13 -0
- package/dist/legacy/components/pivot/chart/MozPivotChart.types.d.ts +16 -0
- package/dist/legacy/components/pivot/chart/MozPivotChart.vue.d.ts +14 -0
- package/dist/legacy/components/pivot/chart/PivotChartDetail.vue.d.ts +13 -0
- package/dist/legacy/components/pivot/chart/PivotChartMini.vue.d.ts +18 -0
- package/dist/legacy/components/pivot/chart/PivotChartMultiple.vue.d.ts +18 -0
- package/dist/legacy/components/pivot/chart/PivotChartToolbar.vue.d.ts +38 -0
- package/dist/legacy/components/pivot/chart/chartUtils.d.ts +45 -0
- package/dist/legacy/components/pivot/chart/useChartData.d.ts +35 -0
- package/dist/legacy/composables/useCellTooltip.d.ts +8 -0
- package/dist/legacy/composables/useClientExcelExport.d.ts +24 -0
- package/dist/legacy/composables/useClientExcelStore.d.ts +16 -0
- package/dist/legacy/composables/useColumnFormatter.d.ts +45 -0
- package/dist/legacy/composables/useColumnSettings.d.ts +35 -0
- package/dist/legacy/composables/useContextMenu.d.ts +71 -0
- package/dist/legacy/composables/useGridBulkEditor.d.ts +36 -0
- package/dist/legacy/composables/useGridChanges.d.ts +28 -0
- package/dist/legacy/composables/useGridColumns.d.ts +37 -0
- package/dist/legacy/composables/useGridCustomCell.d.ts +34 -0
- package/dist/legacy/composables/useGridEvents.d.ts +14 -0
- package/dist/legacy/composables/useGridFilter.d.ts +38 -0
- package/dist/legacy/composables/useGridInstance.d.ts +16 -0
- package/dist/legacy/composables/useGridSelect.d.ts +18 -0
- package/dist/legacy/composables/useGridSelection.d.ts +18 -0
- package/dist/legacy/composables/useGridSort.d.ts +38 -0
- package/dist/legacy/composables/useGridUndoRedo.d.ts +28 -0
- package/dist/legacy/composables/useGridValidation.d.ts +28 -0
- package/dist/legacy/composables/useMaskPresets.d.ts +38 -0
- package/dist/legacy/composables/useSearchHighlight.d.ts +12 -0
- package/dist/legacy/icons/IconAdd.vue.d.ts +11 -0
- package/dist/legacy/icons/IconArrowDownWithTail.vue.d.ts +11 -0
- package/dist/legacy/icons/IconArrowLeft.vue.d.ts +11 -0
- package/dist/legacy/icons/IconArrowLeftWithTail.vue.d.ts +11 -0
- package/dist/legacy/icons/IconArrowRight.vue.d.ts +11 -0
- package/dist/legacy/icons/IconArrowUpCenter.vue.d.ts +11 -0
- package/dist/legacy/icons/IconArrowUpWithTail.vue.d.ts +11 -0
- package/dist/legacy/icons/IconChart.vue.d.ts +11 -0
- package/dist/legacy/icons/IconClose.vue.d.ts +13 -0
- package/dist/legacy/icons/IconColorPicker.vue.d.ts +11 -0
- package/dist/legacy/icons/IconCustomCell.vue.d.ts +11 -0
- package/dist/legacy/icons/IconDecide.vue.d.ts +11 -0
- package/dist/legacy/icons/IconDownload.vue.d.ts +11 -0
- package/dist/legacy/icons/IconDragHandler.vue.d.ts +11 -0
- package/dist/legacy/icons/IconFilter.vue.d.ts +11 -0
- package/dist/legacy/icons/IconInfoFilled.vue.d.ts +11 -0
- package/dist/legacy/icons/IconRedo.vue.d.ts +9 -0
- package/dist/legacy/icons/IconReset.vue.d.ts +9 -0
- package/dist/legacy/icons/IconResetGridToolbar.vue.d.ts +11 -0
- package/dist/legacy/icons/IconSearch.vue.d.ts +11 -0
- package/dist/legacy/icons/IconSetting.vue.d.ts +11 -0
- package/dist/legacy/icons/IconSettingFilled.vue.d.ts +11 -0
- package/dist/legacy/icons/IconSort.vue.d.ts +11 -0
- package/dist/legacy/icons/IconToastWarning.vue.d.ts +11 -0
- package/dist/legacy/icons/IconUndo.vue.d.ts +9 -0
- package/dist/legacy/icons/index.d.ts +25 -0
- package/dist/legacy/index.d.ts +69 -0
- package/dist/legacy/shared/colorPresets.d.ts +36 -0
- package/dist/legacy/store/UploadRefreshRegistry.d.ts +5 -0
- package/dist/legacy/store/excelStore.d.ts +89 -0
- package/dist/legacy/store/index.d.ts +231 -0
- package/dist/legacy/stores/index.d.ts +2 -0
- package/dist/legacy/stores/projectInfo/projectInfo.contract.d.ts +130 -0
- package/dist/legacy/stories/Autofit.stories.d.ts +9 -0
- package/dist/legacy/stories/CRUD.stories.d.ts +9 -0
- package/dist/legacy/stories/CellAttributes.stories.d.ts +19 -0
- package/dist/legacy/stories/CellMask.stories.d.ts +19 -0
- package/dist/legacy/stories/ClientExcel.stories.d.ts +8 -0
- package/dist/legacy/stories/Clipboard.stories.d.ts +12 -0
- package/dist/legacy/stories/ColumnVisibility.stories.d.ts +12 -0
- package/dist/legacy/stories/ColumnWidths.stories.d.ts +11 -0
- package/dist/legacy/stories/CustomSortFilter.stories.d.ts +7 -0
- package/dist/legacy/stories/DynamicRowHeight.stories.d.ts +13 -0
- package/dist/legacy/stories/Editors.stories.d.ts +9 -0
- package/dist/legacy/stories/EmptyState.stories.d.ts +10 -0
- package/dist/legacy/stories/FormatRow.stories.d.ts +20 -0
- package/dist/legacy/stories/Grouping.stories.d.ts +14 -0
- package/dist/legacy/stories/HeaderGroup.stories.d.ts +11 -0
- package/dist/legacy/stories/LargeData.stories.d.ts +19 -0
- package/dist/legacy/stories/MasterDetail.stories.d.ts +17 -0
- package/dist/legacy/stories/Merge.stories.d.ts +10 -0
- package/dist/legacy/stories/MultiRow.stories.d.ts +12 -0
- package/dist/legacy/stories/MultiRowCrud.stories.d.ts +11 -0
- package/dist/legacy/stories/MultiRowGroup.stories.d.ts +11 -0
- package/dist/legacy/stories/Pinning.stories.d.ts +44 -0
- package/dist/legacy/stories/Pivot.stories.d.ts +23 -0
- package/dist/legacy/stories/PivotAdvanced.stories.d.ts +20 -0
- package/dist/legacy/stories/PivotChart.stories.d.ts +23 -0
- package/dist/legacy/stories/PivotNonNumeric.stories.d.ts +27 -0
- package/dist/legacy/stories/Preset.stories.d.ts +11 -0
- package/dist/legacy/stories/ReactiveAPI.stories.d.ts +8 -0
- package/dist/legacy/stories/ReactiveSafety.stories.d.ts +28 -0
- package/dist/legacy/stories/Repro.stories.d.ts +36 -0
- package/dist/legacy/stories/RowAPI.stories.d.ts +12 -0
- package/dist/legacy/stories/SelectionModes.stories.d.ts +35 -0
- package/dist/legacy/stories/Streaming.stories.d.ts +12 -0
- package/dist/legacy/stories/Tree.stories.d.ts +13 -0
- package/dist/legacy/stories/WorkerMode.stories.d.ts +15 -0
- package/dist/legacy/stories/_helpers/localDataLoader.d.ts +7 -0
- package/dist/legacy/stories/_helpers/sampleData.d.ts +117 -0
- package/dist/legacy/types/FileParameter.d.ts +31 -0
- package/dist/legacy/types/StreamingParameter.d.ts +18 -0
- package/dist/legacy/types/excel.types.d.ts +48 -0
- package/dist/legacy/types/index.d.ts +10 -0
- package/dist/legacy/types/pivot-props.d.ts +140 -0
- package/dist/legacy/types/props.d.ts +176 -0
- package/dist/legacy/types/toolbar.d.ts +225 -0
- package/dist/legacy/utils/async/debounce.d.ts +4 -0
- package/dist/legacy/utils/crypto/crypto.d.ts +7 -0
- package/dist/legacy/utils/dialog/dialog.d.ts +19 -0
- package/dist/legacy/utils/excel/ExcelGuard.d.ts +73 -0
- package/dist/legacy/utils/excel/ExcelImportUtil.d.ts +34 -0
- package/dist/legacy/utils/excel/ExcelQueueManager.d.ts +57 -0
- package/dist/legacy/utils/excel/ExcelTaskRunner.d.ts +17 -0
- package/dist/legacy/utils/excel/ExcelTimeoutManager.d.ts +37 -0
- package/dist/legacy/utils/file.d.ts +34 -0
- package/dist/legacy/utils/http/rest.d.ts +5 -0
- package/dist/legacy/utils/id/generator.d.ts +2 -0
- package/dist/legacy/utils/index.d.ts +10 -0
- package/dist/store.cjs +1 -0
- package/dist/store.js +8 -0
- package/dist/stories/ColumnLockVisible.stories.d.ts +42 -0
- package/dist/stories/DateBooleanFilter.stories.d.ts +42 -0
- package/dist/stories/DisplayedRowApi.stories.d.ts +28 -0
- package/dist/stories/FieldId.stories.d.ts +113 -0
- package/dist/stories/GroupPanelWithoutToolbox.stories.d.ts +28 -0
- package/dist/stories/GroupRowRecycle.stories.d.ts +45 -0
- package/dist/stories/GroupTreeExpandNav.stories.d.ts +41 -0
- package/dist/stories/LargeData.stories.d.ts +20 -0
- package/dist/stories/MozGrid.stories.d.ts +51 -0
- package/dist/stories/PivotBarInitiallyOpen.stories.d.ts +69 -0
- package/dist/stories/PivotBarWithoutToolbox.stories.d.ts +39 -0
- package/dist/stories/SelectionApiPlayground.stories.d.ts +28 -0
- package/dist/stories/SingleSelectionModes.stories.d.ts +47 -0
- package/dist/stories/WideColumns.stories.d.ts +17 -0
- package/dist/style.css +1 -0
- package/dist/templates/CellEditor.d.ts +27 -0
- package/dist/templates/CellTemplate.d.ts +27 -0
- package/dist/templates/DetailTemplate.d.ts +60 -0
- package/dist/templates/GroupTemplate.d.ts +17 -0
- package/dist/templates/HeaderTemplate.d.ts +25 -0
- package/dist/types/injection-keys.d.ts +24 -0
- package/dist/types/slots.d.ts +49 -0
- package/dist/utils/excel/ExcelGuard.cjs +1 -0
- package/dist/utils/excel/ExcelGuard.js +74 -0
- package/dist/utils/excel/ExcelImportUtil.cjs +1 -0
- package/dist/utils/excel/ExcelImportUtil.js +61 -0
- package/dist/utils/excel/ExcelQueueManager.cjs +1 -0
- package/dist/utils/excel/ExcelQueueManager.js +10 -0
- package/dist/utils/excel/ExcelTaskRunner.cjs +1 -0
- package/dist/utils/excel/ExcelTaskRunner.js +12 -0
- package/dist/utils/excel/ExcelTimeoutManager.cjs +1 -0
- package/dist/utils/excel/ExcelTimeoutManager.js +420 -0
- package/docs/manual/examples.md +2385 -0
- package/docs/manual/reference.md +4695 -0
- package/docs/manual/reference_vue.md +709 -0
- package/package.json +129 -0
|
@@ -0,0 +1,3404 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import { defineStore } from "pinia";
|
|
5
|
+
import { saveAs } from "file-saver";
|
|
6
|
+
import { useToast, useMozLocale } from "@vmscloud/moz-ui-components";
|
|
7
|
+
import { reactive, ref } from "vue";
|
|
8
|
+
import axios from "axios";
|
|
9
|
+
const DataType = {
|
|
10
|
+
String: 1,
|
|
11
|
+
Number: 2,
|
|
12
|
+
Boolean: 3,
|
|
13
|
+
Date: 4
|
|
14
|
+
};
|
|
15
|
+
class FileParameter {
|
|
16
|
+
constructor(type, id) {
|
|
17
|
+
__publicField(this, "sessionId");
|
|
18
|
+
__publicField(this, "name", "");
|
|
19
|
+
__publicField(this, "path", "");
|
|
20
|
+
__publicField(this, "saveDir", "");
|
|
21
|
+
__publicField(this, "size", 0);
|
|
22
|
+
__publicField(this, "file");
|
|
23
|
+
__publicField(this, "info");
|
|
24
|
+
__publicField(this, "type", "Upload");
|
|
25
|
+
__publicField(this, "offset", 0);
|
|
26
|
+
__publicField(this, "isComplete", false);
|
|
27
|
+
__publicField(this, "isCancelable", false);
|
|
28
|
+
__publicField(this, "isCanceled", false);
|
|
29
|
+
__publicField(this, "blobInfo");
|
|
30
|
+
__publicField(this, "onCompleted");
|
|
31
|
+
__publicField(this, "onCancelClick");
|
|
32
|
+
this.type = type;
|
|
33
|
+
this.sessionId = id;
|
|
34
|
+
}
|
|
35
|
+
get ipcObject() {
|
|
36
|
+
return {
|
|
37
|
+
sessionId: this.sessionId,
|
|
38
|
+
name: this.name,
|
|
39
|
+
path: this.path,
|
|
40
|
+
saveDir: this.saveDir,
|
|
41
|
+
size: this.size,
|
|
42
|
+
info: this.info
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
get totalSize() {
|
|
46
|
+
var _a, _b;
|
|
47
|
+
if (this.type === "Upload") {
|
|
48
|
+
return +(((_a = this.file) == null ? void 0 : _a.size) || this.size);
|
|
49
|
+
} else {
|
|
50
|
+
return +(((_b = this.info) == null ? void 0 : _b.length) || 0);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
get percent() {
|
|
54
|
+
if (this.offset === 0 || this.totalSize === 0) return 0;
|
|
55
|
+
return Math.round(this.offset / this.totalSize * 100);
|
|
56
|
+
}
|
|
57
|
+
get progressValue() {
|
|
58
|
+
return +this.offset;
|
|
59
|
+
}
|
|
60
|
+
get status() {
|
|
61
|
+
return `${this.percent}% (${this.formatSizeUnits(this.offset)}/${this.formatSizeUnits(this.totalSize)})`;
|
|
62
|
+
}
|
|
63
|
+
completed(param) {
|
|
64
|
+
this.isCancelable = false;
|
|
65
|
+
this.isComplete = true;
|
|
66
|
+
this.blobInfo = param;
|
|
67
|
+
if (this.onCompleted) {
|
|
68
|
+
this.onCompleted(this);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
formatSizeUnits(bytes) {
|
|
72
|
+
let result = "";
|
|
73
|
+
if (bytes >= 1073741824) {
|
|
74
|
+
result = (bytes / 1073741824).toFixed(2) + " GB";
|
|
75
|
+
} else if (bytes >= 1048576) {
|
|
76
|
+
result = (bytes / 1048576).toFixed(2) + " MB";
|
|
77
|
+
} else if (bytes >= 1024) {
|
|
78
|
+
result = (bytes / 1024).toFixed(2) + " KB";
|
|
79
|
+
} else if (bytes > 1) {
|
|
80
|
+
result = `${bytes} bytes`;
|
|
81
|
+
} else if (bytes === 1) {
|
|
82
|
+
result = `${bytes} byte`;
|
|
83
|
+
} else {
|
|
84
|
+
result = "0 bytes";
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const generateGUID = () => {
|
|
90
|
+
const ran = () => ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
|
|
91
|
+
return `${ran() + ran()}-${ran()}-${ran()}-${ran()}-${ran()}${ran()}${ran()}`.toUpperCase();
|
|
92
|
+
};
|
|
93
|
+
function getDefaultExportFromCjs(x) {
|
|
94
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
95
|
+
}
|
|
96
|
+
function commonjsRequire(path) {
|
|
97
|
+
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
98
|
+
}
|
|
99
|
+
var bytebuffer$1 = { exports: {} };
|
|
100
|
+
var long$1 = { exports: {} };
|
|
101
|
+
var long = long$1.exports;
|
|
102
|
+
var hasRequiredLong;
|
|
103
|
+
function requireLong() {
|
|
104
|
+
if (hasRequiredLong) return long$1.exports;
|
|
105
|
+
hasRequiredLong = 1;
|
|
106
|
+
(function(module) {
|
|
107
|
+
/**
|
|
108
|
+
* @license long.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
|
|
109
|
+
* Released under the Apache License, Version 2.0
|
|
110
|
+
* see: https://github.com/dcodeIO/long.js for details
|
|
111
|
+
*/
|
|
112
|
+
(function(global, factory) {
|
|
113
|
+
if (typeof commonjsRequire === "function" && true && module && module["exports"])
|
|
114
|
+
module["exports"] = factory();
|
|
115
|
+
else
|
|
116
|
+
(global["dcodeIO"] = global["dcodeIO"] || {})["Long"] = factory();
|
|
117
|
+
})(long, function() {
|
|
118
|
+
function Long(low, high, unsigned) {
|
|
119
|
+
this.low = low | 0;
|
|
120
|
+
this.high = high | 0;
|
|
121
|
+
this.unsigned = !!unsigned;
|
|
122
|
+
}
|
|
123
|
+
Long.prototype.__isLong__;
|
|
124
|
+
Object.defineProperty(Long.prototype, "__isLong__", {
|
|
125
|
+
value: true,
|
|
126
|
+
enumerable: false,
|
|
127
|
+
configurable: false
|
|
128
|
+
});
|
|
129
|
+
function isLong(obj) {
|
|
130
|
+
return (obj && obj["__isLong__"]) === true;
|
|
131
|
+
}
|
|
132
|
+
Long.isLong = isLong;
|
|
133
|
+
var INT_CACHE = {};
|
|
134
|
+
var UINT_CACHE = {};
|
|
135
|
+
function fromInt(value, unsigned) {
|
|
136
|
+
var obj, cachedObj, cache;
|
|
137
|
+
if (unsigned) {
|
|
138
|
+
value >>>= 0;
|
|
139
|
+
if (cache = 0 <= value && value < 256) {
|
|
140
|
+
cachedObj = UINT_CACHE[value];
|
|
141
|
+
if (cachedObj)
|
|
142
|
+
return cachedObj;
|
|
143
|
+
}
|
|
144
|
+
obj = fromBits(value, (value | 0) < 0 ? -1 : 0, true);
|
|
145
|
+
if (cache)
|
|
146
|
+
UINT_CACHE[value] = obj;
|
|
147
|
+
return obj;
|
|
148
|
+
} else {
|
|
149
|
+
value |= 0;
|
|
150
|
+
if (cache = -128 <= value && value < 128) {
|
|
151
|
+
cachedObj = INT_CACHE[value];
|
|
152
|
+
if (cachedObj)
|
|
153
|
+
return cachedObj;
|
|
154
|
+
}
|
|
155
|
+
obj = fromBits(value, value < 0 ? -1 : 0, false);
|
|
156
|
+
if (cache)
|
|
157
|
+
INT_CACHE[value] = obj;
|
|
158
|
+
return obj;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
Long.fromInt = fromInt;
|
|
162
|
+
function fromNumber(value, unsigned) {
|
|
163
|
+
if (isNaN(value) || !isFinite(value))
|
|
164
|
+
return unsigned ? UZERO : ZERO;
|
|
165
|
+
if (unsigned) {
|
|
166
|
+
if (value < 0)
|
|
167
|
+
return UZERO;
|
|
168
|
+
if (value >= TWO_PWR_64_DBL)
|
|
169
|
+
return MAX_UNSIGNED_VALUE;
|
|
170
|
+
} else {
|
|
171
|
+
if (value <= -TWO_PWR_63_DBL)
|
|
172
|
+
return MIN_VALUE;
|
|
173
|
+
if (value + 1 >= TWO_PWR_63_DBL)
|
|
174
|
+
return MAX_VALUE;
|
|
175
|
+
}
|
|
176
|
+
if (value < 0)
|
|
177
|
+
return fromNumber(-value, unsigned).neg();
|
|
178
|
+
return fromBits(value % TWO_PWR_32_DBL | 0, value / TWO_PWR_32_DBL | 0, unsigned);
|
|
179
|
+
}
|
|
180
|
+
Long.fromNumber = fromNumber;
|
|
181
|
+
function fromBits(lowBits, highBits, unsigned) {
|
|
182
|
+
return new Long(lowBits, highBits, unsigned);
|
|
183
|
+
}
|
|
184
|
+
Long.fromBits = fromBits;
|
|
185
|
+
var pow_dbl = Math.pow;
|
|
186
|
+
function fromString(str, unsigned, radix) {
|
|
187
|
+
if (str.length === 0)
|
|
188
|
+
throw Error("empty string");
|
|
189
|
+
if (str === "NaN" || str === "Infinity" || str === "+Infinity" || str === "-Infinity")
|
|
190
|
+
return ZERO;
|
|
191
|
+
if (typeof unsigned === "number") {
|
|
192
|
+
radix = unsigned, unsigned = false;
|
|
193
|
+
} else {
|
|
194
|
+
unsigned = !!unsigned;
|
|
195
|
+
}
|
|
196
|
+
radix = radix || 10;
|
|
197
|
+
if (radix < 2 || 36 < radix)
|
|
198
|
+
throw RangeError("radix");
|
|
199
|
+
var p;
|
|
200
|
+
if ((p = str.indexOf("-")) > 0)
|
|
201
|
+
throw Error("interior hyphen");
|
|
202
|
+
else if (p === 0) {
|
|
203
|
+
return fromString(str.substring(1), unsigned, radix).neg();
|
|
204
|
+
}
|
|
205
|
+
var radixToPower = fromNumber(pow_dbl(radix, 8));
|
|
206
|
+
var result = ZERO;
|
|
207
|
+
for (var i = 0; i < str.length; i += 8) {
|
|
208
|
+
var size = Math.min(8, str.length - i), value = parseInt(str.substring(i, i + size), radix);
|
|
209
|
+
if (size < 8) {
|
|
210
|
+
var power = fromNumber(pow_dbl(radix, size));
|
|
211
|
+
result = result.mul(power).add(fromNumber(value));
|
|
212
|
+
} else {
|
|
213
|
+
result = result.mul(radixToPower);
|
|
214
|
+
result = result.add(fromNumber(value));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
result.unsigned = unsigned;
|
|
218
|
+
return result;
|
|
219
|
+
}
|
|
220
|
+
Long.fromString = fromString;
|
|
221
|
+
function fromValue(val) {
|
|
222
|
+
if (val instanceof Long)
|
|
223
|
+
return val;
|
|
224
|
+
if (typeof val === "number")
|
|
225
|
+
return fromNumber(val);
|
|
226
|
+
if (typeof val === "string")
|
|
227
|
+
return fromString(val);
|
|
228
|
+
return fromBits(val.low, val.high, val.unsigned);
|
|
229
|
+
}
|
|
230
|
+
Long.fromValue = fromValue;
|
|
231
|
+
var TWO_PWR_16_DBL = 1 << 16;
|
|
232
|
+
var TWO_PWR_24_DBL = 1 << 24;
|
|
233
|
+
var TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL;
|
|
234
|
+
var TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL;
|
|
235
|
+
var TWO_PWR_63_DBL = TWO_PWR_64_DBL / 2;
|
|
236
|
+
var TWO_PWR_24 = fromInt(TWO_PWR_24_DBL);
|
|
237
|
+
var ZERO = fromInt(0);
|
|
238
|
+
Long.ZERO = ZERO;
|
|
239
|
+
var UZERO = fromInt(0, true);
|
|
240
|
+
Long.UZERO = UZERO;
|
|
241
|
+
var ONE = fromInt(1);
|
|
242
|
+
Long.ONE = ONE;
|
|
243
|
+
var UONE = fromInt(1, true);
|
|
244
|
+
Long.UONE = UONE;
|
|
245
|
+
var NEG_ONE = fromInt(-1);
|
|
246
|
+
Long.NEG_ONE = NEG_ONE;
|
|
247
|
+
var MAX_VALUE = fromBits(4294967295 | 0, 2147483647 | 0, false);
|
|
248
|
+
Long.MAX_VALUE = MAX_VALUE;
|
|
249
|
+
var MAX_UNSIGNED_VALUE = fromBits(4294967295 | 0, 4294967295 | 0, true);
|
|
250
|
+
Long.MAX_UNSIGNED_VALUE = MAX_UNSIGNED_VALUE;
|
|
251
|
+
var MIN_VALUE = fromBits(0, 2147483648 | 0, false);
|
|
252
|
+
Long.MIN_VALUE = MIN_VALUE;
|
|
253
|
+
var LongPrototype = Long.prototype;
|
|
254
|
+
LongPrototype.toInt = function toInt() {
|
|
255
|
+
return this.unsigned ? this.low >>> 0 : this.low;
|
|
256
|
+
};
|
|
257
|
+
LongPrototype.toNumber = function toNumber() {
|
|
258
|
+
if (this.unsigned)
|
|
259
|
+
return (this.high >>> 0) * TWO_PWR_32_DBL + (this.low >>> 0);
|
|
260
|
+
return this.high * TWO_PWR_32_DBL + (this.low >>> 0);
|
|
261
|
+
};
|
|
262
|
+
LongPrototype.toString = function toString(radix) {
|
|
263
|
+
radix = radix || 10;
|
|
264
|
+
if (radix < 2 || 36 < radix)
|
|
265
|
+
throw RangeError("radix");
|
|
266
|
+
if (this.isZero())
|
|
267
|
+
return "0";
|
|
268
|
+
if (this.isNegative()) {
|
|
269
|
+
if (this.eq(MIN_VALUE)) {
|
|
270
|
+
var radixLong = fromNumber(radix), div = this.div(radixLong), rem1 = div.mul(radixLong).sub(this);
|
|
271
|
+
return div.toString(radix) + rem1.toInt().toString(radix);
|
|
272
|
+
} else
|
|
273
|
+
return "-" + this.neg().toString(radix);
|
|
274
|
+
}
|
|
275
|
+
var radixToPower = fromNumber(pow_dbl(radix, 6), this.unsigned), rem = this;
|
|
276
|
+
var result = "";
|
|
277
|
+
while (true) {
|
|
278
|
+
var remDiv = rem.div(radixToPower), intval = rem.sub(remDiv.mul(radixToPower)).toInt() >>> 0, digits = intval.toString(radix);
|
|
279
|
+
rem = remDiv;
|
|
280
|
+
if (rem.isZero())
|
|
281
|
+
return digits + result;
|
|
282
|
+
else {
|
|
283
|
+
while (digits.length < 6)
|
|
284
|
+
digits = "0" + digits;
|
|
285
|
+
result = "" + digits + result;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
LongPrototype.getHighBits = function getHighBits() {
|
|
290
|
+
return this.high;
|
|
291
|
+
};
|
|
292
|
+
LongPrototype.getHighBitsUnsigned = function getHighBitsUnsigned() {
|
|
293
|
+
return this.high >>> 0;
|
|
294
|
+
};
|
|
295
|
+
LongPrototype.getLowBits = function getLowBits() {
|
|
296
|
+
return this.low;
|
|
297
|
+
};
|
|
298
|
+
LongPrototype.getLowBitsUnsigned = function getLowBitsUnsigned() {
|
|
299
|
+
return this.low >>> 0;
|
|
300
|
+
};
|
|
301
|
+
LongPrototype.getNumBitsAbs = function getNumBitsAbs() {
|
|
302
|
+
if (this.isNegative())
|
|
303
|
+
return this.eq(MIN_VALUE) ? 64 : this.neg().getNumBitsAbs();
|
|
304
|
+
var val = this.high != 0 ? this.high : this.low;
|
|
305
|
+
for (var bit = 31; bit > 0; bit--)
|
|
306
|
+
if ((val & 1 << bit) != 0)
|
|
307
|
+
break;
|
|
308
|
+
return this.high != 0 ? bit + 33 : bit + 1;
|
|
309
|
+
};
|
|
310
|
+
LongPrototype.isZero = function isZero() {
|
|
311
|
+
return this.high === 0 && this.low === 0;
|
|
312
|
+
};
|
|
313
|
+
LongPrototype.isNegative = function isNegative() {
|
|
314
|
+
return !this.unsigned && this.high < 0;
|
|
315
|
+
};
|
|
316
|
+
LongPrototype.isPositive = function isPositive() {
|
|
317
|
+
return this.unsigned || this.high >= 0;
|
|
318
|
+
};
|
|
319
|
+
LongPrototype.isOdd = function isOdd() {
|
|
320
|
+
return (this.low & 1) === 1;
|
|
321
|
+
};
|
|
322
|
+
LongPrototype.isEven = function isEven() {
|
|
323
|
+
return (this.low & 1) === 0;
|
|
324
|
+
};
|
|
325
|
+
LongPrototype.equals = function equals(other) {
|
|
326
|
+
if (!isLong(other))
|
|
327
|
+
other = fromValue(other);
|
|
328
|
+
if (this.unsigned !== other.unsigned && this.high >>> 31 === 1 && other.high >>> 31 === 1)
|
|
329
|
+
return false;
|
|
330
|
+
return this.high === other.high && this.low === other.low;
|
|
331
|
+
};
|
|
332
|
+
LongPrototype.eq = LongPrototype.equals;
|
|
333
|
+
LongPrototype.notEquals = function notEquals(other) {
|
|
334
|
+
return !this.eq(
|
|
335
|
+
/* validates */
|
|
336
|
+
other
|
|
337
|
+
);
|
|
338
|
+
};
|
|
339
|
+
LongPrototype.neq = LongPrototype.notEquals;
|
|
340
|
+
LongPrototype.lessThan = function lessThan(other) {
|
|
341
|
+
return this.comp(
|
|
342
|
+
/* validates */
|
|
343
|
+
other
|
|
344
|
+
) < 0;
|
|
345
|
+
};
|
|
346
|
+
LongPrototype.lt = LongPrototype.lessThan;
|
|
347
|
+
LongPrototype.lessThanOrEqual = function lessThanOrEqual(other) {
|
|
348
|
+
return this.comp(
|
|
349
|
+
/* validates */
|
|
350
|
+
other
|
|
351
|
+
) <= 0;
|
|
352
|
+
};
|
|
353
|
+
LongPrototype.lte = LongPrototype.lessThanOrEqual;
|
|
354
|
+
LongPrototype.greaterThan = function greaterThan(other) {
|
|
355
|
+
return this.comp(
|
|
356
|
+
/* validates */
|
|
357
|
+
other
|
|
358
|
+
) > 0;
|
|
359
|
+
};
|
|
360
|
+
LongPrototype.gt = LongPrototype.greaterThan;
|
|
361
|
+
LongPrototype.greaterThanOrEqual = function greaterThanOrEqual(other) {
|
|
362
|
+
return this.comp(
|
|
363
|
+
/* validates */
|
|
364
|
+
other
|
|
365
|
+
) >= 0;
|
|
366
|
+
};
|
|
367
|
+
LongPrototype.gte = LongPrototype.greaterThanOrEqual;
|
|
368
|
+
LongPrototype.compare = function compare(other) {
|
|
369
|
+
if (!isLong(other))
|
|
370
|
+
other = fromValue(other);
|
|
371
|
+
if (this.eq(other))
|
|
372
|
+
return 0;
|
|
373
|
+
var thisNeg = this.isNegative(), otherNeg = other.isNegative();
|
|
374
|
+
if (thisNeg && !otherNeg)
|
|
375
|
+
return -1;
|
|
376
|
+
if (!thisNeg && otherNeg)
|
|
377
|
+
return 1;
|
|
378
|
+
if (!this.unsigned)
|
|
379
|
+
return this.sub(other).isNegative() ? -1 : 1;
|
|
380
|
+
return other.high >>> 0 > this.high >>> 0 || other.high === this.high && other.low >>> 0 > this.low >>> 0 ? -1 : 1;
|
|
381
|
+
};
|
|
382
|
+
LongPrototype.comp = LongPrototype.compare;
|
|
383
|
+
LongPrototype.negate = function negate() {
|
|
384
|
+
if (!this.unsigned && this.eq(MIN_VALUE))
|
|
385
|
+
return MIN_VALUE;
|
|
386
|
+
return this.not().add(ONE);
|
|
387
|
+
};
|
|
388
|
+
LongPrototype.neg = LongPrototype.negate;
|
|
389
|
+
LongPrototype.add = function add(addend) {
|
|
390
|
+
if (!isLong(addend))
|
|
391
|
+
addend = fromValue(addend);
|
|
392
|
+
var a48 = this.high >>> 16;
|
|
393
|
+
var a32 = this.high & 65535;
|
|
394
|
+
var a16 = this.low >>> 16;
|
|
395
|
+
var a00 = this.low & 65535;
|
|
396
|
+
var b48 = addend.high >>> 16;
|
|
397
|
+
var b32 = addend.high & 65535;
|
|
398
|
+
var b16 = addend.low >>> 16;
|
|
399
|
+
var b00 = addend.low & 65535;
|
|
400
|
+
var c48 = 0, c32 = 0, c16 = 0, c00 = 0;
|
|
401
|
+
c00 += a00 + b00;
|
|
402
|
+
c16 += c00 >>> 16;
|
|
403
|
+
c00 &= 65535;
|
|
404
|
+
c16 += a16 + b16;
|
|
405
|
+
c32 += c16 >>> 16;
|
|
406
|
+
c16 &= 65535;
|
|
407
|
+
c32 += a32 + b32;
|
|
408
|
+
c48 += c32 >>> 16;
|
|
409
|
+
c32 &= 65535;
|
|
410
|
+
c48 += a48 + b48;
|
|
411
|
+
c48 &= 65535;
|
|
412
|
+
return fromBits(c16 << 16 | c00, c48 << 16 | c32, this.unsigned);
|
|
413
|
+
};
|
|
414
|
+
LongPrototype.subtract = function subtract(subtrahend) {
|
|
415
|
+
if (!isLong(subtrahend))
|
|
416
|
+
subtrahend = fromValue(subtrahend);
|
|
417
|
+
return this.add(subtrahend.neg());
|
|
418
|
+
};
|
|
419
|
+
LongPrototype.sub = LongPrototype.subtract;
|
|
420
|
+
LongPrototype.multiply = function multiply(multiplier) {
|
|
421
|
+
if (this.isZero())
|
|
422
|
+
return ZERO;
|
|
423
|
+
if (!isLong(multiplier))
|
|
424
|
+
multiplier = fromValue(multiplier);
|
|
425
|
+
if (multiplier.isZero())
|
|
426
|
+
return ZERO;
|
|
427
|
+
if (this.eq(MIN_VALUE))
|
|
428
|
+
return multiplier.isOdd() ? MIN_VALUE : ZERO;
|
|
429
|
+
if (multiplier.eq(MIN_VALUE))
|
|
430
|
+
return this.isOdd() ? MIN_VALUE : ZERO;
|
|
431
|
+
if (this.isNegative()) {
|
|
432
|
+
if (multiplier.isNegative())
|
|
433
|
+
return this.neg().mul(multiplier.neg());
|
|
434
|
+
else
|
|
435
|
+
return this.neg().mul(multiplier).neg();
|
|
436
|
+
} else if (multiplier.isNegative())
|
|
437
|
+
return this.mul(multiplier.neg()).neg();
|
|
438
|
+
if (this.lt(TWO_PWR_24) && multiplier.lt(TWO_PWR_24))
|
|
439
|
+
return fromNumber(this.toNumber() * multiplier.toNumber(), this.unsigned);
|
|
440
|
+
var a48 = this.high >>> 16;
|
|
441
|
+
var a32 = this.high & 65535;
|
|
442
|
+
var a16 = this.low >>> 16;
|
|
443
|
+
var a00 = this.low & 65535;
|
|
444
|
+
var b48 = multiplier.high >>> 16;
|
|
445
|
+
var b32 = multiplier.high & 65535;
|
|
446
|
+
var b16 = multiplier.low >>> 16;
|
|
447
|
+
var b00 = multiplier.low & 65535;
|
|
448
|
+
var c48 = 0, c32 = 0, c16 = 0, c00 = 0;
|
|
449
|
+
c00 += a00 * b00;
|
|
450
|
+
c16 += c00 >>> 16;
|
|
451
|
+
c00 &= 65535;
|
|
452
|
+
c16 += a16 * b00;
|
|
453
|
+
c32 += c16 >>> 16;
|
|
454
|
+
c16 &= 65535;
|
|
455
|
+
c16 += a00 * b16;
|
|
456
|
+
c32 += c16 >>> 16;
|
|
457
|
+
c16 &= 65535;
|
|
458
|
+
c32 += a32 * b00;
|
|
459
|
+
c48 += c32 >>> 16;
|
|
460
|
+
c32 &= 65535;
|
|
461
|
+
c32 += a16 * b16;
|
|
462
|
+
c48 += c32 >>> 16;
|
|
463
|
+
c32 &= 65535;
|
|
464
|
+
c32 += a00 * b32;
|
|
465
|
+
c48 += c32 >>> 16;
|
|
466
|
+
c32 &= 65535;
|
|
467
|
+
c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48;
|
|
468
|
+
c48 &= 65535;
|
|
469
|
+
return fromBits(c16 << 16 | c00, c48 << 16 | c32, this.unsigned);
|
|
470
|
+
};
|
|
471
|
+
LongPrototype.mul = LongPrototype.multiply;
|
|
472
|
+
LongPrototype.divide = function divide(divisor) {
|
|
473
|
+
if (!isLong(divisor))
|
|
474
|
+
divisor = fromValue(divisor);
|
|
475
|
+
if (divisor.isZero())
|
|
476
|
+
throw Error("division by zero");
|
|
477
|
+
if (this.isZero())
|
|
478
|
+
return this.unsigned ? UZERO : ZERO;
|
|
479
|
+
var approx, rem, res;
|
|
480
|
+
if (!this.unsigned) {
|
|
481
|
+
if (this.eq(MIN_VALUE)) {
|
|
482
|
+
if (divisor.eq(ONE) || divisor.eq(NEG_ONE))
|
|
483
|
+
return MIN_VALUE;
|
|
484
|
+
else if (divisor.eq(MIN_VALUE))
|
|
485
|
+
return ONE;
|
|
486
|
+
else {
|
|
487
|
+
var halfThis = this.shr(1);
|
|
488
|
+
approx = halfThis.div(divisor).shl(1);
|
|
489
|
+
if (approx.eq(ZERO)) {
|
|
490
|
+
return divisor.isNegative() ? ONE : NEG_ONE;
|
|
491
|
+
} else {
|
|
492
|
+
rem = this.sub(divisor.mul(approx));
|
|
493
|
+
res = approx.add(rem.div(divisor));
|
|
494
|
+
return res;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
} else if (divisor.eq(MIN_VALUE))
|
|
498
|
+
return this.unsigned ? UZERO : ZERO;
|
|
499
|
+
if (this.isNegative()) {
|
|
500
|
+
if (divisor.isNegative())
|
|
501
|
+
return this.neg().div(divisor.neg());
|
|
502
|
+
return this.neg().div(divisor).neg();
|
|
503
|
+
} else if (divisor.isNegative())
|
|
504
|
+
return this.div(divisor.neg()).neg();
|
|
505
|
+
res = ZERO;
|
|
506
|
+
} else {
|
|
507
|
+
if (!divisor.unsigned)
|
|
508
|
+
divisor = divisor.toUnsigned();
|
|
509
|
+
if (divisor.gt(this))
|
|
510
|
+
return UZERO;
|
|
511
|
+
if (divisor.gt(this.shru(1)))
|
|
512
|
+
return UONE;
|
|
513
|
+
res = UZERO;
|
|
514
|
+
}
|
|
515
|
+
rem = this;
|
|
516
|
+
while (rem.gte(divisor)) {
|
|
517
|
+
approx = Math.max(1, Math.floor(rem.toNumber() / divisor.toNumber()));
|
|
518
|
+
var log2 = Math.ceil(Math.log(approx) / Math.LN2), delta = log2 <= 48 ? 1 : pow_dbl(2, log2 - 48), approxRes = fromNumber(approx), approxRem = approxRes.mul(divisor);
|
|
519
|
+
while (approxRem.isNegative() || approxRem.gt(rem)) {
|
|
520
|
+
approx -= delta;
|
|
521
|
+
approxRes = fromNumber(approx, this.unsigned);
|
|
522
|
+
approxRem = approxRes.mul(divisor);
|
|
523
|
+
}
|
|
524
|
+
if (approxRes.isZero())
|
|
525
|
+
approxRes = ONE;
|
|
526
|
+
res = res.add(approxRes);
|
|
527
|
+
rem = rem.sub(approxRem);
|
|
528
|
+
}
|
|
529
|
+
return res;
|
|
530
|
+
};
|
|
531
|
+
LongPrototype.div = LongPrototype.divide;
|
|
532
|
+
LongPrototype.modulo = function modulo(divisor) {
|
|
533
|
+
if (!isLong(divisor))
|
|
534
|
+
divisor = fromValue(divisor);
|
|
535
|
+
return this.sub(this.div(divisor).mul(divisor));
|
|
536
|
+
};
|
|
537
|
+
LongPrototype.mod = LongPrototype.modulo;
|
|
538
|
+
LongPrototype.not = function not() {
|
|
539
|
+
return fromBits(~this.low, ~this.high, this.unsigned);
|
|
540
|
+
};
|
|
541
|
+
LongPrototype.and = function and(other) {
|
|
542
|
+
if (!isLong(other))
|
|
543
|
+
other = fromValue(other);
|
|
544
|
+
return fromBits(this.low & other.low, this.high & other.high, this.unsigned);
|
|
545
|
+
};
|
|
546
|
+
LongPrototype.or = function or(other) {
|
|
547
|
+
if (!isLong(other))
|
|
548
|
+
other = fromValue(other);
|
|
549
|
+
return fromBits(this.low | other.low, this.high | other.high, this.unsigned);
|
|
550
|
+
};
|
|
551
|
+
LongPrototype.xor = function xor(other) {
|
|
552
|
+
if (!isLong(other))
|
|
553
|
+
other = fromValue(other);
|
|
554
|
+
return fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned);
|
|
555
|
+
};
|
|
556
|
+
LongPrototype.shiftLeft = function shiftLeft(numBits) {
|
|
557
|
+
if (isLong(numBits))
|
|
558
|
+
numBits = numBits.toInt();
|
|
559
|
+
if ((numBits &= 63) === 0)
|
|
560
|
+
return this;
|
|
561
|
+
else if (numBits < 32)
|
|
562
|
+
return fromBits(this.low << numBits, this.high << numBits | this.low >>> 32 - numBits, this.unsigned);
|
|
563
|
+
else
|
|
564
|
+
return fromBits(0, this.low << numBits - 32, this.unsigned);
|
|
565
|
+
};
|
|
566
|
+
LongPrototype.shl = LongPrototype.shiftLeft;
|
|
567
|
+
LongPrototype.shiftRight = function shiftRight(numBits) {
|
|
568
|
+
if (isLong(numBits))
|
|
569
|
+
numBits = numBits.toInt();
|
|
570
|
+
if ((numBits &= 63) === 0)
|
|
571
|
+
return this;
|
|
572
|
+
else if (numBits < 32)
|
|
573
|
+
return fromBits(this.low >>> numBits | this.high << 32 - numBits, this.high >> numBits, this.unsigned);
|
|
574
|
+
else
|
|
575
|
+
return fromBits(this.high >> numBits - 32, this.high >= 0 ? 0 : -1, this.unsigned);
|
|
576
|
+
};
|
|
577
|
+
LongPrototype.shr = LongPrototype.shiftRight;
|
|
578
|
+
LongPrototype.shiftRightUnsigned = function shiftRightUnsigned(numBits) {
|
|
579
|
+
if (isLong(numBits))
|
|
580
|
+
numBits = numBits.toInt();
|
|
581
|
+
numBits &= 63;
|
|
582
|
+
if (numBits === 0)
|
|
583
|
+
return this;
|
|
584
|
+
else {
|
|
585
|
+
var high = this.high;
|
|
586
|
+
if (numBits < 32) {
|
|
587
|
+
var low = this.low;
|
|
588
|
+
return fromBits(low >>> numBits | high << 32 - numBits, high >>> numBits, this.unsigned);
|
|
589
|
+
} else if (numBits === 32)
|
|
590
|
+
return fromBits(high, 0, this.unsigned);
|
|
591
|
+
else
|
|
592
|
+
return fromBits(high >>> numBits - 32, 0, this.unsigned);
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
LongPrototype.shru = LongPrototype.shiftRightUnsigned;
|
|
596
|
+
LongPrototype.toSigned = function toSigned() {
|
|
597
|
+
if (!this.unsigned)
|
|
598
|
+
return this;
|
|
599
|
+
return fromBits(this.low, this.high, false);
|
|
600
|
+
};
|
|
601
|
+
LongPrototype.toUnsigned = function toUnsigned() {
|
|
602
|
+
if (this.unsigned)
|
|
603
|
+
return this;
|
|
604
|
+
return fromBits(this.low, this.high, true);
|
|
605
|
+
};
|
|
606
|
+
LongPrototype.toBytes = function(le) {
|
|
607
|
+
return le ? this.toBytesLE() : this.toBytesBE();
|
|
608
|
+
};
|
|
609
|
+
LongPrototype.toBytesLE = function() {
|
|
610
|
+
var hi = this.high, lo = this.low;
|
|
611
|
+
return [
|
|
612
|
+
lo & 255,
|
|
613
|
+
lo >>> 8 & 255,
|
|
614
|
+
lo >>> 16 & 255,
|
|
615
|
+
lo >>> 24 & 255,
|
|
616
|
+
hi & 255,
|
|
617
|
+
hi >>> 8 & 255,
|
|
618
|
+
hi >>> 16 & 255,
|
|
619
|
+
hi >>> 24 & 255
|
|
620
|
+
];
|
|
621
|
+
};
|
|
622
|
+
LongPrototype.toBytesBE = function() {
|
|
623
|
+
var hi = this.high, lo = this.low;
|
|
624
|
+
return [
|
|
625
|
+
hi >>> 24 & 255,
|
|
626
|
+
hi >>> 16 & 255,
|
|
627
|
+
hi >>> 8 & 255,
|
|
628
|
+
hi & 255,
|
|
629
|
+
lo >>> 24 & 255,
|
|
630
|
+
lo >>> 16 & 255,
|
|
631
|
+
lo >>> 8 & 255,
|
|
632
|
+
lo & 255
|
|
633
|
+
];
|
|
634
|
+
};
|
|
635
|
+
return Long;
|
|
636
|
+
});
|
|
637
|
+
})(long$1);
|
|
638
|
+
return long$1.exports;
|
|
639
|
+
}
|
|
640
|
+
var bytebuffer = bytebuffer$1.exports;
|
|
641
|
+
var hasRequiredBytebuffer;
|
|
642
|
+
function requireBytebuffer() {
|
|
643
|
+
if (hasRequiredBytebuffer) return bytebuffer$1.exports;
|
|
644
|
+
hasRequiredBytebuffer = 1;
|
|
645
|
+
(function(module) {
|
|
646
|
+
/**
|
|
647
|
+
* @license bytebuffer.js (c) 2015 Daniel Wirtz <dcode@dcode.io>
|
|
648
|
+
* Backing buffer: ArrayBuffer, Accessor: Uint8Array
|
|
649
|
+
* Released under the Apache License, Version 2.0
|
|
650
|
+
* see: https://github.com/dcodeIO/bytebuffer.js for details
|
|
651
|
+
*/
|
|
652
|
+
(function(global, factory) {
|
|
653
|
+
if (typeof commonjsRequire === "function" && true && module && module["exports"])
|
|
654
|
+
module["exports"] = (function() {
|
|
655
|
+
var Long;
|
|
656
|
+
try {
|
|
657
|
+
Long = requireLong();
|
|
658
|
+
} catch (e) {
|
|
659
|
+
}
|
|
660
|
+
return factory(Long);
|
|
661
|
+
})();
|
|
662
|
+
else
|
|
663
|
+
(global["dcodeIO"] = global["dcodeIO"] || {})["ByteBuffer"] = factory(global["dcodeIO"]["Long"]);
|
|
664
|
+
})(bytebuffer, function(Long) {
|
|
665
|
+
var ByteBuffer2 = function(capacity, littleEndian, noAssert) {
|
|
666
|
+
if (typeof capacity === "undefined")
|
|
667
|
+
capacity = ByteBuffer2.DEFAULT_CAPACITY;
|
|
668
|
+
if (typeof littleEndian === "undefined")
|
|
669
|
+
littleEndian = ByteBuffer2.DEFAULT_ENDIAN;
|
|
670
|
+
if (typeof noAssert === "undefined")
|
|
671
|
+
noAssert = ByteBuffer2.DEFAULT_NOASSERT;
|
|
672
|
+
if (!noAssert) {
|
|
673
|
+
capacity = capacity | 0;
|
|
674
|
+
if (capacity < 0)
|
|
675
|
+
throw RangeError("Illegal capacity");
|
|
676
|
+
littleEndian = !!littleEndian;
|
|
677
|
+
noAssert = !!noAssert;
|
|
678
|
+
}
|
|
679
|
+
this.buffer = capacity === 0 ? EMPTY_BUFFER : new ArrayBuffer(capacity);
|
|
680
|
+
this.view = capacity === 0 ? null : new Uint8Array(this.buffer);
|
|
681
|
+
this.offset = 0;
|
|
682
|
+
this.markedOffset = -1;
|
|
683
|
+
this.limit = capacity;
|
|
684
|
+
this.littleEndian = littleEndian;
|
|
685
|
+
this.noAssert = noAssert;
|
|
686
|
+
};
|
|
687
|
+
ByteBuffer2.VERSION = "5.0.1";
|
|
688
|
+
ByteBuffer2.LITTLE_ENDIAN = true;
|
|
689
|
+
ByteBuffer2.BIG_ENDIAN = false;
|
|
690
|
+
ByteBuffer2.DEFAULT_CAPACITY = 16;
|
|
691
|
+
ByteBuffer2.DEFAULT_ENDIAN = ByteBuffer2.BIG_ENDIAN;
|
|
692
|
+
ByteBuffer2.DEFAULT_NOASSERT = false;
|
|
693
|
+
ByteBuffer2.Long = Long || null;
|
|
694
|
+
var ByteBufferPrototype = ByteBuffer2.prototype;
|
|
695
|
+
ByteBufferPrototype.__isByteBuffer__;
|
|
696
|
+
Object.defineProperty(ByteBufferPrototype, "__isByteBuffer__", {
|
|
697
|
+
value: true,
|
|
698
|
+
enumerable: false,
|
|
699
|
+
configurable: false
|
|
700
|
+
});
|
|
701
|
+
var EMPTY_BUFFER = new ArrayBuffer(0);
|
|
702
|
+
var stringFromCharCode = String.fromCharCode;
|
|
703
|
+
function stringSource(s) {
|
|
704
|
+
var i = 0;
|
|
705
|
+
return function() {
|
|
706
|
+
return i < s.length ? s.charCodeAt(i++) : null;
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
function stringDestination() {
|
|
710
|
+
var cs = [], ps = [];
|
|
711
|
+
return function() {
|
|
712
|
+
if (arguments.length === 0)
|
|
713
|
+
return ps.join("") + stringFromCharCode.apply(String, cs);
|
|
714
|
+
if (cs.length + arguments.length > 1024)
|
|
715
|
+
ps.push(stringFromCharCode.apply(String, cs)), cs.length = 0;
|
|
716
|
+
Array.prototype.push.apply(cs, arguments);
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
ByteBuffer2.accessor = function() {
|
|
720
|
+
return Uint8Array;
|
|
721
|
+
};
|
|
722
|
+
ByteBuffer2.allocate = function(capacity, littleEndian, noAssert) {
|
|
723
|
+
return new ByteBuffer2(capacity, littleEndian, noAssert);
|
|
724
|
+
};
|
|
725
|
+
ByteBuffer2.concat = function(buffers, encoding, littleEndian, noAssert) {
|
|
726
|
+
if (typeof encoding === "boolean" || typeof encoding !== "string") {
|
|
727
|
+
noAssert = littleEndian;
|
|
728
|
+
littleEndian = encoding;
|
|
729
|
+
encoding = void 0;
|
|
730
|
+
}
|
|
731
|
+
var capacity = 0;
|
|
732
|
+
for (var i = 0, k = buffers.length, length; i < k; ++i) {
|
|
733
|
+
if (!ByteBuffer2.isByteBuffer(buffers[i]))
|
|
734
|
+
buffers[i] = ByteBuffer2.wrap(buffers[i], encoding);
|
|
735
|
+
length = buffers[i].limit - buffers[i].offset;
|
|
736
|
+
if (length > 0) capacity += length;
|
|
737
|
+
}
|
|
738
|
+
if (capacity === 0)
|
|
739
|
+
return new ByteBuffer2(0, littleEndian, noAssert);
|
|
740
|
+
var bb = new ByteBuffer2(capacity, littleEndian, noAssert), bi;
|
|
741
|
+
i = 0;
|
|
742
|
+
while (i < k) {
|
|
743
|
+
bi = buffers[i++];
|
|
744
|
+
length = bi.limit - bi.offset;
|
|
745
|
+
if (length <= 0) continue;
|
|
746
|
+
bb.view.set(bi.view.subarray(bi.offset, bi.limit), bb.offset);
|
|
747
|
+
bb.offset += length;
|
|
748
|
+
}
|
|
749
|
+
bb.limit = bb.offset;
|
|
750
|
+
bb.offset = 0;
|
|
751
|
+
return bb;
|
|
752
|
+
};
|
|
753
|
+
ByteBuffer2.isByteBuffer = function(bb) {
|
|
754
|
+
return (bb && bb["__isByteBuffer__"]) === true;
|
|
755
|
+
};
|
|
756
|
+
ByteBuffer2.type = function() {
|
|
757
|
+
return ArrayBuffer;
|
|
758
|
+
};
|
|
759
|
+
ByteBuffer2.wrap = function(buffer, encoding, littleEndian, noAssert) {
|
|
760
|
+
if (typeof encoding !== "string") {
|
|
761
|
+
noAssert = littleEndian;
|
|
762
|
+
littleEndian = encoding;
|
|
763
|
+
encoding = void 0;
|
|
764
|
+
}
|
|
765
|
+
if (typeof buffer === "string") {
|
|
766
|
+
if (typeof encoding === "undefined")
|
|
767
|
+
encoding = "utf8";
|
|
768
|
+
switch (encoding) {
|
|
769
|
+
case "base64":
|
|
770
|
+
return ByteBuffer2.fromBase64(buffer, littleEndian);
|
|
771
|
+
case "hex":
|
|
772
|
+
return ByteBuffer2.fromHex(buffer, littleEndian);
|
|
773
|
+
case "binary":
|
|
774
|
+
return ByteBuffer2.fromBinary(buffer, littleEndian);
|
|
775
|
+
case "utf8":
|
|
776
|
+
return ByteBuffer2.fromUTF8(buffer, littleEndian);
|
|
777
|
+
case "debug":
|
|
778
|
+
return ByteBuffer2.fromDebug(buffer, littleEndian);
|
|
779
|
+
default:
|
|
780
|
+
throw Error("Unsupported encoding: " + encoding);
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
if (buffer === null || typeof buffer !== "object")
|
|
784
|
+
throw TypeError("Illegal buffer");
|
|
785
|
+
var bb;
|
|
786
|
+
if (ByteBuffer2.isByteBuffer(buffer)) {
|
|
787
|
+
bb = ByteBufferPrototype.clone.call(buffer);
|
|
788
|
+
bb.markedOffset = -1;
|
|
789
|
+
return bb;
|
|
790
|
+
}
|
|
791
|
+
if (buffer instanceof Uint8Array) {
|
|
792
|
+
bb = new ByteBuffer2(0, littleEndian, noAssert);
|
|
793
|
+
if (buffer.length > 0) {
|
|
794
|
+
bb.buffer = buffer.buffer;
|
|
795
|
+
bb.offset = buffer.byteOffset;
|
|
796
|
+
bb.limit = buffer.byteOffset + buffer.byteLength;
|
|
797
|
+
bb.view = new Uint8Array(buffer.buffer);
|
|
798
|
+
}
|
|
799
|
+
} else if (buffer instanceof ArrayBuffer) {
|
|
800
|
+
bb = new ByteBuffer2(0, littleEndian, noAssert);
|
|
801
|
+
if (buffer.byteLength > 0) {
|
|
802
|
+
bb.buffer = buffer;
|
|
803
|
+
bb.offset = 0;
|
|
804
|
+
bb.limit = buffer.byteLength;
|
|
805
|
+
bb.view = buffer.byteLength > 0 ? new Uint8Array(buffer) : null;
|
|
806
|
+
}
|
|
807
|
+
} else if (Object.prototype.toString.call(buffer) === "[object Array]") {
|
|
808
|
+
bb = new ByteBuffer2(buffer.length, littleEndian, noAssert);
|
|
809
|
+
bb.limit = buffer.length;
|
|
810
|
+
for (var i = 0; i < buffer.length; ++i)
|
|
811
|
+
bb.view[i] = buffer[i];
|
|
812
|
+
} else
|
|
813
|
+
throw TypeError("Illegal buffer");
|
|
814
|
+
return bb;
|
|
815
|
+
};
|
|
816
|
+
ByteBufferPrototype.writeBitSet = function(value, offset) {
|
|
817
|
+
var relative = typeof offset === "undefined";
|
|
818
|
+
if (relative) offset = this.offset;
|
|
819
|
+
if (!this.noAssert) {
|
|
820
|
+
if (!(value instanceof Array))
|
|
821
|
+
throw TypeError("Illegal BitSet: Not an array");
|
|
822
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
823
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
824
|
+
offset >>>= 0;
|
|
825
|
+
if (offset < 0 || offset + 0 > this.buffer.byteLength)
|
|
826
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+0) <= " + this.buffer.byteLength);
|
|
827
|
+
}
|
|
828
|
+
var start = offset, bits = value.length, bytes = bits >> 3, bit = 0, k;
|
|
829
|
+
offset += this.writeVarint32(bits, offset);
|
|
830
|
+
while (bytes--) {
|
|
831
|
+
k = !!value[bit++] & 1 | (!!value[bit++] & 1) << 1 | (!!value[bit++] & 1) << 2 | (!!value[bit++] & 1) << 3 | (!!value[bit++] & 1) << 4 | (!!value[bit++] & 1) << 5 | (!!value[bit++] & 1) << 6 | (!!value[bit++] & 1) << 7;
|
|
832
|
+
this.writeByte(k, offset++);
|
|
833
|
+
}
|
|
834
|
+
if (bit < bits) {
|
|
835
|
+
var m = 0;
|
|
836
|
+
k = 0;
|
|
837
|
+
while (bit < bits) k = k | (!!value[bit++] & 1) << m++;
|
|
838
|
+
this.writeByte(k, offset++);
|
|
839
|
+
}
|
|
840
|
+
if (relative) {
|
|
841
|
+
this.offset = offset;
|
|
842
|
+
return this;
|
|
843
|
+
}
|
|
844
|
+
return offset - start;
|
|
845
|
+
};
|
|
846
|
+
ByteBufferPrototype.readBitSet = function(offset) {
|
|
847
|
+
var relative = typeof offset === "undefined";
|
|
848
|
+
if (relative) offset = this.offset;
|
|
849
|
+
var ret = this.readVarint32(offset), bits = ret.value, bytes = bits >> 3, bit = 0, value = [], k;
|
|
850
|
+
offset += ret.length;
|
|
851
|
+
while (bytes--) {
|
|
852
|
+
k = this.readByte(offset++);
|
|
853
|
+
value[bit++] = !!(k & 1);
|
|
854
|
+
value[bit++] = !!(k & 2);
|
|
855
|
+
value[bit++] = !!(k & 4);
|
|
856
|
+
value[bit++] = !!(k & 8);
|
|
857
|
+
value[bit++] = !!(k & 16);
|
|
858
|
+
value[bit++] = !!(k & 32);
|
|
859
|
+
value[bit++] = !!(k & 64);
|
|
860
|
+
value[bit++] = !!(k & 128);
|
|
861
|
+
}
|
|
862
|
+
if (bit < bits) {
|
|
863
|
+
var m = 0;
|
|
864
|
+
k = this.readByte(offset++);
|
|
865
|
+
while (bit < bits) value[bit++] = !!(k >> m++ & 1);
|
|
866
|
+
}
|
|
867
|
+
if (relative) {
|
|
868
|
+
this.offset = offset;
|
|
869
|
+
}
|
|
870
|
+
return value;
|
|
871
|
+
};
|
|
872
|
+
ByteBufferPrototype.readBytes = function(length, offset) {
|
|
873
|
+
var relative = typeof offset === "undefined";
|
|
874
|
+
if (relative) offset = this.offset;
|
|
875
|
+
if (!this.noAssert) {
|
|
876
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
877
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
878
|
+
offset >>>= 0;
|
|
879
|
+
if (offset < 0 || offset + length > this.buffer.byteLength)
|
|
880
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+" + length + ") <= " + this.buffer.byteLength);
|
|
881
|
+
}
|
|
882
|
+
var slice = this.slice(offset, offset + length);
|
|
883
|
+
if (relative) this.offset += length;
|
|
884
|
+
return slice;
|
|
885
|
+
};
|
|
886
|
+
ByteBufferPrototype.writeBytes = ByteBufferPrototype.append;
|
|
887
|
+
ByteBufferPrototype.writeInt8 = function(value, offset) {
|
|
888
|
+
var relative = typeof offset === "undefined";
|
|
889
|
+
if (relative) offset = this.offset;
|
|
890
|
+
if (!this.noAssert) {
|
|
891
|
+
if (typeof value !== "number" || value % 1 !== 0)
|
|
892
|
+
throw TypeError("Illegal value: " + value + " (not an integer)");
|
|
893
|
+
value |= 0;
|
|
894
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
895
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
896
|
+
offset >>>= 0;
|
|
897
|
+
if (offset < 0 || offset + 0 > this.buffer.byteLength)
|
|
898
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+0) <= " + this.buffer.byteLength);
|
|
899
|
+
}
|
|
900
|
+
offset += 1;
|
|
901
|
+
var capacity0 = this.buffer.byteLength;
|
|
902
|
+
if (offset > capacity0)
|
|
903
|
+
this.resize((capacity0 *= 2) > offset ? capacity0 : offset);
|
|
904
|
+
offset -= 1;
|
|
905
|
+
this.view[offset] = value;
|
|
906
|
+
if (relative) this.offset += 1;
|
|
907
|
+
return this;
|
|
908
|
+
};
|
|
909
|
+
ByteBufferPrototype.writeByte = ByteBufferPrototype.writeInt8;
|
|
910
|
+
ByteBufferPrototype.readInt8 = function(offset) {
|
|
911
|
+
var relative = typeof offset === "undefined";
|
|
912
|
+
if (relative) offset = this.offset;
|
|
913
|
+
if (!this.noAssert) {
|
|
914
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
915
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
916
|
+
offset >>>= 0;
|
|
917
|
+
if (offset < 0 || offset + 1 > this.buffer.byteLength)
|
|
918
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+1) <= " + this.buffer.byteLength);
|
|
919
|
+
}
|
|
920
|
+
var value = this.view[offset];
|
|
921
|
+
if ((value & 128) === 128) value = -(255 - value + 1);
|
|
922
|
+
if (relative) this.offset += 1;
|
|
923
|
+
return value;
|
|
924
|
+
};
|
|
925
|
+
ByteBufferPrototype.readByte = ByteBufferPrototype.readInt8;
|
|
926
|
+
ByteBufferPrototype.writeUint8 = function(value, offset) {
|
|
927
|
+
var relative = typeof offset === "undefined";
|
|
928
|
+
if (relative) offset = this.offset;
|
|
929
|
+
if (!this.noAssert) {
|
|
930
|
+
if (typeof value !== "number" || value % 1 !== 0)
|
|
931
|
+
throw TypeError("Illegal value: " + value + " (not an integer)");
|
|
932
|
+
value >>>= 0;
|
|
933
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
934
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
935
|
+
offset >>>= 0;
|
|
936
|
+
if (offset < 0 || offset + 0 > this.buffer.byteLength)
|
|
937
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+0) <= " + this.buffer.byteLength);
|
|
938
|
+
}
|
|
939
|
+
offset += 1;
|
|
940
|
+
var capacity1 = this.buffer.byteLength;
|
|
941
|
+
if (offset > capacity1)
|
|
942
|
+
this.resize((capacity1 *= 2) > offset ? capacity1 : offset);
|
|
943
|
+
offset -= 1;
|
|
944
|
+
this.view[offset] = value;
|
|
945
|
+
if (relative) this.offset += 1;
|
|
946
|
+
return this;
|
|
947
|
+
};
|
|
948
|
+
ByteBufferPrototype.writeUInt8 = ByteBufferPrototype.writeUint8;
|
|
949
|
+
ByteBufferPrototype.readUint8 = function(offset) {
|
|
950
|
+
var relative = typeof offset === "undefined";
|
|
951
|
+
if (relative) offset = this.offset;
|
|
952
|
+
if (!this.noAssert) {
|
|
953
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
954
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
955
|
+
offset >>>= 0;
|
|
956
|
+
if (offset < 0 || offset + 1 > this.buffer.byteLength)
|
|
957
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+1) <= " + this.buffer.byteLength);
|
|
958
|
+
}
|
|
959
|
+
var value = this.view[offset];
|
|
960
|
+
if (relative) this.offset += 1;
|
|
961
|
+
return value;
|
|
962
|
+
};
|
|
963
|
+
ByteBufferPrototype.readUInt8 = ByteBufferPrototype.readUint8;
|
|
964
|
+
ByteBufferPrototype.writeInt16 = function(value, offset) {
|
|
965
|
+
var relative = typeof offset === "undefined";
|
|
966
|
+
if (relative) offset = this.offset;
|
|
967
|
+
if (!this.noAssert) {
|
|
968
|
+
if (typeof value !== "number" || value % 1 !== 0)
|
|
969
|
+
throw TypeError("Illegal value: " + value + " (not an integer)");
|
|
970
|
+
value |= 0;
|
|
971
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
972
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
973
|
+
offset >>>= 0;
|
|
974
|
+
if (offset < 0 || offset + 0 > this.buffer.byteLength)
|
|
975
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+0) <= " + this.buffer.byteLength);
|
|
976
|
+
}
|
|
977
|
+
offset += 2;
|
|
978
|
+
var capacity2 = this.buffer.byteLength;
|
|
979
|
+
if (offset > capacity2)
|
|
980
|
+
this.resize((capacity2 *= 2) > offset ? capacity2 : offset);
|
|
981
|
+
offset -= 2;
|
|
982
|
+
if (this.littleEndian) {
|
|
983
|
+
this.view[offset + 1] = (value & 65280) >>> 8;
|
|
984
|
+
this.view[offset] = value & 255;
|
|
985
|
+
} else {
|
|
986
|
+
this.view[offset] = (value & 65280) >>> 8;
|
|
987
|
+
this.view[offset + 1] = value & 255;
|
|
988
|
+
}
|
|
989
|
+
if (relative) this.offset += 2;
|
|
990
|
+
return this;
|
|
991
|
+
};
|
|
992
|
+
ByteBufferPrototype.writeShort = ByteBufferPrototype.writeInt16;
|
|
993
|
+
ByteBufferPrototype.readInt16 = function(offset) {
|
|
994
|
+
var relative = typeof offset === "undefined";
|
|
995
|
+
if (relative) offset = this.offset;
|
|
996
|
+
if (!this.noAssert) {
|
|
997
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
998
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
999
|
+
offset >>>= 0;
|
|
1000
|
+
if (offset < 0 || offset + 2 > this.buffer.byteLength)
|
|
1001
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+2) <= " + this.buffer.byteLength);
|
|
1002
|
+
}
|
|
1003
|
+
var value = 0;
|
|
1004
|
+
if (this.littleEndian) {
|
|
1005
|
+
value = this.view[offset];
|
|
1006
|
+
value |= this.view[offset + 1] << 8;
|
|
1007
|
+
} else {
|
|
1008
|
+
value = this.view[offset] << 8;
|
|
1009
|
+
value |= this.view[offset + 1];
|
|
1010
|
+
}
|
|
1011
|
+
if ((value & 32768) === 32768) value = -(65535 - value + 1);
|
|
1012
|
+
if (relative) this.offset += 2;
|
|
1013
|
+
return value;
|
|
1014
|
+
};
|
|
1015
|
+
ByteBufferPrototype.readShort = ByteBufferPrototype.readInt16;
|
|
1016
|
+
ByteBufferPrototype.writeUint16 = function(value, offset) {
|
|
1017
|
+
var relative = typeof offset === "undefined";
|
|
1018
|
+
if (relative) offset = this.offset;
|
|
1019
|
+
if (!this.noAssert) {
|
|
1020
|
+
if (typeof value !== "number" || value % 1 !== 0)
|
|
1021
|
+
throw TypeError("Illegal value: " + value + " (not an integer)");
|
|
1022
|
+
value >>>= 0;
|
|
1023
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
1024
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
1025
|
+
offset >>>= 0;
|
|
1026
|
+
if (offset < 0 || offset + 0 > this.buffer.byteLength)
|
|
1027
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+0) <= " + this.buffer.byteLength);
|
|
1028
|
+
}
|
|
1029
|
+
offset += 2;
|
|
1030
|
+
var capacity3 = this.buffer.byteLength;
|
|
1031
|
+
if (offset > capacity3)
|
|
1032
|
+
this.resize((capacity3 *= 2) > offset ? capacity3 : offset);
|
|
1033
|
+
offset -= 2;
|
|
1034
|
+
if (this.littleEndian) {
|
|
1035
|
+
this.view[offset + 1] = (value & 65280) >>> 8;
|
|
1036
|
+
this.view[offset] = value & 255;
|
|
1037
|
+
} else {
|
|
1038
|
+
this.view[offset] = (value & 65280) >>> 8;
|
|
1039
|
+
this.view[offset + 1] = value & 255;
|
|
1040
|
+
}
|
|
1041
|
+
if (relative) this.offset += 2;
|
|
1042
|
+
return this;
|
|
1043
|
+
};
|
|
1044
|
+
ByteBufferPrototype.writeUInt16 = ByteBufferPrototype.writeUint16;
|
|
1045
|
+
ByteBufferPrototype.readUint16 = function(offset) {
|
|
1046
|
+
var relative = typeof offset === "undefined";
|
|
1047
|
+
if (relative) offset = this.offset;
|
|
1048
|
+
if (!this.noAssert) {
|
|
1049
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
1050
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
1051
|
+
offset >>>= 0;
|
|
1052
|
+
if (offset < 0 || offset + 2 > this.buffer.byteLength)
|
|
1053
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+2) <= " + this.buffer.byteLength);
|
|
1054
|
+
}
|
|
1055
|
+
var value = 0;
|
|
1056
|
+
if (this.littleEndian) {
|
|
1057
|
+
value = this.view[offset];
|
|
1058
|
+
value |= this.view[offset + 1] << 8;
|
|
1059
|
+
} else {
|
|
1060
|
+
value = this.view[offset] << 8;
|
|
1061
|
+
value |= this.view[offset + 1];
|
|
1062
|
+
}
|
|
1063
|
+
if (relative) this.offset += 2;
|
|
1064
|
+
return value;
|
|
1065
|
+
};
|
|
1066
|
+
ByteBufferPrototype.readUInt16 = ByteBufferPrototype.readUint16;
|
|
1067
|
+
ByteBufferPrototype.writeInt32 = function(value, offset) {
|
|
1068
|
+
var relative = typeof offset === "undefined";
|
|
1069
|
+
if (relative) offset = this.offset;
|
|
1070
|
+
if (!this.noAssert) {
|
|
1071
|
+
if (typeof value !== "number" || value % 1 !== 0)
|
|
1072
|
+
throw TypeError("Illegal value: " + value + " (not an integer)");
|
|
1073
|
+
value |= 0;
|
|
1074
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
1075
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
1076
|
+
offset >>>= 0;
|
|
1077
|
+
if (offset < 0 || offset + 0 > this.buffer.byteLength)
|
|
1078
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+0) <= " + this.buffer.byteLength);
|
|
1079
|
+
}
|
|
1080
|
+
offset += 4;
|
|
1081
|
+
var capacity4 = this.buffer.byteLength;
|
|
1082
|
+
if (offset > capacity4)
|
|
1083
|
+
this.resize((capacity4 *= 2) > offset ? capacity4 : offset);
|
|
1084
|
+
offset -= 4;
|
|
1085
|
+
if (this.littleEndian) {
|
|
1086
|
+
this.view[offset + 3] = value >>> 24 & 255;
|
|
1087
|
+
this.view[offset + 2] = value >>> 16 & 255;
|
|
1088
|
+
this.view[offset + 1] = value >>> 8 & 255;
|
|
1089
|
+
this.view[offset] = value & 255;
|
|
1090
|
+
} else {
|
|
1091
|
+
this.view[offset] = value >>> 24 & 255;
|
|
1092
|
+
this.view[offset + 1] = value >>> 16 & 255;
|
|
1093
|
+
this.view[offset + 2] = value >>> 8 & 255;
|
|
1094
|
+
this.view[offset + 3] = value & 255;
|
|
1095
|
+
}
|
|
1096
|
+
if (relative) this.offset += 4;
|
|
1097
|
+
return this;
|
|
1098
|
+
};
|
|
1099
|
+
ByteBufferPrototype.writeInt = ByteBufferPrototype.writeInt32;
|
|
1100
|
+
ByteBufferPrototype.readInt32 = function(offset) {
|
|
1101
|
+
var relative = typeof offset === "undefined";
|
|
1102
|
+
if (relative) offset = this.offset;
|
|
1103
|
+
if (!this.noAssert) {
|
|
1104
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
1105
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
1106
|
+
offset >>>= 0;
|
|
1107
|
+
if (offset < 0 || offset + 4 > this.buffer.byteLength)
|
|
1108
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+4) <= " + this.buffer.byteLength);
|
|
1109
|
+
}
|
|
1110
|
+
var value = 0;
|
|
1111
|
+
if (this.littleEndian) {
|
|
1112
|
+
value = this.view[offset + 2] << 16;
|
|
1113
|
+
value |= this.view[offset + 1] << 8;
|
|
1114
|
+
value |= this.view[offset];
|
|
1115
|
+
value += this.view[offset + 3] << 24 >>> 0;
|
|
1116
|
+
} else {
|
|
1117
|
+
value = this.view[offset + 1] << 16;
|
|
1118
|
+
value |= this.view[offset + 2] << 8;
|
|
1119
|
+
value |= this.view[offset + 3];
|
|
1120
|
+
value += this.view[offset] << 24 >>> 0;
|
|
1121
|
+
}
|
|
1122
|
+
value |= 0;
|
|
1123
|
+
if (relative) this.offset += 4;
|
|
1124
|
+
return value;
|
|
1125
|
+
};
|
|
1126
|
+
ByteBufferPrototype.readInt = ByteBufferPrototype.readInt32;
|
|
1127
|
+
ByteBufferPrototype.writeUint32 = function(value, offset) {
|
|
1128
|
+
var relative = typeof offset === "undefined";
|
|
1129
|
+
if (relative) offset = this.offset;
|
|
1130
|
+
if (!this.noAssert) {
|
|
1131
|
+
if (typeof value !== "number" || value % 1 !== 0)
|
|
1132
|
+
throw TypeError("Illegal value: " + value + " (not an integer)");
|
|
1133
|
+
value >>>= 0;
|
|
1134
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
1135
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
1136
|
+
offset >>>= 0;
|
|
1137
|
+
if (offset < 0 || offset + 0 > this.buffer.byteLength)
|
|
1138
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+0) <= " + this.buffer.byteLength);
|
|
1139
|
+
}
|
|
1140
|
+
offset += 4;
|
|
1141
|
+
var capacity5 = this.buffer.byteLength;
|
|
1142
|
+
if (offset > capacity5)
|
|
1143
|
+
this.resize((capacity5 *= 2) > offset ? capacity5 : offset);
|
|
1144
|
+
offset -= 4;
|
|
1145
|
+
if (this.littleEndian) {
|
|
1146
|
+
this.view[offset + 3] = value >>> 24 & 255;
|
|
1147
|
+
this.view[offset + 2] = value >>> 16 & 255;
|
|
1148
|
+
this.view[offset + 1] = value >>> 8 & 255;
|
|
1149
|
+
this.view[offset] = value & 255;
|
|
1150
|
+
} else {
|
|
1151
|
+
this.view[offset] = value >>> 24 & 255;
|
|
1152
|
+
this.view[offset + 1] = value >>> 16 & 255;
|
|
1153
|
+
this.view[offset + 2] = value >>> 8 & 255;
|
|
1154
|
+
this.view[offset + 3] = value & 255;
|
|
1155
|
+
}
|
|
1156
|
+
if (relative) this.offset += 4;
|
|
1157
|
+
return this;
|
|
1158
|
+
};
|
|
1159
|
+
ByteBufferPrototype.writeUInt32 = ByteBufferPrototype.writeUint32;
|
|
1160
|
+
ByteBufferPrototype.readUint32 = function(offset) {
|
|
1161
|
+
var relative = typeof offset === "undefined";
|
|
1162
|
+
if (relative) offset = this.offset;
|
|
1163
|
+
if (!this.noAssert) {
|
|
1164
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
1165
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
1166
|
+
offset >>>= 0;
|
|
1167
|
+
if (offset < 0 || offset + 4 > this.buffer.byteLength)
|
|
1168
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+4) <= " + this.buffer.byteLength);
|
|
1169
|
+
}
|
|
1170
|
+
var value = 0;
|
|
1171
|
+
if (this.littleEndian) {
|
|
1172
|
+
value = this.view[offset + 2] << 16;
|
|
1173
|
+
value |= this.view[offset + 1] << 8;
|
|
1174
|
+
value |= this.view[offset];
|
|
1175
|
+
value += this.view[offset + 3] << 24 >>> 0;
|
|
1176
|
+
} else {
|
|
1177
|
+
value = this.view[offset + 1] << 16;
|
|
1178
|
+
value |= this.view[offset + 2] << 8;
|
|
1179
|
+
value |= this.view[offset + 3];
|
|
1180
|
+
value += this.view[offset] << 24 >>> 0;
|
|
1181
|
+
}
|
|
1182
|
+
if (relative) this.offset += 4;
|
|
1183
|
+
return value;
|
|
1184
|
+
};
|
|
1185
|
+
ByteBufferPrototype.readUInt32 = ByteBufferPrototype.readUint32;
|
|
1186
|
+
if (Long) {
|
|
1187
|
+
ByteBufferPrototype.writeInt64 = function(value, offset) {
|
|
1188
|
+
var relative = typeof offset === "undefined";
|
|
1189
|
+
if (relative) offset = this.offset;
|
|
1190
|
+
if (!this.noAssert) {
|
|
1191
|
+
if (typeof value === "number")
|
|
1192
|
+
value = Long.fromNumber(value);
|
|
1193
|
+
else if (typeof value === "string")
|
|
1194
|
+
value = Long.fromString(value);
|
|
1195
|
+
else if (!(value && value instanceof Long))
|
|
1196
|
+
throw TypeError("Illegal value: " + value + " (not an integer or Long)");
|
|
1197
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
1198
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
1199
|
+
offset >>>= 0;
|
|
1200
|
+
if (offset < 0 || offset + 0 > this.buffer.byteLength)
|
|
1201
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+0) <= " + this.buffer.byteLength);
|
|
1202
|
+
}
|
|
1203
|
+
if (typeof value === "number")
|
|
1204
|
+
value = Long.fromNumber(value);
|
|
1205
|
+
else if (typeof value === "string")
|
|
1206
|
+
value = Long.fromString(value);
|
|
1207
|
+
offset += 8;
|
|
1208
|
+
var capacity6 = this.buffer.byteLength;
|
|
1209
|
+
if (offset > capacity6)
|
|
1210
|
+
this.resize((capacity6 *= 2) > offset ? capacity6 : offset);
|
|
1211
|
+
offset -= 8;
|
|
1212
|
+
var lo = value.low, hi = value.high;
|
|
1213
|
+
if (this.littleEndian) {
|
|
1214
|
+
this.view[offset + 3] = lo >>> 24 & 255;
|
|
1215
|
+
this.view[offset + 2] = lo >>> 16 & 255;
|
|
1216
|
+
this.view[offset + 1] = lo >>> 8 & 255;
|
|
1217
|
+
this.view[offset] = lo & 255;
|
|
1218
|
+
offset += 4;
|
|
1219
|
+
this.view[offset + 3] = hi >>> 24 & 255;
|
|
1220
|
+
this.view[offset + 2] = hi >>> 16 & 255;
|
|
1221
|
+
this.view[offset + 1] = hi >>> 8 & 255;
|
|
1222
|
+
this.view[offset] = hi & 255;
|
|
1223
|
+
} else {
|
|
1224
|
+
this.view[offset] = hi >>> 24 & 255;
|
|
1225
|
+
this.view[offset + 1] = hi >>> 16 & 255;
|
|
1226
|
+
this.view[offset + 2] = hi >>> 8 & 255;
|
|
1227
|
+
this.view[offset + 3] = hi & 255;
|
|
1228
|
+
offset += 4;
|
|
1229
|
+
this.view[offset] = lo >>> 24 & 255;
|
|
1230
|
+
this.view[offset + 1] = lo >>> 16 & 255;
|
|
1231
|
+
this.view[offset + 2] = lo >>> 8 & 255;
|
|
1232
|
+
this.view[offset + 3] = lo & 255;
|
|
1233
|
+
}
|
|
1234
|
+
if (relative) this.offset += 8;
|
|
1235
|
+
return this;
|
|
1236
|
+
};
|
|
1237
|
+
ByteBufferPrototype.writeLong = ByteBufferPrototype.writeInt64;
|
|
1238
|
+
ByteBufferPrototype.readInt64 = function(offset) {
|
|
1239
|
+
var relative = typeof offset === "undefined";
|
|
1240
|
+
if (relative) offset = this.offset;
|
|
1241
|
+
if (!this.noAssert) {
|
|
1242
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
1243
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
1244
|
+
offset >>>= 0;
|
|
1245
|
+
if (offset < 0 || offset + 8 > this.buffer.byteLength)
|
|
1246
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+8) <= " + this.buffer.byteLength);
|
|
1247
|
+
}
|
|
1248
|
+
var lo = 0, hi = 0;
|
|
1249
|
+
if (this.littleEndian) {
|
|
1250
|
+
lo = this.view[offset + 2] << 16;
|
|
1251
|
+
lo |= this.view[offset + 1] << 8;
|
|
1252
|
+
lo |= this.view[offset];
|
|
1253
|
+
lo += this.view[offset + 3] << 24 >>> 0;
|
|
1254
|
+
offset += 4;
|
|
1255
|
+
hi = this.view[offset + 2] << 16;
|
|
1256
|
+
hi |= this.view[offset + 1] << 8;
|
|
1257
|
+
hi |= this.view[offset];
|
|
1258
|
+
hi += this.view[offset + 3] << 24 >>> 0;
|
|
1259
|
+
} else {
|
|
1260
|
+
hi = this.view[offset + 1] << 16;
|
|
1261
|
+
hi |= this.view[offset + 2] << 8;
|
|
1262
|
+
hi |= this.view[offset + 3];
|
|
1263
|
+
hi += this.view[offset] << 24 >>> 0;
|
|
1264
|
+
offset += 4;
|
|
1265
|
+
lo = this.view[offset + 1] << 16;
|
|
1266
|
+
lo |= this.view[offset + 2] << 8;
|
|
1267
|
+
lo |= this.view[offset + 3];
|
|
1268
|
+
lo += this.view[offset] << 24 >>> 0;
|
|
1269
|
+
}
|
|
1270
|
+
var value = new Long(lo, hi, false);
|
|
1271
|
+
if (relative) this.offset += 8;
|
|
1272
|
+
return value;
|
|
1273
|
+
};
|
|
1274
|
+
ByteBufferPrototype.readLong = ByteBufferPrototype.readInt64;
|
|
1275
|
+
ByteBufferPrototype.writeUint64 = function(value, offset) {
|
|
1276
|
+
var relative = typeof offset === "undefined";
|
|
1277
|
+
if (relative) offset = this.offset;
|
|
1278
|
+
if (!this.noAssert) {
|
|
1279
|
+
if (typeof value === "number")
|
|
1280
|
+
value = Long.fromNumber(value);
|
|
1281
|
+
else if (typeof value === "string")
|
|
1282
|
+
value = Long.fromString(value);
|
|
1283
|
+
else if (!(value && value instanceof Long))
|
|
1284
|
+
throw TypeError("Illegal value: " + value + " (not an integer or Long)");
|
|
1285
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
1286
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
1287
|
+
offset >>>= 0;
|
|
1288
|
+
if (offset < 0 || offset + 0 > this.buffer.byteLength)
|
|
1289
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+0) <= " + this.buffer.byteLength);
|
|
1290
|
+
}
|
|
1291
|
+
if (typeof value === "number")
|
|
1292
|
+
value = Long.fromNumber(value);
|
|
1293
|
+
else if (typeof value === "string")
|
|
1294
|
+
value = Long.fromString(value);
|
|
1295
|
+
offset += 8;
|
|
1296
|
+
var capacity7 = this.buffer.byteLength;
|
|
1297
|
+
if (offset > capacity7)
|
|
1298
|
+
this.resize((capacity7 *= 2) > offset ? capacity7 : offset);
|
|
1299
|
+
offset -= 8;
|
|
1300
|
+
var lo = value.low, hi = value.high;
|
|
1301
|
+
if (this.littleEndian) {
|
|
1302
|
+
this.view[offset + 3] = lo >>> 24 & 255;
|
|
1303
|
+
this.view[offset + 2] = lo >>> 16 & 255;
|
|
1304
|
+
this.view[offset + 1] = lo >>> 8 & 255;
|
|
1305
|
+
this.view[offset] = lo & 255;
|
|
1306
|
+
offset += 4;
|
|
1307
|
+
this.view[offset + 3] = hi >>> 24 & 255;
|
|
1308
|
+
this.view[offset + 2] = hi >>> 16 & 255;
|
|
1309
|
+
this.view[offset + 1] = hi >>> 8 & 255;
|
|
1310
|
+
this.view[offset] = hi & 255;
|
|
1311
|
+
} else {
|
|
1312
|
+
this.view[offset] = hi >>> 24 & 255;
|
|
1313
|
+
this.view[offset + 1] = hi >>> 16 & 255;
|
|
1314
|
+
this.view[offset + 2] = hi >>> 8 & 255;
|
|
1315
|
+
this.view[offset + 3] = hi & 255;
|
|
1316
|
+
offset += 4;
|
|
1317
|
+
this.view[offset] = lo >>> 24 & 255;
|
|
1318
|
+
this.view[offset + 1] = lo >>> 16 & 255;
|
|
1319
|
+
this.view[offset + 2] = lo >>> 8 & 255;
|
|
1320
|
+
this.view[offset + 3] = lo & 255;
|
|
1321
|
+
}
|
|
1322
|
+
if (relative) this.offset += 8;
|
|
1323
|
+
return this;
|
|
1324
|
+
};
|
|
1325
|
+
ByteBufferPrototype.writeUInt64 = ByteBufferPrototype.writeUint64;
|
|
1326
|
+
ByteBufferPrototype.readUint64 = function(offset) {
|
|
1327
|
+
var relative = typeof offset === "undefined";
|
|
1328
|
+
if (relative) offset = this.offset;
|
|
1329
|
+
if (!this.noAssert) {
|
|
1330
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
1331
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
1332
|
+
offset >>>= 0;
|
|
1333
|
+
if (offset < 0 || offset + 8 > this.buffer.byteLength)
|
|
1334
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+8) <= " + this.buffer.byteLength);
|
|
1335
|
+
}
|
|
1336
|
+
var lo = 0, hi = 0;
|
|
1337
|
+
if (this.littleEndian) {
|
|
1338
|
+
lo = this.view[offset + 2] << 16;
|
|
1339
|
+
lo |= this.view[offset + 1] << 8;
|
|
1340
|
+
lo |= this.view[offset];
|
|
1341
|
+
lo += this.view[offset + 3] << 24 >>> 0;
|
|
1342
|
+
offset += 4;
|
|
1343
|
+
hi = this.view[offset + 2] << 16;
|
|
1344
|
+
hi |= this.view[offset + 1] << 8;
|
|
1345
|
+
hi |= this.view[offset];
|
|
1346
|
+
hi += this.view[offset + 3] << 24 >>> 0;
|
|
1347
|
+
} else {
|
|
1348
|
+
hi = this.view[offset + 1] << 16;
|
|
1349
|
+
hi |= this.view[offset + 2] << 8;
|
|
1350
|
+
hi |= this.view[offset + 3];
|
|
1351
|
+
hi += this.view[offset] << 24 >>> 0;
|
|
1352
|
+
offset += 4;
|
|
1353
|
+
lo = this.view[offset + 1] << 16;
|
|
1354
|
+
lo |= this.view[offset + 2] << 8;
|
|
1355
|
+
lo |= this.view[offset + 3];
|
|
1356
|
+
lo += this.view[offset] << 24 >>> 0;
|
|
1357
|
+
}
|
|
1358
|
+
var value = new Long(lo, hi, true);
|
|
1359
|
+
if (relative) this.offset += 8;
|
|
1360
|
+
return value;
|
|
1361
|
+
};
|
|
1362
|
+
ByteBufferPrototype.readUInt64 = ByteBufferPrototype.readUint64;
|
|
1363
|
+
}
|
|
1364
|
+
function ieee754_read(buffer, offset, isLE, mLen, nBytes) {
|
|
1365
|
+
var e, m, eLen = nBytes * 8 - mLen - 1, eMax = (1 << eLen) - 1, eBias = eMax >> 1, nBits = -7, i = isLE ? nBytes - 1 : 0, d = isLE ? -1 : 1, s = buffer[offset + i];
|
|
1366
|
+
i += d;
|
|
1367
|
+
e = s & (1 << -nBits) - 1;
|
|
1368
|
+
s >>= -nBits;
|
|
1369
|
+
nBits += eLen;
|
|
1370
|
+
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {
|
|
1371
|
+
}
|
|
1372
|
+
m = e & (1 << -nBits) - 1;
|
|
1373
|
+
e >>= -nBits;
|
|
1374
|
+
nBits += mLen;
|
|
1375
|
+
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {
|
|
1376
|
+
}
|
|
1377
|
+
if (e === 0) {
|
|
1378
|
+
e = 1 - eBias;
|
|
1379
|
+
} else if (e === eMax) {
|
|
1380
|
+
return m ? NaN : (s ? -1 : 1) * Infinity;
|
|
1381
|
+
} else {
|
|
1382
|
+
m = m + Math.pow(2, mLen);
|
|
1383
|
+
e = e - eBias;
|
|
1384
|
+
}
|
|
1385
|
+
return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
|
|
1386
|
+
}
|
|
1387
|
+
function ieee754_write(buffer, value, offset, isLE, mLen, nBytes) {
|
|
1388
|
+
var e, m, c, eLen = nBytes * 8 - mLen - 1, eMax = (1 << eLen) - 1, eBias = eMax >> 1, rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, i = isLE ? 0 : nBytes - 1, d = isLE ? 1 : -1, s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
|
|
1389
|
+
value = Math.abs(value);
|
|
1390
|
+
if (isNaN(value) || value === Infinity) {
|
|
1391
|
+
m = isNaN(value) ? 1 : 0;
|
|
1392
|
+
e = eMax;
|
|
1393
|
+
} else {
|
|
1394
|
+
e = Math.floor(Math.log(value) / Math.LN2);
|
|
1395
|
+
if (value * (c = Math.pow(2, -e)) < 1) {
|
|
1396
|
+
e--;
|
|
1397
|
+
c *= 2;
|
|
1398
|
+
}
|
|
1399
|
+
if (e + eBias >= 1) {
|
|
1400
|
+
value += rt / c;
|
|
1401
|
+
} else {
|
|
1402
|
+
value += rt * Math.pow(2, 1 - eBias);
|
|
1403
|
+
}
|
|
1404
|
+
if (value * c >= 2) {
|
|
1405
|
+
e++;
|
|
1406
|
+
c /= 2;
|
|
1407
|
+
}
|
|
1408
|
+
if (e + eBias >= eMax) {
|
|
1409
|
+
m = 0;
|
|
1410
|
+
e = eMax;
|
|
1411
|
+
} else if (e + eBias >= 1) {
|
|
1412
|
+
m = (value * c - 1) * Math.pow(2, mLen);
|
|
1413
|
+
e = e + eBias;
|
|
1414
|
+
} else {
|
|
1415
|
+
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
|
|
1416
|
+
e = 0;
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
|
|
1420
|
+
}
|
|
1421
|
+
e = e << mLen | m;
|
|
1422
|
+
eLen += mLen;
|
|
1423
|
+
for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
|
|
1424
|
+
}
|
|
1425
|
+
buffer[offset + i - d] |= s * 128;
|
|
1426
|
+
}
|
|
1427
|
+
ByteBufferPrototype.writeFloat32 = function(value, offset) {
|
|
1428
|
+
var relative = typeof offset === "undefined";
|
|
1429
|
+
if (relative) offset = this.offset;
|
|
1430
|
+
if (!this.noAssert) {
|
|
1431
|
+
if (typeof value !== "number")
|
|
1432
|
+
throw TypeError("Illegal value: " + value + " (not a number)");
|
|
1433
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
1434
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
1435
|
+
offset >>>= 0;
|
|
1436
|
+
if (offset < 0 || offset + 0 > this.buffer.byteLength)
|
|
1437
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+0) <= " + this.buffer.byteLength);
|
|
1438
|
+
}
|
|
1439
|
+
offset += 4;
|
|
1440
|
+
var capacity8 = this.buffer.byteLength;
|
|
1441
|
+
if (offset > capacity8)
|
|
1442
|
+
this.resize((capacity8 *= 2) > offset ? capacity8 : offset);
|
|
1443
|
+
offset -= 4;
|
|
1444
|
+
ieee754_write(this.view, value, offset, this.littleEndian, 23, 4);
|
|
1445
|
+
if (relative) this.offset += 4;
|
|
1446
|
+
return this;
|
|
1447
|
+
};
|
|
1448
|
+
ByteBufferPrototype.writeFloat = ByteBufferPrototype.writeFloat32;
|
|
1449
|
+
ByteBufferPrototype.readFloat32 = function(offset) {
|
|
1450
|
+
var relative = typeof offset === "undefined";
|
|
1451
|
+
if (relative) offset = this.offset;
|
|
1452
|
+
if (!this.noAssert) {
|
|
1453
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
1454
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
1455
|
+
offset >>>= 0;
|
|
1456
|
+
if (offset < 0 || offset + 4 > this.buffer.byteLength)
|
|
1457
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+4) <= " + this.buffer.byteLength);
|
|
1458
|
+
}
|
|
1459
|
+
var value = ieee754_read(this.view, offset, this.littleEndian, 23, 4);
|
|
1460
|
+
if (relative) this.offset += 4;
|
|
1461
|
+
return value;
|
|
1462
|
+
};
|
|
1463
|
+
ByteBufferPrototype.readFloat = ByteBufferPrototype.readFloat32;
|
|
1464
|
+
ByteBufferPrototype.writeFloat64 = function(value, offset) {
|
|
1465
|
+
var relative = typeof offset === "undefined";
|
|
1466
|
+
if (relative) offset = this.offset;
|
|
1467
|
+
if (!this.noAssert) {
|
|
1468
|
+
if (typeof value !== "number")
|
|
1469
|
+
throw TypeError("Illegal value: " + value + " (not a number)");
|
|
1470
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
1471
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
1472
|
+
offset >>>= 0;
|
|
1473
|
+
if (offset < 0 || offset + 0 > this.buffer.byteLength)
|
|
1474
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+0) <= " + this.buffer.byteLength);
|
|
1475
|
+
}
|
|
1476
|
+
offset += 8;
|
|
1477
|
+
var capacity9 = this.buffer.byteLength;
|
|
1478
|
+
if (offset > capacity9)
|
|
1479
|
+
this.resize((capacity9 *= 2) > offset ? capacity9 : offset);
|
|
1480
|
+
offset -= 8;
|
|
1481
|
+
ieee754_write(this.view, value, offset, this.littleEndian, 52, 8);
|
|
1482
|
+
if (relative) this.offset += 8;
|
|
1483
|
+
return this;
|
|
1484
|
+
};
|
|
1485
|
+
ByteBufferPrototype.writeDouble = ByteBufferPrototype.writeFloat64;
|
|
1486
|
+
ByteBufferPrototype.readFloat64 = function(offset) {
|
|
1487
|
+
var relative = typeof offset === "undefined";
|
|
1488
|
+
if (relative) offset = this.offset;
|
|
1489
|
+
if (!this.noAssert) {
|
|
1490
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
1491
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
1492
|
+
offset >>>= 0;
|
|
1493
|
+
if (offset < 0 || offset + 8 > this.buffer.byteLength)
|
|
1494
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+8) <= " + this.buffer.byteLength);
|
|
1495
|
+
}
|
|
1496
|
+
var value = ieee754_read(this.view, offset, this.littleEndian, 52, 8);
|
|
1497
|
+
if (relative) this.offset += 8;
|
|
1498
|
+
return value;
|
|
1499
|
+
};
|
|
1500
|
+
ByteBufferPrototype.readDouble = ByteBufferPrototype.readFloat64;
|
|
1501
|
+
ByteBuffer2.MAX_VARINT32_BYTES = 5;
|
|
1502
|
+
ByteBuffer2.calculateVarint32 = function(value) {
|
|
1503
|
+
value = value >>> 0;
|
|
1504
|
+
if (value < 1 << 7) return 1;
|
|
1505
|
+
else if (value < 1 << 14) return 2;
|
|
1506
|
+
else if (value < 1 << 21) return 3;
|
|
1507
|
+
else if (value < 1 << 28) return 4;
|
|
1508
|
+
else return 5;
|
|
1509
|
+
};
|
|
1510
|
+
ByteBuffer2.zigZagEncode32 = function(n) {
|
|
1511
|
+
return ((n |= 0) << 1 ^ n >> 31) >>> 0;
|
|
1512
|
+
};
|
|
1513
|
+
ByteBuffer2.zigZagDecode32 = function(n) {
|
|
1514
|
+
return n >>> 1 ^ -(n & 1) | 0;
|
|
1515
|
+
};
|
|
1516
|
+
ByteBufferPrototype.writeVarint32 = function(value, offset) {
|
|
1517
|
+
var relative = typeof offset === "undefined";
|
|
1518
|
+
if (relative) offset = this.offset;
|
|
1519
|
+
if (!this.noAssert) {
|
|
1520
|
+
if (typeof value !== "number" || value % 1 !== 0)
|
|
1521
|
+
throw TypeError("Illegal value: " + value + " (not an integer)");
|
|
1522
|
+
value |= 0;
|
|
1523
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
1524
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
1525
|
+
offset >>>= 0;
|
|
1526
|
+
if (offset < 0 || offset + 0 > this.buffer.byteLength)
|
|
1527
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+0) <= " + this.buffer.byteLength);
|
|
1528
|
+
}
|
|
1529
|
+
var size = ByteBuffer2.calculateVarint32(value), b;
|
|
1530
|
+
offset += size;
|
|
1531
|
+
var capacity10 = this.buffer.byteLength;
|
|
1532
|
+
if (offset > capacity10)
|
|
1533
|
+
this.resize((capacity10 *= 2) > offset ? capacity10 : offset);
|
|
1534
|
+
offset -= size;
|
|
1535
|
+
value >>>= 0;
|
|
1536
|
+
while (value >= 128) {
|
|
1537
|
+
b = value & 127 | 128;
|
|
1538
|
+
this.view[offset++] = b;
|
|
1539
|
+
value >>>= 7;
|
|
1540
|
+
}
|
|
1541
|
+
this.view[offset++] = value;
|
|
1542
|
+
if (relative) {
|
|
1543
|
+
this.offset = offset;
|
|
1544
|
+
return this;
|
|
1545
|
+
}
|
|
1546
|
+
return size;
|
|
1547
|
+
};
|
|
1548
|
+
ByteBufferPrototype.writeVarint32ZigZag = function(value, offset) {
|
|
1549
|
+
return this.writeVarint32(ByteBuffer2.zigZagEncode32(value), offset);
|
|
1550
|
+
};
|
|
1551
|
+
ByteBufferPrototype.readVarint32 = function(offset) {
|
|
1552
|
+
var relative = typeof offset === "undefined";
|
|
1553
|
+
if (relative) offset = this.offset;
|
|
1554
|
+
if (!this.noAssert) {
|
|
1555
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
1556
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
1557
|
+
offset >>>= 0;
|
|
1558
|
+
if (offset < 0 || offset + 1 > this.buffer.byteLength)
|
|
1559
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+1) <= " + this.buffer.byteLength);
|
|
1560
|
+
}
|
|
1561
|
+
var c = 0, value = 0 >>> 0, b;
|
|
1562
|
+
do {
|
|
1563
|
+
if (!this.noAssert && offset > this.limit) {
|
|
1564
|
+
var err = Error("Truncated");
|
|
1565
|
+
err["truncated"] = true;
|
|
1566
|
+
throw err;
|
|
1567
|
+
}
|
|
1568
|
+
b = this.view[offset++];
|
|
1569
|
+
if (c < 5)
|
|
1570
|
+
value |= (b & 127) << 7 * c;
|
|
1571
|
+
++c;
|
|
1572
|
+
} while ((b & 128) !== 0);
|
|
1573
|
+
value |= 0;
|
|
1574
|
+
if (relative) {
|
|
1575
|
+
this.offset = offset;
|
|
1576
|
+
return value;
|
|
1577
|
+
}
|
|
1578
|
+
return {
|
|
1579
|
+
"value": value,
|
|
1580
|
+
"length": c
|
|
1581
|
+
};
|
|
1582
|
+
};
|
|
1583
|
+
ByteBufferPrototype.readVarint32ZigZag = function(offset) {
|
|
1584
|
+
var val = this.readVarint32(offset);
|
|
1585
|
+
if (typeof val === "object")
|
|
1586
|
+
val["value"] = ByteBuffer2.zigZagDecode32(val["value"]);
|
|
1587
|
+
else
|
|
1588
|
+
val = ByteBuffer2.zigZagDecode32(val);
|
|
1589
|
+
return val;
|
|
1590
|
+
};
|
|
1591
|
+
if (Long) {
|
|
1592
|
+
ByteBuffer2.MAX_VARINT64_BYTES = 10;
|
|
1593
|
+
ByteBuffer2.calculateVarint64 = function(value) {
|
|
1594
|
+
if (typeof value === "number")
|
|
1595
|
+
value = Long.fromNumber(value);
|
|
1596
|
+
else if (typeof value === "string")
|
|
1597
|
+
value = Long.fromString(value);
|
|
1598
|
+
var part0 = value.toInt() >>> 0, part1 = value.shiftRightUnsigned(28).toInt() >>> 0, part2 = value.shiftRightUnsigned(56).toInt() >>> 0;
|
|
1599
|
+
if (part2 == 0) {
|
|
1600
|
+
if (part1 == 0) {
|
|
1601
|
+
if (part0 < 1 << 14)
|
|
1602
|
+
return part0 < 1 << 7 ? 1 : 2;
|
|
1603
|
+
else
|
|
1604
|
+
return part0 < 1 << 21 ? 3 : 4;
|
|
1605
|
+
} else {
|
|
1606
|
+
if (part1 < 1 << 14)
|
|
1607
|
+
return part1 < 1 << 7 ? 5 : 6;
|
|
1608
|
+
else
|
|
1609
|
+
return part1 < 1 << 21 ? 7 : 8;
|
|
1610
|
+
}
|
|
1611
|
+
} else
|
|
1612
|
+
return part2 < 1 << 7 ? 9 : 10;
|
|
1613
|
+
};
|
|
1614
|
+
ByteBuffer2.zigZagEncode64 = function(value) {
|
|
1615
|
+
if (typeof value === "number")
|
|
1616
|
+
value = Long.fromNumber(value, false);
|
|
1617
|
+
else if (typeof value === "string")
|
|
1618
|
+
value = Long.fromString(value, false);
|
|
1619
|
+
else if (value.unsigned !== false) value = value.toSigned();
|
|
1620
|
+
return value.shiftLeft(1).xor(value.shiftRight(63)).toUnsigned();
|
|
1621
|
+
};
|
|
1622
|
+
ByteBuffer2.zigZagDecode64 = function(value) {
|
|
1623
|
+
if (typeof value === "number")
|
|
1624
|
+
value = Long.fromNumber(value, false);
|
|
1625
|
+
else if (typeof value === "string")
|
|
1626
|
+
value = Long.fromString(value, false);
|
|
1627
|
+
else if (value.unsigned !== false) value = value.toSigned();
|
|
1628
|
+
return value.shiftRightUnsigned(1).xor(value.and(Long.ONE).toSigned().negate()).toSigned();
|
|
1629
|
+
};
|
|
1630
|
+
ByteBufferPrototype.writeVarint64 = function(value, offset) {
|
|
1631
|
+
var relative = typeof offset === "undefined";
|
|
1632
|
+
if (relative) offset = this.offset;
|
|
1633
|
+
if (!this.noAssert) {
|
|
1634
|
+
if (typeof value === "number")
|
|
1635
|
+
value = Long.fromNumber(value);
|
|
1636
|
+
else if (typeof value === "string")
|
|
1637
|
+
value = Long.fromString(value);
|
|
1638
|
+
else if (!(value && value instanceof Long))
|
|
1639
|
+
throw TypeError("Illegal value: " + value + " (not an integer or Long)");
|
|
1640
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
1641
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
1642
|
+
offset >>>= 0;
|
|
1643
|
+
if (offset < 0 || offset + 0 > this.buffer.byteLength)
|
|
1644
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+0) <= " + this.buffer.byteLength);
|
|
1645
|
+
}
|
|
1646
|
+
if (typeof value === "number")
|
|
1647
|
+
value = Long.fromNumber(value, false);
|
|
1648
|
+
else if (typeof value === "string")
|
|
1649
|
+
value = Long.fromString(value, false);
|
|
1650
|
+
else if (value.unsigned !== false) value = value.toSigned();
|
|
1651
|
+
var size = ByteBuffer2.calculateVarint64(value), part0 = value.toInt() >>> 0, part1 = value.shiftRightUnsigned(28).toInt() >>> 0, part2 = value.shiftRightUnsigned(56).toInt() >>> 0;
|
|
1652
|
+
offset += size;
|
|
1653
|
+
var capacity11 = this.buffer.byteLength;
|
|
1654
|
+
if (offset > capacity11)
|
|
1655
|
+
this.resize((capacity11 *= 2) > offset ? capacity11 : offset);
|
|
1656
|
+
offset -= size;
|
|
1657
|
+
switch (size) {
|
|
1658
|
+
case 10:
|
|
1659
|
+
this.view[offset + 9] = part2 >>> 7 & 1;
|
|
1660
|
+
case 9:
|
|
1661
|
+
this.view[offset + 8] = size !== 9 ? part2 | 128 : part2 & 127;
|
|
1662
|
+
case 8:
|
|
1663
|
+
this.view[offset + 7] = size !== 8 ? part1 >>> 21 | 128 : part1 >>> 21 & 127;
|
|
1664
|
+
case 7:
|
|
1665
|
+
this.view[offset + 6] = size !== 7 ? part1 >>> 14 | 128 : part1 >>> 14 & 127;
|
|
1666
|
+
case 6:
|
|
1667
|
+
this.view[offset + 5] = size !== 6 ? part1 >>> 7 | 128 : part1 >>> 7 & 127;
|
|
1668
|
+
case 5:
|
|
1669
|
+
this.view[offset + 4] = size !== 5 ? part1 | 128 : part1 & 127;
|
|
1670
|
+
case 4:
|
|
1671
|
+
this.view[offset + 3] = size !== 4 ? part0 >>> 21 | 128 : part0 >>> 21 & 127;
|
|
1672
|
+
case 3:
|
|
1673
|
+
this.view[offset + 2] = size !== 3 ? part0 >>> 14 | 128 : part0 >>> 14 & 127;
|
|
1674
|
+
case 2:
|
|
1675
|
+
this.view[offset + 1] = size !== 2 ? part0 >>> 7 | 128 : part0 >>> 7 & 127;
|
|
1676
|
+
case 1:
|
|
1677
|
+
this.view[offset] = size !== 1 ? part0 | 128 : part0 & 127;
|
|
1678
|
+
}
|
|
1679
|
+
if (relative) {
|
|
1680
|
+
this.offset += size;
|
|
1681
|
+
return this;
|
|
1682
|
+
} else {
|
|
1683
|
+
return size;
|
|
1684
|
+
}
|
|
1685
|
+
};
|
|
1686
|
+
ByteBufferPrototype.writeVarint64ZigZag = function(value, offset) {
|
|
1687
|
+
return this.writeVarint64(ByteBuffer2.zigZagEncode64(value), offset);
|
|
1688
|
+
};
|
|
1689
|
+
ByteBufferPrototype.readVarint64 = function(offset) {
|
|
1690
|
+
var relative = typeof offset === "undefined";
|
|
1691
|
+
if (relative) offset = this.offset;
|
|
1692
|
+
if (!this.noAssert) {
|
|
1693
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
1694
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
1695
|
+
offset >>>= 0;
|
|
1696
|
+
if (offset < 0 || offset + 1 > this.buffer.byteLength)
|
|
1697
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+1) <= " + this.buffer.byteLength);
|
|
1698
|
+
}
|
|
1699
|
+
var start = offset, part0 = 0, part1 = 0, part2 = 0, b = 0;
|
|
1700
|
+
b = this.view[offset++];
|
|
1701
|
+
part0 = b & 127;
|
|
1702
|
+
if (b & 128) {
|
|
1703
|
+
b = this.view[offset++];
|
|
1704
|
+
part0 |= (b & 127) << 7;
|
|
1705
|
+
if (b & 128 || this.noAssert && typeof b === "undefined") {
|
|
1706
|
+
b = this.view[offset++];
|
|
1707
|
+
part0 |= (b & 127) << 14;
|
|
1708
|
+
if (b & 128 || this.noAssert && typeof b === "undefined") {
|
|
1709
|
+
b = this.view[offset++];
|
|
1710
|
+
part0 |= (b & 127) << 21;
|
|
1711
|
+
if (b & 128 || this.noAssert && typeof b === "undefined") {
|
|
1712
|
+
b = this.view[offset++];
|
|
1713
|
+
part1 = b & 127;
|
|
1714
|
+
if (b & 128 || this.noAssert && typeof b === "undefined") {
|
|
1715
|
+
b = this.view[offset++];
|
|
1716
|
+
part1 |= (b & 127) << 7;
|
|
1717
|
+
if (b & 128 || this.noAssert && typeof b === "undefined") {
|
|
1718
|
+
b = this.view[offset++];
|
|
1719
|
+
part1 |= (b & 127) << 14;
|
|
1720
|
+
if (b & 128 || this.noAssert && typeof b === "undefined") {
|
|
1721
|
+
b = this.view[offset++];
|
|
1722
|
+
part1 |= (b & 127) << 21;
|
|
1723
|
+
if (b & 128 || this.noAssert && typeof b === "undefined") {
|
|
1724
|
+
b = this.view[offset++];
|
|
1725
|
+
part2 = b & 127;
|
|
1726
|
+
if (b & 128 || this.noAssert && typeof b === "undefined") {
|
|
1727
|
+
b = this.view[offset++];
|
|
1728
|
+
part2 |= (b & 127) << 7;
|
|
1729
|
+
if (b & 128 || this.noAssert && typeof b === "undefined") {
|
|
1730
|
+
throw Error("Buffer overrun");
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
var value = Long.fromBits(part0 | part1 << 28, part1 >>> 4 | part2 << 24, false);
|
|
1742
|
+
if (relative) {
|
|
1743
|
+
this.offset = offset;
|
|
1744
|
+
return value;
|
|
1745
|
+
} else {
|
|
1746
|
+
return {
|
|
1747
|
+
"value": value,
|
|
1748
|
+
"length": offset - start
|
|
1749
|
+
};
|
|
1750
|
+
}
|
|
1751
|
+
};
|
|
1752
|
+
ByteBufferPrototype.readVarint64ZigZag = function(offset) {
|
|
1753
|
+
var val = this.readVarint64(offset);
|
|
1754
|
+
if (val && val["value"] instanceof Long)
|
|
1755
|
+
val["value"] = ByteBuffer2.zigZagDecode64(val["value"]);
|
|
1756
|
+
else
|
|
1757
|
+
val = ByteBuffer2.zigZagDecode64(val);
|
|
1758
|
+
return val;
|
|
1759
|
+
};
|
|
1760
|
+
}
|
|
1761
|
+
ByteBufferPrototype.writeCString = function(str, offset) {
|
|
1762
|
+
var relative = typeof offset === "undefined";
|
|
1763
|
+
if (relative) offset = this.offset;
|
|
1764
|
+
var i, k = str.length;
|
|
1765
|
+
if (!this.noAssert) {
|
|
1766
|
+
if (typeof str !== "string")
|
|
1767
|
+
throw TypeError("Illegal str: Not a string");
|
|
1768
|
+
for (i = 0; i < k; ++i) {
|
|
1769
|
+
if (str.charCodeAt(i) === 0)
|
|
1770
|
+
throw RangeError("Illegal str: Contains NULL-characters");
|
|
1771
|
+
}
|
|
1772
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
1773
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
1774
|
+
offset >>>= 0;
|
|
1775
|
+
if (offset < 0 || offset + 0 > this.buffer.byteLength)
|
|
1776
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+0) <= " + this.buffer.byteLength);
|
|
1777
|
+
}
|
|
1778
|
+
k = utfx.calculateUTF16asUTF8(stringSource(str))[1];
|
|
1779
|
+
offset += k + 1;
|
|
1780
|
+
var capacity12 = this.buffer.byteLength;
|
|
1781
|
+
if (offset > capacity12)
|
|
1782
|
+
this.resize((capacity12 *= 2) > offset ? capacity12 : offset);
|
|
1783
|
+
offset -= k + 1;
|
|
1784
|
+
utfx.encodeUTF16toUTF8(stringSource(str), (function(b) {
|
|
1785
|
+
this.view[offset++] = b;
|
|
1786
|
+
}).bind(this));
|
|
1787
|
+
this.view[offset++] = 0;
|
|
1788
|
+
if (relative) {
|
|
1789
|
+
this.offset = offset;
|
|
1790
|
+
return this;
|
|
1791
|
+
}
|
|
1792
|
+
return k;
|
|
1793
|
+
};
|
|
1794
|
+
ByteBufferPrototype.readCString = function(offset) {
|
|
1795
|
+
var relative = typeof offset === "undefined";
|
|
1796
|
+
if (relative) offset = this.offset;
|
|
1797
|
+
if (!this.noAssert) {
|
|
1798
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
1799
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
1800
|
+
offset >>>= 0;
|
|
1801
|
+
if (offset < 0 || offset + 1 > this.buffer.byteLength)
|
|
1802
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+1) <= " + this.buffer.byteLength);
|
|
1803
|
+
}
|
|
1804
|
+
var start = offset;
|
|
1805
|
+
var sd, b = -1;
|
|
1806
|
+
utfx.decodeUTF8toUTF16((function() {
|
|
1807
|
+
if (b === 0) return null;
|
|
1808
|
+
if (offset >= this.limit)
|
|
1809
|
+
throw RangeError("Illegal range: Truncated data, " + offset + " < " + this.limit);
|
|
1810
|
+
b = this.view[offset++];
|
|
1811
|
+
return b === 0 ? null : b;
|
|
1812
|
+
}).bind(this), sd = stringDestination(), true);
|
|
1813
|
+
if (relative) {
|
|
1814
|
+
this.offset = offset;
|
|
1815
|
+
return sd();
|
|
1816
|
+
} else {
|
|
1817
|
+
return {
|
|
1818
|
+
"string": sd(),
|
|
1819
|
+
"length": offset - start
|
|
1820
|
+
};
|
|
1821
|
+
}
|
|
1822
|
+
};
|
|
1823
|
+
ByteBufferPrototype.writeIString = function(str, offset) {
|
|
1824
|
+
var relative = typeof offset === "undefined";
|
|
1825
|
+
if (relative) offset = this.offset;
|
|
1826
|
+
if (!this.noAssert) {
|
|
1827
|
+
if (typeof str !== "string")
|
|
1828
|
+
throw TypeError("Illegal str: Not a string");
|
|
1829
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
1830
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
1831
|
+
offset >>>= 0;
|
|
1832
|
+
if (offset < 0 || offset + 0 > this.buffer.byteLength)
|
|
1833
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+0) <= " + this.buffer.byteLength);
|
|
1834
|
+
}
|
|
1835
|
+
var start = offset, k;
|
|
1836
|
+
k = utfx.calculateUTF16asUTF8(stringSource(str), this.noAssert)[1];
|
|
1837
|
+
offset += 4 + k;
|
|
1838
|
+
var capacity13 = this.buffer.byteLength;
|
|
1839
|
+
if (offset > capacity13)
|
|
1840
|
+
this.resize((capacity13 *= 2) > offset ? capacity13 : offset);
|
|
1841
|
+
offset -= 4 + k;
|
|
1842
|
+
if (this.littleEndian) {
|
|
1843
|
+
this.view[offset + 3] = k >>> 24 & 255;
|
|
1844
|
+
this.view[offset + 2] = k >>> 16 & 255;
|
|
1845
|
+
this.view[offset + 1] = k >>> 8 & 255;
|
|
1846
|
+
this.view[offset] = k & 255;
|
|
1847
|
+
} else {
|
|
1848
|
+
this.view[offset] = k >>> 24 & 255;
|
|
1849
|
+
this.view[offset + 1] = k >>> 16 & 255;
|
|
1850
|
+
this.view[offset + 2] = k >>> 8 & 255;
|
|
1851
|
+
this.view[offset + 3] = k & 255;
|
|
1852
|
+
}
|
|
1853
|
+
offset += 4;
|
|
1854
|
+
utfx.encodeUTF16toUTF8(stringSource(str), (function(b) {
|
|
1855
|
+
this.view[offset++] = b;
|
|
1856
|
+
}).bind(this));
|
|
1857
|
+
if (offset !== start + 4 + k)
|
|
1858
|
+
throw RangeError("Illegal range: Truncated data, " + offset + " == " + (offset + 4 + k));
|
|
1859
|
+
if (relative) {
|
|
1860
|
+
this.offset = offset;
|
|
1861
|
+
return this;
|
|
1862
|
+
}
|
|
1863
|
+
return offset - start;
|
|
1864
|
+
};
|
|
1865
|
+
ByteBufferPrototype.readIString = function(offset) {
|
|
1866
|
+
var relative = typeof offset === "undefined";
|
|
1867
|
+
if (relative) offset = this.offset;
|
|
1868
|
+
if (!this.noAssert) {
|
|
1869
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
1870
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
1871
|
+
offset >>>= 0;
|
|
1872
|
+
if (offset < 0 || offset + 4 > this.buffer.byteLength)
|
|
1873
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+4) <= " + this.buffer.byteLength);
|
|
1874
|
+
}
|
|
1875
|
+
var start = offset;
|
|
1876
|
+
var len = this.readUint32(offset);
|
|
1877
|
+
var str = this.readUTF8String(len, ByteBuffer2.METRICS_BYTES, offset += 4);
|
|
1878
|
+
offset += str["length"];
|
|
1879
|
+
if (relative) {
|
|
1880
|
+
this.offset = offset;
|
|
1881
|
+
return str["string"];
|
|
1882
|
+
} else {
|
|
1883
|
+
return {
|
|
1884
|
+
"string": str["string"],
|
|
1885
|
+
"length": offset - start
|
|
1886
|
+
};
|
|
1887
|
+
}
|
|
1888
|
+
};
|
|
1889
|
+
ByteBuffer2.METRICS_CHARS = "c";
|
|
1890
|
+
ByteBuffer2.METRICS_BYTES = "b";
|
|
1891
|
+
ByteBufferPrototype.writeUTF8String = function(str, offset) {
|
|
1892
|
+
var relative = typeof offset === "undefined";
|
|
1893
|
+
if (relative) offset = this.offset;
|
|
1894
|
+
if (!this.noAssert) {
|
|
1895
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
1896
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
1897
|
+
offset >>>= 0;
|
|
1898
|
+
if (offset < 0 || offset + 0 > this.buffer.byteLength)
|
|
1899
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+0) <= " + this.buffer.byteLength);
|
|
1900
|
+
}
|
|
1901
|
+
var k;
|
|
1902
|
+
var start = offset;
|
|
1903
|
+
k = utfx.calculateUTF16asUTF8(stringSource(str))[1];
|
|
1904
|
+
offset += k;
|
|
1905
|
+
var capacity14 = this.buffer.byteLength;
|
|
1906
|
+
if (offset > capacity14)
|
|
1907
|
+
this.resize((capacity14 *= 2) > offset ? capacity14 : offset);
|
|
1908
|
+
offset -= k;
|
|
1909
|
+
utfx.encodeUTF16toUTF8(stringSource(str), (function(b) {
|
|
1910
|
+
this.view[offset++] = b;
|
|
1911
|
+
}).bind(this));
|
|
1912
|
+
if (relative) {
|
|
1913
|
+
this.offset = offset;
|
|
1914
|
+
return this;
|
|
1915
|
+
}
|
|
1916
|
+
return offset - start;
|
|
1917
|
+
};
|
|
1918
|
+
ByteBufferPrototype.writeString = ByteBufferPrototype.writeUTF8String;
|
|
1919
|
+
ByteBuffer2.calculateUTF8Chars = function(str) {
|
|
1920
|
+
return utfx.calculateUTF16asUTF8(stringSource(str))[0];
|
|
1921
|
+
};
|
|
1922
|
+
ByteBuffer2.calculateUTF8Bytes = function(str) {
|
|
1923
|
+
return utfx.calculateUTF16asUTF8(stringSource(str))[1];
|
|
1924
|
+
};
|
|
1925
|
+
ByteBuffer2.calculateString = ByteBuffer2.calculateUTF8Bytes;
|
|
1926
|
+
ByteBufferPrototype.readUTF8String = function(length, metrics, offset) {
|
|
1927
|
+
if (typeof metrics === "number") {
|
|
1928
|
+
offset = metrics;
|
|
1929
|
+
metrics = void 0;
|
|
1930
|
+
}
|
|
1931
|
+
var relative = typeof offset === "undefined";
|
|
1932
|
+
if (relative) offset = this.offset;
|
|
1933
|
+
if (typeof metrics === "undefined") metrics = ByteBuffer2.METRICS_CHARS;
|
|
1934
|
+
if (!this.noAssert) {
|
|
1935
|
+
if (typeof length !== "number" || length % 1 !== 0)
|
|
1936
|
+
throw TypeError("Illegal length: " + length + " (not an integer)");
|
|
1937
|
+
length |= 0;
|
|
1938
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
1939
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
1940
|
+
offset >>>= 0;
|
|
1941
|
+
if (offset < 0 || offset + 0 > this.buffer.byteLength)
|
|
1942
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+0) <= " + this.buffer.byteLength);
|
|
1943
|
+
}
|
|
1944
|
+
var i = 0, start = offset, sd;
|
|
1945
|
+
if (metrics === ByteBuffer2.METRICS_CHARS) {
|
|
1946
|
+
sd = stringDestination();
|
|
1947
|
+
utfx.decodeUTF8((function() {
|
|
1948
|
+
return i < length && offset < this.limit ? this.view[offset++] : null;
|
|
1949
|
+
}).bind(this), function(cp) {
|
|
1950
|
+
++i;
|
|
1951
|
+
utfx.UTF8toUTF16(cp, sd);
|
|
1952
|
+
});
|
|
1953
|
+
if (i !== length)
|
|
1954
|
+
throw RangeError("Illegal range: Truncated data, " + i + " == " + length);
|
|
1955
|
+
if (relative) {
|
|
1956
|
+
this.offset = offset;
|
|
1957
|
+
return sd();
|
|
1958
|
+
} else {
|
|
1959
|
+
return {
|
|
1960
|
+
"string": sd(),
|
|
1961
|
+
"length": offset - start
|
|
1962
|
+
};
|
|
1963
|
+
}
|
|
1964
|
+
} else if (metrics === ByteBuffer2.METRICS_BYTES) {
|
|
1965
|
+
if (!this.noAssert) {
|
|
1966
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
1967
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
1968
|
+
offset >>>= 0;
|
|
1969
|
+
if (offset < 0 || offset + length > this.buffer.byteLength)
|
|
1970
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+" + length + ") <= " + this.buffer.byteLength);
|
|
1971
|
+
}
|
|
1972
|
+
var k = offset + length;
|
|
1973
|
+
utfx.decodeUTF8toUTF16((function() {
|
|
1974
|
+
return offset < k ? this.view[offset++] : null;
|
|
1975
|
+
}).bind(this), sd = stringDestination(), this.noAssert);
|
|
1976
|
+
if (offset !== k)
|
|
1977
|
+
throw RangeError("Illegal range: Truncated data, " + offset + " == " + k);
|
|
1978
|
+
if (relative) {
|
|
1979
|
+
this.offset = offset;
|
|
1980
|
+
return sd();
|
|
1981
|
+
} else {
|
|
1982
|
+
return {
|
|
1983
|
+
"string": sd(),
|
|
1984
|
+
"length": offset - start
|
|
1985
|
+
};
|
|
1986
|
+
}
|
|
1987
|
+
} else
|
|
1988
|
+
throw TypeError("Unsupported metrics: " + metrics);
|
|
1989
|
+
};
|
|
1990
|
+
ByteBufferPrototype.readString = ByteBufferPrototype.readUTF8String;
|
|
1991
|
+
ByteBufferPrototype.writeVString = function(str, offset) {
|
|
1992
|
+
var relative = typeof offset === "undefined";
|
|
1993
|
+
if (relative) offset = this.offset;
|
|
1994
|
+
if (!this.noAssert) {
|
|
1995
|
+
if (typeof str !== "string")
|
|
1996
|
+
throw TypeError("Illegal str: Not a string");
|
|
1997
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
1998
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
1999
|
+
offset >>>= 0;
|
|
2000
|
+
if (offset < 0 || offset + 0 > this.buffer.byteLength)
|
|
2001
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+0) <= " + this.buffer.byteLength);
|
|
2002
|
+
}
|
|
2003
|
+
var start = offset, k, l;
|
|
2004
|
+
k = utfx.calculateUTF16asUTF8(stringSource(str), this.noAssert)[1];
|
|
2005
|
+
l = ByteBuffer2.calculateVarint32(k);
|
|
2006
|
+
offset += l + k;
|
|
2007
|
+
var capacity15 = this.buffer.byteLength;
|
|
2008
|
+
if (offset > capacity15)
|
|
2009
|
+
this.resize((capacity15 *= 2) > offset ? capacity15 : offset);
|
|
2010
|
+
offset -= l + k;
|
|
2011
|
+
offset += this.writeVarint32(k, offset);
|
|
2012
|
+
utfx.encodeUTF16toUTF8(stringSource(str), (function(b) {
|
|
2013
|
+
this.view[offset++] = b;
|
|
2014
|
+
}).bind(this));
|
|
2015
|
+
if (offset !== start + k + l)
|
|
2016
|
+
throw RangeError("Illegal range: Truncated data, " + offset + " == " + (offset + k + l));
|
|
2017
|
+
if (relative) {
|
|
2018
|
+
this.offset = offset;
|
|
2019
|
+
return this;
|
|
2020
|
+
}
|
|
2021
|
+
return offset - start;
|
|
2022
|
+
};
|
|
2023
|
+
ByteBufferPrototype.readVString = function(offset) {
|
|
2024
|
+
var relative = typeof offset === "undefined";
|
|
2025
|
+
if (relative) offset = this.offset;
|
|
2026
|
+
if (!this.noAssert) {
|
|
2027
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
2028
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
2029
|
+
offset >>>= 0;
|
|
2030
|
+
if (offset < 0 || offset + 1 > this.buffer.byteLength)
|
|
2031
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+1) <= " + this.buffer.byteLength);
|
|
2032
|
+
}
|
|
2033
|
+
var start = offset;
|
|
2034
|
+
var len = this.readVarint32(offset);
|
|
2035
|
+
var str = this.readUTF8String(len["value"], ByteBuffer2.METRICS_BYTES, offset += len["length"]);
|
|
2036
|
+
offset += str["length"];
|
|
2037
|
+
if (relative) {
|
|
2038
|
+
this.offset = offset;
|
|
2039
|
+
return str["string"];
|
|
2040
|
+
} else {
|
|
2041
|
+
return {
|
|
2042
|
+
"string": str["string"],
|
|
2043
|
+
"length": offset - start
|
|
2044
|
+
};
|
|
2045
|
+
}
|
|
2046
|
+
};
|
|
2047
|
+
ByteBufferPrototype.append = function(source, encoding, offset) {
|
|
2048
|
+
if (typeof encoding === "number" || typeof encoding !== "string") {
|
|
2049
|
+
offset = encoding;
|
|
2050
|
+
encoding = void 0;
|
|
2051
|
+
}
|
|
2052
|
+
var relative = typeof offset === "undefined";
|
|
2053
|
+
if (relative) offset = this.offset;
|
|
2054
|
+
if (!this.noAssert) {
|
|
2055
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
2056
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
2057
|
+
offset >>>= 0;
|
|
2058
|
+
if (offset < 0 || offset + 0 > this.buffer.byteLength)
|
|
2059
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+0) <= " + this.buffer.byteLength);
|
|
2060
|
+
}
|
|
2061
|
+
if (!(source instanceof ByteBuffer2))
|
|
2062
|
+
source = ByteBuffer2.wrap(source, encoding);
|
|
2063
|
+
var length = source.limit - source.offset;
|
|
2064
|
+
if (length <= 0) return this;
|
|
2065
|
+
offset += length;
|
|
2066
|
+
var capacity16 = this.buffer.byteLength;
|
|
2067
|
+
if (offset > capacity16)
|
|
2068
|
+
this.resize((capacity16 *= 2) > offset ? capacity16 : offset);
|
|
2069
|
+
offset -= length;
|
|
2070
|
+
this.view.set(source.view.subarray(source.offset, source.limit), offset);
|
|
2071
|
+
source.offset += length;
|
|
2072
|
+
if (relative) this.offset += length;
|
|
2073
|
+
return this;
|
|
2074
|
+
};
|
|
2075
|
+
ByteBufferPrototype.appendTo = function(target, offset) {
|
|
2076
|
+
target.append(this, offset);
|
|
2077
|
+
return this;
|
|
2078
|
+
};
|
|
2079
|
+
ByteBufferPrototype.assert = function(assert) {
|
|
2080
|
+
this.noAssert = !assert;
|
|
2081
|
+
return this;
|
|
2082
|
+
};
|
|
2083
|
+
ByteBufferPrototype.capacity = function() {
|
|
2084
|
+
return this.buffer.byteLength;
|
|
2085
|
+
};
|
|
2086
|
+
ByteBufferPrototype.clear = function() {
|
|
2087
|
+
this.offset = 0;
|
|
2088
|
+
this.limit = this.buffer.byteLength;
|
|
2089
|
+
this.markedOffset = -1;
|
|
2090
|
+
return this;
|
|
2091
|
+
};
|
|
2092
|
+
ByteBufferPrototype.clone = function(copy) {
|
|
2093
|
+
var bb = new ByteBuffer2(0, this.littleEndian, this.noAssert);
|
|
2094
|
+
if (copy) {
|
|
2095
|
+
bb.buffer = new ArrayBuffer(this.buffer.byteLength);
|
|
2096
|
+
bb.view = new Uint8Array(bb.buffer);
|
|
2097
|
+
} else {
|
|
2098
|
+
bb.buffer = this.buffer;
|
|
2099
|
+
bb.view = this.view;
|
|
2100
|
+
}
|
|
2101
|
+
bb.offset = this.offset;
|
|
2102
|
+
bb.markedOffset = this.markedOffset;
|
|
2103
|
+
bb.limit = this.limit;
|
|
2104
|
+
return bb;
|
|
2105
|
+
};
|
|
2106
|
+
ByteBufferPrototype.compact = function(begin, end) {
|
|
2107
|
+
if (typeof begin === "undefined") begin = this.offset;
|
|
2108
|
+
if (typeof end === "undefined") end = this.limit;
|
|
2109
|
+
if (!this.noAssert) {
|
|
2110
|
+
if (typeof begin !== "number" || begin % 1 !== 0)
|
|
2111
|
+
throw TypeError("Illegal begin: Not an integer");
|
|
2112
|
+
begin >>>= 0;
|
|
2113
|
+
if (typeof end !== "number" || end % 1 !== 0)
|
|
2114
|
+
throw TypeError("Illegal end: Not an integer");
|
|
2115
|
+
end >>>= 0;
|
|
2116
|
+
if (begin < 0 || begin > end || end > this.buffer.byteLength)
|
|
2117
|
+
throw RangeError("Illegal range: 0 <= " + begin + " <= " + end + " <= " + this.buffer.byteLength);
|
|
2118
|
+
}
|
|
2119
|
+
if (begin === 0 && end === this.buffer.byteLength)
|
|
2120
|
+
return this;
|
|
2121
|
+
var len = end - begin;
|
|
2122
|
+
if (len === 0) {
|
|
2123
|
+
this.buffer = EMPTY_BUFFER;
|
|
2124
|
+
this.view = null;
|
|
2125
|
+
if (this.markedOffset >= 0) this.markedOffset -= begin;
|
|
2126
|
+
this.offset = 0;
|
|
2127
|
+
this.limit = 0;
|
|
2128
|
+
return this;
|
|
2129
|
+
}
|
|
2130
|
+
var buffer = new ArrayBuffer(len);
|
|
2131
|
+
var view = new Uint8Array(buffer);
|
|
2132
|
+
view.set(this.view.subarray(begin, end));
|
|
2133
|
+
this.buffer = buffer;
|
|
2134
|
+
this.view = view;
|
|
2135
|
+
if (this.markedOffset >= 0) this.markedOffset -= begin;
|
|
2136
|
+
this.offset = 0;
|
|
2137
|
+
this.limit = len;
|
|
2138
|
+
return this;
|
|
2139
|
+
};
|
|
2140
|
+
ByteBufferPrototype.copy = function(begin, end) {
|
|
2141
|
+
if (typeof begin === "undefined") begin = this.offset;
|
|
2142
|
+
if (typeof end === "undefined") end = this.limit;
|
|
2143
|
+
if (!this.noAssert) {
|
|
2144
|
+
if (typeof begin !== "number" || begin % 1 !== 0)
|
|
2145
|
+
throw TypeError("Illegal begin: Not an integer");
|
|
2146
|
+
begin >>>= 0;
|
|
2147
|
+
if (typeof end !== "number" || end % 1 !== 0)
|
|
2148
|
+
throw TypeError("Illegal end: Not an integer");
|
|
2149
|
+
end >>>= 0;
|
|
2150
|
+
if (begin < 0 || begin > end || end > this.buffer.byteLength)
|
|
2151
|
+
throw RangeError("Illegal range: 0 <= " + begin + " <= " + end + " <= " + this.buffer.byteLength);
|
|
2152
|
+
}
|
|
2153
|
+
if (begin === end)
|
|
2154
|
+
return new ByteBuffer2(0, this.littleEndian, this.noAssert);
|
|
2155
|
+
var capacity = end - begin, bb = new ByteBuffer2(capacity, this.littleEndian, this.noAssert);
|
|
2156
|
+
bb.offset = 0;
|
|
2157
|
+
bb.limit = capacity;
|
|
2158
|
+
if (bb.markedOffset >= 0) bb.markedOffset -= begin;
|
|
2159
|
+
this.copyTo(bb, 0, begin, end);
|
|
2160
|
+
return bb;
|
|
2161
|
+
};
|
|
2162
|
+
ByteBufferPrototype.copyTo = function(target, targetOffset, sourceOffset, sourceLimit) {
|
|
2163
|
+
var relative, targetRelative;
|
|
2164
|
+
if (!this.noAssert) {
|
|
2165
|
+
if (!ByteBuffer2.isByteBuffer(target))
|
|
2166
|
+
throw TypeError("Illegal target: Not a ByteBuffer");
|
|
2167
|
+
}
|
|
2168
|
+
targetOffset = (targetRelative = typeof targetOffset === "undefined") ? target.offset : targetOffset | 0;
|
|
2169
|
+
sourceOffset = (relative = typeof sourceOffset === "undefined") ? this.offset : sourceOffset | 0;
|
|
2170
|
+
sourceLimit = typeof sourceLimit === "undefined" ? this.limit : sourceLimit | 0;
|
|
2171
|
+
if (targetOffset < 0 || targetOffset > target.buffer.byteLength)
|
|
2172
|
+
throw RangeError("Illegal target range: 0 <= " + targetOffset + " <= " + target.buffer.byteLength);
|
|
2173
|
+
if (sourceOffset < 0 || sourceLimit > this.buffer.byteLength)
|
|
2174
|
+
throw RangeError("Illegal source range: 0 <= " + sourceOffset + " <= " + this.buffer.byteLength);
|
|
2175
|
+
var len = sourceLimit - sourceOffset;
|
|
2176
|
+
if (len === 0)
|
|
2177
|
+
return target;
|
|
2178
|
+
target.ensureCapacity(targetOffset + len);
|
|
2179
|
+
target.view.set(this.view.subarray(sourceOffset, sourceLimit), targetOffset);
|
|
2180
|
+
if (relative) this.offset += len;
|
|
2181
|
+
if (targetRelative) target.offset += len;
|
|
2182
|
+
return this;
|
|
2183
|
+
};
|
|
2184
|
+
ByteBufferPrototype.ensureCapacity = function(capacity) {
|
|
2185
|
+
var current = this.buffer.byteLength;
|
|
2186
|
+
if (current < capacity)
|
|
2187
|
+
return this.resize((current *= 2) > capacity ? current : capacity);
|
|
2188
|
+
return this;
|
|
2189
|
+
};
|
|
2190
|
+
ByteBufferPrototype.fill = function(value, begin, end) {
|
|
2191
|
+
var relative = typeof begin === "undefined";
|
|
2192
|
+
if (relative) begin = this.offset;
|
|
2193
|
+
if (typeof value === "string" && value.length > 0)
|
|
2194
|
+
value = value.charCodeAt(0);
|
|
2195
|
+
if (typeof begin === "undefined") begin = this.offset;
|
|
2196
|
+
if (typeof end === "undefined") end = this.limit;
|
|
2197
|
+
if (!this.noAssert) {
|
|
2198
|
+
if (typeof value !== "number" || value % 1 !== 0)
|
|
2199
|
+
throw TypeError("Illegal value: " + value + " (not an integer)");
|
|
2200
|
+
value |= 0;
|
|
2201
|
+
if (typeof begin !== "number" || begin % 1 !== 0)
|
|
2202
|
+
throw TypeError("Illegal begin: Not an integer");
|
|
2203
|
+
begin >>>= 0;
|
|
2204
|
+
if (typeof end !== "number" || end % 1 !== 0)
|
|
2205
|
+
throw TypeError("Illegal end: Not an integer");
|
|
2206
|
+
end >>>= 0;
|
|
2207
|
+
if (begin < 0 || begin > end || end > this.buffer.byteLength)
|
|
2208
|
+
throw RangeError("Illegal range: 0 <= " + begin + " <= " + end + " <= " + this.buffer.byteLength);
|
|
2209
|
+
}
|
|
2210
|
+
if (begin >= end)
|
|
2211
|
+
return this;
|
|
2212
|
+
while (begin < end) this.view[begin++] = value;
|
|
2213
|
+
if (relative) this.offset = begin;
|
|
2214
|
+
return this;
|
|
2215
|
+
};
|
|
2216
|
+
ByteBufferPrototype.flip = function() {
|
|
2217
|
+
this.limit = this.offset;
|
|
2218
|
+
this.offset = 0;
|
|
2219
|
+
return this;
|
|
2220
|
+
};
|
|
2221
|
+
ByteBufferPrototype.mark = function(offset) {
|
|
2222
|
+
offset = typeof offset === "undefined" ? this.offset : offset;
|
|
2223
|
+
if (!this.noAssert) {
|
|
2224
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
2225
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
2226
|
+
offset >>>= 0;
|
|
2227
|
+
if (offset < 0 || offset + 0 > this.buffer.byteLength)
|
|
2228
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+0) <= " + this.buffer.byteLength);
|
|
2229
|
+
}
|
|
2230
|
+
this.markedOffset = offset;
|
|
2231
|
+
return this;
|
|
2232
|
+
};
|
|
2233
|
+
ByteBufferPrototype.order = function(littleEndian) {
|
|
2234
|
+
if (!this.noAssert) {
|
|
2235
|
+
if (typeof littleEndian !== "boolean")
|
|
2236
|
+
throw TypeError("Illegal littleEndian: Not a boolean");
|
|
2237
|
+
}
|
|
2238
|
+
this.littleEndian = !!littleEndian;
|
|
2239
|
+
return this;
|
|
2240
|
+
};
|
|
2241
|
+
ByteBufferPrototype.LE = function(littleEndian) {
|
|
2242
|
+
this.littleEndian = typeof littleEndian !== "undefined" ? !!littleEndian : true;
|
|
2243
|
+
return this;
|
|
2244
|
+
};
|
|
2245
|
+
ByteBufferPrototype.BE = function(bigEndian) {
|
|
2246
|
+
this.littleEndian = typeof bigEndian !== "undefined" ? !bigEndian : false;
|
|
2247
|
+
return this;
|
|
2248
|
+
};
|
|
2249
|
+
ByteBufferPrototype.prepend = function(source, encoding, offset) {
|
|
2250
|
+
if (typeof encoding === "number" || typeof encoding !== "string") {
|
|
2251
|
+
offset = encoding;
|
|
2252
|
+
encoding = void 0;
|
|
2253
|
+
}
|
|
2254
|
+
var relative = typeof offset === "undefined";
|
|
2255
|
+
if (relative) offset = this.offset;
|
|
2256
|
+
if (!this.noAssert) {
|
|
2257
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
2258
|
+
throw TypeError("Illegal offset: " + offset + " (not an integer)");
|
|
2259
|
+
offset >>>= 0;
|
|
2260
|
+
if (offset < 0 || offset + 0 > this.buffer.byteLength)
|
|
2261
|
+
throw RangeError("Illegal offset: 0 <= " + offset + " (+0) <= " + this.buffer.byteLength);
|
|
2262
|
+
}
|
|
2263
|
+
if (!(source instanceof ByteBuffer2))
|
|
2264
|
+
source = ByteBuffer2.wrap(source, encoding);
|
|
2265
|
+
var len = source.limit - source.offset;
|
|
2266
|
+
if (len <= 0) return this;
|
|
2267
|
+
var diff = len - offset;
|
|
2268
|
+
if (diff > 0) {
|
|
2269
|
+
var buffer = new ArrayBuffer(this.buffer.byteLength + diff);
|
|
2270
|
+
var view = new Uint8Array(buffer);
|
|
2271
|
+
view.set(this.view.subarray(offset, this.buffer.byteLength), len);
|
|
2272
|
+
this.buffer = buffer;
|
|
2273
|
+
this.view = view;
|
|
2274
|
+
this.offset += diff;
|
|
2275
|
+
if (this.markedOffset >= 0) this.markedOffset += diff;
|
|
2276
|
+
this.limit += diff;
|
|
2277
|
+
offset += diff;
|
|
2278
|
+
} else {
|
|
2279
|
+
new Uint8Array(this.buffer);
|
|
2280
|
+
}
|
|
2281
|
+
this.view.set(source.view.subarray(source.offset, source.limit), offset - len);
|
|
2282
|
+
source.offset = source.limit;
|
|
2283
|
+
if (relative)
|
|
2284
|
+
this.offset -= len;
|
|
2285
|
+
return this;
|
|
2286
|
+
};
|
|
2287
|
+
ByteBufferPrototype.prependTo = function(target, offset) {
|
|
2288
|
+
target.prepend(this, offset);
|
|
2289
|
+
return this;
|
|
2290
|
+
};
|
|
2291
|
+
ByteBufferPrototype.printDebug = function(out) {
|
|
2292
|
+
if (typeof out !== "function") out = console.log.bind(console);
|
|
2293
|
+
out(
|
|
2294
|
+
this.toString() + "\n-------------------------------------------------------------------\n" + this.toDebug(
|
|
2295
|
+
/* columns */
|
|
2296
|
+
true
|
|
2297
|
+
)
|
|
2298
|
+
);
|
|
2299
|
+
};
|
|
2300
|
+
ByteBufferPrototype.remaining = function() {
|
|
2301
|
+
return this.limit - this.offset;
|
|
2302
|
+
};
|
|
2303
|
+
ByteBufferPrototype.reset = function() {
|
|
2304
|
+
if (this.markedOffset >= 0) {
|
|
2305
|
+
this.offset = this.markedOffset;
|
|
2306
|
+
this.markedOffset = -1;
|
|
2307
|
+
} else {
|
|
2308
|
+
this.offset = 0;
|
|
2309
|
+
}
|
|
2310
|
+
return this;
|
|
2311
|
+
};
|
|
2312
|
+
ByteBufferPrototype.resize = function(capacity) {
|
|
2313
|
+
if (!this.noAssert) {
|
|
2314
|
+
if (typeof capacity !== "number" || capacity % 1 !== 0)
|
|
2315
|
+
throw TypeError("Illegal capacity: " + capacity + " (not an integer)");
|
|
2316
|
+
capacity |= 0;
|
|
2317
|
+
if (capacity < 0)
|
|
2318
|
+
throw RangeError("Illegal capacity: 0 <= " + capacity);
|
|
2319
|
+
}
|
|
2320
|
+
if (this.buffer.byteLength < capacity) {
|
|
2321
|
+
var buffer = new ArrayBuffer(capacity);
|
|
2322
|
+
var view = new Uint8Array(buffer);
|
|
2323
|
+
view.set(this.view);
|
|
2324
|
+
this.buffer = buffer;
|
|
2325
|
+
this.view = view;
|
|
2326
|
+
}
|
|
2327
|
+
return this;
|
|
2328
|
+
};
|
|
2329
|
+
ByteBufferPrototype.reverse = function(begin, end) {
|
|
2330
|
+
if (typeof begin === "undefined") begin = this.offset;
|
|
2331
|
+
if (typeof end === "undefined") end = this.limit;
|
|
2332
|
+
if (!this.noAssert) {
|
|
2333
|
+
if (typeof begin !== "number" || begin % 1 !== 0)
|
|
2334
|
+
throw TypeError("Illegal begin: Not an integer");
|
|
2335
|
+
begin >>>= 0;
|
|
2336
|
+
if (typeof end !== "number" || end % 1 !== 0)
|
|
2337
|
+
throw TypeError("Illegal end: Not an integer");
|
|
2338
|
+
end >>>= 0;
|
|
2339
|
+
if (begin < 0 || begin > end || end > this.buffer.byteLength)
|
|
2340
|
+
throw RangeError("Illegal range: 0 <= " + begin + " <= " + end + " <= " + this.buffer.byteLength);
|
|
2341
|
+
}
|
|
2342
|
+
if (begin === end)
|
|
2343
|
+
return this;
|
|
2344
|
+
Array.prototype.reverse.call(this.view.subarray(begin, end));
|
|
2345
|
+
return this;
|
|
2346
|
+
};
|
|
2347
|
+
ByteBufferPrototype.skip = function(length) {
|
|
2348
|
+
if (!this.noAssert) {
|
|
2349
|
+
if (typeof length !== "number" || length % 1 !== 0)
|
|
2350
|
+
throw TypeError("Illegal length: " + length + " (not an integer)");
|
|
2351
|
+
length |= 0;
|
|
2352
|
+
}
|
|
2353
|
+
var offset = this.offset + length;
|
|
2354
|
+
if (!this.noAssert) {
|
|
2355
|
+
if (offset < 0 || offset > this.buffer.byteLength)
|
|
2356
|
+
throw RangeError("Illegal length: 0 <= " + this.offset + " + " + length + " <= " + this.buffer.byteLength);
|
|
2357
|
+
}
|
|
2358
|
+
this.offset = offset;
|
|
2359
|
+
return this;
|
|
2360
|
+
};
|
|
2361
|
+
ByteBufferPrototype.slice = function(begin, end) {
|
|
2362
|
+
if (typeof begin === "undefined") begin = this.offset;
|
|
2363
|
+
if (typeof end === "undefined") end = this.limit;
|
|
2364
|
+
if (!this.noAssert) {
|
|
2365
|
+
if (typeof begin !== "number" || begin % 1 !== 0)
|
|
2366
|
+
throw TypeError("Illegal begin: Not an integer");
|
|
2367
|
+
begin >>>= 0;
|
|
2368
|
+
if (typeof end !== "number" || end % 1 !== 0)
|
|
2369
|
+
throw TypeError("Illegal end: Not an integer");
|
|
2370
|
+
end >>>= 0;
|
|
2371
|
+
if (begin < 0 || begin > end || end > this.buffer.byteLength)
|
|
2372
|
+
throw RangeError("Illegal range: 0 <= " + begin + " <= " + end + " <= " + this.buffer.byteLength);
|
|
2373
|
+
}
|
|
2374
|
+
var bb = this.clone();
|
|
2375
|
+
bb.offset = begin;
|
|
2376
|
+
bb.limit = end;
|
|
2377
|
+
return bb;
|
|
2378
|
+
};
|
|
2379
|
+
ByteBufferPrototype.toBuffer = function(forceCopy) {
|
|
2380
|
+
var offset = this.offset, limit = this.limit;
|
|
2381
|
+
if (!this.noAssert) {
|
|
2382
|
+
if (typeof offset !== "number" || offset % 1 !== 0)
|
|
2383
|
+
throw TypeError("Illegal offset: Not an integer");
|
|
2384
|
+
offset >>>= 0;
|
|
2385
|
+
if (typeof limit !== "number" || limit % 1 !== 0)
|
|
2386
|
+
throw TypeError("Illegal limit: Not an integer");
|
|
2387
|
+
limit >>>= 0;
|
|
2388
|
+
if (offset < 0 || offset > limit || limit > this.buffer.byteLength)
|
|
2389
|
+
throw RangeError("Illegal range: 0 <= " + offset + " <= " + limit + " <= " + this.buffer.byteLength);
|
|
2390
|
+
}
|
|
2391
|
+
if (!forceCopy && offset === 0 && limit === this.buffer.byteLength)
|
|
2392
|
+
return this.buffer;
|
|
2393
|
+
if (offset === limit)
|
|
2394
|
+
return EMPTY_BUFFER;
|
|
2395
|
+
var buffer = new ArrayBuffer(limit - offset);
|
|
2396
|
+
new Uint8Array(buffer).set(new Uint8Array(this.buffer).subarray(offset, limit), 0);
|
|
2397
|
+
return buffer;
|
|
2398
|
+
};
|
|
2399
|
+
ByteBufferPrototype.toArrayBuffer = ByteBufferPrototype.toBuffer;
|
|
2400
|
+
ByteBufferPrototype.toString = function(encoding, begin, end) {
|
|
2401
|
+
if (typeof encoding === "undefined")
|
|
2402
|
+
return "ByteBufferAB(offset=" + this.offset + ",markedOffset=" + this.markedOffset + ",limit=" + this.limit + ",capacity=" + this.capacity() + ")";
|
|
2403
|
+
if (typeof encoding === "number")
|
|
2404
|
+
encoding = "utf8", begin = encoding, end = begin;
|
|
2405
|
+
switch (encoding) {
|
|
2406
|
+
case "utf8":
|
|
2407
|
+
return this.toUTF8(begin, end);
|
|
2408
|
+
case "base64":
|
|
2409
|
+
return this.toBase64(begin, end);
|
|
2410
|
+
case "hex":
|
|
2411
|
+
return this.toHex(begin, end);
|
|
2412
|
+
case "binary":
|
|
2413
|
+
return this.toBinary(begin, end);
|
|
2414
|
+
case "debug":
|
|
2415
|
+
return this.toDebug();
|
|
2416
|
+
case "columns":
|
|
2417
|
+
return this.toColumns();
|
|
2418
|
+
default:
|
|
2419
|
+
throw Error("Unsupported encoding: " + encoding);
|
|
2420
|
+
}
|
|
2421
|
+
};
|
|
2422
|
+
var lxiv = (function() {
|
|
2423
|
+
var lxiv2 = {};
|
|
2424
|
+
var aout = [
|
|
2425
|
+
65,
|
|
2426
|
+
66,
|
|
2427
|
+
67,
|
|
2428
|
+
68,
|
|
2429
|
+
69,
|
|
2430
|
+
70,
|
|
2431
|
+
71,
|
|
2432
|
+
72,
|
|
2433
|
+
73,
|
|
2434
|
+
74,
|
|
2435
|
+
75,
|
|
2436
|
+
76,
|
|
2437
|
+
77,
|
|
2438
|
+
78,
|
|
2439
|
+
79,
|
|
2440
|
+
80,
|
|
2441
|
+
81,
|
|
2442
|
+
82,
|
|
2443
|
+
83,
|
|
2444
|
+
84,
|
|
2445
|
+
85,
|
|
2446
|
+
86,
|
|
2447
|
+
87,
|
|
2448
|
+
88,
|
|
2449
|
+
89,
|
|
2450
|
+
90,
|
|
2451
|
+
97,
|
|
2452
|
+
98,
|
|
2453
|
+
99,
|
|
2454
|
+
100,
|
|
2455
|
+
101,
|
|
2456
|
+
102,
|
|
2457
|
+
103,
|
|
2458
|
+
104,
|
|
2459
|
+
105,
|
|
2460
|
+
106,
|
|
2461
|
+
107,
|
|
2462
|
+
108,
|
|
2463
|
+
109,
|
|
2464
|
+
110,
|
|
2465
|
+
111,
|
|
2466
|
+
112,
|
|
2467
|
+
113,
|
|
2468
|
+
114,
|
|
2469
|
+
115,
|
|
2470
|
+
116,
|
|
2471
|
+
117,
|
|
2472
|
+
118,
|
|
2473
|
+
119,
|
|
2474
|
+
120,
|
|
2475
|
+
121,
|
|
2476
|
+
122,
|
|
2477
|
+
48,
|
|
2478
|
+
49,
|
|
2479
|
+
50,
|
|
2480
|
+
51,
|
|
2481
|
+
52,
|
|
2482
|
+
53,
|
|
2483
|
+
54,
|
|
2484
|
+
55,
|
|
2485
|
+
56,
|
|
2486
|
+
57,
|
|
2487
|
+
43,
|
|
2488
|
+
47
|
|
2489
|
+
];
|
|
2490
|
+
var ain = [];
|
|
2491
|
+
for (var i = 0, k = aout.length; i < k; ++i)
|
|
2492
|
+
ain[aout[i]] = i;
|
|
2493
|
+
lxiv2.encode = function(src, dst) {
|
|
2494
|
+
var b, t;
|
|
2495
|
+
while ((b = src()) !== null) {
|
|
2496
|
+
dst(aout[b >> 2 & 63]);
|
|
2497
|
+
t = (b & 3) << 4;
|
|
2498
|
+
if ((b = src()) !== null) {
|
|
2499
|
+
t |= b >> 4 & 15;
|
|
2500
|
+
dst(aout[(t | b >> 4 & 15) & 63]);
|
|
2501
|
+
t = (b & 15) << 2;
|
|
2502
|
+
if ((b = src()) !== null)
|
|
2503
|
+
dst(aout[(t | b >> 6 & 3) & 63]), dst(aout[b & 63]);
|
|
2504
|
+
else
|
|
2505
|
+
dst(aout[t & 63]), dst(61);
|
|
2506
|
+
} else
|
|
2507
|
+
dst(aout[t & 63]), dst(61), dst(61);
|
|
2508
|
+
}
|
|
2509
|
+
};
|
|
2510
|
+
lxiv2.decode = function(src, dst) {
|
|
2511
|
+
var c, t1, t2;
|
|
2512
|
+
function fail(c2) {
|
|
2513
|
+
throw Error("Illegal character code: " + c2);
|
|
2514
|
+
}
|
|
2515
|
+
while ((c = src()) !== null) {
|
|
2516
|
+
t1 = ain[c];
|
|
2517
|
+
if (typeof t1 === "undefined") fail(c);
|
|
2518
|
+
if ((c = src()) !== null) {
|
|
2519
|
+
t2 = ain[c];
|
|
2520
|
+
if (typeof t2 === "undefined") fail(c);
|
|
2521
|
+
dst(t1 << 2 >>> 0 | (t2 & 48) >> 4);
|
|
2522
|
+
if ((c = src()) !== null) {
|
|
2523
|
+
t1 = ain[c];
|
|
2524
|
+
if (typeof t1 === "undefined")
|
|
2525
|
+
if (c === 61) break;
|
|
2526
|
+
else fail(c);
|
|
2527
|
+
dst((t2 & 15) << 4 >>> 0 | (t1 & 60) >> 2);
|
|
2528
|
+
if ((c = src()) !== null) {
|
|
2529
|
+
t2 = ain[c];
|
|
2530
|
+
if (typeof t2 === "undefined")
|
|
2531
|
+
if (c === 61) break;
|
|
2532
|
+
else fail(c);
|
|
2533
|
+
dst((t1 & 3) << 6 >>> 0 | t2);
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2537
|
+
}
|
|
2538
|
+
};
|
|
2539
|
+
lxiv2.test = function(str) {
|
|
2540
|
+
return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(str);
|
|
2541
|
+
};
|
|
2542
|
+
return lxiv2;
|
|
2543
|
+
})();
|
|
2544
|
+
ByteBufferPrototype.toBase64 = function(begin, end) {
|
|
2545
|
+
if (typeof begin === "undefined")
|
|
2546
|
+
begin = this.offset;
|
|
2547
|
+
if (typeof end === "undefined")
|
|
2548
|
+
end = this.limit;
|
|
2549
|
+
begin = begin | 0;
|
|
2550
|
+
end = end | 0;
|
|
2551
|
+
if (begin < 0 || end > this.capacity || begin > end)
|
|
2552
|
+
throw RangeError("begin, end");
|
|
2553
|
+
var sd;
|
|
2554
|
+
lxiv.encode((function() {
|
|
2555
|
+
return begin < end ? this.view[begin++] : null;
|
|
2556
|
+
}).bind(this), sd = stringDestination());
|
|
2557
|
+
return sd();
|
|
2558
|
+
};
|
|
2559
|
+
ByteBuffer2.fromBase64 = function(str, littleEndian) {
|
|
2560
|
+
if (typeof str !== "string")
|
|
2561
|
+
throw TypeError("str");
|
|
2562
|
+
var bb = new ByteBuffer2(str.length / 4 * 3, littleEndian), i = 0;
|
|
2563
|
+
lxiv.decode(stringSource(str), function(b) {
|
|
2564
|
+
bb.view[i++] = b;
|
|
2565
|
+
});
|
|
2566
|
+
bb.limit = i;
|
|
2567
|
+
return bb;
|
|
2568
|
+
};
|
|
2569
|
+
ByteBuffer2.btoa = function(str) {
|
|
2570
|
+
return ByteBuffer2.fromBinary(str).toBase64();
|
|
2571
|
+
};
|
|
2572
|
+
ByteBuffer2.atob = function(b64) {
|
|
2573
|
+
return ByteBuffer2.fromBase64(b64).toBinary();
|
|
2574
|
+
};
|
|
2575
|
+
ByteBufferPrototype.toBinary = function(begin, end) {
|
|
2576
|
+
if (typeof begin === "undefined")
|
|
2577
|
+
begin = this.offset;
|
|
2578
|
+
if (typeof end === "undefined")
|
|
2579
|
+
end = this.limit;
|
|
2580
|
+
begin |= 0;
|
|
2581
|
+
end |= 0;
|
|
2582
|
+
if (begin < 0 || end > this.capacity() || begin > end)
|
|
2583
|
+
throw RangeError("begin, end");
|
|
2584
|
+
if (begin === end)
|
|
2585
|
+
return "";
|
|
2586
|
+
var chars = [], parts = [];
|
|
2587
|
+
while (begin < end) {
|
|
2588
|
+
chars.push(this.view[begin++]);
|
|
2589
|
+
if (chars.length >= 1024)
|
|
2590
|
+
parts.push(String.fromCharCode.apply(String, chars)), chars = [];
|
|
2591
|
+
}
|
|
2592
|
+
return parts.join("") + String.fromCharCode.apply(String, chars);
|
|
2593
|
+
};
|
|
2594
|
+
ByteBuffer2.fromBinary = function(str, littleEndian) {
|
|
2595
|
+
if (typeof str !== "string")
|
|
2596
|
+
throw TypeError("str");
|
|
2597
|
+
var i = 0, k = str.length, charCode, bb = new ByteBuffer2(k, littleEndian);
|
|
2598
|
+
while (i < k) {
|
|
2599
|
+
charCode = str.charCodeAt(i);
|
|
2600
|
+
if (charCode > 255)
|
|
2601
|
+
throw RangeError("illegal char code: " + charCode);
|
|
2602
|
+
bb.view[i++] = charCode;
|
|
2603
|
+
}
|
|
2604
|
+
bb.limit = k;
|
|
2605
|
+
return bb;
|
|
2606
|
+
};
|
|
2607
|
+
ByteBufferPrototype.toDebug = function(columns) {
|
|
2608
|
+
var i = -1, k = this.buffer.byteLength, b, hex = "", asc = "", out = "";
|
|
2609
|
+
while (i < k) {
|
|
2610
|
+
if (i !== -1) {
|
|
2611
|
+
b = this.view[i];
|
|
2612
|
+
if (b < 16) hex += "0" + b.toString(16).toUpperCase();
|
|
2613
|
+
else hex += b.toString(16).toUpperCase();
|
|
2614
|
+
if (columns)
|
|
2615
|
+
asc += b > 32 && b < 127 ? String.fromCharCode(b) : ".";
|
|
2616
|
+
}
|
|
2617
|
+
++i;
|
|
2618
|
+
if (columns) {
|
|
2619
|
+
if (i > 0 && i % 16 === 0 && i !== k) {
|
|
2620
|
+
while (hex.length < 3 * 16 + 3) hex += " ";
|
|
2621
|
+
out += hex + asc + "\n";
|
|
2622
|
+
hex = asc = "";
|
|
2623
|
+
}
|
|
2624
|
+
}
|
|
2625
|
+
if (i === this.offset && i === this.limit)
|
|
2626
|
+
hex += i === this.markedOffset ? "!" : "|";
|
|
2627
|
+
else if (i === this.offset)
|
|
2628
|
+
hex += i === this.markedOffset ? "[" : "<";
|
|
2629
|
+
else if (i === this.limit)
|
|
2630
|
+
hex += i === this.markedOffset ? "]" : ">";
|
|
2631
|
+
else
|
|
2632
|
+
hex += i === this.markedOffset ? "'" : columns || i !== 0 && i !== k ? " " : "";
|
|
2633
|
+
}
|
|
2634
|
+
if (columns && hex !== " ") {
|
|
2635
|
+
while (hex.length < 3 * 16 + 3)
|
|
2636
|
+
hex += " ";
|
|
2637
|
+
out += hex + asc + "\n";
|
|
2638
|
+
}
|
|
2639
|
+
return columns ? out : hex;
|
|
2640
|
+
};
|
|
2641
|
+
ByteBuffer2.fromDebug = function(str, littleEndian, noAssert) {
|
|
2642
|
+
var k = str.length, bb = new ByteBuffer2((k + 1) / 3 | 0, littleEndian, noAssert);
|
|
2643
|
+
var i = 0, j = 0, ch, b, rs = false, ho = false, hm = false, hl = false, fail = false;
|
|
2644
|
+
while (i < k) {
|
|
2645
|
+
switch (ch = str.charAt(i++)) {
|
|
2646
|
+
case "!":
|
|
2647
|
+
if (!noAssert) {
|
|
2648
|
+
if (ho || hm || hl) {
|
|
2649
|
+
fail = true;
|
|
2650
|
+
break;
|
|
2651
|
+
}
|
|
2652
|
+
ho = hm = hl = true;
|
|
2653
|
+
}
|
|
2654
|
+
bb.offset = bb.markedOffset = bb.limit = j;
|
|
2655
|
+
rs = false;
|
|
2656
|
+
break;
|
|
2657
|
+
case "|":
|
|
2658
|
+
if (!noAssert) {
|
|
2659
|
+
if (ho || hl) {
|
|
2660
|
+
fail = true;
|
|
2661
|
+
break;
|
|
2662
|
+
}
|
|
2663
|
+
ho = hl = true;
|
|
2664
|
+
}
|
|
2665
|
+
bb.offset = bb.limit = j;
|
|
2666
|
+
rs = false;
|
|
2667
|
+
break;
|
|
2668
|
+
case "[":
|
|
2669
|
+
if (!noAssert) {
|
|
2670
|
+
if (ho || hm) {
|
|
2671
|
+
fail = true;
|
|
2672
|
+
break;
|
|
2673
|
+
}
|
|
2674
|
+
ho = hm = true;
|
|
2675
|
+
}
|
|
2676
|
+
bb.offset = bb.markedOffset = j;
|
|
2677
|
+
rs = false;
|
|
2678
|
+
break;
|
|
2679
|
+
case "<":
|
|
2680
|
+
if (!noAssert) {
|
|
2681
|
+
if (ho) {
|
|
2682
|
+
fail = true;
|
|
2683
|
+
break;
|
|
2684
|
+
}
|
|
2685
|
+
ho = true;
|
|
2686
|
+
}
|
|
2687
|
+
bb.offset = j;
|
|
2688
|
+
rs = false;
|
|
2689
|
+
break;
|
|
2690
|
+
case "]":
|
|
2691
|
+
if (!noAssert) {
|
|
2692
|
+
if (hl || hm) {
|
|
2693
|
+
fail = true;
|
|
2694
|
+
break;
|
|
2695
|
+
}
|
|
2696
|
+
hl = hm = true;
|
|
2697
|
+
}
|
|
2698
|
+
bb.limit = bb.markedOffset = j;
|
|
2699
|
+
rs = false;
|
|
2700
|
+
break;
|
|
2701
|
+
case ">":
|
|
2702
|
+
if (!noAssert) {
|
|
2703
|
+
if (hl) {
|
|
2704
|
+
fail = true;
|
|
2705
|
+
break;
|
|
2706
|
+
}
|
|
2707
|
+
hl = true;
|
|
2708
|
+
}
|
|
2709
|
+
bb.limit = j;
|
|
2710
|
+
rs = false;
|
|
2711
|
+
break;
|
|
2712
|
+
case "'":
|
|
2713
|
+
if (!noAssert) {
|
|
2714
|
+
if (hm) {
|
|
2715
|
+
fail = true;
|
|
2716
|
+
break;
|
|
2717
|
+
}
|
|
2718
|
+
hm = true;
|
|
2719
|
+
}
|
|
2720
|
+
bb.markedOffset = j;
|
|
2721
|
+
rs = false;
|
|
2722
|
+
break;
|
|
2723
|
+
case " ":
|
|
2724
|
+
rs = false;
|
|
2725
|
+
break;
|
|
2726
|
+
default:
|
|
2727
|
+
if (!noAssert) {
|
|
2728
|
+
if (rs) {
|
|
2729
|
+
fail = true;
|
|
2730
|
+
break;
|
|
2731
|
+
}
|
|
2732
|
+
}
|
|
2733
|
+
b = parseInt(ch + str.charAt(i++), 16);
|
|
2734
|
+
if (!noAssert) {
|
|
2735
|
+
if (isNaN(b) || b < 0 || b > 255)
|
|
2736
|
+
throw TypeError("Illegal str: Not a debug encoded string");
|
|
2737
|
+
}
|
|
2738
|
+
bb.view[j++] = b;
|
|
2739
|
+
rs = true;
|
|
2740
|
+
}
|
|
2741
|
+
if (fail)
|
|
2742
|
+
throw TypeError("Illegal str: Invalid symbol at " + i);
|
|
2743
|
+
}
|
|
2744
|
+
if (!noAssert) {
|
|
2745
|
+
if (!ho || !hl)
|
|
2746
|
+
throw TypeError("Illegal str: Missing offset or limit");
|
|
2747
|
+
if (j < bb.buffer.byteLength)
|
|
2748
|
+
throw TypeError("Illegal str: Not a debug encoded string (is it hex?) " + j + " < " + k);
|
|
2749
|
+
}
|
|
2750
|
+
return bb;
|
|
2751
|
+
};
|
|
2752
|
+
ByteBufferPrototype.toHex = function(begin, end) {
|
|
2753
|
+
begin = typeof begin === "undefined" ? this.offset : begin;
|
|
2754
|
+
end = typeof end === "undefined" ? this.limit : end;
|
|
2755
|
+
if (!this.noAssert) {
|
|
2756
|
+
if (typeof begin !== "number" || begin % 1 !== 0)
|
|
2757
|
+
throw TypeError("Illegal begin: Not an integer");
|
|
2758
|
+
begin >>>= 0;
|
|
2759
|
+
if (typeof end !== "number" || end % 1 !== 0)
|
|
2760
|
+
throw TypeError("Illegal end: Not an integer");
|
|
2761
|
+
end >>>= 0;
|
|
2762
|
+
if (begin < 0 || begin > end || end > this.buffer.byteLength)
|
|
2763
|
+
throw RangeError("Illegal range: 0 <= " + begin + " <= " + end + " <= " + this.buffer.byteLength);
|
|
2764
|
+
}
|
|
2765
|
+
var out = new Array(end - begin), b;
|
|
2766
|
+
while (begin < end) {
|
|
2767
|
+
b = this.view[begin++];
|
|
2768
|
+
if (b < 16)
|
|
2769
|
+
out.push("0", b.toString(16));
|
|
2770
|
+
else out.push(b.toString(16));
|
|
2771
|
+
}
|
|
2772
|
+
return out.join("");
|
|
2773
|
+
};
|
|
2774
|
+
ByteBuffer2.fromHex = function(str, littleEndian, noAssert) {
|
|
2775
|
+
if (!noAssert) {
|
|
2776
|
+
if (typeof str !== "string")
|
|
2777
|
+
throw TypeError("Illegal str: Not a string");
|
|
2778
|
+
if (str.length % 2 !== 0)
|
|
2779
|
+
throw TypeError("Illegal str: Length not a multiple of 2");
|
|
2780
|
+
}
|
|
2781
|
+
var k = str.length, bb = new ByteBuffer2(k / 2 | 0, littleEndian), b;
|
|
2782
|
+
for (var i = 0, j = 0; i < k; i += 2) {
|
|
2783
|
+
b = parseInt(str.substring(i, i + 2), 16);
|
|
2784
|
+
if (!noAssert) {
|
|
2785
|
+
if (!isFinite(b) || b < 0 || b > 255)
|
|
2786
|
+
throw TypeError("Illegal str: Contains non-hex characters");
|
|
2787
|
+
}
|
|
2788
|
+
bb.view[j++] = b;
|
|
2789
|
+
}
|
|
2790
|
+
bb.limit = j;
|
|
2791
|
+
return bb;
|
|
2792
|
+
};
|
|
2793
|
+
var utfx = (function() {
|
|
2794
|
+
var utfx2 = {};
|
|
2795
|
+
utfx2.MAX_CODEPOINT = 1114111;
|
|
2796
|
+
utfx2.encodeUTF8 = function(src, dst) {
|
|
2797
|
+
var cp = null;
|
|
2798
|
+
if (typeof src === "number")
|
|
2799
|
+
cp = src, src = function() {
|
|
2800
|
+
return null;
|
|
2801
|
+
};
|
|
2802
|
+
while (cp !== null || (cp = src()) !== null) {
|
|
2803
|
+
if (cp < 128)
|
|
2804
|
+
dst(cp & 127);
|
|
2805
|
+
else if (cp < 2048)
|
|
2806
|
+
dst(cp >> 6 & 31 | 192), dst(cp & 63 | 128);
|
|
2807
|
+
else if (cp < 65536)
|
|
2808
|
+
dst(cp >> 12 & 15 | 224), dst(cp >> 6 & 63 | 128), dst(cp & 63 | 128);
|
|
2809
|
+
else
|
|
2810
|
+
dst(cp >> 18 & 7 | 240), dst(cp >> 12 & 63 | 128), dst(cp >> 6 & 63 | 128), dst(cp & 63 | 128);
|
|
2811
|
+
cp = null;
|
|
2812
|
+
}
|
|
2813
|
+
};
|
|
2814
|
+
utfx2.decodeUTF8 = function(src, dst) {
|
|
2815
|
+
var a, b, c, d, fail = function(b2) {
|
|
2816
|
+
b2 = b2.slice(0, b2.indexOf(null));
|
|
2817
|
+
var err = Error(b2.toString());
|
|
2818
|
+
err.name = "TruncatedError";
|
|
2819
|
+
err["bytes"] = b2;
|
|
2820
|
+
throw err;
|
|
2821
|
+
};
|
|
2822
|
+
while ((a = src()) !== null) {
|
|
2823
|
+
if ((a & 128) === 0)
|
|
2824
|
+
dst(a);
|
|
2825
|
+
else if ((a & 224) === 192)
|
|
2826
|
+
(b = src()) === null && fail([a, b]), dst((a & 31) << 6 | b & 63);
|
|
2827
|
+
else if ((a & 240) === 224)
|
|
2828
|
+
((b = src()) === null || (c = src()) === null) && fail([a, b, c]), dst((a & 15) << 12 | (b & 63) << 6 | c & 63);
|
|
2829
|
+
else if ((a & 248) === 240)
|
|
2830
|
+
((b = src()) === null || (c = src()) === null || (d = src()) === null) && fail([a, b, c, d]), dst((a & 7) << 18 | (b & 63) << 12 | (c & 63) << 6 | d & 63);
|
|
2831
|
+
else throw RangeError("Illegal starting byte: " + a);
|
|
2832
|
+
}
|
|
2833
|
+
};
|
|
2834
|
+
utfx2.UTF16toUTF8 = function(src, dst) {
|
|
2835
|
+
var c1, c2 = null;
|
|
2836
|
+
while (true) {
|
|
2837
|
+
if ((c1 = c2 !== null ? c2 : src()) === null)
|
|
2838
|
+
break;
|
|
2839
|
+
if (c1 >= 55296 && c1 <= 57343) {
|
|
2840
|
+
if ((c2 = src()) !== null) {
|
|
2841
|
+
if (c2 >= 56320 && c2 <= 57343) {
|
|
2842
|
+
dst((c1 - 55296) * 1024 + c2 - 56320 + 65536);
|
|
2843
|
+
c2 = null;
|
|
2844
|
+
continue;
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2848
|
+
dst(c1);
|
|
2849
|
+
}
|
|
2850
|
+
if (c2 !== null) dst(c2);
|
|
2851
|
+
};
|
|
2852
|
+
utfx2.UTF8toUTF16 = function(src, dst) {
|
|
2853
|
+
var cp = null;
|
|
2854
|
+
if (typeof src === "number")
|
|
2855
|
+
cp = src, src = function() {
|
|
2856
|
+
return null;
|
|
2857
|
+
};
|
|
2858
|
+
while (cp !== null || (cp = src()) !== null) {
|
|
2859
|
+
if (cp <= 65535)
|
|
2860
|
+
dst(cp);
|
|
2861
|
+
else
|
|
2862
|
+
cp -= 65536, dst((cp >> 10) + 55296), dst(cp % 1024 + 56320);
|
|
2863
|
+
cp = null;
|
|
2864
|
+
}
|
|
2865
|
+
};
|
|
2866
|
+
utfx2.encodeUTF16toUTF8 = function(src, dst) {
|
|
2867
|
+
utfx2.UTF16toUTF8(src, function(cp) {
|
|
2868
|
+
utfx2.encodeUTF8(cp, dst);
|
|
2869
|
+
});
|
|
2870
|
+
};
|
|
2871
|
+
utfx2.decodeUTF8toUTF16 = function(src, dst) {
|
|
2872
|
+
utfx2.decodeUTF8(src, function(cp) {
|
|
2873
|
+
utfx2.UTF8toUTF16(cp, dst);
|
|
2874
|
+
});
|
|
2875
|
+
};
|
|
2876
|
+
utfx2.calculateCodePoint = function(cp) {
|
|
2877
|
+
return cp < 128 ? 1 : cp < 2048 ? 2 : cp < 65536 ? 3 : 4;
|
|
2878
|
+
};
|
|
2879
|
+
utfx2.calculateUTF8 = function(src) {
|
|
2880
|
+
var cp, l = 0;
|
|
2881
|
+
while ((cp = src()) !== null)
|
|
2882
|
+
l += cp < 128 ? 1 : cp < 2048 ? 2 : cp < 65536 ? 3 : 4;
|
|
2883
|
+
return l;
|
|
2884
|
+
};
|
|
2885
|
+
utfx2.calculateUTF16asUTF8 = function(src) {
|
|
2886
|
+
var n = 0, l = 0;
|
|
2887
|
+
utfx2.UTF16toUTF8(src, function(cp) {
|
|
2888
|
+
++n;
|
|
2889
|
+
l += cp < 128 ? 1 : cp < 2048 ? 2 : cp < 65536 ? 3 : 4;
|
|
2890
|
+
});
|
|
2891
|
+
return [n, l];
|
|
2892
|
+
};
|
|
2893
|
+
return utfx2;
|
|
2894
|
+
})();
|
|
2895
|
+
ByteBufferPrototype.toUTF8 = function(begin, end) {
|
|
2896
|
+
if (typeof begin === "undefined") begin = this.offset;
|
|
2897
|
+
if (typeof end === "undefined") end = this.limit;
|
|
2898
|
+
if (!this.noAssert) {
|
|
2899
|
+
if (typeof begin !== "number" || begin % 1 !== 0)
|
|
2900
|
+
throw TypeError("Illegal begin: Not an integer");
|
|
2901
|
+
begin >>>= 0;
|
|
2902
|
+
if (typeof end !== "number" || end % 1 !== 0)
|
|
2903
|
+
throw TypeError("Illegal end: Not an integer");
|
|
2904
|
+
end >>>= 0;
|
|
2905
|
+
if (begin < 0 || begin > end || end > this.buffer.byteLength)
|
|
2906
|
+
throw RangeError("Illegal range: 0 <= " + begin + " <= " + end + " <= " + this.buffer.byteLength);
|
|
2907
|
+
}
|
|
2908
|
+
var sd;
|
|
2909
|
+
try {
|
|
2910
|
+
utfx.decodeUTF8toUTF16((function() {
|
|
2911
|
+
return begin < end ? this.view[begin++] : null;
|
|
2912
|
+
}).bind(this), sd = stringDestination());
|
|
2913
|
+
} catch (e) {
|
|
2914
|
+
if (begin !== end)
|
|
2915
|
+
throw RangeError("Illegal range: Truncated data, " + begin + " != " + end);
|
|
2916
|
+
}
|
|
2917
|
+
return sd();
|
|
2918
|
+
};
|
|
2919
|
+
ByteBuffer2.fromUTF8 = function(str, littleEndian, noAssert) {
|
|
2920
|
+
if (!noAssert) {
|
|
2921
|
+
if (typeof str !== "string")
|
|
2922
|
+
throw TypeError("Illegal str: Not a string");
|
|
2923
|
+
}
|
|
2924
|
+
var bb = new ByteBuffer2(utfx.calculateUTF16asUTF8(stringSource(str), true)[1], littleEndian, noAssert), i = 0;
|
|
2925
|
+
utfx.encodeUTF16toUTF8(stringSource(str), function(b) {
|
|
2926
|
+
bb.view[i++] = b;
|
|
2927
|
+
});
|
|
2928
|
+
bb.limit = i;
|
|
2929
|
+
return bb;
|
|
2930
|
+
};
|
|
2931
|
+
return ByteBuffer2;
|
|
2932
|
+
});
|
|
2933
|
+
})(bytebuffer$1);
|
|
2934
|
+
return bytebuffer$1.exports;
|
|
2935
|
+
}
|
|
2936
|
+
var bytebufferExports = requireBytebuffer();
|
|
2937
|
+
const ByteBuffer = /* @__PURE__ */ getDefaultExportFromCjs(bytebufferExports);
|
|
2938
|
+
const logError = (error) => {
|
|
2939
|
+
if (process.env.NODE_ENV === "development") {
|
|
2940
|
+
console.error(error.message, error);
|
|
2941
|
+
}
|
|
2942
|
+
};
|
|
2943
|
+
async function request(url, method = "get", data, config) {
|
|
2944
|
+
try {
|
|
2945
|
+
const sendDataName = method.toLowerCase() === "get" ? "params" : "data";
|
|
2946
|
+
const headers = {
|
|
2947
|
+
"Content-Type": "application/json",
|
|
2948
|
+
...config == null ? void 0 : config.headers
|
|
2949
|
+
};
|
|
2950
|
+
const response = await axios({
|
|
2951
|
+
method,
|
|
2952
|
+
url,
|
|
2953
|
+
headers,
|
|
2954
|
+
[sendDataName]: data,
|
|
2955
|
+
...config
|
|
2956
|
+
});
|
|
2957
|
+
if (response.status !== 200) {
|
|
2958
|
+
throw response;
|
|
2959
|
+
}
|
|
2960
|
+
return response;
|
|
2961
|
+
} catch (error) {
|
|
2962
|
+
if (!axios.isCancel(error)) {
|
|
2963
|
+
logError(error);
|
|
2964
|
+
}
|
|
2965
|
+
return Promise.reject(error);
|
|
2966
|
+
}
|
|
2967
|
+
}
|
|
2968
|
+
async function responseStream(url, data, param = {}, _method = "post") {
|
|
2969
|
+
const abortController = new AbortController();
|
|
2970
|
+
const { signal } = abortController;
|
|
2971
|
+
const response = await fetch(url, {
|
|
2972
|
+
method: "post",
|
|
2973
|
+
signal,
|
|
2974
|
+
headers: {
|
|
2975
|
+
"Content-Type": "application/json"
|
|
2976
|
+
},
|
|
2977
|
+
body: JSON.stringify(param)
|
|
2978
|
+
});
|
|
2979
|
+
if (!response.body) return;
|
|
2980
|
+
const reader = response.body.getReader();
|
|
2981
|
+
const fileBuffer = new ByteBuffer();
|
|
2982
|
+
const fileName = decodeURI(response.headers.get("content-disposition").split("=")[1]).replaceAll("+", " ");
|
|
2983
|
+
const stream = new ReadableStream({
|
|
2984
|
+
start(streamController) {
|
|
2985
|
+
function push() {
|
|
2986
|
+
reader.read().then(({ done, value }) => {
|
|
2987
|
+
if (done) {
|
|
2988
|
+
fileBuffer.flip();
|
|
2989
|
+
const blob = new Blob([fileBuffer.toArrayBuffer()]);
|
|
2990
|
+
streamController.close();
|
|
2991
|
+
data.completed(blob ? { fileName, blob } : void 0);
|
|
2992
|
+
return;
|
|
2993
|
+
}
|
|
2994
|
+
if (!value) return;
|
|
2995
|
+
streamController.enqueue(value);
|
|
2996
|
+
fileBuffer.append(value);
|
|
2997
|
+
data.offset += value.byteLength;
|
|
2998
|
+
push();
|
|
2999
|
+
});
|
|
3000
|
+
}
|
|
3001
|
+
push();
|
|
3002
|
+
},
|
|
3003
|
+
cancel(_reason) {
|
|
3004
|
+
fileBuffer.clear();
|
|
3005
|
+
abortController.abort();
|
|
3006
|
+
}
|
|
3007
|
+
});
|
|
3008
|
+
data.isCancelable = true;
|
|
3009
|
+
data.onCancelClick = async () => {
|
|
3010
|
+
data.isCanceled = true;
|
|
3011
|
+
stream.cancel("");
|
|
3012
|
+
data.completed();
|
|
3013
|
+
};
|
|
3014
|
+
}
|
|
3015
|
+
const timers = {};
|
|
3016
|
+
const debounce = (key, callback, wait) => {
|
|
3017
|
+
if (timers[key]) {
|
|
3018
|
+
clearTimeout(timers[key]);
|
|
3019
|
+
}
|
|
3020
|
+
timers[key] = window.setTimeout(() => {
|
|
3021
|
+
callback();
|
|
3022
|
+
delete timers[key];
|
|
3023
|
+
}, wait);
|
|
3024
|
+
};
|
|
3025
|
+
const showMessage = (message, result, options = {}) => {
|
|
3026
|
+
debounce(
|
|
3027
|
+
message.toString(),
|
|
3028
|
+
() => {
|
|
3029
|
+
let type;
|
|
3030
|
+
if (typeof result === "boolean") {
|
|
3031
|
+
type = result ? "success" : "error";
|
|
3032
|
+
} else {
|
|
3033
|
+
type = result;
|
|
3034
|
+
}
|
|
3035
|
+
const toast = useToast();
|
|
3036
|
+
toast.open(
|
|
3037
|
+
Object.assign(
|
|
3038
|
+
{},
|
|
3039
|
+
{
|
|
3040
|
+
message,
|
|
3041
|
+
type
|
|
3042
|
+
},
|
|
3043
|
+
options
|
|
3044
|
+
)
|
|
3045
|
+
);
|
|
3046
|
+
if (type === "error") {
|
|
3047
|
+
console.error(message);
|
|
3048
|
+
}
|
|
3049
|
+
},
|
|
3050
|
+
300
|
|
3051
|
+
);
|
|
3052
|
+
};
|
|
3053
|
+
const uploadOwnerMap = reactive(/* @__PURE__ */ new Map());
|
|
3054
|
+
const refreshCallbacks = reactive(/* @__PURE__ */ new Map());
|
|
3055
|
+
const registerUploadOwner = (sessionId, apiKey) => {
|
|
3056
|
+
if (!sessionId || !apiKey) return;
|
|
3057
|
+
uploadOwnerMap.set(sessionId, apiKey);
|
|
3058
|
+
};
|
|
3059
|
+
const clearUploadOwner = (sessionId) => {
|
|
3060
|
+
if (!sessionId) return;
|
|
3061
|
+
uploadOwnerMap.delete(sessionId);
|
|
3062
|
+
};
|
|
3063
|
+
const registerRefresh = (apiKey, cb) => {
|
|
3064
|
+
if (!apiKey || !cb) return;
|
|
3065
|
+
refreshCallbacks.set(apiKey, cb);
|
|
3066
|
+
};
|
|
3067
|
+
const unregisterRefresh = (apiKey) => {
|
|
3068
|
+
if (!apiKey) return;
|
|
3069
|
+
refreshCallbacks.delete(apiKey);
|
|
3070
|
+
};
|
|
3071
|
+
const getRefreshBySession = (sessionId) => {
|
|
3072
|
+
const apiKey = uploadOwnerMap.get(sessionId);
|
|
3073
|
+
return apiKey ? refreshCallbacks.get(apiKey) : void 0;
|
|
3074
|
+
};
|
|
3075
|
+
const exceptColumn = ["_RID", "createDatetime", "createUser", "updateDatetime", "updateUser"];
|
|
3076
|
+
const excelProgressStoreSetup = () => {
|
|
3077
|
+
const currentValue = ref(0);
|
|
3078
|
+
const totalValue = ref(0);
|
|
3079
|
+
const progressTime = ref(0);
|
|
3080
|
+
const remainTime = ref(0);
|
|
3081
|
+
return {
|
|
3082
|
+
currentValue,
|
|
3083
|
+
totalValue,
|
|
3084
|
+
progressTime,
|
|
3085
|
+
remainTime
|
|
3086
|
+
};
|
|
3087
|
+
};
|
|
3088
|
+
const excelStoreSetup = () => {
|
|
3089
|
+
const locale = useMozLocale();
|
|
3090
|
+
const showPopup = ref(false);
|
|
3091
|
+
const isOverwrite = ref(false);
|
|
3092
|
+
const targetTable = ref(void 0);
|
|
3093
|
+
const exportFormat = ref("excel");
|
|
3094
|
+
const excelInfo = ref({
|
|
3095
|
+
keyColumns: [],
|
|
3096
|
+
columnLayout: "",
|
|
3097
|
+
columnMap: {},
|
|
3098
|
+
apiKey: "",
|
|
3099
|
+
apiParams: {},
|
|
3100
|
+
targetTable: "",
|
|
3101
|
+
refreshKey: "",
|
|
3102
|
+
useDataPreclear: false,
|
|
3103
|
+
disableMasterProperty: false,
|
|
3104
|
+
targetStorage: "postgresql"
|
|
3105
|
+
});
|
|
3106
|
+
const excelAPI = ref({
|
|
3107
|
+
onUpload: (_formData) => {
|
|
3108
|
+
},
|
|
3109
|
+
onAdd: (_data) => {
|
|
3110
|
+
},
|
|
3111
|
+
onTruncate: () => {
|
|
3112
|
+
},
|
|
3113
|
+
onValidation: (_binding, _value, _dataItem) => {
|
|
3114
|
+
},
|
|
3115
|
+
onRefresh: () => {
|
|
3116
|
+
},
|
|
3117
|
+
onDownload: () => {
|
|
3118
|
+
},
|
|
3119
|
+
onNotify: (_e) => {
|
|
3120
|
+
}
|
|
3121
|
+
});
|
|
3122
|
+
const file = ref(null);
|
|
3123
|
+
const excelFileMap = reactive(/* @__PURE__ */ new Map());
|
|
3124
|
+
const triggerRefreshBySession = (sessionId) => {
|
|
3125
|
+
var _a, _b;
|
|
3126
|
+
const cb = getRefreshBySession(sessionId);
|
|
3127
|
+
if (cb) {
|
|
3128
|
+
cb();
|
|
3129
|
+
(_b = (_a = excelAPI.value).onRefresh) == null ? void 0 : _b.call(_a);
|
|
3130
|
+
return true;
|
|
3131
|
+
}
|
|
3132
|
+
return false;
|
|
3133
|
+
};
|
|
3134
|
+
const isExcelUploadSuccess = ref("init");
|
|
3135
|
+
const initialize = (info = {}, api = {}) => {
|
|
3136
|
+
excelInfo.value = { ...excelInfo.value, ...info };
|
|
3137
|
+
excelAPI.value = { ...excelAPI.value, ...api };
|
|
3138
|
+
isExcelUploadSuccess.value = "init";
|
|
3139
|
+
};
|
|
3140
|
+
const setInfo = (info) => {
|
|
3141
|
+
excelInfo.value = { ...excelInfo.value, ...info };
|
|
3142
|
+
};
|
|
3143
|
+
const setAPI = (api) => {
|
|
3144
|
+
excelAPI.value = { ...excelAPI.value, ...api };
|
|
3145
|
+
};
|
|
3146
|
+
const setExportFormat = (format) => {
|
|
3147
|
+
exportFormat.value = format;
|
|
3148
|
+
};
|
|
3149
|
+
const setUploadSuccess = (status) => {
|
|
3150
|
+
isExcelUploadSuccess.value = status;
|
|
3151
|
+
};
|
|
3152
|
+
const show = (_isOverwrite = true) => {
|
|
3153
|
+
isOverwrite.value = _isOverwrite;
|
|
3154
|
+
showPopup.value = true;
|
|
3155
|
+
};
|
|
3156
|
+
const hide = () => {
|
|
3157
|
+
showPopup.value = false;
|
|
3158
|
+
};
|
|
3159
|
+
const downloadInfo = ref(null);
|
|
3160
|
+
const download = async (param = {}) => {
|
|
3161
|
+
if (file.value) {
|
|
3162
|
+
return showMessage(locale.value.Grid.alreadyExcelProgress, false);
|
|
3163
|
+
}
|
|
3164
|
+
const id = generateGUID();
|
|
3165
|
+
file.value = new FileParameter("Download", id);
|
|
3166
|
+
downloadInfo.value = {
|
|
3167
|
+
current: 0,
|
|
3168
|
+
total: 100,
|
|
3169
|
+
remainTime: -1,
|
|
3170
|
+
sessionID: id,
|
|
3171
|
+
fileName: ""
|
|
3172
|
+
};
|
|
3173
|
+
param.session_id = id;
|
|
3174
|
+
try {
|
|
3175
|
+
const url = `/excel/download/${param.sample_data ? "sample" : "fetch"}`;
|
|
3176
|
+
await responseStream(url, file.value, param);
|
|
3177
|
+
file.value.onCompleted = onCompleted;
|
|
3178
|
+
file.value.onCancelClick = onCancelClick;
|
|
3179
|
+
} catch {
|
|
3180
|
+
file.value = null;
|
|
3181
|
+
return showMessage(locale.value.Grid.downloadFail, false);
|
|
3182
|
+
}
|
|
3183
|
+
};
|
|
3184
|
+
const onCompleted = (param) => {
|
|
3185
|
+
if (!param.blobInfo) return;
|
|
3186
|
+
saveAs(param.blobInfo.blob, param.blobInfo.fileName);
|
|
3187
|
+
file.value = null;
|
|
3188
|
+
downloadInfo.value = null;
|
|
3189
|
+
};
|
|
3190
|
+
const onCancelClick = (_param) => {
|
|
3191
|
+
file.value = null;
|
|
3192
|
+
downloadInfo.value = null;
|
|
3193
|
+
};
|
|
3194
|
+
const requestGenerateExcel = async (param = {}, requestOptions = {}) => {
|
|
3195
|
+
const reqUrl = `/api/module/data-transfer/${param.project_id ?? "none"}/excel/generate-download-url`;
|
|
3196
|
+
const result = await request(reqUrl, "post", param, requestOptions);
|
|
3197
|
+
const sessionId = param.client_id;
|
|
3198
|
+
const fileName = result.data.data.file_name;
|
|
3199
|
+
const decodedFileName = decodeFileName(fileName);
|
|
3200
|
+
excelFileMap.set(sessionId, decodedFileName);
|
|
3201
|
+
return result;
|
|
3202
|
+
};
|
|
3203
|
+
const normalizeColumns = (flexGrid) => {
|
|
3204
|
+
const cols = flexGrid == null ? void 0 : flexGrid.columns;
|
|
3205
|
+
if (!cols) return [];
|
|
3206
|
+
if (typeof cols.getAll === "function") {
|
|
3207
|
+
const MOZ_TYPE_TO_DATATYPE = {
|
|
3208
|
+
number: DataType.Number,
|
|
3209
|
+
boolean: DataType.Boolean,
|
|
3210
|
+
date: DataType.Date,
|
|
3211
|
+
string: DataType.String
|
|
3212
|
+
};
|
|
3213
|
+
return cols.getAll().map((c) => ({
|
|
3214
|
+
binding: c.id,
|
|
3215
|
+
header: c.header ?? c.label ?? c.id,
|
|
3216
|
+
dataType: MOZ_TYPE_TO_DATATYPE[c.type] ?? DataType.String,
|
|
3217
|
+
visible: c.visible !== false,
|
|
3218
|
+
format: void 0,
|
|
3219
|
+
isRequired: c.required ?? false
|
|
3220
|
+
}));
|
|
3221
|
+
}
|
|
3222
|
+
if (typeof cols.filter === "function") return Array.from(cols);
|
|
3223
|
+
return [];
|
|
3224
|
+
};
|
|
3225
|
+
const createColumnMapForImport = (flexGrid, keyColumns) => {
|
|
3226
|
+
const columnMap = {};
|
|
3227
|
+
if (!flexGrid) return columnMap;
|
|
3228
|
+
normalizeColumns(flexGrid).filter((column) => !exceptColumn.includes(column.binding)).forEach((column) => {
|
|
3229
|
+
if (!column.header || !column.binding) return;
|
|
3230
|
+
columnMap[column.header] = {
|
|
3231
|
+
column_name: column.binding,
|
|
3232
|
+
column_type: dataTypeToString(column.dataType || DataType.String),
|
|
3233
|
+
is_required: column.isRequired,
|
|
3234
|
+
is_key: column.binding ? keyColumns == null ? void 0 : keyColumns.includes(column.binding) : false
|
|
3235
|
+
};
|
|
3236
|
+
});
|
|
3237
|
+
return columnMap;
|
|
3238
|
+
};
|
|
3239
|
+
const createColumnMapForExport = (flexGrid, options) => {
|
|
3240
|
+
const columnMap = {};
|
|
3241
|
+
if (!flexGrid) return columnMap;
|
|
3242
|
+
const { visibleOnly = false } = options ?? {};
|
|
3243
|
+
normalizeColumns(flexGrid).filter((column) => !exceptColumn.includes(column.binding)).filter((column) => !visibleOnly || column.visible !== false).forEach((column) => {
|
|
3244
|
+
if (!column.binding) return;
|
|
3245
|
+
columnMap[column.binding] = {
|
|
3246
|
+
column_name: column.header,
|
|
3247
|
+
column_type: dataTypeToString(column.dataType || DataType.String),
|
|
3248
|
+
column_format: column.format
|
|
3249
|
+
};
|
|
3250
|
+
});
|
|
3251
|
+
return columnMap;
|
|
3252
|
+
};
|
|
3253
|
+
const createFieldMapForExport = (pivotGrid) => {
|
|
3254
|
+
const columnMap = {};
|
|
3255
|
+
if (!pivotGrid) return columnMap;
|
|
3256
|
+
pivotGrid.engine.fields.filter((field) => !exceptColumn.includes(field.binding)).forEach((field) => {
|
|
3257
|
+
if (!field.binding) return;
|
|
3258
|
+
columnMap[field.binding] = {
|
|
3259
|
+
column_name: field.header,
|
|
3260
|
+
column_type: dataTypeToString(field.dataType || DataType.String)
|
|
3261
|
+
};
|
|
3262
|
+
});
|
|
3263
|
+
return columnMap;
|
|
3264
|
+
};
|
|
3265
|
+
const updateDownloadStatus = (newData) => {
|
|
3266
|
+
var _a;
|
|
3267
|
+
if (downloadInfo.value == null || ((_a = downloadInfo.value) == null ? void 0 : _a.sessionID) !== newData.sessionID) return;
|
|
3268
|
+
downloadInfo.value.current = newData.current;
|
|
3269
|
+
downloadInfo.value.total = newData.total;
|
|
3270
|
+
downloadInfo.value.remainTime = newData.remainTime;
|
|
3271
|
+
downloadInfo.value.notiDatetime = newData.notiDatetime;
|
|
3272
|
+
downloadInfo.value.isDone = newData.isDone;
|
|
3273
|
+
};
|
|
3274
|
+
const downloadFromS3 = (presignedUrl) => {
|
|
3275
|
+
if (!presignedUrl) return;
|
|
3276
|
+
try {
|
|
3277
|
+
const link = document.createElement("a");
|
|
3278
|
+
link.setAttribute("href", presignedUrl);
|
|
3279
|
+
document.body.appendChild(link);
|
|
3280
|
+
link.click();
|
|
3281
|
+
document.body.removeChild(link);
|
|
3282
|
+
downloadInfo.value = null;
|
|
3283
|
+
} catch (err) {
|
|
3284
|
+
throw err;
|
|
3285
|
+
}
|
|
3286
|
+
};
|
|
3287
|
+
class ExcelInfo {
|
|
3288
|
+
constructor(gridKeys, flexGrid) {
|
|
3289
|
+
__publicField(this, "keyColumns");
|
|
3290
|
+
__publicField(this, "columnLayout");
|
|
3291
|
+
__publicField(this, "columnMap");
|
|
3292
|
+
this.keyColumns = gridKeys;
|
|
3293
|
+
this.columnLayout = flexGrid.columnLayout;
|
|
3294
|
+
this.columnMap = createColumnMapForImport(flexGrid, gridKeys);
|
|
3295
|
+
}
|
|
3296
|
+
}
|
|
3297
|
+
const newExcelInfo = (gridKeys, flexGrid) => new ExcelInfo(gridKeys, flexGrid);
|
|
3298
|
+
const newExcelApi = (apiKey, flexGrid, sampleData, fileName, refreshCB, excelUpload, autoTransaction) => {
|
|
3299
|
+
registerRefresh(apiKey, refreshCB);
|
|
3300
|
+
return {
|
|
3301
|
+
onUpload: (formData) => excelUpload(formData),
|
|
3302
|
+
onAdd: async (data) => {
|
|
3303
|
+
try {
|
|
3304
|
+
isExcelUploadSuccess.value = "success";
|
|
3305
|
+
return await autoTransaction({ url: apiKey, param: data, method: "POST" });
|
|
3306
|
+
} catch (err) {
|
|
3307
|
+
console.error(err);
|
|
3308
|
+
isExcelUploadSuccess.value = "error";
|
|
3309
|
+
}
|
|
3310
|
+
},
|
|
3311
|
+
onTruncate: async () => {
|
|
3312
|
+
try {
|
|
3313
|
+
isExcelUploadSuccess.value = "success";
|
|
3314
|
+
return await autoTransaction({ url: apiKey, param: [], method: "DELETE" });
|
|
3315
|
+
} catch (err) {
|
|
3316
|
+
console.error(err);
|
|
3317
|
+
isExcelUploadSuccess.value = "error";
|
|
3318
|
+
}
|
|
3319
|
+
return void 0;
|
|
3320
|
+
},
|
|
3321
|
+
onDownload: () => download({
|
|
3322
|
+
sample_data: sampleData,
|
|
3323
|
+
file_name: fileName,
|
|
3324
|
+
column_map: createColumnMapForExport(flexGrid)
|
|
3325
|
+
}),
|
|
3326
|
+
onRefresh: () => {
|
|
3327
|
+
registerRefresh(apiKey, refreshCB);
|
|
3328
|
+
switch (isExcelUploadSuccess.value) {
|
|
3329
|
+
case "init":
|
|
3330
|
+
break;
|
|
3331
|
+
case "success":
|
|
3332
|
+
showMessage(locale.value.Grid.toastSaveSuccess, true);
|
|
3333
|
+
break;
|
|
3334
|
+
case "error":
|
|
3335
|
+
showMessage(locale.value.Grid.toastSaveError, false);
|
|
3336
|
+
break;
|
|
3337
|
+
}
|
|
3338
|
+
isExcelUploadSuccess.value = "init";
|
|
3339
|
+
refreshCB();
|
|
3340
|
+
},
|
|
3341
|
+
onNotify: (e) => {
|
|
3342
|
+
if (showPopup.value) showMessage(e.message, e.type);
|
|
3343
|
+
}
|
|
3344
|
+
};
|
|
3345
|
+
};
|
|
3346
|
+
return {
|
|
3347
|
+
showPopup,
|
|
3348
|
+
isOverwrite,
|
|
3349
|
+
exportFormat,
|
|
3350
|
+
excelInfo,
|
|
3351
|
+
excelAPI,
|
|
3352
|
+
file,
|
|
3353
|
+
excelFileMap,
|
|
3354
|
+
downloadInfo,
|
|
3355
|
+
initialize,
|
|
3356
|
+
setInfo,
|
|
3357
|
+
newExcelInfo,
|
|
3358
|
+
setAPI,
|
|
3359
|
+
newExcelApi,
|
|
3360
|
+
setExportFormat,
|
|
3361
|
+
setUploadSuccess,
|
|
3362
|
+
show,
|
|
3363
|
+
hide,
|
|
3364
|
+
download,
|
|
3365
|
+
createColumnMapForImport,
|
|
3366
|
+
createColumnMapForExport,
|
|
3367
|
+
createFieldMapForExport,
|
|
3368
|
+
updateDownloadStatus,
|
|
3369
|
+
downloadFromS3,
|
|
3370
|
+
requestGenerateExcel,
|
|
3371
|
+
targetTable,
|
|
3372
|
+
// multi-tab helpers
|
|
3373
|
+
registerUploadOwner,
|
|
3374
|
+
clearUploadOwner,
|
|
3375
|
+
registerRefresh,
|
|
3376
|
+
unregisterRefresh,
|
|
3377
|
+
triggerRefreshBySession
|
|
3378
|
+
};
|
|
3379
|
+
};
|
|
3380
|
+
const dataTypeToString = (type) => {
|
|
3381
|
+
switch (type) {
|
|
3382
|
+
case DataType.String:
|
|
3383
|
+
return "System.String";
|
|
3384
|
+
case DataType.Number:
|
|
3385
|
+
return "System.Decimal";
|
|
3386
|
+
case DataType.Boolean:
|
|
3387
|
+
return "System.Boolean";
|
|
3388
|
+
case DataType.Date:
|
|
3389
|
+
return "System.DateTime";
|
|
3390
|
+
default:
|
|
3391
|
+
return "System.String";
|
|
3392
|
+
}
|
|
3393
|
+
};
|
|
3394
|
+
const decodeFileName = (fileName) => decodeURIComponent(fileName).replace(/\+/g, " ");
|
|
3395
|
+
const useExcelStore = defineStore("excelPopup", excelStoreSetup);
|
|
3396
|
+
const useExcelDownloadStore = defineStore("excelDownload", excelProgressStoreSetup);
|
|
3397
|
+
const useExcelUploadStore = defineStore("excelUpload", excelProgressStoreSetup);
|
|
3398
|
+
export {
|
|
3399
|
+
useExcelStore as a,
|
|
3400
|
+
useExcelUploadStore as b,
|
|
3401
|
+
dataTypeToString as d,
|
|
3402
|
+
generateGUID as g,
|
|
3403
|
+
useExcelDownloadStore as u
|
|
3404
|
+
};
|