@gramlot/gramlot 0.3.9 → 0.3.10
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/components/editors.js +234 -183
- package/dist/components/inputs.js +4 -2
- package/dist/components/layout.js +1994 -11
- package/dist/gramlot.js +40 -9
- package/dist/gramlot.min.js +8 -8
- package/package.json +1 -1
- package/src/binding/remote.js +9 -2
- package/src/binding/runtime.js +8 -3
- package/src/builder/source.js +8 -3
- package/src/components/border-container.js +7 -1
- package/src/components/choice-editor.js +1 -1
- package/src/components/validation.js +1 -1
- package/src/renderer/attributes.js +11 -2
- package/src/server/assets.js +2 -2
- package/src/view/html.js +7 -0
package/dist/gramlot.js
CHANGED
|
@@ -22995,7 +22995,7 @@ var NATIVE_ATTRIBUTES = {
|
|
|
22995
22995
|
canvas: ["width", "height"]
|
|
22996
22996
|
};
|
|
22997
22997
|
var DISPLAY_ATTRIBUTES = ["format", "mask", "locale", "timeZone", "places", "dtype"];
|
|
22998
|
-
var URL_ATTRIBUTES = /* @__PURE__ */ new Set(["href", "src", "formaction", "xlink:href", "xlink_href"]);
|
|
22998
|
+
var URL_ATTRIBUTES = /* @__PURE__ */ new Set(["href", "src", "action", "formaction", "xlink:href", "xlink_href"]);
|
|
22999
22999
|
function withoutBindingAttributes(attrs) {
|
|
23000
23000
|
return Object.fromEntries(Object.entries(attrs).filter(([name, value]) => !(value && typeof value === "object" && Object.hasOwn(value, "$gramlotRef")) && !BINDING_ATTRIBUTES.has(name) && !BINDING_ATTRIBUTE_PREFIXES.some((prefix) => name.startsWith(prefix))));
|
|
23001
23001
|
}
|
|
@@ -23009,6 +23009,14 @@ function requireStyleClassAttributes(node, attrs, prefixes = []) {
|
|
|
23009
23009
|
}
|
|
23010
23010
|
}
|
|
23011
23011
|
function requireNoScriptAttributes(node, attrs, prefixes = []) {
|
|
23012
|
+
if (node.nodeTag === "script") {
|
|
23013
|
+
const executable = [["", node.staticValue], ...sourceAttributeItems(node.getAttr()).filter(([name]) => ["src", "href", "xlink:href", "xlink_href", "_text"].includes(name.slice((prefixes.find((prefix) => name.startsWith(prefix)) ?? "").length).toLowerCase()))];
|
|
23014
|
+
for (const [name, value] of executable) {
|
|
23015
|
+
if (node.pointerType(value) || isExpression(value)) {
|
|
23016
|
+
throw new Error(`script '${node.label}': '${name}' must be literal Source; script code and URLs cannot come from Data`);
|
|
23017
|
+
}
|
|
23018
|
+
}
|
|
23019
|
+
}
|
|
23012
23020
|
if (attrs.onClose != null && !node.parentNode?._getMeta("gramlot_component")?.childParameters?.onClose) {
|
|
23013
23021
|
throw new Error("onClose is only supported on a tab/stack panel");
|
|
23014
23022
|
}
|
|
@@ -23295,7 +23303,8 @@ var GramlotBuilderBagNode = class extends SourceBagNode {
|
|
|
23295
23303
|
* `formula` of a dataFormula, `script` of a dataController, `_if`/`_else` of the four providers, the
|
|
23296
23304
|
* `_onCalling`/`_onResult`/`_onError` of a dataRpc and the `_onCalling` of a dataRemote, `action` of a
|
|
23297
23305
|
* button, `_if`/`_else`/`_onRemote`/`_onCalling` of a node whose `remote` is a string, every `connect_on<event>`,
|
|
23298
|
-
* every `==` attribute (canonical name) and a `==` node value (`''`).
|
|
23306
|
+
* every `==` attribute (canonical name) and a `==` node value (`''`). Script elements also retain
|
|
23307
|
+
* their literal executable text and URLs here for the live renderer's activation check.
|
|
23299
23308
|
*/
|
|
23300
23309
|
codeAttributes() {
|
|
23301
23310
|
const own2 = [
|
|
@@ -23318,8 +23327,12 @@ var GramlotBuilderBagNode = class extends SourceBagNode {
|
|
|
23318
23327
|
}
|
|
23319
23328
|
for (const [name, value] of sourceAttributeItems(this.getAttr())) {
|
|
23320
23329
|
if (isExpression2(value)) items.push([name, value]);
|
|
23330
|
+
if (this.nodeTag === "script" && typeof value === "string") {
|
|
23331
|
+
const prefix = this.builder.constructor.dialectPrefixes.find((prefix2) => name.startsWith(prefix2)) ?? "";
|
|
23332
|
+
if (["src", "href", "xlink:href", "xlink_href", "_text"].includes(name.slice(prefix.length).toLowerCase())) items.push([name, value]);
|
|
23333
|
+
}
|
|
23321
23334
|
}
|
|
23322
|
-
if (isExpression2(this.staticValue)) items.push(["", this.staticValue]);
|
|
23335
|
+
if (isExpression2(this.staticValue) || this.nodeTag === "script" && typeof this.staticValue === "string") items.push(["", this.staticValue]);
|
|
23323
23336
|
return items;
|
|
23324
23337
|
}
|
|
23325
23338
|
/**
|
|
@@ -23371,7 +23384,7 @@ var GramlotBuilderBagNode = class extends SourceBagNode {
|
|
|
23371
23384
|
}
|
|
23372
23385
|
/** Publish to this node's selfsubscribe topics, as in the legacy Source API. */
|
|
23373
23386
|
publish(topic, payload = {}) {
|
|
23374
|
-
return this.
|
|
23387
|
+
return this.rootBuilder.binding.subscriptions.publishNode(this, topic, payload);
|
|
23375
23388
|
}
|
|
23376
23389
|
/** Builder's `^` pointers, except the attributes ending in `_path`, which hold a bare path. */
|
|
23377
23390
|
pointers() {
|
|
@@ -25255,6 +25268,13 @@ var HtmlElement = class {
|
|
|
25255
25268
|
* control belongs to its ControlAdapter: neither the attribute nor the property is written here.
|
|
25256
25269
|
*/
|
|
25257
25270
|
update(record2, node, attrs = node.attr, textValue2 = DEFAULT_TEXT, visible = null) {
|
|
25271
|
+
if (node.nodeTag === "script") {
|
|
25272
|
+
for (const [name, code] of node.codeAttributes()) {
|
|
25273
|
+
if (node.activatedCode(name) !== code) {
|
|
25274
|
+
throw new Error(`script '${node.label}': '${name}' runs only as received with the Source`);
|
|
25275
|
+
}
|
|
25276
|
+
}
|
|
25277
|
+
}
|
|
25258
25278
|
const { element, text } = record2;
|
|
25259
25279
|
const isHtml = element.namespaceURI === XHTML_NS;
|
|
25260
25280
|
const renderAttributes = this.definition(node).meta.render_attributes ?? {};
|
|
@@ -26689,6 +26709,7 @@ ${text}`, { cause: error });
|
|
|
26689
26709
|
var RemoteBinding = class {
|
|
26690
26710
|
#binding;
|
|
26691
26711
|
#timers;
|
|
26712
|
+
#closed = false;
|
|
26692
26713
|
// The name and TYTX parameters of the fragment mounted last on the node, whoever requested it.
|
|
26693
26714
|
#lastName = null;
|
|
26694
26715
|
#lastParams = null;
|
|
@@ -26703,7 +26724,12 @@ var RemoteBinding = class {
|
|
|
26703
26724
|
return this.binding.node;
|
|
26704
26725
|
}
|
|
26705
26726
|
get closed() {
|
|
26706
|
-
return this.binding.closed;
|
|
26727
|
+
return this.#closed || this.binding.closed;
|
|
26728
|
+
}
|
|
26729
|
+
/** Removing the declaration releases scheduled calls; an in-flight fragment keeps the node request contract. */
|
|
26730
|
+
close() {
|
|
26731
|
+
this.#closed = true;
|
|
26732
|
+
this.#timers.cancel();
|
|
26707
26733
|
}
|
|
26708
26734
|
/** Start `_timing` again from its current value: called at every registration of the node's pointers. */
|
|
26709
26735
|
register() {
|
|
@@ -26752,7 +26778,7 @@ var RemoteBinding = class {
|
|
|
26752
26778
|
throw new Error(`${node.nodeTag} '${node.label}': remote '${name}' failed: ${error.message}`, { cause: error });
|
|
26753
26779
|
}
|
|
26754
26780
|
const onRemote = node.getAttr("_onRemote");
|
|
26755
|
-
if (mounted && onRemote) this.#inline("_onRemote", onRemote, onRemote, params);
|
|
26781
|
+
if (!this.closed && mounted && onRemote) this.#inline("_onRemote", onRemote, onRemote, params);
|
|
26756
26782
|
}
|
|
26757
26783
|
/**
|
|
26758
26784
|
* Record the fragment `remoteSource` mounted on the node, with its method and the TYTX of its parameters:
|
|
@@ -27144,8 +27170,8 @@ var BindingRuntime = class {
|
|
|
27144
27170
|
/**
|
|
27145
27171
|
* Steps 2-4 of §5.1 on `branch` (a SourceBagNode or a new SourceBag value). The `nodeId` map is
|
|
27146
27172
|
* complete, and a duplicate refused, before the first write or registration, so a `#<nodeId>`
|
|
27147
|
-
* of the branch translates;
|
|
27148
|
-
*
|
|
27173
|
+
* of the branch translates; one NodeBinding per node owns expression cleanup before installation
|
|
27174
|
+
* (`dataSetter`s and defaults), followed by registrations, providers included. On an error the NodeBindings
|
|
27149
27175
|
* opened here are closed and the map entries they brought are removed; the Data is not rolled
|
|
27150
27176
|
* back. Then `_init` (step 5), once per node: its error propagates and the NodeBindings stay
|
|
27151
27177
|
* open (P12, no rollback).
|
|
@@ -27165,8 +27191,8 @@ var BindingRuntime = class {
|
|
|
27165
27191
|
}
|
|
27166
27192
|
for (const [nodeId, node] of entering) this.nodeIds.set(nodeId, node);
|
|
27167
27193
|
try {
|
|
27168
|
-
this.installer.install(branch);
|
|
27169
27194
|
for (const node of nodes) this.openBinding(node);
|
|
27195
|
+
this.installer.install(branch);
|
|
27170
27196
|
for (const node of nodes) this.bindingFor(node).registerPointers();
|
|
27171
27197
|
} catch (error) {
|
|
27172
27198
|
const errors = [error];
|
|
@@ -27335,6 +27361,10 @@ var NodeBinding = class {
|
|
|
27335
27361
|
const dataElement = node._getMeta("data_element");
|
|
27336
27362
|
if (dataElement && !PROVIDERS[node.nodeTag]) return;
|
|
27337
27363
|
if (!dataElement && typeof node.getAttr("remote") === "string") this.#remote ??= new RemoteBinding(this);
|
|
27364
|
+
else if (this.#remote) {
|
|
27365
|
+
this.#remote.close();
|
|
27366
|
+
this.#remote = null;
|
|
27367
|
+
}
|
|
27338
27368
|
const remoteDependencies = /* @__PURE__ */ new Set();
|
|
27339
27369
|
if (node._getMeta("gramlot_component")?.bagStore) {
|
|
27340
27370
|
const storepath = node.getAttr("storepath");
|
|
@@ -27448,6 +27478,7 @@ var NodeBinding = class {
|
|
|
27448
27478
|
close() {
|
|
27449
27479
|
if (this.closed) return;
|
|
27450
27480
|
this.#closed = true;
|
|
27481
|
+
this.#remote?.close();
|
|
27451
27482
|
if (this.node._getMeta("data_element")) this.runtime.renderer.references.remove(this.node);
|
|
27452
27483
|
this.#closeRegistrations();
|
|
27453
27484
|
const errors = [];
|