GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — refactor: one derivation over the query channel says whether the buil… · u8array/ZPLab@7ad1739

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • components
      • Output
        • RendererSelect.tsx
        • ZPLOutput.tsx
        • ZebraWayPanel.tsx
      • PrinterSettings
        • PreviewSettingsTab.tsx
        • PrintTargetTab.tsx
        • PrinterSettingsModal.tsx
        • PrinterStorage.tsx
        • StoredFontsTab.tsx
        • StoredGraphicsTab.tsx
    • lib
      • previewProviderLabel.ts
      • printTarget.test.ts
      • printTarget.ts
      • printerQuery.ts
    • store
      • labelStore.selectors.ts
      • labelStore.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/components/Output/RendererSelect.tsx‎

Copy file name to clipboardExpand all lines: src/components/Output/RendererSelect.tsx
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useId } from "react";
22
import { useT } from "../../hooks/useT";
33
import { formatTemplate } from "../../lib/formatTemplate";
44
import { previewProviderChoices, previewProviderLabel } from "../../lib/previewProviderLabel";
5-
import { selectEffectivePreviewProvider, useLabelStore } from "../../store/labelStore";
5+
import { selectEffectivePreviewProvider, selectReadsPrinter, useLabelStore } from "../../store/labelStore";
66
import type { PreviewProvider } from "../../store/slices/uiSlice";
77
import { sectionHeadingCls } from "../ui/formStyles";
88
import { Select } from "../ui/Select";
@@ -14,8 +14,9 @@ export function RendererSelect() {
1414
const chosen = useLabelStore((s) => s.previewProvider);
1515
const effective = useLabelStore(selectEffectivePreviewProvider);
1616
const labelaryAvailable = useLabelStore((s) => s.thirdParty.labelary);
17+
const readsPrinter = useLabelStore(selectReadsPrinter);
1718
const setProvider = useLabelStore((s) => s.setPreviewProvider);
18-
const choices = previewProviderChoices(t, { thirdParty: { labelary: labelaryAvailable } });
19+
const choices = previewProviderChoices(t, { labelary: labelaryAvailable, printer: readsPrinter });
1920
return (
2021
<div className="flex flex-col gap-1">
2122
<label htmlFor={id} className={sectionHeadingCls}>
Collapse file

‎src/components/Output/ZPLOutput.tsx‎

Copy file name to clipboardExpand all lines: src/components/Output/ZPLOutput.tsx
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import { useRef } from 'react';
22
import { CheckIcon, ClipboardDocumentIcon, ChevronDownIcon, ChevronUpIcon, EyeIcon, PrinterIcon } from '@heroicons/react/16/solid';
3-
import { useLabelStore, selectEffectivePreviewProvider, selectPreviewLocksEditor } from '../../store/labelStore';
3+
import { useLabelStore, selectEffectivePreviewProvider, selectPreviewLocksEditor, selectReadsPrinter } from '../../store/labelStore';
44
import { useZplOutputView } from '../../hooks/useZplOutputView';
55
import { useCopyToClipboard } from '../../hooks/useCopyToClipboard';
66
import { finishZplExport } from '../../lib/exportZpl';
77
import { useT } from '../../hooks/useT';
88
import { useLabelaryConsent } from '../../hooks/useLabelaryConsent';
99
import { ZplSourceEditor } from './ZplSourceEditor';
1010
import { Tooltip } from '../ui/Tooltip';
11-
import { isDesktopShell } from '../../lib/platform';
1211
import { PrinterChip } from './PrinterChip';
1312
import { PaginationControl } from './PaginationControl';
1413
import { sectionHeadingCls } from '../ui/formStyles';
@@ -27,6 +26,7 @@ export function ZPLOutput({ collapsed, onCollapse, onExpand, onResizeMouseDown }
2726
const t = useT();
2827
const effectiveProvider = useLabelStore(selectEffectivePreviewProvider);
2928
const previewActive = useLabelStore(selectPreviewLocksEditor);
29+
const readsPrinter = useLabelStore(selectReadsPrinter);
3030
const enterPreviewMode = useLabelStore((s) => s.enterPreviewMode);
3131
const exitPreviewMode = useLabelStore((s) => s.exitPreviewMode);
3232
const { gate, notice: consentNotice } = useLabelaryConsent();
@@ -80,7 +80,7 @@ export function ZPLOutput({ collapsed, onCollapse, onExpand, onResizeMouseDown }
8080
</div>
8181
<PaginationControl />
8282
<div className="col-start-3 justify-self-end flex items-center gap-3">
83-
{isDesktopShell && <PrinterChip />}
83+
{readsPrinter && <PrinterChip />}
8484
{previewAvailable && (
8585
<Tooltip content={t.output.previewHeading}>
8686
<button
Collapse file

‎src/components/Output/ZebraWayPanel.tsx‎

Copy file name to clipboardExpand all lines: src/components/Output/ZebraWayPanel.tsx
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Select } from "../ui/Select";
55
import { primaryButtonCls } from "../ui/formStyles";
66
import { sendViaBrowserPrint, sendViaNetwork } from "../../lib/zebraPrint";
77
import { isDesktopShell } from "../../lib/platform";
8-
import { needsRawChannel, resolveQueryTarget, type PrintTransport } from "../../lib/printTarget";
8+
import { needsRawChannel, readsPrinter, resolveQueryTarget, type PrintTransport } from "../../lib/printTarget";
99
import { queryButtonText, queryOffer } from "../../lib/printWayText";
1010
import { QueryHints } from "./QueryHints";
1111
import type { DocumentQueryFacts } from "../../lib/outputChoice";
@@ -204,7 +204,7 @@ export function ZebraWayPanel({ zpl, way, devices, query }: { zpl: () => string;
204204
// Every way reaches the same device, so every way may ask it, and a way that cannot be questioned
205205
// itself falls back to the configured address.
206206
const addressCheck = (sending: boolean) => {
207-
if (!isDesktopShell) return null;
207+
if (!readsPrinter(printTarget, isDesktopShell, way)) return null;
208208
const resolved = resolveQueryTarget(printTarget, way);
209209
if ("failure" in resolved) return null;
210210
return (
Collapse file

‎src/components/PrinterSettings/PreviewSettingsTab.tsx‎

Copy file name to clipboardExpand all lines: src/components/PrinterSettings/PreviewSettingsTab.tsx
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useState, useEffect } from "react";
22
import { useT } from "../../hooks/useT";
3-
import { useLabelStore, selectEffectivePreviewProvider } from "../../store/labelStore";
3+
import { useLabelStore, selectEffectivePreviewProvider, selectReadsPrinter } from "../../store/labelStore";
44
import { isDesktopShell } from "../../lib/platform";
55
import { isDefaultHost } from "../../lib/labelary";
66
import { labelCls, inputCls, buttonCls, sectionHeadingCls } from "../ui/formStyles";
@@ -18,7 +18,8 @@ export function PreviewSettingsTab() {
1818
const provider = useLabelStore(selectEffectivePreviewProvider);
1919
const setProvider = useLabelStore((s) => s.setPreviewProvider);
2020
const labelaryAvailable = useLabelStore((s) => s.thirdParty.labelary);
21-
const locked = Object.fromEntries(previewProviderChoices(t, { thirdParty: { labelary: labelaryAvailable } }).map((c) => [c.provider, c.disabled]));
21+
const readsPrinter = useLabelStore(selectReadsPrinter);
22+
const locked = Object.fromEntries(previewProviderChoices(t, { labelary: labelaryAvailable, printer: readsPrinter }).map((c) => [c.provider, c.disabled]));
2223
const labelaryConsent = useLabelStore((s) => s.labelaryNoticeAcknowledged);
2324
const acknowledgeLabelaryNotice = useLabelStore((s) => s.acknowledgeLabelaryNotice);
2425
const revokeLabelaryNotice = useLabelStore((s) => s.revokeLabelaryNotice);
@@ -92,7 +93,7 @@ export function PreviewSettingsTab() {
9293
current={chosen}
9394
onSelect={setProvider}
9495
label={loc.providerPrinter}
95-
hint={isDesktopShell ? loc.providerPrinterHint : loc.providerPrinterDesktopOnly}
96+
hint={readsPrinter ? loc.providerPrinterHint : loc.providerPrinterDesktopOnly}
9697
disabled={locked.printer}
9798
/>
9899
<RadioOption
@@ -110,7 +111,7 @@ export function PreviewSettingsTab() {
110111
)}
111112
</section>
112113

113-
{provider === "printer" && isDesktopShell && (
114+
{provider === "printer" && (
114115
<section className="flex items-center gap-3">
115116
<span className="text-[10px] text-muted">{loc.printerTargetHint}</span>
116117
<button type="button" className={buttonCls} onClick={() => setPrinterSettingsTab("printTarget")}>
Collapse file

‎src/components/PrinterSettings/PrintTargetTab.tsx‎

Copy file name to clipboardExpand all lines: src/components/PrinterSettings/PrintTargetTab.tsx
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { SgdSetting } from "@zplab/core/lib/sgd";
22
import { useReplyRead } from "../../hooks/useReplyRead";
33
import { useT } from "../../hooks/useT";
4-
import { useLabelStore } from "../../store/labelStore";
4+
import { useLabelStore, selectReadsPrinter } from "../../store/labelStore";
55
import { isDesktopShell } from "../../lib/platform";
66
import { effectiveTransport, offeredTransports, type PrintTransport } from "../../lib/printTarget";
77
import { wayHint, wayLabel } from "../../lib/printWayText";
@@ -33,6 +33,7 @@ export function PrintTargetTab() {
3333
const setPrintTarget = useLabelStore((s) => s.setPrintTarget);
3434
const readPrinterSettings = useLabelStore((s) => s.readPrinterSettings);
3535
const reading = useLabelStore((s) => s.printerReading) !== undefined;
36+
const readsPrinter = useLabelStore(selectReadsPrinter);
3637
const settings = useReplyRead<SgdSetting[]>();
3738
const usb = useUsbPrinters(isDesktopShell);
3839
const local = useLocalPrinters(isDesktopShell);
@@ -88,7 +89,7 @@ export function PrintTargetTab() {
8889
<span className="text-[10px] text-muted max-w-md">{loc.addressHint}</span>
8990
</section>
9091

91-
{isDesktopShell && (
92+
{readsPrinter && (
9293
<button type="button" className={`${buttonCls} self-start`} disabled={reading} onClick={openSettings}>
9394
{t.printerSettings.printerStatus.adoptFromPrinter}
9495
</button>
Collapse file

‎src/components/PrinterSettings/PrinterSettingsModal.tsx‎

Copy file name to clipboardExpand all lines: src/components/PrinterSettings/PrinterSettingsModal.tsx
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { useT } from "../../hooks/useT";
77
import { generateSetupScript, setupFormatBlocks, setupScriptLines, type SetupScriptField } from "../../lib/zplSetupScript";
88
import type { SETUP_UPLOAD_FIELDS } from "@zplab/core/types/PrinterProfile";
99
import type { Translations } from "../../locales";
10-
import { useLabelStore, selectEditorFrozen, selectHasPerLabelOverrides } from "../../store/labelStore";
10+
import { useLabelStore, selectEditorFrozen, selectHasPerLabelOverrides, selectReadsPrinter } from "../../store/labelStore";
1111
import { isDesktopShell } from "../../lib/platform";
1212
import type { PrinterSettingsTab } from "../../store/slices/uiSlice";
1313
import { TAB_GATES, type TabGateCtx } from "./tabVisibility";
@@ -167,6 +167,7 @@ export function PrinterSettingsModal() {
167167
resetPerLabelConfig();
168168
};
169169
const hasPerLabelOverrides = useLabelStore(selectHasPerLabelOverrides);
170+
const readsPrinter = useLabelStore(selectReadsPrinter);
170171
const mcpSidecarAvailable = useLabelStore((s) => s.mcpSidecarAvailable);
171172
const gateCtx: TabGateCtx = { mcpSidecarAvailable, isDesktop: isDesktopShell };
172173
const openOutput = useLabelStore((s) => s.openOutput);
@@ -271,7 +272,7 @@ export function PrinterSettingsModal() {
271272
/>
272273
))}
273274
</nav>
274-
{activeTopTab === 'objects' && isDesktopShell && <PrinterStorageUsage />}
275+
{activeTopTab === 'objects' && readsPrinter && <PrinterStorageUsage />}
275276
{activeTopTab === 'perLabel' && hasPerLabelOverrides && (
276277
<div className="px-3 pb-3">
277278
<ResetPerLabelButton
Collapse file

‎src/components/PrinterSettings/PrinterStorage.tsx‎

Copy file name to clipboardExpand all lines: src/components/PrinterSettings/PrinterStorage.tsx
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@ import { InformationCircleIcon } from "@heroicons/react/16/solid";
33
import { hostObjectPath, type HostObject } from "@zplab/core/lib/hostDirectory";
44
import { isWritableDevice } from "@zplab/core/lib/storagePath";
55
import { deleteKnowledge, driveUsage, listedObject, originState, type DeleteKnowledge, type OriginState, type StoredObjectKind, type StoredObjectOrigin } from "@zplab/core/lib/storedObjectOrigins";
6-
import { isDesktopShell } from "../../lib/platform";
76
import { usePrinterListing } from "../../hooks/usePrinterListing";
87
import { useReplyRead } from "../../hooks/useReplyRead";
98
import { useT } from "../../hooks/useT";
109
import type { Translations } from "../../locales";
1110
import { formatTemplate } from "../../lib/formatTemplate";
1211
import type { PrinterObjectsState } from "../../store/slices/printerObjectsSlice";
1312
import { driveUsageText, failureText, kilobytes, readingText } from "../../lib/printerStatusText";
14-
import { selectPrinterObjects, useLabelStore } from "../../store/labelStore";
13+
import { selectPrinterObjects, selectReadsPrinter, useLabelStore } from "../../store/labelStore";
1514
import { ConfirmDialog } from "../ui/ConfirmDialog";
1615
import { MemoryBar } from "../ui/MemoryBar";
1716
import { Tooltip } from "../ui/Tooltip";
@@ -21,17 +20,18 @@ import { useStoredObjectHover } from "../../hooks/useStoredObjectHover";
2120

2221
export function StoredObjectsHeading() {
2322
const loc = useT().printerSettings.objects;
23+
const readsPrinter = useLabelStore(selectReadsPrinter);
2424
return (
2525
<div className="flex items-baseline justify-between gap-2">
2626
<div className="flex items-center gap-1.5">
2727
<h3 className={sectionHeadingCls}>{loc.listHeading}</h3>
28-
<Tooltip content={isDesktopShell ? `${loc.listHint} ${loc.listHintPrinter}` : loc.listHint}>
28+
<Tooltip content={readsPrinter ? `${loc.listHint} ${loc.listHintPrinter}` : loc.listHint}>
2929
<InformationCircleIcon className="w-3 h-3 text-muted/60 cursor-help shrink-0" />
3030
</Tooltip>
3131
</div>
3232
<span className="flex items-center gap-1">
3333
<span className={zplCommandTagCls}>~DY</span>
34-
{isDesktopShell && <span className={zplCommandTagCls}>^HW</span>}
34+
{readsPrinter && <span className={zplCommandTagCls}>^HW</span>}
3535
</span>
3636
</div>
3737
);
Collapse file

‎src/components/PrinterSettings/StoredFontsTab.tsx‎

Copy file name to clipboardExpand all lines: src/components/PrinterSettings/StoredFontsTab.tsx
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import { listsStoredFont } from "@zplab/core/lib/storedObjects";
99
import { storedObjectOrigins } from "@zplab/core/lib/storedObjectOrigins";
1010
import { storageKey, storageRefMatchesPath } from "@zplab/core/lib/storagePath";
1111
import { useCachedFonts } from "../../hooks/useCachedFonts";
12-
import { useLabelStore, selectEditorFrozen } from "../../store/labelStore";
13-
import { isDesktopShell } from "../../lib/platform";
12+
import { useLabelStore, selectEditorFrozen, selectReadsPrinter } from "../../store/labelStore";
1413
import { PrinterObjectActions, PrinterOriginMark, PrinterStorageBar, StoredObjectsHeading } from "./PrinterStorage";
1514
import { buttonCls, disabledCls } from "../ui/formStyles";
1615
import { ConfirmDialog } from "../ui/ConfirmDialog";
@@ -41,6 +40,7 @@ export function StoredFontsTab() {
4140
const loc = t.printerSettings.fonts;
4241
const { setHoveredKey } = useStoredObjectHover();
4342
const frozen = useLabelStore(selectEditorFrozen);
43+
const readsPrinter = useLabelStore(selectReadsPrinter);
4444

4545
// A cache row is named by its printer path, so profile and cache rows share one identity rule.
4646
const cachedPaths = fonts.map(cachedFontPath).filter((path) => listsStoredFont(path, setupFonts));
@@ -95,7 +95,7 @@ export function StoredFontsTab() {
9595
</span>
9696
)}
9797
</div>
98-
{isDesktopShell && <PrinterStorageBar />}
98+
{readsPrinter && <PrinterStorageBar />}
9999
{rows.length === 0 ? (
100100
<p className="text-xs text-muted/70">{loc.noFonts}</p>
101101
) : (
Collapse file

‎src/components/PrinterSettings/StoredGraphicsTab.tsx‎

Copy file name to clipboardExpand all lines: src/components/PrinterSettings/StoredGraphicsTab.tsx
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useStoredObjectHover } from "../../hooks/useStoredObjectHover";
66
import { usePrinterListing } from "../../hooks/usePrinterListing";
77
import { useT } from "../../hooks/useT";
88
import { useUpload } from "../../hooks/useUpload";
9-
import { useLabelStore, useFileDeletability, forgetHistoryUsing, selectEditorFrozen, type DeleteBlock } from "../../store/labelStore";
9+
import { useLabelStore, useFileDeletability, forgetHistoryUsing, selectEditorFrozen, selectReadsPrinter, type DeleteBlock } from "../../store/labelStore";
1010
import { encodeGraphicFile } from "@zplab/core/lib/imageToZpl";
1111
import { sanitizeStorageName, uploadedGraphicPath } from "@zplab/core/lib/storagePath";
1212
import { setupEntryHoldsOther, withSetupEntry, withoutSetupEntry } from "@zplab/core/lib/setupEntries";
@@ -18,7 +18,6 @@ import { storedObjectOrigins } from "@zplab/core/lib/storedObjectOrigins";
1818
import { removeImage } from "@zplab/core/lib/imageCache";
1919
import { imageUsage } from "@zplab/core/lib/imageUsage";
2020
import type { SetupGraphic } from "@zplab/core/types/PrinterProfile";
21-
import { isDesktopShell } from "../../lib/platform";
2221
import { PrinterObjectActions, PrinterOriginMark, PrinterStorageBar, StoredObjectsHeading } from "./PrinterStorage";
2322

2423
export function StoredGraphicsTab() {
@@ -52,6 +51,7 @@ export function StoredGraphicsTab() {
5251

5352
// Frozen, the open pages are not what a source session will apply, so no control may act on them.
5453
const frozen = useLabelStore(selectEditorFrozen);
54+
const readsPrinter = useLabelStore(selectReadsPrinter);
5555
const usage = imageUsage(pages);
5656
const deletability = useFileDeletability();
5757
const cached = useCachedImages();
@@ -116,7 +116,7 @@ export function StoredGraphicsTab() {
116116
</span>
117117
)}
118118
</div>
119-
{isDesktopShell && <PrinterStorageBar />}
119+
{readsPrinter && <PrinterStorageBar />}
120120
{origins.length === 0 ? (
121121
<p className="text-xs text-muted/70">{loc.noGraphics}</p>
122122
) : (
Collapse file

‎src/lib/previewProviderLabel.ts‎

Copy file name to clipboardExpand all lines: src/lib/previewProviderLabel.ts
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import type { Translations } from "../locales";
2-
import type { LabelState } from "../store/labelStore";
32
import type { PreviewProvider } from "../store/slices/uiSlice";
4-
import { isDesktopShell } from "./platform";
53

64
/** The one wording per renderer, so every place names it the same. */
75
export function previewProviderLabel(t: Translations, provider: PreviewProvider): string {
@@ -18,11 +16,11 @@ export interface PreviewProviderChoice {
1816
}
1917

2018
/** The renderers as one choice list, so every place locks the same ones. */
21-
export function previewProviderChoices(t: Translations, s: Pick<LabelState, "thirdParty">): PreviewProviderChoice[] {
19+
export function previewProviderChoices(t: Translations, offered: { labelary: boolean; printer: boolean }): PreviewProviderChoice[] {
2220
const loc = t.printerSettings.preview;
2321
return [
24-
{ provider: "labelary", label: loc.providerLabelary, disabled: !s.thirdParty.labelary },
25-
{ provider: "printer", label: loc.providerPrinter, disabled: !isDesktopShell, ...(isDesktopShell ? {} : { reason: loc.providerPrinterDesktopOnly }) },
22+
{ provider: "labelary", label: loc.providerLabelary, disabled: !offered.labelary },
23+
{ provider: "printer", label: loc.providerPrinter, disabled: !offered.printer, ...(offered.printer ? {} : { reason: loc.providerPrinterDesktopOnly }) },
2624
{ provider: "none", label: loc.providerNone, disabled: false },
2725
];
2826
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.