@panyam/tsappkit 0.7.4 → 0.7.5

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/index.mjs CHANGED
@@ -1371,6 +1371,41 @@ var MobileBottomDrawer = class extends BaseComponent {
1371
1371
  }
1372
1372
  };
1373
1373
 
1374
+ // src/Port.ts
1375
+ var Port = class {
1376
+ /** @param replay runs on each view as it attaches, to bring it up to date. */
1377
+ constructor(replay) {
1378
+ this.replay = replay;
1379
+ this.views = /* @__PURE__ */ new Set();
1380
+ }
1381
+ /**
1382
+ * Adds a view, runs the replay on it, and returns the function that removes
1383
+ * it again. An island attaches when it activates and detaches when it
1384
+ * deactivates (tsappkit-solid's useView does both). Attaching the same view
1385
+ * twice keeps one copy, and calling the returned function more than once is
1386
+ * harmless.
1387
+ */
1388
+ attach(view) {
1389
+ this.views.add(view);
1390
+ this.replay?.(view);
1391
+ return () => {
1392
+ this.views.delete(view);
1393
+ };
1394
+ }
1395
+ /**
1396
+ * Sends a command to every view attached when it's called, in the order they
1397
+ * attached. A view may detach (or attach another) from inside the command.
1398
+ * A view that throws stops the command reaching the views after it.
1399
+ */
1400
+ each(send) {
1401
+ for (const view of [...this.views]) send(view);
1402
+ }
1403
+ /** How many views are attached. */
1404
+ get size() {
1405
+ return this.views.size;
1406
+ }
1407
+ };
1408
+
1374
1409
  // src/page/load.ts
1375
1410
  function parseLoad(load) {
1376
1411
  switch (load ?? "") {
@@ -1979,6 +2014,6 @@ var KeyboardShortcutManager = class {
1979
2014
  }
1980
2015
  };
1981
2016
 
1982
- export { BaseComponent, BasePage, ComponentEventTypes, EventBus, IslandOverlay, IslandPage, KeyboardShortcutManager, KeyboardState, LifecycleController, LifecycleEventTypes, MobileBottomDrawer, Modal, SPEC_ELEMENT_ID, SplashScreen, TemplateLoader, ThemeManager, ToastManager, hasModifierKeys, isInInputContext, lazy, mountIslands, parseLoad, readSpec, scheduleMount, shouldIgnoreShortcut };
2017
+ export { BaseComponent, BasePage, ComponentEventTypes, EventBus, IslandOverlay, IslandPage, KeyboardShortcutManager, KeyboardState, LifecycleController, LifecycleEventTypes, MobileBottomDrawer, Modal, Port, SPEC_ELEMENT_ID, SplashScreen, TemplateLoader, ThemeManager, ToastManager, hasModifierKeys, isInInputContext, lazy, mountIslands, parseLoad, readSpec, scheduleMount, shouldIgnoreShortcut };
1983
2018
  //# sourceMappingURL=index.mjs.map
1984
2019
  //# sourceMappingURL=index.mjs.map