@aiao/rxdb-angular 0.0.7 → 0.0.8
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/fesm2022/aiao-rxdb-angular.mjs +423 -0
- package/fesm2022/aiao-rxdb-angular.mjs.map +1 -0
- package/package.json +26 -13
- package/types/aiao-rxdb-angular.d.ts +222 -0
- package/eslint.config.mjs +0 -58
- package/ng-package.json +0 -7
- package/project.json +0 -48
- package/src/InfiniteScrollingList.ts +0 -123
- package/src/devtools/devtools.html +0 -99
- package/src/devtools/devtools.interface.ts +0 -3
- package/src/devtools/devtools.scss +0 -49
- package/src/devtools/devtools.spec.ts +0 -30
- package/src/devtools/devtools.ts +0 -207
- package/src/devtools/entity-table-item.ts +0 -47
- package/src/devtools/entity-table-tools.html +0 -56
- package/src/devtools/entity-table-tools.scss +0 -8
- package/src/devtools/entity-table-tools.ts +0 -153
- package/src/devtools/event-tools.html +0 -15
- package/src/devtools/event-tools.scss +0 -18
- package/src/devtools/event-tools.ts +0 -45
- package/src/devtools/scroll-advanced-calc.service.ts +0 -41
- package/src/devtools/settings.html +0 -46
- package/src/devtools/settings.scss +0 -19
- package/src/devtools/settings.ts +0 -122
- package/src/hooks.ts +0 -307
- package/src/index.ts +0 -7
- package/src/rxdb-change-detector.directive.spec.ts +0 -94
- package/src/rxdb-change-detector.directive.ts +0 -35
- package/src/rxdb.provider.ts +0 -13
- package/src/rxdb.service.spec.ts +0 -31
- package/src/rxdb.service.ts +0 -35
- package/src/test-setup.ts +0 -14
- package/src/use-action.spec.ts +0 -88
- package/src/use-action.ts +0 -20
- package/src/use-state.spec.ts +0 -105
- package/src/use-state.ts +0 -28
- package/tsconfig.json +0 -33
- package/tsconfig.lib.json +0 -42
- package/tsconfig.lib.prod.json +0 -10
- package/tsconfig.spec.json +0 -23
- package/vite.config.mts +0 -55
package/src/devtools/devtools.ts
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import { RxDB, RxDBBranch } from '@aiao/rxdb';
|
|
2
|
-
import {
|
|
3
|
-
ChangeDetectionStrategy,
|
|
4
|
-
Component,
|
|
5
|
-
ComponentRef,
|
|
6
|
-
DOCUMENT,
|
|
7
|
-
effect,
|
|
8
|
-
ElementRef,
|
|
9
|
-
inject,
|
|
10
|
-
input,
|
|
11
|
-
model,
|
|
12
|
-
signal
|
|
13
|
-
} from '@angular/core';
|
|
14
|
-
import { FormsModule } from '@angular/forms';
|
|
15
|
-
import { LucideAngularModule, PanelBottom, PanelLeft, PanelRight, Settings, X } from 'lucide-angular';
|
|
16
|
-
import { useFindAll } from '../hooks';
|
|
17
|
-
import { useState } from '../use-state';
|
|
18
|
-
import { RxDBEntityTableTools } from './entity-table-tools';
|
|
19
|
-
import { RxDBEventTools } from './event-tools';
|
|
20
|
-
import { RxDBSettings } from './settings';
|
|
21
|
-
|
|
22
|
-
interface FeatureTab {
|
|
23
|
-
id: string;
|
|
24
|
-
name: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const defaultSize = '480px';
|
|
28
|
-
const state = useState('rxdb-devtools');
|
|
29
|
-
|
|
30
|
-
@Component({
|
|
31
|
-
selector: 'rxdb-devtools',
|
|
32
|
-
imports: [LucideAngularModule, RxDBEntityTableTools, RxDBEventTools, RxDBSettings, FormsModule],
|
|
33
|
-
styleUrls: ['./devtools.scss'],
|
|
34
|
-
templateUrl: './devtools.html',
|
|
35
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
36
|
-
host: {
|
|
37
|
-
'[class.right]': "$side() === 'right'",
|
|
38
|
-
'[class.left]': "$side() === 'left'",
|
|
39
|
-
'[class.bottom]': "$side() === 'bottom'",
|
|
40
|
-
'[style.width]': '$width()',
|
|
41
|
-
'[style.height]': '$height()'
|
|
42
|
-
}
|
|
43
|
-
})
|
|
44
|
-
export class RxDBDevtools {
|
|
45
|
-
#last_tab_before_setting = '';
|
|
46
|
-
#document = inject(DOCUMENT);
|
|
47
|
-
#elementRef = inject<ElementRef<HTMLElement>>(ElementRef);
|
|
48
|
-
#rxdb = inject(RxDB);
|
|
49
|
-
|
|
50
|
-
protected readonly X = X;
|
|
51
|
-
protected readonly Settings = Settings;
|
|
52
|
-
protected readonly PanelLeft = PanelLeft;
|
|
53
|
-
protected readonly PanelBottom = PanelBottom;
|
|
54
|
-
protected readonly PanelRight = PanelRight;
|
|
55
|
-
|
|
56
|
-
public readonly componentRef = input<ComponentRef<RxDBDevtools>>();
|
|
57
|
-
theme = input<'light' | 'dark'>('light');
|
|
58
|
-
|
|
59
|
-
$side = state('side').signal<'right' | 'left' | 'bottom'>('right');
|
|
60
|
-
$width = state('width').signal<string>(defaultSize);
|
|
61
|
-
$height = state('height').signal<string>('100%');
|
|
62
|
-
$switch_branching = model<boolean>(false);
|
|
63
|
-
|
|
64
|
-
$branchName = model<string>('');
|
|
65
|
-
|
|
66
|
-
$tabs = signal<FeatureTab[]>([
|
|
67
|
-
{
|
|
68
|
-
id: 'tables',
|
|
69
|
-
name: 'Tables'
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
id: 'events',
|
|
73
|
-
name: 'Events'
|
|
74
|
-
}
|
|
75
|
-
]);
|
|
76
|
-
$current_tab = signal<string>('tables');
|
|
77
|
-
|
|
78
|
-
branches = useFindAll(RxDBBranch, {
|
|
79
|
-
where: {
|
|
80
|
-
combinator: 'and',
|
|
81
|
-
rules: []
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
constructor() {
|
|
86
|
-
effect(() => {
|
|
87
|
-
const side = this.$side();
|
|
88
|
-
switch (side) {
|
|
89
|
-
case 'left':
|
|
90
|
-
case 'right':
|
|
91
|
-
if (this.$height() !== '100%') {
|
|
92
|
-
this.$width.set(defaultSize);
|
|
93
|
-
this.$height.set('100%');
|
|
94
|
-
}
|
|
95
|
-
break;
|
|
96
|
-
case 'bottom':
|
|
97
|
-
if (this.$width() !== '100%') {
|
|
98
|
-
this.$width.set('100%');
|
|
99
|
-
this.$height.set(defaultSize);
|
|
100
|
-
}
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
effect(() => {
|
|
105
|
-
const side = this.$side();
|
|
106
|
-
const width = this.$width();
|
|
107
|
-
const height = this.$height();
|
|
108
|
-
this.#body_style_default();
|
|
109
|
-
switch (side) {
|
|
110
|
-
case 'left':
|
|
111
|
-
this.#document.body.style.paddingLeft = width;
|
|
112
|
-
break;
|
|
113
|
-
case 'right':
|
|
114
|
-
this.#document.body.style.paddingRight = width;
|
|
115
|
-
break;
|
|
116
|
-
case 'bottom':
|
|
117
|
-
this.#document.body.style.paddingBottom = height;
|
|
118
|
-
break;
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
close_rxdb_devtools() {
|
|
124
|
-
this.#body_style_default();
|
|
125
|
-
this.componentRef()?.destroy();
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
toggle_settings() {
|
|
129
|
-
const current_tab = this.$current_tab();
|
|
130
|
-
if (current_tab !== 'settings') {
|
|
131
|
-
this.#last_tab_before_setting = current_tab;
|
|
132
|
-
this.$current_tab.set('settings');
|
|
133
|
-
} else {
|
|
134
|
-
this.$current_tab.set(this.#last_tab_before_setting || 'tables');
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
async create_branch(branch_name: string) {
|
|
139
|
-
try {
|
|
140
|
-
await this.#rxdb.versionManager.createBranch(branch_name);
|
|
141
|
-
this.$branchName.set('');
|
|
142
|
-
} catch {
|
|
143
|
-
//
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
mousedown(event: MouseEvent) {
|
|
148
|
-
const side = this.$side();
|
|
149
|
-
this.#document.body.style.cursor = side === 'bottom' ? 'ns-resize' : 'ew-resize';
|
|
150
|
-
|
|
151
|
-
const pageX = event.pageX;
|
|
152
|
-
const pageY = event.pageY;
|
|
153
|
-
const clientWidth = this.#elementRef.nativeElement.clientWidth;
|
|
154
|
-
const clientHeight = this.#elementRef.nativeElement.clientHeight;
|
|
155
|
-
const mousemove = (event: MouseEvent) => {
|
|
156
|
-
switch (side) {
|
|
157
|
-
case 'left':
|
|
158
|
-
{
|
|
159
|
-
let width = clientWidth + event.pageX - pageX;
|
|
160
|
-
width = width < 100 ? 100 : width;
|
|
161
|
-
this.$width.set(`${width}px`);
|
|
162
|
-
}
|
|
163
|
-
break;
|
|
164
|
-
case 'right':
|
|
165
|
-
{
|
|
166
|
-
let width = clientWidth + pageX - event.pageX;
|
|
167
|
-
width = width < 100 ? 100 : width;
|
|
168
|
-
this.$width.set(`${width}px`);
|
|
169
|
-
}
|
|
170
|
-
break;
|
|
171
|
-
case 'bottom':
|
|
172
|
-
{
|
|
173
|
-
let height = clientHeight + pageY - event.pageY;
|
|
174
|
-
height = height < 100 ? 100 : height;
|
|
175
|
-
this.$height.set(`${height}px`);
|
|
176
|
-
}
|
|
177
|
-
break;
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
const mouseup = () => {
|
|
181
|
-
this.#document.body.style.cursor = 'auto';
|
|
182
|
-
this.#document.removeEventListener('mousemove', mousemove);
|
|
183
|
-
this.#document.removeEventListener('mouseup', mouseup);
|
|
184
|
-
};
|
|
185
|
-
this.#document.addEventListener('mousemove', mousemove);
|
|
186
|
-
this.#document.addEventListener('mouseup', mouseup);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
protected async switch_branch(event: Event) {
|
|
190
|
-
const branch = (event.target as HTMLSelectElement).value;
|
|
191
|
-
this.$switch_branching.set(true);
|
|
192
|
-
try {
|
|
193
|
-
await this.#rxdb.versionManager.switchBranch(branch);
|
|
194
|
-
} catch (error) {
|
|
195
|
-
console.error(error);
|
|
196
|
-
} finally {
|
|
197
|
-
this.$switch_branching.set(false);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
#body_style_default() {
|
|
202
|
-
this.#document.body.style.paddingBottom = '';
|
|
203
|
-
this.#document.body.style.paddingRight = '';
|
|
204
|
-
this.#document.body.style.paddingLeft = '';
|
|
205
|
-
this.#document.body.style.cursor = '';
|
|
206
|
-
}
|
|
207
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { JsonPipe } from '@angular/common';
|
|
2
|
-
import { afterNextRender, Component, ElementRef, inject, input } from '@angular/core';
|
|
3
|
-
import { RxDBEntityChangeDirective } from '../rxdb-change-detector.directive';
|
|
4
|
-
import { ScrollAdvancedCalcService } from './scroll-advanced-calc.service';
|
|
5
|
-
|
|
6
|
-
@Component({
|
|
7
|
-
selector: 'rxdb-entity-item',
|
|
8
|
-
template: `
|
|
9
|
-
@let item = entity();
|
|
10
|
-
@let i = index();
|
|
11
|
-
|
|
12
|
-
<pre class="text-xs" [class.bg-base-100]="i % 2 === 0" [rxdbChangeDetector]="item">
|
|
13
|
-
{{ item | json }}
|
|
14
|
-
</pre
|
|
15
|
-
>
|
|
16
|
-
`,
|
|
17
|
-
imports: [JsonPipe, RxDBEntityChangeDirective],
|
|
18
|
-
styles: [
|
|
19
|
-
`
|
|
20
|
-
:host {
|
|
21
|
-
display: block;
|
|
22
|
-
min-height: 150px;
|
|
23
|
-
}
|
|
24
|
-
`
|
|
25
|
-
]
|
|
26
|
-
})
|
|
27
|
-
export class RxDBEntityTableItem {
|
|
28
|
-
readonly #calcService = inject(ScrollAdvancedCalcService);
|
|
29
|
-
readonly #el = inject(ElementRef);
|
|
30
|
-
readonly entity = input.required<any>();
|
|
31
|
-
readonly index = input.required<number>();
|
|
32
|
-
|
|
33
|
-
constructor() {
|
|
34
|
-
afterNextRender(() => {
|
|
35
|
-
const item = this.entity();
|
|
36
|
-
this.#calcService.cacheCalcDynamic.update(cache => {
|
|
37
|
-
if (!cache.some(c => c.trackId === item.id)) {
|
|
38
|
-
cache.push({
|
|
39
|
-
trackId: item.id,
|
|
40
|
-
itemSize: this.#el.nativeElement.getBoundingClientRect().height
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
return cache;
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
@let entity_meta_tree = $entity_meta_tree();
|
|
2
|
-
@let current_entity_meta = $current_entity_meta();
|
|
3
|
-
|
|
4
|
-
<div class="bg-base-200 overflow-y-auto">
|
|
5
|
-
<ul class="menu menu-xs rounded-box w-30 p-0">
|
|
6
|
-
@for (ns of entity_meta_tree; track $index) {
|
|
7
|
-
<li>
|
|
8
|
-
<details open>
|
|
9
|
-
<summary>{{ ns.namespace }}</summary>
|
|
10
|
-
<ul>
|
|
11
|
-
@for (entity of ns.entities; track entity.name) {
|
|
12
|
-
<li>
|
|
13
|
-
<a
|
|
14
|
-
[class.menu-active]="current_entity_meta === entity"
|
|
15
|
-
(click)="$current_entity_meta.set(entity)"
|
|
16
|
-
aria-hidden="true"
|
|
17
|
-
>
|
|
18
|
-
{{ entity.name }}
|
|
19
|
-
</a>
|
|
20
|
-
</li>
|
|
21
|
-
}
|
|
22
|
-
</ul>
|
|
23
|
-
</details>
|
|
24
|
-
</li>
|
|
25
|
-
}
|
|
26
|
-
</ul>
|
|
27
|
-
</div>
|
|
28
|
-
|
|
29
|
-
<div class="relative flex-1 overflow-hidden">
|
|
30
|
-
<div class="tabs tabs-border tabs-xs bg-base-300 h-full">
|
|
31
|
-
<input class="tab" aria-label="Data" checked="checked" name="my_tabs_2" type="radio" />
|
|
32
|
-
<div class="tab-content h-full overflow-hidden">
|
|
33
|
-
<cdk-virtual-scroll-viewport
|
|
34
|
-
class="tab-content h-full"
|
|
35
|
-
[itemDynamicSizes]="dynamicSize()"
|
|
36
|
-
maxBufferPx="1350"
|
|
37
|
-
minBufferPx="900"
|
|
38
|
-
rdlaboFixVirtualScrollElement
|
|
39
|
-
>
|
|
40
|
-
@defer (on viewport) {
|
|
41
|
-
<ng-container *cdkVirtualFor="let item of $entity_all_data(); let i = index; trackBy: trackByFn">
|
|
42
|
-
<rxdb-entity-item [entity]="item" [index]="i"></rxdb-entity-item>
|
|
43
|
-
</ng-container>
|
|
44
|
-
} @placeholder {
|
|
45
|
-
<div class="h-40"></div>
|
|
46
|
-
}
|
|
47
|
-
</cdk-virtual-scroll-viewport>
|
|
48
|
-
</div>
|
|
49
|
-
<input class="tab" aria-label="Metadata" name="my_tabs_2" type="radio" />
|
|
50
|
-
<div class="tab-content h-full overflow-y-auto">
|
|
51
|
-
@if (current_entity_meta) {
|
|
52
|
-
<ao-code-editor [theme]="theme()" [value]="current_entity_meta | json" language="json"></ao-code-editor>
|
|
53
|
-
}
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
</div>
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { CodeEditor } from '@aiao/code-editor-angular';
|
|
2
|
-
import { EntityMetadata, EntityType, getEntityMetadata, RxDB } from '@aiao/rxdb';
|
|
3
|
-
import { nextMacroTask } from '@aiao/utils';
|
|
4
|
-
import { ObserversModule } from '@angular/cdk/observers';
|
|
5
|
-
import { CdkVirtualForOf, CdkVirtualScrollViewport } from '@angular/cdk/scrolling';
|
|
6
|
-
import { CommonModule } from '@angular/common';
|
|
7
|
-
import {
|
|
8
|
-
ChangeDetectionStrategy,
|
|
9
|
-
ChangeDetectorRef,
|
|
10
|
-
Component,
|
|
11
|
-
computed,
|
|
12
|
-
effect,
|
|
13
|
-
inject,
|
|
14
|
-
input,
|
|
15
|
-
OnInit,
|
|
16
|
-
signal,
|
|
17
|
-
viewChild
|
|
18
|
-
} from '@angular/core';
|
|
19
|
-
import { toObservable, toSignal } from '@angular/core/rxjs-interop';
|
|
20
|
-
import {
|
|
21
|
-
CdkDynamicSizeVirtualScroll,
|
|
22
|
-
DynamicSizeVirtualScrollService,
|
|
23
|
-
itemDynamicSize
|
|
24
|
-
} from '@rdlabo/ngx-cdk-scroll-strategies';
|
|
25
|
-
import { LucideAngularModule } from 'lucide-angular';
|
|
26
|
-
import { of, switchMap } from 'rxjs';
|
|
27
|
-
import { RxDBEntityTableItem } from './entity-table-item';
|
|
28
|
-
import { ScrollAdvancedCalcService } from './scroll-advanced-calc.service';
|
|
29
|
-
|
|
30
|
-
interface EntityTreeItem {
|
|
31
|
-
namespace: string;
|
|
32
|
-
entities: EntityMetadata[];
|
|
33
|
-
}
|
|
34
|
-
(BigInt.prototype as any)['toJSON'] = function () {
|
|
35
|
-
return Number(this);
|
|
36
|
-
};
|
|
37
|
-
@Component({
|
|
38
|
-
selector: 'rxdb-entity-table-tools',
|
|
39
|
-
imports: [
|
|
40
|
-
LucideAngularModule,
|
|
41
|
-
CommonModule,
|
|
42
|
-
RxDBEntityTableItem,
|
|
43
|
-
CodeEditor,
|
|
44
|
-
ObserversModule,
|
|
45
|
-
CdkVirtualForOf,
|
|
46
|
-
CdkVirtualScrollViewport,
|
|
47
|
-
CdkDynamicSizeVirtualScroll
|
|
48
|
-
],
|
|
49
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
50
|
-
styleUrls: ['./entity-table-tools.scss'],
|
|
51
|
-
templateUrl: './entity-table-tools.html'
|
|
52
|
-
})
|
|
53
|
-
export class RxDBEntityTableTools implements OnInit {
|
|
54
|
-
#rxdb = inject(RxDB);
|
|
55
|
-
#entity_metadata_map = new Map<EntityMetadata, EntityType>();
|
|
56
|
-
#scroll = inject(DynamicSizeVirtualScrollService);
|
|
57
|
-
#calcService = inject(ScrollAdvancedCalcService);
|
|
58
|
-
#latestScrollOffset = 0;
|
|
59
|
-
|
|
60
|
-
virtualScroll = viewChild(CdkVirtualScrollViewport);
|
|
61
|
-
|
|
62
|
-
dynamicSize = computed<itemDynamicSize[]>(() => {
|
|
63
|
-
const size = this.#calcService.changeItemsToDynamicItemSize(
|
|
64
|
-
this.$entity_all_data() as any,
|
|
65
|
-
this.#calcService.cacheCalcDynamic(),
|
|
66
|
-
this.virtualScroll()
|
|
67
|
-
);
|
|
68
|
-
return size;
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
cdr = inject(ChangeDetectorRef);
|
|
72
|
-
theme = input<'light' | 'dark'>('light');
|
|
73
|
-
|
|
74
|
-
$entity_meta_tree = signal<EntityTreeItem[]>([]);
|
|
75
|
-
$current_entity_meta = signal<EntityMetadata | null>(null);
|
|
76
|
-
|
|
77
|
-
current_entity_meta$ = toObservable(this.$current_entity_meta);
|
|
78
|
-
|
|
79
|
-
entity_all_data$ = this.current_entity_meta$.pipe(
|
|
80
|
-
switchMap(meta => {
|
|
81
|
-
if (meta) {
|
|
82
|
-
const entity = this.#entity_metadata_map.get(meta)!;
|
|
83
|
-
return this.#rxdb.entityManager.getRepository(entity).findAll({
|
|
84
|
-
where: {
|
|
85
|
-
combinator: 'and',
|
|
86
|
-
rules: []
|
|
87
|
-
},
|
|
88
|
-
orderBy: [
|
|
89
|
-
{
|
|
90
|
-
field: 'id',
|
|
91
|
-
sort: 'desc'
|
|
92
|
-
}
|
|
93
|
-
]
|
|
94
|
-
});
|
|
95
|
-
} else {
|
|
96
|
-
return of([]);
|
|
97
|
-
}
|
|
98
|
-
})
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
$entity_all_data = toSignal(this.entity_all_data$);
|
|
102
|
-
constructor() {
|
|
103
|
-
effect(() => {
|
|
104
|
-
this.$current_entity_meta();
|
|
105
|
-
nextMacroTask(() => {
|
|
106
|
-
this.#calcService.beforeCacheCalcDynamicSize.set(0);
|
|
107
|
-
this.#calcService.cacheCalcDynamic.set([]);
|
|
108
|
-
this.virtualScroll()?.scrollTo({
|
|
109
|
-
top: 0
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
trackByFn = (_: number, item: any) => {
|
|
115
|
-
let track_id = item.id;
|
|
116
|
-
if (item.updatedAt) {
|
|
117
|
-
track_id += (item.updatedAt as Date).getTime();
|
|
118
|
-
}
|
|
119
|
-
return track_id;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
ngOnInit(): void {
|
|
123
|
-
this.#scroll.onInit(this.virtualScroll()!, this.#latestScrollOffset);
|
|
124
|
-
this.virtualScroll()?.scrolledIndexChange.subscribe(() => {
|
|
125
|
-
if (this.#calcService.beforeCacheCalcDynamicSize() !== this.#calcService.cacheCalcDynamic().length) {
|
|
126
|
-
this.#calcService.cacheCalcDynamic.update(cache => [...cache]);
|
|
127
|
-
this.#calcService.beforeCacheCalcDynamicSize.set(this.#calcService.cacheCalcDynamic().length);
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
const entity_meta_tree: EntityTreeItem[] = [];
|
|
132
|
-
let rxdb_change_meta: any;
|
|
133
|
-
this.#rxdb.config.entities.forEach(entity => {
|
|
134
|
-
const meta = getEntityMetadata(entity);
|
|
135
|
-
this.#entity_metadata_map.set(meta, entity);
|
|
136
|
-
if (meta.name === 'RxDBChange') {
|
|
137
|
-
rxdb_change_meta = meta;
|
|
138
|
-
}
|
|
139
|
-
const namespace = meta.namespace;
|
|
140
|
-
const existing = entity_meta_tree.find(item => item.namespace === namespace);
|
|
141
|
-
if (existing) {
|
|
142
|
-
existing.entities.push(meta);
|
|
143
|
-
} else {
|
|
144
|
-
entity_meta_tree.push({
|
|
145
|
-
namespace,
|
|
146
|
-
entities: [meta]
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
this.$entity_meta_tree.set(entity_meta_tree);
|
|
151
|
-
this.$current_entity_meta.set(rxdb_change_meta);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
@let events = $events();
|
|
2
|
-
|
|
3
|
-
<div class="bg-base-300 w-full text-xs">
|
|
4
|
-
<button class="btn btn-xs" (click)="clear()">clear</button>
|
|
5
|
-
<span>{{ events.length }}</span>
|
|
6
|
-
</div>
|
|
7
|
-
<div class="bg-base-300 relative flex-1 overflow-y-auto">
|
|
8
|
-
@for (item of events; track item) {
|
|
9
|
-
@defer (on viewport) {
|
|
10
|
-
<pre class="text-xs" [class.bg-base-100]="$index % 2 === 0" animate.enter="fade-in">{{ item | json }}</pre>
|
|
11
|
-
} @placeholder {
|
|
12
|
-
<div class="h-40">loading...</div>
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
</div>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
:host {
|
|
2
|
-
@apply flex h-full w-full flex-col overflow-hidden;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.fade-in {
|
|
6
|
-
animation: fadeIn 0.3s ease-out;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
@keyframes fadeIn {
|
|
10
|
-
from {
|
|
11
|
-
opacity: 0;
|
|
12
|
-
transform: translateX(100px);
|
|
13
|
-
}
|
|
14
|
-
to {
|
|
15
|
-
opacity: 1;
|
|
16
|
-
transform: translateX(0);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ENTITY_LOCAL_CREATE_EVENT,
|
|
3
|
-
ENTITY_LOCAL_NEW_EVENT,
|
|
4
|
-
ENTITY_LOCAL_REMOVE_EVENT,
|
|
5
|
-
ENTITY_LOCAL_UPDATE_EVENT,
|
|
6
|
-
RxDB,
|
|
7
|
-
RxDBEvent,
|
|
8
|
-
TRANSACTION_BEGIN,
|
|
9
|
-
TRANSACTION_COMMIT,
|
|
10
|
-
TRANSACTION_ROLLBACK
|
|
11
|
-
} from '@aiao/rxdb';
|
|
12
|
-
import { JsonPipe } from '@angular/common';
|
|
13
|
-
import { ChangeDetectionStrategy, Component, inject, OnInit, signal } from '@angular/core';
|
|
14
|
-
import { LucideAngularModule } from 'lucide-angular';
|
|
15
|
-
|
|
16
|
-
@Component({
|
|
17
|
-
selector: 'rxdb-event-tools',
|
|
18
|
-
imports: [LucideAngularModule, JsonPipe],
|
|
19
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
20
|
-
styleUrls: ['./event-tools.scss'],
|
|
21
|
-
templateUrl: './event-tools.html'
|
|
22
|
-
})
|
|
23
|
-
export class RxDBEventTools implements OnInit {
|
|
24
|
-
#rxdb = inject(RxDB);
|
|
25
|
-
|
|
26
|
-
$events = signal<RxDBEvent[]>([]);
|
|
27
|
-
|
|
28
|
-
ngOnInit(): void {
|
|
29
|
-
this.#rxdb.addEventListener(ENTITY_LOCAL_NEW_EVENT, this.handler);
|
|
30
|
-
this.#rxdb.addEventListener(ENTITY_LOCAL_CREATE_EVENT, this.handler);
|
|
31
|
-
this.#rxdb.addEventListener(ENTITY_LOCAL_UPDATE_EVENT, this.handler);
|
|
32
|
-
this.#rxdb.addEventListener(ENTITY_LOCAL_REMOVE_EVENT, this.handler);
|
|
33
|
-
this.#rxdb.addEventListener(TRANSACTION_BEGIN, this.handler);
|
|
34
|
-
this.#rxdb.addEventListener(TRANSACTION_COMMIT, this.handler);
|
|
35
|
-
this.#rxdb.addEventListener(TRANSACTION_ROLLBACK, this.handler);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
handler = (event: RxDBEvent) => {
|
|
39
|
-
this.$events.update(events => [event, ...events]);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
clear() {
|
|
43
|
-
this.$events.set([]);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { CdkVirtualScrollViewport } from '@angular/cdk/scrolling';
|
|
2
|
-
import { Injectable, signal } from '@angular/core';
|
|
3
|
-
import { itemDynamicSize } from '@rdlabo/ngx-cdk-scroll-strategies';
|
|
4
|
-
|
|
5
|
-
export interface ScrollAdvancedItem {
|
|
6
|
-
id: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface DynamicSizeCache {
|
|
10
|
-
trackId: number | string;
|
|
11
|
-
itemSize: number;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
@Injectable({
|
|
15
|
-
providedIn: 'root'
|
|
16
|
-
})
|
|
17
|
-
export class ScrollAdvancedCalcService {
|
|
18
|
-
readonly cacheCalcDynamic = signal<DynamicSizeCache[]>([]);
|
|
19
|
-
readonly beforeCacheCalcDynamicSize = signal<number>(0);
|
|
20
|
-
|
|
21
|
-
changeItemsToDynamicItemSize(
|
|
22
|
-
items: ScrollAdvancedItem[],
|
|
23
|
-
dynamicSizeCache: DynamicSizeCache[],
|
|
24
|
-
virtualScroll: CdkVirtualScrollViewport | undefined
|
|
25
|
-
): itemDynamicSize[] {
|
|
26
|
-
if (virtualScroll === undefined) {
|
|
27
|
-
return [];
|
|
28
|
-
}
|
|
29
|
-
return (
|
|
30
|
-
items?.map(item => {
|
|
31
|
-
const cacheSize = dynamicSizeCache.find(cache => cache.trackId === item.id)?.itemSize;
|
|
32
|
-
const itemSize = cacheSize || 150;
|
|
33
|
-
return {
|
|
34
|
-
itemSize: Math.ceil(itemSize),
|
|
35
|
-
trackId: item.id,
|
|
36
|
-
source: cacheSize !== undefined ? 'cache' : 'temporary'
|
|
37
|
-
};
|
|
38
|
-
}) || []
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
<div class="p-2">
|
|
2
|
-
<fieldset class="fieldset">
|
|
3
|
-
<legend class="fieldset-legend">Side</legend>
|
|
4
|
-
<div class="join" id="side">
|
|
5
|
-
<button
|
|
6
|
-
class="btn join-item btn-xs btn-ghost"
|
|
7
|
-
id="panel-left"
|
|
8
|
-
(click)="sideChange.emit('left')"
|
|
9
|
-
aria-hidden="true"
|
|
10
|
-
>
|
|
11
|
-
<lucide-icon [img]="PanelLeft" size="16"></lucide-icon>
|
|
12
|
-
</button>
|
|
13
|
-
<button
|
|
14
|
-
class="btn join-item btn-xs btn-ghost"
|
|
15
|
-
id="panel-bottom"
|
|
16
|
-
(click)="sideChange.emit('bottom')"
|
|
17
|
-
aria-hidden="true"
|
|
18
|
-
>
|
|
19
|
-
<lucide-icon [img]="PanelBottom" size="16"></lucide-icon>
|
|
20
|
-
</button>
|
|
21
|
-
<button
|
|
22
|
-
class="btn join-item btn-xs btn-ghost"
|
|
23
|
-
id="panel-right"
|
|
24
|
-
(click)="sideChange.emit('right')"
|
|
25
|
-
aria-hidden="true"
|
|
26
|
-
>
|
|
27
|
-
<lucide-icon [img]="PanelRight" size="16"></lucide-icon>
|
|
28
|
-
</button>
|
|
29
|
-
</div>
|
|
30
|
-
</fieldset>
|
|
31
|
-
|
|
32
|
-
<fieldset class="fieldset">
|
|
33
|
-
<legend class="fieldset-legend">tools</legend>
|
|
34
|
-
<div class="flex gap-2 p-2">
|
|
35
|
-
<button class="btn btn-xs" (click)="delete_db()">delete_db</button>
|
|
36
|
-
</div>
|
|
37
|
-
</fieldset>
|
|
38
|
-
</div>
|
|
39
|
-
|
|
40
|
-
<ng-template #message let-message="message">
|
|
41
|
-
<div class="toast toast-top toast-center">
|
|
42
|
-
<div class="alert alert-error">
|
|
43
|
-
<span>{{ message }}</span>
|
|
44
|
-
</div>
|
|
45
|
-
</div>
|
|
46
|
-
</ng-template>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
:host {
|
|
2
|
-
@apply flex h-full w-full flex-col overflow-hidden;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
:has(rxdb-devtools.right) :host {
|
|
6
|
-
#panel-right {
|
|
7
|
-
color: var(--color-primary);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
:has(rxdb-devtools.left) :host {
|
|
11
|
-
#panel-left {
|
|
12
|
-
color: var(--color-primary);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
:has(rxdb-devtools.bottom) :host {
|
|
16
|
-
#panel-bottom {
|
|
17
|
-
color: var(--color-primary);
|
|
18
|
-
}
|
|
19
|
-
}
|