@rtzh/engine 0.0.9 → 0.0.11
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/Build/ThirdParty/Workers/zip-web-worker.js +586 -480
- package/Build/Workers/chunk-3CD4WIF4.js +101 -0
- package/Build/Workers/chunk-3PWX65TL.js +398 -0
- package/Build/Workers/chunk-4CQDMEZY.js +2058 -0
- package/Build/Workers/chunk-4GZLJPDW.js +8366 -0
- package/Build/Workers/chunk-5WKGRIN6.js +114 -0
- package/Build/Workers/chunk-6BNIWSFA.js +940 -0
- package/Build/Workers/chunk-6TWMNB7Q.js +455 -0
- package/Build/Workers/chunk-72Q33KL6.js +280 -0
- package/Build/Workers/chunk-74HENCNJ.js +171 -0
- package/Build/Workers/chunk-7C2MOK27.js +57 -0
- package/Build/Workers/chunk-7EFYX4FL.js +642 -0
- package/Build/Workers/chunk-7RAUHLDW.js +497 -0
- package/Build/Workers/chunk-B3FJJGCH.js +305 -0
- package/Build/Workers/chunk-BIJHMMCD.js +138 -0
- package/Build/Workers/chunk-CGAHG2LR.js +163 -0
- package/Build/Workers/chunk-CQ5PWUMS.js +37 -0
- package/Build/Workers/chunk-CQB3KRGK.js +198 -0
- package/Build/Workers/chunk-DHWZGIOA.js +139 -0
- package/Build/Workers/chunk-EDFDPOY6.js +55 -0
- package/Build/Workers/chunk-F2BQY3GT.js +1317 -0
- package/Build/Workers/chunk-FARHIBOA.js +75 -0
- package/Build/Workers/chunk-G6PDJHNG.js +476 -0
- package/Build/Workers/chunk-GCPD37SU.js +1054 -0
- package/Build/Workers/chunk-GDHDJK32.js +1045 -0
- package/Build/Workers/chunk-GNGGEDZK.js +352 -0
- package/Build/Workers/chunk-GNGZG6C6.js +162 -0
- package/Build/Workers/chunk-HFCJLXTG.js +55 -0
- package/Build/Workers/chunk-HKII76UV.js +1800 -0
- package/Build/Workers/chunk-HWUHUN7Z.js +387 -0
- package/Build/Workers/chunk-I3VVEQQ6.js +439 -0
- package/Build/Workers/chunk-IKMU6YHA.js +288 -0
- package/Build/Workers/chunk-J4PNHKWO.js +2719 -0
- package/Build/Workers/chunk-JFLJS4QU.js +1443 -0
- package/Build/Workers/chunk-JJWMDUOJ.js +44 -0
- package/Build/Workers/chunk-JOQFYJZ2.js +692 -0
- package/Build/Workers/chunk-JUJONRWD.js +788 -0
- package/Build/Workers/chunk-MCJRXFRL.js +102 -0
- package/Build/Workers/chunk-MLL4AAXV.js +1460 -0
- package/Build/Workers/chunk-MPCZC3G6.js +414 -0
- package/Build/Workers/chunk-MPHEIDPB.js +629 -0
- package/Build/Workers/chunk-NXZJKIYD.js +97 -0
- package/Build/Workers/chunk-OD7UYXFV.js +352 -0
- package/Build/Workers/chunk-R2AFDOIY.js +778 -0
- package/Build/Workers/chunk-RBLCJVK6.js +73 -0
- package/Build/Workers/chunk-SCF2OVAZ.js +219 -0
- package/Build/Workers/chunk-SJX7UJNW.js +241 -0
- package/Build/Workers/chunk-SZQC2TUH.js +368 -0
- package/Build/Workers/chunk-TAWVKT4B.js +58 -0
- package/Build/Workers/chunk-U267N6IJ.js +299 -0
- package/Build/Workers/chunk-UZXJSLDO.js +3514 -0
- package/Build/Workers/chunk-VP2OAU4C.js +124 -0
- package/Build/Workers/chunk-XMIENZET.js +256 -0
- package/Build/Workers/chunk-XXD3TQVI.js +837 -0
- package/Build/Workers/chunk-YCTK62TY.js +1483 -0
- package/Build/Workers/chunk-YWSB7PZP.js +511 -0
- package/Build/Workers/chunk-ZVXETFPZ.js +1067 -0
- package/Build/Workers/chunk-ZXZTWDTN.js +682 -0
- package/Build/Workers/combineGeometry.js +24 -24
- package/Build/Workers/createBoxGeometry.js +18 -18
- package/Build/Workers/createBoxOutlineGeometry.js +16 -16
- package/Build/Workers/createCircleGeometry.js +26 -26
- package/Build/Workers/createCircleOutlineGeometry.js +19 -19
- package/Build/Workers/createCoplanarPolygonGeometry.js +33 -33
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
- package/Build/Workers/createCorridorGeometry.js +29 -29
- package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
- package/Build/Workers/createCylinderGeometry.js +20 -20
- package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
- package/Build/Workers/createEllipseGeometry.js +26 -26
- package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
- package/Build/Workers/createEllipsoidGeometry.js +19 -19
- package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
- package/Build/Workers/createFrustumGeometry.js +18 -18
- package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
- package/Build/Workers/createGeometry.js +24 -24
- package/Build/Workers/createGroundPolylineGeometry.js +22 -22
- package/Build/Workers/createPlaneGeometry.js +16 -16
- package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
- package/Build/Workers/createPolygonGeometry.js +32 -32
- package/Build/Workers/createPolygonOutlineGeometry.js +30 -30
- package/Build/Workers/createPolylineGeometry.js +25 -25
- package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
- package/Build/Workers/createRectangleGeometry.js +27 -27
- package/Build/Workers/createRectangleOutlineGeometry.js +20 -20
- package/Build/Workers/createSimplePolylineGeometry.js +23 -23
- package/Build/Workers/createSphereGeometry.js +19 -19
- package/Build/Workers/createSphereOutlineGeometry.js +18 -18
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
- package/Build/Workers/createVectorTileGeometries.js +24 -24
- package/Build/Workers/createVectorTilePoints.js +13 -13
- package/Build/Workers/createVectorTilePolygons.js +22 -22
- package/Build/Workers/createVectorTilePolylines.js +14 -14
- package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
- package/Build/Workers/createVerticesFromHeightmap.js +22 -22
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
- package/Build/Workers/createWallGeometry.js +24 -24
- package/Build/Workers/createWallOutlineGeometry.js +23 -23
- package/Build/Workers/decodeDraco.js +10 -10
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +10 -10
- package/Build/Workers/gaussianSplatSorter.js +4 -4
- package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
- package/Build/Workers/incrementallyBuildTerrainPicker.js +10 -10
- package/Build/Workers/transcodeKTX2.js +6 -6
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
- package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
- package/README.md +69 -9
- package/Source/Renderer/AutomaticUniforms.js +76 -1
- package/Source/Renderer/UniformState.js +108 -1
- package/Source/Scene/Cesium3DTileset.js +4157 -4157
- package/Source/Scene/Model/BarycentricWireframePipelineStage.js +462 -414
- package/Source/Scene/Model/LightingPipelineStage.js +17 -2
- package/Source/Scene/Model/MaterialPipelineStage.js +50 -0
- package/Source/Scene/Model/Model.js +3646 -3631
- package/Source/Scene/Model/Model3DTileContent.js +568 -568
- package/Source/Scene/Model/ModelRuntimePrimitive.js +391 -391
- package/Source/Scene/Model/WireframePipelineStage.js +122 -122
- package/Source/Scene/PointLight.js +36 -0
- package/Source/Scene/Scene.js +9 -1
- package/Source/Shaders/Model/LightingStageFS.glsl +33 -0
- package/Source/Shaders/Model/LightingStageFS.js +33 -0
- package/Source/ThirdParty/Workers/zip-web-worker.js +1 -1
- package/Source/ThirdParty/zip-module.wasm +0 -0
- package/index.d.ts +809 -779
- package/index.js +11 -10
- package/package.json +1 -1
|
@@ -1,122 +1,122 @@
|
|
|
1
|
-
import Buffer from "../../Renderer/Buffer.js";
|
|
2
|
-
import BufferUsage from "../../Renderer/BufferUsage.js";
|
|
3
|
-
import defined from "../../Core/defined.js";
|
|
4
|
-
import IndexDatatype from "../../Core/IndexDatatype.js";
|
|
5
|
-
import ModelUtility from "./ModelUtility.js";
|
|
6
|
-
import PrimitiveType from "../../Core/PrimitiveType.js";
|
|
7
|
-
import ShaderDestination from "../../Renderer/ShaderDestination.js";
|
|
8
|
-
import VertexAttributeSemantic from "../VertexAttributeSemantic.js";
|
|
9
|
-
import WireframeIndexGenerator from "../../Core/WireframeIndexGenerator.js";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* The wireframe pipeline stage generates a new index buffer for rendering the
|
|
13
|
-
* structure of the mesh with gl.LINES.
|
|
14
|
-
*
|
|
15
|
-
* @namespace WireframePipelineStage
|
|
16
|
-
* @private
|
|
17
|
-
*/
|
|
18
|
-
const WireframePipelineStage = {
|
|
19
|
-
name: "WireframePipelineStage", // Helps with debugging
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Process a primitive. This modifies the render resources as follows:
|
|
24
|
-
* <ul>
|
|
25
|
-
* <li>Adds a define to the fragment shader to prevent extra shading of the lines.</li>
|
|
26
|
-
* <li>Adds a separate index buffer for wireframe indices</li>
|
|
27
|
-
* <li>Updates the primitive type and count for rendering with gl.LINES</li>
|
|
28
|
-
* </ul>
|
|
29
|
-
*
|
|
30
|
-
* @param {PrimitiveRenderResources} renderResources The render resources for this node
|
|
31
|
-
* @param {ModelComponents.primitive} primitive The primitive
|
|
32
|
-
* @param {FrameState} frameState The frame state
|
|
33
|
-
*/
|
|
34
|
-
WireframePipelineStage.process = function (
|
|
35
|
-
renderResources,
|
|
36
|
-
primitive,
|
|
37
|
-
frameState,
|
|
38
|
-
) {
|
|
39
|
-
const model = renderResources.model;
|
|
40
|
-
|
|
41
|
-
if (model.debugWireframeMode === "barycentric") {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Applying normal mapping to the lines will result in rendering
|
|
46
|
-
// errors on Linux. This define is added to disable normal
|
|
47
|
-
// mapping in the shader.
|
|
48
|
-
const shaderBuilder = renderResources.shaderBuilder;
|
|
49
|
-
shaderBuilder.addDefine(
|
|
50
|
-
"HAS_WIREFRAME",
|
|
51
|
-
undefined,
|
|
52
|
-
ShaderDestination.FRAGMENT,
|
|
53
|
-
);
|
|
54
|
-
const wireframeIndexBuffer = createWireframeIndexBuffer(
|
|
55
|
-
primitive,
|
|
56
|
-
renderResources.indices,
|
|
57
|
-
frameState,
|
|
58
|
-
);
|
|
59
|
-
model._pipelineResources.push(wireframeIndexBuffer);
|
|
60
|
-
renderResources.wireframeIndexBuffer = wireframeIndexBuffer;
|
|
61
|
-
|
|
62
|
-
// We only need to count memory for the generated buffer. In WebGL 1, the CPU
|
|
63
|
-
// copy of the original indices is already counted in the geometry stage,
|
|
64
|
-
// and in WebGL 2, the CPU copy of the original indices (generated from the
|
|
65
|
-
// data of the original buffer) is discarded after generating the wireframe
|
|
66
|
-
// indices.
|
|
67
|
-
const hasCpuCopy = false;
|
|
68
|
-
model.statistics.addBuffer(wireframeIndexBuffer, hasCpuCopy);
|
|
69
|
-
|
|
70
|
-
// Update render resources so we render LINES with the correct index count
|
|
71
|
-
const originalPrimitiveType = renderResources.primitiveType;
|
|
72
|
-
const originalCount = renderResources.count;
|
|
73
|
-
renderResources.primitiveType = PrimitiveType.LINES;
|
|
74
|
-
renderResources.count = WireframeIndexGenerator.getWireframeIndicesCount(
|
|
75
|
-
originalPrimitiveType,
|
|
76
|
-
originalCount,
|
|
77
|
-
);
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
function createWireframeIndexBuffer(primitive, indices, frameState) {
|
|
81
|
-
const positionAttribute = ModelUtility.getAttributeBySemantic(
|
|
82
|
-
primitive,
|
|
83
|
-
VertexAttributeSemantic.POSITION,
|
|
84
|
-
);
|
|
85
|
-
const vertexCount = positionAttribute.count;
|
|
86
|
-
const webgl2 = frameState.context.webgl2;
|
|
87
|
-
|
|
88
|
-
let originalIndices;
|
|
89
|
-
if (defined(indices)) {
|
|
90
|
-
const indicesBuffer = indices.buffer;
|
|
91
|
-
const indicesCount = indices.count;
|
|
92
|
-
if (defined(indicesBuffer) && webgl2) {
|
|
93
|
-
const useUint8Array = indicesBuffer.sizeInBytes === indicesCount;
|
|
94
|
-
originalIndices = useUint8Array
|
|
95
|
-
? new Uint8Array(indicesCount)
|
|
96
|
-
: IndexDatatype.createTypedArray(vertexCount, indicesCount);
|
|
97
|
-
|
|
98
|
-
indicesBuffer.getBufferData(originalIndices);
|
|
99
|
-
} else {
|
|
100
|
-
originalIndices = indices.typedArray;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const primitiveType = primitive.primitiveType;
|
|
105
|
-
const wireframeIndices = WireframeIndexGenerator.createWireframeIndices(
|
|
106
|
-
primitiveType,
|
|
107
|
-
vertexCount,
|
|
108
|
-
originalIndices,
|
|
109
|
-
);
|
|
110
|
-
const indexDatatype = IndexDatatype.fromSizeInBytes(
|
|
111
|
-
wireframeIndices.BYTES_PER_ELEMENT,
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
return Buffer.createIndexBuffer({
|
|
115
|
-
context: frameState.context,
|
|
116
|
-
typedArray: wireframeIndices,
|
|
117
|
-
usage: BufferUsage.STATIC_DRAW,
|
|
118
|
-
indexDatatype: indexDatatype,
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export default WireframePipelineStage;
|
|
1
|
+
import Buffer from "../../Renderer/Buffer.js";
|
|
2
|
+
import BufferUsage from "../../Renderer/BufferUsage.js";
|
|
3
|
+
import defined from "../../Core/defined.js";
|
|
4
|
+
import IndexDatatype from "../../Core/IndexDatatype.js";
|
|
5
|
+
import ModelUtility from "./ModelUtility.js";
|
|
6
|
+
import PrimitiveType from "../../Core/PrimitiveType.js";
|
|
7
|
+
import ShaderDestination from "../../Renderer/ShaderDestination.js";
|
|
8
|
+
import VertexAttributeSemantic from "../VertexAttributeSemantic.js";
|
|
9
|
+
import WireframeIndexGenerator from "../../Core/WireframeIndexGenerator.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The wireframe pipeline stage generates a new index buffer for rendering the
|
|
13
|
+
* structure of the mesh with gl.LINES.
|
|
14
|
+
*
|
|
15
|
+
* @namespace WireframePipelineStage
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
const WireframePipelineStage = {
|
|
19
|
+
name: "WireframePipelineStage", // Helps with debugging
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Process a primitive. This modifies the render resources as follows:
|
|
24
|
+
* <ul>
|
|
25
|
+
* <li>Adds a define to the fragment shader to prevent extra shading of the lines.</li>
|
|
26
|
+
* <li>Adds a separate index buffer for wireframe indices</li>
|
|
27
|
+
* <li>Updates the primitive type and count for rendering with gl.LINES</li>
|
|
28
|
+
* </ul>
|
|
29
|
+
*
|
|
30
|
+
* @param {PrimitiveRenderResources} renderResources The render resources for this node
|
|
31
|
+
* @param {ModelComponents.primitive} primitive The primitive
|
|
32
|
+
* @param {FrameState} frameState The frame state
|
|
33
|
+
*/
|
|
34
|
+
WireframePipelineStage.process = function (
|
|
35
|
+
renderResources,
|
|
36
|
+
primitive,
|
|
37
|
+
frameState,
|
|
38
|
+
) {
|
|
39
|
+
const model = renderResources.model;
|
|
40
|
+
|
|
41
|
+
if (model.debugWireframeMode === "barycentric") {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Applying normal mapping to the lines will result in rendering
|
|
46
|
+
// errors on Linux. This define is added to disable normal
|
|
47
|
+
// mapping in the shader.
|
|
48
|
+
const shaderBuilder = renderResources.shaderBuilder;
|
|
49
|
+
shaderBuilder.addDefine(
|
|
50
|
+
"HAS_WIREFRAME",
|
|
51
|
+
undefined,
|
|
52
|
+
ShaderDestination.FRAGMENT,
|
|
53
|
+
);
|
|
54
|
+
const wireframeIndexBuffer = createWireframeIndexBuffer(
|
|
55
|
+
primitive,
|
|
56
|
+
renderResources.indices,
|
|
57
|
+
frameState,
|
|
58
|
+
);
|
|
59
|
+
model._pipelineResources.push(wireframeIndexBuffer);
|
|
60
|
+
renderResources.wireframeIndexBuffer = wireframeIndexBuffer;
|
|
61
|
+
|
|
62
|
+
// We only need to count memory for the generated buffer. In WebGL 1, the CPU
|
|
63
|
+
// copy of the original indices is already counted in the geometry stage,
|
|
64
|
+
// and in WebGL 2, the CPU copy of the original indices (generated from the
|
|
65
|
+
// data of the original buffer) is discarded after generating the wireframe
|
|
66
|
+
// indices.
|
|
67
|
+
const hasCpuCopy = false;
|
|
68
|
+
model.statistics.addBuffer(wireframeIndexBuffer, hasCpuCopy);
|
|
69
|
+
|
|
70
|
+
// Update render resources so we render LINES with the correct index count
|
|
71
|
+
const originalPrimitiveType = renderResources.primitiveType;
|
|
72
|
+
const originalCount = renderResources.count;
|
|
73
|
+
renderResources.primitiveType = PrimitiveType.LINES;
|
|
74
|
+
renderResources.count = WireframeIndexGenerator.getWireframeIndicesCount(
|
|
75
|
+
originalPrimitiveType,
|
|
76
|
+
originalCount,
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
function createWireframeIndexBuffer(primitive, indices, frameState) {
|
|
81
|
+
const positionAttribute = ModelUtility.getAttributeBySemantic(
|
|
82
|
+
primitive,
|
|
83
|
+
VertexAttributeSemantic.POSITION,
|
|
84
|
+
);
|
|
85
|
+
const vertexCount = positionAttribute.count;
|
|
86
|
+
const webgl2 = frameState.context.webgl2;
|
|
87
|
+
|
|
88
|
+
let originalIndices;
|
|
89
|
+
if (defined(indices)) {
|
|
90
|
+
const indicesBuffer = indices.buffer;
|
|
91
|
+
const indicesCount = indices.count;
|
|
92
|
+
if (defined(indicesBuffer) && webgl2) {
|
|
93
|
+
const useUint8Array = indicesBuffer.sizeInBytes === indicesCount;
|
|
94
|
+
originalIndices = useUint8Array
|
|
95
|
+
? new Uint8Array(indicesCount)
|
|
96
|
+
: IndexDatatype.createTypedArray(vertexCount, indicesCount);
|
|
97
|
+
|
|
98
|
+
indicesBuffer.getBufferData(originalIndices);
|
|
99
|
+
} else {
|
|
100
|
+
originalIndices = indices.typedArray;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const primitiveType = primitive.primitiveType;
|
|
105
|
+
const wireframeIndices = WireframeIndexGenerator.createWireframeIndices(
|
|
106
|
+
primitiveType,
|
|
107
|
+
vertexCount,
|
|
108
|
+
originalIndices,
|
|
109
|
+
);
|
|
110
|
+
const indexDatatype = IndexDatatype.fromSizeInBytes(
|
|
111
|
+
wireframeIndices.BYTES_PER_ELEMENT,
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
return Buffer.createIndexBuffer({
|
|
115
|
+
context: frameState.context,
|
|
116
|
+
typedArray: wireframeIndices,
|
|
117
|
+
usage: BufferUsage.STATIC_DRAW,
|
|
118
|
+
indexDatatype: indexDatatype,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export default WireframePipelineStage;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import Cartesian3 from "../Core/Cartesian3.js";
|
|
2
|
+
import Check from "../Core/Check.js";
|
|
3
|
+
import Color from "../Core/Color.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A point light that radiates light in all directions from a single point in space.
|
|
7
|
+
* Point lights are useful for simulating local light sources like light bulbs or torches.
|
|
8
|
+
*
|
|
9
|
+
* @param {object} options Object with the following properties:
|
|
10
|
+
* @param {Cartesian3} options.position The position of the light in world coordinates.
|
|
11
|
+
* @param {Color} [options.color=Color.WHITE] The color of the light.
|
|
12
|
+
* @param {number} [options.intensity=1.0] The intensity of the light.
|
|
13
|
+
* @param {number} [options.range=Number.MAX_VALUE] The maximum distance the light reaches.
|
|
14
|
+
*
|
|
15
|
+
* @alias PointLight
|
|
16
|
+
* @constructor
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* const pointLight = new Cesium.PointLight({
|
|
20
|
+
* position: Cesium.Cartesian3.fromDegrees(116.0, 39.0, 100),
|
|
21
|
+
* color: new Cesium.Color(1.0, 1.0, 1.0),
|
|
22
|
+
* intensity: 10.0,
|
|
23
|
+
* range: 500.0
|
|
24
|
+
* });
|
|
25
|
+
* viewer.scene.pointLights.push(pointLight);
|
|
26
|
+
*/
|
|
27
|
+
function PointLight(options) {
|
|
28
|
+
Check.typeOf.object("options", options);
|
|
29
|
+
Check.typeOf.object("options.position", options.position);
|
|
30
|
+
this.position = Cartesian3.clone(options.position);
|
|
31
|
+
this.color = Color.clone(options.color ?? Color.WHITE);
|
|
32
|
+
this.intensity = options.intensity ?? 1.0;
|
|
33
|
+
this.range = options.range ?? Number.MAX_VALUE;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default PointLight;
|
package/Source/Scene/Scene.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import BoundingRectangle from "../Core/BoundingRectangle.js";
|
|
2
2
|
import BoundingSphere from "../Core/BoundingSphere.js";
|
|
3
3
|
import BoxGeometry from "../Core/BoxGeometry.js";
|
|
4
4
|
import Cartesian3 from "../Core/Cartesian3.js";
|
|
@@ -761,6 +761,13 @@ function Scene(options) {
|
|
|
761
761
|
*/
|
|
762
762
|
this.light = new SunLight();
|
|
763
763
|
|
|
764
|
+
/**
|
|
765
|
+
* An array of point lights for additional illumination.
|
|
766
|
+
* @type {PointLight[]}
|
|
767
|
+
* @default []
|
|
768
|
+
*/
|
|
769
|
+
this.pointLights = [];
|
|
770
|
+
|
|
764
771
|
/**
|
|
765
772
|
* Whether or not to enable edge visibility rendering for 3D tiles.
|
|
766
773
|
* When enabled, creates a framebuffer with multiple render targets
|
|
@@ -2003,6 +2010,7 @@ Scene.prototype.updateFrameState = function () {
|
|
|
2003
2010
|
this.camera.frustum instanceof OrthographicOffCenterFrustum
|
|
2004
2011
|
);
|
|
2005
2012
|
frameState.light = this.light;
|
|
2013
|
+
frameState.pointLights = this.pointLights;
|
|
2006
2014
|
frameState.cameraUnderground = this._cameraUnderground;
|
|
2007
2015
|
frameState.globeTranslucencyState = this._globeTranslucencyState;
|
|
2008
2016
|
|
|
@@ -76,6 +76,39 @@ vec3 computePbrLighting(in czm_modelMaterial material, in vec3 position)
|
|
|
76
76
|
color = addClearcoatReflection(color, position, lightDirection, lightColorHdr, material);
|
|
77
77
|
#endif
|
|
78
78
|
|
|
79
|
+
#ifdef POINT_LIGHTS
|
|
80
|
+
for (int i = 0; i < 8; i++) {
|
|
81
|
+
if (i >= czm_pointLightCount) {
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
vec3 lightPosEC = czm_pointLightPositionsEC[i];
|
|
85
|
+
vec3 toLightEC = lightPosEC - position;
|
|
86
|
+
float distEC = length(toLightEC);
|
|
87
|
+
vec3 pointLightDir = toLightEC / distEC;
|
|
88
|
+
|
|
89
|
+
float range = czm_pointLightRanges[i];
|
|
90
|
+
if (range > 0.0) {
|
|
91
|
+
vec3 positionWC = (czm_inverseView * vec4(position, 1.0)).xyz;
|
|
92
|
+
vec3 lightPosWC = czm_pointLightPositionsWC[i];
|
|
93
|
+
float distWC = length(lightPosWC - positionWC);
|
|
94
|
+
if (distWC > range) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
float attenuation = 1.0 / (distEC * distEC);
|
|
98
|
+
float fade = clamp(1.0 - distWC / range, 0.0, 1.0);
|
|
99
|
+
attenuation *= fade * fade;
|
|
100
|
+
vec3 pointLightColor = czm_pointLightColors[i];
|
|
101
|
+
float NdotL = clamp(dot(normal, pointLightDir), 0.0, 1.0);
|
|
102
|
+
color += pointLightColor * (material.diffuse / czm_pi) * NdotL * attenuation;
|
|
103
|
+
} else {
|
|
104
|
+
float attenuation = 1.0 / (distEC * distEC);
|
|
105
|
+
vec3 pointLightColor = czm_pointLightColors[i];
|
|
106
|
+
float NdotL = clamp(dot(normal, pointLightDir), 0.0, 1.0);
|
|
107
|
+
color += pointLightColor * (material.diffuse / czm_pi) * NdotL * attenuation;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
#endif
|
|
111
|
+
|
|
79
112
|
return color;
|
|
80
113
|
}
|
|
81
114
|
#endif
|
|
@@ -76,6 +76,39 @@ vec3 computePbrLighting(in czm_modelMaterial material, in vec3 position)\n\
|
|
|
76
76
|
#ifdef USE_CLEARCOAT\n\
|
|
77
77
|
color = addClearcoatReflection(color, position, lightDirection, lightColorHdr, material);\n\
|
|
78
78
|
#endif\n\
|
|
79
|
+
\n\
|
|
80
|
+
#ifdef POINT_LIGHTS\n\
|
|
81
|
+
for (int i = 0; i < 8; i++) {\n\
|
|
82
|
+
if (i >= czm_pointLightCount) {\n\
|
|
83
|
+
break;\n\
|
|
84
|
+
}\n\
|
|
85
|
+
vec3 lightPosEC = czm_pointLightPositionsEC[i];\n\
|
|
86
|
+
vec3 toLightEC = lightPosEC - position;\n\
|
|
87
|
+
float distEC = length(toLightEC);\n\
|
|
88
|
+
vec3 pointLightDir = toLightEC / distEC;\n\
|
|
89
|
+
\n\
|
|
90
|
+
float range = czm_pointLightRanges[i];\n\
|
|
91
|
+
if (range > 0.0) {\n\
|
|
92
|
+
vec3 positionWC = (czm_inverseView * vec4(position, 1.0)).xyz;\n\
|
|
93
|
+
vec3 lightPosWC = czm_pointLightPositionsWC[i];\n\
|
|
94
|
+
float distWC = length(lightPosWC - positionWC);\n\
|
|
95
|
+
if (distWC > range) {\n\
|
|
96
|
+
continue;\n\
|
|
97
|
+
}\n\
|
|
98
|
+
float attenuation = 1.0 / (distEC * distEC);\n\
|
|
99
|
+
float fade = clamp(1.0 - distWC / range, 0.0, 1.0);\n\
|
|
100
|
+
attenuation *= fade * fade;\n\
|
|
101
|
+
vec3 pointLightColor = czm_pointLightColors[i];\n\
|
|
102
|
+
float NdotL = clamp(dot(normal, pointLightDir), 0.0, 1.0);\n\
|
|
103
|
+
color += pointLightColor * (material.diffuse / czm_pi) * NdotL * attenuation;\n\
|
|
104
|
+
} else {\n\
|
|
105
|
+
float attenuation = 1.0 / (distEC * distEC);\n\
|
|
106
|
+
vec3 pointLightColor = czm_pointLightColors[i];\n\
|
|
107
|
+
float NdotL = clamp(dot(normal, pointLightDir), 0.0, 1.0);\n\
|
|
108
|
+
color += pointLightColor * (material.diffuse / czm_pi) * NdotL * attenuation;\n\
|
|
109
|
+
}\n\
|
|
110
|
+
}\n\
|
|
111
|
+
#endif\n\
|
|
79
112
|
\n\
|
|
80
113
|
return color;\n\
|
|
81
114
|
}\n\
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";const{Array:e,Object:t,Number:n,Math:s,Error:r,Uint8Array:i,Uint16Array:a,Uint32Array:o,Int32Array:c,Map:l,DataView:u,Promise:h,TextEncoder:f,crypto:p,postMessage:d,TransformStream:w,ReadableStream:g,WritableStream:m,CompressionStream:_,DecompressionStream:y}=self,b=void 0,S="undefined",z="function",k=[];for(let e=0;256>e;e++){let t=e;for(let e=0;8>e;e++)1&t?t=t>>>1^3988292384:t>>>=1;k[e]=t}class v{constructor(e){this.crc=e||-1}append(e){let t=0|this.crc;for(let n=0,s=0|e.length;s>n;n++)t=t>>>8^k[255&(t^e[n])];this.crc=t}get(){return~this.crc}}class H extends w{constructor(){let e;const t=new v;super({transform(e,n){t.append(e),n.enqueue(e)},flush(){const n=new i(4);new u(n.buffer).setUint32(0,t.get()),e.value=n}}),e=this}}const C={concat(e,t){if(0===e.length||0===t.length)return e.concat(t);const n=e[e.length-1],s=C.getPartial(n);return 32===s?e.concat(t):C._shiftRight(t,s,0|n,e.slice(0,e.length-1))},bitLength(e){const t=e.length;if(0===t)return 0;const n=e[t-1];return 32*(t-1)+C.getPartial(n)},clamp(e,t){if(32*e.length<t)return e;const n=(e=e.slice(0,s.ceil(t/32))).length;return t&=31,n>0&&t&&(e[n-1]=C.partial(t,e[n-1]&2147483648>>t-1,1)),e},partial:(e,t,n)=>32===e?t:(n?0|t:t<<32-e)+1099511627776*e,getPartial:e=>s.round(e/1099511627776)||32,_shiftRight(e,t,n,s){for(void 0===s&&(s=[]);t>=32;t-=32)s.push(n),n=0;if(0===t)return s.concat(e);for(let r=0;r<e.length;r++)s.push(n|e[r]>>>t),n=e[r]<<32-t;const r=e.length?e[e.length-1]:0,i=C.getPartial(r);return s.push(C.partial(t+i&31,t+i>32?n:s.pop(),1)),s}},B={bytes:{fromBits(e){const t=C.bitLength(e)/8,n=new i(t);let s;for(let r=0;t>r;r++)3&r||(s=e[r/4]),n[r]=s>>>24,s<<=8;return n},toBits(e){const t=[];let n,s=0;for(n=0;n<e.length;n++)s=s<<8|e[n],3&~n||(t.push(s),s=0);return 3&n&&t.push(C.partial(8*(3&n),s)),t}}},A=class{constructor(e){const t=this;t.blockSize=512,t._init=[1732584193,4023233417,2562383102,271733878,3285377520],t._key=[1518500249,1859775393,2400959708,3395469782],e?(t._h=e._h.slice(0),t._buffer=e._buffer.slice(0),t._length=e._length):t.reset()}reset(){const e=this;return e._h=e._init.slice(0),e._buffer=[],e._length=0,e}update(e){const t=this;"string"==typeof e&&(e=B.utf8String.toBits(e));const n=t._buffer=C.concat(t._buffer,e),s=t._length,i=t._length=s+C.bitLength(e);if(i>9007199254740991)throw new r("Cannot hash more than 2^53 - 1 bits");const a=new o(n);let c=0;for(let e=t.blockSize+s-(t.blockSize+s&t.blockSize-1);i>=e;e+=t.blockSize)t._block(a.subarray(16*c,16*(c+1))),c+=1;return n.splice(0,16*c),t}finalize(){const e=this;let t=e._buffer;const n=e._h;t=C.concat(t,[C.partial(1,1)]);for(let e=t.length+2;15&e;e++)t.push(0);for(t.push(s.floor(e._length/4294967296)),t.push(0|e._length);t.length;)e._block(t.splice(0,16));return e.reset(),n}_f(e,t,n,s){return e>19?e>39?e>59?e>79?void 0:t^n^s:t&n|t&s|n&s:t^n^s:t&n|~t&s}_S(e,t){return t<<e|t>>>32-e}_block(t){const n=this,r=n._h,i=e(80);for(let e=0;16>e;e++)i[e]=t[e];let a=r[0],o=r[1],c=r[2],l=r[3],u=r[4];for(let e=0;79>=e;e++){16>e||(i[e]=n._S(1,i[e-3]^i[e-8]^i[e-14]^i[e-16]));const t=n._S(5,a)+n._f(e,o,c,l)+u+i[e]+n._key[s.floor(e/20)]|0;u=l,l=c,c=n._S(30,o),o=a,a=t}r[0]=r[0]+a|0,r[1]=r[1]+o|0,r[2]=r[2]+c|0,r[3]=r[3]+l|0,r[4]=r[4]+u|0}},R={getRandomValues(e){const t=new o(e.buffer),n=e=>{let t=987654321;const n=4294967295;return()=>(t=36969*(65535&t)+(t>>16)&n,(((t<<16)+(e=18e3*(65535&e)+(e>>16)&n)&n)/4294967296+.5)*(s.random()>.5?1:-1))};for(let r,i=0;i<e.length;i+=4){const e=n(4294967296*(r||s.random()));r=987654071*e(),t[i/4]=4294967296*e()|0}return e}},I={importKey:e=>new I.hmacSha1(B.bytes.toBits(e)),pbkdf2(e,t,n,s){if(n=n||1e4,0>s||0>n)throw new r("invalid params to pbkdf2");const i=1+(s>>5)<<2;let a,o,c,l,h;const f=new ArrayBuffer(i),p=new u(f);let d=0;const w=C;for(t=B.bytes.toBits(t),h=1;(i||1)>d;h++){for(a=o=e.encrypt(w.concat(t,[h])),c=1;n>c;c++)for(o=e.encrypt(o),l=0;l<o.length;l++)a[l]^=o[l];for(c=0;(i||1)>d&&c<a.length;c++)p.setInt32(d,a[c]),d+=4}return f.slice(0,s/8)},hmacSha1:class{constructor(e){const t=this,n=t._hash=A,s=[[],[]];t._baseHash=[new n,new n];const r=t._baseHash[0].blockSize/32;e.length>r&&(e=(new n).update(e).finalize());for(let t=0;r>t;t++)s[0][t]=909522486^e[t],s[1][t]=1549556828^e[t];t._baseHash[0].update(s[0]),t._baseHash[1].update(s[1]),t._resultHash=new n(t._baseHash[0])}reset(){const e=this;e._resultHash=new e._hash(e._baseHash[0]),e._updated=!1}update(e){this._updated=!0,this._resultHash.update(e)}digest(){const e=this,t=e._resultHash.finalize(),n=new e._hash(e._baseHash[1]).update(t).finalize();return e.reset(),n}encrypt(e){if(this._updated)throw new r("encrypt on already updated hmac called!");return this.update(e),this.digest(e)}}},q=typeof p!=S&&typeof p.getRandomValues==z,K="Invalid password",P="Invalid signature",T="zipjs-abort-check-password";function V(e){return q?p.getRandomValues(e):R.getRandomValues(e)}const x=16,U={name:"PBKDF2"},W=t.assign({hash:{name:"HMAC"}},U),M=t.assign({iterations:1e3,hash:{name:"SHA-1"}},U),E=["deriveBits"],D=[8,12,16],L=[16,24,32],Z=10,F=[0,0,0,0],N=typeof p!=S,O=N&&p.subtle,j=N&&typeof O!=S,G=B.bytes,X=class{constructor(e){const t=this;t._tables=[[[],[],[],[],[]],[[],[],[],[],[]]],t._tables[0][0][0]||t._precompute();const n=t._tables[0][4],s=t._tables[1],i=e.length;let a,o,c,l=1;if(4!==i&&6!==i&&8!==i)throw new r("invalid aes key size");for(t._key=[o=e.slice(0),c=[]],a=i;4*i+28>a;a++){let e=o[a-1];(a%i===0||8===i&&a%i===4)&&(e=n[e>>>24]<<24^n[e>>16&255]<<16^n[e>>8&255]<<8^n[255&e],a%i===0&&(e=e<<8^e>>>24^l<<24,l=l<<1^283*(l>>7))),o[a]=o[a-i]^e}for(let e=0;a;e++,a--){const t=o[3&e?a:a-4];c[e]=4>=a||4>e?t:s[0][n[t>>>24]]^s[1][n[t>>16&255]]^s[2][n[t>>8&255]]^s[3][n[255&t]]}}encrypt(e){return this._crypt(e,0)}decrypt(e){return this._crypt(e,1)}_precompute(){const e=this._tables[0],t=this._tables[1],n=e[4],s=t[4],r=[],i=[];let a,o,c,l;for(let e=0;256>e;e++)i[(r[e]=e<<1^283*(e>>7))^e]=e;for(let u=a=0;!n[u];u^=o||1,a=i[a]||1){let i=a^a<<1^a<<2^a<<3^a<<4;i=i>>8^255&i^99,n[u]=i,s[i]=u,l=r[c=r[o=r[u]]];let h=16843009*l^65537*c^257*o^16843008*u,f=257*r[i]^16843008*i;for(let n=0;4>n;n++)e[n][u]=f=f<<24^f>>>8,t[n][i]=h=h<<24^h>>>8}for(let n=0;5>n;n++)e[n]=e[n].slice(0),t[n]=t[n].slice(0)}_crypt(e,t){if(4!==e.length)throw new r("invalid aes block size");const n=this._key[t],s=n.length/4-2,i=[0,0,0,0],a=this._tables[t],o=a[0],c=a[1],l=a[2],u=a[3],h=a[4];let f,p,d,w=e[0]^n[0],g=e[t?3:1]^n[1],m=e[2]^n[2],_=e[t?1:3]^n[3],y=4;for(let e=0;s>e;e++)f=o[w>>>24]^c[g>>16&255]^l[m>>8&255]^u[255&_]^n[y],p=o[g>>>24]^c[m>>16&255]^l[_>>8&255]^u[255&w]^n[y+1],d=o[m>>>24]^c[_>>16&255]^l[w>>8&255]^u[255&g]^n[y+2],_=o[_>>>24]^c[w>>16&255]^l[g>>8&255]^u[255&m]^n[y+3],y+=4,w=f,g=p,m=d;for(let e=0;4>e;e++)i[t?3&-e:e]=h[w>>>24]<<24^h[g>>16&255]<<16^h[m>>8&255]<<8^h[255&_]^n[y++],f=w,w=g,g=m,m=_,_=f;return i}},J=class{constructor(e,t){this._prf=e,this._initIv=t,this._iv=t}reset(){this._iv=this._initIv}update(e){return this.calculate(this._prf,e,this._iv)}incWord(e){if(255&~(e>>24))e+=1<<24;else{let t=e>>16&255,n=e>>8&255,s=255&e;255===t?(t=0,255===n?(n=0,255===s?s=0:++s):++n):++t,e=0,e+=t<<16,e+=n<<8,e+=s}return e}incCounter(e){0===(e[0]=this.incWord(e[0]))&&(e[1]=this.incWord(e[1]))}calculate(e,t,n){let s;if(!(s=t.length))return[];const r=C.bitLength(t);for(let r=0;s>r;r+=4){this.incCounter(n);const s=e.encrypt(n);t[r]^=s[0],t[r+1]^=s[1],t[r+2]^=s[2],t[r+3]^=s[3]}return C.clamp(t,r)}},Q=I.hmacSha1;let Y=N&&j&&typeof O.importKey==z,$=N&&j&&typeof O.deriveBits==z;class ee extends w{constructor({password:e,rawPassword:n,signed:s,encryptionStrength:a,checkPasswordOnly:o}){super({start(){t.assign(this,{ready:new h(e=>this.resolveReady=e),password:re(e,n),signed:s,strength:a-1,pending:new i})},async transform(e,t){const n=this,{password:s,strength:a,resolveReady:c,ready:l}=n;s?(await(async(e,t,n,s)=>{const i=await se(e,t,n,ae(s,0,D[t])),a=ae(s,D[t]);if(i[0]!=a[0]||i[1]!=a[1])throw new r(K)})(n,a,s,ae(e,0,D[a]+2)),e=ae(e,D[a]+2),o?t.error(new r(T)):c()):await l;const u=new i(e.length-Z-(e.length-Z)%x);t.enqueue(ne(n,e,u,0,Z,!0))},async flush(e){const{signed:t,ctr:n,hmac:s,pending:a,ready:o}=this;if(s&&n){await o;const c=ae(a,0,a.length-Z),l=ae(a,a.length-Z);let u=new i;if(c.length){const e=ce(G,c);s.update(e);const t=n.update(e);u=oe(G,t)}if(t){const e=ae(oe(G,s.digest()),0,Z);for(let t=0;Z>t;t++)if(e[t]!=l[t])throw new r(P)}e.enqueue(u)}}})}}class te extends w{constructor({password:e,rawPassword:n,encryptionStrength:s}){let r;super({start(){t.assign(this,{ready:new h(e=>this.resolveReady=e),password:re(e,n),strength:s-1,pending:new i})},async transform(e,t){const n=this,{password:s,strength:r,resolveReady:a,ready:o}=n;let c=new i;s?(c=await(async(e,t,n)=>{const s=V(new i(D[t]));return ie(s,await se(e,t,n,s))})(n,r,s),a()):await o;const l=new i(c.length+e.length-e.length%x);l.set(c,0),t.enqueue(ne(n,e,l,c.length,0))},async flush(e){const{ctr:t,hmac:n,pending:s,ready:a}=this;if(n&&t){await a;let o=new i;if(s.length){const e=t.update(ce(G,s));n.update(e),o=oe(G,e)}r.signature=oe(G,n.digest()).slice(0,Z),e.enqueue(ie(o,r.signature))}}}),r=this}}function ne(e,t,n,s,r,a){const{ctr:o,hmac:c,pending:l}=e,u=t.length-r;let h;for(l.length&&(t=ie(l,t),n=((e,t)=>{if(t&&t>e.length){const n=e;(e=new i(t)).set(n,0)}return e})(n,u-u%x)),h=0;u-x>=h;h+=x){const e=ce(G,ae(t,h,h+x));a&&c.update(e);const r=o.update(e);a||c.update(r),n.set(oe(G,r),h+s)}return e.pending=ae(t,h),n}async function se(n,s,r,a){n.password=null;const o=await(async(e,t,n,s,r)=>{if(!Y)return I.importKey(t);try{return await O.importKey("raw",t,n,!1,r)}catch{return Y=!1,I.importKey(t)}})(0,r,W,0,E),c=await(async(e,t,n)=>{if(!$)return I.pbkdf2(t,e.salt,M.iterations,n);try{return await O.deriveBits(e,t,n)}catch{return $=!1,I.pbkdf2(t,e.salt,M.iterations,n)}})(t.assign({salt:a},M),o,8*(2*L[s]+2)),l=new i(c),u=ce(G,ae(l,0,L[s])),h=ce(G,ae(l,L[s],2*L[s])),f=ae(l,2*L[s]);return t.assign(n,{keys:{key:u,authentication:h,passwordVerification:f},ctr:new J(new X(u),e.from(F)),hmac:new Q(h)}),f}function re(e,t){return t===b?(e=>{if(typeof f==S){const t=new i((e=unescape(encodeURIComponent(e))).length);for(let n=0;n<t.length;n++)t[n]=e.charCodeAt(n);return t}return(new f).encode(e)})(e):t}function ie(e,t){let n=e;return e.length+t.length&&(n=new i(e.length+t.length),n.set(e,0),n.set(t,e.length)),n}function ae(e,t,n){return e.subarray(t,n)}function oe(e,t){return e.fromBits(t)}function ce(e,t){return e.toBits(t)}class le extends w{constructor({password:e,passwordVerification:n,checkPasswordOnly:s}){super({start(){t.assign(this,{password:e,passwordVerification:n}),pe(this,e)},transform(e,t){const n=this;if(n.password){const t=he(n,e.subarray(0,12));if(n.password=null,t.at(-1)!=n.passwordVerification)throw new r(K);e=e.subarray(12)}s?t.error(new r(T)):t.enqueue(he(n,e))}})}}class ue extends w{constructor({password:e,passwordVerification:n}){super({start(){t.assign(this,{password:e,passwordVerification:n}),pe(this,e)},transform(e,t){const n=this;let s,r;if(n.password){n.password=null;const t=V(new i(12));t[11]=n.passwordVerification,s=new i(e.length+t.length),s.set(fe(n,t),0),r=12}else s=new i(e.length),r=0;s.set(fe(n,e),r),t.enqueue(s)}})}}function he(e,t){const n=new i(t.length);for(let s=0;s<t.length;s++)n[s]=we(e)^t[s],de(e,n[s]);return n}function fe(e,t){const n=new i(t.length);for(let s=0;s<t.length;s++)n[s]=we(e)^t[s],de(e,t[s]);return n}function pe(e,n){const s=[305419896,591751049,878082192];t.assign(e,{keys:s,crcKey0:new v(s[0]),crcKey2:new v(s[2])});for(let t=0;t<n.length;t++)de(e,n.charCodeAt(t))}function de(e,t){let[n,r,i]=e.keys;e.crcKey0.append([t]),n=~e.crcKey0.get(),r=me(s.imul(me(r+ge(n)),134775813)+1),e.crcKey2.append([r>>>24]),i=~e.crcKey2.get(),e.keys=[n,r,i]}function we(e){const t=2|e.keys[2];return ge(s.imul(t,1^t)>>>8)}function ge(e){return 255&e}function me(e){return 4294967295&e}class _e extends w{constructor(e,{chunkSize:t,CompressionStreamZlib:n,CompressionStream:s}){super({});const{compressed:r,encrypted:i,useCompressionStream:a,zipCrypto:o,signed:c,level:l}=e,h=this;let f,p,d=super.readable;i&&!o||!c||(f=new H,d=ze(d,f)),r&&(d=Se(d,a,{level:l,chunkSize:t},s,n,s)),i&&(o?d=ze(d,new ue(e)):(p=new te(e),d=ze(d,p))),be(h,d,()=>{let e;i&&!o&&(e=p.signature),i&&!o||!c||(e=new u(f.value.buffer).getUint32(0)),h.signature=e})}}class ye extends w{constructor(e,{chunkSize:t,DecompressionStreamZlib:n,DecompressionStream:s}){super({});const{zipCrypto:i,encrypted:a,signed:o,signature:c,compressed:l,useCompressionStream:h,deflate64:f}=e;let p,d,w=super.readable;a&&(i?w=ze(w,new le(e)):(d=new ee(e),w=ze(w,d))),l&&(w=Se(w,h,{chunkSize:t,deflate64:f},s,n,s)),a&&!i||!o||(p=new H,w=ze(w,p)),be(this,w,()=>{if((!a||i)&&o){const e=new u(p.value.buffer);if(c!=e.getUint32(0,!1))throw new r(P)}})}}function be(e,n,s){n=ze(n,new w({flush:s})),t.defineProperty(e,"readable",{get:()=>n})}function Se(e,t,n,s,r,i){const a=t&&s?s:r||i,o=n.deflate64?"deflate64-raw":"deflate-raw";try{e=ze(e,new a(o,n))}catch(s){if(!t)throw s;if(r)e=ze(e,new r(o,n));else{if(!i)throw s;e=ze(e,new i(o,n))}}return e}function ze(e,t){return e.pipeThrough(t)}const ke="data",ve="close";class He extends w{constructor(e,n){super({});const s=this,{codecType:i}=e;let a;i.startsWith("deflate")?a=_e:i.startsWith("inflate")&&(a=ye),s.outputSize=0;let o=0;const c=new a(e,n),l=super.readable,u=new w({transform(e,t){e&&e.length&&(o+=e.length,t.enqueue(e))},flush(){t.assign(s,{inputSize:o})}}),h=new w({transform(t,n){if(t&&t.length&&(n.enqueue(t),s.outputSize+=t.length,e.outputSize!==b&&s.outputSize>e.outputSize))throw new r("Invalid uncompressed size")},flush(){const{signature:e}=c;t.assign(s,{signature:e,inputSize:o})}});t.defineProperty(s,"readable",{get:()=>l.pipeThrough(u).pipeThrough(c).pipeThrough(h)})}}class Ce extends w{constructor(e){let t;super({transform:function n(s,r){if(t){const e=new i(t.length+s.length);e.set(t),e.set(s,t.length),s=e,t=null}s.length>e?(r.enqueue(s.slice(0,e)),n(s.slice(e),r)):t=s},flush(e){t&&t.length&&e.enqueue(t)}})}}const Be=new l,Ae=new l;let Re,Ie,qe,Ke,Pe,Te=0;async function Ve(e){try{const{options:t,config:s}=e;if(!t.useCompressionStream)try{await self.initModule(e.config)}catch{t.useCompressionStream=!0}s.CompressionStream=self.CompressionStream,s.DecompressionStream=self.DecompressionStream;const r={highWaterMark:1},i=e.readable||new g({async pull(e){const t=new h(e=>Be.set(Te,e));xe({type:"pull",messageId:Te}),Te=(Te+1)%n.MAX_SAFE_INTEGER;const{value:s,done:r}=await t;e.enqueue(s),r&&e.close()}},r),a=e.writable||new m({async write(e){let t;const s=new h(e=>t=e);Ae.set(Te,t),xe({type:ke,value:e,messageId:Te}),Te=(Te+1)%n.MAX_SAFE_INTEGER,await s}},r),o=new He(t,s);Re=new AbortController;const{signal:c}=Re;await i.pipeThrough(o).pipeThrough(new Ce(s.chunkSize)).pipeTo(a,{signal:c,preventClose:!0,preventAbort:!0}),await a.getWriter().close();const{signature:l,inputSize:u,outputSize:f}=o;xe({type:ve,result:{signature:l,inputSize:u,outputSize:f}})}catch(e){e.outputSize=0,Ue(e)}}function xe(e){let{value:t}=e;if(t)if(t.length)try{t=new i(t),e.value=t.buffer,d(e,[e.value])}catch{d(e)}else d(e);else d(e)}function Ue(e=new r("Unknown error")){const{message:t,stack:n,code:s,name:i,outputSize:a}=e;d({error:{message:t,stack:n,code:s,name:i,outputSize:a}})}function We(e,t,n={}){const a="number"==typeof n.level?n.level:-1,o="number"==typeof n.outBuffer?n.outBuffer:65536,c="number"==typeof n.inBufferSize?n.inBufferSize:65536;return new w({start(){let n;if(this.out=qe(o),this.in=qe(c),this.inBufferSize=c,this._scratch=new i(o),e?(this._process=Ie.deflate_process,this._last_consumed=Ie.deflate_last_consumed,this._end=Ie.deflate_end,this.streamHandle=Ie.deflate_new(),n="gzip"===t?Ie.deflate_init_gzip(this.streamHandle,a):"deflate-raw"===t?Ie.deflate_init_raw(this.streamHandle,a):Ie.deflate_init(this.streamHandle,a)):"deflate64-raw"===t?(this._process=Ie.inflate9_process,this._last_consumed=Ie.inflate9_last_consumed,this._end=Ie.inflate9_end,this.streamHandle=Ie.inflate9_new(),n=Ie.inflate9_init_raw(this.streamHandle)):(this._process=Ie.inflate_process,this._last_consumed=Ie.inflate_last_consumed,this._end=Ie.inflate_end,this.streamHandle=Ie.inflate_new(),n="deflate-raw"===t?Ie.inflate_init_raw(this.streamHandle):"gzip"===t?Ie.inflate_init_gzip(this.streamHandle):Ie.inflate_init(this.streamHandle)),0!==n)throw new r("init failed:"+n)},transform(t,n){try{const a=t,c=new i(Pe.buffer),l=this._process,u=this._last_consumed,h=this.out,f=this._scratch;let p=0;for(;p<a.length;){const t=s.min(a.length-p,32768);this.in&&this.inBufferSize>=t||(this.in&&Ke&&Ke(this.in),this.in=qe(t),this.inBufferSize=t),c.set(a.subarray(p,p+t),this.in);const i=l(this.streamHandle,this.in,t,h,o,0),d=16777215&i;if(d&&(f.set(c.subarray(h,h+d),0),n.enqueue(f.slice(0,d))),!e){const e=i>>24&255,t=128&e?e-256:e;if(0>t)throw new r("process error:"+t)}const w=u(this.streamHandle);if(0===w)break;p+=w}}catch(e){this._end&&this.streamHandle&&this._end(this.streamHandle),this.in&&Ke&&Ke(this.in),this.out&&Ke&&Ke(this.out),n.error(e)}},flush(t){try{const n=new i(Pe.buffer),s=this._process,a=this.out,c=this._scratch;for(;;){const i=s(this.streamHandle,0,0,a,o,4),l=16777215&i,u=i>>24&255;if(!e){const e=128&u?u-256:u;if(0>e)throw new r("process error:"+e)}if(l&&(c.set(n.subarray(a,a+l),0),t.enqueue(c.slice(0,l))),1===u||0===l)break}}catch(e){t.error(e)}finally{if(this._end&&this.streamHandle){const e=this._end(this.streamHandle);0!==e&&t.error(new r("end error:"+e))}this.in&&Ke&&Ke(this.in),this.out&&Ke&&Ke(this.out)}}})}addEventListener("message",({data:e})=>{const{type:t,messageId:n,value:s,done:r}=e;try{if("start"==t&&Ve(e),t==ke){const e=Be.get(n);Be.delete(n),e({value:new i(s),done:r})}if("ack"==t){const e=Ae.get(n);Ae.delete(n),e()}t==ve&&Re.abort()}catch(e){Ue(e)}});class Me{constructor(e="deflate",t){return We(!0,e,t)}}class Ee{constructor(e="deflate",t){return We(!1,e,t)}}let De=!1;self.initModule=async e=>{try{const t=await(async(e,{baseURI:t})=>{if(!De){let n,s;try{try{s=new URL(e,t)}catch{}const r=await fetch(s);n=await r.arrayBuffer()}catch(t){if(!e.startsWith("data:application/wasm;base64,"))throw t;n=(e=>{const t=e.split(",")[1],n=atob(t),s=n.length,r=new i(s);for(let e=0;s>e;++e)r[e]=n.charCodeAt(e);return r.buffer})(e)}(e=>{if(Ie=e,({malloc:qe,free:Ke,memory:Pe}=Ie),"function"!=typeof qe||"function"!=typeof Ke||!Pe)throw Ie=qe=Ke=Pe=null,new r("Invalid WASM module")})((await WebAssembly.instantiate(n)).instance.exports),De=!0}})(e.wasmURI,e);return e.CompressionStreamZlib=Me,e.DecompressionStreamZlib=Ee,t}catch{}}}();
|
|
1
|
+
!function(){"use strict";const{Array:t,Object:e,Number:n,Math:s,Error:r,Uint8Array:o,Uint16Array:i,Uint32Array:a,Int32Array:c,Map:l,DataView:f,Promise:w,TextEncoder:u,crypto:h,postMessage:p,TransformStream:d,ReadableStream:y,WritableStream:m,CompressionStream:g,DecompressionStream:S}=self,b=void 0,k="undefined",v="function",z=new o,C=[[],[],[],[],[],[],[],[]];for(let t=0;256>t;t++){let e=t;for(let t=0;8>t;t++)e=1&e?e>>>1^3988292384:e>>>1;C[0][t]=e}for(let t=0;256>t;t++)for(let e=1;8>e;e++){const n=C[e-1][t];C[e][t]=n>>>8^C[0][255&n]}const[I,A,x,P,R,U,W,D]=C;class M{constructor(t){this.t=t||-1}append(t){let e=0|this.t;const n=0|t.length;let s=0;if(n>=8&&t.buffer){const r=new f(t.buffer,t.byteOffset,n),o=n-8;for(;o>=s;s+=8){const t=e^r.getInt32(s,!0),n=r.getInt32(s+4,!0);e=D[255&t]^W[t>>>8&255]^U[t>>>16&255]^R[t>>>24&255]^P[255&n]^x[n>>>8&255]^A[n>>>16&255]^I[n>>>24&255]}}for(;n>s;s++)e=e>>>8^I[255&(e^t[s])];this.t=e}get(){return~this.t}}class _ extends d{constructor(){let t;const e=new M;super({transform(t,n){e.append(t),n.enqueue(t)},flush(){const n=new o(4);new f(n.buffer).setUint32(0,e.get()),t.value=n}}),t=this}}const B={concat(t,e){if(0===t.length||0===e.length)return t.concat(e);const n=t[t.length-1],s=B.o(n);return 32===s?t.concat(e):B.i(e,s,0|n,t.slice(0,t.length-1))},l(t){const e=t.length;if(0===e)return 0;const n=t[e-1];return 32*(e-1)+B.o(n)},u(t,e){if(32*t.length<e)return t;const n=(t=t.slice(0,s.ceil(e/32))).length;return e&=31,n>0&&e&&(t[n-1]=B.h(e,t[n-1]&2147483648>>e-1,1)),t},h:(t,e,n)=>32===t?e:(n?0|e:e<<32-t)+1099511627776*t,o:t=>s.round(t/1099511627776)||32,i(t,e,n,s){for(void 0===s&&(s=[]);e>=32;e-=32)s.push(n),n=0;if(0===e)return s.concat(t);for(let r=0;r<t.length;r++)s.push(n|t[r]>>>e),n=t[r]<<32-e;const r=t.length?t[t.length-1]:0,o=B.o(r);return s.push(B.h(e+o&31,e+o>32?n:s.pop(),1)),s}},T={bytes:{p(t){const e=B.l(t)/8,n=new o(e);let s;for(let r=0;e>r;r++)3&r||(s=t[r/4]),n[r]=s>>>24,s<<=8;return n},m(t){const e=[];let n,s=0;for(n=0;n<t.length;n++)s=s<<8|t[n],3&~n||(e.push(s),s=0);return 3&n&&e.push(B.h(8*(3&n),s)),e}}},V=class{constructor(t){const e=this;e.blockSize=512,e.S=[1732584193,4023233417,2562383102,271733878,3285377520],e.k=[1518500249,1859775393,2400959708,3395469782],t?(e.v=t.v.slice(0),e.C=t.C.slice(0),e.I=t.I):e.reset()}reset(){const t=this;return t.v=t.S.slice(0),t.C=[],t.I=0,t}update(t){const e=this;"string"==typeof t&&(t=T.A.m(t));const n=e.C=B.concat(e.C,t),s=e.I,o=e.I=s+B.l(t);if(o>9007199254740991)throw new r("Cannot hash more than 2^53 - 1 bits");const i=new a(n);let c=0;for(let t=e.blockSize+s-(e.blockSize+s&e.blockSize-1);o>=t;t+=e.blockSize)e.P(i.subarray(16*c,16*(c+1))),c+=1;return n.splice(0,16*c),e}R(){const t=this;let e=t.C;const n=t.v;e=B.concat(e,[B.h(1,1)]);for(let t=e.length+2;15&t;t++)e.push(0);for(e.push(s.floor(t.I/4294967296)),e.push(0|t.I);e.length;)t.P(e.splice(0,16));return t.reset(),n}U(t,e,n,s){return t>19?t>39?t>59?t>79?void 0:e^n^s:e&n|e&s|n&s:e^n^s:e&n|~e&s}W(t,e){return e<<t|e>>>32-t}P(e){const n=this,r=n.v,o=t(80);for(let t=0;16>t;t++)o[t]=e[t];let i=r[0],a=r[1],c=r[2],l=r[3],f=r[4];for(let t=0;79>=t;t++){16>t||(o[t]=n.W(1,o[t-3]^o[t-8]^o[t-14]^o[t-16]));const e=n.W(5,i)+n.U(t,a,c,l)+f+o[t]+n.k[s.floor(t/20)]|0;f=l,l=c,c=n.W(30,a),a=i,i=e}r[0]=r[0]+i|0,r[1]=r[1]+a|0,r[2]=r[2]+c|0,r[3]=r[3]+l|0,r[4]=r[4]+f|0}},K={importKey:t=>new K.D(T.bytes.m(t)),M(t,e,n,s){if(n=n||1e4,0>s||0>n)throw new r("invalid params to pbkdf2");const o=1+(s>>5)<<2;let i,a,c,l,w;const u=new ArrayBuffer(o),h=new f(u);let p=0;const d=B;for(e=T.bytes.m(e),w=1;(o||1)>p;w++){for(i=a=t.encrypt(d.concat(e,[w])),c=1;n>c;c++)for(a=t.encrypt(a),l=0;l<a.length;l++)i[l]^=a[l];for(c=0;(o||1)>p&&c<i.length;c++)h.setInt32(p,i[c]),p+=4}return u.slice(0,s/8)},D:class{constructor(t){const e=this,n=e._=V,s=[[],[]];e.B=[new n,new n];const r=e.B[0].blockSize/32;t.length>r&&(t=(new n).update(t).R());for(let e=0;r>e;e++)s[0][e]=909522486^t[e],s[1][e]=1549556828^t[e];e.B[0].update(s[0]),e.B[1].update(s[1]),e.T=new n(e.B[0])}reset(){const t=this;t.T=new t._(t.B[0]),t.V=!1}update(t){this.V=!0,this.T.update(t)}digest(){const t=this,e=t.T.R(),n=new t._(t.B[1]).update(e).R();return t.reset(),n}encrypt(t){if(this.V)throw new r("encrypt on already updated hmac called!");return this.update(t),this.digest(t)}}},j=typeof h!=k&&typeof h.getRandomValues==v,E="Invalid password",L="Invalid signature",O="zipjs-abort-check-password";function H(t){if(j)return h.getRandomValues(t);throw new r("Crypto API not supported")}const Z=16,F={name:"PBKDF2"},N=e.assign({hash:{name:"HMAC"}},F),q=e.assign({iterations:1e3,hash:{name:"SHA-1"}},F),G=["deriveBits"],J=[8,12,16],Q=[16,24,32],X=10,Y=[0,0,0,0],$=typeof h!=k,tt=$&&h.subtle,et=$&&typeof tt!=k,nt=T.bytes,st=class{constructor(t){const e=this;e.K=[[[],[],[],[],[]],[[],[],[],[],[]]],e.K[0][0][0]||e.j();const n=e.K[0][4],s=e.K[1],o=t.length;let i,a,c,l=1;if(4!==o&&6!==o&&8!==o)throw new r("invalid aes key size");for(e.k=[a=t.slice(0),c=[]],i=o;4*o+28>i;i++){let t=a[i-1];(i%o===0||8===o&&i%o===4)&&(t=n[t>>>24]<<24^n[t>>16&255]<<16^n[t>>8&255]<<8^n[255&t],i%o===0&&(t=t<<8^t>>>24^l<<24,l=l<<1^283*(l>>7))),a[i]=a[i-o]^t}for(let t=0;i;t++,i--){const e=a[3&t?i:i-4];c[t]=4>=i||4>t?e:s[0][n[e>>>24]]^s[1][n[e>>16&255]]^s[2][n[e>>8&255]]^s[3][n[255&e]]}}encrypt(t){return this.L(t,0)}decrypt(t){return this.L(t,1)}j(){const t=this.K[0],e=this.K[1],n=t[4],s=e[4],r=[],o=[];let i,a,c,l;for(let t=0;256>t;t++)o[(r[t]=t<<1^283*(t>>7))^t]=t;for(let f=i=0;!n[f];f^=a||1,i=o[i]||1){let o=i^i<<1^i<<2^i<<3^i<<4;o=o>>8^255&o^99,n[f]=o,s[o]=f,l=r[c=r[a=r[f]]];let w=16843009*l^65537*c^257*a^16843008*f,u=257*r[o]^16843008*o;for(let n=0;4>n;n++)t[n][f]=u=u<<24^u>>>8,e[n][o]=w=w<<24^w>>>8}for(let n=0;5>n;n++)t[n]=t[n].slice(0),e[n]=e[n].slice(0)}L(t,e){if(4!==t.length)throw new r("invalid aes block size");const n=this.k[e],s=n.length/4-2,o=[0,0,0,0],i=this.K[e],a=i[0],c=i[1],l=i[2],f=i[3],w=i[4];let u,h,p,d=t[0]^n[0],y=t[e?3:1]^n[1],m=t[2]^n[2],g=t[e?1:3]^n[3],S=4;for(let t=0;s>t;t++)u=a[d>>>24]^c[y>>16&255]^l[m>>8&255]^f[255&g]^n[S],h=a[y>>>24]^c[m>>16&255]^l[g>>8&255]^f[255&d]^n[S+1],p=a[m>>>24]^c[g>>16&255]^l[d>>8&255]^f[255&y]^n[S+2],g=a[g>>>24]^c[d>>16&255]^l[y>>8&255]^f[255&m]^n[S+3],S+=4,d=u,y=h,m=p;for(let t=0;4>t;t++)o[e?3&-t:t]=w[d>>>24]<<24^w[y>>16&255]<<16^w[m>>8&255]<<8^w[255&g]^n[S++],u=d,d=y,y=m,m=g,g=u;return o}},rt=class{constructor(t,e){this.O=t,this.H=e,this.Z=e}reset(){this.Z=this.H}update(t){return this.F(this.O,t,this.Z)}N(t){if(255&~(t>>24))t+=1<<24;else{let e=t>>16&255,n=t>>8&255,s=255&t;255===e?(e=0,255===n?(n=0,255===s?s=0:++s):++n):++e,t=0,t+=e<<16,t+=n<<8,t+=s}return t}q(t){0===(t[0]=this.N(t[0]))&&(t[1]=this.N(t[1]))}F(t,e,n){let s;if(!(s=e.length))return[];const r=B.l(e);for(let r=0;s>r;r+=4){this.q(n);const s=t.encrypt(n);e[r]^=s[0],e[r+1]^=s[1],e[r+2]^=s[2],e[r+3]^=s[3]}return B.u(e,r)}},ot=K.D;let it=$&&et&&typeof tt.importKey==v,at=$&&et&&typeof tt.deriveBits==v;class ct extends d{constructor({password:t,rawPassword:e,encryptionStrength:n,checkPasswordOnly:s}){super({start(){ft(this,t,e,n)},async transform(t,e){const n=this,{password:i,strength:a,G:c,ready:l}=n;i?(await(async(t,e,n,s)=>{const o=await ut(t,e,n,dt(s,0,J[e])),i=dt(s,J[e]);if(o[0]!=i[0]||o[1]!=i[1])throw new r(E)})(n,a,i,dt(t,0,J[a]+2)),t=dt(t,J[a]+2),s?e.error(new r(O)):c()):await l;const f=new o(t.length-X-(t.length-X)%Z);e.enqueue(wt(n,t,f,0,X,!0))},async flush(t){const{J:e,X:n,pending:s,ready:o}=this;if(n&&e){await o;const i=dt(s,0,s.length-X),a=dt(s,s.length-X);let c=z;if(i.length){const t=mt(nt,i);n.update(t);const s=e.update(t);c=yt(nt,s)}const l=dt(yt(nt,n.digest()),0,X);let f=s.length<X?1:0;for(let t=0;X>t;t++)f|=l[t]^a[t];if(f)throw new r(L);t.enqueue(c)}}})}}class lt extends d{constructor({password:t,rawPassword:e,encryptionStrength:n}){let s;super({start(){ft(this,t,e,n)},async transform(t,e){const n=this,{password:s,strength:r,G:i,ready:a}=n;let c=z;s?(c=await(async(t,e,n)=>{const s=H(new o(J[e]));return pt(s,await ut(t,e,n,s))})(n,r,s),i()):await a;const l=new o(c.length+t.length-t.length%Z);l.set(c,0),e.enqueue(wt(n,t,l,c.length,0))},async flush(t){const{J:e,X:n,pending:r,ready:o}=this;if(n&&e){await o;let i=z;if(r.length){const t=e.update(mt(nt,r));n.update(t),i=yt(nt,t)}s.signature=yt(nt,n.digest()).slice(0,X),t.enqueue(pt(i,s.signature))}}}),s=this}}function ft(t,n,s,r){e.assign(t,{ready:new w(e=>t.G=e),password:ht(n,s),strength:r-1,pending:z})}function wt(t,e,n,s,r,i){const{J:a,X:c,pending:l}=t;l.length&&(e=pt(l,e));const f=e.length-r;let w;for(n=((t,e)=>{if(e&&e>t.length){const n=t;(t=new o(e)).set(n,0)}return t})(n,s+(f-f%Z)),w=0;f-Z>=w;w+=Z){const t=mt(nt,dt(e,w,w+Z));i&&c.update(t);const r=a.update(t);i||c.update(r),n.set(yt(nt,r),w+s)}return t.pending=dt(e,w),n}async function ut(n,s,r,i){n.password=null;const a=await(async(t,e,n,s,r)=>{if(!it)return K.importKey(e);try{return await tt.importKey("raw",e,n,!1,r)}catch{return it=!1,K.importKey(e)}})(0,r,N,0,G),c=await(async(t,e,n)=>{if(!at)return K.M(e,t.salt,q.iterations,n);try{return await tt.deriveBits(t,e,n)}catch{return at=!1,K.M(e,t.salt,q.iterations,n)}})(e.assign({salt:i},q),a,8*(2*Q[s]+2)),l=new o(c),f=mt(nt,dt(l,0,Q[s])),w=mt(nt,dt(l,Q[s],2*Q[s])),u=dt(l,2*Q[s]);return e.assign(n,{keys:{key:f,Y:w,passwordVerification:u},J:new rt(new st(f),t.from(Y)),X:new ot(w)}),u}function ht(t,e){return e===b?(t=>{if(typeof u==k){const e=new o((t=unescape(encodeURIComponent(t))).length);for(let n=0;n<e.length;n++)e[n]=t.charCodeAt(n);return e}return(new u).encode(t)})(t):e}function pt(t,e){let n=t;return t.length+e.length&&(n=new o(t.length+e.length),n.set(t,0),n.set(e,t.length)),n}function dt(t,e,n){return t.subarray(e,n)}function yt(t,e){return t.p(e)}function mt(t,e){return t.m(e)}class gt extends d{constructor({password:t,rawPassword:e,passwordVerification:n,checkPasswordOnly:s}){super({start(){bt(this,t,e,n)},transform(t,e){const n=this;if(n.password||n.rawPassword){const e=kt(n,t.subarray(0,12));if(n.password=n.rawPassword=null,0!=(e.at(-1)^n.passwordVerification))throw new r(E);t=t.subarray(12)}s?e.error(new r(O)):e.enqueue(kt(n,t))}})}}class St extends d{constructor({password:t,rawPassword:e,passwordVerification:n}){super({start(){bt(this,t,e,n)},transform(t,e){const n=this;let s,r;if(n.password||n.rawPassword){n.password=n.rawPassword=null;const e=H(new o(12));e[11]=n.passwordVerification,s=new o(t.length+e.length),s.set(vt(n,e),0),r=12}else s=new o(t.length),r=0;s.set(vt(n,t),r),e.enqueue(s)}})}}function bt(t,n,s,r){e.assign(t,{password:n,rawPassword:s,passwordVerification:r}),((t,n,s)=>{const r=[305419896,591751049,878082192];if(e.assign(t,{keys:r,$:new M(r[0]),tt:new M(r[2])}),s)for(let e=0;e<s.length;e++)zt(t,s[e]);else for(let e=0;e<n.length;e++)zt(t,n.charCodeAt(e))})(t,n,s)}function kt(t,e){const n=new o(e.length);for(let s=0;s<e.length;s++)n[s]=Ct(t)^e[s],zt(t,n[s]);return n}function vt(t,e){const n=new o(e.length);for(let s=0;s<e.length;s++)n[s]=Ct(t)^e[s],zt(t,e[s]);return n}function zt(t,e){let[,n]=t.keys;t.$.append([e]);const r=~t.$.get();n=At(s.imul(At(n+It(r)),134775813)+1),t.tt.append([n>>>24]);const o=~t.tt.get();t.keys=[r,n,o]}function Ct(t){const e=2|t.keys[2];return It(s.imul(e,1^e)>>>8)}function It(t){return 255&t}function At(t){return 4294967295&t}class xt extends d{constructor(t,{chunkSize:e,CompressionStreamZlib:n,CompressionStream:s}){super({});const{compressed:r,encrypted:o,useCompressionStream:i,zipCrypto:a,signed:c,level:l,deflate64:w}=t,u=this;let h,p,d,y=super.readable;const m=c&&r&&!w&&(!o||a)&&!(!i||!s);o&&!a||!c||m||(h=new _,y=Dt(y,h)),r&&(m?(d=new Pt,y=Mt(y,new s("gzip")),y=Dt(y,d)):y=Wt(y,i,{level:l,chunkSize:e},s,n,s)),o&&(a?y=Dt(y,new St(t)):(p=new lt(t),y=Dt(y,p))),Ut(u,y,()=>{let t;o&&!a&&(t=p.signature),o&&!a||!c||(t=m?d.signature:new f(h.value.buffer).getUint32(0)),u.signature=t})}}class Pt extends d{constructor(){let t,e=10,n=new o(0);super({transform(t,r){if(e){const n=s.min(e,t.length);if(e-=n,!(t=t.subarray(n)).length)return}const i=n.length+t.length;if(8>=i){const e=new o(i);return e.set(n),e.set(t,n.length),void(n=e)}const a=i-8,c=new o(a),l=s.min(a,n.length);c.set(n.subarray(0,l),0),a>l&&c.set(t.subarray(0,a-l),l),r.enqueue(c);const f=new o(8),w=n.length-l;w&&f.set(n.subarray(l),0),f.set(t.subarray(a-l),w),n=f},flush(){const e=new f(n.buffer,n.byteOffset,n.byteLength);t.signature=e.getUint32(0,!0),t.uncompressedSize=e.getUint32(4,!0)}}),t=this}}class Rt extends d{constructor(t,{chunkSize:e,DecompressionStreamZlib:n,DecompressionStream:s}){super({});const{zipCrypto:o,encrypted:i,signed:a,signature:c,compressed:l,useCompressionStream:w,deflate64:u}=t;let h,p,d=super.readable;i&&(o?d=Dt(d,new gt(t)):(p=new ct(t),d=Dt(d,p))),l&&(d=Wt(d,w,{chunkSize:e,deflate64:u},s,n,s),d=(t=>{const e=t.getReader();return new y({async pull(t){let n;try{n=await e.read()}catch(t){if(t&&t.message)throw t;const e=new r("Invalid compressed data");throw e.cause=t,e}const{value:s,done:o}=n;o?t.close():t.enqueue(s)},cancel:t=>e.cancel(t)})})(d)),i&&!o||!a||(h=new _,d=Dt(d,h)),Ut(this,d,()=>{if((!i||o)&&a){const t=new f(h.value.buffer);if(c!=t.getUint32(0,!1))throw new r(L)}})}}function Ut(t,n,s){n=Dt(n,new d({flush:s})),e.defineProperty(t,"readable",{get:()=>n})}function Wt(t,e,n,s,r,o){const i=e&&s?s:r||o,a=n.deflate64?"deflate64-raw":"deflate-raw";let c;try{c=new i(a,n)}catch(t){if(!e)throw t;if(r)c=new r(a,n);else{if(!o)throw t;c=new o(a,n)}}return Mt(t,c)}function Dt(t,e){return t.pipeThrough(e)}function Mt(t,e){const n=e.writable.getWriter(),s=t.getReader();return(async()=>{try{for(;;){await n.ready;const t=await s.read();if(t.done){await n.close();break}await n.write(t.value)}}catch(t){await(async(t,e)=>{try{await t.abort(e)}catch{}})(n,t),await(async(t,e)=>{try{await t.cancel(e)}catch{}})(s,t)}})(),e.readable}const _t="data",Bt="close";class Tt extends d{constructor(t,n){super({});const s=this,{codecType:o}=t;let i;o.startsWith("deflate")?i=xt:o.startsWith("inflate")&&(i=Rt),s.outputSize=0;let a=0;const c=new i(t,n),l=super.readable,f=new d({transform(t,e){t&&t.length&&(a+=t.length,e.enqueue(t))},flush(){e.assign(s,{inputSize:a})}}),w=new d({transform(e,n){if(e&&e.length&&(n.enqueue(e),s.outputSize+=e.length,t.outputSize!==b&&s.outputSize>t.outputSize))throw new r("Invalid uncompressed size")},flush(){const{signature:t}=c;e.assign(s,{signature:t,inputSize:a})}});e.defineProperty(s,"readable",{get:()=>l.pipeThrough(f).pipeThrough(c).pipeThrough(w)})}}class Vt extends d{constructor(t){let e;1>t&&(t=65536),super({transform:(n,s)=>{if(e){const t=new o(e.length+n.length);t.set(e),t.set(n,e.length),n=t,e=null}let r=0;for(;n.length-r>t;)s.enqueue(n.slice(r,r+t)),r+=t;e=r?n.slice(r):n},flush(t){e&&e.length&&t.enqueue(e)}})}}let Kt=2;try{typeof navigator!=k&&navigator.hardwareConcurrency&&(Kt=navigator.hardwareConcurrency)}catch{}const jt={workerURI:"./core/web-worker-wasm.js",wasmURI:"./core/streams/zlib-wasm/zlib-streams.wasm",chunkSize:65536,maxWorkers:Kt,terminateWorkerTimeout:5e3,workerStarvationTimeout:5e3,useWebWorkers:!0,useCompressionStream:!0,CompressionStream:typeof g!=k&&g,DecompressionStream:typeof S!=k&&S};e.assign({},jt);const Et=new l,Lt=new l;let Ot,Ht,Zt,Ft,Nt,qt=0;async function Gt(t){let e,r;try{const{options:o,config:i}=t;if(!o.useCompressionStream)try{await self.initModule(t.config)}catch{o.useCompressionStream=!0}i.CompressionStream=self.CompressionStream,i.DecompressionStream=self.DecompressionStream;const a={highWaterMark:1},c=t.readable||new y({async pull(t){const e=new w(t=>Et.set(qt,t));Jt({type:"pull",messageId:qt}),qt=(qt+1)%n.MAX_SAFE_INTEGER;const{value:s,done:r}=await e;t.enqueue(s),r&&t.close()}},a);r=t.writable||new m({async write(t){let e;const s=new w(t=>e=t);Lt.set(qt,e),Jt({type:_t,value:t,messageId:qt}),qt=(qt+1)%n.MAX_SAFE_INTEGER,await s}},a),e=new Tt(o,i),Ot=new AbortController;const{signal:l}=Ot;await c.pipeThrough(e).pipeThrough(new Vt((t=>s.max(t.chunkSize,64))(i))).pipeTo(r,{signal:l,preventClose:!0,preventAbort:!0}),await r.getWriter().close();const{signature:f,inputSize:u,outputSize:h}=e;Jt({type:Bt,result:{signature:f,inputSize:u,outputSize:h}})}catch(t){if(t.outputSize=e?e.outputSize:0,r&&!r.locked)try{await r.getWriter().close()}catch{}Qt(t)}}function Jt(t){let{value:e}=t;if(e)if(e.length)try{e=new o(e),t.value=e.buffer,p(t,[t.value])}catch{p(t)}else p(t);else p(t)}function Qt(t=new r("Unknown error")){const{message:e,stack:n,code:s,name:o,outputSize:i}=t;p({error:{message:e,stack:n,code:s,name:o,outputSize:i}})}function Xt(t,e,n={}){const i="number"==typeof n.level?n.level:-1,a="number"==typeof n.outBuffer?n.outBuffer:65536,c="number"==typeof n.inBufferSize?n.inBufferSize:65536;return new d({start(){try{let n;if(this.et=Zt(a),this.in=Zt(c),this.inBufferSize=c,!this.et||!this.in)throw new r("allocation failed");if(this.nt=new o(a),t?(this.st=Ht.deflate_process,this.rt=Ht.deflate_last_consumed,this.ot=Ht.deflate_end,this.it=Ht.deflate_new(),n="gzip"===e?Ht.deflate_init_gzip(this.it,i):"deflate-raw"===e?Ht.deflate_init_raw(this.it,i):Ht.deflate_init(this.it,i)):"deflate64-raw"===e?(this.st=Ht.inflate9_process,this.rt=Ht.inflate9_last_consumed,this.ot=Ht.inflate9_end,this.it=Ht.inflate9_new(),n=Ht.inflate9_init_raw(this.it)):(this.st=Ht.inflate_process,this.rt=Ht.inflate_last_consumed,this.ot=Ht.inflate_end,this.it=Ht.inflate_new(),n="deflate-raw"===e?Ht.inflate_init_raw(this.it):"gzip"===e?Ht.inflate_init_gzip(this.it):Ht.inflate_init(this.it)),0!==n)throw new r("init failed:"+n)}catch(t){throw l(this),t}},transform(e,n){try{const i=e,c=new o(Nt.buffer),l=this.st,f=this.rt,w=this.et,u=this.nt;let h=0;for(;h<i.length;){const e=s.min(i.length-h,32768);if((!this.in||this.inBufferSize<e)&&(this.in&&Ft&&(Ft(this.in),this.in=0),this.in=Zt(e),this.inBufferSize=e,!this.in))throw new r("allocation failed");c.set(i.subarray(h,h+e),this.in);const o=l(this.it,this.in,e,w,a,0),p=16777215&o;if(p&&(u.set(c.subarray(w,w+p),0),n.enqueue(u.slice(0,p))),!t){const t=o>>24&255,e=128&t?t-256:t;if(0>e)throw new r("process error:"+e)}const d=f(this.it);if(0===d)break;h+=d}}catch(t){l(this),n.error(t)}},flush(e){try{const n=new o(Nt.buffer),s=this.st,i=this.et,c=this.nt;for(;;){const o=s(this.it,0,0,i,a,4),l=16777215&o,f=o>>24&255;if(!t){const t=128&f?f-256:f;if(0>t)throw new r("process error:"+t)}if(l&&(c.set(n.subarray(i,i+l),0),e.enqueue(c.slice(0,l))),1===f||0===l)break}}catch(t){e.error(t)}finally{const t=l(this);0!==t&&e.error(new r("end error:"+t))}},cancel(){l(this)}});function l(t){let e=0;return t.it&&t.ot&&(e=t.ot(t.it)),t.it=0,t.in&&Ft&&Ft(t.in),t.in=0,t.et&&Ft&&Ft(t.et),t.et=0,e}}addEventListener("message",({data:t})=>{const{type:e,messageId:n,value:s,done:r}=t;try{if("start"==e&&Gt(t),e==_t){const t=Et.get(n);Et.delete(n),t({value:new o(s),done:r})}if("ack"==e){const t=Lt.get(n);Lt.delete(n),t()}e==Bt&&Ot.abort()}catch(t){Qt(t)}});class Yt{constructor(t="deflate",e){return Xt(!0,t,e)}}class $t{constructor(t="deflate",e){return Xt(!1,t,e)}}Yt.ct=!0,$t.ct=!0;let te=!1;self.initModule=async t=>{try{const e=await(async(t,{baseURI:e})=>{if(!te){let n,s;try{try{s=new URL(t,e)}catch{}const r=await fetch(s);n=await r.arrayBuffer()}catch(e){if(!t.startsWith("data:application/wasm;base64,"))throw e;n=(t=>{const e=t.split(",")[1],n=atob(e),s=n.length,r=new o(s);for(let t=0;s>t;++t)r[t]=n.charCodeAt(t);return r.buffer})(t)}(t=>{if(Ht=t,({malloc:Zt,free:Ft,memory:Nt}=Ht),"function"!=typeof Zt||"function"!=typeof Ft||!Nt)throw Ht=Zt=Ft=Nt=null,new r("Invalid WASM module")})((await WebAssembly.instantiate(n)).instance.exports),te=!0}})(t.wasmURI,t);return t.CompressionStreamZlib=Yt,t.DecompressionStreamZlib=$t,e}catch{}}}();
|
|
Binary file
|