@openclaw/google-meet 2026.8.1-beta.2 → 2026.8.1-beta.3

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,19 +1,18 @@
1
- import { a as resolveGoogleMeetTokenFromParams, c as buildGoogleMeetPreflightReport, d as fetchGoogleMeetSpace, f as fetchLatestGoogleMeetConferenceRecord, i as resolveArtifactQueryFromParams, l as createGoogleMeetSpace, m as listGoogleMeetCalendarEvents, n as fetchResolvedGoogleMeetAttendance, o as resolveMeetingFromParams, p as buildGoogleMeetCalendarDayWindow, s as resolveSpaceFromParams, t as fetchResolvedGoogleMeetArtifacts, u as endGoogleMeetActiveConference } from "./plugin-helpers-CfeT1SYY.js";
1
+ import { a as resolveGoogleMeetTokenFromParams, c as buildGoogleMeetPreflightReport, d as fetchGoogleMeetSpace, f as fetchLatestGoogleMeetConferenceRecord, i as resolveArtifactQueryFromParams, l as createGoogleMeetSpace, m as listGoogleMeetCalendarEvents, n as fetchResolvedGoogleMeetAttendance, o as resolveMeetingFromParams, p as buildGoogleMeetCalendarDayWindow, s as resolveSpaceFromParams, t as fetchResolvedGoogleMeetArtifacts, u as endGoogleMeetActiveConference } from "./plugin-helpers-C9-Y0Ago.js";
2
2
  import { i as resolveGoogleMeetGatewayOperationTimeoutMs } from "./config-wBK8loBb.js";
3
3
  import { buildGoogleMeetAuthUrl, exchangeGoogleMeetAuthCode, resolveGoogleMeetAccessToken, waitForGoogleMeetAuthCode } from "./oauth-9sUJ68Mw.js";
4
- import { n as hasCreateSpaceConfigInput, r as resolveCreateSpaceConfig } from "./create-UHeaRzsH.js";
5
- import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
4
+ import { n as hasCreateSpaceConfigInput, r as resolveCreateSpaceConfig } from "./create-BEDHM6uL.js";
6
5
  import { clampTimerTimeoutMs, parseStrictNonNegativeInteger, parseStrictPositiveInteger } from "openclaw/plugin-sdk/number-runtime";
7
- import { callGatewayFromCli } from "openclaw/plugin-sdk/gateway-runtime";
6
+ import { callGatewayFromCli, isGatewayClientRequestError, isGatewayTransportError } from "openclaw/plugin-sdk/gateway-runtime";
8
7
  import { generateHexPkceVerifierChallenge } from "openclaw/plugin-sdk/provider-auth";
9
8
  import { generateOAuthState } from "openclaw/plugin-sdk/provider-auth-runtime";
10
- import fsp, { writeFile } from "node:fs/promises";
9
+ import fsp, { stat } from "node:fs/promises";
11
10
  import path from "node:path";
12
11
  import JSZip from "jszip";
13
- import { writeExternalFileWithinRoot } from "openclaw/plugin-sdk/security-runtime";
12
+ import { replaceFileAtomic, writeExternalFileWithinRoot } from "openclaw/plugin-sdk/security-runtime";
14
13
  import { createInterface } from "node:readline/promises";
15
14
  import { format } from "node:util";
16
- import prettyMilliseconds from "pretty-ms";
15
+ import { formatDurationCompact } from "openclaw/plugin-sdk/time-runtime";
17
16
  //#region extensions/google-meet/src/cli-command-context.ts
