@gramlot/gramlot 0.3.5 → 0.3.7

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 (66) hide show
  1. package/dist/gramlot.js +1374 -905
  2. package/dist/gramlot.min.js +22 -23
  3. package/package.json +3 -3
  4. package/src/binding/ask-dialog.js +47 -24
  5. package/src/binding/inline.js +7 -5
  6. package/src/binding/installation.js +14 -5
  7. package/src/binding/logic.js +10 -5
  8. package/src/binding/pointer.js +6 -10
  9. package/src/binding/providers.js +105 -82
  10. package/src/binding/remote.js +60 -26
  11. package/src/binding/router.js +2 -4
  12. package/src/binding/rpc-resolver.js +102 -53
  13. package/src/binding/runtime.js +73 -32
  14. package/src/bootstrap.d.ts +8 -1
  15. package/src/bootstrap.js +28 -11
  16. package/src/builder/binding.json +13 -1
  17. package/src/builder/gramlot-builder.d.ts +5 -2
  18. package/src/builder/gramlot-builder.js +17 -9
  19. package/src/builder/name-syntax.d.ts +37 -0
  20. package/src/builder/name-syntax.js +54 -0
  21. package/src/builder/source.js +170 -14
  22. package/src/components/border-container.js +17 -10
  23. package/src/components/selected-container.js +19 -18
  24. package/src/dom.d.ts +3 -0
  25. package/src/format.js +3 -10
  26. package/src/frame-messages.js +2 -1
  27. package/src/gramlot.d.ts +12 -4
  28. package/src/gramlot.js +25 -10
  29. package/src/handlers/rpc-handler.d.ts +25 -12
  30. package/src/handlers/rpc-handler.js +57 -13
  31. package/src/handlers/source-handler.d.ts +13 -3
  32. package/src/handlers/source-handler.js +23 -18
  33. package/src/handlers/subscriptions-handler.js +26 -2
  34. package/src/http-transport.d.ts +11 -2
  35. package/src/http-transport.js +31 -11
  36. package/src/index-page-runtime.js +2 -2
  37. package/src/index.d.ts +4 -2
  38. package/src/index.js +6 -2
  39. package/src/random-id.js +14 -0
  40. package/src/renderer/attributes.js +1 -1
  41. package/src/renderer/gramlot-html-renderer.js +14 -5
  42. package/src/renderer/gramlot-renderer.js +3 -3
  43. package/src/server/conformance.d.ts +4 -2
  44. package/src/server/conformance.js +70 -9
  45. package/src/server/files.js +40 -0
  46. package/src/server/gramlot-file-server.d.ts +2 -0
  47. package/src/server/gramlot-file-server.js +18 -18
  48. package/src/server/gramlot-server.d.ts +26 -7
  49. package/src/server/gramlot-server.js +153 -33
  50. package/src/server/index-page.js +1 -1
  51. package/src/server/index.d.ts +3 -1
  52. package/src/server/index.js +2 -1
  53. package/src/server/page-base.js +55 -20
  54. package/src/server/page.d.ts +37 -15
  55. package/src/server/page.js +7 -0
  56. package/src/server/resources.d.ts +2 -0
  57. package/src/server-adapter.d.ts +17 -0
  58. package/src/server-adapter.js +23 -0
  59. package/src/view/button.js +5 -5
  60. package/src/view/controls.js +5 -6
  61. package/src/view/html.js +7 -1
  62. package/themes/gramlot-base/README.md +5 -4
  63. package/themes/gramlot-base/theme.css +2 -0
  64. package/themes/gramlot-compact/README.md +5 -12
  65. package/themes/joanna/README.md +2 -3
  66. package/themes/mimi/README.md +2 -3
@@ -3,7 +3,6 @@
3
3
  * target selection; this binding owns execution, ask, delay and disposal.
4
4
  */
5
5
 
6
- import {AskDialog} from '../binding/ask-dialog.js';
7
6
 
