@crossworks/content-core 0.400.29 → 0.400.34

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crossworks/content-core",
3
- "version": "0.400.29",
3
+ "version": "0.400.34",
4
4
  "description": "Browser-safe content logic — markdown, blocks, pages, tables, formulas — shared by the server and any client. Zero server deps by design: nothing here may reach @mantle/db, node-only APIs, or the network (the jackdaw-repo-split P0 boundary).",
5
5
  "type": "module",
6
6
  "exports": {
@@ -37,7 +37,7 @@
37
37
  "./tree": "./src/tree.ts"
38
38
  },
39
39
  "dependencies": {
40
- "@mantle/client-types": "npm:@crossworks/client-types@0.400.29",
40
+ "@mantle/client-types": "npm:@crossworks/client-types@0.400.34",
41
41
  "marked": "^18.1.1",
42
42
  "mathjs": "15.2.0"
43
43
  },
@@ -1,5 +1,10 @@
1
1
  import { describe, expect, it } from 'vitest';
2
- import { projectAppOpens, projectAppPins, projectNavFavorites } from './profile-projections';
2
+ import {
3
+ projectAppOpens,
4
+ projectAppPins,
5
+ projectNavFavorites,
6
+ projectSounds,
7
+ } from './profile-projections';
3
8
 
4
9
  const id = (n: number) => `00000000-0000-4000-8000-${String(n).padStart(12, '0')}`;
5
10
 
@@ -32,3 +37,21 @@ describe('projectAppOpens', () => {
32
37
  expect(Object.keys(out)).toEqual([id(2), id(1)]);
33
38
  });
34
39
  });
40
+
41
+ describe('projectSounds', () => {
42
+ it('is unset for anything but an object', () => {
43
+ expect(projectSounds(undefined)).toBeUndefined();
44
+ expect(projectSounds('on')).toBeUndefined();
45
+ expect(projectSounds([true, 1])).toBeUndefined();
46
+ });
47
+
48
+ it('keeps a stored choice, clamps the volume, defaults what is missing', () => {
49
+ expect(projectSounds({ enabled: false, volume: 0.3 })).toEqual({ enabled: false, volume: 0.3 });
50
+ expect(projectSounds({ enabled: true, volume: 4 })).toEqual({ enabled: true, volume: 1 });
51
+ expect(projectSounds({ volume: -1 })).toEqual({ enabled: true, volume: 0 });
52
+ expect(projectSounds({ enabled: 'no', volume: Number.NaN })).toEqual({
53
+ enabled: true,
54
+ volume: 0.7,
55
+ });
56
+ });
57
+ });
@@ -23,6 +23,7 @@ import type {
23
23
  OnboardingModelChoices,
24
24
  ProfilePreferences,
25
25
  ReminderChannel,
26
+ SoundPreference,
26
27
  ThoughtTrailMode,
27
28
  } from '@mantle/client-types';
28
29
  import { kindsWhere } from '@mantle/client-types/kinds';
@@ -509,6 +510,20 @@ export function projectNavFavorites(raw: unknown): string[] | undefined {
509
510
  return out.length > 0 ? out : undefined;
510
511
  }
511
512
 
513
+ /** Project stored `sounds`: an object with a boolean `enabled` (else on) and
514
+ * a finite `volume` clamped to 0..1 (else 0.7, the client's default).
515
+ * Anything that is not an object is unset: the client's default applies. */
516
+ export function projectSounds(raw: unknown): SoundPreference | undefined {
517
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return undefined;
518
+ const v = raw as { enabled?: unknown; volume?: unknown };
519
+ const enabled = typeof v.enabled === 'boolean' ? v.enabled : true;
520
+ const volume =
521
+ typeof v.volume === 'number' && Number.isFinite(v.volume)
522
+ ? Math.min(1, Math.max(0, v.volume))
523
+ : 0.7;
524
+ return { enabled, volume };
525
+ }
526
+
512
527
  /** The Desk's bounds. Generous (a full desk is a few KB); they bound
513
528
  * the stored jsonb, not the layout. */
514
529
  export const HOME_DESK_ITEMS_MAX = 400;