nucleus-core-ts 0.10.237 → 0.10.239
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/.build-ok +1 -1
- package/dist/fe/components/Replay/_components/ReplayCaption/index.d.ts +3 -0
- package/dist/fe/components/Replay/_components/ReplayCaption/index.js +53 -0
- package/dist/fe/components/Replay/_components/ReplayCaption/types.d.ts +12 -0
- package/dist/fe/components/Replay/_components/ReplayCaption/types.js +1 -0
- package/dist/fe/components/Replay/_components/ReplayChapters/index.d.ts +3 -0
- package/dist/fe/components/Replay/_components/ReplayChapters/index.js +56 -0
- package/dist/fe/components/Replay/_components/ReplayChapters/types.d.ts +8 -0
- package/dist/fe/components/Replay/_components/ReplayChapters/types.js +1 -0
- package/dist/fe/components/Replay/_components/ReplayControls/index.d.ts +3 -0
- package/dist/fe/components/Replay/_components/ReplayControls/index.js +88 -0
- package/dist/fe/components/Replay/_components/ReplayControls/types.d.ts +15 -0
- package/dist/fe/components/Replay/_components/ReplayControls/types.js +1 -0
- package/dist/fe/components/Replay/_components/ReplayCursor/index.d.ts +6 -0
- package/dist/fe/components/Replay/_components/ReplayCursor/index.js +91 -0
- package/dist/fe/components/Replay/_components/ReplayCursor/types.d.ts +11 -0
- package/dist/fe/components/Replay/_components/ReplayCursor/types.js +1 -0
- package/dist/fe/components/Replay/_components/ReplayEnded/index.d.ts +9 -0
- package/dist/fe/components/Replay/_components/ReplayEnded/index.js +36 -0
- package/dist/fe/components/Replay/_components/ReplayFailure/index.d.ts +3 -0
- package/dist/fe/components/Replay/_components/ReplayFailure/index.js +32 -0
- package/dist/fe/components/Replay/_components/ReplayFailure/types.d.ts +6 -0
- package/dist/fe/components/Replay/_components/ReplayFailure/types.js +1 -0
- package/dist/fe/components/Replay/_components/ReplayPlayer/ReplayView.d.ts +10 -0
- package/dist/fe/components/Replay/_components/ReplayPlayer/ReplayView.js +100 -0
- package/dist/fe/components/Replay/_components/ReplayPlayer/index.d.ts +6 -0
- package/dist/fe/components/Replay/_components/ReplayPlayer/index.js +28 -0
- package/dist/fe/components/Replay/_components/ReplayPlayer/types.d.ts +9 -0
- package/dist/fe/components/Replay/_components/ReplayPlayer/types.js +1 -0
- package/dist/fe/components/Replay/_components/ReplaySkeleton/index.d.ts +4 -0
- package/dist/fe/components/Replay/_components/ReplaySkeleton/index.js +148 -0
- package/dist/fe/components/Replay/_components/ReplayStage/ReplayVeil.d.ts +2 -0
- package/dist/fe/components/Replay/_components/ReplayStage/ReplayVeil.js +34 -0
- package/dist/fe/components/Replay/_components/ReplayStage/index.d.ts +6 -0
- package/dist/fe/components/Replay/_components/ReplayStage/index.js +76 -0
- package/dist/fe/components/Replay/_components/ReplayStage/types.d.ts +18 -0
- package/dist/fe/components/Replay/_components/ReplayStage/types.js +1 -0
- package/dist/fe/components/Replay/_components/index.d.ts +11 -0
- package/dist/fe/components/Replay/_components/index.js +10 -0
- package/dist/fe/components/Replay/_hooks/index.d.ts +3 -0
- package/dist/fe/components/Replay/_hooks/index.js +3 -0
- package/dist/fe/components/Replay/_hooks/useReplayPlayer.d.ts +6 -0
- package/dist/fe/components/Replay/_hooks/useReplayPlayer.js +63 -0
- package/dist/fe/components/Replay/_hooks/useShimmer.d.ts +3 -0
- package/dist/fe/components/Replay/_hooks/useShimmer.js +31 -0
- package/dist/fe/components/Replay/_hooks/useStageScale.d.ts +5 -0
- package/dist/fe/components/Replay/_hooks/useStageScale.js +24 -0
- package/dist/fe/components/Replay/_store/index.d.ts +1 -0
- package/dist/fe/components/Replay/_store/index.js +1 -0
- package/dist/fe/components/Replay/_store/replayStore.d.ts +13 -0
- package/dist/fe/components/Replay/_store/replayStore.js +74 -0
- package/dist/fe/components/Replay/_types/index.d.ts +1 -0
- package/dist/fe/components/Replay/_types/index.js +1 -0
- package/dist/fe/components/Replay/_types/player.d.ts +105 -0
- package/dist/fe/components/Replay/_types/player.js +1 -0
- package/dist/fe/components/Replay/_utils/controller.d.ts +10 -0
- package/dist/fe/components/Replay/_utils/controller.js +208 -0
- package/dist/fe/components/Replay/_utils/controllerReports.d.ts +18 -0
- package/dist/fe/components/Replay/_utils/controllerReports.js +70 -0
- package/dist/fe/components/Replay/_utils/copy.d.ts +29 -0
- package/dist/fe/components/Replay/_utils/copy.js +75 -0
- package/dist/fe/components/Replay/_utils/cursorMotion.d.ts +38 -0
- package/dist/fe/components/Replay/_utils/cursorMotion.js +98 -0
- package/dist/fe/components/Replay/_utils/frameBridge.d.ts +40 -0
- package/dist/fe/components/Replay/_utils/frameBridge.js +167 -0
- package/dist/fe/components/Replay/_utils/framePoints.d.ts +17 -0
- package/dist/fe/components/Replay/_utils/framePoints.js +24 -0
- package/dist/fe/components/Replay/_utils/frameUrl.d.ts +21 -0
- package/dist/fe/components/Replay/_utils/frameUrl.js +23 -0
- package/dist/fe/components/Replay/_utils/index.d.ts +7 -0
- package/dist/fe/components/Replay/_utils/index.js +7 -0
- package/dist/fe/components/Replay/_utils/replayCss.d.ts +2 -0
- package/dist/fe/components/Replay/_utils/replayCss.js +4 -0
- package/dist/fe/components/Replay/_utils/replayLayout.d.ts +2 -0
- package/dist/fe/components/Replay/_utils/replayLayout.js +20 -0
- package/dist/fe/components/Replay/_utils/replayPalette.d.ts +1 -0
- package/dist/fe/components/Replay/_utils/replayPalette.js +8 -0
- package/dist/fe/components/Replay/_utils/replayParts.d.ts +1 -0
- package/dist/fe/components/Replay/_utils/replayParts.js +56 -0
- package/dist/fe/components/Replay/_utils/replayProgress.d.ts +14 -0
- package/dist/fe/components/Replay/_utils/replayProgress.js +39 -0
- package/dist/fe/components/Replay/index.d.ts +5 -0
- package/dist/fe/components/Replay/index.js +5 -0
- package/dist/src/Client/Replay/index.d.ts +1 -0
- package/dist/src/Client/Replay/index.js +1 -0
- package/dist/src/Client/Replay/recorder/anchors.d.ts +18 -0
- package/dist/src/Client/Replay/recorder/anchors.js +39 -0
- package/dist/src/Client/Replay/recorder/bundle.d.ts +60 -0
- package/dist/src/Client/Replay/recorder/bundle.js +103 -0
- package/dist/src/Client/Replay/recorder/clock.d.ts +13 -0
- package/dist/src/Client/Replay/recorder/clock.js +9 -0
- package/dist/src/Client/Replay/recorder/factoryTap.d.ts +22 -0
- package/dist/src/Client/Replay/recorder/factoryTap.js +24 -0
- package/dist/src/Client/Replay/recorder/fetchTee.d.ts +37 -0
- package/dist/src/Client/Replay/recorder/fetchTee.js +121 -0
- package/dist/src/Client/Replay/recorder/index.d.ts +9 -0
- package/dist/src/Client/Replay/recorder/index.js +9 -0
- package/dist/src/Client/Replay/recorder/privacy.d.ts +27 -0
- package/dist/src/Client/Replay/recorder/privacy.js +115 -0
- package/dist/src/Client/Replay/recorder/redact.d.ts +8 -0
- package/dist/src/Client/Replay/recorder/redact.js +100 -0
- package/dist/src/Client/Replay/recorder/socketTap.d.ts +21 -0
- package/dist/src/Client/Replay/recorder/socketTap.js +43 -0
- package/dist/src/Client/Replay/recorder/sse.d.ts +15 -0
- package/dist/src/Client/Replay/recorder/sse.js +56 -0
- package/dist/src/Client/Replay/recorder/steps.d.ts +27 -0
- package/dist/src/Client/Replay/recorder/steps.js +152 -0
- package/package.json +5 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** One dispatched server-sent event. */
|
|
2
|
+
export interface ParsedSseFrame {
|
|
3
|
+
data: string;
|
|
4
|
+
event?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface SseParser {
|
|
7
|
+
/** Feeds decoded text; returns the events completed by it. A chunk may end anywhere, even between `\r` and `\n`. */
|
|
8
|
+
push: (text: string) => ParsedSseFrame[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* An incremental SSE parser: `event:` and `data:` fields (several `data:` lines join with `\n`), a blank line
|
|
12
|
+
* dispatches; comments (`:` lines, heartbeats) and `id:`/`retry:` are ignored; an event with no data is dropped,
|
|
13
|
+
* and so is one still open when the stream ends.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createSseParser(): SseParser;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/** One dispatched server-sent event. */ function field(line) {
|
|
2
|
+
const colon = line.indexOf(':');
|
|
3
|
+
if (colon === -1) return [
|
|
4
|
+
line,
|
|
5
|
+
''
|
|
6
|
+
];
|
|
7
|
+
const value = line.slice(colon + 1);
|
|
8
|
+
return [
|
|
9
|
+
line.slice(0, colon),
|
|
10
|
+
value.startsWith(' ') ? value.slice(1) : value
|
|
11
|
+
];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* An incremental SSE parser: `event:` and `data:` fields (several `data:` lines join with `\n`), a blank line
|
|
15
|
+
* dispatches; comments (`:` lines, heartbeats) and `id:`/`retry:` are ignored; an event with no data is dropped,
|
|
16
|
+
* and so is one still open when the stream ends.
|
|
17
|
+
*/ export function createSseParser() {
|
|
18
|
+
let buffer = '';
|
|
19
|
+
let data = [];
|
|
20
|
+
let event;
|
|
21
|
+
const line = (text, out)=>{
|
|
22
|
+
if (text === '') {
|
|
23
|
+
if (data.length > 0) out.push(event === undefined ? {
|
|
24
|
+
data: data.join('\n')
|
|
25
|
+
} : {
|
|
26
|
+
data: data.join('\n'),
|
|
27
|
+
event
|
|
28
|
+
});
|
|
29
|
+
data = [];
|
|
30
|
+
event = undefined;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (text.startsWith(':')) return;
|
|
34
|
+
const [name, value] = field(text);
|
|
35
|
+
if (name === 'data') data.push(value);
|
|
36
|
+
else if (name === 'event') event = value;
|
|
37
|
+
};
|
|
38
|
+
return {
|
|
39
|
+
push (text) {
|
|
40
|
+
buffer += text;
|
|
41
|
+
if (buffer.charCodeAt(0) === 0xfeff) buffer = buffer.slice(1);
|
|
42
|
+
const out = [];
|
|
43
|
+
let start = 0;
|
|
44
|
+
for(let i = 0; i < buffer.length; i++){
|
|
45
|
+
const ch = buffer[i];
|
|
46
|
+
if (ch !== '\n' && ch !== '\r') continue;
|
|
47
|
+
if (ch === '\r' && i === buffer.length - 1) break;
|
|
48
|
+
line(buffer.slice(start, i), out);
|
|
49
|
+
if (ch === '\r' && buffer[i + 1] === '\n') i++;
|
|
50
|
+
start = i + 1;
|
|
51
|
+
}
|
|
52
|
+
buffer = buffer.slice(start);
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ReplayStep } from '../contract/types';
|
|
2
|
+
import { type UnanchoredReport } from './anchors';
|
|
3
|
+
import type { RecorderClock } from './clock';
|
|
4
|
+
export interface StepCaptureOptions {
|
|
5
|
+
root: Document;
|
|
6
|
+
clock: RecorderClock;
|
|
7
|
+
/** The attribute anchors are read from. Default `data-tour`. */
|
|
8
|
+
targetAttribute?: string;
|
|
9
|
+
/** Chapter new steps belong to. Default `main`. */
|
|
10
|
+
chapter?: string;
|
|
11
|
+
/** Quiet time after the last keystroke before a `type` action is written. Default 400 ms. */
|
|
12
|
+
debounceMs?: number;
|
|
13
|
+
/** Written in place of what was typed into a password field; the real value is never read. Default empty. */
|
|
14
|
+
secretValue?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface StepCapture {
|
|
17
|
+
start: () => void;
|
|
18
|
+
/** Removes the listeners and writes any typing still waiting. */
|
|
19
|
+
stop: () => void;
|
|
20
|
+
/** Closes the current step; the next action opens a new one, in `chapter` when given. */
|
|
21
|
+
beginStep: (chapter?: string) => void;
|
|
22
|
+
steps: () => ReplayStep[];
|
|
23
|
+
/** Operated elements that carry no anchor, so the app can add one. */
|
|
24
|
+
unanchored: () => UnanchoredReport[];
|
|
25
|
+
}
|
|
26
|
+
/** Captures user steps from DOM events on elements carrying the target attribute. */
|
|
27
|
+
export declare function createStepCapture(options: StepCaptureOptions): StepCapture;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { anchorOf, clickTarget, createUnanchoredLog } from './anchors';
|
|
2
|
+
const NON_TEXT = new Set([
|
|
3
|
+
'checkbox',
|
|
4
|
+
'radio',
|
|
5
|
+
'file',
|
|
6
|
+
'button',
|
|
7
|
+
'submit',
|
|
8
|
+
'reset',
|
|
9
|
+
'image',
|
|
10
|
+
'range',
|
|
11
|
+
'color'
|
|
12
|
+
]);
|
|
13
|
+
const KEYS = new Set([
|
|
14
|
+
'Enter',
|
|
15
|
+
'Escape'
|
|
16
|
+
]);
|
|
17
|
+
/** Captures user steps from DOM events on elements carrying the target attribute. */ export function createStepCapture(options) {
|
|
18
|
+
const { root, clock } = options;
|
|
19
|
+
const attribute = options.targetAttribute ?? 'data-tour';
|
|
20
|
+
const debounceMs = options.debounceMs ?? 400;
|
|
21
|
+
const log = createUnanchoredLog(root, attribute);
|
|
22
|
+
const list = [];
|
|
23
|
+
let chapter = options.chapter ?? 'main';
|
|
24
|
+
let current = null;
|
|
25
|
+
let pending = null;
|
|
26
|
+
const add = (element, build)=>{
|
|
27
|
+
const target = anchorOf(element, attribute, root);
|
|
28
|
+
if (target === null) return log.add(element);
|
|
29
|
+
const action = build(target);
|
|
30
|
+
if (action === null) return;
|
|
31
|
+
if (current === null) {
|
|
32
|
+
current = {
|
|
33
|
+
id: `step-${list.length + 1}`,
|
|
34
|
+
chapter,
|
|
35
|
+
at: clock.at(),
|
|
36
|
+
caption: {
|
|
37
|
+
en: ''
|
|
38
|
+
},
|
|
39
|
+
actions: []
|
|
40
|
+
};
|
|
41
|
+
list.push(current);
|
|
42
|
+
}
|
|
43
|
+
current.actions.push(action);
|
|
44
|
+
};
|
|
45
|
+
const flush = ()=>{
|
|
46
|
+
if (pending === null) return;
|
|
47
|
+
const { element, timer } = pending;
|
|
48
|
+
pending = null;
|
|
49
|
+
clearTimeout(timer);
|
|
50
|
+
const secret = element instanceof HTMLInputElement && element.type === 'password';
|
|
51
|
+
add(element, (target)=>({
|
|
52
|
+
kind: 'type',
|
|
53
|
+
target,
|
|
54
|
+
value: secret ? options.secretValue ?? '' : element.value
|
|
55
|
+
}));
|
|
56
|
+
};
|
|
57
|
+
const onInput = (event)=>{
|
|
58
|
+
const { target } = event;
|
|
59
|
+
const text = target instanceof HTMLTextAreaElement || target instanceof HTMLInputElement && !NON_TEXT.has(target.type);
|
|
60
|
+
if (!text) return;
|
|
61
|
+
if (pending !== null && pending.element !== target) flush();
|
|
62
|
+
if (pending !== null) clearTimeout(pending.timer);
|
|
63
|
+
pending = {
|
|
64
|
+
element: target,
|
|
65
|
+
timer: setTimeout(flush, debounceMs)
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
const onChange = (event)=>{
|
|
69
|
+
const { target } = event;
|
|
70
|
+
flush();
|
|
71
|
+
if (target instanceof HTMLSelectElement) {
|
|
72
|
+
const option = target.selectedOptions[0];
|
|
73
|
+
const label = option?.textContent?.trim() ?? '';
|
|
74
|
+
if (option === undefined) return;
|
|
75
|
+
if (label === '') return;
|
|
76
|
+
add(target, (id)=>({
|
|
77
|
+
kind: 'select',
|
|
78
|
+
target: id,
|
|
79
|
+
value: label,
|
|
80
|
+
optionValue: option.value
|
|
81
|
+
}));
|
|
82
|
+
} else if (target instanceof HTMLInputElement && (target.type === 'checkbox' || target.type === 'radio')) {
|
|
83
|
+
add(target, (id)=>({
|
|
84
|
+
kind: 'check',
|
|
85
|
+
target: id,
|
|
86
|
+
checked: target.checked
|
|
87
|
+
}));
|
|
88
|
+
} else if (target instanceof HTMLInputElement && target.type === 'file') {
|
|
89
|
+
const files = Array.from(target.files ?? []).slice(0, 10).map(({ name, type })=>({
|
|
90
|
+
name,
|
|
91
|
+
type
|
|
92
|
+
}));
|
|
93
|
+
if (files.length > 0) add(target, (id)=>({
|
|
94
|
+
kind: 'file',
|
|
95
|
+
target: id,
|
|
96
|
+
files
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const onClick = (event)=>{
|
|
101
|
+
flush();
|
|
102
|
+
const element = clickTarget(event.target, attribute);
|
|
103
|
+
if (element !== null) add(element, (id)=>({
|
|
104
|
+
kind: 'click',
|
|
105
|
+
target: id
|
|
106
|
+
}));
|
|
107
|
+
};
|
|
108
|
+
const onKey = (event)=>{
|
|
109
|
+
if (!(event instanceof KeyboardEvent) || !KEYS.has(event.key) || !(event.target instanceof Element)) return;
|
|
110
|
+
const { target } = event;
|
|
111
|
+
// Enter on a button or link is already its click; Enter inside a textarea is a line break.
|
|
112
|
+
if (event.key === 'Enter' && target.closest('button, a[href], summary, textarea')) return;
|
|
113
|
+
flush();
|
|
114
|
+
add(target, (id)=>({
|
|
115
|
+
kind: 'key',
|
|
116
|
+
target: id,
|
|
117
|
+
key: event.key
|
|
118
|
+
}));
|
|
119
|
+
};
|
|
120
|
+
const listeners = [
|
|
121
|
+
[
|
|
122
|
+
'input',
|
|
123
|
+
onInput
|
|
124
|
+
],
|
|
125
|
+
[
|
|
126
|
+
'change',
|
|
127
|
+
onChange
|
|
128
|
+
],
|
|
129
|
+
[
|
|
130
|
+
'click',
|
|
131
|
+
onClick
|
|
132
|
+
],
|
|
133
|
+
[
|
|
134
|
+
'keydown',
|
|
135
|
+
onKey
|
|
136
|
+
]
|
|
137
|
+
];
|
|
138
|
+
return {
|
|
139
|
+
start: ()=>listeners.forEach(([type, handler])=>root.addEventListener(type, handler, true)),
|
|
140
|
+
stop: ()=>{
|
|
141
|
+
listeners.forEach(([type, handler])=>root.removeEventListener(type, handler, true));
|
|
142
|
+
flush();
|
|
143
|
+
},
|
|
144
|
+
beginStep: (next)=>{
|
|
145
|
+
flush();
|
|
146
|
+
current = null;
|
|
147
|
+
if (next !== undefined) chapter = next;
|
|
148
|
+
},
|
|
149
|
+
steps: ()=>list,
|
|
150
|
+
unanchored: log.report
|
|
151
|
+
};
|
|
152
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nucleus-core-ts",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.239",
|
|
4
4
|
"description": "Production-ready, enterprise-grade TypeScript framework for building multi-tenant APIs",
|
|
5
5
|
"author": "Hidayet Can Özcan <hidayetcan@gmail.com>",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -47,6 +47,10 @@
|
|
|
47
47
|
"types": "./dist/fe/index.d.ts",
|
|
48
48
|
"import": "./dist/fe/index.js"
|
|
49
49
|
},
|
|
50
|
+
"./fe/replay": {
|
|
51
|
+
"types": "./dist/fe/components/Replay/index.d.ts",
|
|
52
|
+
"import": "./dist/fe/components/Replay/index.js"
|
|
53
|
+
},
|
|
50
54
|
"./fe/auth": {
|
|
51
55
|
"types": "./dist/fe/components/AuthGuard/index.d.ts",
|
|
52
56
|
"import": "./dist/fe/components/AuthGuard/index.js"
|