18
17
  function addGoogleMeetOAuthOptions(command) {
19
18
  return command.option("--access-token <token>", "Access token override").option("--refresh-token <token>", "Refresh token override").option("--client-id <id>", "OAuth client id override").option("--client-secret <secret>", "OAuth client secret override").option("--expires-at <ms>", "Cached access token expiry as unix epoch milliseconds");
@@ -29,12 +28,6 @@ function addGoogleMeetArtifactOptions(command) {
29
28
  }
30
29
  //#endregion
31
30
  //#region extensions/google-meet/src/cli-shared.ts
32
- const testing = {
33
- parsePositiveNumber,
34
- resolveGoogleMeetGatewayOperationTimeoutMs,
35
- resolveGoogleMeetGatewayTimeoutMs,
36
- resolveGoogleMeetOAuthCallbackTimeoutMs
37
- };
38
31
  const GOOGLE_MEET_GATEWAY_DEFAULT_TIMEOUT_MS = 5e3;
39
32
  const PLAIN_DECIMAL_NUMBER_RE = /^\d+(?:\.\d+)?$/;
40
33
  function parseGoogleMeetMode(value) {
@@ -54,15 +47,26 @@ function writeStdoutJson(value) {
54
47
  process.stdout.write(`${JSON.stringify(value, null, 2)}\n`);
55
48
  }
56
49
  function isGatewayUnavailableForLocalFallback(err, method) {
57
- const message = formatErrorMessage(err);
58
- return message.includes("ECONNREFUSED") || message.includes("ECONNRESET") || message.includes("EHOSTUNREACH") || message.includes("ENOTFOUND") || message.includes("gateway not connected") || message.includes(`unknown method: ${method}`);
50
+ if (isGatewayTransportError(err)) return err.kind === "closed" && err.code === void 0;
51
+ return isGatewayClientRequestError(err) && err.message.includes(`unknown method: ${method}`);
59
52
  }
60
53
  function writeStdoutLine(...values) {
61
54
  process.stdout.write(`${format(...values)}\n`);
62
55
  }
63
56
  async function writeCliOutput(options, text) {
64
57
  if (options.output?.trim()) {
65
- await writeFile(options.output, text.endsWith("\n") ? text : `${text}\n`, "utf8");
58
+ const dirMode = (await stat(path.dirname(options.output))).mode & 4095;
59
+ await replaceFileAtomic({
60
+ filePath: options.output,
61
+ content: text.endsWith("\n") ? text : `${text}\n`,
62
+ dirMode,
63
+ mode: 438 & ~process.umask(),
64
+ preserveExistingMode: true,
65
+ tempPrefix: ".google-meet-output",
66
+ syncTempFile: true,
67
+ syncParentDir: true,
68
+ throwOnCleanupError: true
69
+ });
66
70
  writeStdoutLine("wrote: %s", options.output);
67
71
  return;
68
72
  }
@@ -135,7 +139,10 @@ async function callGoogleMeetGateway(params) {
135
139
  }
136
140
  function formatDuration(value) {
137
141
  if (value === void 0) return "n/a";
138
- return prettyMilliseconds(Math.max(0, Math.round(value / 1e3) * 1e3), { unitCount: 2 });
142
+ return formatDurationCompact(Math.max(0, Math.round(value / 1e3) * 1e3), {
143
+ showYears: true,
144
+ spaced: true
145
+ }) ?? "0ms";
139
146
  }
140
147
  function writeDoctorStatus(status) {
141
148
  if (!status.found) {
@@ -585,7 +592,12 @@ async function publishMeetExportFile(outputPath, content) {
585
592
  async function writeMeetExportBundle(params) {
586
593
  const outputDir = params.outputDir?.trim() || defaultExportDirectory();
587
594
  await fsp.mkdir(outputDir, { recursive: true });
588
- const zipFile = params.zip ? `${outputDir.replace(/\/$/, "")}.zip` : void 0;
595
+ let zipOutputDir = outputDir;
596
+ if (params.zip) {
597
+ const resolvedOutputDir = path.resolve(outputDir);
598
+ if (resolvedOutputDir !== path.parse(resolvedOutputDir).root) zipOutputDir = outputDir.replace(path.sep === "\\" ? /[\\/]+$/ : /\/+$/, "");
599
+ }
600
+ const zipFile = params.zip ? `${zipOutputDir.replace(/\/$/, "")}.zip` : void 0;
589
601
  const fileNames = googleMeetExportFileNames();
590
602
  const files = [
591
603
  {
@@ -1359,4 +1371,4 @@ function registerGoogleMeetCli(params) {
1359
1371
  registerGoogleMeetLifecycleCommands(context);
1360
1372
  }
1361
1373
  //#endregion
1362
- export { buildGoogleMeetExportManifest, googleMeetExportFileNames, registerGoogleMeetCli, testing, writeMeetExportBundle };
1374
+ export { buildGoogleMeetExportManifest, googleMeetExportFileNames, registerGoogleMeetCli, writeMeetExportBundle };
@@ -1,4 +1,4 @@
1
- import { h as __exportAll, l as createGoogleMeetSpace } from "./plugin-helpers-CfeT1SYY.js";
1
+ import { h as __exportAll, l as createGoogleMeetSpace } from "./plugin-helpers-C9-Y0Ago.js";
2
2
  import { resolveGoogleMeetAccessToken } from "./oauth-9sUJ68Mw.js";
3
3
  import { t as createMeetWithBrowserProxyOnNode } from "./chrome-create-PKAyxCiL.js";
4
4
  import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { t as GOOGLE_MEET_CLI_DESCRIPTOR } from "./cli-output-mode-BwH_6tH8.js";
2
2
  import { n as GOOGLE_MEET_NODE_COMMAND } from "./google-meet-platform-constants-Bs5iAg3E.js";
3
3
  import { r as resolveGoogleMeetConfig } from "./config-wBK8loBb.js";
4
- import { a as createLazyGoogleMeetNodeInvokePolicy, c as loadGoogleMeetCliModule, d as normalizeMode, f as normalizeTransport, g as testing, h as shouldJoinCreatedMeet, i as createGoogleMeetRuntimeAccessor, l as loadGoogleMeetNodeHostModule, m as sendGoogleMeetGatewayError, n as assertGoogleMeetAgentToolActionSupported, o as formatGoogleMeetGatewayError, p as resolveMeetingInput, r as callGoogleMeetGatewayFromTool, s as keepTrustedToolAgentId, t as asParamRecord, u as loadGoogleMeetPluginHelpers } from "./plugin-registration-rSOssQmm.js";
4
+ import { a as createLazyGoogleMeetNodeInvokePolicy, c as loadGoogleMeetCliModule, d as normalizeMode, f as normalizeTransport, h as shouldJoinCreatedMeet, i as createGoogleMeetRuntimeAccessor, l as loadGoogleMeetNodeHostModule, m as sendGoogleMeetGatewayError, n as assertGoogleMeetAgentToolActionSupported, o as formatGoogleMeetGatewayError, p as resolveMeetingInput, r as callGoogleMeetGatewayFromTool, s as keepTrustedToolAgentId, t as asParamRecord, u as loadGoogleMeetPluginHelpers } from "./plugin-registration-Csi-NdQU.js";
5
5
  import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
6
6
  import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
7
7
  import { jsonResult } from "openclaw/plugin-sdk/tool-results";
@@ -375,4 +375,4 @@ var google_meet_default = definePluginEntry({
375
375
  }
376
376
  });
377
377
  //#endregion
378
- export { google_meet_default as default, testing };
378
+ export { google_meet_default as default };
@@ -1,4 +1,4 @@
1
- import { c as loadGoogleMeetCliModule, p as resolveMeetingInput } from "./plugin-registration-rSOssQmm.js";
1
+ import { c as loadGoogleMeetCliModule, p as resolveMeetingInput } from "./plugin-registration-Csi-NdQU.js";
2
2
  import { t as googleApiError } from "./google-api-errors-CDUYkIcK.js";
3
3
  import { t as normalizeMeetUrl } from "./meet-url-BP2Jlvjs.js";
4
4
  import { normalizeOptionalString, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
@@ -773,7 +773,7 @@ var plugin_helpers_exports = /* @__PURE__ */ __exportAll({
773
773
  resolveMeetingFromParams: () => resolveMeetingFromParams,
774
774
  resolveSpaceFromParams: () => resolveSpaceFromParams
775
775
  });
776
- const loadGoogleMeetCreateModule = createLazyRuntimeModule(() => import("./create-UHeaRzsH.js").then((n) => n.t));
776
+ const loadGoogleMeetCreateModule = createLazyRuntimeModule(() => import("./create-BEDHM6uL.js").then((n) => n.t));
777
777
  async function createMeetFromParams(params) {
778
778
  return (await loadGoogleMeetCreateModule()).createMeetFromParams(params);
779
779
  }
@@ -4,8 +4,8 @@ import { asNonArrayRecord as asParamRecord, normalizeOptionalString } from "open
4
4
  import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
5
5
  import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
6
6
  //#region extensions/google-meet/src/plugin-registration.ts
7
- const loadGoogleMeetPluginHelpers = createLazyRuntimeModule(() => import("./plugin-helpers-CfeT1SYY.js").then((n) => n.r));
8
- const loadGoogleMeetCliModule = createLazyRuntimeModule(() => import("./cli-o7RWVqDb.js"));
7
+ const loadGoogleMeetPluginHelpers = createLazyRuntimeModule(() => import("./plugin-helpers-C9-Y0Ago.js").then((n) => n.r));
8
+ const loadGoogleMeetCliModule = createLazyRuntimeModule(() => import("./cli-Bd63VJ5q.js"));
9
9
  const loadGoogleMeetNodeHostModule = createLazyRuntimeModule(() => import("./node-host-BXtXbsMa.js"));
10
10
  const loadGoogleMeetRuntimeModule = createLazyRuntimeModule(() => import("./runtime-B8d1beHo.js"));
11
11
  const loadGoogleMeetNodeInvokePolicyModule = createLazyRuntimeModule(() => import("./node-invoke-policy-B0gOlLJR.js"));
@@ -127,15 +127,5 @@ function sendGoogleMeetGatewayError(respond, err, code = "UNAVAILABLE") {
127
127
  details: payload
128
128
  });
129
129
  }
130
- const testing = {
131
- setCallGatewayFromCliForTests(next) {
132
- googleMeetToolDeps.callGatewayFromCli = next;
133
- },
134
- setPlatformForTests(next) {
135
- googleMeetToolDeps.platform = next ?? (() => process.platform);
136
- },
137
- isGoogleMeetAgentToolActionUnsupportedOnHost,
138
- resolveGoogleMeetGatewayOperationTimeoutMs
139
- };
140
130
  //#endregion
141
- export { createLazyGoogleMeetNodeInvokePolicy as a, loadGoogleMeetCliModule as c, normalizeMode as d, normalizeTransport as f, testing as g, shouldJoinCreatedMeet as h, createGoogleMeetRuntimeAccessor as i, loadGoogleMeetNodeHostModule as l, sendGoogleMeetGatewayError as m, assertGoogleMeetAgentToolActionSupported as n, formatGoogleMeetGatewayError as o, resolveMeetingInput as p, callGoogleMeetGatewayFromTool as r, keepTrustedToolAgentId as s, asParamRecord as t, loadGoogleMeetPluginHelpers as u };
131
+ export { createLazyGoogleMeetNodeInvokePolicy as a, loadGoogleMeetCliModule as c, normalizeMode as d, normalizeTransport as f, shouldJoinCreatedMeet as h, createGoogleMeetRuntimeAccessor as i, loadGoogleMeetNodeHostModule as l, sendGoogleMeetGatewayError as m, assertGoogleMeetAgentToolActionSupported as n, formatGoogleMeetGatewayError as o, resolveMeetingInput as p, callGoogleMeetGatewayFromTool as r, keepTrustedToolAgentId as s, asParamRecord as t, loadGoogleMeetPluginHelpers as u };
@@ -5,6 +5,13 @@
5
5
  },
6
6
  "name": "Google Meet",
7
7
  "description": "OpenClaw Google Meet participant plugin for joining calls through Chrome or Twilio transports.",
8
+ "cliCommands": [
9
+ {
10
+ "name": "googlemeet",
11
+ "description": "Join and manage Google Meet calls",
12
+ "hasSubcommands": true
13
+ }
14
+ ],
8
15
  "icon": "https://cdn.simpleicons.org/googlemeet",
9
16
  "enabledByDefault": true,
10
17
  "commandAliases": [{ "name": "googlemeet" }],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/google-meet",
3
- "version": "2026.8.1-beta.2",
3
+ "version": "2026.8.1-beta.3",
4
4
  "description": "OpenClaw Google Meet participant plugin for joining calls through Chrome or Twilio transports.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,11 +9,10 @@
9
9
  "type": "module",
10
10
  "dependencies": {
11
11
  "jszip": "3.10.1",
12
- "pretty-ms": "9.3.0",
13
12
  "typebox": "1.3.6"
14
13
  },
15
14
  "peerDependencies": {
16
- "openclaw": ">=2026.8.1-beta.2"
15
+ "openclaw": ">=2026.8.1-beta.3"
17
16
  },
18
17
  "peerDependenciesMeta": {
19
18
  "openclaw": {
@@ -30,10 +29,10 @@
30
29
  "minHostVersion": ">=2026.4.20"
31
30
  },
32
31
  "compat": {
33
- "pluginApi": ">=2026.8.1-beta.2"
32
+ "pluginApi": ">=2026.8.1-beta.3"
34
33
  },
35
34
  "build": {
36
- "openclawVersion": "2026.8.1-beta.2"
35
+ "openclawVersion": "2026.8.1-beta.3"
37
36
  },
38
37
  "release": {
39
38
  "publishToClawHub": true,
@@ -50,7 +49,6 @@
50
49
  ],
51
50
  "bundledDependencies": [
52
51
  "jszip",
53
- "pretty-ms",
54
52
  "typebox"
55
53
  ]
56
54
  }
@@ -1,157 +0,0 @@
1
- export type Options = {
2
- /**
3
- Number of digits to appear after the seconds decimal point.
4
-
5
- @default 1
6
- */
7
- readonly secondsDecimalDigits?: number;
8
-
9
- /**
10
- Number of digits to appear after the milliseconds decimal point.
11
-
12
- Useful in combination with [`process.hrtime()`](https://nodejs.org/api/process.html#process_process_hrtime).
13
-
14
- @default 0
15
- */
16
- readonly millisecondsDecimalDigits?: number;
17
-
18
- /**
19
- Keep milliseconds on whole seconds: `13s` → `13.0s`.
20
-
21
- Useful when you are showing a number of seconds spent on an operation and don't want the width of the output to change when hitting a whole number.
22
-
23
- @default false
24
- */
25
- readonly keepDecimalsOnWholeSeconds?: boolean;
26
-
27
- /**
28
- Only show the first unit: `1h 10m` → `1h`.
29
-
30
- Also ensures that `millisecondsDecimalDigits` and `secondsDecimalDigits` are both set to `0`.
31
-
32
- @default false
33
- */
34
- readonly compact?: boolean;
35
-
36
- /**
37
- Number of units to show. Setting `compact` to `true` overrides this option.
38
-
39
- @default Infinity
40
- */
41
- readonly unitCount?: number;
42
-
43
- /**
44
- Use full-length units: `5h 1m 45s` → `5 hours 1 minute 45 seconds`.
45
-
46
- @default false
47
- */
48
- readonly verbose?: boolean;
49
-
50
- /**
51
- Show milliseconds separately. This means they won't be included in the decimal part of the seconds.
52
-
53
- @default false
54
- */
55
- readonly separateMilliseconds?: boolean;
56
-
57
- /**
58
- Show microseconds and nanoseconds.
59
-
60
- @default false
61
- */
62
- readonly formatSubMilliseconds?: boolean;
63
-
64
- /**
65
- Display time using colon notation: `5h 1m 45s` → `5:01:45`. Always shows time in at least minutes: `1s` → `0:01`
66
-
67
- Useful when you want to display time without the time units, similar to a digital watch.
68
-
69
- Setting `colonNotation` to `true` overrides the following options to `false`:
70
- - `compact`
71
- - `formatSubMilliseconds`
72
- - `separateMilliseconds`
73
- - `verbose`
74
-
75
- @default false
76
- */
77
- readonly colonNotation?: boolean;
78
-
79
- /**
80
- Hides the year and shows the hidden year additionally as days (365 per year): `1y 3d 5h 1m 45s` → `368d 5h 1m 45s`.
81
-
82
- @default false
83
- */
84
- readonly hideYear?: boolean;
85
-
86
- /**
87
- Hides the year and days and shows the hidden values additionally as hours: `1y 3d 5h 1m 45s` → `8837h 1m 45s`.
88
-
89
- @default false
90
- */
91
- readonly hideYearAndDays?: boolean;
92
-
93
- /**
94
- Hides the seconds: `1y 3d 5h 1m 45s` → `1y 3d 5h 1m`.
95
-
96
- @default false
97
- */
98
- readonly hideSeconds?: boolean;
99
-
100
- /**
101
- Show sub-second values as decimal seconds: `900ms` → `0.9s`.
102
-
103
- Useful for progress indicators where you want consistent unit format to prevent flickering.
104
-
105
- @default false
106
- */
107
- readonly subSecondsAsDecimals?: boolean;
108
- };
109
-
110
- /**
111
- Convert milliseconds to a human readable string: `1337000000` → `15d 11h 23m 20s`.
112
-
113
- @param milliseconds - Milliseconds to humanize.
114
-
115
- @example
116
- ```
117
- import prettyMilliseconds from 'pretty-ms';
118
-
119
- prettyMilliseconds(1337000000);
120
- //=> '15d 11h 23m 20s'
121
-
122
- prettyMilliseconds(1337);
123
- //=> '1.3s'
124
-
125
- prettyMilliseconds(133);
126
- //=> '133ms'
127
-
128
- // `compact` option
129
- prettyMilliseconds(1337, {compact: true});
130
- //=> '1s'
131
-
132
- // `verbose` option
133
- prettyMilliseconds(1335669000, {verbose: true});
134
- //=> '15 days 11 hours 1 minute 9 seconds'
135
-
136
- // `colonNotation` option
137
- prettyMilliseconds(95500, {colonNotation: true});
138
- //=> '1:35.5'
139
-
140
- // `formatSubMilliseconds` option
141
- prettyMilliseconds(100.400080, {formatSubMilliseconds: true})
142
- //=> '100ms 400µs 80ns'
143
-
144
- // `subSecondsAsDecimals` option
145
- prettyMilliseconds(900, {subSecondsAsDecimals: true});
146
- //=> '0.9s'
147
-
148
- // Can be useful for time durations
149
- prettyMilliseconds(new Date(2014, 0, 1, 10, 40) - new Date(2014, 0, 1, 10, 5))
150
- //=> '35m'
151
- ```
152
- */
153
- export default function prettyMilliseconds(
154
- milliseconds: number | bigint,
155
- options?: Options
156
- ): string;
157
-
@@ -1,149 +0,0 @@
1
- import parseMilliseconds from 'parse-ms';
2
-
3
- const isZero = value => value === 0 || value === 0n;
4
- const pluralize = (word, count) => (count === 1 || count === 1n) ? word : `${word}s`;
5
-
6
- const SECOND_ROUNDING_EPSILON = 0.000_000_1;
7
- const ONE_DAY_IN_MILLISECONDS = 24n * 60n * 60n * 1000n;
8
-
9
- export default function prettyMilliseconds(milliseconds, options) {
10
- const isBigInt = typeof milliseconds === 'bigint';
11
- if (!isBigInt && !Number.isFinite(milliseconds)) {
12
- throw new TypeError('Expected a finite number or bigint');
13
- }
14
-
15
- options = {...options};
16
-
17
- const sign = milliseconds < 0 ? '-' : '';
18
- milliseconds = milliseconds < 0 ? -milliseconds : milliseconds; // Cannot use `Math.abs()` because of BigInt support.
19
-
20
- if (options.colonNotation) {
21
- options.compact = false;
22
- options.formatSubMilliseconds = false;
23
- options.separateMilliseconds = false;
24
- options.verbose = false;
25
- }
26
-
27
- if (options.compact) {
28
- options.unitCount = 1;
29
- options.secondsDecimalDigits = 0;
30
- options.millisecondsDecimalDigits = 0;
31
- }
32
-
33
- let result = [];
34
-
35
- const floorDecimals = (value, decimalDigits) => {
36
- const flooredInterimValue = Math.floor((value * (10 ** decimalDigits)) + SECOND_ROUNDING_EPSILON);
37
- const flooredValue = Math.round(flooredInterimValue) / (10 ** decimalDigits);
38
- return flooredValue.toFixed(decimalDigits);
39
- };
40
-
41
- const add = (value, long, short, valueString) => {
42
- if (
43
- (result.length === 0 || !options.colonNotation)
44
- && isZero(value)
45
- && !(options.colonNotation && short === 'm')) {
46
- return;
47
- }
48
-
49
- valueString ??= String(value);
50
- if (options.colonNotation) {
51
- const wholeDigits = valueString.includes('.') ? valueString.split('.')[0].length : valueString.length;
52
- const minLength = result.length > 0 ? 2 : 1;
53
- valueString = '0'.repeat(Math.max(0, minLength - wholeDigits)) + valueString;
54
- } else {
55
- valueString += options.verbose ? ' ' + pluralize(long, value) : short;
56
- }
57
-
58
- result.push(valueString);
59
- };
60
-
61
- const parsed = parseMilliseconds(milliseconds);
62
- const days = BigInt(parsed.days);
63
-
64
- if (options.hideYearAndDays) {
65
- add((BigInt(days) * 24n) + BigInt(parsed.hours), 'hour', 'h');
66
- } else {
67
- if (options.hideYear) {
68
- add(days, 'day', 'd');
69
- } else {
70
- add(days / 365n, 'year', 'y');
71
- add(days % 365n, 'day', 'd');
72
- }
73
-
74
- add(Number(parsed.hours), 'hour', 'h');
75
- }
76
-
77
- add(Number(parsed.minutes), 'minute', 'm');
78
-
79
- if (!options.hideSeconds) {
80
- if (
81
- options.separateMilliseconds
82
- || options.formatSubMilliseconds
83
- || (!options.colonNotation && milliseconds < 1000 && !options.subSecondsAsDecimals)
84
- ) {
85
- const seconds = Number(parsed.seconds);
86
- const milliseconds = Number(parsed.milliseconds);
87
- const microseconds = Number(parsed.microseconds);
88
- const nanoseconds = Number(parsed.nanoseconds);
89
-
90
- add(seconds, 'second', 's');
91
-
92
- if (options.formatSubMilliseconds) {
93
- add(milliseconds, 'millisecond', 'ms');
94
- add(microseconds, 'microsecond', 'µs');
95
- add(nanoseconds, 'nanosecond', 'ns');
96
- } else {
97
- const millisecondsAndBelow
98
- = milliseconds
99
- + (microseconds / 1000)
100
- + (nanoseconds / 1e6);
101
-
102
- const millisecondsDecimalDigits
103
- = typeof options.millisecondsDecimalDigits === 'number'
104
- ? options.millisecondsDecimalDigits
105
- : 0;
106
-
107
- const roundedMilliseconds = millisecondsAndBelow >= 1
108
- ? Math.round(millisecondsAndBelow)
109
- : Math.ceil(millisecondsAndBelow);
110
-
111
- const millisecondsString = millisecondsDecimalDigits
112
- ? millisecondsAndBelow.toFixed(millisecondsDecimalDigits)
113
- : roundedMilliseconds;
114
-
115
- add(
116
- Number.parseFloat(millisecondsString),
117
- 'millisecond',
118
- 'ms',
119
- millisecondsString,
120
- );
121
- }
122
- } else {
123
- const seconds = (
124
- (isBigInt ? Number(milliseconds % ONE_DAY_IN_MILLISECONDS) : milliseconds)
125
- / 1000
126
- ) % 60;
127
- const secondsDecimalDigits
128
- = typeof options.secondsDecimalDigits === 'number'
129
- ? options.secondsDecimalDigits
130
- : 1;
131
- const secondsFixed = floorDecimals(seconds, secondsDecimalDigits);
132
- const secondsString = options.keepDecimalsOnWholeSeconds
133
- ? secondsFixed
134
- : secondsFixed.replace(/\.0+$/, '');
135
- add(Number.parseFloat(secondsString), 'second', 's', secondsString);
136
- }
137
- }
138
-
139
- if (result.length === 0) {
140
- return sign + '0' + (options.verbose ? ' milliseconds' : 'ms');
141
- }
142
-
143
- const separator = options.colonNotation ? ':' : ' ';
144
- if (typeof options.unitCount === 'number') {
145
- result = result.slice(0, Math.max(options.unitCount, 1));
146
- }
147
-
148
- return sign + result.join(separator);
149
- }
@@ -1,9 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
-
7
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,30 +0,0 @@
1
- export type TimeComponents<T extends (number | bigint) = number> = {
2
- days: T;
3
- hours: T;
4
- minutes: T;
5
- seconds: T;
6
- milliseconds: T;
7
- microseconds: T;
8
- nanoseconds: T;
9
- };
10
-
11
- /**
12
- Parse milliseconds into an object.
13
-
14
- @example
15
- ```
16
- import parseMilliseconds from 'parse-ms';
17
-
18
- parseMilliseconds(1337000001);
19
- // {
20
- // days: 15,
21
- // hours: 11,
22
- // minutes: 23,
23
- // seconds: 20,
24
- // milliseconds: 1,
25
- // microseconds: 0,
26
- // nanoseconds: 0
27
- // }
28
- ```
29
- */
30
- export default function parseMilliseconds<T extends number | bigint>(milliseconds: T): TimeComponents<T>;
@@ -1,45 +0,0 @@
1
- const toZeroIfInfinity = value => Number.isFinite(value) ? value : 0;
2
-
3
- function parseNumber(milliseconds) {
4
- return {
5
- days: Math.trunc(milliseconds / 86_400_000),
6
- hours: Math.trunc(milliseconds / 3_600_000 % 24),
7
- minutes: Math.trunc(milliseconds / 60_000 % 60),
8
- seconds: Math.trunc(milliseconds / 1000 % 60),
9
- milliseconds: Math.trunc(milliseconds % 1000),
10
- microseconds: Math.trunc(toZeroIfInfinity(milliseconds * 1000) % 1000),
11
- nanoseconds: Math.trunc(toZeroIfInfinity(milliseconds * 1e6) % 1000),
12
- };
13
- }
14
-
15
- function parseBigint(milliseconds) {
16
- return {
17
- days: milliseconds / 86_400_000n,
18
- hours: milliseconds / 3_600_000n % 24n,
19
- minutes: milliseconds / 60_000n % 60n,
20
- seconds: milliseconds / 1000n % 60n,
21
- milliseconds: milliseconds % 1000n,
22
- microseconds: 0n,
23
- nanoseconds: 0n,
24
- };
25
- }
26
-
27
- export default function parseMilliseconds(milliseconds) {
28
- switch (typeof milliseconds) {
29
- case 'number': {
30
- if (Number.isFinite(milliseconds)) {
31
- return parseNumber(milliseconds);
32
- }
33
-
34
- break;
35
- }
36
-
37
- case 'bigint': {
38
- return parseBigint(milliseconds);
39
- }
40
-
41
- // No default
42
- }
43
-
44
- throw new TypeError('Expected a finite number or bigint');
45
- }
@@ -1,9 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
-
7
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,47 +0,0 @@
1
- {
2
- "name": "parse-ms",
3
- "version": "4.0.0",
4
- "description": "Parse milliseconds into an object",
5
- "license": "MIT",
6
- "repository": "sindresorhus/parse-ms",
7
- "funding": "https://github.com/sponsors/sindresorhus",
8
- "author": {
9
- "name": "Sindre Sorhus",
10
- "email": "sindresorhus@gmail.com",
11
- "url": "https://sindresorhus.com"
12
- },
13
- "type": "module",
14
- "exports": {
15
- "types": "./index.d.ts",
16
- "default": "./index.js"
17
- },
18
- "sideEffects": false,
19
- "engines": {
20
- "node": ">=18"
21
- },
22
- "scripts": {
23
- "test": "xo && ava && tsd"
24
- },
25
- "files": [
26
- "index.js",
27
- "index.d.ts"
28
- ],
29
- "keywords": [
30
- "browser",
31
- "parse",
32
- "time",
33
- "ms",
34
- "milliseconds",
35
- "microseconds",
36
- "nanoseconds",
37
- "duration",
38
- "period",
39
- "range",
40
- "interval"
41
- ],
42
- "devDependencies": {
43
- "ava": "^6.0.1",
44
- "tsd": "^0.30.3",
45
- "xo": "^0.56.0"
46
- }
47
- }
@@ -1,46 +0,0 @@
1
- # parse-ms
2
-
3
- > Parse milliseconds into an object
4
-
5
- ## Install
6
-
7
- ```sh
8
- npm install parse-ms
9
- ```
10
-
11
- ## Usage
12
-
13
- ```js
14
- import parseMilliseconds from 'parse-ms';
15
-
16
- parseMilliseconds(1337000001);
17
- /*
18
- {
19
- days: 15,
20
- hours: 11,
21
- minutes: 23,
22
- seconds: 20,
23
- milliseconds: 1,
24
- microseconds: 0,
25
- nanoseconds: 0
26
- }
27
- */
28
-
29
- parseMilliseconds(1337000001n);
30
- /*
31
- {
32
- days: 15n,
33
- hours: 11n,
34
- minutes: 23n,
35
- seconds: 20n,
36
- milliseconds: 1n,
37
- microseconds: 0n,
38
- nanoseconds: 0n
39
- }
40
- */
41
- ```
42
-
43
- ## Related
44
-
45
- - [to-milliseconds](https://github.com/sindresorhus/to-milliseconds) - The inverse of this module
46
- - [pretty-ms](https://github.com/sindresorhus/pretty-ms) - Convert milliseconds to a human readable string
@@ -1,55 +0,0 @@
1
- {
2
- "name": "pretty-ms",
3
- "version": "9.3.0",
4
- "description": "Convert milliseconds to a human readable string: `1337000000` → `15d 11h 23m 20s`",
5
- "license": "MIT",
6
- "repository": "sindresorhus/pretty-ms",
7
- "funding": "https://github.com/sponsors/sindresorhus",
8
- "author": {
9
- "name": "Sindre Sorhus",
10
- "email": "sindresorhus@gmail.com",
11
- "url": "https://sindresorhus.com"
12
- },
13
- "type": "module",
14
- "exports": {
15
- "types": "./index.d.ts",
16
- "default": "./index.js"
17
- },
18
- "sideEffects": false,
19
- "engines": {
20
- "node": ">=18"
21
- },
22
- "scripts": {
23
- "test": "xo && ava && tsd"
24
- },
25
- "files": [
26
- "index.js",
27
- "index.d.ts"
28
- ],
29
- "keywords": [
30
- "pretty",
31
- "prettify",
32
- "human",
33
- "humanize",
34
- "humanized",
35
- "readable",
36
- "time",
37
- "ms",
38
- "milliseconds",
39
- "duration",
40
- "period",
41
- "range",
42
- "text",
43
- "string",
44
- "number",
45
- "hrtime"
46
- ],
47
- "dependencies": {
48
- "parse-ms": "^4.0.0"
49
- },
50
- "devDependencies": {
51
- "ava": "^6.2.0",
52
- "tsd": "^0.31.2",
53
- "xo": "^0.59.3"
54
- }
55
- }
@@ -1,179 +0,0 @@
1
- # pretty-ms
2
-
3
- > Convert milliseconds to a human readable string: `1337000000` → `15d 11h 23m 20s`
4
-
5
- ## Install
6
-
7
- ```sh
8
- npm install pretty-ms
9
- ```
10
-
11
- ## Usage
12
-
13
- ```js
14
- import prettyMilliseconds from 'pretty-ms';
15
-
16
- prettyMilliseconds(1337000000);
17
- //=> '15d 11h 23m 20s'
18
-
19
- prettyMilliseconds(1337000000n);
20
- //=> '15d 11h 23m 20s'
21
-
22
- prettyMilliseconds(1337);
23
- //=> '1.3s'
24
-
25
- prettyMilliseconds(133);
26
- //=> '133ms'
27
-
28
- // `compact` option
29
- prettyMilliseconds(1337, {compact: true});
30
- //=> '1s'
31
-
32
- // `verbose` option
33
- prettyMilliseconds(1335669000, {verbose: true});
34
- //=> '15 days 11 hours 1 minute 9 seconds'
35
-
36
- // `colonNotation` option
37
- prettyMilliseconds(95500, {colonNotation: true});
38
- //=> '1:35.5'
39
-
40
- // `formatSubMilliseconds` option
41
- prettyMilliseconds(100.400080, {formatSubMilliseconds: true})
42
- //=> '100ms 400µs 80ns'
43
-
44
- // `subSecondsAsDecimals` option
45
- prettyMilliseconds(900, {subSecondsAsDecimals: true});
46
- //=> '0.9s'
47
-
48
- // Can be useful for time durations
49
- prettyMilliseconds(new Date(2014, 0, 1, 10, 40) - new Date(2014, 0, 1, 10, 5))
50
- //=> '35m'
51
- ```
52
-
53
- ## API
54
-
55
- ### prettyMilliseconds(milliseconds, options?)
56
-
57
- #### milliseconds
58
-
59
- Type: `number | bigint`
60
-
61
- Milliseconds to humanize.
62
-
63
- #### options
64
-
65
- Type: `object`
66
-
67
- ##### secondsDecimalDigits
68
-
69
- Type: `number`\
70
- Default: `1`
71
-
72
- Number of digits to appear after the seconds decimal point.
73
-
74
- ##### millisecondsDecimalDigits
75
-
76
- Type: `number`\
77
- Default: `0`
78
-
79
- Number of digits to appear after the milliseconds decimal point.
80
-
81
- Useful in combination with [`process.hrtime()`](https://nodejs.org/api/process.html#process_process_hrtime_time).
82
-
83
- ##### keepDecimalsOnWholeSeconds
84
-
85
- Type: `boolean`\
86
- Default: `false`
87
-
88
- Keep milliseconds on whole seconds: `13s` → `13.0s`.
89
-
90
- Useful when you are showing a number of seconds spent on an operation and don't want the width of the output to change when hitting a whole number.
91
-
92
- ##### compact
93
-
94
- Type: `boolean`\
95
- Default: `false`
96
-
97
- Only show the first unit: `1h 10m` → `1h`.
98
-
99
- Also ensures that `millisecondsDecimalDigits` and `secondsDecimalDigits` are both set to `0`.
100
-
101
- ##### unitCount
102
-
103
- Type: `number`\
104
- Default: `Infinity`
105
-
106
- Number of units to show. Setting `compact` to `true` overrides this option.
107
-
108
- ##### verbose
109
-
110
- Type: `boolean`\
111
- Default: `false`
112
-
113
- Use full-length units: `5h 1m 45s` → `5 hours 1 minute 45 seconds`
114
-
115
- ##### separateMilliseconds
116
-
117
- Type: `boolean`\
118
- Default: `false`
119
-
120
- Show milliseconds separately. This means they won't be included in the decimal part of the seconds.
121
-
122
- ##### formatSubMilliseconds
123
-
124
- Type: `boolean`\
125
- Default: `false`
126
-
127
- Show microseconds and nanoseconds.
128
-
129
- ##### colonNotation
130
-
131
- Type: `boolean`\
132
- Default: `false`
133
-
134
- Display time using colon notation: `5h 1m 45s` → `5:01:45`. Always shows time in at least minutes: `1s` → `0:01`
135
-
136
- Useful when you want to display time without the time units, similar to a digital watch.
137
-
138
- Setting `colonNotation` to `true` overrides the following options to `false`:
139
- - `compact`
140
- - `formatSubMilliseconds`
141
- - `separateMilliseconds`
142
- - `verbose`
143
-
144
- ##### hideYear
145
-
146
- Type: `boolean`\
147
- Default: `false`
148
-
149
- Hides the year and shows the hidden year additionally as days (365 per year): `1y 3d 5h 1m 45s` → `368d 5h 1m 45s`.
150
-
151
- ##### hideYearAndDays
152
-
153
- Type: `boolean`\
154
- Default: `false`
155
-
156
- Hides the year and days and shows the hidden values additionally as hours: `1y 3d 5h 1m 45s` → `8837h 1m 45s`.
157
-
158
- ##### hideSeconds
159
-
160
- Type: `boolean`\
161
- Default: `false`
162
-
163
- Hides the seconds: `1y 3d 5h 1m 45s` → `1y 3d 5h 1m`.
164
-
165
- ##### subSecondsAsDecimals
166
-
167
- Type: `boolean`\
168
- Default: `false`
169
-
170
- Show sub-second values as decimal seconds: `900ms` → `0.9s`.
171
-
172
- Useful for progress indicators where you want consistent unit format to prevent flickering.
173
-
174
- ## Related
175
-
176
- - [pretty-ms-cli](https://github.com/sindresorhus/pretty-ms-cli) - CLI for this module
177
- - [parse-ms](https://github.com/sindresorhus/parse-ms) - Parse milliseconds into an object
178
- - [to-milliseconds](https://github.com/sindresorhus/to-milliseconds) - Convert an object of time properties to milliseconds
179
- - [pretty-bytes](https://github.com/sindresorhus/pretty-bytes) - Convert bytes to a human readable string