@eintrek/erp-shell 0.1.76 → 0.1.78

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.
@@ -100,6 +100,12 @@ export interface StepLayerProps {
100
100
  height: number;
101
101
  offsetTop: number;
102
102
  };
103
+ /**
104
+ * The app's content column (GuideConfig.contentRoot), already cut to the
105
+ * viewport: the bubble stays inside it (LIFF's 460 px column on a desktop).
106
+ * Shell ≥ 0.1.77. Omitted: the viewport.
107
+ */
108
+ bounds?: Rect | null;
103
109
  phone: boolean;
104
110
  showHand: boolean;
105
111
  bubble: BubbleModel;
@@ -62,6 +62,11 @@ export type GuideScreen = {
62
62
  section?: string;
63
63
  /** A flow's step: the flow key (the mission is `flow:<key>`). Shell ≥ 0.1.76. */
64
64
  flow?: string;
65
+ /** "ขั้นที่ no/total" as shown (GuideState.counter): never going down. Shell ≥ 0.1.77. */
66
+ pos?: {
67
+ no: number;
68
+ total: number;
69
+ };
65
70
  }
66
71
  /** The first-visit offer of this page's guide: a small card, not modal. */
67
72
  | {
@@ -129,6 +134,18 @@ export interface GuideState {
129
134
  mission: string;
130
135
  steps: number[];
131
136
  } | null;
137
+ /**
138
+ * The counter of the run being played (shell ≥ 0.1.77): the steps shown so
139
+ * far, and the total as last worked out and on which page. The total is
140
+ * worked out when a step is entered on a page it was not worked out on,
141
+ * and never goes down.
142
+ */
143
+ counter: {
144
+ mission: string;
145
+ shown: number[];
146
+ total: number;
147
+ path: string;
148
+ } | null;
132
149
  }
133
150
  /** The page-guide part of the state, from the progress answer. */
