@ttt-productions/q-core 0.1.15 → 0.1.16

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.
@@ -1,13 +1,20 @@
1
1
  import type { FileOrigin } from './file-origins.js';
2
2
  /** The tray row's title for each origin's upload. */
3
3
  export declare const fileOriginRowLabel: Record<FileOrigin, string>;
4
- /** How long a row's time reads as relative ("5m ago") before it reads as a clock time. */
5
- export declare const DEFAULT_RELATIVE_TIME_CUTOFF_MS: number;
6
- /**
7
- * An upload's accept time for a tray row. Within `cutoffMs` of now: "just now", "Xm ago", "Xh ago".
8
- * Older: the local time today, "Yesterday" and the time, or a short date and the time.
9
- */
10
- export declare function formatUploadTimestamp(createdAtMs: number, nowMs: number, cutoffMs?: number): string;
11
- /** The file's kind for a tray row, from its stored content type; `null` when it has none. */
12
- export declare function getFileTypeLabel(contentType: string | undefined): string | null;
4
+ /** How long an upload row's time reads as relative ("5m ago") before it reads as a clock time. */
5
+ export declare const UPLOAD_ROW_RELATIVE_TIME_CUTOFF_MS: number;
6
+ /** An upload row's words for its time and its file's kind, for upload-ui's `createUploadDisplayFormatters`. */
7
+ export declare const UPLOAD_ROW_DISPLAY_COPY: {
8
+ readonly justNow: "just now";
9
+ readonly minutesAgo: (minutes: number) => string;
10
+ readonly hoursAgo: (hours: number) => string;
11
+ readonly yesterdayAt: (time: string) => string;
12
+ readonly dateAt: (date: string, time: string) => string;
13
+ readonly fileType: {
14
+ readonly image: "Image";
15
+ readonly video: "Video";
16
+ readonly audio: "Audio";
17
+ readonly other: "File";
18
+ };
19
+ };
13
20
  //# sourceMappingURL=upload-tray-display.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"upload-tray-display.d.ts","sourceRoot":"","sources":["../../src/media/upload-tray-display.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,qDAAqD;AACrD,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CASzD,CAAC;AAEF,0FAA0F;AAC1F,eAAO,MAAM,+BAA+B,QAAqB,CAAC;AAElE;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,QAAQ,GAAE,MAAwC,GACjD,MAAM,CA8BR;AAED,6FAA6F;AAC7F,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAY/E"}
