@phosart/common 0.4.60 → 0.4.62

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.
@@ -3,7 +3,7 @@ export type ImageId = string;
3
3
  export declare const nsfwConsented: {
4
4
  unblurThumbnails: boolean;
5
5
  unblurText: boolean;
6
- consented: "all" | SvelteSet<ImageId>;
6
+ consented: "all" | SvelteSet<ImageId> | boolean;
7
7
  };
8
8
  export declare const nsfwBlurStyle = "filter: blur(200px); overflow: hidden;";
9
9
  export declare function nsfwBlur(nsfw: boolean | undefined, sha256?: ImageId, imageType?: 'full' | 'thumb'): string;
@@ -1 +1 @@
1
- {"version":3,"file":"nsfw_helper.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/util/nsfw_helper.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAE7B,eAAO,MAAM,aAAa;sBACP,OAAO;gBACb,OAAO;eACR,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC;CACwC,CAAC;AAE/E,eAAO,MAAM,aAAa,2CAA2C,CAAC;AAEtE,wBAAgB,QAAQ,CACvB,IAAI,EAAE,OAAO,GAAG,SAAS,EACzB,MAAM,GAAE,OAAa,EACrB,SAAS,GAAE,MAAM,GAAG,OAAiB,GACnC,MAAM,CAOR;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAK5D"}
1
+ {"version":3,"file":"nsfw_helper.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/util/nsfw_helper.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAE7B,eAAO,MAAM,aAAa;sBACP,OAAO;gBACb,OAAO;eACR,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,OAAO;CAC8B,CAAC;AAE/E,eAAO,MAAM,aAAa,2CAA2C,CAAC;AAEtE,wBAAgB,QAAQ,CACvB,IAAI,EAAE,OAAO,GAAG,SAAS,EACzB,MAAM,GAAE,OAAa,EACrB,SAAS,GAAE,MAAM,GAAG,OAAiB,GACnC,MAAM,CAUR;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAK5D"}
@@ -2,8 +2,10 @@ import { SvelteSet } from 'svelte/reactivity';
2
2
  export const nsfwConsented = $state({ unblurThumbnails: false, consented: new SvelteSet(), unblurText: false });
3
3
  export const nsfwBlurStyle = 'filter: blur(200px); overflow: hidden;';
4
4
  export function nsfwBlur(nsfw, sha256 = '.', imageType = 'thumb') {
5
- const didConsent = nsfwConsented.consented === 'all' || nsfwConsented.consented.has(sha256);
6
- const shouldBlur = didConsent && (nsfwConsented.unblurThumbnails || imageType === 'full');
5
+ const didConsent = nsfwConsented.consented === 'all' ||
6
+ nsfwConsented.consented === true ||
7
+ (nsfwConsented.consented !== false && nsfwConsented.consented.has(sha256));
8
+ const shouldBlur = !didConsent || (!nsfwConsented.unblurThumbnails && imageType === 'thumb');
7
9
  if (nsfw && shouldBlur) {
8
10
  return nsfwBlurStyle;
9
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phosart/common",
3
- "version": "0.4.60",
3
+ "version": "0.4.62",
4
4
  "files": [
5
5
  "dist",
6
6
  "!dist/**/*.test.*",
@@ -5,7 +5,7 @@ export type ImageId = string;
5
5
  export const nsfwConsented = $state<{
6
6
  unblurThumbnails: boolean;
7
7
  unblurText: boolean;
8
- consented: 'all' | SvelteSet<ImageId>;
8
+ consented: 'all' | SvelteSet<ImageId> | boolean;
9
9
  }>({ unblurThumbnails: false, consented: new SvelteSet(), unblurText: false });
10
10
 
11
11
  export const nsfwBlurStyle = 'filter: blur(200px); overflow: hidden;';
@@ -15,8 +15,11 @@ export function nsfwBlur(
15
15
  sha256: ImageId = '.',
16
16
  imageType: 'full' | 'thumb' = 'thumb'
17
17
  ): string {
18
- const didConsent = nsfwConsented.consented === 'all' || nsfwConsented.consented.has(sha256);
19
- const shouldBlur = didConsent && (nsfwConsented.unblurThumbnails || imageType === 'full');
18
+ const didConsent =
19
+ nsfwConsented.consented === 'all' ||
20
+ nsfwConsented.consented === true ||
21
+ (nsfwConsented.consented !== false && nsfwConsented.consented.has(sha256));
22
+ const shouldBlur = !didConsent || (!nsfwConsented.unblurThumbnails && imageType === 'thumb');
20
23
  if (nsfw && shouldBlur) {
21
24
  return nsfwBlurStyle;
22
25
  }