@bino-bi/bn-template-engine 1.0.0-alpha.12 → 1.0.0-alpha.14

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.
@@ -1 +1 @@
1
- import{r as t,h as s,H as i,g as a}from"./p-B_d-jp99.js";import{w as r}from"./p-DSXNgKLa.js";import{g as e,f as n}from"./p-DHheVOfP.js";import{w as o,a as h}from"./p-B4JfKvVT.js";const c=class{constructor(s){t(this,s),o(this),this.errors=h(this),r(this,(t=>{this.stores||(this.stores=e(this.element));try{const s=n(JSON.parse(t)),i=Object.assign({},this.stores.internationalization.get(this.namespace));i[this.code]=s,this.stores.internationalization.set(this.namespace,i)}catch(t){console.error(t)}}))}render(){return s(i,{key:"dd384ecf77e4fd5d46ed04b04c4395fba8bac4e1"})}get element(){return a(this)}};c.style="bn-internationalization{display:none}";export{c as bn_internationalization}
1
+ import{r as t,h as s,H as i,g as a}from"./p-B_d-jp99.js";import{w as r}from"./p-BjBz5cSL.js";import{g as e,f as n}from"./p-DHheVOfP.js";import{w as o,a as h}from"./p-B4JfKvVT.js";const c=class{constructor(s){t(this,s),o(this),this.errors=h(this),r(this,(t=>{this.stores||(this.stores=e(this.element));try{const s=n(JSON.parse(t)),i=Object.assign({},this.stores.internationalization.get(this.namespace));i[this.code]=s,this.stores.internationalization.set(this.namespace,i)}catch(t){console.error(t)}}))}render(){return s(i,{key:"dd384ecf77e4fd5d46ed04b04c4395fba8bac4e1"})}get element(){return a(this)}};c.style="bn-internationalization{display:none}";export{c as bn_internationalization}
@@ -0,0 +1 @@
1
+ import{g as r}from"./p-B_d-jp99.js";import{r as t}from"./p-B4JfKvVT.js";const o=(o,s)=>{let a;const e=new MutationObserver((()=>{var r;a&&s(null!==(r=a.textContent)&&void 0!==r?r:"")})),i=o.connectedCallback;o.connectedCallback=()=>{var n;a=r(o),e.observe(a,{childList:!0,subtree:!0,characterData:!0}),s(null!==(n=a.textContent)&&void 0!==n?n:""),t(i,o)};const n=o.disconnectedCallback;o.disconnectedCallback=()=>{e.disconnect(),t(n,o)}};export{o as w}
@@ -3,7 +3,7 @@
3
3
  var index = require('./index-CDKG4xmO.js');
4
4
  var withHasError = require('./withHasError-Cl2gTQzA.js');
5
5
  var contextProtocol = require('./context-protocol-Op7uUwN3.js');
6
- var withBodyObserver = require('./withBodyObserver-D7BKWN2N.js');
6
+ var withBodyObserver = require('./withBodyObserver-BKUE_ypL.js');
7
7
  var withStyled = require('./withStyled-C2kmGAK3.js');
8
8
  var scaling = require('./scaling-57N4Cxb_.js');
9
9
 
