buzzcasting-storage 3.21.5 → 3.22.2

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/LICENSE CHANGED
File without changes
package/README.md CHANGED
@@ -6,6 +6,16 @@ BuzzCasting Social Media Wall & Dataviz [More info](https://www.touchflows.com/s
6
6
 
7
7
  Currently supported are: Local Storage, Session Storage, IDB Keyval, Dexie, Window object
8
8
 
9
+ ## Documentation
10
+
11
+ `docs/` is typedoc-generated API reference (regenerated by `npm run docs`, overwritten every time — don't hand-edit it). Hand-written architecture guides live in [`documentation/`](documentation/) instead:
12
+
13
+ - [documentation/architecture.md](documentation/architecture.md) — the `BuzzcastingStorageManager`/`Widget`/`BuzzcastingStorageReader` pipeline, the subscribe → fetch → hash-diff → broadcast → re-read data flow, and why a `Widget` can only ever render `cloud`/`series`/`messages` data.
14
+ - [documentation/storage-backends.md](documentation/storage-backends.md) — the five interchangeable storage backends, the Dexie schema, and the staleness/expiry model (there isn't much of one).
15
+ - [documentation/known-issues.md](documentation/known-issues.md) — confirmed bugs and inconsistencies in the current codebase (e.g. `ApiClient.loadDashboards` actually fetching the widgets endpoint, not a dashboards one) worth knowing about before you hit them yourself.
16
+ - [documentation/moderation.md](documentation/moderation.md) — `hideMessage`/`hideLabels`: a soft `visible` flag in Dexie plus a remote call for messages, a remote-only call with no local implementation at all for cloud labels, and the separate, deployment-time `MODERATION` enum that gates which messages are ever fetched in the first place.
17
+ - [documentation/release-process.md](documentation/release-process.md) — `npm run release` bumps/tags/pushes locally, but the actual `npm publish` now happens in CI on that tag push (via npm Trusted Publishing/OIDC, no stored token) - what to do if a release run fails.
18
+
9
19
  ## Features
10
20
 
11
21
  - ✨ Fully customized [eslint](https://eslint.org/) configuration based on the config by [Antfu](https://github.com/antfu/eslint-config)
@@ -18,59 +28,47 @@ Currently supported are: Local Storage, Session Storage, IDB Keyval, Dexie, Wind
18
28
 
19
29
  ## Get started
20
30
 
21
- Example call:
22
-
23
- ```ts
24
- import BuzzcastingStorageManager, {
25
- IMessages,
26
- IQuery,
27
- IStorageManager,
28
- } from 'buzzcasting-storage'
29
-
30
- const options: IStorageManager = {
31
- app: 'my-subdomain',
32
- version: 'v4',
33
- token: 'meta',
34
- bearer: 'bearer_token',
35
- storage: 'dexie',
36
- moderation: 'none',
37
- beforeTime: null,
38
- delay: 0,
39
- period: 0,
40
- }
31
+ This package has two entry points, used by two different kinds of consumer — see [documentation/architecture.md](documentation/architecture.md) for the full picture.
41
32
 
42
- const storageManager = new BuzzcastingStorageManager(options)
33
+ **A rendered widget component** (e.g. a `cards-widget`/`series-widget`/`cloud-widget` in `buzzcasting-app`) uses `Widget`, keyed off its own `data-*` attributes:
43
34
 
44
- const query: IQuery = {
45
- type: 'messages',
46
- dashboard: 'dashboard_id',
47
- widget: 'widget_id',
35
+ ```ts
36
+ import { Widget } from 'buzzcasting-storage'
37
+ import type { IResponse } from 'buzzcasting-utils'
38
+
39
+ // element.dataset.{widget,dashboard,type} become the query; window.__bc.opts
40
+ // must already be set up by the host app (it supplies `presentation`).
41
+ const setData = (response: IResponse) => {
42
+ if (!response.success) return
43
+ // ...update component state from response.data
48
44
  }
49
45
 
50
- const data: IMessages = storageManager.getMessages(query)
46
+ const widget = new Widget(element, [setData])
47
+ widget.subscribe() // registers with the app-level BuzzcastingStorageManager
51
48
  ```
52
49
 
53
- This will initiate a call to the buzzcasting backoffice to retrieve results
50
+ `Widget` only supports `series`, `cloud`, and `messages` query types — nothing else (this is a hard architectural constraint, see [documentation/architecture.md](documentation/architecture.md)).
54
51
 
55
- The Storage Manager will carry out the API call for the subscriber, and send out a BroadcastChannel on `app` to inform the subcriber that it can retrieve new data. The broadcast channel facilitates its incorporation in for example a Web Worker.
52
+ **The host app itself** (once, at startup) constructs the orchestrator every `Widget` rendezvouses with over a shared `BroadcastChannel`:
56
53
 
57
54
  ```ts
58
- const broadcastChannel = new BroadcastChannel('my-subdomain')
55
+ import { BuzzcastingStorageManager } from 'buzzcasting-storage'
56
+ import type { IStorageOptions } from 'buzzcasting-utils'
59
57
 
60
- broadcastChannel.onmessage = (messageEvent: MessageEvent) => {
61
- this.actions(messageEvent)
58
+ const options: IStorageOptions = {
59
+ app: 'my-subdomain',
60
+ version: 'v4',
61
+ presentation: 'presentation_id',
62
+ locale: 'en-US',
63
+ bearer: 'bearer_token',
64
+ storage: 'dexie', // the only backend actually exercised in production - see documentation/storage-backends.md
62
65
  }
63
66
 
64
- actions = (messageEvent: MessageEvent) => {
65
- switch (messageEvent.data.event) {
66
- case 'widget-update':
67
- // handle update
68
- this.widgetUpdated.emit(messageEvent.data.data)
69
- break
70
- default:
71
- // console.log('[storage]', messageEvent.data)
72
- }
73
- }
67
+ const storageManager = new BuzzcastingStorageManager(options)
68
+ storageManager.startBroadcastListener() // begins listening for widget SUBSCRIBE/UPDATE events
69
+
70
+ // on whatever interval/event the host app decides:
71
+ await storageManager.update()
74
72
  ```
75
73
 
76
74
  ### Git Clone
@@ -87,7 +85,7 @@ The project contains the following scripts:
87
85
 
88
86
  - `dev` - Start the development server
89
87
  - `build` - Build for production
90
- - `release` - Generate changelog and npm publish
88
+ - `release` - Generate changelog, bump the version, tag, and push - the pushed tag triggers CI to actually run `npm publish` (see [documentation/release-process.md](documentation/release-process.md))
91
89
  - `lint` - Checks your code for any linting errors
92
90
  - `test` - Run all tests
93
91
  - `test:watch` - Run all tests with watch mode
@@ -25,6 +25,7 @@ export declare class BuzzcastingStorageManager {
25
25
  cleanMessages: () => Promise<void>;
26
26
  hideMessage: (query: IQuery) => Promise<IResponse>;
27
27
  hideLabels: (query: IQuery) => Promise<IResponse>;
28
+ approveMessage: (query: IQuery) => Promise<void>;
28
29
  getSubscribers: () => Promise<any[]>;
29
30
  deleteSubscribers: () => Promise<any[]>;
30
31
  bulk: (table: string, queries: IQuery[]) => Promise<IResponse | number | undefined>;
@@ -35,6 +36,7 @@ export declare class BuzzcastingStorageManager {
35
36
  setSlide: (query: IQuery) => Promise<IResponse | undefined>;
36
37
  loadSlide: (query: IQuery) => Promise<number>;
37
38
  storeSlide: (query: IQuery) => Promise<IResponse | number>;
39
+ createSlide: (query: IQuery) => Promise<IResponse | number>;
38
40
  deleteSlide: (query: IQuery) => Promise<IResponse | number | undefined>;
39
41
  deleteSlides: () => Promise<IResponse | number | undefined>;
40
42
  getPresentation: (query: IQuery) => Promise<IResponse | undefined>;
@@ -128,6 +130,15 @@ export declare class Widget {
128
130
  * This takes place when the container indicates it has finished loading (ready)
129
131
  */
130
132
  subscribe(): void;
133
+ /**
134
+ * Tell the container to drop this widget from its subscriber list - the
135
+ * counterpart to subscribe(), called from destroy() when the widget's own
136
+ * component unmounts (e.g. the builder switches to a different slide).
137
+ * Without this, the container's subscriber list only ever grows: every
138
+ * widget ever mounted in the session stays in it, and every periodic
139
+ * refresh re-fetches all of them, not just the ones actually on screen.
140
+ */
141
+ unsubscribe(): void;
131
142
  /**
132
143
  * Generic call to any query type
133
144
  *
@@ -13,7 +13,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
13
13
  }({}), u = function(e) {
14
14
  return e.API = "color:white;background-color:grey;padding:0 4px 0 4px;border-radius:5px;", e.APP = "color:white;background-color:navy;padding:0 4px 0 4px;border-radius:5px;", e.BROADCAST = "color:navy;background-color:orange;padding:0 4px 0 4px;border-radius:5px;", e.CLOUD = "color:purple;background-color:mistyrose;padding:0 4px 0 4px;border-radius:5px;", e.DATA = "color:grey;background-color:lightskyblue;padding:0 4px 0 4px;border-radius:5px;", e.ERROR = "color:white;background-color:red;padding:0 4px 0 4px;border-radius:5px;", e.GET_DATA = "color:black;background-color:lime;padding:0 4px 0 4px;border-radius:5px;", e.HIDE = "color:white;background-color:red;padding:0 4px 0 4px;border-radius:5px;", e.KO = "color:white;background-color:red;padding:0 4px 0 4px;border-radius:5px;", e.MESSAGES = "color:white;background-color:darkslateblue;padding:0 4px 0 4px;border-radius:5px;", e.NO_UPDATES = "color:grey;border:1px solid grey;padding:0 4px 0 4px;border-radius:5px;", e.NONE = "color:transparent;background-color:transparent;", e.OK = "color:black;background-color:lime;padding:0 4px 0 4px;border-radius:5px;", e.PRESENTATION = "color:white;background-color:darkred;padding:0 4px 0 4px;border-radius:5px;", e.SERIES = "color:purple;background-color:thistle;padding:0 4px 0 4px;border-radius:5px;", e.SLIDE = "color:black;background-color:yellow;padding:0 4px 0 4px;border-radius:5px;", e.STORAGE = "color:black;background-color:cyan;padding:0 4px 0 4px;border-radius:5px;", e.SUBSCRIBE = "color:white;background-color:dodgerblue;padding:0 4px 0 4px;border-radius:5px;", e.WIDGET = "color:black;background-color:lemonchiffon;padding:0 4px 0 4px;border-radius:5px;", e.WS = "color:white;background-color:green;padding:0 4px 0 4px;border-radius:5px;", e;
15
15
  }({}), d = function(e) {
16
- return e.ADD_SLIDE = "addSlide", e.APP_READY = "appReady", e.API_UPDATE = "apiUpdate", e.BACKGROUND_UPDATE = "backgroundUpdate", e.BUILDER_PREVIEW = "builderPreview", e.COMPONENT_UPDATE = "componentUpdate", e.APPROVE_MESSAGE = "approveMessage", e.CHANNEL = "channel", e.CLEAN_MESSAGES = "cleanMessages", e.CLOSE_BUILDER_DIALOG = "closeBuilderDialog", e.CLOSE_BUILDER_MODAL = "closeBuilderModal", e.CLOSE_MODAL = "closeModal", e.COLOR_UPDATE = "colorUpdate", e.COMPONENT_INDEX = "componentIndex", e.CSS_SET = "setCss", e.CSS_STORE = "storeCss", e.DASHBOARD_LOAD = "loadDashboard", e.DASHBOARD_STORE = "storeDashboard", e.DASHBOARD_UPDATED = "dashboardUpdated", e.ERROR = "error", e.HIDE_MESSAGE = "hideMessage", e.HIDE_LABELS = "hideLabels", e.IMAGE_GET = "getImage", e.IMAGE_SET = "setImage", e.IMAGE_STORED = "imageStored", e.LAUPPUT_UPDATE = "layoutUpdate", e.PREV_SLIDE = "prevSlide", e.RELOAD_PRESENTATION = "reloadPresentation", e.STAR_MESSAGE = "starMessage", e.GOTO_SLIDE = "gotoSlide", e.NEXT_SLIDE = "nextSlide", e.PREFERENCE_LOAD = "loadPreference", e.PREFERENCE_STORE = "storePreference", e.PREFERENCE_UPDATED = "preferenceUpdated", e.PAUSE_PRESENTATION = "pausePresentation", e.PRESENTATION_READY = "presentationReady", e.PRESENTATION_LOAD = "loadPresentation", e.PRESENTATION_STORE = "storePresentation", e.PRESENTATION_UPDATED = "presentationUpdated", e.ROW_COL_UPDATE = "rowcolupdate", e.SCREENSHOT_TAKE = "takeScreenshot", e.SCREENSHOT_STORE = "storeScreenshot", e.SECTION_UPDATE = "sectionUpdate", e.SHOW_BUILDER_DIALOG = "showBuilderDialog", e.SHOW_BUILDER_MODAL = "showBuilderModal", e.SHOW_MODAL = "showModal", e.SLIDE_DID_LOAD = "slideDidLoad", e.SLIDE_GET = "getSlide", e.SLIDE_GOTO = "slideGoto", e.SLIDE_LOAD = "loadSlide", e.SLIDE_READY = "slideReady", e.SLIDE_SAVED = "slideSaved", e.SLIDE_SET = "setSlide", e.SLIDE_STORE = "storeSlide", e.SLIDE_STORED = "slideStored", e.SLIDE_TRANSITIONER = "slideTransitioner", e.SLIDE_UPDATED = "slideUpdated", e.START_TRANSITIONER = "startTransitioner", e.STORAGE_INIT = "storageInit", e.STREAM = "stream", e.SUBSCRIBE = "subscribe", e.SUSPEND_ACCOUNT = "suspendAccount", e.SWITCH_PRESENTATION = "switchPresentation", e.REMOVE_CLOUD = "removeCloud", e.UPDATE = "update", e.UPLOAD_COMPLETED = "uploadCompleted", e.VERSION = "version", e.WIDGETS_CLEAR = "widgetsClear", e.WIDGET_DID_LOAD = "widgetDidLoad", e.WIDGET_DID_UPDATE = "widgetDidUpdate", e.WIDGET_LOAD = "widgetLoad", e.WIDGET_STORE = "widgetStore", e.WIDGET_UPDATE = "widgetUpdate", e.WS_API_REQUEST = "wsApiRequest", e.WS_API_RESPONSE = "wsApiResponse", e.WS_API_UPDATE = "wsApiRUpdate", e;
16
+ return e.ADD_SLIDE = "addSlide", e.APP_READY = "appReady", e.API_UPDATE = "apiUpdate", e.BACKGROUND_UPDATE = "backgroundUpdate", e.BUILDER_PREVIEW = "builderPreview", e.COMPONENT_UPDATE = "componentUpdate", e.APPROVE_MESSAGE = "approveMessage", e.CHANNEL = "channel", e.CLEAN_MESSAGES = "cleanMessages", e.CLOSE_BUILDER_DIALOG = "closeBuilderDialog", e.CLOSE_BUILDER_MODAL = "closeBuilderModal", e.CLOSE_MODAL = "closeModal", e.COLOR_UPDATE = "colorUpdate", e.COMPONENT_INDEX = "componentIndex", e.CSS_SET = "setCss", e.CSS_STORE = "storeCss", e.DASHBOARD_LOAD = "loadDashboard", e.DASHBOARD_STORE = "storeDashboard", e.DASHBOARD_UPDATED = "dashboardUpdated", e.ERROR = "error", e.HIDE_MESSAGE = "hideMessage", e.IMAGE_GET = "getImage", e.IMAGE_SET = "setImage", e.IMAGE_STORED = "imageStored", e.LAYOUT_UPDATE = "layoutUpdate", e.PREV_SLIDE = "prevSlide", e.RELOAD_PRESENTATION = "reloadPresentation", e.STAR_MESSAGE = "starMessage", e.GOTO_SLIDE = "gotoSlide", e.NEXT_SLIDE = "nextSlide", e.PREFERENCE_LOAD = "loadPreference", e.PREFERENCE_STORE = "storePreference", e.PREFERENCE_UPDATED = "preferenceUpdated", e.PAUSE_PRESENTATION = "pausePresentation", e.PRESENTATION_READY = "presentationReady", e.PRESENTATION_LOAD = "loadPresentation", e.PRESENTATION_STORE = "storePresentation", e.PRESENTATION_UPDATED = "presentationUpdated", e.ROW_COL_UPDATE = "rowcolupdate", e.SCREENSHOT_TAKE = "takeScreenshot", e.SCREENSHOT_STORE = "storeScreenshot", e.SECTION_UPDATE = "sectionUpdate", e.SHOW_BUILDER_DIALOG = "showBuilderDialog", e.SHOW_BUILDER_MODAL = "showBuilderModal", e.SHOW_MODAL = "showModal", e.SLIDE_DID_LOAD = "slideDidLoad", e.SLIDE_GET = "getSlide", e.SLIDE_GOTO = "slideGoto", e.SLIDE_LOAD = "loadSlide", e.SLIDE_READY = "slideReady", e.SLIDE_SAVED = "slideSaved", e.SLIDE_SET = "setSlide", e.SLIDE_STORE = "storeSlide", e.SLIDE_STORED = "slideStored", e.SLIDE_TRANSITIONER = "slideTransitioner", e.SLIDE_UPDATED = "slideUpdated", e.START_TRANSITIONER = "startTransitioner", e.STORAGE_INIT = "storageInit", e.STREAM = "stream", e.SUBSCRIBE = "subscribe", e.UNSUBSCRIBE = "unsubscribe", e.SUSPEND_ACCOUNT = "suspendAccount", e.SWITCH_PRESENTATION = "switchPresentation", e.REMOVE_CLOUD = "removeCloud", e.UPDATE = "update", e.UPLOAD_COMPLETED = "uploadCompleted", e.VERSION = "version", e.WIDGETS_CLEAR = "widgetsClear", e.WIDGET_DID_LOAD = "widgetDidLoad", e.WIDGET_DID_UPDATE = "widgetDidUpdate", e.WIDGET_LOAD = "widgetLoad", e.WIDGET_STORE = "widgetStore", e.WIDGET_UPDATE = "widgetUpdate", e.WS_API_REQUEST = "wsApiRequest", e.WS_API_RESPONSE = "wsApiResponse", e.WS_API_UPDATE = "wsApiUpdate", e;
17
17
  }({}), f = function(e) {
18
18
  return e.APPROVED = "approved", e.BEFORE = "before", e.DELAYED = "delayed", e.NONE = "none", e.REALTIME = "realtime", e;
19
19
  }({}), p = function(e) {
@@ -159,7 +159,7 @@ function D(e, t) {
159
159
  }({});
160
160
  //#endregion
161
161
  //#region package.json
162
- var te = "3.21.4", ne = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => {
162
+ var te = "3.22.2", ne = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => {
163
163
  (function(n, r) {
164
164
  typeof e == "object" && t !== void 0 ? t.exports = r() : typeof define == "function" && define.amd ? define(r) : (n = typeof globalThis < "u" ? globalThis : n || self, n.readNDJSONStream = r());
165
165
  })(e, (function() {
@@ -284,7 +284,7 @@ var te = "3.21.4", ne = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => {
284
284
  async hideLabels(e) {
285
285
  let { version: t } = this.options, n = this.formHeaders(), r = new URLSearchParams(), i = e.labels || [];
286
286
  for (let [e, t] of i.entries()) r.append(`custom_filters[${e}]`, t);
287
- return console.info("%capi%c %cput", u.API, u.NONE, u.GET_DATA, d.HIDE_LABELS, e.widget, i), await fetch([
287
+ return console.info("%capi%c %cput", u.API, u.NONE, u.GET_DATA, d.REMOVE_CLOUD, e.widget, i), await fetch([
288
288
  this.url,
289
289
  "api",
290
290
  t,
@@ -336,6 +336,36 @@ var te = "3.21.4", ne = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => {
336
336
  data: null
337
337
  }));
338
338
  }
339
+ async createSlide(e) {
340
+ let { version: t } = this.options, n = this.formHeaders();
341
+ delete e.update, delete e.type, delete e.id;
342
+ let r = JSON.stringify(e);
343
+ return w(3, [
344
+ "%cpost%c %capi%c %ccreate slide",
345
+ u.OK,
346
+ u.NONE,
347
+ u.API,
348
+ u.NONE,
349
+ u.SLIDE,
350
+ e
351
+ ]), await fetch([
352
+ this.url,
353
+ "api",
354
+ t,
355
+ "slides"
356
+ ].join("/"), {
357
+ ...n,
358
+ body: r,
359
+ method: "post"
360
+ }).then((e) => {
361
+ if (!e.ok) throw Error(e.statusText);
362
+ return e;
363
+ }).then((e) => e.json()).catch((e) => ({
364
+ succes: !1,
365
+ message: e,
366
+ data: []
367
+ }));
368
+ }
339
369
  async storeSlide(e) {
340
370
  let { version: t } = this.options, n = this.formHeaders();
341
371
  delete e.update, delete e.type;
@@ -457,9 +487,13 @@ var te = "3.21.4", ne = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => {
457
487
  }));
458
488
  }
459
489
  async storePreference(e) {
460
- let { version: t } = this.options, n = this.formHeaders();
490
+ let { version: t } = this.options, n = `Bearer ${this.options.bearer}`, r = { headers: new Headers({
491
+ Authorization: n,
492
+ "Content-Type": "application/json",
493
+ Accept: "application/json"
494
+ }) };
461
495
  delete e.update;
462
- let r = JSON.stringify({ data: e });
496
+ let i = JSON.stringify({ data: e });
463
497
  return w(3, [
464
498
  "%capi%c %cstorePreference",
465
499
  u.API,
@@ -470,11 +504,10 @@ var te = "3.21.4", ne = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => {
470
504
  this.url,
471
505
  "api",
472
506
  t,
473
- l.PREFERENCES,
474
- e.id
475
- ].join("/"), {
476
- ...n,
477
- body: r,
507
+ l.PREFERENCES
508
+ ].join("/") + "/", {
509
+ ...r,
510
+ body: i,
478
511
  method: "post"
479
512
  }).then((e) => {
480
513
  if (!e.ok) throw Error(e.statusText);
@@ -4600,11 +4633,11 @@ var { liveQuery: A, mergeRanges: ae, rangesOverlap: j, RangeSet: oe, cmp: se, En
4600
4633
  query: e
4601
4634
  };
4602
4635
  let t = e?.order ?? "utc", n = Math.floor(Date.now() / 1e3), r = e?.period ?? 0;
4603
- e.since = r === 0 ? n - 2592e3 : n - r, e.before = this.options.delay === 0 ? n : n - (this.options.delay || 0);
4636
+ e.since = r === 0 ? n - 2592e3 : n - r, e.before = this.options.moderation === f.DELAYED && this.options.delay ? n - this.options.delay : n;
4604
4637
  let i = (t) => t.utc > (e?.since || 0), a = (t) => t.utc < (e?.before || n);
4605
4638
  try {
4606
4639
  let n = this.db.table(l.TOPICS).where("widget_id").equals(e.widget).filter(i).filter(a);
4607
- e?.approved === "true" ? n.and((e) => e.approved === 1) : n.and((e) => e.visible === 1), n.reverse();
4640
+ this.options.moderation === f.APPROVED ? n.and((e) => e.approved === 1) : n.and((e) => e.visible === 1), n.reverse();
4608
4641
  let r = await n.limit(e?.limit ?? 25).sortBy(t);
4609
4642
  if (r.length === 0) return {
4610
4643
  data: null,
@@ -4652,6 +4685,9 @@ var { liveQuery: A, mergeRanges: ae, rangesOverlap: j, RangeSet: oe, cmp: se, En
4652
4685
  hideMessage = async (e, t) => {
4653
4686
  await this.db.table(l.TOPICS).where("message_id").equals(e).modify({ visible: +!!t }).catch((e) => (console.error("%chide%c %cstorage%c %cmessage", u.KO, u.NONE, u.STORAGE, u.NONE, u.HIDE, e.message), 0));
4654
4687
  };
4688
+ approveMessage = async (e, t) => {
4689
+ await this.db.table(l.TOPICS).where("message_id").equals(e).modify({ approved: +!!t }).catch((e) => (console.error("%capprove%c %cstorage%c %cmessage", u.KO, u.NONE, u.STORAGE, u.NONE, u.OK, e.message), 0));
4690
+ };
4655
4691
  setMessages = async (e, t) => {
4656
4692
  if (e.type !== l.MESSAGES) return 400;
4657
4693
  let n = t.data.title, r = 0;
@@ -5100,7 +5136,7 @@ var { liveQuery: A, mergeRanges: ae, rangesOverlap: j, RangeSet: oe, cmp: se, En
5100
5136
  }));
5101
5137
  };
5102
5138
  //#endregion
5103
- //#region node_modules/idb-keyval/dist/index.js
5139
+ //#region node_modules/.pnpm/idb-keyval@6.2.2/node_modules/idb-keyval/dist/index.js
5104
5140
  function N(e) {
5105
5141
  return new Promise((t, n) => {
5106
5142
  e.oncomplete = e.onsuccess = () => t(e.result), e.onabort = e.onerror = () => n(e.error);
@@ -5173,6 +5209,9 @@ var ge = class {
5173
5209
  hideMessage = async (e, t) => {
5174
5210
  console.debug(`hideMessage ${e} ${t} not implemented for ${this.options.storage}`);
5175
5211
  };
5212
+ approveMessage = async (e, t) => {
5213
+ console.debug(`approveMessage ${e} ${t} not implemented for ${this.options.storage}`);
5214
+ };
5176
5215
  getDashboard = async (e) => await F(E(e)).then((e) => e).catch((t) => (console.warn("%capi", u.API, l.SLIDE, e.id), {
5177
5216
  data: null,
5178
5217
  message: `Widget ${e.data.id} load error: ${t.message}`,
@@ -5320,9 +5359,9 @@ var ge = class {
5320
5359
  options;
5321
5360
  constructor(e) {
5322
5361
  this.options = e, Storage.prototype.setObject = function(e, t) {
5323
- this.setObject(e, JSON.stringify(t));
5362
+ this.setItem(e, JSON.stringify(t));
5324
5363
  }, Storage.prototype.getObject = function(e) {
5325
- let t = this.getObject(e);
5364
+ let t = this.getItem(e);
5326
5365
  return t && JSON.parse(t);
5327
5366
  };
5328
5367
  }
@@ -5398,6 +5437,9 @@ var ge = class {
5398
5437
  hideMessage = async (e, t) => {
5399
5438
  console.debug(`hideMessage ${e} ${t} not implemented for ${this.options.storage}`);
5400
5439
  };
5440
+ approveMessage = async (e, t) => {
5441
+ console.debug(`approveMessage ${e} ${t} not implemented for ${this.options.storage}`);
5442
+ };
5401
5443
  getDashboard = async (e) => {
5402
5444
  try {
5403
5445
  return localStorage.getObject(`${l.DASHBOARD}.${e.id}`);
@@ -5678,6 +5720,9 @@ var ge = class {
5678
5720
  hideMessage = async (e, t) => {
5679
5721
  console.debug(`hideMessage ${e} ${t} not implemented for ${this.options.storage}`);
5680
5722
  };
5723
+ approveMessage = async (e, t) => {
5724
+ console.debug(`approveMessage ${e} ${t} not implemented for ${this.options.storage}`);
5725
+ };
5681
5726
  bulk = async (e, t) => 404;
5682
5727
  get = async (e, t) => 404;
5683
5728
  set = async (e, t) => 404;
@@ -5956,6 +6001,9 @@ var ge = class {
5956
6001
  hideMessage = async (e, t) => {
5957
6002
  console.debug(`hideMessage ${e} ${t} not implemented for ${this.options.storage}`);
5958
6003
  };
6004
+ approveMessage = async (e, t) => {
6005
+ console.debug(`approveMessage ${e} ${t} not implemented for ${this.options.storage}`);
6006
+ };
5959
6007
  bulk = async (e, t) => 404;
5960
6008
  get = async (e, t) => 404;
5961
6009
  set = async (e, t) => 404;
@@ -6178,10 +6226,10 @@ var ge = class {
6178
6226
  this.sm = new pe(e);
6179
6227
  break;
6180
6228
  case p.LOCAL:
6181
- this.sm = new ve(e);
6229
+ this.sm = new _e(e);
6182
6230
  break;
6183
6231
  case p.SESSION:
6184
- this.sm = new _e(e);
6232
+ this.sm = new ve(e);
6185
6233
  break;
6186
6234
  case p.KEYVAL:
6187
6235
  this.sm = new ge(e);
@@ -6411,6 +6459,9 @@ var ge = class {
6411
6459
  t
6412
6460
  ]), this.addSubscriber(t));
6413
6461
  break;
6462
+ case d.UNSUBSCRIBE:
6463
+ e.data.data.widget !== void 0 && this.deleteSubscriber(e.data.data);
6464
+ break;
6414
6465
  case d.UPDATE:
6415
6466
  w(3, [
6416
6467
  "%cupdate%c %capi%c %cstorage",
@@ -6470,6 +6521,18 @@ var ge = class {
6470
6521
  ]), await this.api.hideMessage(e);
6471
6522
  };
6472
6523
  hideLabels = async (e) => await this.api.hideLabels(e);
6524
+ approveMessage = async (e) => {
6525
+ let t = await this.sm?.approveMessage(e.id, +!!e.approved);
6526
+ w(3, [
6527
+ "%capprove%c %cstorage%c %cmessages",
6528
+ u.OK,
6529
+ u.NONE,
6530
+ u.STORAGE,
6531
+ u.NONE,
6532
+ u.MESSAGES,
6533
+ `${t} messages approved`
6534
+ ]);
6535
+ };
6473
6536
  getSubscribers = async () => await new Promise((e) => e(this.subscribers));
6474
6537
  deleteSubscribers = async () => (this.subscribers = [], await new Promise((e) => e(this.subscribers)));
6475
6538
  bulk = async (e, t) => await this.sm?.bulk(e, t);
@@ -6480,6 +6543,7 @@ var ge = class {
6480
6543
  setSlide = async (e) => await this.sm?.setSlide(e);
6481
6544
  loadSlide = async (e) => await this.api.loadSlide(e);
6482
6545
  storeSlide = async (e) => await this.api.storeSlide(e);
6546
+ createSlide = async (e) => await this.api.createSlide(e);
6483
6547
  deleteSlide = async (e) => await this.sm?.deleteSlide(e);
6484
6548
  deleteSlides = async () => await this.sm?.deleteSlides();
6485
6549
  getPresentation = async (e) => await this.sm?.getPresentation(e);
@@ -6521,10 +6585,10 @@ var ge = class {
6521
6585
  this.sm = new pe(e);
6522
6586
  break;
6523
6587
  case p.LOCAL:
6524
- this.sm = new ve(e);
6588
+ this.sm = new _e(e);
6525
6589
  break;
6526
6590
  case p.SESSION:
6527
- this.sm = new _e(e);
6591
+ this.sm = new ve(e);
6528
6592
  break;
6529
6593
  case p.KEYVAL:
6530
6594
  this.sm = new ge(e);
@@ -6617,6 +6681,20 @@ var ge = class {
6617
6681
  this.query
6618
6682
  ]));
6619
6683
  }
6684
+ unsubscribe() {
6685
+ this.query.widget?.length && (this.broadcastChannel.postMessage({
6686
+ event: d.UNSUBSCRIBE,
6687
+ data: this.query
6688
+ }), w(3, [
6689
+ `%cunsubscribe%c %cwidget%c %c${this.query.type}`,
6690
+ u.SUBSCRIBE,
6691
+ u.NONE,
6692
+ u.WIDGET,
6693
+ u.NONE,
6694
+ T(this.query),
6695
+ this.query.widget
6696
+ ]));
6697
+ }
6620
6698
  getData = async () => {
6621
6699
  switch (this.query.type) {
6622
6700
  case l.CLOUD: return await this.getCloud();
@@ -6718,7 +6796,7 @@ var ge = class {
6718
6796
  window.dispatchEvent(t);
6719
6797
  };
6720
6798
  destroy() {
6721
- this.broadcastChannel.close();
6799
+ this.unsubscribe(), this.broadcastChannel.close();
6722
6800
  }
6723
6801
  };
6724
6802
  //#endregion
package/package.json CHANGED
@@ -1,8 +1,13 @@
1
1
  {
2
2
  "name": "buzzcasting-storage",
3
3
  "type": "module",
4
- "version": "3.21.5",
4
+ "version": "3.22.2",
5
+ "packageManager": "pnpm@11.5.2",
5
6
  "private": false,
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/TouchFlows/buzzcasting-storage.git"
10
+ },
6
11
  "author": {
7
12
  "name": "Mark Tamis, TouchFlows SAS",
8
13
  "email": "mark.tamis@touchflows.com"
@@ -25,13 +30,14 @@
25
30
  "docs": "typedoc",
26
31
  "build": "tsc && vite build",
27
32
  "changelog": "changelogen --release",
28
- "release": "npm test && npm run build && changelogen --release && npm publish && git push --follow-tags",
33
+ "release": "pnpm test && pnpm run build && changelogen --release && git push --follow-tags",
29
34
  "lint": "eslint . --fix",
30
35
  "test": "vitest --run",
31
36
  "test:watch": "vitest",
32
37
  "test:coverage": "vitest --coverage"
33
38
  },
34
39
  "dependencies": {
40
+ "buzzcasting-utils": "^1.13.9",
35
41
  "dexie": "^4.3.0",
36
42
  "idb-keyval": "^6.2.2",
37
43
  "ndjson-readablestream": "^1.4.0"
@@ -43,8 +49,7 @@
43
49
  "@types/node": "^24.13.3",
44
50
  "@typescript-eslint/eslint-plugin": "^8.66.0",
45
51
  "@typescript-eslint/parser": "^8.66.0",
46
- "@vitest/coverage-v8": "^4.1.10",
47
- "buzzcasting-utils": "^1.13.5",
52
+ "@vitest/coverage-v8": "^4.1.11",
48
53
  "camelcase": "^9.0.0",
49
54
  "changelogen": "^0.6.2",
50
55
  "eslint": "^9.39.5",
@@ -54,9 +59,9 @@
54
59
  "typescript": "^5.9.3",
55
60
  "vite": "^8.2.0",
56
61
  "vite-plugin-dts": "^4.5.4",
57
- "vitest": "^4.1.10"
62
+ "vitest": "^4.1.11"
58
63
  },
59
64
  "lint-staged": {
60
65
  "*.ts": "npm run lint"
61
66
  }
62
- }
67
+ }