@ibgib/web-gib 0.0.23 → 0.0.26
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/AUTO-GENERATED-version.d.mts +14 -0
- package/dist/AUTO-GENERATED-version.d.mts.map +1 -0
- package/dist/AUTO-GENERATED-version.mjs +14 -0
- package/dist/AUTO-GENERATED-version.mjs.map +1 -0
- package/package.json +4 -1
- package/src/AUTO-GENERATED-version.mts +14 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-add-core-engine/SKILL.md +81 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-add-core-engine/generate-id.js +9 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-add-core-engine/templates/bootstrap.mts.template +58 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-add-core-engine/templates/constants.mts.template +75 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-add-core-engine/templates/declarations.d.ts.template +9 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-add-core-engine/templates/helpers.web.mts.template +199 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-add-core-engine/templates/index.html.template +65 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-add-core-engine/templates/index.mts.template +61 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-add-core-engine/templates/types.mts.template +128 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-create-app-witness/SKILL.md +59 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-create-app-witness/templates/api/function-infos.web.mts.template +11 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-create-app-witness/templates/witness/app/app-v1.mts.template +124 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-create-app-witness/templates/witness/app/constants.mts.template +48 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-create-app-witness/templates/witness/app/helper.mts.template +72 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-create-app-witness/templates/witness/app/types.mts.template +38 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-create-component/SKILL.md +36 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-create-component/templates/components/component-name/component.css.template +26 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-create-component/templates/components/component-name/component.html.template +6 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-create-component/templates/components/component-name/component.mts.template +131 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-create-shell/SKILL.md +34 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-create-shell/templates/ui/shell/shell-constants.mts.template +10 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-create-shell/templates/ui/shell/shell-service.mts.template +139 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-create-shell/templates/ui/shell/shell-types.mts.template +6 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-enum-pattern/SKILL.md +153 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-get-pattern/SKILL.md +92 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-scaffold-app/SKILL.md +42 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-targeted-refactoring/SKILL.md +84 -0
- package/tools/auto-generated-agent-skills/skills/ibgib-targeted-refactoring/generate-id.js +9 -0
- package/tools/copy-agent-skills.js +51 -0
- package/{generate-version-file.js → tools/generate-version-file.js} +1 -1
- package/tools/init-agents.js +51 -10
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module auto-generated-version
|
|
3
|
+
*
|
|
4
|
+
* CHANGES TO THIS FILE NOT BE SAVED
|
|
5
|
+
*
|
|
6
|
+
* this is automatically updated in the build process.
|
|
7
|
+
*
|
|
8
|
+
* CHANGES TO THIS FILE NOT BE SAVED
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* this is the version of this package, auto-updated in the build process
|
|
12
|
+
*/
|
|
13
|
+
export declare const AUTO_GENERATED_VERSION = "0.0.26";
|
|
14
|
+
//# sourceMappingURL=AUTO-GENERATED-version.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AUTO-GENERATED-version.d.mts","sourceRoot":"","sources":["../src/AUTO-GENERATED-version.mts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;GAEG;AACH,eAAO,MAAM,sBAAsB,WAAW,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module auto-generated-version
|
|
3
|
+
*
|
|
4
|
+
* CHANGES TO THIS FILE NOT BE SAVED
|
|
5
|
+
*
|
|
6
|
+
* this is automatically updated in the build process.
|
|
7
|
+
*
|
|
8
|
+
* CHANGES TO THIS FILE NOT BE SAVED
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* this is the version of this package, auto-updated in the build process
|
|
12
|
+
*/
|
|
13
|
+
export const AUTO_GENERATED_VERSION = '0.0.26';
|
|
14
|
+
//# sourceMappingURL=AUTO-GENERATED-version.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AUTO-GENERATED-version.mjs","sourceRoot":"","sources":["../src/AUTO-GENERATED-version.mts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,QAAQ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibgib/web-gib",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.26",
|
|
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",
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
14
|
"clean": "node node_modules/@ibgib/helper-gib/tools/clean.js ./dist",
|
|
15
|
+
"generate:src:version": "node ./tools/generate-version-file.js",
|
|
16
|
+
"generate:agent:skills": "node ./tools/copy-agent-skills.js",
|
|
17
|
+
"prebuild": "npm run generate:src:version && npm run generate:agent:skills",
|
|
15
18
|
"build": "npm run clean && tsc -b tsconfig.json --force",
|
|
16
19
|
"build:test": "npm run clean && tsc -b tsconfig.test.json --force",
|
|
17
20
|
"build:test:noclean": "tsc -b tsconfig.test.json --force",
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module auto-generated-version
|
|
3
|
+
*
|
|
4
|
+
* CHANGES TO THIS FILE NOT BE SAVED
|
|
5
|
+
*
|
|
6
|
+
* this is automatically updated in the build process.
|
|
7
|
+
*
|
|
8
|
+
* CHANGES TO THIS FILE NOT BE SAVED
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* this is the version of this package, auto-updated in the build process
|
|
13
|
+
*/
|
|
14
|
+
export const AUTO_GENERATED_VERSION = '0.0.26';
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ibgib-add-core-engine
|
|
3
|
+
description: >
|
|
4
|
+
Scaffolds the foundational ibgib bootstrap flow and global state management.
|
|
5
|
+
Generates the 7 foundational files (index.html, index.mts, bootstrap.mts,
|
|
6
|
+
constants.mts, types.mts, helpers.web.mts, and style.css) required for an
|
|
7
|
+
ibgib app to boot. Supports both greenfield and brownfield projects.
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Skill: ibgib-add-core-engine
|
|
11
|
+
|
|
12
|
+
## What This Skill Does
|
|
13
|
+
|
|
14
|
+
Generates the engineering foundation for an ibgib app. This includes:
|
|
15
|
+
- **Global State**: Wiring `globalThis.ibgib` with the appropriate app-specific sub-objects.
|
|
16
|
+
- **Bootstrap flow**: Handling `DOMContentLoaded` and asynchronously loading the heavy ibgib engine.
|
|
17
|
+
- **Storage**: Initializing IndexedDB spaces.
|
|
18
|
+
- **Types & Helpers**: Providing the basic framework for identity and witness coordination.
|
|
19
|
+
|
|
20
|
+
This skill is often the first step in creating a new app, or used to "ibgib-ify" an existing project. It does NOT generate the App Witness (the business logic) or the UI Shell; use `ibgib-create-app-witness` and `ibgib-create-shell` for those.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Pre-Requisites (check before running)
|
|
25
|
+
|
|
26
|
+
1. Confirm the target directory exists or ask where to create files.
|
|
27
|
+
2. Verify that `@ibgib/ts-gib`, `@ibgib/helper-gib`, `@ibgib/core-gib`, and
|
|
28
|
+
`@ibgib/web-gib` are available in the workspace.
|
|
29
|
+
3. Confirm the project has an `AUTO-GENERATED-version.mts` file, or note that
|
|
30
|
+
one is needed.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Token Reference
|
|
35
|
+
|
|
36
|
+
| Token | Example value | How it's computed |
|
|
37
|
+
|---|---|---|
|
|
38
|
+
| `{{APP_HUMAN_NAME}}` | `PulmonIQ Learning` | Asked of developer |
|
|
39
|
+
| `{{APP_NAME_UPPER}}` | `PULMONIQ_LEARNING` | Uppercase + underscores of app name |
|
|
40
|
+
| `{{APP_CLASSNAME_PREFIX}}` | `PulmoniqLearning` | PascalCase, no suffix |
|
|
41
|
+
| `{{APP_DIR_NAME}}` | `pulmoniq-learning` | kebab-case |
|
|
42
|
+
| `{{DB_NAME}}` | `pulmoniq_learning_db` | Asked of developer |
|
|
43
|
+
| `{{STORE_NAME}}` | `pulmoniq_learning_store` | Asked of developer |
|
|
44
|
+
| `{{APP_UUID}}` | `8d6217327e6490650169be9cb22a0b25` | **Generated fresh** with `generate-id.js`. |
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Generation Steps
|
|
49
|
+
|
|
50
|
+
### 1. Confirm token values
|
|
51
|
+
|
|
52
|
+
Derive tokens from the developer's answers. Generate a fresh `{{APP_UUID}}` using:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
node .agents/skills/ibgib-add-core-engine/generate-id.js
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 2. Generate all files
|
|
59
|
+
|
|
60
|
+
Apply token substitutions to templates in `templates/` and write to the target directory (`src/` by default).
|
|
61
|
+
|
|
62
|
+
| Template file | Output file |
|
|
63
|
+
|---|---|
|
|
64
|
+
| `templates/index.html.template` | `index.html` |
|
|
65
|
+
| `templates/index.mts.template` | `index.mts` |
|
|
66
|
+
| `templates/bootstrap.mts.template` | `bootstrap.mts` |
|
|
67
|
+
| `templates/constants.mts.template` | `constants.mts` |
|
|
68
|
+
| `templates/types.mts.template` | `types.mts` |
|
|
69
|
+
| `templates/helpers.web.mts.template` | `helpers.web.mts` |
|
|
70
|
+
| `templates/style.css.template` | `style.css` (if missing) |
|
|
71
|
+
|
|
72
|
+
### 3. Replace `genuuid` placeholders
|
|
73
|
+
|
|
74
|
+
Replace every `(I: genuuid)`, `(W: genuuid)`, etc., with unique IDs from `generate-id.js`.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Reference Implementations
|
|
79
|
+
|
|
80
|
+
- **Standalone Pattern**: These templates are designed to be self-contained. They import from shared `@ibgib/*` packages and use standard relative paths for app-internal files.
|
|
81
|
+
- **Library Integration (Optional)**: If the project uses a shared framework layer (like a `common` library), manually update imports in the generated files to point to that layer after scaffolding.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const crypto = require('crypto');
|
|
2
|
+
|
|
3
|
+
const yearStr = new Date().getFullYear().toString().slice(-2);
|
|
4
|
+
|
|
5
|
+
for (let i = 0; i < 10; i++) {
|
|
6
|
+
const hash = crypto.createHash('md5').update(crypto.randomBytes(16)).digest('hex');
|
|
7
|
+
const id = hash.slice(0, 30) + yearStr;
|
|
8
|
+
console.log(id);
|
|
9
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module bootstrap
|
|
3
|
+
*
|
|
4
|
+
* Startup code for ibgib-specific things: initializing the metaspace and
|
|
5
|
+
* starting the {{APP_HUMAN_NAME}} app.
|
|
6
|
+
*
|
|
7
|
+
* Called dynamically by index.mts AFTER initial page render, so the heavy
|
|
8
|
+
* ibgib import graph doesn't block first paint.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { bootstrapIbGibApp } from "../../../libs/ibgib-common/dist/bootstrap.mjs";
|
|
12
|
+
|
|
13
|
+
import { APP_CONFIG, GLOBAL_LOG_A_LOT } from "./constants.mjs";
|
|
14
|
+
import { getIbGibGlobalThis_{{APP_CLASSNAME_PREFIX}} } from "./helpers.web.mjs";
|
|
15
|
+
import { {{APP_CLASSNAME}} } from "./witness/app/{{APP_DIR_NAME}}/{{APP_DIR_NAME}}-app-v1.mjs";
|
|
16
|
+
import { PARAM_INFOS } from "./witness/app/{{APP_DIR_NAME}}/{{APP_DIR_NAME}}-constants.mjs";
|
|
17
|
+
import { DEFAULT_{{APP_NAME_UPPER}}_APP_DATA_V1 } from "./witness/app/{{APP_DIR_NAME}}/{{APP_DIR_NAME}}-types.mjs";
|
|
18
|
+
import { AUTO_GENERATED_VERSION } from "./AUTO-GENERATED-version.mjs";
|
|
19
|
+
import { registerDeprecatedFunctionNamesAndFunctionInfos_Web } from "./api/function-infos.web.mjs";
|
|
20
|
+
|
|
21
|
+
// {{OPTIONAL_SHELL_IMPORT}}
|
|
22
|
+
// import { get{{APP_CLASSNAME_PREFIX}}ShellSvc } from "./ui/shell/{{APP_DIR_NAME}}-shell-service.mjs";
|
|
23
|
+
|
|
24
|
+
// {{OPTIONAL_IDENTITY_IMPORT}}
|
|
25
|
+
// import { resolveIdentity } from "./identity/{{APP_DIR_NAME}}-identity.mjs";
|
|
26
|
+
|
|
27
|
+
console.log(`[{{APP_DIR_NAME}} bootstrap] version: ${AUTO_GENERATED_VERSION}`);
|
|
28
|
+
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
// Main entry point
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
|
|
33
|
+
export async function bootstrap{{APP_CLASSNAME_PREFIX}}App() {
|
|
34
|
+
await bootstrapIbGibApp({
|
|
35
|
+
config: APP_CONFIG,
|
|
36
|
+
getGlobalThis: getIbGibGlobalThis_{{APP_CLASSNAME_PREFIX}},
|
|
37
|
+
AppClass: {{APP_CLASSNAME}},
|
|
38
|
+
defaultAppData: DEFAULT_{{APP_NAME_UPPER}}_APP_DATA_V1,
|
|
39
|
+
paramInfos: PARAM_INFOS,
|
|
40
|
+
registerAgentFunctionInfos: registerDeprecatedFunctionNamesAndFunctionInfos_Web,
|
|
41
|
+
|
|
42
|
+
// {{OPTIONAL_IDENTITY_BLOCK_START}}
|
|
43
|
+
// resolveIdentity: async (metaspace) => {
|
|
44
|
+
// const identity = await resolveIdentity(metaspace);
|
|
45
|
+
// window.dispatchEvent(new CustomEvent('ibgib-identity-resolved', {
|
|
46
|
+
// detail: { identity }
|
|
47
|
+
// }));
|
|
48
|
+
// return identity;
|
|
49
|
+
// },
|
|
50
|
+
// {{OPTIONAL_IDENTITY_BLOCK_END}}
|
|
51
|
+
|
|
52
|
+
onReady: async (app) => {
|
|
53
|
+
if (GLOBAL_LOG_A_LOT) { console.log(`[bootstrap{{APP_CLASSNAME_PREFIX}}App] Engine ready. app: ${app?.ib}`); }
|
|
54
|
+
// {{OPTIONAL_SHELL_ONREADY}}
|
|
55
|
+
// await get{{APP_CLASSNAME_PREFIX}}ShellSvc().onEngineReady();
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { tagTextToIb } from "@ibgib/core-gib/dist/common/other/ibgib-helper.mjs";
|
|
2
|
+
import { ZERO_SPACE_ID } from "@ibgib/core-gib/dist/witness/space/space-constants.mjs";
|
|
3
|
+
|
|
4
|
+
import { IbGibAmbientContextConfig } from "./types.mjs";
|
|
5
|
+
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
// Logging / debug
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
export const GLOBAL_LOG_A_LOT = false;
|
|
11
|
+
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// Storage — unique per app instance
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
export const {{APP_NAME_UPPER}}_DB_NAME = '{{DB_NAME}}';
|
|
17
|
+
export const {{APP_NAME_UPPER}}_STORE_NAME = '{{STORE_NAME}}';
|
|
18
|
+
export const {{APP_NAME_UPPER}}_API_KEY_NAME = '{{API_KEY_NAME}}';
|
|
19
|
+
|
|
20
|
+
export const {{APP_NAME_UPPER}}_INDEXEDDB_KEY_LOCAL_SPACE_NAME = 'local_space_name';
|
|
21
|
+
/**
|
|
22
|
+
* Prefix for the automatically generated local space name on first visit.
|
|
23
|
+
* A random suffix is appended at runtime.
|
|
24
|
+
*/
|
|
25
|
+
export const {{APP_NAME_UPPER}}_INDEXEDDB_LOCAL_SPACE_NAME_PREFIX = '{{SPACE_NAME_PREFIX}}';
|
|
26
|
+
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
// App identity discriminator
|
|
29
|
+
//
|
|
30
|
+
// NOTE: This value MUST be unique per app. It is used by
|
|
31
|
+
// isExecutingInBlankGibWebAppProper() to distinguish the top-level shell from
|
|
32
|
+
// embedded iframes. Generate a fresh UUID when creating a new app.
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
|
|
35
|
+
export const HTML_META_APP_ID_NAME = "ibgib-app-id";
|
|
36
|
+
export const HTML_META_APP_ID_CONTENT = "{{APP_UUID}}";
|
|
37
|
+
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
// Agent / AI
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
|
|
42
|
+
export const GEMINI_API_KEY_REGEXP = /^[a-zA-Z0-9\-_]{32,64}$/;
|
|
43
|
+
export const CONFIG_OPTION_GEMINI_API_KEY_LOCATION_HELP = `Gemini API Key config option (⚙️ icon)`;
|
|
44
|
+
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
// Tags
|
|
47
|
+
// ---------------------------------------------------------------------------
|
|
48
|
+
|
|
49
|
+
export const TAG_AGENT_TEXT = "agent";
|
|
50
|
+
export const TAG_AGENT_ICON = "body-outline";
|
|
51
|
+
export const TAG_AGENT_DESCRIPTION =
|
|
52
|
+
"This tag tracks the active agents for the current local user space.";
|
|
53
|
+
export const TAG_AGENT_IB = tagTextToIb(TAG_AGENT_TEXT);
|
|
54
|
+
|
|
55
|
+
// ---------------------------------------------------------------------------
|
|
56
|
+
// Colors
|
|
57
|
+
// ---------------------------------------------------------------------------
|
|
58
|
+
|
|
59
|
+
export const DEFAULT_IBGIB_COLOR = '#78f87e88';
|
|
60
|
+
export const DEFAULT_IBGIB_TRANSLUCENT = '#78f87e10';
|
|
61
|
+
export const DEFAULT_IBGIB_COLOR_CONTRAST = '#ffffff';
|
|
62
|
+
export const DEFAULT_TJP_COLOR = '#78f87e88';
|
|
63
|
+
export const DEFAULT_TJP_COLOR_TRANSLUCENT = '#78f87e10';
|
|
64
|
+
export const DEFAULT_TJP_COLOR_CONTRAST = '#ffffff';
|
|
65
|
+
|
|
66
|
+
// ---------------------------------------------------------------------------
|
|
67
|
+
// Ambient context config — the single config object passed through the app
|
|
68
|
+
// ---------------------------------------------------------------------------
|
|
69
|
+
|
|
70
|
+
export const APP_CONFIG: IbGibAmbientContextConfig = {
|
|
71
|
+
dbName: {{APP_NAME_UPPER}}_DB_NAME,
|
|
72
|
+
storeName: {{APP_NAME_UPPER}}_STORE_NAME,
|
|
73
|
+
additionalStoreNames: [ZERO_SPACE_ID],
|
|
74
|
+
apiKeyName: {{APP_NAME_UPPER}}_API_KEY_NAME,
|
|
75
|
+
};
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module helpers.web
|
|
3
|
+
*
|
|
4
|
+
* Web-specific helper functions. Handles storage initialization, globalThis
|
|
5
|
+
* wiring, and dynamic script loading.
|
|
6
|
+
*
|
|
7
|
+
* NOTE: initIbGibStorage, initIbGibGlobalThis, and dynamicallyLoadBootstrapScript
|
|
8
|
+
* are candidates for upstreaming into @ibgib/web-gib.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { extractErrorMsg } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
|
|
12
|
+
import { storageGet } from "@ibgib/web-gib/dist/storage/storage-helpers.web.mjs";
|
|
13
|
+
import { initAppStorage } from "@ibgib/web-gib/dist/helpers.web.mjs";
|
|
14
|
+
import { getGlobalMetaspace_waitIfNeeded } from "@ibgib/web-gib/dist/helpers.mjs";
|
|
15
|
+
import { IbGibDynamicComponentMetaCtorOpts } from "@ibgib/web-gib/dist/ui/component/component-types.mjs";
|
|
16
|
+
import { IbGibGlobalThisInfo } from "@ibgib/web-gib/dist/types.mjs";
|
|
17
|
+
import { delay } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
|
|
18
|
+
|
|
19
|
+
import { GLOBAL_LOG_A_LOT } from "./constants.mjs";
|
|
20
|
+
import { AUTO_GENERATED_VERSION } from "./AUTO-GENERATED-version.mjs";
|
|
21
|
+
import {
|
|
22
|
+
IbGibAmbientContextConfig,
|
|
23
|
+
IbGibGlobalThis_{{APP_CLASSNAME_PREFIX}},
|
|
24
|
+
IbGibGlobalThis_Common,
|
|
25
|
+
} from "./types.mjs";
|
|
26
|
+
|
|
27
|
+
const logalot = GLOBAL_LOG_A_LOT;
|
|
28
|
+
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
// Storage initialization
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Initializes the IndexedDB stores required by this app.
|
|
35
|
+
* Call once on DOMContentLoaded, before bootstrap.
|
|
36
|
+
*/
|
|
37
|
+
export async function initIbGibStorage(config: IbGibAmbientContextConfig): Promise<void> {
|
|
38
|
+
const lc = `[${initIbGibStorage.name}]`;
|
|
39
|
+
try {
|
|
40
|
+
if (logalot) { console.log(`${lc} starting... (I: genuuid)`); }
|
|
41
|
+
await initAppStorage({
|
|
42
|
+
infos: [
|
|
43
|
+
{
|
|
44
|
+
dbName: config.dbName,
|
|
45
|
+
storeNames: [config.storeName, ...(config.additionalStoreNames ?? [])],
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
});
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
51
|
+
throw error;
|
|
52
|
+
} finally {
|
|
53
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// ---------------------------------------------------------------------------
|
|
58
|
+
// globalThis initialization
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Sets up globalThis.ibgib.{{APP_GLOBALTHIS_KEY}} once.
|
|
63
|
+
* Safe to call multiple times (idempotent).
|
|
64
|
+
*/
|
|
65
|
+
export function initIbGibGlobalThis(config: IbGibAmbientContextConfig): void {
|
|
66
|
+
const lc = `[${initIbGibGlobalThis.name}]`;
|
|
67
|
+
try {
|
|
68
|
+
if (logalot) { console.log(`${lc} starting... (I: genuuid)`); }
|
|
69
|
+
|
|
70
|
+
if (!(globalThis as any).ibgib) {
|
|
71
|
+
(globalThis as any).ibgib = {
|
|
72
|
+
dbName_hack: config.dbName,
|
|
73
|
+
apiKeyName_hack: config.apiKeyName,
|
|
74
|
+
storeName_hack: config.storeName,
|
|
75
|
+
} satisfies IbGibGlobalThisInfo;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (!(globalThis as any).ibgib.{{APP_GLOBALTHIS_KEY}}) {
|
|
79
|
+
(globalThis as any).ibgib.{{APP_GLOBALTHIS_KEY}} = {
|
|
80
|
+
version: AUTO_GENERATED_VERSION,
|
|
81
|
+
spaceShim: {},
|
|
82
|
+
fnDefaultGetAPIKey: async () => {
|
|
83
|
+
const apiKey = await storageGet({
|
|
84
|
+
dbName: config.dbName,
|
|
85
|
+
storeName: config.storeName,
|
|
86
|
+
key: config.apiKeyName,
|
|
87
|
+
});
|
|
88
|
+
return apiKey ?? '';
|
|
89
|
+
},
|
|
90
|
+
dbName_hack: config.dbName,
|
|
91
|
+
apiKeyName_hack: config.apiKeyName,
|
|
92
|
+
storeName_hack: config.storeName,
|
|
93
|
+
} satisfies IbGibGlobalThis_{{APP_CLASSNAME_PREFIX}};
|
|
94
|
+
}
|
|
95
|
+
} catch (error) {
|
|
96
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
97
|
+
throw error;
|
|
98
|
+
} finally {
|
|
99
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// ---------------------------------------------------------------------------
|
|
104
|
+
// GlobalThis accessors
|
|
105
|
+
// ---------------------------------------------------------------------------
|
|
106
|
+
|
|
107
|
+
export function getIbGibGlobalThis_{{APP_CLASSNAME_PREFIX}}(
|
|
108
|
+
config?: IbGibAmbientContextConfig
|
|
109
|
+
): IbGibGlobalThis_{{APP_CLASSNAME_PREFIX}} {
|
|
110
|
+
if (!(globalThis as any).ibgib?.{{APP_GLOBALTHIS_KEY}}) {
|
|
111
|
+
if (!config) {
|
|
112
|
+
throw new Error(`Global context not initialized and config not provided.`);
|
|
113
|
+
}
|
|
114
|
+
initIbGibGlobalThis(config);
|
|
115
|
+
}
|
|
116
|
+
return (globalThis as any).ibgib.{{APP_GLOBALTHIS_KEY}} as IbGibGlobalThis_{{APP_CLASSNAME_PREFIX}};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function getIbGibGlobalThis_Common(): IbGibGlobalThis_Common {
|
|
120
|
+
const g = (globalThis as any).ibgib?.{{APP_GLOBALTHIS_KEY}};
|
|
121
|
+
if (!g) {
|
|
122
|
+
throw new Error(`(UNEXPECTED) globalThis.ibgib.{{APP_GLOBALTHIS_KEY}} not initialized.`);
|
|
123
|
+
}
|
|
124
|
+
return g as IbGibGlobalThis_Common;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// ---------------------------------------------------------------------------
|
|
128
|
+
// API key helper
|
|
129
|
+
// ---------------------------------------------------------------------------
|
|
130
|
+
|
|
131
|
+
export function getDefaultFnGetAPIKey(): () => Promise<string> {
|
|
132
|
+
return async () => {
|
|
133
|
+
const gb = getIbGibGlobalThis_{{APP_CLASSNAME_PREFIX}}();
|
|
134
|
+
return (await storageGet({
|
|
135
|
+
dbName: gb.dbName_hack,
|
|
136
|
+
storeName: gb.storeName_hack,
|
|
137
|
+
key: gb.apiKeyName_hack,
|
|
138
|
+
})) ?? '';
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// ---------------------------------------------------------------------------
|
|
143
|
+
// Dynamic bootstrap loading
|
|
144
|
+
// ---------------------------------------------------------------------------
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Dynamically imports the bootstrap module and calls the app's bootstrap
|
|
148
|
+
* function. Called after DOMContentLoaded so the initial page render is not
|
|
149
|
+
* blocked by the heavy ibgib import graph.
|
|
150
|
+
*/
|
|
151
|
+
export async function dynamicallyLoadBootstrapScript(path: string): Promise<void> {
|
|
152
|
+
const lc = `[${dynamicallyLoadBootstrapScript.name}]`;
|
|
153
|
+
try {
|
|
154
|
+
if (logalot) { console.log(`${lc} starting... (I: genuuid)`); }
|
|
155
|
+
const module = await import(path);
|
|
156
|
+
await module.bootstrap{{APP_CLASSNAME_PREFIX}}App();
|
|
157
|
+
} catch (error) {
|
|
158
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
159
|
+
throw error;
|
|
160
|
+
} finally {
|
|
161
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// ---------------------------------------------------------------------------
|
|
166
|
+
// Component constructor args helper
|
|
167
|
+
// ---------------------------------------------------------------------------
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Returns the standard ctor options for IbGib dynamic components, including
|
|
171
|
+
* a bootstrap promise wrapper so components can await app readiness.
|
|
172
|
+
*/
|
|
173
|
+
export function getComponentCtorArg(): IbGibDynamicComponentMetaCtorOpts {
|
|
174
|
+
const fnGetMetaspace = async () => getGlobalMetaspace_waitIfNeeded();
|
|
175
|
+
|
|
176
|
+
const bootstrapPromiseWrapper = new Promise<void>(async (resolve, reject) => {
|
|
177
|
+
try {
|
|
178
|
+
let maxTries = 100_000;
|
|
179
|
+
let counter = 0;
|
|
180
|
+
let bootstrapPromise: Promise<void> | undefined;
|
|
181
|
+
do {
|
|
182
|
+
bootstrapPromise =
|
|
183
|
+
getIbGibGlobalThis_{{APP_CLASSNAME_PREFIX}}()?.bootstrapPromise;
|
|
184
|
+
counter++;
|
|
185
|
+
if (counter > maxTries) { break; }
|
|
186
|
+
await delay(10);
|
|
187
|
+
} while (bootstrapPromise === undefined);
|
|
188
|
+
if (!bootstrapPromise) {
|
|
189
|
+
throw new Error(`Timed out waiting for bootstrapPromise. (E: genuuid)`);
|
|
190
|
+
}
|
|
191
|
+
await bootstrapPromise;
|
|
192
|
+
resolve();
|
|
193
|
+
} catch (error) {
|
|
194
|
+
reject(error);
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
return { fnGetMetaspace, bootstrapPromise: bootstrapPromiseWrapper };
|
|
199
|
+
}
|
package/tools/auto-generated-agent-skills/skills/ibgib-add-core-engine/templates/index.html.template
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en-US">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<!--
|
|
8
|
+
HTML_META_APP_ID: Used by isExecutingInBlankGibWebAppProper() to detect
|
|
9
|
+
whether code is running in the top-level shell vs. an embedded iframe.
|
|
10
|
+
The content value MUST be unique per app (generate a fresh UUID at scaffold time).
|
|
11
|
+
-->
|
|
12
|
+
<meta name="ibgib-app-id" content="{{APP_UUID}}" />
|
|
13
|
+
<title>{{APP_HUMAN_NAME}}</title>
|
|
14
|
+
<link rel="stylesheet" type="text/css" href="style.css">
|
|
15
|
+
<script type="module" src="index.mjs" defer></script>
|
|
16
|
+
</head>
|
|
17
|
+
|
|
18
|
+
<body>
|
|
19
|
+
<!--
|
|
20
|
+
REQUIRED: fullscreen-dialog
|
|
21
|
+
This block is required by @ibgib/web-gib helper functions (alertUser,
|
|
22
|
+
promptForText, promptForSecret, promptForConfirm). Do not remove or rename
|
|
23
|
+
the element IDs prefixed with "fullscreen-dialog-".
|
|
24
|
+
-->
|
|
25
|
+
<dialog id="fullscreen-dialog" class="fullscreen-dialog">
|
|
26
|
+
<div id="fullscreen-dialog-content" class="fullscreen-dialog-content">
|
|
27
|
+
<div id="fullscreen-dialog-header" class="fullscreen-dialog-header">
|
|
28
|
+
<h2 id="fullscreen-dialog-title"></h2>
|
|
29
|
+
</div>
|
|
30
|
+
<div id="fullscreen-dialog-body" class="fullscreen-dialog-body">
|
|
31
|
+
<div id="fullscreen-dialog-message" class="fullscreen-dialog-message"></div>
|
|
32
|
+
<input type="text" id="fullscreen-dialog-prompt-input" class="collapsed">
|
|
33
|
+
</div>
|
|
34
|
+
<div id="fullscreen-dialog-footer" class="fullscreen-dialog-footer">
|
|
35
|
+
<button id="fullscreen-dialog-ok-button" class="dialog-button">OK</button>
|
|
36
|
+
<button id="fullscreen-dialog-cancel-button" class="dialog-button">Cancel</button>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
</dialog>
|
|
40
|
+
|
|
41
|
+
<!--
|
|
42
|
+
SHELL: Everything below this line is the consumer's responsibility.
|
|
43
|
+
|
|
44
|
+
The ibgib framework does not prescribe any layout. Replace the content of
|
|
45
|
+
<body> beyond the dialog above with whatever shell your app needs:
|
|
46
|
+
- HTML panels (see apps/learning or tmp/blank-gib for examples)
|
|
47
|
+
- A <canvas> element for a game engine frontend
|
|
48
|
+
- Nothing (if the app has no visual shell — e.g. a background worker)
|
|
49
|
+
|
|
50
|
+
The framework calls your onReady() callback (configured in bootstrap.mts)
|
|
51
|
+
when the metaspace and App witness are initialized. Wire your shell to
|
|
52
|
+
that callback.
|
|
53
|
+
|
|
54
|
+
If your app uses identity, listen for the 'ibgib-identity-resolved' window
|
|
55
|
+
event to update the shell's auth state.
|
|
56
|
+
-->
|
|
57
|
+
|
|
58
|
+
<div id="app-root">
|
|
59
|
+
<!-- Replace this placeholder with your actual shell markup -->
|
|
60
|
+
<p>{{APP_HUMAN_NAME}} shell loading...</p>
|
|
61
|
+
</div>
|
|
62
|
+
|
|
63
|
+
</body>
|
|
64
|
+
|
|
65
|
+
</html>
|
package/tools/auto-generated-agent-skills/skills/ibgib-add-core-engine/templates/index.mts.template
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
2
|
+
|
|
3
|
+
import { GLOBAL_LOG_A_LOT, APP_CONFIG } from './constants.mjs';
|
|
4
|
+
import {
|
|
5
|
+
initIbGibStorage,
|
|
6
|
+
initIbGibGlobalThis,
|
|
7
|
+
dynamicallyLoadBootstrapScript,
|
|
8
|
+
} from './helpers.web.mjs';
|
|
9
|
+
|
|
10
|
+
// {{OPTIONAL_ROUTER_IMPORT}}
|
|
11
|
+
// import { simpleIbGibRouterSingleton as router } from './ui/router/router-one-file.mjs';
|
|
12
|
+
|
|
13
|
+
initIbGibGlobalThis(APP_CONFIG);
|
|
14
|
+
|
|
15
|
+
const logalot = GLOBAL_LOG_A_LOT;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Initiates startup without blocking DOMContentLoaded.
|
|
19
|
+
*
|
|
20
|
+
* Sequence:
|
|
21
|
+
* 1. Init IndexedDB storage
|
|
22
|
+
* 2. (Optional) trigger shell / router
|
|
23
|
+
* 3. Dynamically import bootstrap.mts — the heavy ibgib graph loads here
|
|
24
|
+
*/
|
|
25
|
+
async function spinOffStartup(): Promise<void> {
|
|
26
|
+
const lc = `[${spinOffStartup.name}]`;
|
|
27
|
+
try {
|
|
28
|
+
if (logalot) { console.log(`${lc} starting... (I: genuuid)`); }
|
|
29
|
+
console.time(lc);
|
|
30
|
+
|
|
31
|
+
document.addEventListener('DOMContentLoaded', async () => {
|
|
32
|
+
try {
|
|
33
|
+
console.timeLog(lc, 'DOMContentLoaded fired');
|
|
34
|
+
|
|
35
|
+
await initIbGibStorage(APP_CONFIG);
|
|
36
|
+
console.timeLog(lc, 'initIbGibStorage complete');
|
|
37
|
+
|
|
38
|
+
// {{OPTIONAL_ROUTER_CALL}}
|
|
39
|
+
// router.loadCurrentURLPath();
|
|
40
|
+
|
|
41
|
+
await dynamicallyLoadBootstrapScript('./bootstrap.mjs');
|
|
42
|
+
console.timeLog(lc, 'dynamicallyLoadBootstrapScript complete');
|
|
43
|
+
|
|
44
|
+
console.timeEnd(lc);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.timeEnd(lc);
|
|
53
|
+
debugger; // error in index.mts — investigate immediately
|
|
54
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
55
|
+
throw error;
|
|
56
|
+
} finally {
|
|
57
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
spinOffStartup();
|