@@ -3350,12 +3350,26 @@ const Dataset = class {
3350
3350
  // query text changes; otherwise we just re-materialize so upstream data updates
3351
3351
  // flow through.
3352
3352
  if (this.lastViewQuery !== this.query) {
3353
+ // alasql tracks names in BOTH `db.tables` and `db.views`, and its
3354
+ // CREATE-conflict check looks at `db.tables`. Clean both locations
3355
+ // before creating so devtools "Edit as HTML" (which destroys the old
3356
+ // element and creates a new one without giving us a clean slate)
3357
+ // doesn't trip the "already exists" guard.
3358
+ try {
3359
+ db.exec(`DROP VIEW \`${this.name}\``);
3360
+ }
3361
+ catch (_e) {
3362
+ /* not registered as a view — fine */
3363
+ }
3364
+ if (db.tables[this.name] != null) {
3365
+ delete db.tables[this.name];
3366
+ }
3367
+ // @ts-ignore - views typing is loose
3368
+ if (db.views && db.views[this.name] != null) {
3369
+ // @ts-ignore
3370
+ delete db.views[this.name];
3371
+ }
3353
3372
  try {
3354
- // alasql stores views in `db.views` keyed by name; drop any prior version.
3355
- // @ts-ignore - views typing is loose
3356
- if (db.views && db.views[this.name] != null) {
3357
- db.exec(`DROP VIEW \`${this.name}\``);
3358
- }
3359
3373
  db.exec(`CREATE VIEW \`${this.name}\` AS ${this.query}`);
3360
3374
  this.lastViewQuery = this.query;
3361
3375
  }
@@ -3370,9 +3384,12 @@ const Dataset = class {
3370
3384
  try {
3371
3385
  result = db.exec(`SELECT * FROM \`${this.name}\``);
3372
3386
  }
3373
- catch (e) {
3374
- console.error("bn-dataset: SQL execution failed", e, this.query);
3375
- result = [];
3387
+ catch (_e) {
3388
+ // Most common cause: an upstream datasource referenced by the view hasn't
3389
+ // been registered yet (HTML parse/connectedCallback race). `withDatasource`
3390
+ // re-fires executeQuery on every upstream notify, so we'll retry then.
3391
+ // Skip publish so we don't clobber datasetsMeta with empty data.
3392
+ return;
3376
3393
  }
3377
3394
  }
3378
3395
  this.publish(result);
@@ -3404,25 +3421,31 @@ const Dataset = class {
3404
3421
  if (((_b = (_a = this.stores) === null || _a === void 0 ? void 0 : _a.db) === null || _b === void 0 ? void 0 : _b.db) && this.name) {
3405
3422
  const db = this.stores.db.db;
3406
3423
  try {
3407
- // @ts-ignore - views typing is loose
3408
- if (db.views && db.views[this.name] != null) {
3409
- db.exec(`DROP VIEW \`${this.name}\``);
3410
- }
3424
+ db.exec(`DROP VIEW \`${this.name}\``);
3411
3425
  }
3412
3426
  catch (_e) {
3413
- // ignore; view may not exist
3427
+ // not registered as a view — fine
3414
3428
  }
3415
3429
  if (db.tables[this.name] != null) {
3416
3430
  delete db.tables[this.name];
3417
3431
  }
3432
+ // @ts-ignore - views typing is loose
3433
+ if (db.views && db.views[this.name] != null) {
3434
+ // @ts-ignore
3435
+ delete db.views[this.name];
3436
+ }
3418
3437
  this.stores.db.notify(this.name);
3419
3438
  }
3420
3439
  }
3421
3440
  /**
3422
- * Returns `true` if the text starts with `http://` or `https://`.
3441
+ * Returns `true` if the text is a fetchable URL: an absolute `http(s)://`
3442
+ * URL, or a same-origin path starting with `/` (but not `//`, which is a
3443
+ * protocol-relative URL we treat as inline-mode escape).
3423
3444
  */
3424
3445
  isUrl(text) {
3425
- return text.startsWith("http://") || text.startsWith("https://");
3446
+ if (text.startsWith("http://") || text.startsWith("https://"))
3447
+ return true;
3448
+ return text.startsWith("/") && !text.startsWith("//");
3426
3449
  }
3427
3450
  /**
3428
3451
  * Fetches JSON from the given URL and stores the result as the dataset.
@@ -3474,7 +3497,7 @@ const Dataset = class {
3474
3497
  }
3475
3498
  }
3476
3499
  render() {
3477
- return index.h(index.Host, { key: 'd8f90bd66e8d9aafc83c0818cc0e6573a3186568' });
3500
+ return index.h(index.Host, { key: 'fc620f662e5e23800416e0a43dcdf2df6a4859fc' });
3478
3501
  }
3479
3502
  get element() { return index.getElement(this); }
3480
3503
  static get watchers() { return {
@@ -3574,18 +3597,30 @@ const Datasource = class {
3574
3597
  }
3575
3598
  }
3576
3599
  disconnectedCallback() {
3577
- var _a, _b, _c, _d;
3600
+ var _a, _b;
3578
3601
  this.clearPolling();
3579
- if ((_d = (_c = (_b = (_a = this.stores) === null || _a === void 0 ? void 0 : _a.db) === null || _b === void 0 ? void 0 : _b.db) === null || _c === void 0 ? void 0 : _c.tables) === null || _d === void 0 ? void 0 : _d[this.name]) {
3580
- delete this.stores.db.db.tables[this.name];
3602
+ const db = (_b = (_a = this.stores) === null || _a === void 0 ? void 0 : _a.db) === null || _b === void 0 ? void 0 : _b.db;
3603
+ if (db && this.name) {
3604
+ if (db.tables[this.name] != null) {
3605
+ delete db.tables[this.name];
3606
+ }
3607
+ // @ts-ignore - views typing is loose
3608
+ if (db.views && db.views[this.name] != null) {
3609
+ // @ts-ignore
3610
+ delete db.views[this.name];
3611
+ }
3581
3612
  this.stores.db.notify(this.name);
3582
3613
  }
3583
3614
  }
3584
3615
  /**
3585
- * Returns `true` if the text starts with `http://` or `https://`.
3616
+ * Returns `true` if the text is a fetchable URL: an absolute `http(s)://`
3617
+ * URL, or a same-origin path starting with `/` (but not `//`, which is a
3618
+ * protocol-relative URL we treat as inline-mode escape).
3586
3619
  */
3587
3620
  isUrl(text) {
3588
- return text.startsWith("http://") || text.startsWith("https://");
3621
+ if (text.startsWith("http://") || text.startsWith("https://"))
3622
+ return true;
3623
+ return text.startsWith("/") && !text.startsWith("//");
3589
3624
  }
3590
3625
  /**
3591
3626
  * Fetches JSON from the given URL and stores the result.
@@ -3631,7 +3666,7 @@ const Datasource = class {
3631
3666
  }
3632
3667
  }
3633
3668
  render() {
3634
- return index.h(index.Host, { key: '541bcc84a90dc736d62f1c596e0b9e3e5a54ebf3' });
3669
+ return index.h(index.Host, { key: '7690736d5996a63f5e2fbccd00876d560261185f' });
3635
3670
  }
3636
3671
  get element() { return index.getElement(this); }
3637
3672
  static get watchers() { return {
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var index = require('./index-CDKG4xmO.js');
4
- var withBodyObserver = require('./withBodyObserver-D7BKWN2N.js');
4
+ var withBodyObserver = require('./withBodyObserver-BKUE_ypL.js');
5
5
  var contextProtocol = require('./context-protocol-Op7uUwN3.js');
6
6
  var withHasError = require('./withHasError-Cl2gTQzA.js');
7
7
 
@@ -17,16 +17,21 @@ var withHasError = require('./withHasError-Cl2gTQzA.js');
17
17
  */
18
18
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
19
  const withBodyObserver = (component, onUpdate) => {
20
- const observer = new MutationObserver((mutations) => {
21
- mutations.forEach((mutation) => {
22
- onUpdate(mutation.target.textContent);
23
- });
20
+ let hostElement;
21
+ // Coalesce bursts of mutations (e.g. devtools "Edit as HTML" fires childList +
22
+ // characterData in quick succession) and always read the *host* textContent so
23
+ // we deliver the complete body, not the individual text node that mutated.
24
+ const observer = new MutationObserver(() => {
25
+ var _a;
26
+ if (hostElement)
27
+ onUpdate((_a = hostElement.textContent) !== null && _a !== void 0 ? _a : "");
24
28
  });
25
29
  const connectedCallback = component["connectedCallback"];
26
30
  component["connectedCallback"] = () => {
27
- const element = index.getElement(component);
28
- observer.observe(element, { childList: true, subtree: true, characterData: true });
29
- onUpdate(element.textContent);
31
+ var _a;
32
+ hostElement = index.getElement(component);
33
+ observer.observe(hostElement, { childList: true, subtree: true, characterData: true });
34
+ onUpdate((_a = hostElement.textContent) !== null && _a !== void 0 ? _a : "");
30
35
  withHasError.runIfExisits(connectedCallback, component);
31
36
  };
32
37
  const disconnectedCallback = component["disconnectedCallback"];
@@ -14,9 +14,10 @@ import { computeContentHash, decodeCompressedContent } from "../../utils/content
14
14
  * 1. **SQL** (default) — AlaSQL query against referenced `datasources`.
15
15
  * 2. **Static JSON** — set `static="true"` to bypass SQL and write the
16
16
  * parsed body directly to the `datasets` store.
17
- * 3. **URL** — place an `http://` or `https://` URL in the body to fetch
18
- * JSON from a remote endpoint and write it to the `datasets` store.
19
- * Set the `interval` prop (in seconds) to enable periodic re-fetching.
17
+ * 3. **URL** — place an `http://`/`https://` URL or a same-origin path
18
+ * starting with `/` in the body to fetch JSON from an HTTP endpoint and
19
+ * write it to the `datasets` store. Set the `interval` prop (in seconds)
20
+ * to enable periodic re-fetching.
20
21
  */
21
22
  export class Dataset {
22
23
  constructor() {
@@ -125,12 +126,26 @@ export class Dataset {
125
126
  // query text changes; otherwise we just re-materialize so upstream data updates
126
127
  // flow through.
127
128
  if (this.lastViewQuery !== this.query) {
129
+ // alasql tracks names in BOTH `db.tables` and `db.views`, and its
130
+ // CREATE-conflict check looks at `db.tables`. Clean both locations
131
+ // before creating so devtools "Edit as HTML" (which destroys the old
132
+ // element and creates a new one without giving us a clean slate)
133
+ // doesn't trip the "already exists" guard.
134
+ try {
135
+ db.exec(`DROP VIEW \`${this.name}\``);
136
+ }
137
+ catch (_e) {
138
+ /* not registered as a view — fine */
139
+ }
140
+ if (db.tables[this.name] != null) {
141
+ delete db.tables[this.name];
142
+ }
143
+ // @ts-ignore - views typing is loose
144
+ if (db.views && db.views[this.name] != null) {
145
+ // @ts-ignore
146
+ delete db.views[this.name];
147
+ }
128
148
  try {
129
- // alasql stores views in `db.views` keyed by name; drop any prior version.
130
- // @ts-ignore - views typing is loose
131
- if (db.views && db.views[this.name] != null) {
132
- db.exec(`DROP VIEW \`${this.name}\``);
133
- }
134
149
  db.exec(`CREATE VIEW \`${this.name}\` AS ${this.query}`);
135
150
  this.lastViewQuery = this.query;
136
151
  }
@@ -145,9 +160,12 @@ export class Dataset {
145
160
  try {
146
161
  result = db.exec(`SELECT * FROM \`${this.name}\``);
147
162
  }
148
- catch (e) {
149
- console.error("bn-dataset: SQL execution failed", e, this.query);
150
- result = [];
163
+ catch (_e) {
164
+ // Most common cause: an upstream datasource referenced by the view hasn't
165
+ // been registered yet (HTML parse/connectedCallback race). `withDatasource`
166
+ // re-fires executeQuery on every upstream notify, so we'll retry then.
167
+ // Skip publish so we don't clobber datasetsMeta with empty data.
168
+ return;
151
169
  }
152
170
  }
153
171
  this.publish(result);
@@ -179,25 +197,31 @@ export class Dataset {
179
197
  if (((_b = (_a = this.stores) === null || _a === void 0 ? void 0 : _a.db) === null || _b === void 0 ? void 0 : _b.db) && this.name) {
180
198
  const db = this.stores.db.db;
181
199
  try {
182
- // @ts-ignore - views typing is loose
183
- if (db.views && db.views[this.name] != null) {
184
- db.exec(`DROP VIEW \`${this.name}\``);
185
- }
200
+ db.exec(`DROP VIEW \`${this.name}\``);
186
201
  }
187
202
  catch (_e) {
188
- // ignore; view may not exist
203
+ // not registered as a view — fine
189
204
  }
190
205
  if (db.tables[this.name] != null) {
191
206
  delete db.tables[this.name];
192
207
  }
208
+ // @ts-ignore - views typing is loose
209
+ if (db.views && db.views[this.name] != null) {
210
+ // @ts-ignore
211
+ delete db.views[this.name];
212
+ }
193
213
  this.stores.db.notify(this.name);
194
214
  }
195
215
  }
196
216
  /**
197
- * Returns `true` if the text starts with `http://` or `https://`.
217
+ * Returns `true` if the text is a fetchable URL: an absolute `http(s)://`
218
+ * URL, or a same-origin path starting with `/` (but not `//`, which is a
219
+ * protocol-relative URL we treat as inline-mode escape).
198
220
  */
199
221
  isUrl(text) {
200
- return text.startsWith("http://") || text.startsWith("https://");
222
+ if (text.startsWith("http://") || text.startsWith("https://"))
223
+ return true;
224
+ return text.startsWith("/") && !text.startsWith("//");
201
225
  }
202
226
  /**
203
227
  * Fetches JSON from the given URL and stores the result as the dataset.
@@ -249,7 +273,7 @@ export class Dataset {
249
273
  }
250
274
  }
251
275
  render() {
252
- return h(Host, { key: 'd8f90bd66e8d9aafc83c0818cc0e6573a3186568' });
276
+ return h(Host, { key: 'fc620f662e5e23800416e0a43dcdf2df6a4859fc' });
253
277
  }
254
278
  static get is() { return "bn-dataset"; }
255
279
  static get originalStyleUrls() {
@@ -10,8 +10,8 @@ import { computeContentHash, decodeCompressedContent } from "../../utils/content
10
10
  * Data can be provided in three ways:
11
11
  * 1. **Inline JSON** — Place JSON text inside the element body (default).
12
12
  * 2. **Compressed payload** — Set `raw="false"` and provide `<hash>:<base64_gzip>` format.
13
- * 3. **URL** — Place an `http://` or `https://` URL in the body to fetch JSON
14
- * from a remote endpoint.
13
+ * 3. **URL** — Place an `http://`/`https://` URL or a same-origin path
14
+ * starting with `/` in the body to fetch JSON from an HTTP endpoint.
15
15
  *
16
16
  * In URL mode the component fetches JSON from the URL. Set the `interval`
17
17
  * prop (in seconds) to enable periodic re-fetching (polling).
@@ -102,18 +102,30 @@ export class Datasource {
102
102
  }
103
103
  }
104
104
  disconnectedCallback() {
105
- var _a, _b, _c, _d;
105
+ var _a, _b;
106
106
  this.clearPolling();
107
- if ((_d = (_c = (_b = (_a = this.stores) === null || _a === void 0 ? void 0 : _a.db) === null || _b === void 0 ? void 0 : _b.db) === null || _c === void 0 ? void 0 : _c.tables) === null || _d === void 0 ? void 0 : _d[this.name]) {
108
- delete this.stores.db.db.tables[this.name];
107
+ const db = (_b = (_a = this.stores) === null || _a === void 0 ? void 0 : _a.db) === null || _b === void 0 ? void 0 : _b.db;
108
+ if (db && this.name) {
109
+ if (db.tables[this.name] != null) {
110
+ delete db.tables[this.name];
111
+ }
112
+ // @ts-ignore - views typing is loose
113
+ if (db.views && db.views[this.name] != null) {
114
+ // @ts-ignore
115
+ delete db.views[this.name];
116
+ }
109
117
  this.stores.db.notify(this.name);
110
118
  }
111
119
  }
112
120
  /**
113
- * Returns `true` if the text starts with `http://` or `https://`.
121
+ * Returns `true` if the text is a fetchable URL: an absolute `http(s)://`
122
+ * URL, or a same-origin path starting with `/` (but not `//`, which is a
123
+ * protocol-relative URL we treat as inline-mode escape).
114
124
  */
115
125
  isUrl(text) {
116
- return text.startsWith("http://") || text.startsWith("https://");
126
+ if (text.startsWith("http://") || text.startsWith("https://"))
127
+ return true;
128
+ return text.startsWith("/") && !text.startsWith("//");
117
129
  }
118
130
  /**
119
131
  * Fetches JSON from the given URL and stores the result.
@@ -159,7 +171,7 @@ export class Datasource {
159
171
  }
160
172
  }
161
173
  render() {
162
- return h(Host, { key: '541bcc84a90dc736d62f1c596e0b9e3e5a54ebf3' });
174
+ return h(Host, { key: '7690736d5996a63f5e2fbccd00876d560261185f' });
163
175
  }
164
176
  static get is() { return "bn-datasource"; }
165
177
  static get originalStyleUrls() {
@@ -14,16 +14,21 @@ import { runIfExisits } from "./utils";
14
14
  */
15
15
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
16
  const withBodyObserver = (component, onUpdate) => {
17
- const observer = new MutationObserver((mutations) => {
18
- mutations.forEach((mutation) => {
19
- onUpdate(mutation.target.textContent);
20
- });
17
+ let hostElement;
18
+ // Coalesce bursts of mutations (e.g. devtools "Edit as HTML" fires childList +
19
+ // characterData in quick succession) and always read the *host* textContent so
20
+ // we deliver the complete body, not the individual text node that mutated.
21
+ const observer = new MutationObserver(() => {
22
+ var _a;
23
+ if (hostElement)
24
+ onUpdate((_a = hostElement.textContent) !== null && _a !== void 0 ? _a : "");
21
25
  });
22
26
  const connectedCallback = component["connectedCallback"];
23
27
  component["connectedCallback"] = () => {
24
- const element = getElement(component);
25
- observer.observe(element, { childList: true, subtree: true, characterData: true });
26
- onUpdate(element.textContent);
28
+ var _a;
29
+ hostElement = getElement(component);
30
+ observer.observe(hostElement, { childList: true, subtree: true, characterData: true });
31
+ onUpdate((_a = hostElement.textContent) !== null && _a !== void 0 ? _a : "");
27
32
  runIfExisits(connectedCallback, component);
28
33
  };
29
34
  const disconnectedCallback = component["disconnectedCallback"];
@@ -1 +1 @@
1
- import{getElement as t,proxyCustomElement as s,HTMLElement as i,h as e,Host as n,transformTag as a}from"@stencil/core/internal/client";import{g as r,c as o}from"./context-protocol.js";import{r as l}from"./utils.js";import{w as h}from"./withBodyObserver.js";import{w as c,a as u}from"./withHasError.js";import{d,c as f}from"./contentDecoder.js";const p=["ac1","ac2","ac3","ac4","pp1","pp2","pp3","pp4","fc1","fc2","fc3","fc4","pl1","pl2","pl3","pl4"],m=["rowGroup","category","subCategory","columnGroup","columnSubGroup"];function g(t){return"number"==typeof t&&!isNaN(t)&&isFinite(t)}function v(t){const s=Array.from(t);return{distinctValues:s,count:s.length,hasData:s.length>0}}const y=s(class extends i{constructor(s){super(),!1!==s&&this.__registerHost(),this.datasources="",this.static=!1,this.raw=!0,this.interval=0,this.lastBodyHash=null,this.lastViewQuery=null,this.currentUrl=null,this.pollTimerId=null,this.abortController=null,c(this),this.errors=u(this),((s,i)=>{let e,n=[],a=[];const h=t=>{let s;try{s=e.db.db.exec(`SELECT * FROM \`${t}\``)}catch(t){s=[]}i()},c=()=>{n.forEach((t=>t())),n=[],a.forEach((t=>{t&&(n.push(e.db.subscribe(t,(()=>h(t)))),h(t))}))},u=new MutationObserver((i=>{i.forEach((i=>{"datasources"===i.attributeName&&(a=(t(s).getAttribute("datasources")||"").split(","),c())}))})),d=s.connectedCallback;s.connectedCallback=()=>{const i=t(s);e=r(i),a=(i.getAttribute("datasources")||"").split(","),c(),u.observe(i,{attributes:!0,attributeFilter:["datasources"]}),l(d,s)};const f=s.disconnectedCallback;s.disconnectedCallback=()=>{u.disconnect(),n.forEach((t=>t())),n=[],o(t(s)),l(f,s)}})(this,(()=>{this.executeQuery()})),h(this,(t=>{const s=t.trim();if(this.isUrl(s)){if(s===this.currentUrl)return;return this.currentUrl=s,this.lastBodyHash=null,this.fetchAndStore(s),void this.startPolling()}let i,e;if(null!==this.currentUrl&&(this.clearPolling(),this.currentUrl=null),!this.raw&&this.static)try{const s=d(t);i=s.hash,e=s.json}catch(s){return void console.error("Error decoding compressed dataset",s,(t+"").slice(0,200))}else i=f(t),e=t;i!==this.lastBodyHash&&(this.lastBodyHash=i,this.query=e,this.executeQuery())}))}executeQuery(){if(this.stores||(this.stores=r(this.element)),!this.query||!this.name)return;const t=this.stores.db.db;let s;if(this.static){try{s=JSON.parse(this.query)}catch(t){console.error("Failed to parse static dataset",t),s=[]}t.tables[this.name]={data:Array.isArray(s)?s:[]},this.lastViewQuery=null}else{if(this.lastViewQuery!==this.query)try{t.views&&null!=t.views[this.name]&&t.exec(`DROP VIEW \`${this.name}\``),t.exec(`CREATE VIEW \`${this.name}\` AS ${this.query}`),this.lastViewQuery=this.query}catch(t){return console.error("bn-dataset: failed to register SQL view",t,this.query),this.lastViewQuery=null,s=[],void this.publish(s)}try{s=t.exec(`SELECT * FROM \`${this.name}\``)}catch(t){console.error("bn-dataset: SQL execution failed",t,this.query),s=[]}}this.publish(s)}publish(t){this.latestResult!==t?(this.latestResult=t,this.stores.db.notify(this.name),this.stores.datasetsMeta.set(this.name,function(t){const s={};for(const t of m)s[t]=new Set;const i={};for(const t of p)i[t]={hasData:!1,min:null,max:null};const e=new Set;let n=null,a=null;const r=Array.isArray(t)?t:[];for(let t=0;t<r.length;t++){const o=r[t];if(null==o)continue;for(const t of m){const i=o[t];null!=i&&""!==i&&s[t].add(i+"")}for(const t of p){const s=o[t];if(g(s)){const e=i[t];e.hasData=!0,(null===e.min||s<e.min)&&(e.min=s),(null===e.max||s>e.max)&&(e.max=s)}}const l=o.date;if(null!=l&&""!==l){const t=l+"";e.add(t),(null===n||t<n)&&(n=t),(null===a||t>a)&&(a=t)}}const o=p.map((t=>({key:t,hasData:i[t].hasData,min:i[t].min,max:i[t].max}))),l=o.filter((t=>t.hasData)).map((t=>t.key)),h=v(s.rowGroup),c=v(s.category),u=v(s.subCategory),d=v(s.columnGroup),f=v(s.columnSubGroup),y={min:n,max:a,hasData:e.size>0,distinctCount:e.size};let b="category";return u.hasData?b="subCategory":c.hasData?b="category":h.hasData&&(b="rowGroup"),{rowCount:r.length,scenarios:o,availableScenarios:l,rowGroup:h,category:c,subCategory:u,columnGroup:d,columnSubGroup:f,dateRange:y,suggestedLevel:b,suggestedOrder:b,suggestedDateInterval:y.hasData?"auto":null,calculatedAt:Date.now()}}(t))):this.stores.db.notify(this.name)}nameUpdated(){this.executeQuery()}onIntervalChange(){this.currentUrl&&this.startPolling()}disconnectedCallback(){var t,s;if(this.clearPolling(),(null===(s=null===(t=this.stores)||void 0===t?void 0:t.db)||void 0===s?void 0:s.db)&&this.name){const t=this.stores.db.db;try{t.views&&null!=t.views[this.name]&&t.exec(`DROP VIEW \`${this.name}\``)}catch(t){}null!=t.tables[this.name]&&delete t.tables[this.name],this.stores.db.notify(this.name)}}isUrl(t){return t.startsWith("http://")||t.startsWith("https://")}async fetchAndStore(t){var s;null===(s=this.abortController)||void 0===s||s.abort(),this.abortController=new AbortController,this.stores||(this.stores=r(this.element));try{const s=await fetch(t,{signal:this.abortController.signal}),i=await s.json();this.stores.db.db.tables[this.name]={data:Array.isArray(i)?i:[]},this.lastViewQuery=null,this.publish(i)}catch(s){if(s instanceof DOMException&&"AbortError"===s.name)return;console.error("bn-dataset: error fetching URL",s,t),this.stores.db.db.tables[this.name]={data:[]},this.lastViewQuery=null,this.publish([])}}clearPolling(){var t;null!==this.pollTimerId&&(clearInterval(this.pollTimerId),this.pollTimerId=null),null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=null}startPolling(){this.clearPolling(),this.currentUrl&&this.interval>0&&(this.pollTimerId=setInterval((()=>{this.currentUrl&&this.fetchAndStore(this.currentUrl)}),1e3*this.interval))}render(){return e(n,{key:"d8f90bd66e8d9aafc83c0818cc0e6573a3186568"})}get element(){return this}static get watchers(){return{name:[{nameUpdated:0}],interval:[{onIntervalChange:0}]}}static get style(){return"bn-dataset{display:none}"}},[0,"bn-dataset",{name:[1],datasources:[1],static:[4],raw:[4],interval:[2]},void 0,{name:[{nameUpdated:0}],interval:[{onIntervalChange:0}]}]),b=y,w=function(){"undefined"!=typeof customElements&&["bn-dataset"].forEach((t=>{"bn-dataset"===t&&(customElements.get(a(t))||customElements.define(a(t),y))}))};export{b as BnDataset,w as defineCustomElement}
1
+ import{getElement as t,proxyCustomElement as s,HTMLElement as i,h as e,Host as n,transformTag as r}from"@stencil/core/internal/client";import{g as a,c as o}from"./context-protocol.js";import{r as l}from"./utils.js";import{w as h}from"./withBodyObserver.js";import{w as c,a as u}from"./withHasError.js";import{d,c as f}from"./contentDecoder.js";const p=["ac1","ac2","ac3","ac4","pp1","pp2","pp3","pp4","fc1","fc2","fc3","fc4","pl1","pl2","pl3","pl4"],m=["rowGroup","category","subCategory","columnGroup","columnSubGroup"];function y(t){return"number"==typeof t&&!isNaN(t)&&isFinite(t)}function g(t){const s=Array.from(t);return{distinctValues:s,count:s.length,hasData:s.length>0}}const v=s(class extends i{constructor(s){super(),!1!==s&&this.__registerHost(),this.datasources="",this.static=!1,this.raw=!0,this.interval=0,this.lastBodyHash=null,this.lastViewQuery=null,this.currentUrl=null,this.pollTimerId=null,this.abortController=null,c(this),this.errors=u(this),((s,i)=>{let e,n=[],r=[];const h=t=>{let s;try{s=e.db.db.exec(`SELECT * FROM \`${t}\``)}catch(t){s=[]}i()},c=()=>{n.forEach((t=>t())),n=[],r.forEach((t=>{t&&(n.push(e.db.subscribe(t,(()=>h(t)))),h(t))}))},u=new MutationObserver((i=>{i.forEach((i=>{"datasources"===i.attributeName&&(r=(t(s).getAttribute("datasources")||"").split(","),c())}))})),d=s.connectedCallback;s.connectedCallback=()=>{const i=t(s);e=a(i),r=(i.getAttribute("datasources")||"").split(","),c(),u.observe(i,{attributes:!0,attributeFilter:["datasources"]}),l(d,s)};const f=s.disconnectedCallback;s.disconnectedCallback=()=>{u.disconnect(),n.forEach((t=>t())),n=[],o(t(s)),l(f,s)}})(this,(()=>{this.executeQuery()})),h(this,(t=>{const s=t.trim();if(this.isUrl(s)){if(s===this.currentUrl)return;return this.currentUrl=s,this.lastBodyHash=null,this.fetchAndStore(s),void this.startPolling()}let i,e;if(null!==this.currentUrl&&(this.clearPolling(),this.currentUrl=null),!this.raw&&this.static)try{const s=d(t);i=s.hash,e=s.json}catch(s){return void console.error("Error decoding compressed dataset",s,(t+"").slice(0,200))}else i=f(t),e=t;i!==this.lastBodyHash&&(this.lastBodyHash=i,this.query=e,this.executeQuery())}))}executeQuery(){if(this.stores||(this.stores=a(this.element)),!this.query||!this.name)return;const t=this.stores.db.db;let s;if(this.static){try{s=JSON.parse(this.query)}catch(t){console.error("Failed to parse static dataset",t),s=[]}t.tables[this.name]={data:Array.isArray(s)?s:[]},this.lastViewQuery=null}else{if(this.lastViewQuery!==this.query){try{t.exec(`DROP VIEW \`${this.name}\``)}catch(t){}null!=t.tables[this.name]&&delete t.tables[this.name],t.views&&null!=t.views[this.name]&&delete t.views[this.name];try{t.exec(`CREATE VIEW \`${this.name}\` AS ${this.query}`),this.lastViewQuery=this.query}catch(t){return console.error("bn-dataset: failed to register SQL view",t,this.query),this.lastViewQuery=null,s=[],void this.publish(s)}}try{s=t.exec(`SELECT * FROM \`${this.name}\``)}catch(t){return}}this.publish(s)}publish(t){this.latestResult!==t?(this.latestResult=t,this.stores.db.notify(this.name),this.stores.datasetsMeta.set(this.name,function(t){const s={};for(const t of m)s[t]=new Set;const i={};for(const t of p)i[t]={hasData:!1,min:null,max:null};const e=new Set;let n=null,r=null;const a=Array.isArray(t)?t:[];for(let t=0;t<a.length;t++){const o=a[t];if(null==o)continue;for(const t of m){const i=o[t];null!=i&&""!==i&&s[t].add(i+"")}for(const t of p){const s=o[t];if(y(s)){const e=i[t];e.hasData=!0,(null===e.min||s<e.min)&&(e.min=s),(null===e.max||s>e.max)&&(e.max=s)}}const l=o.date;if(null!=l&&""!==l){const t=l+"";e.add(t),(null===n||t<n)&&(n=t),(null===r||t>r)&&(r=t)}}const o=p.map((t=>({key:t,hasData:i[t].hasData,min:i[t].min,max:i[t].max}))),l=o.filter((t=>t.hasData)).map((t=>t.key)),h=g(s.rowGroup),c=g(s.category),u=g(s.subCategory),d=g(s.columnGroup),f=g(s.columnSubGroup),v={min:n,max:r,hasData:e.size>0,distinctCount:e.size};let b="category";return u.hasData?b="subCategory":c.hasData?b="category":h.hasData&&(b="rowGroup"),{rowCount:a.length,scenarios:o,availableScenarios:l,rowGroup:h,category:c,subCategory:u,columnGroup:d,columnSubGroup:f,dateRange:v,suggestedLevel:b,suggestedOrder:b,suggestedDateInterval:v.hasData?"auto":null,calculatedAt:Date.now()}}(t))):this.stores.db.notify(this.name)}nameUpdated(){this.executeQuery()}onIntervalChange(){this.currentUrl&&this.startPolling()}disconnectedCallback(){var t,s;if(this.clearPolling(),(null===(s=null===(t=this.stores)||void 0===t?void 0:t.db)||void 0===s?void 0:s.db)&&this.name){const t=this.stores.db.db;try{t.exec(`DROP VIEW \`${this.name}\``)}catch(t){}null!=t.tables[this.name]&&delete t.tables[this.name],t.views&&null!=t.views[this.name]&&delete t.views[this.name],this.stores.db.notify(this.name)}}isUrl(t){return!(!t.startsWith("http://")&&!t.startsWith("https://"))||t.startsWith("/")&&!t.startsWith("//")}async fetchAndStore(t){var s;null===(s=this.abortController)||void 0===s||s.abort(),this.abortController=new AbortController,this.stores||(this.stores=a(this.element));try{const s=await fetch(t,{signal:this.abortController.signal}),i=await s.json();this.stores.db.db.tables[this.name]={data:Array.isArray(i)?i:[]},this.lastViewQuery=null,this.publish(i)}catch(s){if(s instanceof DOMException&&"AbortError"===s.name)return;console.error("bn-dataset: error fetching URL",s,t),this.stores.db.db.tables[this.name]={data:[]},this.lastViewQuery=null,this.publish([])}}clearPolling(){var t;null!==this.pollTimerId&&(clearInterval(this.pollTimerId),this.pollTimerId=null),null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=null}startPolling(){this.clearPolling(),this.currentUrl&&this.interval>0&&(this.pollTimerId=setInterval((()=>{this.currentUrl&&this.fetchAndStore(this.currentUrl)}),1e3*this.interval))}render(){return e(n,{key:"fc620f662e5e23800416e0a43dcdf2df6a4859fc"})}get element(){return this}static get watchers(){return{name:[{nameUpdated:0}],interval:[{onIntervalChange:0}]}}static get style(){return"bn-dataset{display:none}"}},[0,"bn-dataset",{name:[1],datasources:[1],static:[4],raw:[4],interval:[2]},void 0,{name:[{nameUpdated:0}],interval:[{onIntervalChange:0}]}]),b=v,w=function(){"undefined"!=typeof customElements&&["bn-dataset"].forEach((t=>{"bn-dataset"===t&&(customElements.get(r(t))||customElements.define(r(t),v))}))};export{b as BnDataset,w as defineCustomElement}
@@ -1 +1 @@
1
- import{proxyCustomElement as t,HTMLElement as s,h as i,Host as e,transformTag as n}from"@stencil/core/internal/client";import{w as r}from"./withBodyObserver.js";import{g as h}from"./context-protocol.js";import{w as o,a as l}from"./withHasError.js";import{c as a,d as c}from"./contentDecoder.js";const u=t(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.raw=!0,this.interval=0,this.lastHash=null,this.currentUrl=null,this.pollTimerId=null,this.abortController=null,o(this),this.errors=l(this),r(this,(t=>{this.stores||(this.stores=h(this.element));const s=t.trim();if(this.isUrl(s)){if(s===this.currentUrl)return;return this.currentUrl=s,this.lastHash=null,this.fetchAndStore(s),void this.startPolling()}null!==this.currentUrl&&(this.clearPolling(),this.currentUrl=null);try{let s,i;if(this.raw)s=a(t),i=t;else{const e=c(t);s=e.hash,i=e.json}if(s===this.lastHash)return;this.lastHash=s;const e=JSON.parse(i);this.publish(e)}catch(s){console.error("Error parsing datasource",s,(t+"").slice(0,200)),this.publish([])}}))}publish(t){this.stores.db.db.tables[this.name]={data:Array.isArray(t)?t:[]},this.stores.db.notify(this.name)}onIntervalChange(){this.currentUrl&&this.startPolling()}disconnectedCallback(){var t,s,i,e;this.clearPolling(),(null===(e=null===(i=null===(s=null===(t=this.stores)||void 0===t?void 0:t.db)||void 0===s?void 0:s.db)||void 0===i?void 0:i.tables)||void 0===e?void 0:e[this.name])&&(delete this.stores.db.db.tables[this.name],this.stores.db.notify(this.name))}isUrl(t){return t.startsWith("http://")||t.startsWith("https://")}async fetchAndStore(t){var s;null===(s=this.abortController)||void 0===s||s.abort(),this.abortController=new AbortController,this.stores||(this.stores=h(this.element));try{const s=await fetch(t,{signal:this.abortController.signal}),i=await s.json();this.publish(i)}catch(s){if(s instanceof DOMException&&"AbortError"===s.name)return;console.error("bn-datasource: error fetching URL",s,t),this.publish([])}}clearPolling(){var t;null!==this.pollTimerId&&(clearInterval(this.pollTimerId),this.pollTimerId=null),null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=null}startPolling(){this.clearPolling(),this.currentUrl&&this.interval>0&&(this.pollTimerId=setInterval((()=>{this.currentUrl&&this.fetchAndStore(this.currentUrl)}),1e3*this.interval))}render(){return i(e,{key:"541bcc84a90dc736d62f1c596e0b9e3e5a54ebf3"})}get element(){return this}static get watchers(){return{interval:[{onIntervalChange:0}]}}static get style(){return"bn-datasource{display:none}"}},[0,"bn-datasource",{name:[1],raw:[4],interval:[2]},void 0,{interval:[{onIntervalChange:0}]}]),d=u,v=function(){"undefined"!=typeof customElements&&["bn-datasource"].forEach((t=>{"bn-datasource"===t&&(customElements.get(n(t))||customElements.define(n(t),u))}))};export{d as BnDatasource,v as defineCustomElement}
1
+ import{proxyCustomElement as t,HTMLElement as s,h as i,Host as e,transformTag as n}from"@stencil/core/internal/client";import{w as r}from"./withBodyObserver.js";import{g as h}from"./context-protocol.js";import{w as l,a as o}from"./withHasError.js";import{c as a,d as c}from"./contentDecoder.js";const u=t(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.raw=!0,this.interval=0,this.lastHash=null,this.currentUrl=null,this.pollTimerId=null,this.abortController=null,l(this),this.errors=o(this),r(this,(t=>{this.stores||(this.stores=h(this.element));const s=t.trim();if(this.isUrl(s)){if(s===this.currentUrl)return;return this.currentUrl=s,this.lastHash=null,this.fetchAndStore(s),void this.startPolling()}null!==this.currentUrl&&(this.clearPolling(),this.currentUrl=null);try{let s,i;if(this.raw)s=a(t),i=t;else{const e=c(t);s=e.hash,i=e.json}if(s===this.lastHash)return;this.lastHash=s;const e=JSON.parse(i);this.publish(e)}catch(s){console.error("Error parsing datasource",s,(t+"").slice(0,200)),this.publish([])}}))}publish(t){this.stores.db.db.tables[this.name]={data:Array.isArray(t)?t:[]},this.stores.db.notify(this.name)}onIntervalChange(){this.currentUrl&&this.startPolling()}disconnectedCallback(){var t,s;this.clearPolling();const i=null===(s=null===(t=this.stores)||void 0===t?void 0:t.db)||void 0===s?void 0:s.db;i&&this.name&&(null!=i.tables[this.name]&&delete i.tables[this.name],i.views&&null!=i.views[this.name]&&delete i.views[this.name],this.stores.db.notify(this.name))}isUrl(t){return!(!t.startsWith("http://")&&!t.startsWith("https://"))||t.startsWith("/")&&!t.startsWith("//")}async fetchAndStore(t){var s;null===(s=this.abortController)||void 0===s||s.abort(),this.abortController=new AbortController,this.stores||(this.stores=h(this.element));try{const s=await fetch(t,{signal:this.abortController.signal}),i=await s.json();this.publish(i)}catch(s){if(s instanceof DOMException&&"AbortError"===s.name)return;console.error("bn-datasource: error fetching URL",s,t),this.publish([])}}clearPolling(){var t;null!==this.pollTimerId&&(clearInterval(this.pollTimerId),this.pollTimerId=null),null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=null}startPolling(){this.clearPolling(),this.currentUrl&&this.interval>0&&(this.pollTimerId=setInterval((()=>{this.currentUrl&&this.fetchAndStore(this.currentUrl)}),1e3*this.interval))}render(){return i(e,{key:"7690736d5996a63f5e2fbccd00876d560261185f"})}get element(){return this}static get watchers(){return{interval:[{onIntervalChange:0}]}}static get style(){return"bn-datasource{display:none}"}},[0,"bn-datasource",{name:[1],raw:[4],interval:[2]},void 0,{interval:[{onIntervalChange:0}]}]),d=u,f=function(){"undefined"!=typeof customElements&&["bn-datasource"].forEach((t=>{"bn-datasource"===t&&(customElements.get(n(t))||customElements.define(n(t),u))}))};export{d as BnDatasource,f as defineCustomElement}
@@ -1 +1 @@
1
- import{getElement as t}from"@stencil/core/internal/client";import{r}from"./utils.js";const s=(s,e)=>{const o=new MutationObserver((t=>{t.forEach((t=>{e(t.target.textContent)}))})),c=s.connectedCallback;s.connectedCallback=()=>{const n=t(s);o.observe(n,{childList:!0,subtree:!0,characterData:!0}),e(n.textContent),r(c,s)};const n=s.disconnectedCallback;s.disconnectedCallback=()=>{o.disconnect(),r(n,s)}};export{s as w}
1
+ import{getElement as t}from"@stencil/core/internal/client";import{r}from"./utils.js";const e=(e,o)=>{let i;const n=new MutationObserver((()=>{var t;i&&o(null!==(t=i.textContent)&&void 0!==t?t:"")})),s=e.connectedCallback;e.connectedCallback=()=>{var a;i=t(e),n.observe(i,{childList:!0,subtree:!0,characterData:!0}),o(null!==(a=i.textContent)&&void 0!==a?a:""),r(s,e)};const a=e.disconnectedCallback;e.disconnectedCallback=()=>{n.disconnect(),r(a,e)}};export{e as w}
@@ -1,7 +1,7 @@
1
1
  import { r as registerInstance, h, H as Host, g as getElement, f as forceUpdate, d as writeTask, e as getAssetPath, F as Fragment$1 } from './index-B_d-jp99.js';
2
2
  import { w as withComponentStatus, a as withHasError, r as runIfExisits } from './withHasError-DW_vMDUp.js';
3
3
  import { g as getStores, c as clearStoresCache, a as globalLabelKeys, b as getDefaultExportFromCjs, d as getOrCreateStores, D as DateTime, e as buildFromExpr } from './context-protocol-BDhzNbeD.js';
4
- import { w as withBodyObserver } from './withBodyObserver-AFk2wwHT.js';
4
+ import { w as withBodyObserver } from './withBodyObserver-IokS6fHD.js';
5
5
  import { a as withComponentStyle, v as validateScenarioList, c as validateVariancesList, b as isValidNumber, d as isValidLevel, e as validateOrderList, f as isValidDirection, g as isValidInteger, i as isValidBoolean, h as isValidMeasureScale, j as validateStackConfig, w as withStyled, k as isBlankInput, A as AggregationLevel$1, O as OrderDirection$1, l as OrderColumn, S as StackBy, m as StackOrder, n as StackMode, o as isValidDateFormat, p as isValidAxisLabelsMode, D as DateDistance, q as AxisLabelsMode, C as ChartMode, r as murmur2, s as isTableBarColumnWidth, t as isValidDataFormat, u as isValidTableType, x as validateThereOfJsonStr, y as validatePartOfJsonStr, z as isValidMeasureType, B as isTableCategoryWidth, E as validateColumnThereOfJsonStr, F as DataFormat, I as I18nMode, T as TableCategoryWidth, M as MeasureType, G as BAR_COLUMN_WIDTH_EM, H as TableBarColumnWidth, J as validateMeasureList, K as isValidDate, L as isValidDateLink, N as DateLink, P as AdapterUtils, Q as CompareUtil, R as OrderAdapter, U as DateStringFactory } from './withStyled-Bl9cSoRW.js';
6
6
  import { a as withDataset, w as withTranslation, g as getParentDimensions, p as parseScaling } from './scaling-La1Ow72h.js';
7
7
 
@@ -3348,12 +3348,26 @@ const Dataset = class {
3348
3348
  // query text changes; otherwise we just re-materialize so upstream data updates
3349
3349
  // flow through.
3350
3350
  if (this.lastViewQuery !== this.query) {
3351
+ // alasql tracks names in BOTH `db.tables` and `db.views`, and its
3352
+ // CREATE-conflict check looks at `db.tables`. Clean both locations
3353
+ // before creating so devtools "Edit as HTML" (which destroys the old
3354
+ // element and creates a new one without giving us a clean slate)
3355
+ // doesn't trip the "already exists" guard.
3356
+ try {
3357
+ db.exec(`DROP VIEW \`${this.name}\``);
3358
+ }
3359
+ catch (_e) {
3360
+ /* not registered as a view — fine */
3361
+ }
3362
+ if (db.tables[this.name] != null) {
3363
+ delete db.tables[this.name];
3364
+ }
3365
+ // @ts-ignore - views typing is loose
3366
+ if (db.views && db.views[this.name] != null) {
3367
+ // @ts-ignore
3368
+ delete db.views[this.name];
3369
+ }
3351
3370
  try {
3352
- // alasql stores views in `db.views` keyed by name; drop any prior version.
3353
- // @ts-ignore - views typing is loose
3354
- if (db.views && db.views[this.name] != null) {
3355
- db.exec(`DROP VIEW \`${this.name}\``);
3356
- }
3357
3371
  db.exec(`CREATE VIEW \`${this.name}\` AS ${this.query}`);
3358
3372
  this.lastViewQuery = this.query;
3359
3373
  }
@@ -3368,9 +3382,12 @@ const Dataset = class {
3368
3382
  try {
3369
3383
  result = db.exec(`SELECT * FROM \`${this.name}\``);
3370
3384
  }
3371
- catch (e) {
3372
- console.error("bn-dataset: SQL execution failed", e, this.query);
3373
- result = [];
3385
+ catch (_e) {
3386
+ // Most common cause: an upstream datasource referenced by the view hasn't
3387
+ // been registered yet (HTML parse/connectedCallback race). `withDatasource`
3388
+ // re-fires executeQuery on every upstream notify, so we'll retry then.
3389
+ // Skip publish so we don't clobber datasetsMeta with empty data.
3390
+ return;
3374
3391
  }
3375
3392
  }
3376
3393
  this.publish(result);
@@ -3402,25 +3419,31 @@ const Dataset = class {
3402
3419
  if (((_b = (_a = this.stores) === null || _a === void 0 ? void 0 : _a.db) === null || _b === void 0 ? void 0 : _b.db) && this.name) {
3403
3420
  const db = this.stores.db.db;
3404
3421
  try {
3405
- // @ts-ignore - views typing is loose
3406
- if (db.views && db.views[this.name] != null) {
3407
- db.exec(`DROP VIEW \`${this.name}\``);
3408
- }
3422
+ db.exec(`DROP VIEW \`${this.name}\``);
3409
3423
  }
3410
3424
  catch (_e) {
3411
- // ignore; view may not exist
3425
+ // not registered as a view — fine
3412
3426
  }
3413
3427
  if (db.tables[this.name] != null) {
3414
3428
  delete db.tables[this.name];
3415
3429
  }
3430
+ // @ts-ignore - views typing is loose
3431
+ if (db.views && db.views[this.name] != null) {
3432
+ // @ts-ignore
3433
+ delete db.views[this.name];
3434
+ }
3416
3435
  this.stores.db.notify(this.name);
3417
3436
  }
3418
3437
  }
3419
3438
  /**
3420
- * Returns `true` if the text starts with `http://` or `https://`.
3439
+ * Returns `true` if the text is a fetchable URL: an absolute `http(s)://`
3440
+ * URL, or a same-origin path starting with `/` (but not `//`, which is a
3441
+ * protocol-relative URL we treat as inline-mode escape).
3421
3442
  */
3422
3443
  isUrl(text) {
3423
- return text.startsWith("http://") || text.startsWith("https://");
3444
+ if (text.startsWith("http://") || text.startsWith("https://"))
3445
+ return true;
3446
+ return text.startsWith("/") && !text.startsWith("//");
3424
3447
  }
3425
3448
  /**
3426
3449
  * Fetches JSON from the given URL and stores the result as the dataset.
@@ -3472,7 +3495,7 @@ const Dataset = class {
3472
3495
  }
3473
3496
  }
3474
3497
  render() {
3475
- return h(Host, { key: 'd8f90bd66e8d9aafc83c0818cc0e6573a3186568' });
3498
+ return h(Host, { key: 'fc620f662e5e23800416e0a43dcdf2df6a4859fc' });
3476
3499
  }
3477
3500
  get element() { return getElement(this); }
3478
3501
  static get watchers() { return {
@@ -3572,18 +3595,30 @@ const Datasource = class {
3572
3595
  }
3573
3596
  }
3574
3597
  disconnectedCallback() {
3575
- var _a, _b, _c, _d;
3598
+ var _a, _b;
3576
3599
  this.clearPolling();
3577
- if ((_d = (_c = (_b = (_a = this.stores) === null || _a === void 0 ? void 0 : _a.db) === null || _b === void 0 ? void 0 : _b.db) === null || _c === void 0 ? void 0 : _c.tables) === null || _d === void 0 ? void 0 : _d[this.name]) {
3578
- delete this.stores.db.db.tables[this.name];
3600
+ const db = (_b = (_a = this.stores) === null || _a === void 0 ? void 0 : _a.db) === null || _b === void 0 ? void 0 : _b.db;
3601
+ if (db && this.name) {
3602
+ if (db.tables[this.name] != null) {
3603
+ delete db.tables[this.name];
3604
+ }
3605
+ // @ts-ignore - views typing is loose
3606
+ if (db.views && db.views[this.name] != null) {
3607
+ // @ts-ignore
3608
+ delete db.views[this.name];
3609
+ }
3579
3610
  this.stores.db.notify(this.name);
3580
3611
  }
3581
3612
  }
3582
3613
  /**
3583
- * Returns `true` if the text starts with `http://` or `https://`.
3614
+ * Returns `true` if the text is a fetchable URL: an absolute `http(s)://`
3615
+ * URL, or a same-origin path starting with `/` (but not `//`, which is a
3616
+ * protocol-relative URL we treat as inline-mode escape).
3584
3617
  */
3585
3618
  isUrl(text) {
3586
- return text.startsWith("http://") || text.startsWith("https://");
3619
+ if (text.startsWith("http://") || text.startsWith("https://"))
3620
+ return true;
3621
+ return text.startsWith("/") && !text.startsWith("//");
3587
3622
  }
3588
3623
  /**
3589
3624
  * Fetches JSON from the given URL and stores the result.
@@ -3629,7 +3664,7 @@ const Datasource = class {
3629
3664
  }
3630
3665
  }
3631
3666
  render() {
3632
- return h(Host, { key: '541bcc84a90dc736d62f1c596e0b9e3e5a54ebf3' });
3667
+ return h(Host, { key: '7690736d5996a63f5e2fbccd00876d560261185f' });
3633
3668
  }
3634
3669
  get element() { return getElement(this); }
3635
3670
  static get watchers() { return {
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, h, H as Host, g as getElement } from './index-B_d-jp99.js';
2
- import { w as withBodyObserver } from './withBodyObserver-AFk2wwHT.js';
2
+ import { w as withBodyObserver } from './withBodyObserver-IokS6fHD.js';
3
3
  import { g as getStores, f as flattenObject } from './context-protocol-BDhzNbeD.js';
4
4
  import { w as withComponentStatus, a as withHasError } from './withHasError-DW_vMDUp.js';
5
5