@cosystem/devtools 0.0.2
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/LICENSE +21 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +66 -0
- package/dist/index.js.map +1 -0
- package/package.json +39 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Coaction
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ActionEvent, App, ErrorContext, PatchEvent, Plugin, StateChangeEvent } from "@cosystem/core";
|
|
2
|
+
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
type DevtoolsTimelineEvent = {
|
|
5
|
+
readonly type: "setup";
|
|
6
|
+
readonly app: App;
|
|
7
|
+
readonly time: number;
|
|
8
|
+
} | {
|
|
9
|
+
readonly type: "action:start" | "action:end";
|
|
10
|
+
readonly event: ActionEvent;
|
|
11
|
+
readonly time: number;
|
|
12
|
+
} | {
|
|
13
|
+
readonly type: "patch";
|
|
14
|
+
readonly event: PatchEvent;
|
|
15
|
+
readonly time: number;
|
|
16
|
+
} | {
|
|
17
|
+
readonly type: "state";
|
|
18
|
+
readonly event: StateChangeEvent;
|
|
19
|
+
readonly time: number;
|
|
20
|
+
} | {
|
|
21
|
+
readonly type: "error";
|
|
22
|
+
readonly error: unknown;
|
|
23
|
+
readonly context: ErrorContext;
|
|
24
|
+
readonly time: number;
|
|
25
|
+
};
|
|
26
|
+
interface DevtoolsPlugin extends Plugin {
|
|
27
|
+
getTimeline(): readonly DevtoolsTimelineEvent[];
|
|
28
|
+
clearTimeline(): void;
|
|
29
|
+
}
|
|
30
|
+
interface DevtoolsOptions {
|
|
31
|
+
readonly maxEvents?: number;
|
|
32
|
+
readonly now?: () => number;
|
|
33
|
+
}
|
|
34
|
+
declare function createDevtoolsPlugin(options?: DevtoolsOptions): DevtoolsPlugin;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { DevtoolsOptions, DevtoolsPlugin, DevtoolsTimelineEvent, createDevtoolsPlugin };
|
|
37
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;KASY,qBAAA;EAAA,SAEG,IAAA;EAAA,SACA,GAAA,EAAK,GAAA;EAAA,SACL,IAAA;AAAA;EAAA,SAGA,IAAA;EAAA,SACA,KAAA,EAAO,WAAA;EAAA,SACP,IAAA;AAAA;EAAA,SAGA,IAAA;EAAA,SACA,KAAA,EAAO,UAAA;EAAA,SACP,IAAA;AAAA;EAAA,SAGA,IAAA;EAAA,SACA,KAAA,EAAO,gBAAA;EAAA,SACP,IAAA;AAAA;EAAA,SAGA,IAAA;EAAA,SACA,KAAA;EAAA,SACA,OAAA,EAAS,YAAA;EAAA,SACT,IAAA;AAAA;AAAA,UAGE,cAAA,SAAuB,MAAA;EACtC,WAAA,aAAwB,qBAAA;EACxB,aAAA;AAAA;AAAA,UAGe,eAAA;EAAA,SACN,SAAA;EAAA,SACA,GAAA;AAAA;AAAA,iBAGK,oBAAA,CAAqB,OAAA,GAAS,eAAA,GAAuB,cAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
//#region src/index.ts
|
|
2
|
+
function createDevtoolsPlugin(options = {}) {
|
|
3
|
+
const timeline = [];
|
|
4
|
+
const maxEvents = options.maxEvents ?? 1e3;
|
|
5
|
+
const now = options.now ?? Date.now;
|
|
6
|
+
const push = (event) => {
|
|
7
|
+
timeline.push(event);
|
|
8
|
+
if (timeline.length > maxEvents) timeline.splice(0, timeline.length - maxEvents);
|
|
9
|
+
};
|
|
10
|
+
return {
|
|
11
|
+
name: "cosystem:devtools",
|
|
12
|
+
clearTimeline() {
|
|
13
|
+
timeline.length = 0;
|
|
14
|
+
},
|
|
15
|
+
getTimeline() {
|
|
16
|
+
return timeline;
|
|
17
|
+
},
|
|
18
|
+
onActionEnd(event) {
|
|
19
|
+
push({
|
|
20
|
+
event,
|
|
21
|
+
time: now(),
|
|
22
|
+
type: "action:end"
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
onActionStart(event) {
|
|
26
|
+
push({
|
|
27
|
+
event,
|
|
28
|
+
time: now(),
|
|
29
|
+
type: "action:start"
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
onError(error, context) {
|
|
33
|
+
push({
|
|
34
|
+
context,
|
|
35
|
+
error,
|
|
36
|
+
time: now(),
|
|
37
|
+
type: "error"
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
onPatch(event) {
|
|
41
|
+
push({
|
|
42
|
+
event,
|
|
43
|
+
time: now(),
|
|
44
|
+
type: "patch"
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
onStateChange(event) {
|
|
48
|
+
push({
|
|
49
|
+
event,
|
|
50
|
+
time: now(),
|
|
51
|
+
type: "state"
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
setup(app) {
|
|
55
|
+
push({
|
|
56
|
+
app,
|
|
57
|
+
time: now(),
|
|
58
|
+
type: "setup"
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
export { createDevtoolsPlugin };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type {\n ActionEvent,\n App,\n ErrorContext,\n PatchEvent,\n Plugin,\n StateChangeEvent,\n} from \"@cosystem/core\";\n\nexport type DevtoolsTimelineEvent =\n | {\n readonly type: \"setup\";\n readonly app: App;\n readonly time: number;\n }\n | {\n readonly type: \"action:start\" | \"action:end\";\n readonly event: ActionEvent;\n readonly time: number;\n }\n | {\n readonly type: \"patch\";\n readonly event: PatchEvent;\n readonly time: number;\n }\n | {\n readonly type: \"state\";\n readonly event: StateChangeEvent;\n readonly time: number;\n }\n | {\n readonly type: \"error\";\n readonly error: unknown;\n readonly context: ErrorContext;\n readonly time: number;\n };\n\nexport interface DevtoolsPlugin extends Plugin {\n getTimeline(): readonly DevtoolsTimelineEvent[];\n clearTimeline(): void;\n}\n\nexport interface DevtoolsOptions {\n readonly maxEvents?: number;\n readonly now?: () => number;\n}\n\nexport function createDevtoolsPlugin(options: DevtoolsOptions = {}): DevtoolsPlugin {\n const timeline: DevtoolsTimelineEvent[] = [];\n const maxEvents = options.maxEvents ?? 1_000;\n const now = options.now ?? Date.now;\n\n const push = (event: DevtoolsTimelineEvent): void => {\n timeline.push(event);\n\n if (timeline.length > maxEvents) {\n timeline.splice(0, timeline.length - maxEvents);\n }\n };\n\n return {\n name: \"cosystem:devtools\",\n clearTimeline() {\n timeline.length = 0;\n },\n getTimeline() {\n return timeline;\n },\n onActionEnd(event) {\n push({\n event,\n time: now(),\n type: \"action:end\",\n });\n },\n onActionStart(event) {\n push({\n event,\n time: now(),\n type: \"action:start\",\n });\n },\n onError(error, context) {\n push({\n context,\n error,\n time: now(),\n type: \"error\",\n });\n },\n onPatch(event) {\n push({\n event,\n time: now(),\n type: \"patch\",\n });\n },\n onStateChange(event) {\n push({\n event,\n time: now(),\n type: \"state\",\n });\n },\n setup(app) {\n push({\n app,\n time: now(),\n type: \"setup\",\n });\n },\n };\n}\n"],"mappings":";AA+CA,SAAgB,qBAAqB,UAA2B,CAAC,GAAmB;CAClF,MAAM,WAAoC,CAAC;CAC3C,MAAM,YAAY,QAAQ,aAAa;CACvC,MAAM,MAAM,QAAQ,OAAO,KAAK;CAEhC,MAAM,QAAQ,UAAuC;EACnD,SAAS,KAAK,KAAK;EAEnB,IAAI,SAAS,SAAS,WACpB,SAAS,OAAO,GAAG,SAAS,SAAS,SAAS;CAElD;CAEA,OAAO;EACL,MAAM;EACN,gBAAgB;GACd,SAAS,SAAS;EACpB;EACA,cAAc;GACZ,OAAO;EACT;EACA,YAAY,OAAO;GACjB,KAAK;IACH;IACA,MAAM,IAAI;IACV,MAAM;GACR,CAAC;EACH;EACA,cAAc,OAAO;GACnB,KAAK;IACH;IACA,MAAM,IAAI;IACV,MAAM;GACR,CAAC;EACH;EACA,QAAQ,OAAO,SAAS;GACtB,KAAK;IACH;IACA;IACA,MAAM,IAAI;IACV,MAAM;GACR,CAAC;EACH;EACA,QAAQ,OAAO;GACb,KAAK;IACH;IACA,MAAM,IAAI;IACV,MAAM;GACR,CAAC;EACH;EACA,cAAc,OAAO;GACnB,KAAK;IACH;IACA,MAAM,IAAI;IACV,MAAM;GACR,CAAC;EACH;EACA,MAAM,KAAK;GACT,KAAK;IACH;IACA,MAAM,IAAI;IACV,MAAM;GACR,CAAC;EACH;CACF;AACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cosystem/devtools",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Dev inspection plugin for CoSystem.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"type": "module",
|
|
10
|
+
"sideEffects": false,
|
|
11
|
+
"module": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@cosystem/core": "0.0.2"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"tsdown": "0.22.3",
|
|
27
|
+
"typescript": "6.0.3",
|
|
28
|
+
"vitest": "4.1.9",
|
|
29
|
+
"@cosystem/tsconfig": "0.0.2"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsdown",
|
|
33
|
+
"clean": "rm -rf coverage dist .turbo",
|
|
34
|
+
"dev": "tsdown --watch",
|
|
35
|
+
"test": "cd ../.. && vitest run --project @cosystem/devtools",
|
|
36
|
+
"test:coverage": "cd ../.. && vitest run --coverage --project @cosystem/devtools",
|
|
37
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
38
|
+
}
|
|
39
|
+
}
|