134
151
  export interface GuidePagesInit {
@@ -291,6 +308,21 @@ export type GuideAction = {
291
308
  | {
292
309
  type: "back";
293
310
  }
311
+ /**
312
+ * Another tab took over (shell ≥ 0.1.78): stop here, silently — a running
313
+ * step, an offer, a card or the panel goes, nothing is written.
314
+ */
315
+ | {
316
+ type: "yield";
317
+ }
318
+ /** The server's rows, read again (another tab saved, or this tab took over). */
319
+ | {
320
+ type: "refresh";
321
+ progress: GuideProgress;
322
+ pages: Record<string, PageRow>;
323
+ sections?: Record<string, PageRow>;
324
+ flows?: Record<string, PageRow>;
325
+ }
294
326
  /** A page row came back from the server. */
295
327
  | {
296
328
  type: "pageRow";
@@ -442,6 +474,14 @@ export declare function stepPosition(mission: GuideMission, index: number, env:
442
474
  no: number;
443
475
  total: number;
444
476
  };
477
+ /**
478
+ * The steps after `index` this person will see, as far as can be known from
479
+ * here: on this page, everything is read (requires, skipIf, a click whose
480
+ * outcome already holds); on another page, a step whose showing depends on
481
+ * what is on that page (`skipIf`, `onMissing: "skip"`) is not counted until
482
+ * its page is reached.
483
+ */
484
+ export declare function stepsAhead(mission: GuideMission, index: number, env: GuideEnv, context: Readonly<Record<string, string>>): number;
445
485
  /** A step entered now would pass at once: a click or select step whose route or visible outcome holds. */
446
486
  export declare function wouldAutoPass(step: GuideStep, env: GuideEnv): boolean;
447
487
  /** The steps of this mission that passed by themselves in this run. */
@@ -481,6 +521,14 @@ export declare function firstStepReady(suite: GuideSuite, pageKey: string, env:
481
521
  * route, a moment of nothing loading, the primary tab, not hidden.
482
522
  */
483
523
  export declare function pageOfferDue(state: GuideState, suite: GuideSuite, env: GuideEnv): string | null;
524
+ /**
525
+ * Whether a row may be written now: none of this version yet, or — once —
526
+ * a skipped one that the person has now finished (skipped → completed,
527
+ * shell ≥ 0.1.77). A completed row is final; skipped again changes nothing.
528
+ */
529
+ export declare function rowWritable(row: PageRow | undefined, version: number, status: "completed" | "skipped"): boolean;
530
+ /** Whether a run should keep its row to write at its end: no row yet, or only a skipped one. */
531
+ export declare function rowStillDue(row: PageRow | undefined, version: number): boolean;
484
532
  /** The section guide's row says this person has ended this version of it. */
485
533
  export declare function sectionRecorded(state: GuideState, section: {
486
534
  key: string;
@@ -517,4 +565,10 @@ export declare function backTarget(mission: GuideMission, index: number, env: Gu
517
565
  index: number;
518
566
  close: boolean;
519
567
  } | null;
568
+ /**
569
+ * A flow's next step (the next one this person sees) when the person is on
570
+ * its page and no longer on the current step's: they moved on by
571
+ * themselves. -1 otherwise (still on this step's page, or elsewhere).
572
+ */
573
+ export declare function flowStepArrivedAt(mission: GuideMission, index: number, env: GuideEnv, context: Readonly<Record<string, string>>): number;
520
574
  export declare function reduceGuide(state: GuideState, action: GuideAction, suite: GuideSuite, env: GuideEnv): GuideResult;
@@ -13,6 +13,11 @@ import { type GuideProgress, type GuidesAnswer, type PageRow } from "./progress"
13
13
  export interface GuideProgressRequest {
14
14
  /** The suite's app ("peoplx", "liff"). */
15
15
  app: string;
16
+ /**
17
+ * fetchProgress only: another tab saved, or this tab is taking over — skip
18
+ * any cache and ask the server (shell ≥ 0.1.78).
19
+ */
20
+ fresh?: boolean;
16
21
  /** The suite's key, the row on the server ("liff.first-run"). */
17
22
  guideKey: string;
18
23
  }
@@ -59,7 +64,7 @@ export declare class GuideProgressConflict extends Error {
59
64
  constructor(current: unknown, code?: string);
60
65
  }
61
66
  /** The GET, parsed for this suite; null (show nothing) on any failure or odd answer. */
62
- export declare function loadGuides(adapter: GuideProgressAdapter, suite: GuideSuite, signal?: AbortSignal): Promise<GuidesAnswer | null>;
67
+ export declare function loadGuides(adapter: GuideProgressAdapter, suite: GuideSuite, signal?: AbortSignal, fresh?: boolean): Promise<GuidesAnswer | null>;
63
68
  /**
64
69
  * PUT the whole state. On 409 the server's row comes back: merge (keeping
65
70
  * whatever is further along) and try once more with its rev. Returns the
@@ -542,4 +542,10 @@ export interface GuideConfig {
542
542
  * `module.accounting` is known). Shell ≥ 0.1.74.
543
543
  */
544
544
  pagesReady?: boolean;
545
+ /**
546
+ * A selector for the app's content column (LIFF's centred 460 px
547
+ * `MobileShell` on a desktop): bubbles stay inside it. Omitted: the
548
+ * viewport. Shell ≥ 0.1.77.
549
+ */
550
+ contentRoot?: string;
545
551
  }
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  'use strict';
3
3
 
4
- var format = require('./chunks/format-BVoVc7Yk.cjs');
4
+ var format = require('./chunks/format-BmTSD3DB.cjs');
5
5
  require('react/jsx-runtime');
6
6
  require('react');
7
7
  require('react-dom');
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- export { A as GUIDE_API_EVENT, G as GUIDE_EVENT_PREFIX, a as GUIDE_LAYER_ATTRIBUTE, c as GuideProgressConflict, d as GuideRuntime, S as SectionGuideButton, T as THAI_MONTHS_SHORT, e as apiCallDetail, f as emitGuideEvent, g as fillRoute, h as formatBaht, i as guideAnchor, j as guideMenuItems, k as guideMenuShown, l as loadGuides, m as matchApiPath, n as matchRoute, o as openFlow, p as openFlowsPanel, q as openGuidePanel, r as openPageGuide, s as openPagesPanel, t as openSectionGuide, u as reportApiCall, v as reportApiEvent, w as setSectionGuideValues, x as storeGuides, y as thaiMonth, z as thaiMonthYear, B as useGuideEntry, C as usePageGuideEntry, D as usePageGuides, E as useSectionGuideValues } from './chunks/format-BWUKNKxg.esm.js';
2
+ export { A as GUIDE_API_EVENT, G as GUIDE_EVENT_PREFIX, a as GUIDE_LAYER_ATTRIBUTE, c as GuideProgressConflict, d as GuideRuntime, S as SectionGuideButton, T as THAI_MONTHS_SHORT, e as apiCallDetail, f as emitGuideEvent, g as fillRoute, h as formatBaht, i as guideAnchor, j as guideMenuItems, k as guideMenuShown, l as loadGuides, m as matchApiPath, n as matchRoute, o as openFlow, p as openFlowsPanel, q as openGuidePanel, r as openPageGuide, s as openPagesPanel, t as openSectionGuide, u as reportApiCall, v as reportApiEvent, w as setSectionGuideValues, x as storeGuides, y as thaiMonth, z as thaiMonthYear, B as useGuideEntry, C as usePageGuideEntry, D as usePageGuides, E as useSectionGuideValues } from './chunks/format-Wgj2sKpK.esm.js';
3
3
  import 'react/jsx-runtime';
4
4
  import 'react';
5
5
  import 'react-dom';
package/dist/index.cjs CHANGED
@@ -14,7 +14,7 @@ var Link = require('next/link');
14
14
  var reactDom = require('react-dom');
15
15
  var nextThemes = require('next-themes');
16
16
  var axios = require('axios');
17
- var format = require('./chunks/format-BVoVc7Yk.cjs');
17
+ var format = require('./chunks/format-BmTSD3DB.cjs');
18
18
  var reactQueryDevtools = require('@tanstack/react-query-devtools');
19
19
  require('@floating-ui/dom');
20
20
 
@@ -1740,7 +1740,7 @@ function platformApiBase(app) {
1740
1740
  * This package's version, attached to help messages so the back office can
1741
1741
  * tell which shell a report came from. Keep in step with package.json.
1742
1742
  */
1743
- const SHELL_VERSION = "0.1.76";
1743
+ const SHELL_VERSION = "0.1.78";
1744
1744
 
1745
1745
  const HELP_APP_LABEL = {
1746
1746
  platform: "แพลตฟอร์ม",
@@ -3658,7 +3658,8 @@ function GuideHostInner({ config, organizationId, code }) {
3658
3658
  fetchProgress: req => client.fetchQuery({
3659
3659
  queryKey: ["erp-shell", "guides", organizationId, suite.app, suite.key, suite.version],
3660
3660
  queryFn: ({ signal }) => platform.fetchProgress({ ...req, signal }).catch(() => null),
3661
- staleTime: 5 * 60000,
3661
+ // Fresh after another tab saved (0.1.78); otherwise kept 5 minutes.
3662
+ staleTime: req.fresh ? 0 : 5 * 60000,
3662
3663
  gcTime: 30 * 60000,
3663
3664
  retry: false,
3664
3665
  }),