Skip to content

Commit

Permalink
Merge pull request #142 from rspencer01/decompress
Browse files Browse the repository at this point in the history
Use browsers' DecompressionStream to do zlib decompression instead of rolling our own
  • Loading branch information
rspencer01 authored Jan 15, 2025
2 parents 9f43a4e + 8fe35b2 commit a5dc5cb
Show file tree
Hide file tree
Showing 18 changed files with 87 additions and 2,253 deletions.
6 changes: 3 additions & 3 deletions pybloqs/static/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def write(self, parent: Optional[bs4.Tag] = None, permit_compression: bool = Tru

# Wrapper to make accidental multiple inclusion if the same code (e.g. with different file names) safe to load.
sentinel_var_name = "_pybloqs_load_sentinel_{}".format(self.name.replace("-", "_"))
stream.write(f"if(typeof({sentinel_var_name}) == 'undefined'){{")
stream.write(f"if(typeof({sentinel_var_name}) == 'undefined'){{\n")

if self.encode and permit_compression:
self.write_compressed(stream, self.content_string)
Expand All @@ -100,9 +100,9 @@ def write(self, parent: Optional[bs4.Tag] = None, permit_compression: bool = Tru
@classmethod
def write_compressed(cls, stream: StringIO, data: str) -> None:
if cls.global_encode:
stream.write('blocksEval(RawDeflate.inflate(atob("')
stream.write('(async function(){var code = await RawDeflate.inflate("')
stream.write(encode_string(data).decode())
stream.write('")));')
stream.write('"); blocksEval(code);})()')
else:
stream.write(data)

Expand Down
109 changes: 3 additions & 106 deletions pybloqs/static/jsinflate.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a5dc5cb

Please # to comment.