@ibgib/space-gib 0.0.9 → 0.0.13

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.
Files changed (82) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +1 -0
  3. package/dist/client/bootstrap.mjs +33 -33
  4. package/dist/client/bootstrap.mjs.map +3 -3
  5. package/dist/client/chunk-ROJZUPPE.mjs +19 -0
  6. package/dist/client/chunk-ROJZUPPE.mjs.map +7 -0
  7. package/dist/client/chunk-WJHRARK6.mjs +2329 -0
  8. package/dist/client/chunk-WJHRARK6.mjs.map +7 -0
  9. package/dist/client/index.mjs +22 -1
  10. package/dist/client/index.mjs.map +4 -4
  11. package/dist/client/script.mjs +1 -1
  12. package/dist/server/server.mjs +19147 -18210
  13. package/dist/server/server.mjs.map +4 -4
  14. package/package.json +4 -4
  15. package/space-gib.localhost-1785337158142.log +75 -0
  16. package/src/client/AUTO-GENERATED-version.mts +1 -1
  17. package/src/client/README.md +1 -1
  18. package/src/client/api/space-gib-api-bridge.mts +8 -224
  19. package/src/client/ui/shell/space-gib-shell-service.mts +68 -18
  20. package/src/common/keystone-policies.mts +1 -1
  21. package/src/server/README.md +3 -2
  22. package/src/server/server.mts +13 -32
  23. package/src/server/test.json +0 -0
  24. package/dist/client/chunk-ACIGPCQW.mjs +0 -2407
  25. package/dist/client/chunk-ACIGPCQW.mjs.map +0 -7
  26. package/dist/client/chunk-QRMTJE6M.mjs +0 -42
  27. package/dist/client/chunk-QRMTJE6M.mjs.map +0 -7
  28. package/space-gib.localhost-1783713259760.log +0 -45
  29. package/src/client/components/identity-header/IMPLEMENTATION.md +0 -45
  30. package/src/client/components/identity-header/identity-header.css +0 -112
  31. package/src/client/components/identity-header/identity-header.html +0 -11
  32. package/src/client/components/identity-header/identity-header.mts +0 -439
  33. package/src/client/components/identity-manager/IMPLEMENTATION.md +0 -100
  34. package/src/client/components/identity-manager/identity-manager.css +0 -171
  35. package/src/client/components/identity-manager/identity-manager.html +0 -19
  36. package/src/client/components/identity-manager/identity-manager.mts +0 -639
  37. package/src/client/components/keystone-creator/keystone-creator.css +0 -65
  38. package/src/client/components/keystone-creator/keystone-creator.html +0 -41
  39. package/src/client/components/keystone-creator/keystone-creator.mts +0 -443
  40. package/src/client/components/keystone-details/keystone-details.css +0 -611
  41. package/src/client/components/keystone-details/keystone-details.html +0 -151
  42. package/src/client/components/keystone-details/keystone-details.mts +0 -1213
  43. package/src/client/components/keystone-scrubber/SCRUBBER_IMPLEMENTATION.md +0 -33
  44. package/src/client/components/keystone-scrubber/keystone-scrubber.css +0 -46
  45. package/src/client/components/keystone-scrubber/keystone-scrubber.html +0 -15
  46. package/src/client/components/keystone-scrubber/keystone-scrubber.mts +0 -356
  47. package/src/server/bootstrap-helper.mts +0 -141
  48. package/src/server/bootstrap-helper.respec.mts +0 -100
  49. package/src/server/metaspace-nodeindexedspace/metaspace-nodeindexedspace.mts +0 -85
  50. package/src/server/path-constants.mts +0 -101
  51. package/src/server/path-helper.mts +0 -101
  52. package/src/server/path-helper.respec.mts +0 -99
  53. package/src/server/serve-gib/CHANGELOG.md +0 -29
  54. package/src/server/serve-gib/README.md +0 -43
  55. package/src/server/serve-gib/constants.mts +0 -1
  56. package/src/server/serve-gib/handlers/api/debug/ws-echo.handler.mts +0 -105
  57. package/src/server/serve-gib/handlers/api/health.handler.mts +0 -23
  58. package/src/server/serve-gib/handlers/api/health.respec.mts +0 -51
  59. package/src/server/serve-gib/handlers/api/ibgib/ibgib-handler-types.mts +0 -49
  60. package/src/server/serve-gib/handlers/api/ibgib/ibgib.handler.mts +0 -176
  61. package/src/server/serve-gib/handlers/api/keystone/keystone-evolve.handler.mts +0 -150
  62. package/src/server/serve-gib/handlers/api/keystone/keystone-genesis.handler.mts +0 -146
  63. package/src/server/serve-gib/handlers/api/keystone/keystone-get.handler.mts +0 -198
  64. package/src/server/serve-gib/handlers/api/keystone/keystone-get.respec.mts +0 -107
  65. package/src/server/serve-gib/handlers/api/keystone/keystone-handler-types.mts +0 -29
  66. package/src/server/serve-gib/handlers/api/keystone/keystone-post.handler.mts +0 -55
  67. package/src/server/serve-gib/handlers/api/keystone/keystone-post.respec.mts +0 -130
  68. package/src/server/serve-gib/handlers/api/keystone/sso-config.handler.mts +0 -66
  69. package/src/server/serve-gib/handlers/api/keystone/sso-link.handler.mts +0 -140
  70. package/src/server/serve-gib/handlers/api/keystone/sso-login.handler.mts +0 -190
  71. package/src/server/serve-gib/handlers/error-handler.mts +0 -36
  72. package/src/server/serve-gib/handlers/handler-base.mts +0 -383
  73. package/src/server/serve-gib/handlers/static-handler.mts +0 -82
  74. package/src/server/serve-gib/handlers/ws/sync-upgrade-handler-base.mts +0 -233
  75. package/src/server/serve-gib/handlers/ws/sync-upgrade.handler.mts +0 -24
  76. package/src/server/serve-gib/handlers/ws/ws-helper.mts +0 -216
  77. package/src/server/serve-gib/handlers/ws/ws-types.mts +0 -53
  78. package/src/server/serve-gib/serve-gib-helpers.mts +0 -32
  79. package/src/server/serve-gib/serve-gib-v1.mts +0 -172
  80. package/src/server/serve-gib/serve-gib.respec.mts +0 -90
  81. package/src/server/serve-gib/types.mts +0 -102
  82. package/src/server/server-constants.mts +0 -2
