mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-21 16:27:18 +02:00
Style the offline recovery page with the supplied character, embedded token-based CSS, and accessible reload action. Include the production-build fixture regression fix. Co-Authored-By: Paperclip <noreply@paperclip.ing>
167 lines
25 KiB
JavaScript
167 lines
25 KiB
JavaScript
// The build id is stamped into this file at production build time (see
|
|
// stampServiceWorkerBuildId in vite.config.ts), so a deploy that changes only
|
|
// the app bundle still changes sw.js byte-for-byte. That is what makes the
|
|
// browser install a new worker, which — via skipWaiting + controllerchange —
|
|
// reloads parked tabs onto the fresh bundle. Left as the literal placeholder in
|
|
// dev, where HMR (not the worker) drives refreshes.
|
|
const BUILD_ID = "__PAPERCLIP_BUILD_ID__";
|
|
const OFFLINE_STYLES = "__PAPERCLIP_OFFLINE_STYLES__";
|
|
// Separate this allowlisted cache from older workers that cached arbitrary URLs.
|
|
const CACHE_NAME = `paperclip-public-assets-${BUILD_ID}`;
|
|
const privateRequests = new Set();
|
|
const privateCacheControl = /(?:^|,)\s*(?:no-store|private)(?:\s*(?:,|=)|\s*$)/i;
|
|
|
|
// Static recovery only: never cache or embed authenticated page content here.
|
|
function offlineNavigationResponse() {
|
|
return new Response(`<!doctype html>
|
|
<html lang="en">
|
|
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<meta name="color-scheme" content="dark"><title>Paperclip is offline</title>
|
|
<style>${OFFLINE_STYLES}</style></head>
|
|
<body class="paperclip-offline"><main aria-labelledby="offline-title">
|
|
<div class="paperclip-offline-message">
|
|
<div class="paperclip-offline-identity">
|
|
<svg class="paperclip-offline-character" aria-hidden="true" viewBox="0 0 1080 1080" xmlns="http://www.w3.org/2000/svg">
|
|
<defs>
|
|
<linearGradient id="cliplab-e0abb94d-3507-4338-9704-4a0b0c63dfde-body-gradient" gradientUnits="userSpaceOnUse" color-interpolation="linearRGB" x1="52.54562" y1="529.74149" x2="838.98378" y2="632.13774">
|
|
<stop stop-color="var(--offline-character-outer-start)"/>
|
|
<stop offset="1" stop-color="var(--offline-character-outer-end)"/>
|
|
</linearGradient>
|
|
<linearGradient id="cliplab-e0abb94d-3507-4338-9704-4a0b0c63dfde-candle-light-gradient" gradientUnits="userSpaceOnUse" color-interpolation="linearRGB" x1="64.38252" y1="541.52138" x2="850.82067" y2="643.91763">
|
|
<stop stop-color="var(--offline-character-inner-start)"/>
|
|
<stop offset="1" stop-color="var(--offline-character-inner-end)"/>
|
|
</linearGradient>
|
|
<clipPath id="cliplab-e0abb94d-3507-4338-9704-4a0b0c63dfde-face-visible">
|
|
<path d="M229.937 470.993L229.456 479.689L228.78 496.893L228.466 513.864L228.489 530.614L228.622 538.91L229.123 555.35L229.926 571.592L231.025 587.642L231.683 595.596L233.214 611.365L253.536 790.939L258.888 791.84L269.862 793.468L275.475 794.2L286.938 795.51L304.684 797.115L316.858 797.962L329.289 798.642L348.395 799.362L361.426 799.65L374.684 799.791L388.164 799.788L401.862 799.643L415.776 799.357L429.903 798.932L444.243 798.369L458.797 797.666L473.567 796.824L488.554 795.839L503.763 794.71L519.2 793.433L542.795 791.231L558.831 789.563L575.125 787.728L600.08 784.641L625.705 781.117L652.08 777.105L631.758 597.532L630.227 581.763L629.569 573.809L628.47 557.759L627.667 541.516L627.166 525.077L627.033 516.781L627.009 500.031L627.324 483.06L627.999 465.855L628.481 457.159L601.517 461.554L575.438 465.373L550.13 468.691L533.644 470.651L517.446 472.423L493.657 474.752L478.12 476.094L462.831 477.275L447.783 478.3L432.971 479.17L418.391 479.89L404.042 480.458L389.924 480.878L376.036 481.147L362.38 481.264L348.961 481.228L335.783 481.035L322.853 480.68L303.941 479.834L291.671 479.05L279.689 478.078L268.013 476.907L262.297 476.242L251.123 474.744L245.674 473.905L235.075 472.033L229.937 470.993Z"/>
|
|
</clipPath>
|
|
</defs>
|
|
<g id="cliplab-e0abb94d-3507-4338-9704-4a0b0c63dfde-body" data-name="Outer body">
|
|
<path fill="url(#cliplab-e0abb94d-3507-4338-9704-4a0b0c63dfde-body-gradient)" d="M165.306 547.388L165.546 523.532L166.67 505.554L168.694 487.659L171.612 469.89L175.418 452.29L180.102 434.901L185.654 417.766L187.745 412.253L194.098 395.547L201.285 379.188L209.289 363.217L218.088 347.672L227.664 332.59L237.992 318.007L241.396 313.346L252.296 299.511L263.889 286.256L276.147 273.612L293.12 257.77L306.344 246.697L320.13 236.331L324.788 232.958L338.717 223.603L353.131 215.011L357.926 212.173L372.287 204.662L377.377 202.109L396.69 193.466L415.487 186.288L421.008 184.394L438.438 179.05L443.847 177.537L449.603 176.074L455.668 174.671L469.024 171.845L479.731 169.89L490.923 168.228L502.324 166.899L513.654 165.937L524.634 165.365L537.834 165.096L544.168 165.055L550.229 165.141L555.98 165.354L561.384 165.692L573.901 166.578L579.904 167.129L599.702 169.811L605.493 170.78L620.42 173.789L626.266 175.067L641.686 179.109L647.36 180.726L663.116 185.803L684.325 193.893L699.915 200.837L720.496 211.335L735.628 220.072L750.288 229.579L769.261 243.343L783.105 254.489L796.363 266.323L809.004 278.816L820.996 291.939L824.789 296.342L836.224 310.202L846.946 324.614L856.928 339.546L866.146 354.961L874.579 370.821L882.206 387.089L891.22 409.156L897.206 426.181L902.332 443.48L906.584 461.011L909.954 478.733L912.432 496.603L948.008 810.713L948.318 817.44L948.301 823.299L947.714 829.993L946.239 836.548L941.632 848.834L938.497 854.715L930.191 866.156L925.658 870.913L919.185 877.006L914.145 881.007L905.719 887.109L890.067 896.33L877.915 902.423L863.932 908.511L843.375 916.453L826.33 922.302L807.773 928.034L787.818 933.616L766.59 939.011L744.219 944.188L720.842 949.114L696.605 953.759L671.655 958.094L646.148 962.092L620.24 965.729L594.091 968.983L567.863 971.832L541.716 974.261L515.813 976.253L490.313 977.797L465.373 978.882L441.147 979.503L417.784 979.656L395.428 979.338L374.218 978.554L354.284 977.306L335.748 975.604L318.726 973.457L313.404 972.66L297.702 970.032L283.745 966.98L271.621 963.524L265.726 961.684L255.325 957.775L249.578 955.031L241.046 950.686L235.606 947.092L229.07 942.334L224.086 937.961L215.261 927.754L211.584 922.152L208.687 916.107L206.419 910.535L204.346 904.13L203.144 897.508L167.568 583.397L165.986 565.423L165.306 547.388Z"/>
|
|
</g>
|
|
<g id="cliplab-e0abb94d-3507-4338-9704-4a0b0c63dfde-candle-light" data-name="Inner body">
|
|
<path fill="url(#cliplab-e0abb94d-3507-4338-9704-4a0b0c63dfde-candle-light-gradient)" d="M187.656 560.092L187.86 539.815L188.815 524.533L190.536 509.322L193.016 494.219L196.251 479.259L200.233 464.478L204.951 449.913L206.729 445.228L212.129 431.027L218.238 417.122L225.041 403.547L232.521 390.333L240.66 377.513L249.439 365.118L252.332 361.156L261.597 349.397L271.451 338.13L281.871 327.383L296.298 313.917L307.538 304.505L319.257 295.693L323.215 292.826L335.055 284.875L347.307 277.571L351.383 275.16L363.59 268.775L367.917 266.605L384.332 259.259L400.31 253.157L405.003 251.547L419.818 247.005L429.308 244.475L434.463 243.282L445.816 240.88L454.917 239.219L464.43 237.806L474.121 236.677L483.752 235.859L493.085 235.372L504.305 235.144L514.841 235.182L519.728 235.363L524.322 235.65L534.962 236.403L540.065 236.872L556.893 239.151L561.815 239.975L579.472 243.619L592.579 247.055L597.402 248.429L610.794 252.745L628.822 259.622L642.073 265.523L659.568 274.447L672.43 281.873L684.891 289.954L701.018 301.653L712.785 311.128L724.054 321.186L734.799 331.806L744.992 342.96L748.216 346.703L757.936 358.484L767.049 370.734L775.534 383.426L783.37 396.529L790.538 410.01L797.021 423.838L804.682 442.595L809.771 457.066L814.128 471.77L817.742 486.672L820.607 501.735L822.713 516.925L852.953 783.918L853.216 789.636L853.202 794.616L852.703 800.306L851.449 805.878L847.533 816.321L844.868 821.32L837.808 831.045L833.955 835.088L828.453 840.267L824.169 843.668L817.007 848.855L803.703 856.692L793.374 861.872L781.488 867.046L764.015 873.797L749.526 878.769L733.752 883.641L716.791 888.385L698.748 892.972L679.732 897.372L659.862 901.559L639.26 905.507L618.053 909.192L596.371 912.59L574.35 915.682L552.123 918.447L529.829 920.87L507.605 922.934L485.587 924.627L463.912 925.939L442.713 926.862L422.121 927.39L402.262 927.519L383.26 927.25L365.231 926.583L348.287 925.522L332.532 924.075L318.063 922.25L300.192 919.339L288.329 916.746L278.024 913.808L273.013 912.243L264.172 908.921L259.287 906.589L252.035 902.896L247.411 899.841L241.856 895.796L237.619 892.079L230.118 883.403L226.992 878.642L224.53 873.503L222.602 868.767L220.84 863.323L219.818 857.694L189.578 590.7L188.234 575.422L187.656 560.092Z"/>
|
|
</g>
|
|
<g id="cliplab-e0abb94d-3507-4338-9704-4a0b0c63dfde-face" data-name="Facial expression">
|
|
<g clip-path="url(#cliplab-e0abb94d-3507-4338-9704-4a0b0c63dfde-face-visible)">
|
|
<defs>
|
|
<clipPath id="cliplab-e0abb94d-3507-4338-9704-4a0b0c63dfde-face-clip-0" clipPathUnits="userSpaceOnUse">
|
|
<path d="M308.152 606.556L308.158 605.224L308.434 603.982L308.968 602.896L309.75 602.055L310.717 601.516L311.798 601.288L312.931 601.391L314.046 601.859L315.074 602.613L315.953 603.613L316.613 604.814L317.015 606.129L317.438 608.829L317.745 610.17L318.637 612.782L319.209 614.038L320.592 616.409L322.256 618.544L323.182 619.506L325.202 621.177L326.274 621.886L328.513 623.009L329.673 623.42L332.02 623.92L334.351 623.996L336.623 623.637L338.768 622.858L340.721 621.674L341.617 620.943L343.217 619.209L343.91 618.224L345.052 616.049L345.841 613.65L346.272 611.083L346.351 609.756L346.266 607.065L346.39 605.753L346.795 604.547L347.489 603.536L348.411 602.788L349.488 602.33L350.661 602.196L351.856 602.437L352.997 602.986L354.023 603.811L354.845 604.889L355.423 606.133L355.732 607.463L355.852 608.813L355.882 611.502L355.688 614.143L355.264 616.717L354.607 619.202L353.741 621.564L353.231 622.693L352.053 624.837L351.388 625.847L349.915 627.733L348.268 629.42L346.47 630.888L344.525 632.129L342.455 633.132L340.296 633.875L338.051 634.363L335.746 634.589L334.585 634.598L332.242 634.42L329.891 633.981L327.573 633.274L325.293 632.316L323.072 631.119L321.998 630.428L319.922 628.881L317.955 627.128L315.26 624.143L313.662 621.941L312.233 619.6L310.457 615.863L309.523 613.265L308.803 610.607L308.152 606.556Z" clip-rule="nonzero"/>
|
|
</clipPath>
|
|
<clipPath id="cliplab-e0abb94d-3507-4338-9704-4a0b0c63dfde-face-clip-1" clipPathUnits="userSpaceOnUse">
|
|
<path d="M463.972 603.941L464.002 602.593L464.353 601.302L465.009 600.136L465.956 599.188L467.123 598.519L468.426 598.146L469.787 598.1L471.113 598.431L472.326 599.065L473.356 599.967L474.121 601.1L474.577 602.38L475.034 605.057L475.377 606.375L476.396 608.904L477.056 610.102L478.666 612.325L480.611 614.278L482.845 615.908L485.327 617.165L486.639 617.641L489.349 618.294L492.126 618.515L493.524 618.461L496.277 618.03L497.614 617.655L500.177 616.603L502.533 615.157L503.614 614.307L505.541 612.36L506.379 611.28L507.783 608.935L508.771 606.405L509.335 603.752L509.454 602.399L509.403 599.686L509.574 598.344L510.074 597.076L510.911 595.972L512.013 595.107L513.297 594.514L514.696 594.232L516.115 594.327L517.462 594.743L518.66 595.456L519.612 596.449L520.273 597.64L520.614 598.949L520.731 600.301L520.718 603.017L520.44 605.713L519.89 608.369L519.067 610.962L517.99 613.462L516.665 615.845L515.098 618.095L513.319 620.181L511.334 622.088L509.159 623.8L506.824 625.296L504.354 626.559L501.761 627.585L499.083 628.355L496.344 628.863L493.561 629.111L490.775 629.086L488.004 628.794L485.269 628.243L483.93 627.867L481.317 626.925L478.803 625.741L476.415 624.326L474.189 622.685L472.131 620.843L470.26 618.819L468.594 616.632L467.17 614.29L465.985 611.826L465.045 609.267L464.375 606.628L463.972 603.941Z" clip-rule="nonzero"/>
|
|
</clipPath>
|
|
<clipPath id="cliplab-e0abb94d-3507-4338-9704-4a0b0c63dfde-face-clip-2" clipPathUnits="userSpaceOnUse">
|
|
<path d="M329.863 701.788L329.552 693.76L329.547 689.775L330.151 681.928L331.558 674.36L332.485 670.682L334.891 663.589L338.086 656.995L341.984 650.929L344.149 648.1L346.487 645.41L348.905 642.812L354.195 638.095L359.995 634.013L366.195 630.49L369.411 628.914L376.092 626.129L383.07 623.889L390.299 622.188L393.985 621.509L401.485 620.465L409.145 619.92L416.931 619.897L420.863 620.047L428.77 620.669L436.719 621.804L444.659 623.494L448.613 624.528L456.481 626.941L464.23 629.904L471.753 633.514L478.993 637.716L482.494 640.019L489.191 645.067L495.365 650.726L500.871 656.995L503.335 660.334L505.659 663.769L507.84 667.281L511.549 674.641L514.305 682.358L515.443 686.277L517.146 694.251L518.276 706.392L517.963 710.427L516.486 714.2L513.878 717.356L510.416 719.654L506.492 721.084L502.353 721.812L498.164 722.029L493.972 721.884L485.66 721.076L473.286 720.207L461.057 719.587L452.982 719.32L437.041 719.133L429.181 719.218L421.398 719.422L409.884 719.945L402.309 720.443L394.823 721.057L387.427 721.787L376.514 723.094L369.358 724.108L358.812 725.847L355.378 726.574L351.897 727.061L348.372 727.215L344.814 726.906L341.279 725.934L337.925 724.113L335.019 721.359L332.837 717.853L331.548 713.916L329.863 701.788Z" clip-rule="nonzero"/>
|
|
</clipPath>
|
|
<clipPath id="cliplab-e0abb94d-3507-4338-9704-4a0b0c63dfde-face-clip-3" clipPathUnits="userSpaceOnUse">
|
|
<path d="M335.808 701.812L335.566 694.459L335.6 690.814L336.161 683.62L337.507 676.69L338.412 673.335L339.501 670.072L340.682 666.858L343.642 660.798L347.289 655.269L349.34 652.713L351.486 650.246L353.765 647.904L356.189 645.735L358.664 643.609L364.002 639.86L369.724 636.659L372.703 635.227L378.841 632.678L385.241 630.619L391.865 629.051L395.234 628.404L402.097 627.4L409.112 626.903L412.66 626.814L419.818 626.876L427.049 627.397L434.314 628.396L437.951 629.032L445.222 630.628L452.426 632.771L455.978 634.052L459.521 635.411L463.015 636.893L469.877 640.244L476.448 644.19L482.645 648.711L485.576 651.174L488.391 653.774L491.117 656.458L496.091 662.252L500.329 668.558L502.139 671.873L503.83 675.249L505.363 678.685L507.842 685.772L508.679 689.412L510.116 696.734L510.763 704.153L510.969 707.864L509.723 711.318L506.752 713.593L503.078 714.682L499.257 715.065L495.407 715.035L483.978 714.008L472.644 713.246L457.72 712.548L446.676 712.277L439.385 712.215L428.563 712.3L421.431 712.484L410.861 712.933L403.9 713.351L397.014 713.873L386.822 714.828L380.126 715.58L370.234 716.893L360.526 718.404L357.332 718.954L354.19 719.629L351.013 720.118L347.792 720.305L344.53 720.016L341.326 718.901L338.648 716.449L337.312 712.922L335.808 701.812Z" clip-rule="nonzero"/>
|
|
</clipPath>
|
|
</defs>
|
|
<path d="M308.152 606.556L308.158 605.224L308.434 603.982L308.968 602.896L309.75 602.055L310.717 601.516L311.798 601.288L312.931 601.391L314.046 601.859L315.074 602.613L315.953 603.613L316.613 604.814L317.015 606.129L317.438 608.829L317.745 610.17L318.637 612.782L319.209 614.038L320.592 616.409L322.256 618.544L323.182 619.506L325.202 621.177L326.274 621.886L328.513 623.009L329.673 623.42L332.02 623.92L334.351 623.996L336.623 623.637L338.768 622.858L340.721 621.674L341.617 620.943L343.217 619.209L343.91 618.224L345.052 616.049L345.841 613.65L346.272 611.083L346.351 609.756L346.266 607.065L346.39 605.753L346.795 604.547L347.489 603.536L348.411 602.788L349.488 602.33L350.661 602.196L351.856 602.437L352.997 602.986L354.023 603.811L354.845 604.889L355.423 606.133L355.732 607.463L355.852 608.813L355.882 611.502L355.688 614.143L355.264 616.717L354.607 619.202L353.741 621.564L353.231 622.693L352.053 624.837L351.388 625.847L349.915 627.733L348.268 629.42L346.47 630.888L344.525 632.129L342.455 633.132L340.296 633.875L338.051 634.363L335.746 634.589L334.585 634.598L332.242 634.42L329.891 633.981L327.573 633.274L325.293 632.316L323.072 631.119L321.998 630.428L319.922 628.881L317.955 627.128L315.26 624.143L313.662 621.941L312.233 619.6L310.457 615.863L309.523 613.265L308.803 610.607L308.152 606.556Z" opacity="1" fill="var(--offline-character-face)" fill-rule="nonzero"/>
|
|
<path d="M306.602 583.506L306.653 582.564L306.854 581.674L307.197 580.868L307.669 580.175L308.254 579.62L308.931 579.223L309.675 578.998L310.455 578.955L311.245 579.095L313.613 579.839L316.006 580.42L318.41 580.775L320.023 580.867L322.422 580.772L324.773 580.374L327.063 579.638L328.531 578.973L329.939 578.168L331.283 577.229L332.568 576.172L333.782 575.009L335.469 573.093L337.012 570.999L339.773 566.442L340.327 565.782L340.988 565.267L341.73 564.915L342.527 564.74L343.351 564.748L344.177 564.935L344.968 565.298L345.697 565.823L346.335 566.492L346.86 567.281L347.253 568.161L347.499 569.099L347.59 570.062L347.521 571.014L347.295 571.921L346.929 572.754L344.691 576.594L343.205 578.761L341.614 580.808L339.916 582.713L338.711 583.893L336.159 586.018L333.413 587.797L331.241 588.88L329.754 589.463L327.461 590.158L325.896 590.488L323.525 590.794L321.927 590.869L319.512 590.815L317.102 590.552L313.1 589.705L309.95 588.69L309.189 588.308L308.483 587.767L307.862 587.085L307.348 586.287L306.958 585.402L306.706 584.464L306.602 583.506Z" opacity="1" fill="var(--offline-character-face)" fill-rule="nonzero"/>
|
|
<path d="M308.685 655.89L307.368 658.522L305.754 660.951L300.497 667.549L299.094 669.681L298.096 671.867L297.794 672.997L297.646 674.159L297.629 675.527L297.925 678.098L298.612 680.434L299.634 682.516L300.252 683.457L301.668 685.128L303.275 686.502L305.023 687.557L306.858 688.274L308.712 688.641L310.529 688.643L312.266 688.25L313.848 687.457L315.216 686.247L315.802 685.481L316.312 684.605L316.745 683.614L317.086 682.508L317.33 681.286L317.468 679.946L317.453 678.731L317.28 677.458L316.534 674.755L315.379 671.87L310.964 662.451L309.661 659.175L308.685 655.89Z" opacity="0.60641" fill="var(--offline-character-tear)" fill-rule="nonzero"/>
|
|
<path d="M463.972 603.941L464.002 602.593L464.353 601.302L465.009 600.136L465.956 599.188L467.123 598.519L468.426 598.146L469.787 598.1L471.113 598.431L472.326 599.065L473.356 599.967L474.121 601.1L474.577 602.38L475.034 605.057L475.377 606.375L476.396 608.904L477.056 610.102L478.666 612.325L480.611 614.278L482.845 615.908L485.327 617.165L486.639 617.641L489.349 618.294L492.126 618.515L493.524 618.461L496.277 618.03L497.614 617.655L500.177 616.603L502.533 615.157L503.614 614.307L505.541 612.36L506.379 611.28L507.783 608.935L508.771 606.405L509.335 603.752L509.454 602.399L509.403 599.686L509.574 598.344L510.074 597.076L510.911 595.972L512.013 595.107L513.297 594.514L514.696 594.232L516.115 594.327L517.462 594.743L518.66 595.456L519.612 596.449L520.273 597.64L520.614 598.949L520.731 600.301L520.718 603.017L520.44 605.713L519.89 608.369L519.067 610.962L517.99 613.462L516.665 615.845L515.098 618.095L513.319 620.181L511.334 622.088L509.159 623.8L506.824 625.296L504.354 626.559L501.761 627.585L499.083 628.355L496.344 628.863L493.561 629.111L490.775 629.086L488.004 628.794L485.269 628.243L483.93 627.867L481.317 626.925L478.803 625.741L476.415 624.326L474.189 622.685L472.131 620.843L470.26 618.819L468.594 616.632L467.17 614.29L465.985 611.826L465.045 609.267L464.375 606.628L463.972 603.941Z" opacity="1" fill="var(--offline-character-face)" fill-rule="nonzero"/>
|
|
<path d="M467.085 565.743L467.106 564.774L467.308 563.825L467.683 562.93L468.217 562.122L468.89 561.43L469.679 560.879L470.554 560.489L471.484 560.274L472.441 560.238L473.383 560.386L474.276 560.712L475.088 561.206L475.789 561.848L477.611 564.059L479.539 566.178L481.635 568.137L483.13 569.334L484.691 570.445L486.325 571.446L488.03 572.329L489.806 573.081L491.638 573.693L494.47 574.336L497.383 574.647L500.327 574.632L503.263 574.343L505.218 573.992L508.114 573.287L511.921 572.093L512.904 571.925L513.895 571.94L514.857 572.138L515.757 572.511L516.563 573.044L517.245 573.718L517.777 574.511L518.14 575.392L518.32 576.329L518.311 577.289L518.113 578.236L517.734 579.136L517.186 579.955L516.492 580.663L515.677 581.234L514.767 581.649L511.917 582.598L507.11 583.822L503.201 584.455L501.243 584.632L498.297 584.723L494.394 584.487L490.558 583.84L488.675 583.361L486.837 582.768L483.285 581.288L479.918 579.439L476.774 577.252L474.558 575.427L472.472 573.46L469.28 569.908L468.094 568.407L467.59 567.594L467.25 566.695L467.085 565.743Z" opacity="1" fill="var(--offline-character-face)" fill-rule="nonzero"/>
|
|
<path d="M528.179 607.608L527.783 610.642L527.02 613.679L524.069 622.453L523.411 625.124L523.233 626.39L523.183 627.602L523.281 628.756L523.546 629.847L524.016 631.039L524.579 632.117L525.231 633.083L525.963 633.939L526.765 634.688L528.549 635.875L530.517 636.665L531.55 636.916L533.676 637.142L535.84 637.009L537.963 636.544L539.98 635.768L541.83 634.697L543.453 633.347L544.155 632.576L545.299 630.856L545.724 629.911L546.041 628.913L546.241 627.865L546.316 626.769L546.257 625.627L546.058 624.442L545.708 623.216L545.25 622.185L544.611 621.194L543.812 620.238L542.873 619.307L540.655 617.499L532.802 611.956L530.314 609.889L528.179 607.608Z" opacity="1" fill="var(--offline-character-tear)" fill-rule="nonzero"/>
|
|
<path d="M329.863 701.788L329.552 693.76L329.547 689.775L330.151 681.928L331.558 674.36L332.485 670.682L334.891 663.589L338.086 656.995L341.984 650.929L344.149 648.1L346.487 645.41L348.905 642.812L354.195 638.095L359.995 634.013L366.195 630.49L369.411 628.914L376.092 626.129L383.07 623.889L390.299 622.188L393.985 621.509L401.485 620.465L409.145 619.92L416.931 619.897L420.863 620.047L428.77 620.669L436.719 621.804L444.659 623.494L448.613 624.528L456.481 626.941L464.23 629.904L471.753 633.514L478.993 637.716L482.494 640.019L489.191 645.067L495.365 650.726L500.871 656.995L503.335 660.334L505.659 663.769L507.84 667.281L511.549 674.641L514.305 682.358L515.443 686.277L517.146 694.251L518.276 706.392L517.963 710.427L516.486 714.2L513.878 717.356L510.416 719.654L506.492 721.084L502.353 721.812L498.164 722.029L493.972 721.884L485.66 721.076L473.286 720.207L461.057 719.587L452.982 719.32L437.041 719.133L429.181 719.218L421.398 719.422L409.884 719.945L402.309 720.443L394.823 721.057L387.427 721.787L376.514 723.094L369.358 724.108L358.812 725.847L355.378 726.574L351.897 727.061L348.372 727.215L344.814 726.906L341.279 725.934L337.925 724.113L335.019 721.359L332.837 717.853L331.548 713.916L329.863 701.788Z" opacity="1" fill="var(--offline-character-face)" fill-rule="nonzero"/>
|
|
</g>
|
|
</g>
|
|
</svg>
|
|
<h1 id="offline-title">Paperclip is offline</h1>
|
|
</div>
|
|
<p>Check your connection, then reload this page to try again.</p>
|
|
</div>
|
|
<button type="button" onclick="window.location.reload()">Reload page</button>
|
|
</main></body></html>`, {
|
|
status: 503,
|
|
headers: { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store" },
|
|
});
|
|
}
|
|
|
|
async function evictRequest(request) {
|
|
await Promise.all((await caches.keys()).map(async (key) => {
|
|
const cache = await caches.open(key);
|
|
await cache.delete(request, { ignoreVary: true });
|
|
}));
|
|
}
|
|
|
|
self.addEventListener("install", () => {
|
|
self.skipWaiting();
|
|
});
|
|
|
|
self.addEventListener("activate", (event) => {
|
|
event.waitUntil(
|
|
caches.keys().then((keys) =>
|
|
Promise.all(keys.map((key) => caches.delete(key)))
|
|
)
|
|
);
|
|
self.clients.claim();
|
|
});
|
|
|
|
self.addEventListener("fetch", (event) => {
|
|
// Vite owns development module revalidation and HMR. Passing that graph
|
|
// through an offline worker can forward bodyless 304 responses on reload.
|
|
// Only a stamped production build has an offline-cache contract.
|
|
if (BUILD_ID.startsWith("__")) return;
|
|
const { request } = event;
|
|
const url = new URL(request.url);
|
|
// Only immutable Vite build assets have a public offline-cache contract.
|
|
// Never infer that application/extension responses are public from absent
|
|
// headers, or from an in-memory classification lost when this worker restarts.
|
|
const publicAsset = url.origin === self.location.origin && !url.search &&
|
|
/^\/assets\/[^/]+-[a-zA-Z0-9_-]{8,}\.[a-zA-Z0-9.]+$/.test(url.pathname);
|
|
|
|
// Explicitly private requests must bypass BOTH cache writes and offline
|
|
// fallback, including extension endpoints outside the host /api namespace.
|
|
if (request.method !== "GET" || url.pathname.startsWith("/api")) {
|
|
return;
|
|
}
|
|
if (request.cache === "no-store") {
|
|
privateRequests.add(request.url);
|
|
event.waitUntil(evictRequest(request).catch(() => {}));
|
|
return;
|
|
}
|
|
|
|
// Vite development modules use the browser's conditional-response cache.
|
|
// Passing their requests through fetch/respondWith can return a bodyless 304
|
|
// to the module loader on reload and leave the app root empty. They are not
|
|
// build assets and have no offline contract, so leave them to the browser.
|
|
if (url.origin === self.location.origin &&
|
|
/^\/(?:@fs|@vite|@id|src|node_modules)\//.test(url.pathname)) {
|
|
return;
|
|
}
|
|
|
|
// Network-first; only public build assets can use an offline fallback.
|
|
event.respondWith(
|
|
fetch(request)
|
|
.then(async (response) => {
|
|
const cacheControl = response.headers.get("cache-control") ?? "";
|
|
if (privateCacheControl.test(cacheControl)) {
|
|
// Revoke earlier cacheable responses too. Keep an in-memory denylist
|
|
// if storage is unavailable so offline fallback still fails closed.
|
|
privateRequests.add(request.url);
|
|
await evictRequest(request).catch(() => {});
|
|
} else if (response.ok && publicAsset && !privateRequests.has(request.url)) {
|
|
const clone = response.clone();
|
|
await caches.open(CACHE_NAME).then(async (cache) => {
|
|
await cache.put(request, clone);
|
|
// A concurrent response may have revoked this URL during put().
|
|
if (privateRequests.has(request.url)) await cache.delete(request, { ignoreVary: true });
|
|
}).catch(() => {});
|
|
}
|
|
return response;
|
|
})
|
|
.catch(async () => {
|
|
if (privateRequests.has(request.url)) return Response.error();
|
|
if (!publicAsset) return request.mode === "navigate" ? offlineNavigationResponse() : Response.error();
|
|
// Restrict lookup to this policy's cache; old arbitrary-response caches
|
|
// must not become fallback candidates if activation cleanup fails.
|
|
try {
|
|
const cached = await (await caches.open(CACHE_NAME)).match(request);
|
|
if (cached && !privateCacheControl.test(cached.headers.get("cache-control") ?? "")) return cached;
|
|
} catch { /* Unavailable cache storage is an offline miss. */ }
|
|
return Response.error();
|
|
})
|
|
);
|
|
});
|