8
7
  export class ButtonBinding {
9
8
  #binding;
@@ -107,7 +106,7 @@ export class ButtonBinding {
107
106
  // Legacy reads inherited _delay. An explicit zero overrides an ancestor's delay.
108
107
  let owner = this.node;
109
108
  while (owner && owner.getAttr('_delay') == null) owner = owner.parentNode;
110
- const delay = owner ? owner.builder.runtimeValues(owner)[1]._delay : 0;
109
+ const delay = owner ? owner.rootBuilder.runtimeValues(owner)[1]._delay : 0;
111
110
  if (delay > 0) {
112
111
  const count = this.#pendingCount + 1;
113
112
  this.#cancelDelay?.();
@@ -143,7 +142,7 @@ export class ButtonBinding {
143
142
  provider?.invoke({kind: 'click', event, counter});
144
143
  } else if (mechanism === 'action') {
145
144
  const read = () => {
146
- const [, attrs] = node.builder.runtimeValues(node);
145
+ const [, attrs] = node.rootBuilder.runtimeValues(node);
147
146
  const authored = Object.fromEntries(Object.entries(attrs).filter(([name]) => name !== 'ask'));
148
147
  return {...this.binding.runtime.renderer.references.resolveArguments(authored), event, _counter: counter, modifiers};
149
148
  };
@@ -154,8 +153,9 @@ export class ButtonBinding {
154
153
  this.binding.runtime.inlineCompiler.compile(node, 'action', node.getAttr('action'), Object.keys(values))(values);
155
154
  };
156
155
  const ask = node.getAttr('ask');
157
- if (ask && AskDialog.required(this.binding, ask, read(), 'ask')) {
158
- return AskDialog.show(this.binding, ask, read()).then(execute);
156
+ const askDialog = this.binding.runtime.askDialog;
157
+ if (ask && askDialog.required(this.binding, ask, read(), 'ask')) {
158
+ return askDialog.show(this.binding, ask, read()).then(execute);
159
159
  }
160
160
  execute(undefined);
161
161
  } else {
@@ -139,17 +139,16 @@ export class ControlAdapter {
139
139
  }
140
140
 
141
141
  /**
142
- * Write `read()` at the `value` pointer (`^`, `?attr` included). A literal or `=` value accepts
143
- * input and writes nothing (gate decision 5); a null path raises from the listener (Q7). A closed
144
- * NodeBinding writes nothing (R12).
142
+ * Write `read()` at the `value` pointer (`^`, `?attr` included) with HtmlElement.writeParameter,
143
+ * the DOM → Data rule of component parameters too. A literal or `=` value accepts input and writes
144
+ * nothing (gate decision 5); a value equal to the Data value is not written; a null path raises
145
+ * from the listener (Q7). A closed NodeBinding writes nothing (R12).
145
146
  */
146
147
  commit(event, value = this.read()) {
147
148
  if (this.binding.closed) return;
148
- const pointer = this.node.getAttr('value');
149
- if (this.node.pointerType(pointer) !== '^') return;
150
149
  this.#committing = true;
151
150
  try {
152
- this.node.setRelativeData(pointer.slice(1), value);
151
+ this.binding.runtime.renderer.html.writeParameter(this.node, 'value', value);
153
152
  } finally {
154
153
  this.#committing = false;
155
154
  }
package/src/view/html.js CHANGED
@@ -110,7 +110,13 @@ export class HtmlElement {
110
110
  && record.element.namespaceURI === namespace;
111
111
  }
112
112
 
113
- /** Write a component interaction through a plain reactive Source pointer. */
113
+ /**
114
+ * Write `value`, produced in the DOM, through the attribute `name` of `node`: the one DOM → Data
115
+ * rule, used by component parameters and by ControlAdapter.commit. Only a plain reactive `^`
116
+ * pointer writes; a literal, a `=` pointer and a pointer with a suffix write nothing (no inverse
117
+ * conversion, 11.81). A value equal (`Object.is`) to the Data value is not written, as the legacy
118
+ * `setAttributeInDatasource` with `lazySet`: a null value on a missing path creates no Data node.
119
+ */
114
120
  writeParameter(node, name, value) {
115
121
  const pointer = node.getAttr(name);
116
122
  if (node.pointerType(pointer) === '^' && !pointerTransform(pointer)
@@ -6,15 +6,16 @@
6
6
  <link rel="stylesheet" href="/themes/gramlot-base/theme.css">
7
7
  ```
8
8
 
9
- The adapters of `gramlot-py-server` and `gramlot-js-server` serve the themes packaged with the core at `/themes/…`, below the mount prefix, and `@gramlot/gramlot-serverless` copies or inlines them in its export. Another host must serve this file at that path. The theme styles semantic HTML, forms, tables, dialogs, details, code, focus states, and a few optional layout classes: `.example-page`, `.stack`, `.grid`, `.card`, `.muted`, and fluid SVG `.example-art`. Secondary button variants are `.button--secondary` and `.button--quiet`; status chips use `.status` with a semantic modifier. SVG icons can use `.gramlot-icon` (fill) or `.gramlot-icon--stroke` (stroke) and inherit `currentColor`. Supply an accessible name or mark decorative icons `aria-hidden="true"` in the application.
9
+ The adapters of `gramlot-py-server` and `gramlot-js-server` serve the themes packaged with the core at `/themes/…`, below the mount prefix, and `@gramlot/gramlot-serverless` copies or inlines them in its export. Another host must serve this file at that path. The theme styles semantic HTML, forms, tables, dialogs, details, code, focus states, and a few optional layout classes: `.example-page`, `.stack`, `.grid`, `.card`, `.muted`, `.actions` (a wrapping row of buttons), `.eyebrow` (a small uppercase label above a heading), and fluid SVG `.example-art`. Secondary button variants are `.button--secondary` and `.button--quiet`; status chips use `.status` with a semantic modifier. SVG icons can use `.gramlot-icon` (fill) or `.gramlot-icon--stroke` (stroke) and inherit `currentColor`. Supply an accessible name or mark decorative icons `aria-hidden="true"` in the application.
10
10
 
11
11
  ## Available themes
12
12
 
13
13
  Base is the original theme. [Compact](../gramlot-compact/README.md) is its denser
14
14
  alternative, with smaller headings, gaps, card padding and form controls. Both
15
- support light and dark mode. Load Base alone for the original appearance, or Base
16
- followed by `/themes/gramlot-compact/theme.css` for Compact. The existing `Page.css`
17
- list can be declared once on a shared application Page base class.
15
+ support light and dark mode. A Gramlot server loads Base on every page as its base
16
+ theme (option `css_theme`, GC-090 §030); a page adds `/themes/gramlot-compact/theme.css`
17
+ with `Page.css` for Compact. The `Page.css` list can be declared once on a shared
18
+ application Page base class.
18
19
 
19
20
  ## Tokens and extension
20
21
 
@@ -255,6 +255,8 @@
255
255
  .example-art { display: block; inline-size: 100%; block-size: auto; }
256
256
  .example-art { display: block; inline-size: 100%; block-size: auto; }
257
257
  .muted { color: var(--gramlot-text-secondary); }
258
+ .actions { display: flex; flex-wrap: wrap; gap: var(--gramlot-space-2); }
259
+ .eyebrow { margin: 0; color: var(--gramlot-text-secondary); font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
258
260
  .surface-subtle { background: var(--gramlot-surface-subtle); }
259
261
  .status { display: inline-flex; align-items: center; gap: 0.4em; border-radius: 999px; padding: 0.25em 0.65em; font-size: 0.75rem; font-weight: 650; }
260
262
  .status--success { background: var(--gramlot-success-background); color: var(--gramlot-success); }
@@ -4,35 +4,28 @@ Compact is the denser alternative to Gramlot Base. It reduces typography, spacin
4
4
  headings, card padding, table cells and form controls. It shares Base's palette,
5
5
  light/dark modes, focus indicators and semantic HTML rules.
6
6
 
7
- Load both stylesheets, in this order. Compact contains only the size and spacing
7
+ Load Compact after Base. The server loads Base as its base theme (GC-090 §030);
8
+ the page adds Compact with `Page.css`. Compact contains only the size and spacing
8
9
  rules that differ; it does not duplicate the Base stylesheet or import another URL.
9
- The same resource list works with Python servers, JavaScript servers and standalone
10
- exports using the existing `Page.css` mechanism.
11
10
 
12
11
  ```python
13
12
  from gramlot import Page as BasePage
14
13
 
15
14
  class Page(BasePage):
16
- css = (
17
- "/themes/gramlot-base/theme.css",
18
- "/themes/gramlot-compact/theme.css",
19
- )
15
+ css = ("/themes/gramlot-compact/theme.css",)
20
16
  ```
21
17
 
22
18
  ```javascript
23
19
  import {Page as BasePage} from '@gramlot/gramlot/page';
24
20
 
25
21
  export class Page extends BasePage {
26
- static css = [
27
- '/themes/gramlot-base/theme.css',
28
- '/themes/gramlot-compact/theme.css',
29
- ];
22
+ static css = ['/themes/gramlot-compact/theme.css'];
30
23
  }
31
24
  ```
32
25
 
33
26
  Declare this list on a shared application Page base class to reuse it across pages.
34
27
  Keep the usual native elements and classes in `main`; there is no theme-specific
35
- builder syntax. Load only Base to use the original theme.
28
+ builder syntax. Declare no `css` to use the original theme, Base alone.
36
29
 
37
30
  | Setting | Base | Compact |
38
31
  | --- | --- | --- |
@@ -6,12 +6,11 @@ implemented for current HTML and Gramlot components, without Dojo dependencies.
6
6
  Dark mode is a new coordinated adaptation. It is not a pixel-identical port of
7
7
  legacy layout widgets. Legacy user color variants are outside this increment.
8
8
 
9
- Load Base, Compact and this profile in order:
9
+ The server loads Base (its base theme, GC-090 §030); load Compact and this profile after it:
10
10
 
11
11
  ```python
12
12
  class Page(BasePage):
13
- css = ("/themes/gramlot-base/theme.css",
14
- "/themes/gramlot-compact/theme.css",
13
+ css = ("/themes/gramlot-compact/theme.css",
15
14
  "/themes/joanna/theme.css")
16
15
  ```
17
16
 
@@ -6,12 +6,11 @@ implemented for current HTML and Gramlot components, without Dojo dependencies.
6
6
  Dark mode is a new coordinated adaptation. It is not a pixel-identical port of
7
7
  legacy layout widgets. Legacy user color variants are outside this increment.
8
8
 
9
- Load Base, Compact and this profile in order:
9
+ The server loads Base (its base theme, GC-090 §030); load Compact and this profile after it:
10
10
 
11
11
  ```python
12
12
  class Page(BasePage):
13
- css = ("/themes/gramlot-base/theme.css",
14
- "/themes/gramlot-compact/theme.css",
13
+ css = ("/themes/gramlot-compact/theme.css",
15
14
  "/themes/mimi/theme.css")
16
15
  ```
17
16