jsgui3-server 0.0.150 → 0.0.152
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/.github/instructions/copilot.instructions.md +1 -0
- package/AGENTS.md +2 -0
- package/README.md +89 -13
- package/admin-ui/v1/controls/admin_shell.js +702 -669
- package/admin-ui/v1/server.js +14 -1
- package/docs/api-reference.md +504 -306
- package/docs/books/creating-a-new-admin-ui/README.md +20 -20
- package/docs/books/website-design/01-introduction.md +73 -0
- package/docs/books/website-design/02-current-state.md +195 -0
- package/docs/books/website-design/03-base-class.md +181 -0
- package/docs/books/website-design/04-webpage.md +307 -0
- package/docs/books/website-design/05-website.md +456 -0
- package/docs/books/website-design/06-pages-storage.md +170 -0
- package/docs/books/website-design/07-api-layer.md +285 -0
- package/docs/books/website-design/08-server-integration.md +271 -0
- package/docs/books/website-design/09-cross-agent-review.md +190 -0
- package/docs/books/website-design/10-open-questions.md +196 -0
- package/docs/books/website-design/11-converged-recommendation.md +205 -0
- package/docs/books/website-design/12-content-model.md +395 -0
- package/docs/books/website-design/13-webpage-module-spec.md +404 -0
- package/docs/books/website-design/14-website-module-spec.md +541 -0
- package/docs/books/website-design/15-multi-repo-plan.md +275 -0
- package/docs/books/website-design/16-minimal-first.md +203 -0
- package/docs/books/website-design/17-implementation-report-codex.md +81 -0
- package/docs/books/website-design/README.md +43 -0
- package/docs/comprehensive-documentation.md +220 -220
- package/docs/configuration-reference.md +281 -204
- package/docs/middleware-guide.md +236 -0
- package/docs/proposals/jsgui3-website-and-webpage-design-jsgui3-server-support.md +257 -0
- package/docs/proposals/jsgui3-website-and-webpage-design-review.md +73 -0
- package/docs/proposals/jsgui3-website-and-webpage-design.md +732 -0
- package/docs/swagger.md +316 -0
- package/docs/system-architecture.md +24 -18
- package/examples/controls/1) window/server.js +6 -1
- package/examples/controls/21) mvvm and declarative api/check.js +94 -0
- package/examples/controls/21) mvvm and declarative api/check_output.txt +25 -0
- package/examples/controls/21) mvvm and declarative api/check_output_2.txt +27 -0
- package/examples/controls/21) mvvm and declarative api/client.js +241 -0
- declarative api/e2e-screenshot-1-name-change.png +0 -0
- declarative api/e2e-screenshot-2-toggled.png +0 -0
- declarative api/e2e-screenshot-3-final.png +0 -0
- declarative api/e2e-screenshot-final.png +0 -0
- package/examples/controls/21) mvvm and declarative api/e2e-test.js +175 -0
- package/examples/controls/21) mvvm and declarative api/out.html +1 -0
- package/examples/controls/21) mvvm and declarative api/page_out.html +1 -0
- package/examples/controls/21) mvvm and declarative api/server.js +18 -0
- package/examples/data-views/01) query-endpoint/server.js +61 -0
- package/labs/website-design/001-base-class-overhead/check.js +162 -0
- package/labs/website-design/002-pages-storage/check.js +244 -0
- package/labs/website-design/002-pages-storage/results.txt +0 -0
- package/labs/website-design/003-type-detection/check.js +193 -0
- package/labs/website-design/003-type-detection/results.txt +0 -0
- package/labs/website-design/004-two-stage-validation/check.js +314 -0
- package/labs/website-design/004-two-stage-validation/results.txt +0 -0
- package/labs/website-design/005-normalize-input/check.js +303 -0
- package/labs/website-design/006-serve-website-spike/check.js +290 -0
- package/labs/website-design/README.md +34 -0
- package/labs/website-design/manifest.json +68 -0
- package/labs/website-design/run-all.js +60 -0
- package/middleware/compression.js +217 -0
- package/middleware/index.js +15 -0
- package/middleware/json-body.js +126 -0
- package/module.js +3 -0
- package/openapi.js +474 -0
- package/package.json +11 -8
- package/publishers/Publishers.js +6 -5
- package/publishers/http-function-publisher.js +135 -126
- package/publishers/http-webpage-publisher.js +89 -11
- package/publishers/query-publisher.js +116 -0
- package/publishers/swagger-publisher.js +203 -0
- package/publishers/swagger-ui.js +578 -0
- package/resources/adapters/array-adapter.js +143 -0
- package/resources/query-resource.js +131 -0
- package/serve-factory.js +756 -18
- package/server.js +502 -123
- package/tests/README.md +23 -1
- package/tests/admin-ui-jsgui-controls.test.js +16 -1
- package/tests/helpers/playwright-e2e-harness.js +326 -0
- package/tests/openapi.test.js +319 -0
- package/tests/playwright-smoke.test.js +134 -0
- package/tests/publish-enhancements.test.js +673 -0
- package/tests/query-publisher.test.js +430 -0
- package/tests/quick-json-body-test.js +169 -0
- package/tests/serve.test.js +425 -122
- package/tests/swagger-publisher.test.js +1076 -0
- package/tests/test-runner.js +1 -0
|
@@ -15,7 +15,7 @@ This document provides detailed technical documentation for the JSGUI3 Server fr
|
|
|
15
15
|
- You're troubleshooting complex issues or performance problems
|
|
16
16
|
- You need to understand deployment, security, and production considerations
|
|
17
17
|
|
|
18
|
-
**Note:** Start with [README.md](../README.md) for project overview and basic usage. For server API design principles, see [docs/simple-server-api-design.md](docs/simple-server-api-design.md). For bundling internals and elimination strategy research, see [docs/books/jsgui3-bundling-research-book/README.md](docs/books/jsgui3-bundling-research-book/README.md).
|
|
18
|
+
**Note:** Start with [README.md](../README.md) for project overview and basic usage. For server API design principles, see [docs/simple-server-api-design.md](docs/simple-server-api-design.md). For bundling internals and elimination strategy research, see [docs/books/jsgui3-bundling-research-book/README.md](docs/books/jsgui3-bundling-research-book/README.md).
|
|
19
19
|
|
|
20
20
|
# JSGUI3 Server - Comprehensive Documentation
|
|
21
21
|
|
|
@@ -27,24 +27,24 @@ The server acts as a bridge between server-side JavaScript applications and brow
|
|
|
27
27
|
|
|
28
28
|
## Table of Contents
|
|
29
29
|
|
|
30
|
-
1. [Quick Start](#quick-start)
|
|
31
|
-
2. [AI Agent Fast Start](#ai-agent-fast-start)
|
|
32
|
-
3. [Architecture Overview](#architecture-overview)
|
|
33
|
-
4. [Core Components](#core-components)
|
|
34
|
-
5. [Installation and Setup](#installation-and-setup)
|
|
35
|
-
6. [Configuration](#configuration)
|
|
36
|
-
7. [API Reference](#api-reference)
|
|
37
|
-
8. [Examples](#examples)
|
|
38
|
-
9. [Development](#development)
|
|
39
|
-
10. [Troubleshooting](#troubleshooting)
|
|
40
|
-
11. [Deployment & Production](#deployment--production)
|
|
41
|
-
12. [Contributing](#contributing)
|
|
42
|
-
13. [Code Style Guidelines](#code-style-guidelines)
|
|
43
|
-
14. [License](#license)
|
|
44
|
-
15. [Changelog](#changelog)
|
|
45
|
-
16. [Support](#support)
|
|
46
|
-
17. [Roadmap](#roadmap)
|
|
47
|
-
18. [MVVM and Full-Stack Controls](#mvvm-and-full-stack-controls)
|
|
30
|
+
1. [Quick Start](#quick-start)
|
|
31
|
+
2. [AI Agent Fast Start](#ai-agent-fast-start)
|
|
32
|
+
3. [Architecture Overview](#architecture-overview)
|
|
33
|
+
4. [Core Components](#core-components)
|
|
34
|
+
5. [Installation and Setup](#installation-and-setup)
|
|
35
|
+
6. [Configuration](#configuration)
|
|
36
|
+
7. [API Reference](#api-reference)
|
|
37
|
+
8. [Examples](#examples)
|
|
38
|
+
9. [Development](#development)
|
|
39
|
+
10. [Troubleshooting](#troubleshooting)
|
|
40
|
+
11. [Deployment & Production](#deployment--production)
|
|
41
|
+
12. [Contributing](#contributing)
|
|
42
|
+
13. [Code Style Guidelines](#code-style-guidelines)
|
|
43
|
+
14. [License](#license)
|
|
44
|
+
15. [Changelog](#changelog)
|
|
45
|
+
16. [Support](#support)
|
|
46
|
+
17. [Roadmap](#roadmap)
|
|
47
|
+
18. [MVVM and Full-Stack Controls](#mvvm-and-full-stack-controls)
|
|
48
48
|
|
|
49
49
|
## Quick Start
|
|
50
50
|
|
|
@@ -99,43 +99,43 @@ Server.serve({
|
|
|
99
99
|
|
|
100
100
|
### With API Endpoints
|
|
101
101
|
|
|
102
|
-
```javascript
|
|
103
|
-
Server.serve({
|
|
104
|
-
ctrl: DashboardControl,
|
|
105
|
-
src_path_client_js: require.resolve('./client.js'),
|
|
106
|
-
api: {
|
|
107
|
-
'metrics': () => ({ users: 1234, revenue: 56789 }),
|
|
108
|
-
'data': async ({ range }) => await fetchAnalytics(range)
|
|
109
|
-
},
|
|
110
|
-
port: 3000
|
|
111
|
-
});
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
## AI Agent Fast Start
|
|
115
|
-
|
|
116
|
-
This section is a short, task-oriented runway for AI agents that need to act quickly with minimal overhead.
|
|
117
|
-
|
|
118
|
-
**Start here:**
|
|
119
|
-
1. Identify the target subsystem: examples, bundlers, publishers, or controls.
|
|
120
|
-
2. Jump to the focused guide: `docs/books/jsgui3-mvvm-fullstack/README.md`.
|
|
121
|
-
3. For bundle-size and pruning work, use: `docs/books/jsgui3-bundling-research-book/README.md`.
|
|
122
|
-
4. Make the smallest change that can pass a targeted test.
|
|
123
|
-
5. Run the narrow test file first, then widen if needed.
|
|
124
|
-
|
|
125
|
-
**Minimal commands:**
|
|
126
|
-
```bash
|
|
127
|
-
rg -n "needle" path/
|
|
128
|
-
rg --files path/
|
|
129
|
-
node tests/test-runner.js --test=examples-controls.e2e.test.js
|
|
130
|
-
node tests/test-runner.js --test=window-examples.puppeteer.test.js
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
**Known fast checks:**
|
|
134
|
-
- Render server-side quickly with `Server_Static_Page_Context`.
|
|
135
|
-
- Confirm a control is exported under `jsgui.controls`.
|
|
136
|
-
- Ensure composition happens only when `!spec.el`.
|
|
137
|
-
|
|
138
|
-
## Architecture Overview
|
|
102
|
+
```javascript
|
|
103
|
+
Server.serve({
|
|
104
|
+
ctrl: DashboardControl,
|
|
105
|
+
src_path_client_js: require.resolve('./client.js'),
|
|
106
|
+
api: {
|
|
107
|
+
'metrics': () => ({ users: 1234, revenue: 56789 }),
|
|
108
|
+
'data': async ({ range }) => await fetchAnalytics(range)
|
|
109
|
+
},
|
|
110
|
+
port: 3000
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## AI Agent Fast Start
|
|
115
|
+
|
|
116
|
+
This section is a short, task-oriented runway for AI agents that need to act quickly with minimal overhead.
|
|
117
|
+
|
|
118
|
+
**Start here:**
|
|
119
|
+
1. Identify the target subsystem: examples, bundlers, publishers, or controls.
|
|
120
|
+
2. Jump to the focused guide: `docs/books/jsgui3-mvvm-fullstack/README.md`.
|
|
121
|
+
3. For bundle-size and pruning work, use: `docs/books/jsgui3-bundling-research-book/README.md`.
|
|
122
|
+
4. Make the smallest change that can pass a targeted test.
|
|
123
|
+
5. Run the narrow test file first, then widen if needed.
|
|
124
|
+
|
|
125
|
+
**Minimal commands:**
|
|
126
|
+
```bash
|
|
127
|
+
rg -n "needle" path/
|
|
128
|
+
rg --files path/
|
|
129
|
+
node tests/test-runner.js --test=examples-controls.e2e.test.js
|
|
130
|
+
node tests/test-runner.js --test=window-examples.puppeteer.test.js
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Known fast checks:**
|
|
134
|
+
- Render server-side quickly with `Server_Static_Page_Context`.
|
|
135
|
+
- Confirm a control is exported under `jsgui.controls`.
|
|
136
|
+
- Ensure composition happens only when `!spec.el`.
|
|
137
|
+
|
|
138
|
+
## Architecture Overview
|
|
139
139
|
|
|
140
140
|
### Core Architecture
|
|
141
141
|
|
|
@@ -238,97 +238,97 @@ JSGUI3 provides a rich set of UI controls:
|
|
|
238
238
|
- **Button**: Interactive button control
|
|
239
239
|
- **Text_Input**: Text input field
|
|
240
240
|
- **Checkbox**: Boolean input control
|
|
241
|
-
- **Date_Picker**: Date selection control
|
|
242
|
-
- **Month_View**: Calendar display
|
|
243
|
-
- **Menu**: Dropdown menu control
|
|
244
|
-
|
|
245
|
-
## MVVM and Full-Stack Controls
|
|
246
|
-
|
|
247
|
-
For a complete, step-by-step walkthrough of MVVM binding and full-stack control usage, use:
|
|
248
|
-
`docs/books/jsgui3-mvvm-fullstack/README.md`
|
|
249
|
-
|
|
250
|
-
### Minimal Full-Stack Control Example
|
|
251
|
-
|
|
252
|
-
```javascript
|
|
253
|
-
const jsgui = require('jsgui3-client');
|
|
254
|
-
const { controls } = jsgui;
|
|
255
|
-
const Active_HTML_Document = require('jsgui3-server/controls/Active_HTML_Document');
|
|
256
|
-
|
|
257
|
-
class Demo_UI extends Active_HTML_Document {
|
|
258
|
-
constructor(spec = {}) {
|
|
259
|
-
spec.__type_name = spec.__type_name || 'demo_ui';
|
|
260
|
-
super(spec);
|
|
261
|
-
const { context } = this;
|
|
262
|
-
if (!spec.el) {
|
|
263
|
-
const window_ctrl = new controls.Window({
|
|
264
|
-
context,
|
|
265
|
-
title: 'Hello JSGUI3'
|
|
266
|
-
});
|
|
267
|
-
this.body.add(window_ctrl);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
controls.Demo_UI = Demo_UI;
|
|
273
|
-
module.exports = jsgui;
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
```javascript
|
|
277
|
-
const Server = require('jsgui3-server');
|
|
278
|
-
const { Demo_UI } = require('./client').controls;
|
|
279
|
-
|
|
280
|
-
Server.serve({
|
|
281
|
-
ctrl: Demo_UI,
|
|
282
|
-
src_path_client_js: require.resolve('./client.js'),
|
|
283
|
-
port: 3000
|
|
284
|
-
});
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
### MVVM Binding Skeleton
|
|
288
|
-
|
|
289
|
-
```javascript
|
|
290
|
-
const jsgui = require('jsgui3-client');
|
|
291
|
-
const { controls, Control } = jsgui;
|
|
292
|
-
|
|
293
|
-
const set_model_value = (model, name, value) => {
|
|
294
|
-
if (!model) return;
|
|
295
|
-
if (typeof model.set === 'function') {
|
|
296
|
-
model.set(name, value);
|
|
297
|
-
} else {
|
|
298
|
-
model[name] = value;
|
|
299
|
-
}
|
|
300
|
-
};
|
|
301
|
-
|
|
302
|
-
class Profile_Panel extends Control {
|
|
303
|
-
constructor(spec = {}) {
|
|
304
|
-
spec.__type_name = spec.__type_name || 'profile_panel';
|
|
305
|
-
super(spec);
|
|
306
|
-
if (!spec.el) {
|
|
307
|
-
const { context } = this;
|
|
308
|
-
const name_input = new controls.Text_Input({ context });
|
|
309
|
-
this.add(name_input);
|
|
310
|
-
this.name_input = name_input;
|
|
311
|
-
}
|
|
312
|
-
this.setup_bindings();
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
setup_bindings() {
|
|
316
|
-
const data_model = this.data && this.data.model;
|
|
317
|
-
if (!data_model || !this.name_input) return;
|
|
318
|
-
this.watch(data_model, 'full_name', value => {
|
|
319
|
-
this.name_input.set_value(value || '');
|
|
320
|
-
});
|
|
321
|
-
this.name_input.on('input', () => {
|
|
322
|
-
set_model_value(data_model, 'full_name', this.name_input.get_value());
|
|
323
|
-
});
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
controls.Profile_Panel = Profile_Panel;
|
|
328
|
-
module.exports = jsgui;
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
## Installation and Setup
|
|
241
|
+
- **Date_Picker**: Date selection control
|
|
242
|
+
- **Month_View**: Calendar display
|
|
243
|
+
- **Menu**: Dropdown menu control
|
|
244
|
+
|
|
245
|
+
## MVVM and Full-Stack Controls
|
|
246
|
+
|
|
247
|
+
For a complete, step-by-step walkthrough of MVVM binding and full-stack control usage, use:
|
|
248
|
+
`docs/books/jsgui3-mvvm-fullstack/README.md`
|
|
249
|
+
|
|
250
|
+
### Minimal Full-Stack Control Example
|
|
251
|
+
|
|
252
|
+
```javascript
|
|
253
|
+
const jsgui = require('jsgui3-client');
|
|
254
|
+
const { controls } = jsgui;
|
|
255
|
+
const Active_HTML_Document = require('jsgui3-server/controls/Active_HTML_Document');
|
|
256
|
+
|
|
257
|
+
class Demo_UI extends Active_HTML_Document {
|
|
258
|
+
constructor(spec = {}) {
|
|
259
|
+
spec.__type_name = spec.__type_name || 'demo_ui';
|
|
260
|
+
super(spec);
|
|
261
|
+
const { context } = this;
|
|
262
|
+
if (!spec.el) {
|
|
263
|
+
const window_ctrl = new controls.Window({
|
|
264
|
+
context,
|
|
265
|
+
title: 'Hello JSGUI3'
|
|
266
|
+
});
|
|
267
|
+
this.body.add(window_ctrl);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
controls.Demo_UI = Demo_UI;
|
|
273
|
+
module.exports = jsgui;
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
```javascript
|
|
277
|
+
const Server = require('jsgui3-server');
|
|
278
|
+
const { Demo_UI } = require('./client').controls;
|
|
279
|
+
|
|
280
|
+
Server.serve({
|
|
281
|
+
ctrl: Demo_UI,
|
|
282
|
+
src_path_client_js: require.resolve('./client.js'),
|
|
283
|
+
port: 3000
|
|
284
|
+
});
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### MVVM Binding Skeleton
|
|
288
|
+
|
|
289
|
+
```javascript
|
|
290
|
+
const jsgui = require('jsgui3-client');
|
|
291
|
+
const { controls, Control } = jsgui;
|
|
292
|
+
|
|
293
|
+
const set_model_value = (model, name, value) => {
|
|
294
|
+
if (!model) return;
|
|
295
|
+
if (typeof model.set === 'function') {
|
|
296
|
+
model.set(name, value);
|
|
297
|
+
} else {
|
|
298
|
+
model[name] = value;
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
class Profile_Panel extends Control {
|
|
303
|
+
constructor(spec = {}) {
|
|
304
|
+
spec.__type_name = spec.__type_name || 'profile_panel';
|
|
305
|
+
super(spec);
|
|
306
|
+
if (!spec.el) {
|
|
307
|
+
const { context } = this;
|
|
308
|
+
const name_input = new controls.Text_Input({ context });
|
|
309
|
+
this.add(name_input);
|
|
310
|
+
this.name_input = name_input;
|
|
311
|
+
}
|
|
312
|
+
this.setup_bindings();
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
setup_bindings() {
|
|
316
|
+
const data_model = this.data && this.data.model;
|
|
317
|
+
if (!data_model || !this.name_input) return;
|
|
318
|
+
this.watch(data_model, 'full_name', value => {
|
|
319
|
+
this.name_input.set_value(value || '');
|
|
320
|
+
});
|
|
321
|
+
this.name_input.on('input', () => {
|
|
322
|
+
set_model_value(data_model, 'full_name', this.name_input.get_value());
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
controls.Profile_Panel = Profile_Panel;
|
|
328
|
+
module.exports = jsgui;
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
## Installation and Setup
|
|
332
332
|
|
|
333
333
|
### Prerequisites
|
|
334
334
|
|
|
@@ -396,30 +396,30 @@ body {
|
|
|
396
396
|
}
|
|
397
397
|
`;
|
|
398
398
|
|
|
399
|
-
controls.MyControl = MyControl;
|
|
400
|
-
module.exports = jsgui;
|
|
401
|
-
```
|
|
402
|
-
|
|
403
|
-
SCSS/SASS: You can also set `MyControl.scss` or `MyControl.sass` using template literals. These are compiled to CSS during bundling and removed from the JS output, just like `.css`. CSS and SCSS blocks can be mixed in a control; the bundler preserves their order during compilation. If you mix indented `.sass` with `.scss`/`.css`, each block is compiled independently to preserve order. Inline CSS sourcemaps are emitted only when a single compilation pass is used; mixed syntax skips inline maps to keep them accurate.
|
|
404
|
-
|
|
405
|
-
To enable inline CSS sourcemaps for Sass/SCSS outputs, pass a `style` configuration:
|
|
406
|
-
|
|
407
|
-
```javascript
|
|
408
|
-
Server.serve({
|
|
409
|
-
ctrl: MyControl,
|
|
410
|
-
src_path_client_js: require.resolve('./client.js'),
|
|
411
|
-
debug: true,
|
|
412
|
-
style: {
|
|
413
|
-
sourcemaps: {
|
|
414
|
-
enabled: true,
|
|
415
|
-
inline: true,
|
|
416
|
-
include_sources: true
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
});
|
|
420
|
-
```
|
|
421
|
-
|
|
422
|
-
2. Create server:
|
|
399
|
+
controls.MyControl = MyControl;
|
|
400
|
+
module.exports = jsgui;
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
SCSS/SASS: You can also set `MyControl.scss` or `MyControl.sass` using template literals. These are compiled to CSS during bundling and removed from the JS output, just like `.css`. CSS and SCSS blocks can be mixed in a control; the bundler preserves their order during compilation. If you mix indented `.sass` with `.scss`/`.css`, each block is compiled independently to preserve order. Inline CSS sourcemaps are emitted only when a single compilation pass is used; mixed syntax skips inline maps to keep them accurate.
|
|
404
|
+
|
|
405
|
+
To enable inline CSS sourcemaps for Sass/SCSS outputs, pass a `style` configuration:
|
|
406
|
+
|
|
407
|
+
```javascript
|
|
408
|
+
Server.serve({
|
|
409
|
+
ctrl: MyControl,
|
|
410
|
+
src_path_client_js: require.resolve('./client.js'),
|
|
411
|
+
debug: true,
|
|
412
|
+
style: {
|
|
413
|
+
sourcemaps: {
|
|
414
|
+
enabled: true,
|
|
415
|
+
inline: true,
|
|
416
|
+
include_sources: true
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
2. Create server:
|
|
423
423
|
|
|
424
424
|
```javascript
|
|
425
425
|
// server.js
|
|
@@ -490,16 +490,16 @@ Main entry point for starting the server.
|
|
|
490
490
|
**Parameters:**
|
|
491
491
|
- `options` (object): Server configuration object
|
|
492
492
|
|
|
493
|
-
**Options:**
|
|
494
|
-
- `ctrl` or `Ctrl`: Main control class constructor
|
|
495
|
-
- `pages`: Object defining multiple pages with routes as keys
|
|
496
|
-
- `api`: Object defining API endpoints
|
|
497
|
-
- `resources`: Object/array of managed resource definitions
|
|
498
|
-
- `events`: Enable/configure built-in SSE endpoint for resource lifecycle events
|
|
499
|
-
- `src_path_client_js`: Path to client-side JavaScript file
|
|
500
|
-
- `port`: Server port (default: 8080)
|
|
501
|
-
- `host`: Server host (default: all IPv4 interfaces)
|
|
502
|
-
- `debug`: Enable debug mode (default: false)
|
|
493
|
+
**Options:**
|
|
494
|
+
- `ctrl` or `Ctrl`: Main control class constructor
|
|
495
|
+
- `pages`: Object defining multiple pages with routes as keys
|
|
496
|
+
- `api`: Object defining API endpoints
|
|
497
|
+
- `resources`: Object/array of managed resource definitions
|
|
498
|
+
- `events`: Enable/configure built-in SSE endpoint for resource lifecycle events
|
|
499
|
+
- `src_path_client_js`: Path to client-side JavaScript file
|
|
500
|
+
- `port`: Server port (default: 8080)
|
|
501
|
+
- `host`: Server host (default: all IPv4 interfaces)
|
|
502
|
+
- `debug`: Enable debug mode (default: false)
|
|
503
503
|
|
|
504
504
|
**Returns:** Promise that resolves to the server instance
|
|
505
505
|
|
|
@@ -530,45 +530,45 @@ const server = await Server.serve({
|
|
|
530
530
|
port: 3000
|
|
531
531
|
});
|
|
532
532
|
|
|
533
|
-
// With API endpoints
|
|
534
|
-
const server = await Server.serve({
|
|
535
|
-
ctrl: DashboardControl,
|
|
533
|
+
// With API endpoints
|
|
534
|
+
const server = await Server.serve({
|
|
535
|
+
ctrl: DashboardControl,
|
|
536
536
|
src_path_client_js: require.resolve('./client.js'),
|
|
537
537
|
api: {
|
|
538
538
|
'status': () => ({ uptime: process.uptime() }),
|
|
539
539
|
'users': async () => await getUsers()
|
|
540
|
-
},
|
|
541
|
-
port: 3000
|
|
542
|
-
});
|
|
543
|
-
|
|
544
|
-
// With managed resources and SSE lifecycle events
|
|
545
|
-
let server_with_resources;
|
|
546
|
-
server_with_resources = await Server.serve({
|
|
547
|
-
api: {
|
|
548
|
-
'resources/summary': () => server_with_resources.resource_pool.summary
|
|
549
|
-
},
|
|
550
|
-
resources: {
|
|
551
|
-
worker_direct: {
|
|
552
|
-
type: 'process',
|
|
553
|
-
command: process.execPath,
|
|
554
|
-
args: ['worker.js'],
|
|
555
|
-
autoRestart: true
|
|
556
|
-
},
|
|
557
|
-
worker_pm2: {
|
|
558
|
-
type: 'process',
|
|
559
|
-
processManager: { type: 'pm2' }, // pm2Path optional
|
|
560
|
-
command: process.execPath,
|
|
561
|
-
args: ['worker.js']
|
|
562
|
-
},
|
|
563
|
-
remote_worker: {
|
|
564
|
-
type: 'remote',
|
|
565
|
-
host: '127.0.0.1',
|
|
566
|
-
port: 3400
|
|
567
|
-
}
|
|
568
|
-
},
|
|
569
|
-
events: true // creates /events and forwards resource lifecycle events
|
|
570
|
-
});
|
|
571
|
-
```
|
|
540
|
+
},
|
|
541
|
+
port: 3000
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
// With managed resources and SSE lifecycle events
|
|
545
|
+
let server_with_resources;
|
|
546
|
+
server_with_resources = await Server.serve({
|
|
547
|
+
api: {
|
|
548
|
+
'resources/summary': () => server_with_resources.resource_pool.summary
|
|
549
|
+
},
|
|
550
|
+
resources: {
|
|
551
|
+
worker_direct: {
|
|
552
|
+
type: 'process',
|
|
553
|
+
command: process.execPath,
|
|
554
|
+
args: ['worker.js'],
|
|
555
|
+
autoRestart: true
|
|
556
|
+
},
|
|
557
|
+
worker_pm2: {
|
|
558
|
+
type: 'process',
|
|
559
|
+
processManager: { type: 'pm2' }, // pm2Path optional
|
|
560
|
+
command: process.execPath,
|
|
561
|
+
args: ['worker.js']
|
|
562
|
+
},
|
|
563
|
+
remote_worker: {
|
|
564
|
+
type: 'remote',
|
|
565
|
+
host: '127.0.0.1',
|
|
566
|
+
port: 3400
|
|
567
|
+
}
|
|
568
|
+
},
|
|
569
|
+
events: true // creates /events and forwards resource lifecycle events
|
|
570
|
+
});
|
|
571
|
+
```
|
|
572
572
|
|
|
573
573
|
### Publishers API
|
|
574
574
|
|
|
@@ -1110,7 +1110,7 @@ const server = Server.serve({
|
|
|
1110
1110
|
debug: false, // Disable for production
|
|
1111
1111
|
// Additional production settings
|
|
1112
1112
|
max_age: 86400, // Cache static assets for 24 hours
|
|
1113
|
-
|
|
1113
|
+
compression: true // Enable gzip/deflate/brotli compression
|
|
1114
1114
|
});
|
|
1115
1115
|
```
|
|
1116
1116
|
|
|
@@ -1300,8 +1300,8 @@ Server.serve({
|
|
|
1300
1300
|
src_path_client_js: require.resolve('./client.js'),
|
|
1301
1301
|
// Cache static assets
|
|
1302
1302
|
max_age: 86400, // 24 hours
|
|
1303
|
-
// Enable compression
|
|
1304
|
-
|
|
1303
|
+
// Enable compression (gzip/deflate/brotli via built-in middleware)
|
|
1304
|
+
compression: true,
|
|
1305
1305
|
// Optimize bundling
|
|
1306
1306
|
debug: false
|
|
1307
1307
|
});
|
|
@@ -1561,4 +1561,4 @@ MIT License - see LICENSE file for details.
|
|
|
1561
1561
|
---
|
|
1562
1562
|
|
|
1563
1563
|
This documentation provides a comprehensive overview of JSGUI3 Server. For more detailed information about specific components, see the individual files in the `docs/` directory and the examples in `examples/`.</content>
|
|
1564
|
-
<parameter name="filePath">c:\\Users\\james\\Documents\\repos\\jsgui3-server\\docs\\comprehensive-documentation.md
|
|
1564
|
+
<parameter name="filePath">c:\\Users\\james\\Documents\\repos\\jsgui3-server\\docs\\comprehensive-documentation.md
|