@ibgib/web-gib 0.0.28 → 0.0.29

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../src/app-bootstrap/constants.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oDAAoD,CAAC;AAEjF,8EAA8E;AAC9E,sBAAsB;AACtB,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,yBAAyB,CAAC;AAE/D;;;GAGG;AACH,MAAM,CAAC,MAAM,0CAA0C,GACnD,yDAAyD,CAAC;AAE9D,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;AAEtC;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,cAAc,CAAC;AAE7C;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAC9B,qEAAqE,CAAC;AAE1E;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CAAC,cAAc,CAAC,CAAC;AAExD,8EAA8E;AAC9E,6BAA6B;AAC7B,8EAA8E;AAE9E,MAAM,CAAC,MAAM,mBAAmB,GAAG,WAAW,CAAC;AAC/C,MAAM,CAAC,MAAM,yBAAyB,GAAG,WAAW,CAAC;AACrD,MAAM,CAAC,MAAM,4BAA4B,GAAG,SAAS,CAAC;AACtD,MAAM,CAAC,MAAM,iBAAiB,GAAG,WAAW,CAAC;AAC7C,MAAM,CAAC,MAAM,6BAA6B,GAAG,WAAW,CAAC;AACzD,MAAM,CAAC,MAAM,0BAA0B,GAAG,SAAS,CAAC;AAEpD,8EAA8E;AAC9E,4BAA4B;AAC5B,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,gBAAgB,CAAC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @module helpers.web
3
+ *
4
+ * Shared web helper functions for ibgib-based frontend apps.
5
+ *
6
+ * ## what belongs here
7
+ *
8
+ * Functions that are identical across all ibgib apps and depend only on the
9
+ * IbGibAmbientContextConfig seam. App-specific logic (typed globalThis
10
+ * accessors, component helpers) belongs in each app's own helpers.web.mts.
11
+ */
12
+ import { IbGibDynamicComponentMetaCtorOpts } from "../ui/component/component-types.mjs";
13
+ import { IbGibAmbientContextConfig, IbGibGlobalThis_Common, IbGibGlobalThis_IbGibApp } from "./types.mjs";
14
+ /**
15
+ * Initializes the IndexedDB stores required by an ibgib app.
16
+ *
17
+ * Call once on DOMContentLoaded, before the bootstrap script is dynamically
18
+ * loaded. This ensures storage is available when the metaspace initializes.
19
+ */
20
+ export declare function initIbGibStorage(config: IbGibAmbientContextConfig): Promise<void>;
21
+ /**
22
+ * Sets up globalThis.ibgib.[globalThisKey] for the given app config.
23
+ *
24
+ * Idempotent — safe to call multiple times. The root `globalThis.ibgib` object
25
+ * is created if it doesn't exist, then the per-app sub-key is populated.
26
+ *
27
+ * @param config The app's ambient context config.
28
+ * @param globalThisKey The snake_case key for this app's namespace under
29
+ * `globalThis.ibgib` (e.g. `'my_app'`, `'cool_new_thing'`).
30
+ * @param version Optional semver string (from AUTO_GENERATED_VERSION).
31
+ */
32
+ export declare function initIbGibGlobalThis(config: IbGibAmbientContextConfig, globalThisKey: string, version?: string): void;
33
+ /**
34
+ * Returns the raw IbGibGlobalThis_Common for the given key.
35
+ * Typed as the Common base — use the app-specific typed accessor for
36
+ * full-type access.
37
+ */
38
+ export declare function getIbGibGlobalThis_Common(globalThisKey: string): IbGibGlobalThis_Common;
39
+ /**
40
+ * Returns the IbGibGlobalThis_IbGibApp for the given key, initializing it
41
+ * from config if not yet present.
42
+ */
43
+ export declare function getIbGibGlobalThis_IbGibApp(globalThisKey: string, config?: IbGibAmbientContextConfig, version?: string): IbGibGlobalThis_IbGibApp;
44
+ /**
45
+ * Returns a function that retrieves the AI API key from storage at call time.
46
+ * The globalThisKey links back to the per-app namespace for DB/store/key names.
47
+ */
48
+ export declare function getDefaultFnGetAPIKey(globalThisKey: string): () => Promise<string>;
49
+ /**
50
+ * Dynamically imports the bootstrap module at the given path and calls the
51
+ * named export bootstrap function.
52
+ *
53
+ * Called after DOMContentLoaded so the heavy ibgib import graph does not block
54
+ * first paint.
55
+ *
56
+ * @param path Path to bootstrap.mjs (relative to the app's index.mts).
57
+ * @param bootstrapFnName The exported async function to call. Defaults to
58
+ * `'bootstrapApp'` — override with the app-specific function name
59
+ * (e.g. `'bootstrapMyAppApp'`).
60
+ */
61
+ export declare function dynamicallyLoadBootstrapScript(path: string, bootstrapFnName?: string): Promise<void>;
62
+ /**
63
+ * Returns the standard ctor options object for IbGib dynamic components.
64
+ *
65
+ * Provides two things components need at construction time:
66
+ * 1. `fnGetMetaspace` — accesses the global metaspace once initialized
67
+ * 2. `bootstrapPromise` — components can await this to defer their own init
68
+ * until the App witness and metaspace are fully ready
69
+ *
70
+ * @param globalThisKey The per-app namespace key used to find the bootstrap
71
+ * promise on globalThis.
72
+ */
73
+ export declare function getComponentCtorArg(globalThisKey: string): IbGibDynamicComponentMetaCtorOpts;
74
+ //# sourceMappingURL=helpers.web.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.web.d.mts","sourceRoot":"","sources":["../../src/app-bootstrap/helpers.web.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAExF,OAAO,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAM1G;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAevF;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAC/B,MAAM,EAAE,yBAAyB,EACjC,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,MAAM,GACjB,IAAI,CAkCN;AAMD;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,aAAa,EAAE,MAAM,GAAG,sBAAsB,CAOvF;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CACvC,aAAa,EAAE,MAAM,EACrB,MAAM,CAAC,EAAE,yBAAyB,EAClC,OAAO,CAAC,EAAE,MAAM,GACjB,wBAAwB,CAU1B;AAMD;;;GAGG;AACH,wBAAgB,qBAAqB,CACjC,aAAa,EAAE,MAAM,GACtB,MAAM,OAAO,CAAC,MAAM,CAAC,CASvB;AAMD;;;;;;;;;;;GAWG;AACH,wBAAsB,8BAA8B,CAChD,IAAI,EAAE,MAAM,EACZ,eAAe,GAAE,MAAuB,GACzC,OAAO,CAAC,IAAI,CAAC,CAgBf;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,MAAM,GAAG,iCAAiC,CA4B5F"}
@@ -0,0 +1,210 @@
1
+ /**
2
+ * @module helpers.web
3
+ *
4
+ * Shared web helper functions for ibgib-based frontend apps.
5
+ *
6
+ * ## what belongs here
7
+ *
8
+ * Functions that are identical across all ibgib apps and depend only on the
9
+ * IbGibAmbientContextConfig seam. App-specific logic (typed globalThis
10
+ * accessors, component helpers) belongs in each app's own helpers.web.mts.
11
+ */
12
+ import { delay, extractErrorMsg } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
13
+ import { storageGet } from "../storage/storage-helpers.web.mjs";
14
+ import { initAppStorage } from "../helpers.web.mjs";
15
+ import { getGlobalMetaspace_waitIfNeeded } from "../helpers.mjs";
16
+ // ---------------------------------------------------------------------------
17
+ // Storage initialization
18
+ // ---------------------------------------------------------------------------
19
+ /**
20
+ * Initializes the IndexedDB stores required by an ibgib app.
21
+ *
22
+ * Call once on DOMContentLoaded, before the bootstrap script is dynamically
23
+ * loaded. This ensures storage is available when the metaspace initializes.
24
+ */
25
+ export async function initIbGibStorage(config) {
26
+ const lc = `[${initIbGibStorage.name}]`;
27
+ try {
28
+ await initAppStorage({
29
+ infos: [
30
+ {
31
+ dbName: config.dbName,
32
+ storeNames: [config.storeName, ...(config.additionalStoreNames ?? [])],
33
+ },
34
+ ],
35
+ });
36
+ }
37
+ catch (error) {
38
+ console.error(`${lc} ${extractErrorMsg(error)}`);
39
+ throw error;
40
+ }
41
+ }
42
+ // ---------------------------------------------------------------------------
43
+ // globalThis initialization
44
+ // ---------------------------------------------------------------------------
45
+ /**
46
+ * Sets up globalThis.ibgib.[globalThisKey] for the given app config.
47
+ *
48
+ * Idempotent — safe to call multiple times. The root `globalThis.ibgib` object
49
+ * is created if it doesn't exist, then the per-app sub-key is populated.
50
+ *
51
+ * @param config The app's ambient context config.
52
+ * @param globalThisKey The snake_case key for this app's namespace under
53
+ * `globalThis.ibgib` (e.g. `'my_app'`, `'cool_new_thing'`).
54
+ * @param version Optional semver string (from AUTO_GENERATED_VERSION).
55
+ */
56
+ export function initIbGibGlobalThis(config, globalThisKey, version) {
57
+ const lc = `[${initIbGibGlobalThis.name}]`;
58
+ try {
59
+ // Ensure the root ibgib object exists
60
+ if (!globalThis.ibgib) {
61
+ globalThis.ibgib = {
62
+ dbName_hack: config.dbName,
63
+ apiKeyName_hack: config.apiKeyName,
64
+ storeName_hack: config.storeName,
65
+ };
66
+ }
67
+ // Populate the per-app namespace
68
+ if (!globalThis.ibgib[globalThisKey]) {
69
+ globalThis.ibgib[globalThisKey] = {
70
+ version,
71
+ spaceShim: {},
72
+ fnDefaultGetAPIKey: async () => {
73
+ const apiKey = await storageGet({
74
+ dbName: config.dbName,
75
+ storeName: config.storeName,
76
+ key: config.apiKeyName,
77
+ });
78
+ return apiKey ?? '';
79
+ },
80
+ dbName_hack: config.dbName,
81
+ apiKeyName_hack: config.apiKeyName,
82
+ storeName_hack: config.storeName,
83
+ };
84
+ }
85
+ }
86
+ catch (error) {
87
+ console.error(`${lc} ${extractErrorMsg(error)}`);
88
+ throw error;
89
+ }
90
+ }
91
+ // ---------------------------------------------------------------------------
92
+ // globalThis accessors
93
+ // ---------------------------------------------------------------------------
94
+ /**
95
+ * Returns the raw IbGibGlobalThis_Common for the given key.
96
+ * Typed as the Common base — use the app-specific typed accessor for
97
+ * full-type access.
98
+ */
99
+ export function getIbGibGlobalThis_Common(globalThisKey) {
100
+ const lc = `[${getIbGibGlobalThis_Common.name}]`;
101
+ const g = globalThis.ibgib?.[globalThisKey];
102
+ if (!g) {
103
+ throw new Error(`${lc} (UNEXPECTED) globalThis.ibgib.${globalThisKey} not initialized. (E: 8d621732ibgib-commonfe25)`);
104
+ }
105
+ return g;
106
+ }
107
+ /**
108
+ * Returns the IbGibGlobalThis_IbGibApp for the given key, initializing it
109
+ * from config if not yet present.
110
+ */
111
+ export function getIbGibGlobalThis_IbGibApp(globalThisKey, config, version) {
112
+ if (!globalThis.ibgib?.[globalThisKey]) {
113
+ if (!config) {
114
+ throw new Error(`Global context not initialized and config not provided for key '${globalThisKey}'.`);
115
+ }
116
+ initIbGibGlobalThis(config, globalThisKey, version);
117
+ }
118
+ return globalThis.ibgib[globalThisKey];
119
+ }
120
+ // ---------------------------------------------------------------------------
121
+ // API key helper
122
+ // ---------------------------------------------------------------------------
123
+ /**
124
+ * Returns a function that retrieves the AI API key from storage at call time.
125
+ * The globalThisKey links back to the per-app namespace for DB/store/key names.
126
+ */
127
+ export function getDefaultFnGetAPIKey(globalThisKey) {
128
+ return async () => {
129
+ const gb = getIbGibGlobalThis_IbGibApp(globalThisKey);
130
+ return (await storageGet({
131
+ dbName: gb.dbName_hack,
132
+ storeName: gb.storeName_hack,
133
+ key: gb.apiKeyName_hack,
134
+ })) ?? '';
135
+ };
136
+ }
137
+ // ---------------------------------------------------------------------------
138
+ // Dynamic bootstrap loading
139
+ // ---------------------------------------------------------------------------
140
+ /**
141
+ * Dynamically imports the bootstrap module at the given path and calls the
142
+ * named export bootstrap function.
143
+ *
144
+ * Called after DOMContentLoaded so the heavy ibgib import graph does not block
145
+ * first paint.
146
+ *
147
+ * @param path Path to bootstrap.mjs (relative to the app's index.mts).
148
+ * @param bootstrapFnName The exported async function to call. Defaults to
149
+ * `'bootstrapApp'` — override with the app-specific function name
150
+ * (e.g. `'bootstrapMyAppApp'`).
151
+ */
152
+ export async function dynamicallyLoadBootstrapScript(path, bootstrapFnName = 'bootstrapApp') {
153
+ const lc = `[${dynamicallyLoadBootstrapScript.name}]`;
154
+ try {
155
+ const module = await import(path);
156
+ const fn = module[bootstrapFnName];
157
+ if (typeof fn !== 'function') {
158
+ throw new Error(`${lc} Bootstrap function '${bootstrapFnName}' not found in '${path}'. ` +
159
+ `Available exports: ${Object.keys(module).join(', ')} (E: 9136085eibgib-common26)`);
160
+ }
161
+ await fn();
162
+ }
163
+ catch (error) {
164
+ console.error(`${lc} ${extractErrorMsg(error)}`);
165
+ throw error;
166
+ }
167
+ }
168
+ // ---------------------------------------------------------------------------
169
+ // Component constructor args helper
170
+ // ---------------------------------------------------------------------------
171
+ /**
172
+ * Returns the standard ctor options object for IbGib dynamic components.
173
+ *
174
+ * Provides two things components need at construction time:
175
+ * 1. `fnGetMetaspace` — accesses the global metaspace once initialized
176
+ * 2. `bootstrapPromise` — components can await this to defer their own init
177
+ * until the App witness and metaspace are fully ready
178
+ *
179
+ * @param globalThisKey The per-app namespace key used to find the bootstrap
180
+ * promise on globalThis.
181
+ */
182
+ export function getComponentCtorArg(globalThisKey) {
183
+ const fnGetMetaspace = async () => getGlobalMetaspace_waitIfNeeded();
184
+ const bootstrapPromiseWrapper = new Promise(async (resolve, reject) => {
185
+ try {
186
+ let maxTries = 100_000;
187
+ let counter = 0;
188
+ let bootstrapPromise;
189
+ do {
190
+ bootstrapPromise =
191
+ getIbGibGlobalThis_IbGibApp(globalThisKey)?.bootstrapPromise;
192
+ counter++;
193
+ if (counter > maxTries) {
194
+ break;
195
+ }
196
+ await delay(10);
197
+ } while (bootstrapPromise === undefined);
198
+ if (!bootstrapPromise) {
199
+ throw new Error(`Timed out waiting for bootstrapPromise on key '${globalThisKey}'. (E: 4048ce92ibgib-common26)`);
200
+ }
201
+ await bootstrapPromise;
202
+ resolve();
203
+ }
204
+ catch (error) {
205
+ reject(error);
206
+ }
207
+ });
208
+ return { fnGetMetaspace, bootstrapPromise: bootstrapPromiseWrapper };
209
+ }
210
+ //# sourceMappingURL=helpers.web.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.web.mjs","sourceRoot":"","sources":["../../src/app-bootstrap/helpers.web.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AAEzF,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,+BAA+B,EAAE,MAAM,gBAAgB,CAAC;AAKjE,8EAA8E;AAC9E,yBAAyB;AACzB,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,MAAiC;IACpE,MAAM,EAAE,GAAG,IAAI,gBAAgB,CAAC,IAAI,GAAG,CAAC;IACxC,IAAI,CAAC;QACD,MAAM,cAAc,CAAC;YACjB,KAAK,EAAE;gBACH;oBACI,MAAM,EAAE,MAAM,CAAC,MAAM;oBACrB,UAAU,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAC;iBACzE;aACJ;SACJ,CAAC,CAAC;IACP,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACjD,MAAM,KAAK,CAAC;IAChB,CAAC;AACL,CAAC;AAED,8EAA8E;AAC9E,4BAA4B;AAC5B,8EAA8E;AAE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CAAC,EAAE,CAAC,CAAC;YACpB,CAAC,QAAQ,gBAAgB,KAAK,SAAS,EAAE;YACzC,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBACpB,MAAM,IAAI,KAAK,CACX,kDAAkD,aAAa,gCAAgC,CAClG,CAAC;YACN,CAAC;YACD,MAAM,gBAAgB,CAAC;YACvB,OAAO,EAAE,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,CAAC;AACzE,CAAC"}
@@ -0,0 +1,163 @@
1
+ /**
2
+ * @module types
3
+ *
4
+ * Shared type definitions for ibgib-based frontend apps.
5
+ *
6
+ * ## notes
7
+ *
8
+ * Three layers of globalThis state:
9
+ * IbGibGlobalThisInfo (@ibgib/web-gib — the root ibgib slot)
10
+ * └── IbGibGlobalThis_Common (bootstrap promise tracking)
11
+ * └── IbGibGlobalThis_IbGibApp (all ibgib App witness apps)
12
+ * └── IbGibGlobalThis_[AppName] (per-app extensions)
13
+ */
14
+ import { IbGibRel8ns_V1, IbGib_V1 } from "@ibgib/ts-gib/dist/V1/types.mjs";
15
+ import { CommentData_V1 } from "@ibgib/core-gib/dist/common/comment/comment-types.mjs";
16
+ import { RCLIArgInfo } from "@ibgib/helper-gib/dist/rcli/rcli-types.mjs";
17
+ import { LiveProxyIbGib } from "../witness/live-proxy-ibgib/live-proxy-ibgib-one-file.mjs";
18
+ import { IbGibGlobalThisInfo } from "../types.mjs";
19
+ /**
20
+ * Configuration object that parameterizes an ibgib app's storage substrates.
21
+ *
22
+ * This is the primary seam between the framework layer and a specific app.
23
+ * Every downstream app creates exactly one APP_CONFIG and passes it to the
24
+ * framework helpers.
25
+ *
26
+ * ## notes
27
+ *
28
+ * Intended to be upstreamed into @ibgib/web-gib.
29
+ */
30
+ export interface IbGibAmbientContextConfig {
31
+ /** Target IndexedDB database name */
32
+ dbName: string;
33
+ /** Primary object store name */
34
+ storeName: string;
35
+ /** Additional stores to initialize alongside the primary (e.g., ZERO_SPACE_ID) */
36
+ additionalStoreNames?: string[];
37
+ /** The IndexedDB key under which the AI API key is persisted */
38
+ apiKeyName: string;
39
+ }
40
+ /**
41
+ * Per-space shim that mimics a filesystem CWD context for ibgib RCLI compat.
42
+ */
43
+ export interface SpaceShimGlobalInfo {
44
+ /**
45
+ * The initial cwd() value when the RCLI was started. Used as the context
46
+ * path the user types commands from.
47
+ */
48
+ initialCwd: string;
49
+ /** The active CWD, updated by pass-through `cd` commands. */
50
+ cwd: string;
51
+ }
52
+ /** @see {@link RequestCommentIbGib_V1} */
53
+ export interface RequestCommentData_V1 extends CommentData_V1 {
54
+ /** As close to the raw args as we can get. */
55
+ args: string[];
56
+ /** Interpreted infos for args. */
57
+ interpretedArgInfos: RCLIArgInfo[];
58
+ }
59
+ export interface RequestCommentRel8ns_V1 extends IbGibRel8ns_V1 {
60
+ }
61
+ /**
62
+ * Special Comment ibgib that acts as a "request" — the command analog from RCLI.
63
+ *
64
+ * The raw text of the command is `text` from `CommentData_V1`.
65
+ */
66
+ export interface RequestCommentIbGib_V1 extends IbGib_V1<RequestCommentData_V1, RequestCommentRel8ns_V1> {
67
+ /** Kluge for one-off commandlines during initial development. */
68
+ oneOff: boolean;
69
+ }
70
+ /**
71
+ * Framework-level identity interface.
72
+ *
73
+ * ## design notes
74
+ *
75
+ * The implementation is entirely consumer-supplied. The framework defines only
76
+ * the shape of the slot so shells and components can react to auth state
77
+ * without coupling to a specific identity mechanism.
78
+ *
79
+ * For ibgib apps, the typical implementation will be keystone-based (a Merkle
80
+ * DAG proof of cryptographic identity continuity), not token-based.
81
+ *
82
+ * ## WIP caveat (atow April 2026)
83
+ *
84
+ * The keystone identity implementation in @ibgib/core-gib is still under
85
+ * active development. This interface represents the intended framework
86
+ * contract. Check the ibgib-libs sync/keystone module for the current
87
+ * implementation status before using.
88
+ */
89
+ export interface IbGibIdentityContext {
90
+ /** Whether identity resolution has completed (does not imply authenticated). */
91
+ resolved: boolean;
92
+ /** Whether the current session has a verified identity. */
93
+ authenticated: boolean;
94
+ /**
95
+ * App-specific identity payload.
96
+ * For ibgib: typically `{ keystoneAddr, userIbGibAddr }`.
97
+ */
98
+ data?: Record<string, any>;
99
+ }
100
+ /**
101
+ * Layer 1: Fields shared across ALL ibgib web apps.
102
+ *
103
+ * Extends IbGibGlobalThisInfo from @ibgib/web-gib (the root ibgib slot).
104
+ * Intended to be upstreamed into @ibgib/web-gib.
105
+ */
106
+ export interface IbGibGlobalThis_Common extends IbGibGlobalThisInfo {
107
+ /**
108
+ * Set to true when bootstrap has been triggered.
109
+ * There is no "bootstrapComplete" — await {@link bootstrapPromise} instead.
110
+ */
111
+ bootstrapStarted?: boolean;
112
+ /**
113
+ * The promise returned by the bootstrap function. Components await this
114
+ * to defer initialization until the App witness and metaspace are ready.
115
+ */
116
+ bootstrapPromise?: Promise<void>;
117
+ /**
118
+ * Singleton chronologys component. Should not be destroyed for the
119
+ * duration of the page session.
120
+ */
121
+ chronologysComponent?: any;
122
+ }
123
+ /**
124
+ * Layer 2: Fields shared by any app that follows the ibgib App witness pattern.
125
+ *
126
+ * Apps using the bootstrap factory pattern extend this interface and add only
127
+ * their app-specific fields.
128
+ *
129
+ * ## notes
130
+ *
131
+ * Intended to be upstreamed into @ibgib/web-gib as IbGibGlobalThis_IbGibApp.
132
+ */
133
+ export interface IbGibGlobalThis_IbGibApp extends IbGibGlobalThis_Common {
134
+ /** Semver string generated at build time. */
135
+ version?: string;
136
+ /** Per-space RCLI pathing shim. */
137
+ spaceShim: {
138
+ [spaceId: string]: SpaceShimGlobalInfo;
139
+ };
140
+ /** When true, verbose output is enabled for the session. */
141
+ verbose?: boolean;
142
+ /**
143
+ * Looks up the AI API key from IndexedDB storage.
144
+ * Stored as a function so the key is never cached in memory at the global level.
145
+ */
146
+ fnDefaultGetAPIKey: () => Promise<string>;
147
+ /** The initial "command" comment ibgib created at bootstrap time. */
148
+ initialCommentIbGib?: IbGib_V1;
149
+ /** Live proxy wrapping {@link initialCommentIbGib} for reactive subscriptions. */
150
+ initialCommentIbGibProxy?: LiveProxyIbGib;
151
+ /**
152
+ * Optional identity context. Populated by the consumer's resolveIdentity()
153
+ * callback in the bootstrap options.
154
+ *
155
+ * - `undefined`: no identity mechanism configured
156
+ * - `null`: identity resolution was attempted; user is unauthenticated
157
+ * - `IbGibIdentityContext`: identity resolved (check `.authenticated`)
158
+ *
159
+ * @see {@link IbGibIdentityContext}
160
+ */
161
+ identity?: IbGibIdentityContext | null;
162
+ }
163
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../src/app-bootstrap/types.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,uDAAuD,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,MAAM,4CAA4C,CAAC;AAEzE,OAAO,EAAE,cAAc,EAAE,MAAM,2DAA2D,CAAC;AAC3F,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAMnD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,yBAAyB;IACtC,qCAAqC;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,kFAAkF;IAClF,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,gEAAgE;IAChE,UAAU,EAAE,MAAM,CAAC;CACtB;AAMD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,GAAG,EAAE,MAAM,CAAC;CACf;AAMD,0CAA0C;AAC1C,MAAM,WAAW,qBA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C;;;;;;;;;OASG;IACH,QAAQ,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;CAC1C"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @module types
3
+ *
4
+ * Shared type definitions for ibgib-based frontend apps.
5
+ *
6
+ * ## notes
7
+ *
8
+ * Three layers of globalThis state:
9
+ * IbGibGlobalThisInfo (@ibgib/web-gib — the root ibgib slot)
10
+ * └── IbGibGlobalThis_Common (bootstrap promise tracking)
11
+ * └── IbGibGlobalThis_IbGibApp (all ibgib App witness apps)
12
+ * └── IbGibGlobalThis_[AppName] (per-app extensions)
13
+ */
14
+ export {};
15
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/app-bootstrap/types.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibgib/web-gib",
3
- "version": "0.0.28",
3
+ "version": "0.0.29",
4
4
  "description": "Framework for creating agentic ibGib web apps. Contains plumbing for ibgib components, agentic framework (currently only Gemini implemented), web-based IndexedDB storage substrate, and more.",
5
5
  "funding": {
6
6
  "type": "individual",
@@ -11,4 +11,4 @@
11
11
  /**
12
12
  * this is the version of this package, auto-updated in the build process
13
13
  */
14
- export const AUTO_GENERATED_VERSION = '0.0.28';
14
+ export const AUTO_GENERATED_VERSION = '0.0.29';