@@ -1,33 +0,0 @@
1
- # Keystone Scrubber Implementation Plan
2
-
3
- > [!WARNING]
4
- > Skip automated browser testing for these component changes. The user (Bill) will perform manual verification to avoid token usage from screenshots/images.
5
-
6
- ## Driving Problem
7
- In the previous monolithic parent/child component refactoring, the `<ibgib-keystone-details>` component was designed to handle *both* displaying metadata for a single keystone frame, and managing/scrubbing through the timeline history.
8
- Because it was a child component managed by the `<ibgib-identity-manager>` tab view, it was instantiated dynamically via `getComponentInstance()`. But since it was not yet injected into the DOM, its custom element `connectedCallback()` and `created()` methods had not run. Consequently, `loadIbGib()` was never triggered, leaving its `this.ibGib` property `undefined` at initialization time and throwing errors when the parent manager attempted to read its backing data.
9
-
10
- ## Solution: Separating Concerns with a Scrubber Parent Component
11
- To resolve this, we will introduce a new `<ibgib-keystone-scrubber>` component.
12
- * **`<ibgib-keystone-scrubber>` (Parent)**: Acts as the parent component for a keystone's timeline. It loads history, renders the scrubber navigation toolbar (scrub buttons and status), and acts as a `Parent` component that injects a details view child component for whichever frame address is selected.
13
- * **`<ibgib-keystone-details>` (Child)**: A simple, static child component that only renders the details of a *single* specific keystone address. It does not manage history or scrubber state. It overrides `initialize()` to call `loadIbGib()`, ensuring `this.ibGib` is populated immediately upon instantiation.
14
-
15
- ---
16
-
17
- ## Tasks Checklist
18
-
19
- - [ ] Register new component metadata
20
- - [ ] Register `KeystoneScrubberComponentMeta` in [space-gib-shell-service.mts](file:///c:/Users/billm/antigravity/ibgib/apps/space-gib/src/client/ui/shell/space-gib-shell-service.mts)
21
- - [ ] Create Scrubber component files
22
- - [ ] Create [keystone-scrubber.html](file:///c:/Users/billm/antigravity/ibgib/apps/space-gib/src/client/components/keystone-scrubber/keystone-scrubber.html) containing the scrubber header layout and a `#keystone-scrubber-content` slot
23
- - [ ] Create [keystone-scrubber.css](file:///c:/Users/billm/antigravity/ibgib/apps/space-gib/src/client/components/keystone-scrubber/keystone-scrubber.css) for scrubber-specific bar and button stylings
24
- - [ ] Create [keystone-scrubber.mts](file:///c:/Users/billm/antigravity/ibgib/apps/space-gib/src/client/components/keystone-scrubber/keystone-scrubber.mts) extending `IbGibDynamicComponentInstanceBase_Parent` to manage the history array and child detail views
25
- - [ ] Refactor details component to be static
26
- - [ ] Simplify [keystone-details.html](file:///c:/Users/billm/antigravity/ibgib/apps/space-gib/src/client/components/keystone-details/keystone-details.html) to remove all scrubber header elements
27
- - [ ] Simplify [keystone-details.css](file:///c:/Users/billm/antigravity/ibgib/apps/space-gib/src/client/components/keystone-details/keystone-details.css) to remove scrubber styles
28
- - [ ] Modify [keystone-details.mts](file:///c:/Users/billm/antigravity/ibgib/apps/space-gib/src/client/components/keystone-details/keystone-details.mts) to extend standard `IbGibDynamicComponentInstanceBase`, load `loadIbGib()` inside `initialize()`, and remove history/scrubbing logic
29
- - [ ] Update Parent Identity Manager to point to Scrubber
30
- - [ ] Update `getLoadedChildInfo` in [identity-manager.mts](file:///c:/Users/billm/antigravity/ibgib/apps/space-gib/src/client/components/identity-manager/identity-manager.mts) to instantiate `ibgib-keystone-scrubber` instead of `ibgib-keystone-details`
31
- - [ ] Compile and verify
32
- - [ ] Compile space-gib via `npm run build:space-gib` (and `npm run chain:build:web-gib` if web-gib changes are needed)
33
- - [ ] Restart space-gib server and manually verify tab switching and timeline scrubbing
@@ -1,46 +0,0 @@
1
- :host {
2
- display: block;
3
- width: 100%;
4
- max-width: 100%;
5
- margin: 0;
6
- box-sizing: border-box;
7
- }
8
-
9
- .scrubber-container {
10
- display: flex;
11
- flex-direction: column;
12
- gap: 1.5rem;
13
- }
14
-
15
- /* Timeline Scrubber Navigation */
16
- .scrubber-nav {
17
- display: flex;
18
- align-items: center;
19
- justify-content: center;
20
- gap: 0.5rem;
21
- padding: 0.75rem;
22
- background: rgba(0, 0, 0, 0.2);
23
- border: 1px solid var(--border-color-base, rgba(255, 255, 255, 0.05));
24
- border-radius: var(--radius-md, 8px);
25
- }
26
-
27
- .scrubber-info {
28
- font-family: var(--font-mono, monospace);
29
- font-size: 0.85rem;
30
- color: var(--clr-accent, #50fa7b);
31
- min-width: 120px;
32
- text-align: center;
33
- font-weight: 500;
34
- }
35
-
36
- .scrubber-btn {
37
- padding: 0.4rem 0.8rem;
38
- font-size: 0.8rem;
39
- min-width: 2.2rem;
40
- }
41
-
42
- .content {
43
- display: flex;
44
- flex-direction: column;
45
- gap: 1.5rem;
46
- }
@@ -1,15 +0,0 @@
1
- <div id="container" class="scrubber-container">
2
- <div class="scrubber-nav">
3
- <button id="btn-scrub-first" class="action-btn scrubber-btn" title="First Frame">&lt;&lt;</button>
4
- <button id="btn-scrub-prev10" class="action-btn scrubber-btn" title="Back 10 Frames">-10</button>
5
- <button id="btn-scrub-prev" class="action-btn scrubber-btn" title="Previous Frame">&lt;</button>
6
- <span id="scrubber-status" class="scrubber-info">Loading timeline...</span>
7
- <button id="btn-scrub-next" class="action-btn scrubber-btn" title="Next Frame">&gt;</button>
8
- <button id="btn-scrub-next10" class="action-btn scrubber-btn" title="Forward 10 Frames">+10</button>
9
- <button id="btn-scrub-latest" class="action-btn scrubber-btn" title="Latest Frame">&gt;&gt;</button>
10
- </div>
11
-
12
- <div id="keystone-scrubber-content" class="content">
13
- <!-- Details component for the active frame will be injected here -->
14
- </div>
15
- </div>
@@ -1,356 +0,0 @@
1
- import styleCss from "../../style.css";
2
- import thisCss from "./keystone-scrubber.css";
3
- import thisHtml from "./keystone-scrubber.html";
4
-
5
- import { extractErrorMsg } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
6
- import { IbGibAddr } from "@ibgib/ts-gib/dist/types.mjs";
7
- import { IbGib_V1 } from "@ibgib/ts-gib/dist/V1/types.mjs";
8
- import { getGibInfo } from "@ibgib/ts-gib/dist/V1/transforms/transform-helper.mjs";
9
- import { getIbAndGib, getIbGibAddr } from "@ibgib/ts-gib/dist/helper.mjs";
10
- import { KeystoneIbGib_V1 } from "@ibgib/core-gib/dist/keystone/keystone-types.mjs";
11
- import {
12
- IbGibDynamicComponentMetaBase, IbGibDynamicComponentInstanceBase_Parent,
13
- } from "@ibgib/web-gib/dist/ui/component/ibgib-dynamic-component-bases.mjs";
14
- import {
15
- ElementsBase, ChildInfoBase, IbGibDynamicComponentInstance,
16
- IbGibDynamicComponentInstanceInitOpts,
17
- } from "@ibgib/web-gib/dist/ui/component/component-types.mjs";
18
- import { getComponentSvc } from "@ibgib/web-gib/dist/ui/component/ibgib-component-service.mjs";
19
-
20
- import { GLOBAL_LOG_A_LOT, APP_CONFIG } from "../../constants.mjs";
21
- import { getComponentCtorArg, getIbGibGlobalThis_SpaceGib } from "../../helpers.web.mjs";
22
-
23
- const logalot = GLOBAL_LOG_A_LOT || true;
24
-
25
- export const KEYSTONE_SCRUBBER_COMPONENT_NAME = 'ibgib-keystone-scrubber';
26
-
27
- export class KeystoneScrubberComponentMeta extends IbGibDynamicComponentMetaBase {
28
- protected lc: string = `[KeystoneScrubberComponentMeta]`;
29
-
30
- routeRegExp?: RegExp = new RegExp(`^${KEYSTONE_SCRUBBER_COMPONENT_NAME}$`);
31
- componentName = KEYSTONE_SCRUBBER_COMPONENT_NAME;
32
-
33
- constructor() {
34
- super(getComponentCtorArg());
35
- if (!customElements.get(this.componentName)) {
36
- customElements.define(this.componentName, KeystoneScrubberComponentInstance);
37
- }
38
- }
39
-
40
- async createInstance({
41
- path,
42
- ibGibAddr
43
- }: {
44
- path: string;
45
- ibGibAddr: IbGibAddr;
46
- }): Promise<IbGibDynamicComponentInstance> {
47
- const lc = `${this.lc}[${this.createInstance.name}]`;
48
- const component = document.createElement(this.componentName) as KeystoneScrubberComponentInstance;
49
- await component.initialize({
50
- ibGibAddr,
51
- meta: this,
52
- html: thisHtml,
53
- css: [styleCss, thisCss],
54
- });
55
- return component;
56
- }
57
- }
58
-
59
- interface ScrubberTabInfo extends ChildInfoBase<IbGibDynamicComponentInstance<any, any>> {
60
- }
61
-
62
- interface KeystoneScrubberElements extends ElementsBase {
63
- containerEl: HTMLDivElement;
64
- btnScrubFirstEl: HTMLButtonElement;
65
- btnScrubPrev10El: HTMLButtonElement;
66
- btnScrubPrevEl: HTMLButtonElement;
67
- scrubberStatusEl: HTMLSpanElement;
68
- btnScrubNextEl: HTMLButtonElement;
69
- btnScrubNext10El: HTMLButtonElement;
70
- btnScrubLatestEl: HTMLButtonElement;
71
- }
72
-
73
- export class KeystoneScrubberComponentInstance
74
- extends IbGibDynamicComponentInstanceBase_Parent<KeystoneIbGib_V1, KeystoneScrubberElements, ScrubberTabInfo>
75
- implements IbGibDynamicComponentInstance<KeystoneIbGib_V1, KeystoneScrubberElements> {
76
-
77
- protected override lc: string = `[KeystoneScrubberComponentInstance]`;
78
-
79
- private history: string[] = [];
80
- private currentFrameIndex: number = -1;
81
- private lastLoadedHistoryAddr: string | null = null;
82
-
83
- constructor() {
84
- console.log('yes this is being updated! I am just wondering if I am seeing old code in the browser, i.e., if refresh is happening or just getting cache (I: 6599db11c1086062b8f5e86db89cba26)')
85
- const lc = `${KeystoneScrubberComponentInstance.name}[ctor]`;
86
- if (logalot) { console.log(`${lc} (I: 3adca837d5c898d8e839d23c59538126)`); }
87
- super();
88
- }
89
-
90
- override async initialize(opts: IbGibDynamicComponentInstanceInitOpts): Promise<void> {
91
- const lc = `${this.lc}[${this.initialize.name}]`;
92
- try {
93
- if (logalot) { console.log(`${lc} starting... (I: 75eecfc01af7f3fa9897932ec5457526)`); }
94
-
95
- await super.initialize(opts);
96
- await this.loadIbGib();
97
-
98
- } catch (error) {
99
- console.error(`${lc} ${extractErrorMsg(error)}`);
100
- throw error;
101
- } finally {
102
- if (logalot) { console.log(`${lc} complete.`); }
103
- }
104
- }
105
-
106
- override async created(): Promise<void> {
107
- const lc = `${this.lc}[${this.created.name}]`;
108
- try {
109
- if (logalot) { console.log(`${lc} starting... (I: bc16e6212928658ed8034c75b6279526)`); }
110
-
111
- this.elements = {} as KeystoneScrubberElements;
112
-
113
- const shadow = this.shadowRoot!;
114
- this.elements.containerEl = shadow.getElementById('container') as HTMLDivElement;
115
- this.elements.btnScrubFirstEl = shadow.getElementById('btn-scrub-first') as HTMLButtonElement;
116
- this.elements.btnScrubPrev10El = shadow.getElementById('btn-scrub-prev10') as HTMLButtonElement;
117
- this.elements.btnScrubPrevEl = shadow.getElementById('btn-scrub-prev') as HTMLButtonElement;
118
- this.elements.scrubberStatusEl = shadow.getElementById('scrubber-status') as HTMLSpanElement;
119
- this.elements.btnScrubNextEl = shadow.getElementById('btn-scrub-next') as HTMLButtonElement;
120
- this.elements.btnScrubNext10El = shadow.getElementById('btn-scrub-next10') as HTMLButtonElement;
121
- this.elements.btnScrubLatestEl = shadow.getElementById('btn-scrub-latest') as HTMLButtonElement;
122
-
123
- // ElementBase contentEl holds the child component
124
- this.elements.contentEl = shadow.getElementById('keystone-scrubber-content') as HTMLDivElement;
125
-
126
- this.initHandlers();
127
- this.loadHistoryData().catch(err => console.error(`${this.lc} loadHistoryData error: ${extractErrorMsg(err)}`));
128
- } catch (error) {
129
- console.error(`${lc} ${extractErrorMsg(error)}`);
130
- throw error;
131
- } finally {
132
- if (logalot) { console.log(`${lc} complete.`); }
133
- }
134
- }
135
-
136
- override async disconnected(): Promise<void> {
137
- // No-op
138
- }
139
-
140
- private initHandlers() {
141
- this.elements!.btnScrubFirstEl.addEventListener('click', () => this.scrubFirst());
142
- this.elements!.btnScrubPrev10El.addEventListener('click', () => this.scrubPrev10());
143
- this.elements!.btnScrubPrevEl.addEventListener('click', () => this.scrubPrev());
144
- this.elements!.btnScrubNextEl.addEventListener('click', () => this.scrubNext());
145
- this.elements!.btnScrubNext10El.addEventListener('click', () => this.scrubNext10());
146
- this.elements!.btnScrubLatestEl.addEventListener('click', () => this.scrubLatest());
147
- }
148
-
149
- override async loadIbGib(): Promise<void> {
150
- const lc = `${this.lc}[${this.loadIbGib.name}]`;
151
- try {
152
- if (logalot) { console.log(`${lc} starting... (I: a4a9181bbb58a22cc71c8745a91ec426)`); }
153
-
154
- if (!this.ibGibAddr) return;
155
-
156
- await super.loadIbGib();
157
- await this.loadHistoryData();
158
- } catch (error) {
159
- console.error(`${lc} ${extractErrorMsg(error)}`);
160
- throw error;
161
- } finally {
162
- if (logalot) { console.log(`${lc} complete.`); }
163
- }
164
- }
165
-
166
- public override async activateIbGib({
167
- addr,
168
- ibGib,
169
- }: {
170
- addr?: IbGibAddr,
171
- ibGib?: IbGib_V1,
172
- }): Promise<void> {
173
- const lc = `${this.lc}[activateIbGib]`;
174
- try {
175
- if (logalot) { console.log(`${lc} starting... (I: 890a8cb88f72c918a8bcf82c8af63e26)`); }
176
- if (!addr) return;
177
-
178
- // Get or create the details component for this specific frame
179
- const childInfo = await this.getLoadedChildInfo({ addr, ibGib });
180
-
181
- // Manage active states in childInfos
182
- const currentlyActive = this.activeChildInfo;
183
- if (currentlyActive) {
184
- currentlyActive.active = false;
185
- }
186
- childInfo.active = true;
187
-
188
- // Re-use the framework's content injection code
189
- const componentSvc = await getComponentSvc();
190
- await componentSvc.inject({
191
- parentEl: this.elements!.contentEl,
192
- componentToInject: childInfo.component!,
193
- });
194
- } catch (error) {
195
- console.error(`${lc} ${extractErrorMsg(error)}`);
196
- }
197
- }
198
-
199
- private async loadHistoryData(): Promise<void> {
200
- if (!this.ibGibAddr || !this.elements) return;
201
-
202
- if (this.ibGibAddr !== this.lastLoadedHistoryAddr) {
203
- await this.loadHistory(this.ibGibAddr);
204
- this.lastLoadedHistoryAddr = this.ibGibAddr;
205
- }
206
-
207
- await this.scrubTo(this.history.length - 1);
208
- }
209
-
210
- private async loadHistory(tipAddr: string): Promise<void> {
211
- const lc = `${this.lc}[loadHistory]`;
212
- this.history = [];
213
- this.currentFrameIndex = -1;
214
-
215
- const metaspace = getIbGibGlobalThis_SpaceGib(APP_CONFIG).metaspace;
216
- if (!metaspace) return;
217
- const space = await metaspace.getLocalUserSpace({ lock: false });
218
- if (!space) return;
219
-
220
- let currentAddr: string | undefined = tipAddr;
221
- const tempHistory: string[] = [];
222
-
223
- while (currentAddr) {
224
- const res = await metaspace.get({ addr: currentAddr, space });
225
- if (!res.success || !res.ibGibs || res.ibGibs.length === 0) {
226
- console.warn(`${lc} Could not find frame at ${currentAddr}`);
227
- break;
228
- }
229
- const keystone = res.ibGibs[0] as KeystoneIbGib_V1;
230
- tempHistory.push(currentAddr);
231
-
232
- if (keystone.data?.n === 0) {
233
- break;
234
- }
235
-
236
- const past = keystone.rel8ns?.past;
237
- currentAddr = (past && past.length > 0) ? past[past.length - 1] : undefined;
238
- }
239
-
240
- this.history = tempHistory.reverse();
241
- this.currentFrameIndex = this.history.length - 1;
242
- }
243
-
244
- private async scrubTo(index: number): Promise<void> {
245
- if (this.history.length === 0) return;
246
- this.currentFrameIndex = Math.max(0, Math.min(index, this.history.length - 1));
247
-
248
- this.updateScrubberUI();
249
-
250
- const addr = this.history[this.currentFrameIndex];
251
- await this.activateIbGib({ addr });
252
- }
253
-
254
- private scrubFirst() { this.scrubTo(0); }
255
- private scrubPrev10() { this.scrubTo(this.currentFrameIndex - 10); }
256
- private scrubPrev() { this.scrubTo(this.currentFrameIndex - 1); }
257
- private scrubNext() { this.scrubTo(this.currentFrameIndex + 1); }
258
- private scrubNext10() { this.scrubTo(this.currentFrameIndex + 10); }
259
- private scrubLatest() { this.scrubTo(this.history.length - 1); }
260
-
261
- private updateScrubberUI() {
262
- if (!this.elements) return;
263
- this.elements.scrubberStatusEl.textContent = `Frame ${this.currentFrameIndex + 1} / ${this.history.length}`;
264
-
265
- this.elements.btnScrubFirstEl.disabled = this.currentFrameIndex === 0;
266
- this.elements.btnScrubPrev10El.disabled = this.currentFrameIndex === 0;
267
- this.elements.btnScrubPrevEl.disabled = this.currentFrameIndex === 0;
268
- this.elements.btnScrubNextEl.disabled = this.currentFrameIndex === this.history.length - 1;
269
- this.elements.btnScrubNext10El.disabled = this.currentFrameIndex === this.history.length - 1;
270
- this.elements.btnScrubLatestEl.disabled = this.currentFrameIndex === this.history.length - 1;
271
- }
272
-
273
- protected async getLoadedChildInfo({
274
- addr,
275
- ibGib,
276
- }: {
277
- addr: IbGibAddr,
278
- ibGib?: IbGib_V1,
279
- }): Promise<ScrubberTabInfo> {
280
- const lc = `${this.lc}[${this.getLoadedChildInfo.name}]`;
281
- try {
282
- if (logalot) { console.log(`${lc} starting... (I: 9eea188f6b55f04b483fbda8a110f826)`); }
283
-
284
- if (!addr) { throw new Error(`(UNEXPECTED) addr falsy?`); }
285
- const tjpGib = getGibInfo({ ibGibAddr: addr }).tjpGib ?? getIbAndGib({ ibGibAddr: addr }).gib;
286
-
287
- const fnCreateAndLoadChildComponent = async () => {
288
- const componentSvc = await getComponentSvc();
289
- const detailsComponent = await componentSvc.getComponentInstance({
290
- path: 'ibgib-keystone-details',
291
- ibGibAddr: addr,
292
- useRegExpPrefilter: true,
293
- });
294
- if (!detailsComponent) {
295
- throw new Error(`(UNEXPECTED) detailsComponent falsy?`);
296
- }
297
- return detailsComponent;
298
- }
299
-
300
- let tabInfo: ScrubberTabInfo;
301
-
302
- const filtered = this.childInfos.filter(x => x.addr === addr);
303
-
304
- if (filtered.length > 0) {
305
- if (filtered.length !== 1) { throw new Error(`(UNEXPECTED) filtered.length !== 1?`); }
306
- tabInfo = filtered[0];
307
- if (!tabInfo.component) {
308
- tabInfo.component = await fnCreateAndLoadChildComponent();
309
- }
310
- } else {
311
- const detailsComponent = await fnCreateAndLoadChildComponent();
312
- ibGib = detailsComponent.ibGib ?? ibGib;
313
- const tabBtnEl = await this.addChild({ addr, ibGib: ibGib! });
314
- tabInfo = {
315
- addr,
316
- childBtnEl: tabBtnEl,
317
- component: detailsComponent,
318
- active: false,
319
- };
320
- this.childInfos.push(tabInfo);
321
- }
322
-
323
- return tabInfo;
324
- } catch (error) {
325
- console.error(`${lc} ${extractErrorMsg(error)}`);
326
- throw error;
327
- } finally {
328
- if (logalot) { console.log(`${lc} complete.`); }
329
- }
330
- }
331
-
332
- protected override async addChild({
333
- addr,
334
- ibGib,
335
- }: {
336
- ibGib: IbGib_V1,
337
- addr?: IbGibAddr,
338
- }): Promise<HTMLElement> {
339
- const lc = `${this.lc}[${this.addChild.name}]`;
340
- try {
341
- if (logalot) { console.log(`${lc} starting... (I: 824f98b6f9a2c922f8b3a9f67ad63e26)`); }
342
-
343
- // why are we making a dummy???
344
-
345
- // Return a dummy hidden element since we don't display visual tab buttons in the scrubber
346
- const dummy = document.createElement('div');
347
- dummy.style.display = 'none';
348
- return dummy;
349
- } catch (error) {
350
- console.error(`${lc} ${extractErrorMsg(error)}`);
351
- throw error;
352
- } finally {
353
- if (logalot) { console.log(`${lc} complete.`); }
354
- }
355
- }
356
- }
@@ -1,141 +0,0 @@
1
- import { join } from 'node:path';
2
-
3
- import { clone, getUUID, } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
4
- import { IbGib_V1 } from '@ibgib/ts-gib/dist/V1/types.mjs';
5
- import { getGib, getGibInfo } from '@ibgib/ts-gib/dist/V1/transforms/transform-helper.mjs';
6
- import {
7
- MetaspaceFactory, MetaspaceService, ZeroSpaceFactoryFunction,
8
- LocalSpaceFactoryFunction, DtoToSpaceFunction
9
- } from '@ibgib/core-gib/dist/witness/space/metaspace/metaspace-types.mjs';
10
- import { NodeIndexedFilesystemSpace_V1 } from '@ibgib/node-gib/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/node-indexed-filesystem-space-v1.mjs';
11
- import {
12
- NodeFilesystemSpaceData_V1, DEFAULT_NODE_FILESYSTEM_SPACE_DATA_V1,
13
- } from '@ibgib/node-gib/dist/witness/space/node-filesystem-space/node-filesystem-space-types.mjs';
14
-
15
- import { GLOBAL_LOG_A_LOT } from './server-constants.mjs';
16
- import { NodeIndexedFilesystemSpaceData_V1, NodeIndexedFilesystemSpaceRel8ns_V1 } from '@ibgib/node-gib/dist/witness/space/node-filesystem-space/node-indexed-filesystem-space/node-indexed-filesystem-space-types.mjs';
17
- import { Metaspace_Nodeindexedspace } from './metaspace-nodeindexedspace/metaspace-nodeindexedspace.mjs';
18
-
19
- const logalot = GLOBAL_LOG_A_LOT;
20
-
21
- /**
22
- * Deterministically calculates the physical filesystem path for a domain
23
- * based on its keystone's tjpGib.
24
- *
25
- * @param tjpGib The TJP hash of the keystone defining the domain.
26
- * @param baseDataDir The root directory for all ibgib spaces on the server.
27
- * @returns The absolute path to the domain's isolated root.
28
- */
29
- export function getDomainRootPath(tjpGib: string, baseDataDir: string): string {
30
- // We use the first 2 characters as subfolders to balance the OS filesystem entries.
31
- // e.g. /data/spaces/ab/c1/defg...
32
- const sub1 = tjpGib.slice(0, 2);
33
- const sub2 = tjpGib.slice(2, 4);
34
- const remaining = tjpGib;
35
-
36
- return join(baseDataDir, 'domains', sub1, sub2, remaining);
37
- }
38
-
39
- /**
40
- * Creates a MetaspaceFactory using the "Factory Closure Pattern" to isolate
41
- * all space operations within the given domainRootPath.
42
- *
43
- * @param domainRootPath The physical root directory for this domain.
44
- * @returns A MetaspaceFactory pre-configured for this domain.
45
- */
46
- export function getDomainFactory(domainRootPath: string): MetaspaceFactory {
47
- const lc = `[${getDomainFactory.name}]`;
48
-
49
- const fnZeroSpaceFactory: ZeroSpaceFactoryFunction = () => {
50
- const zeroSpaceData: NodeIndexedFilesystemSpaceData_V1 = {
51
- ...clone(DEFAULT_NODE_FILESYSTEM_SPACE_DATA_V1),
52
- classname: NodeIndexedFilesystemSpace_V1.name,
53
- baseDir: domainRootPath,
54
- };
55
-
56
- const zeroSpace = new NodeIndexedFilesystemSpace_V1(zeroSpaceData);
57
- zeroSpace.gib = 'gib'; // Primitive zero space
58
- return zeroSpace;
59
- };
60
-
61
- const fnDefaultLocalSpaceFactory: LocalSpaceFactoryFunction = async (opts) => {
62
- // Ensure we don't prompt for a name during server bootstrap
63
- // opts.spaceName ||= `default_${pickRandom_Letters({ count: 5 })}`;
64
- opts.spaceName ||= `default`;
65
-
66
- const spaceData: NodeFilesystemSpaceData_V1 = {
67
- ...clone(DEFAULT_NODE_FILESYSTEM_SPACE_DATA_V1),
68
- classname: NodeIndexedFilesystemSpace_V1.name,
69
- uuid: await getUUID(),
70
- baseDir: domainRootPath,
71
- name: opts.spaceName,
72
- spaceSubPath: opts.spaceName,
73
- baseSubPath: 'ibgib',
74
- binSubPath: 'bin',
75
- dnaSubPath: 'dna',
76
- ibgibsSubPath: 'ibgibs',
77
- metaSubPath: 'meta',
78
- isTjp: true,
79
- };
80
- if (logalot) { console.log(`${lc}[${fnDefaultLocalSpaceFactory.name}] spaceData.classname: ${spaceData.classname} (I: b60da661e9282e1253101e08765eb226)`); }
81
-
82
- const space = new NodeIndexedFilesystemSpace_V1(spaceData);
83
- space.gib = await getGib({ ibGib: space as any, hasTjp: true });
84
-
85
- return space;
86
- };
87
-
88
- const fnDtoToSpace: DtoToSpaceFunction = async (spaceDto: IbGib_V1) => {
89
- if (!spaceDto) { throw new Error(`spaceDto required (E: 30ede52f9c974591dac980a810510e26)`); }
90
- if (!spaceDto.data) { throw new Error(`spaceDto.data required (E: 867b08a9c998e95028396f283d1d4826)`); }
91
- if (!spaceDto.data.classname) { throw new Error(`spaceDto.data.classname required (E: 95a68813e64e68e6c84296d8dbaeb826)`); }
92
- if (spaceDto.data.classname !== NodeIndexedFilesystemSpace_V1.name) {
93
- throw new Error(`spaceDto.data.classname (${spaceDto.data.classname}) expeced to be ${NodeIndexedFilesystemSpace_V1.name} (E: 68aaa875ff22b92f57a0a3189da4b826)`);
94
- }
95
-
96
- const space = await NodeIndexedFilesystemSpace_V1.createFromDto(
97
- spaceDto as IbGib_V1<NodeIndexedFilesystemSpaceData_V1, NodeIndexedFilesystemSpaceRel8ns_V1>
98
- );
99
- return space;
100
- };
101
-
102
-
103
- return {
104
- fnZeroSpaceFactory,
105
- fnDefaultLocalSpaceFactory,
106
- fnDtoToSpace,
107
- };
108
- }
109
-
110
- /**
111
- * Orchestrates the bootstrapping of a domain-isolated metaspace.
112
- *
113
- * @param keystoneAddr The full address of the keystone defining the domain.
114
- * @param baseDataDir The server's root data directory.
115
- * @returns An initialized MetaspaceService scoped to the domain.
116
- */
117
- export async function bootstrapDomainMetaspace(
118
- keystoneAddr: string,
119
- baseDataDir: string
120
- ): Promise<MetaspaceService> {
121
- const { tjpGib, punctiliarHash } = getGibInfo({ ibGibAddr: keystoneAddr });
122
- const domainGib = tjpGib || punctiliarHash;
123
- if (!domainGib) {
124
- throw new Error(`Could not extract tjpGib from keystone address: ${keystoneAddr}`);
125
- }
126
-
127
- const domainRootPath = getDomainRootPath(domainGib, baseDataDir);
128
- const factory = getDomainFactory(domainRootPath);
129
-
130
- const metaspace = new Metaspace_Nodeindexedspace(/*cacheSvc*/ undefined);
131
-
132
- await metaspace.initialize({
133
- metaspaceFactory: factory,
134
- // For server-side, these prompts should probably be non-interactive or log errors.
135
- getFnAlert: () => async (arg) => console.log(`[ALERT] ${arg.title}: ${arg.msg}`),
136
- getFnPrompt: () => async (arg) => { throw new Error(`Interactive prompt (${arg.title}) not supported in server bootstrap.`); },
137
- getFnPromptPassword: () => async (title) => { throw new Error(`Password prompt (${title}) not supported in server bootstrap.`); },
138
- });
139
-
140
- return metaspace;
141
- }