1
+ {"version":3,"file":"upload-tray-display.d.ts","sourceRoot":"","sources":["../../src/media/upload-tray-display.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,qDAAqD;AACrD,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CASzD,CAAC;AAEF,kGAAkG;AAClG,eAAO,MAAM,kCAAkC,QAAqB,CAAC;AAErE,+GAA+G;AAC/G,eAAO,MAAM,uBAAuB;;mCAEZ,MAAM;+BACV,MAAM;iCACJ,MAAM;4BACX,MAAM,QAAQ,MAAM;;;;;;;CAE3B,CAAC"}
@@ -1,6 +1,5 @@
1
1
  // What an admin's upload tray shows for one upload row: what it was for, the file's kind, and when it
2
2
  // was accepted.
3
- import { getSimplifiedMediaType } from '@ttt-productions/media-schemas';
4
3
  /** The tray row's title for each origin's upload. */
5
4
  export const fileOriginRowLabel = {
6
5
  'league-picture': 'League picture',
@@ -12,53 +11,15 @@ export const fileOriginRowLabel = {
12
11
  'waiver-signature': 'Waiver signature',
13
12
  'hardware-signature': 'Hardware contract signature',
14
13
  };
15
- /** How long a row's time reads as relative ("5m ago") before it reads as a clock time. */
16
- export const DEFAULT_RELATIVE_TIME_CUTOFF_MS = 6 * 60 * 60 * 1000;
17
- /**
18
- * An upload's accept time for a tray row. Within `cutoffMs` of now: "just now", "Xm ago", "Xh ago".
19
- * Older: the local time today, "Yesterday" and the time, or a short date and the time.
20
- */
21
- export function formatUploadTimestamp(createdAtMs, nowMs, cutoffMs = DEFAULT_RELATIVE_TIME_CUTOFF_MS) {
22
- const diffMs = Math.max(0, nowMs - createdAtMs);
23
- if (diffMs < cutoffMs) {
24
- if (diffMs < 60_000)
25
- return 'just now';
26
- const minutes = Math.floor(diffMs / 60_000);
27
- if (minutes < 60)
28
- return `${minutes}m ago`;
29
- const hours = Math.floor(diffMs / 3_600_000);
30
- return `${hours}h ago`;
31
- }
32
- const created = new Date(createdAtMs);
33
- const now = new Date(nowMs);
34
- const timeStr = created.toLocaleTimeString(undefined, { hour: 'numeric', minute: '2-digit' });
35
- const sameDay = created.getFullYear() === now.getFullYear() &&
36
- created.getMonth() === now.getMonth() &&
37
- created.getDate() === now.getDate();
38
- if (sameDay)
39
- return timeStr;
40
- const yesterday = new Date(nowMs - 24 * 60 * 60 * 1000);
41
- const isYesterday = created.getFullYear() === yesterday.getFullYear() &&
42
- created.getMonth() === yesterday.getMonth() &&
43
- created.getDate() === yesterday.getDate();
44
- if (isYesterday)
45
- return `Yesterday ${timeStr}`;
46
- const dateStr = created.toLocaleDateString(undefined, { month: 'short', day: 'numeric' });
47
- return `${dateStr}, ${timeStr}`;
48
- }
49
- /** The file's kind for a tray row, from its stored content type; `null` when it has none. */
50
- export function getFileTypeLabel(contentType) {
51
- if (!contentType)
52
- return null;
53
- switch (getSimplifiedMediaType(contentType)) {
54
- case 'image':
55
- return 'Image';
56
- case 'video':
57
- return 'Video';
58
- case 'audio':
59
- return 'Audio';
60
- default:
61
- return 'File';
62
- }
63
- }
14
+ /** How long an upload row's time reads as relative ("5m ago") before it reads as a clock time. */
15
+ export const UPLOAD_ROW_RELATIVE_TIME_CUTOFF_MS = 6 * 60 * 60 * 1000;
16
+ /** An upload row's words for its time and its file's kind, for upload-ui's `createUploadDisplayFormatters`. */
17
+ export const UPLOAD_ROW_DISPLAY_COPY = {
18
+ justNow: 'just now',
19
+ minutesAgo: (minutes) => `${minutes}m ago`,
20
+ hoursAgo: (hours) => `${hours}h ago`,
21
+ yesterdayAt: (time) => `Yesterday ${time}`,
22
+ dateAt: (date, time) => `${date}, ${time}`,
23
+ fileType: { image: 'Image', video: 'Video', audio: 'Audio', other: 'File' },
24
+ };
64
25
  //# sourceMappingURL=upload-tray-display.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"upload-tray-display.js","sourceRoot":"","sources":["../../src/media/upload-tray-display.ts"],"names":[],"mappings":"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","sourcesContent":["// What an admin's upload tray shows for one upload row: what it was for, the file's kind, and when it\n// was accepted.\n\nimport { getSimplifiedMediaType } from '@ttt-productions/media-schemas';\nimport type { FileOrigin } from './file-origins.js';\n\n/** The tray row's title for each origin's upload. */\nexport const fileOriginRowLabel: Record<FileOrigin, string> = {\n 'league-picture': 'League picture',\n 'team-picture': 'Team picture',\n 'landing-picture': 'Landing picture',\n 'location-picture': 'Venue picture',\n 'award-badge': 'Award badge',\n // A signature never rides the upload tray: it is kept by its signing callable, with no upload row.\n 'waiver-signature': 'Waiver signature',\n 'hardware-signature': 'Hardware contract signature',\n};\n\n/** How long a row's time reads as relative (\"5m ago\") before it reads as a clock time. */\nexport const DEFAULT_RELATIVE_TIME_CUTOFF_MS = 6 * 60 * 60 * 1000;\n\n/**\n * An upload's accept time for a tray row. Within `cutoffMs` of now: \"just now\", \"Xm ago\", \"Xh ago\".\n * Older: the local time today, \"Yesterday\" and the time, or a short date and the time.\n */\nexport function formatUploadTimestamp(\n createdAtMs: number,\n nowMs: number,\n cutoffMs: number = DEFAULT_RELATIVE_TIME_CUTOFF_MS,\n): string {\n const diffMs = Math.max(0, nowMs - createdAtMs);\n\n if (diffMs < cutoffMs) {\n if (diffMs < 60_000) return 'just now';\n const minutes = Math.floor(diffMs / 60_000);\n if (minutes < 60) return `${minutes}m ago`;\n const hours = Math.floor(diffMs / 3_600_000);\n return `${hours}h ago`;\n }\n\n const created = new Date(createdAtMs);\n const now = new Date(nowMs);\n const timeStr = created.toLocaleTimeString(undefined, { hour: 'numeric', minute: '2-digit' });\n\n const sameDay =\n created.getFullYear() === now.getFullYear() &&\n created.getMonth() === now.getMonth() &&\n created.getDate() === now.getDate();\n if (sameDay) return timeStr;\n\n const yesterday = new Date(nowMs - 24 * 60 * 60 * 1000);\n const isYesterday =\n created.getFullYear() === yesterday.getFullYear() &&\n created.getMonth() === yesterday.getMonth() &&\n created.getDate() === yesterday.getDate();\n if (isYesterday) return `Yesterday ${timeStr}`;\n\n const dateStr = created.toLocaleDateString(undefined, { month: 'short', day: 'numeric' });\n return `${dateStr}, ${timeStr}`;\n}\n\n/** The file's kind for a tray row, from its stored content type; `null` when it has none. */\nexport function getFileTypeLabel(contentType: string | undefined): string | null {\n if (!contentType) return null;\n switch (getSimplifiedMediaType(contentType)) {\n case 'image':\n return 'Image';\n case 'video':\n return 'Video';\n case 'audio':\n return 'Audio';\n default:\n return 'File';\n }\n}\n"]}
1
+ {"version":3,"file":"upload-tray-display.js","sourceRoot":"","sources":["../../src/media/upload-tray-display.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,gBAAgB;AAIhB,qDAAqD;AACrD,MAAM,CAAC,MAAM,kBAAkB,GAA+B;IAC5D,gBAAgB,EAAE,gBAAgB;IAClC,cAAc,EAAE,cAAc;IAC9B,iBAAiB,EAAE,iBAAiB;IACpC,kBAAkB,EAAE,eAAe;IACnC,aAAa,EAAE,aAAa;IAC5B,mGAAmG;IACnG,kBAAkB,EAAE,kBAAkB;IACtC,oBAAoB,EAAE,6BAA6B;CACpD,CAAC;AAEF,kGAAkG;AAClG,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAErE,+GAA+G;AAC/G,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,OAAO,EAAE,UAAU;IACnB,UAAU,EAAE,CAAC,OAAe,EAAE,EAAE,CAAC,GAAG,OAAO,OAAO;IAClD,QAAQ,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,GAAG,KAAK,OAAO;IAC5C,WAAW,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,aAAa,IAAI,EAAE;IAClD,MAAM,EAAE,CAAC,IAAY,EAAE,IAAY,EAAE,EAAE,CAAC,GAAG,IAAI,KAAK,IAAI,EAAE;IAC1D,QAAQ,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE;CACnE,CAAC","sourcesContent":["// What an admin's upload tray shows for one upload row: what it was for, the file's kind, and when it\n// was accepted.\n\nimport type { FileOrigin } from './file-origins.js';\n\n/** The tray row's title for each origin's upload. */\nexport const fileOriginRowLabel: Record<FileOrigin, string> = {\n 'league-picture': 'League picture',\n 'team-picture': 'Team picture',\n 'landing-picture': 'Landing picture',\n 'location-picture': 'Venue picture',\n 'award-badge': 'Award badge',\n // A signature never rides the upload tray: it is kept by its signing callable, with no upload row.\n 'waiver-signature': 'Waiver signature',\n 'hardware-signature': 'Hardware contract signature',\n};\n\n/** How long an upload row's time reads as relative (\"5m ago\") before it reads as a clock time. */\nexport const UPLOAD_ROW_RELATIVE_TIME_CUTOFF_MS = 6 * 60 * 60 * 1000;\n\n/** An upload row's words for its time and its file's kind, for upload-ui's `createUploadDisplayFormatters`. */\nexport const UPLOAD_ROW_DISPLAY_COPY = {\n justNow: 'just now',\n minutesAgo: (minutes: number) => `${minutes}m ago`,\n hoursAgo: (hours: number) => `${hours}h ago`,\n yesterdayAt: (time: string) => `Yesterday ${time}`,\n dateAt: (date: string, time: string) => `${date}, ${time}`,\n fileType: { image: 'Image', video: 'Video', audio: 'Audio', other: 'File' },\n} as const;\n"]}
@@ -9,5 +9,4 @@ export * from './app-routes.js';
9
9
  export * from './team-member-actions.js';
10
10
  export * from './league-mode.js';
11
11
  export * from './league-joining.js';
12
- export * from './format.js';
13
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC"}
@@ -9,5 +9,4 @@ export * from './app-routes.js';
9
9
  export * from './team-member-actions.js';
10
10
  export * from './league-mode.js';
11
11
  export * from './league-joining.js';
12
- export * from './format.js';
13
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC","sourcesContent":["export * from './display-name.js';\nexport * from './app-config.js';\nexport * from './league-calendar.js';\nexport * from './team-creation.js';\nexport * from './account-status.js';\nexport * from './league-join-warning.js';\nexport * from './schedules.js';\nexport * from './app-routes.js';\nexport * from './team-member-actions.js';\nexport * from './league-mode.js';\nexport * from './league-joining.js';\nexport * from './format.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC","sourcesContent":["export * from './display-name.js';\nexport * from './app-config.js';\nexport * from './league-calendar.js';\nexport * from './team-creation.js';\nexport * from './account-status.js';\nexport * from './league-join-warning.js';\nexport * from './schedules.js';\nexport * from './app-routes.js';\nexport * from './team-member-actions.js';\nexport * from './league-mode.js';\nexport * from './league-joining.js';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttt-productions/q-core",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "description": "Core types, Firestore path constants, zod schemas, and shared constants for Q-Sports",
5
5
  "repository": {
6
6
  "type": "git",
@@ -92,7 +92,7 @@
92
92
  "@ttt-productions/input-format-core": "^0.1.1",
93
93
  "@ttt-productions/media-schemas": "^0.14.10",
94
94
  "@ttt-productions/notification-core": "^0.15.16",
95
- "@ttt-productions/theme-core": "^0.12.11",
95
+ "@ttt-productions/theme-core": "^0.12.13",
96
96
  "zod": "^4.4.3"
97
97
  },
98
98
  "author": "DJ (TTT Productions)",
@@ -1,3 +0,0 @@
1
- /** A byte count as a short human size: `512 B`, `24 KB`, `1.5 MB`. `null` for no usable count. */
2
- export declare function formatFileSize(bytes: number | undefined): string | null;
3
- //# sourceMappingURL=format.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/utils/format.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAUvE"}
@@ -1,16 +0,0 @@
1
- /** A byte count as a short human size: `512 B`, `24 KB`, `1.5 MB`. `null` for no usable count. */
2
- export function formatFileSize(bytes) {
3
- if (bytes === undefined || !Number.isFinite(bytes) || bytes < 0)
4
- return null;
5
- if (bytes < 1024)
6
- return `${bytes} B`;
7
- if (bytes < 1024 * 1024)
8
- return `${Math.round(bytes / 1024)} KB`;
9
- if (bytes < 1024 * 1024 * 1024) {
10
- const mb = bytes / (1024 * 1024);
11
- return `${mb < 10 ? mb.toFixed(1) : Math.round(mb)} MB`;
12
- }
13
- const gb = bytes / (1024 * 1024 * 1024);
14
- return `${gb < 10 ? gb.toFixed(1) : Math.round(gb)} GB`;
15
- }
16
- //# sourceMappingURL=format.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/utils/format.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,MAAM,UAAU,cAAc,CAAC,KAAyB;IACtD,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC7E,IAAI,KAAK,GAAG,IAAI;QAAE,OAAO,GAAG,KAAK,IAAI,CAAC;IACtC,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI;QAAE,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;IACjE,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC;QAC/B,MAAM,EAAE,GAAG,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;QACjC,OAAO,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC;IAC1D,CAAC;IACD,MAAM,EAAE,GAAG,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;IACxC,OAAO,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC;AAC1D,CAAC","sourcesContent":["/** A byte count as a short human size: `512 B`, `24 KB`, `1.5 MB`. `null` for no usable count. */\nexport function formatFileSize(bytes: number | undefined): string | null {\n if (bytes === undefined || !Number.isFinite(bytes) || bytes < 0) return null;\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`;\n if (bytes < 1024 * 1024 * 1024) {\n const mb = bytes / (1024 * 1024);\n return `${mb < 10 ? mb.toFixed(1) : Math.round(mb)} MB`;\n }\n const gb = bytes / (1024 * 1024 * 1024);\n return `${gb < 10 ? gb.toFixed(1) : Math.round(gb)} GB`;\n}\n"]}