pushwork 2.0.0-preview.3 → 2.0.0-preview.5
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/dist/branches.d.ts +2 -1
- package/dist/branches.d.ts.map +1 -1
- package/dist/branches.js +23 -4
- package/dist/branches.js.map +1 -1
- package/dist/checkpoints.d.ts +41 -0
- package/dist/checkpoints.d.ts.map +1 -0
- package/dist/checkpoints.js +210 -0
- package/dist/checkpoints.js.map +1 -0
- package/dist/cli.js +14 -0
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/pushwork.d.ts +22 -7
- package/dist/pushwork.d.ts.map +1 -1
- package/dist/pushwork.js +144 -18
- package/dist/pushwork.js.map +1 -1
- package/dist/stash.d.ts +2 -0
- package/dist/stash.d.ts.map +1 -1
- package/dist/stash.js +1 -0
- package/dist/stash.js.map +1 -1
- package/package.json +2 -2
- package/dist/cli/commands.d.ts +0 -71
- package/dist/cli/commands.d.ts.map +0 -1
- package/dist/cli/commands.js +0 -794
- package/dist/cli/commands.js.map +0 -1
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/index.js +0 -19
- package/dist/cli/index.js.map +0 -1
- package/dist/commands.d.ts +0 -58
- package/dist/commands.d.ts.map +0 -1
- package/dist/commands.js +0 -975
- package/dist/commands.js.map +0 -1
- package/dist/config/index.d.ts +0 -71
- package/dist/config/index.d.ts.map +0 -1
- package/dist/config/index.js +0 -314
- package/dist/config/index.js.map +0 -1
- package/dist/core/change-detection.d.ts +0 -80
- package/dist/core/change-detection.d.ts.map +0 -1
- package/dist/core/change-detection.js +0 -560
- package/dist/core/change-detection.js.map +0 -1
- package/dist/core/config.d.ts +0 -81
- package/dist/core/config.d.ts.map +0 -1
- package/dist/core/config.js +0 -304
- package/dist/core/config.js.map +0 -1
- package/dist/core/index.d.ts +0 -6
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -22
- package/dist/core/index.js.map +0 -1
- package/dist/core/move-detection.d.ts +0 -34
- package/dist/core/move-detection.d.ts.map +0 -1
- package/dist/core/move-detection.js +0 -128
- package/dist/core/move-detection.js.map +0 -1
- package/dist/core/snapshot.d.ts +0 -105
- package/dist/core/snapshot.d.ts.map +0 -1
- package/dist/core/snapshot.js +0 -254
- package/dist/core/snapshot.js.map +0 -1
- package/dist/core/sync-engine.d.ts +0 -177
- package/dist/core/sync-engine.d.ts.map +0 -1
- package/dist/core/sync-engine.js +0 -1471
- package/dist/core/sync-engine.js.map +0 -1
- package/dist/types/config.d.ts +0 -102
- package/dist/types/config.d.ts.map +0 -1
- package/dist/types/config.js +0 -10
- package/dist/types/config.js.map +0 -1
- package/dist/types/documents.d.ts +0 -88
- package/dist/types/documents.d.ts.map +0 -1
- package/dist/types/documents.js +0 -23
- package/dist/types/documents.js.map +0 -1
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -20
- package/dist/types/index.js.map +0 -1
- package/dist/types/snapshot.d.ts +0 -64
- package/dist/types/snapshot.d.ts.map +0 -1
- package/dist/types/snapshot.js +0 -3
- package/dist/types/snapshot.js.map +0 -1
- package/dist/utils/content-similarity.d.ts +0 -53
- package/dist/utils/content-similarity.d.ts.map +0 -1
- package/dist/utils/content-similarity.js +0 -155
- package/dist/utils/content-similarity.js.map +0 -1
- package/dist/utils/content.d.ts +0 -10
- package/dist/utils/content.d.ts.map +0 -1
- package/dist/utils/content.js +0 -35
- package/dist/utils/content.js.map +0 -1
- package/dist/utils/directory.d.ts +0 -24
- package/dist/utils/directory.d.ts.map +0 -1
- package/dist/utils/directory.js +0 -56
- package/dist/utils/directory.js.map +0 -1
- package/dist/utils/fs.d.ts +0 -74
- package/dist/utils/fs.d.ts.map +0 -1
- package/dist/utils/fs.js +0 -298
- package/dist/utils/fs.js.map +0 -1
- package/dist/utils/index.d.ts +0 -5
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -21
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/mime-types.d.ts +0 -13
- package/dist/utils/mime-types.d.ts.map +0 -1
- package/dist/utils/mime-types.js +0 -247
- package/dist/utils/mime-types.js.map +0 -1
- package/dist/utils/network-sync.d.ts +0 -30
- package/dist/utils/network-sync.d.ts.map +0 -1
- package/dist/utils/network-sync.js +0 -391
- package/dist/utils/network-sync.js.map +0 -1
- package/dist/utils/node-polyfills.d.ts +0 -9
- package/dist/utils/node-polyfills.d.ts.map +0 -1
- package/dist/utils/node-polyfills.js +0 -9
- package/dist/utils/node-polyfills.js.map +0 -1
- package/dist/utils/output.d.ts +0 -129
- package/dist/utils/output.d.ts.map +0 -1
- package/dist/utils/output.js +0 -375
- package/dist/utils/output.js.map +0 -1
- package/dist/utils/repo-factory.d.ts +0 -15
- package/dist/utils/repo-factory.d.ts.map +0 -1
- package/dist/utils/repo-factory.js +0 -156
- package/dist/utils/repo-factory.js.map +0 -1
- package/dist/utils/string-similarity.d.ts +0 -14
- package/dist/utils/string-similarity.d.ts.map +0 -1
- package/dist/utils/string-similarity.js +0 -43
- package/dist/utils/string-similarity.js.map +0 -1
- package/dist/utils/text-diff.d.ts +0 -37
- package/dist/utils/text-diff.d.ts.map +0 -1
- package/dist/utils/text-diff.js +0 -131
- package/dist/utils/text-diff.js.map +0 -1
- package/dist/utils/trace.d.ts +0 -19
- package/dist/utils/trace.d.ts.map +0 -1
- package/dist/utils/trace.js +0 -68
- package/dist/utils/trace.js.map +0 -1
- package/patches/@automerge__automerge-repo@2.6.0-subduction.15.patch +0 -26
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import * as A from "@automerge/automerge";
|
|
2
|
-
/**
|
|
3
|
-
* Read content from an Automerge document, normalizing legacy ImmutableString
|
|
4
|
-
* values to plain strings for backwards compatibility.
|
|
5
|
-
*
|
|
6
|
-
* Old documents may store text as ImmutableString. This helper ensures callers
|
|
7
|
-
* always get back `string | Uint8Array | null`.
|
|
8
|
-
*/
|
|
9
|
-
export declare function readDocContent(content: unknown): string | Uint8Array | null;
|
|
10
|
-
/**
|
|
11
|
-
* Update text content on an Automerge document property inside a change
|
|
12
|
-
* callback.
|
|
13
|
-
*
|
|
14
|
-
* If the existing value is already a collaborative text string, we diff and
|
|
15
|
-
* splice for minimal CRDT operations. If the existing value is a legacy
|
|
16
|
-
* ImmutableString we can't splice into it, so we assign the whole string
|
|
17
|
-
* which converts the field to a collaborative text CRDT going forward.
|
|
18
|
-
*
|
|
19
|
-
* @param doc - The mutable Automerge document (inside a change callback)
|
|
20
|
-
* @param path - Property path to the text field, e.g. ["content"]
|
|
21
|
-
* @param newContent - The desired new text value
|
|
22
|
-
*/
|
|
23
|
-
export declare function updateTextContent(doc: any, path: A.Prop[], newContent: string): void;
|
|
24
|
-
/**
|
|
25
|
-
* Apply a text diff between oldContent and newContent as Automerge splice
|
|
26
|
-
* operations on the given document property path.
|
|
27
|
-
*
|
|
28
|
-
* This preserves the collaborative text CRDT structure by making minimal
|
|
29
|
-
* character-level edits rather than replacing the entire string.
|
|
30
|
-
*
|
|
31
|
-
* @param doc - The Automerge document (inside a change callback)
|
|
32
|
-
* @param path - The property path to the text field, e.g. ["content"]
|
|
33
|
-
* @param oldContent - The previous text content
|
|
34
|
-
* @param newContent - The desired new text content
|
|
35
|
-
*/
|
|
36
|
-
export declare function spliceText(doc: any, path: A.Prop[], oldContent: string, newContent: string): void;
|
|
37
|
-
//# sourceMappingURL=text-diff.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"text-diff.d.ts","sourceRoot":"","sources":["../../src/utils/text-diff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,sBAAsB,CAAA;AAGzC;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,IAAI,CAO3E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAChC,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EACd,UAAU,EAAE,MAAM,GAChB,IAAI,CAeN;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CACzB,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EACd,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GAChB,IAAI,CA8BN"}
|
package/dist/utils/text-diff.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.readDocContent = readDocContent;
|
|
37
|
-
exports.updateTextContent = updateTextContent;
|
|
38
|
-
exports.spliceText = spliceText;
|
|
39
|
-
const A = __importStar(require("@automerge/automerge"));
|
|
40
|
-
const diffLib = __importStar(require("diff"));
|
|
41
|
-
/**
|
|
42
|
-
* Read content from an Automerge document, normalizing legacy ImmutableString
|
|
43
|
-
* values to plain strings for backwards compatibility.
|
|
44
|
-
*
|
|
45
|
-
* Old documents may store text as ImmutableString. This helper ensures callers
|
|
46
|
-
* always get back `string | Uint8Array | null`.
|
|
47
|
-
*/
|
|
48
|
-
function readDocContent(content) {
|
|
49
|
-
if (content == null)
|
|
50
|
-
return null;
|
|
51
|
-
if (typeof content === "string")
|
|
52
|
-
return content;
|
|
53
|
-
if (content instanceof Uint8Array)
|
|
54
|
-
return content;
|
|
55
|
-
// Legacy ImmutableString — convert to plain string
|
|
56
|
-
if (A.isImmutableString(content))
|
|
57
|
-
return content.toString();
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Update text content on an Automerge document property inside a change
|
|
62
|
-
* callback.
|
|
63
|
-
*
|
|
64
|
-
* If the existing value is already a collaborative text string, we diff and
|
|
65
|
-
* splice for minimal CRDT operations. If the existing value is a legacy
|
|
66
|
-
* ImmutableString we can't splice into it, so we assign the whole string
|
|
67
|
-
* which converts the field to a collaborative text CRDT going forward.
|
|
68
|
-
*
|
|
69
|
-
* @param doc - The mutable Automerge document (inside a change callback)
|
|
70
|
-
* @param path - Property path to the text field, e.g. ["content"]
|
|
71
|
-
* @param newContent - The desired new text value
|
|
72
|
-
*/
|
|
73
|
-
function updateTextContent(doc, path, newContent) {
|
|
74
|
-
const target = path.reduce((obj, key) => obj?.[key], doc);
|
|
75
|
-
if (typeof target === "string") {
|
|
76
|
-
// Already a collaborative text string — diff and splice
|
|
77
|
-
spliceText(doc, path, target, newContent);
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
// Legacy ImmutableString, undefined, or other — assign directly.
|
|
81
|
-
// This converts the field to a collaborative text CRDT.
|
|
82
|
-
let obj = doc;
|
|
83
|
-
for (let i = 0; i < path.length - 1; i++) {
|
|
84
|
-
obj = obj[path[i]];
|
|
85
|
-
}
|
|
86
|
-
obj[path[path.length - 1]] = newContent;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Apply a text diff between oldContent and newContent as Automerge splice
|
|
91
|
-
* operations on the given document property path.
|
|
92
|
-
*
|
|
93
|
-
* This preserves the collaborative text CRDT structure by making minimal
|
|
94
|
-
* character-level edits rather than replacing the entire string.
|
|
95
|
-
*
|
|
96
|
-
* @param doc - The Automerge document (inside a change callback)
|
|
97
|
-
* @param path - The property path to the text field, e.g. ["content"]
|
|
98
|
-
* @param oldContent - The previous text content
|
|
99
|
-
* @param newContent - The desired new text content
|
|
100
|
-
*/
|
|
101
|
-
function spliceText(doc, path, oldContent, newContent) {
|
|
102
|
-
if (oldContent === newContent)
|
|
103
|
-
return;
|
|
104
|
-
// Fast path: if old is empty, just insert everything
|
|
105
|
-
if (oldContent === "") {
|
|
106
|
-
A.splice(doc, path, 0, 0, newContent);
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
// Fast path: if new is empty, just delete everything
|
|
110
|
-
if (newContent === "") {
|
|
111
|
-
A.splice(doc, path, 0, oldContent.length);
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
const changes = diffLib.diffChars(oldContent, newContent);
|
|
115
|
-
let pos = 0;
|
|
116
|
-
for (const part of changes) {
|
|
117
|
-
if (part.removed) {
|
|
118
|
-
A.splice(doc, path, pos, part.value.length);
|
|
119
|
-
// Don't advance pos — text shifted left after deletion
|
|
120
|
-
}
|
|
121
|
-
else if (part.added) {
|
|
122
|
-
A.splice(doc, path, pos, 0, part.value);
|
|
123
|
-
pos += part.value.length;
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
// Unchanged text — just advance the cursor
|
|
127
|
-
pos += part.value.length;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
//# sourceMappingURL=text-diff.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"text-diff.js","sourceRoot":"","sources":["../../src/utils/text-diff.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,wCAOC;AAeD,8CAmBC;AAcD,gCAmCC;AApGD,wDAAyC;AACzC,8CAA+B;AAE/B;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,OAAgB;IAC9C,IAAI,OAAO,IAAI,IAAI;QAAE,OAAO,IAAI,CAAA;IAChC,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAA;IAC/C,IAAI,OAAO,YAAY,UAAU;QAAE,OAAO,OAAO,CAAA;IACjD,mDAAmD;IACnD,IAAI,CAAC,CAAC,iBAAiB,CAAC,OAAO,CAAC;QAAE,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAA;IAC3D,OAAO,IAAI,CAAA;AACZ,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,iBAAiB,CAChC,GAAQ,EACR,IAAc,EACd,UAAkB;IAElB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAQ,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAA;IAE9D,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE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AAG,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;YAC3C,uDAAuD;QACxD,CAAC;aAAM,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACvB,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;YACvC,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAA;QACzB,CAAC;aAAM,CAAC;YACP,2CAA2C;YAC3C,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAA;QACzB,CAAC;IACF,CAAC;AACF,CAAC"}
|
package/dist/utils/trace.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Enable or disable tracing
|
|
3
|
-
*/
|
|
4
|
-
export declare function setTracingEnabled(enabled: boolean): void;
|
|
5
|
-
/**
|
|
6
|
-
* Check if tracing is enabled
|
|
7
|
-
*/
|
|
8
|
-
export declare function isTracingEnabled(): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Trace a span of work by outputting to console
|
|
11
|
-
* Works for both sync and async functions
|
|
12
|
-
* Only outputs if tracing is enabled
|
|
13
|
-
*
|
|
14
|
-
* Usage:
|
|
15
|
-
* await span("operation", async () => { ... })
|
|
16
|
-
* span("operation", () => { ... })
|
|
17
|
-
*/
|
|
18
|
-
export declare function span<T>(name: string, fn: () => T | Promise<T>): T | Promise<T>;
|
|
19
|
-
//# sourceMappingURL=trace.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../src/utils/trace.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAExD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C;AAED;;;;;;;;GAQG;AACH,wBAAgB,IAAI,CAAC,CAAC,EACpB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GACvB,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAqBhB"}
|
package/dist/utils/trace.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setTracingEnabled = setTracingEnabled;
|
|
4
|
-
exports.isTracingEnabled = isTracingEnabled;
|
|
5
|
-
exports.span = span;
|
|
6
|
-
const output_1 = require("./output");
|
|
7
|
-
/**
|
|
8
|
-
* Global tracing state
|
|
9
|
-
*/
|
|
10
|
-
let tracingEnabled = false;
|
|
11
|
-
/**
|
|
12
|
-
* Enable or disable tracing
|
|
13
|
-
*/
|
|
14
|
-
function setTracingEnabled(enabled) {
|
|
15
|
-
tracingEnabled = enabled;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Check if tracing is enabled
|
|
19
|
-
*/
|
|
20
|
-
function isTracingEnabled() {
|
|
21
|
-
return tracingEnabled;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Trace a span of work by outputting to console
|
|
25
|
-
* Works for both sync and async functions
|
|
26
|
-
* Only outputs if tracing is enabled
|
|
27
|
-
*
|
|
28
|
-
* Usage:
|
|
29
|
-
* await span("operation", async () => { ... })
|
|
30
|
-
* span("operation", () => { ... })
|
|
31
|
-
*/
|
|
32
|
-
function span(name, fn) {
|
|
33
|
-
if (!tracingEnabled) {
|
|
34
|
-
return fn();
|
|
35
|
-
}
|
|
36
|
-
const start = performance.now();
|
|
37
|
-
const result = fn();
|
|
38
|
-
// Check if it's a promise (async)
|
|
39
|
-
if (result instanceof Promise) {
|
|
40
|
-
return result.then((value) => {
|
|
41
|
-
const duration = performance.now() - start;
|
|
42
|
-
output_1.out.taskLine(`${name} (${formatDuration(duration)})`, true);
|
|
43
|
-
return value;
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
// Sync case
|
|
47
|
-
const duration = performance.now() - start;
|
|
48
|
-
output_1.out.taskLine(`${name} (${formatDuration(duration)})`, true);
|
|
49
|
-
return result;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Format duration for display
|
|
53
|
-
*/
|
|
54
|
-
function formatDuration(ms) {
|
|
55
|
-
if (ms < 1) {
|
|
56
|
-
return `${ms.toFixed(2)}ms`;
|
|
57
|
-
}
|
|
58
|
-
else if (ms < 1000) {
|
|
59
|
-
return `${Math.round(ms)}ms`;
|
|
60
|
-
}
|
|
61
|
-
else if (ms < 2000) {
|
|
62
|
-
return `${(ms / 1000).toFixed(2)}s`;
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
return `${(ms / 1000).toFixed(1)}s`;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=trace.js.map
|
package/dist/utils/trace.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"trace.js","sourceRoot":"","sources":["../../src/utils/trace.ts"],"names":[],"mappings":";;AAUA,8CAEC;AAKD,4CAEC;AAWD,oBAwBC;AAtDD,qCAA+B;AAE/B;;GAEG;AACH,IAAI,cAAc,GAAG,KAAK,CAAC;AAE3B;;GAEG;AACH,SAAgB,iBAAiB,CAAC,OAAgB;IAChD,cAAc,GAAG,OAAO,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,SAAgB,gBAAgB;IAC9B,OAAO,cAAc,CAAC;AACxB,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,IAAI,CAClB,IAAY,EACZ,EAAwB;IAExB,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;IAED,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAChC,MAAM,MAAM,GAAG,EAAE,EAAE,CAAC;IAEpB,kCAAkC;IAClC,IAAI,MA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800f163b58a153e747f2a7090c0d38 100644
|
|
3
|
-
--- a/dist/helpers/throttle.js
|
|
4
|
-
+++ b/dist/helpers/throttle.js
|
|
5
|
-
@@ -31,7 +31,7 @@ export const throttle = (fn, delay) => {
|
|
6
|
-
let pendingArgs;
|
|
7
|
-
const throttled = function (...args) {
|
|
8
|
-
pendingArgs = args;
|
|
9
|
-
- wait = lastCall + delay - Date.now();
|
|
10
|
-
+ wait = Math.max(0, lastCall + delay - Date.now());
|
|
11
|
-
clearTimeout(timeout);
|
|
12
|
-
timeout = setTimeout(() => {
|
|
13
|
-
timeout = undefined;
|
|
14
|
-
diff --git a/src/helpers/throttle.ts b/src/helpers/throttle.ts
|
|
15
|
-
index a0933cdc809ed9944f2129c943ac0c9e90bcd195..43050dc0375031bc4490162a7314e3b3541a3f40 100644
|
|
16
|
-
--- a/src/helpers/throttle.ts
|
|
17
|
-
+++ b/src/helpers/throttle.ts
|
|
18
|
-
@@ -42,7 +42,7 @@ export const throttle = <F extends (...args: any[]) => any>(
|
|
19
|
-
|
|
20
|
-
const throttled = function (...args: Parameters<F>) {
|
|
21
|
-
pendingArgs = args
|
|
22
|
-
- wait = lastCall + delay - Date.now()
|
|
23
|
-
+ wait = Math.max(0, lastCall + delay - Date.now())
|
|
24
|
-
clearTimeout(timeout)
|
|
25
|
-
timeout = setTimeout(() => {
|
|
26
|
-
timeout = undefined
|