transcend-io / penumbra

Encrypt/decrypt anything in the browser using streams on background threads.
https://penumbra-example.vercel.app/
Apache License 2.0
145 stars 19 forks source link

Penumbra 5.0.0: Safari/Firefox Support #171

Closed michaelfarrell76 closed 4 years ago

michaelfarrell76 commented 4 years ago

Penumbra 4.18.x brings support to safari, however we dynamically import encrypt/decrypt functions into the the main thread for safari use. This created files 0.js and 1.js and 2.js that needed to be copied into the build. Since webpack commonly uses these file names, this often created a file naming conflict with the application that is importing penumbra.

The changes here modify the namespace of the compiled penumbra files so that all files end in .penumbra.js. This is a breaking change to the previous webpack configuration.

New Style

webpack.js

 // Copy in penumbra workers
    new CopyPlugin({
      patterns: readdirSync(PENUMBRA_DIRECTORY)
        .filter((fil) => fil.indexOf('.') > 0)
        .map((fil) => ({
          from: `${PENUMBRA_DIRECTORY}/${fil}`,
          to: `${outputPath}/${fil}`,
        })),
    }),

index.html <script src="/main.penumbra.js"></script>

Old Style

webpack.js

 // Copy in penumbra workers
    new CopyPlugin({
      patterns: [
        {
          from: `${PENUMBRA_DIRECTORY}/penumbra.worker.js`,
          to: `${outputPath}/penumbra.worker.js`,
        },
        {
          from: `${PENUMBRA_DIRECTORY}/penumbra.js`,
          to: `${outputPath}/penumbra.js`,
        },
      ],
    }),

index.html <script src="/penumbra.js"></script>

codecov[bot] commented 4 years ago

Codecov Report

Merging #171 into master will decrease coverage by 0.48%. The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #171      +/-   ##
==========================================
- Coverage   66.94%   66.46%   -0.49%     
==========================================
  Files          34       34              
  Lines         829      829              
  Branches      139      139              
==========================================
- Hits          555      551       -4     
- Misses        194      195       +1     
- Partials       80       83       +3     
Impacted Files Coverage Δ
src/workers.ts 60.71% <0.00%> (ø)
src/tests/api.test.ts 84.21% <0.00%> (-1.76%) :arrow_down:
src/zip.ts 67.13% <0.00%> (-0.70%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update cf2bf60...68d246f. Read the comment docs.