Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/Canvas/LabelCanvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { KonvaObject } from "./KonvaObject";
import { Grid } from "./Grid";
import { GuideLines } from "./GuideLines";
import { Ruler, RULER_SIZE } from "./Ruler";
import { ObjectRegistry } from "../../registry";
import { getEntry } from "../../registry";
import type { LeafObject } from "../../registry";
import { useColorScheme } from "../../lib/useColorScheme";
import { objectIdsAtPoint } from "./hitTesting";
Expand Down Expand Up @@ -704,7 +704,7 @@ export const LabelCanvas = forwardRef<LabelCanvasHandle, Props>(function LabelCa
const dragData = event.active.data.current as PaletteDragData | undefined;
const type = dragData?.type;
if (!type) return;
const def = ObjectRegistry[type];
const def = getEntry(type);
if (!def) return;
setGhost({
id: "__ghost__",
Expand Down
8 changes: 4 additions & 4 deletions src/components/Canvas/hooks/useKonvaTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useRef, useEffect } from "react";
import type Konva from "konva";
import { pxToDots } from "../../../lib/coordinates";
import { getCurrentObjects } from "../../../store/labelStore";
import { BARCODE_1D_TYPES, STACKED_2D_TYPES, ObjectRegistry } from "../../../registry";
import { BARCODE_1D_TYPES, STACKED_2D_TYPES, getEntry } from "../../../registry";
import type { LeafObject } from "../../../registry";
import type { ObjectChanges } from "../../../store/labelStore";
import { findObjectById, isGroup } from "../../../types/Group";
Expand Down Expand Up @@ -189,7 +189,7 @@ export function useKonvaTransformer({
: undefined;
const resizeEnabled = selectedIds.length <= 1 && !singleSelected?.locked;
const singleType = singleSelected?.type ?? "";
const uniformScaleDef = ObjectRegistry[singleType]?.uniformScale;
const uniformScaleDef = getEntry(singleType)?.uniformScale;
const isUniformScale =
typeof uniformScaleDef === "function"
? !!singleSelected && !isGroup(singleSelected) &&
Expand All @@ -198,7 +198,7 @@ export function useKonvaTransformer({
const enabledAnchors: string[] | undefined =
selectedIds.length > 1
? []
: ObjectRegistry[singleType]?.heightLocked
: getEntry(singleType)?.heightLocked
? []
: BARCODE_1D_TYPES.has(singleType)
? [
Expand Down Expand Up @@ -347,7 +347,7 @@ export function useKonvaTransformer({
x: positionDidMove(renderedXDots, oldRendered.x) ? snap(modelPos.x) : obj.x,
y: positionDidMove(renderedYDots, oldRendered.y) ? snap(modelPos.y) : obj.y,
};
const commit = ObjectRegistry[obj.type]?.commitTransform;
const commit = getEntry(obj.type)?.commitTransform;
if (commit) {
const propChanges = commit(obj, {
sx,
Expand Down
3 changes: 1 addition & 2 deletions src/components/Fonts/FontManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import {
import { inputCls, labelCls } from '../Properties/styles';
import { CollapsibleSection } from '../ui/CollapsibleSection';
import { ConfirmDialog } from '../ui/ConfirmDialog';
import type { CustomFontMapping } from '../../types/ObjectType';

import type { CustomFontMapping } from '../../types/LabelConfig';
const PATHS_DATALIST_ID = 'zpl-custom-font-paths';

const addBtnCls =
Expand Down
2 changes: 1 addition & 1 deletion src/components/Output/ZplImportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { importZplText } from '../../lib/zplImportService';
import { readFileAsText } from '../../lib/readFile';
import { useLabelStore } from '../../store/labelStore';
import type { Page } from '../../types/Group';
import type { LabelConfig } from '../../types/ObjectType';
import type { LabelConfig } from '../../types/LabelConfig';
import type { PrinterProfile } from '../../types/PrinterProfile';
import type { Variable } from '../../types/Variable';
import { formatReportAsText, type ImportReport, type ImportResult } from '../../lib/importReport';
Expand Down
3 changes: 2 additions & 1 deletion src/components/Palette/ObjectPalette.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { PALETTE_GROUPS } from './paletteGroups';
import { useT } from '../../lib/useT';
import { useLabelStore } from '../../store/labelStore';
import { mmToDots } from '../../lib/coordinates';
import type { ObjectGroup, ObjectTypeDefinition } from '../../types/ObjectType';
import type { ObjectGroup } from '../../types/LabelObject';
import type { ObjectTypeDefinition } from '../../types/ObjectType';
import { resolveDefaultSizeDots } from './resolveDefaultSize';
import { DragHandleIcon } from '../ui/DragHandleIcon';
import { CollapsibleSection } from '../ui/CollapsibleSection';
Expand Down
3 changes: 1 addition & 2 deletions src/components/Palette/paletteGroups.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { ObjectGroup } from '../../types/ObjectType';

import type { ObjectGroup } from '../../types/LabelObject';
export const PALETTE_GROUPS = [
{ key: 'text' as ObjectGroup, labelKey: 'groupText' },
{ key: 'code-1d' as ObjectGroup, labelKey: 'groupCode1d' },
Expand Down
3 changes: 1 addition & 2 deletions src/components/Palette/resolveDefaultSize.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { describe, it, expect } from "vitest";
import { resolveDefaultSizeDots } from "./resolveDefaultSize";
import type { LabelConfig } from "../../types/ObjectType";

import type { LabelConfig } from "../../types/LabelConfig";
const labelAt = (dpmm: number): LabelConfig =>
({ widthMm: 100, heightMm: 50, dpmm }) as LabelConfig;

Expand Down
4 changes: 2 additions & 2 deletions src/components/Palette/resolveDefaultSize.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { mmToDots } from "../../lib/coordinates";
import type { LabelConfig, ObjectTypeDefinition } from "../../types/ObjectType";

import type { LabelConfig } from "../../types/LabelConfig";
import type { ObjectTypeDefinition } from "../../types/ObjectType";
/** Resolve a registry `defaultSize` declaration to dot units against
* the active label config. Spec-fixed-physical-size symbols (e.g.
* Maxicode) declare `widthMm`/`heightMm` so their footprint stays
Expand Down
14 changes: 1 addition & 13 deletions src/components/PrinterSettings/ClockAndTimeTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,7 @@ import { useId } from "react";
import { useT } from "../../lib/useT";
import { useLabelStore } from "../../store/labelStore";
import { inputCls, labelCls } from "../ui/formStyles";
import {
CLOCK_FORMAT_VALUES,
CLOCK_LANGUAGE_VALUES,
CLOCK_MODE_VALUES,
CLOCK_TOLERANCE_DEFAULT,
CLOCK_TOLERANCE_RANGE,
isClockFormat,
isClockLanguage,
isClockMode,
type ClockFormat,
type ClockLanguage,
type ClockMode,
} from "../../types/ObjectType";
import { CLOCK_FORMAT_VALUES, CLOCK_LANGUAGE_VALUES, CLOCK_MODE_VALUES, CLOCK_TOLERANCE_DEFAULT, CLOCK_TOLERANCE_RANGE, isClockFormat, isClockLanguage, isClockMode, type ClockFormat, type ClockLanguage, type ClockMode } from "../../types/PrinterProfile";
import {
BoundedIntControl,
ZplCommandLabel,
Expand Down
9 changes: 1 addition & 8 deletions src/components/PrinterSettings/EncodingAndLanguageTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,7 @@ import { useId } from "react";
import { useT } from "../../lib/useT";
import { useLabelStore } from "../../store/labelStore";
import { inputCls } from "../ui/formStyles";
import {
PRINTER_LOCALE_VALUES,
ZPL_MODE_VALUES,
isPrinterLocale,
isZplMode,
type PrinterLocale,
type ZplMode,
} from "../../types/ObjectType";
import { PRINTER_LOCALE_VALUES, ZPL_MODE_VALUES, isPrinterLocale, isZplMode, type PrinterLocale, type ZplMode } from "../../types/PrinterProfile";
import {
ZplCommandLabel,
ZplEnumSelect,
Expand Down
2 changes: 1 addition & 1 deletion src/components/PrinterSettings/IdentityTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useId } from "react";
import { useT } from "../../lib/useT";
import { useLabelStore } from "../../store/labelStore";
import { inputCls, labelCls } from "../ui/formStyles";
import { PRINTER_NAME_MAX_LEN } from "../../types/ObjectType";
import { PRINTER_NAME_MAX_LEN } from "../../types/PrinterProfile";
import {
ZplCommandLabel,
ZplField,
Expand Down
16 changes: 1 addition & 15 deletions src/components/PrinterSettings/MediaFeedTab.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
import { useT } from "../../lib/useT";
import { useLabelStore } from "../../store/labelStore";
import {
MAX_LABEL_LENGTH_RANGE,
MEDIA_FEED_VALUES,
MEDIA_MODE_VALUES,
MEDIA_TRACKING_VALUES,
MEDIA_TYPE_VALUES,
isMediaFeedMode,
isMediaMode,
isMediaTracking,
isMediaType,
type MediaFeedMode,
type MediaMode,
type MediaTracking,
type MediaType,
} from "../../types/ObjectType";
import { MAX_LABEL_LENGTH_RANGE, MEDIA_FEED_VALUES, MEDIA_MODE_VALUES, MEDIA_TRACKING_VALUES, MEDIA_TYPE_VALUES, isMediaFeedMode, isMediaMode, isMediaTracking, isMediaType, type MediaFeedMode, type MediaMode, type MediaTracking, type MediaType } from "../../types/LabelConfig";
import {
ZplBoundedIntInput,
ZplCheckbox,
Expand Down
12 changes: 2 additions & 10 deletions src/components/PrinterSettings/PrintQualityTab.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import { useT } from "../../lib/useT";
import { useLabelStore } from "../../store/labelStore";
import {
DARKNESS_INSTANT_RANGE,
DARKNESS_PERMANENT_RANGE,
HEAD_TEST_INTERVAL_RANGE,
PRINT_ORIENTATION_VALUES,
SPEED_RANGE,
TEAR_OFF_ADJUST_RANGE,
isPrintOrientation,
type PrintOrientation,
} from "../../types/ObjectType";
import { DARKNESS_INSTANT_RANGE, DARKNESS_PERMANENT_RANGE, PRINT_ORIENTATION_VALUES, SPEED_RANGE, isPrintOrientation, type PrintOrientation } from "../../types/LabelConfig";
import { HEAD_TEST_INTERVAL_RANGE, TEAR_OFF_ADJUST_RANGE } from "../../types/PrinterProfile";
import {
BoundedIntControl,
ZplBoundedIntInput,
Expand Down
4 changes: 2 additions & 2 deletions src/components/Properties/LayerRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
LinkSlashIcon,
VariableIcon,
} from '@heroicons/react/16/solid';
import { ObjectRegistry } from '../../registry';
import { getEntry } from '../../registry';
import { isGroup, type LabelObject } from '../../types/Group';
import { useT } from '../../lib/useT';
import { useLabelStore } from '../../store/labelStore';
Expand Down Expand Up @@ -69,7 +69,7 @@ export function LayerRow({
onRename,
}: LayerRowProps) {
const t = useT();
const def = ObjectRegistry[obj.type];
const def = getEntry(obj.type);
const groupRow = isGroup(obj);
// Variable badge: small {x} glyph next to the type icon when the leaf
// is bound, with the variable name as a tooltip. Lets the user scan
Expand Down
9 changes: 5 additions & 4 deletions src/components/Properties/PropertiesPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { InformationCircleIcon, FolderPlusIcon } from "@heroicons/react/16/solid
import { useLabelStore, useCurrentObjects } from "../../store/labelStore";
import type { LabelCanvasHandle } from "../Canvas/LabelCanvas";
import type { AlignAxis } from "../../lib/alignment";
import { ObjectRegistry } from "../../registry";
import { getEntry } from "../../registry";
import { getPanel } from "../../registry/panels";
import { canGroupSelection, findObjectById, isGroup } from "../../types/Group";
import { BWIP_APPROX_SEVERITY } from "../Canvas/bwipConstants";
import { stripZplCommandChars } from "../../registry/zplHelpers";
Expand All @@ -23,7 +24,7 @@ import { AlignButtons } from "./AlignButtons";
import { VariableBindingControl } from "../Variables/VariableBindingControl";
import { applyBindingToObject, lookupBoundVariable } from "../../lib/variableBinding";
import { inputCls, labelCls } from "./styles";
import type { LabelConfig } from "../../types/ObjectType";
import type { LabelConfig } from "../../types/LabelConfig";
import {
getAvailableFontIds,
stripDrivePrefix,
Expand Down Expand Up @@ -152,8 +153,8 @@ export function PropertiesPanel({ canvasRef }: PropertiesPanelProps) {
);
}

const definition = ObjectRegistry[obj.type];
const TypePanel = definition?.PropertiesPanel;
const definition = getEntry(obj.type);
const TypePanel = getPanel(obj.type)?.PropertiesPanel;
const groupRow = isGroup(obj);
// Groups intentionally have no registry entry; surface a folder-shape
// glyph here so the header reads as something rather than blank.
Expand Down
3 changes: 1 addition & 2 deletions src/lib/customFonts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { CustomFontMapping, LabelConfig } from "../types/ObjectType";

import type { CustomFontMapping, LabelConfig } from "../types/LabelConfig";
/** Characters NOT allowed in a ^CW alias. Used as a strip-pattern on
* user input so a single source of truth feeds both UI surfaces (the
* Custom Fonts editor and the Fonts-tab inline alias). The schema
Expand Down
3 changes: 2 additions & 1 deletion src/lib/designFile.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { z } from "zod";
import { labelConfigSchema, labelObjectBaseSchema, type LabelConfig } from "../types/ObjectType";
import { labelConfigSchema, type LabelConfig } from "../types/LabelConfig";
import { labelObjectBaseSchema } from "../types/LabelObject";
import {
variableSchema,
csvMappingSchema,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/labelGeometry/textRenderMetrics.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { resolvePreviewFontName } from "../customFonts";
import { getFontFamily } from "../fontCache";
import type { LabelObject } from "../../types/Group";
import type { LabelConfig } from "../../types/ObjectType";
import type { LabelConfig } from "../../types/LabelConfig";
import { measureInkWidthPx } from "./measureTextDots";
import { ZPL_FONT_HEIGHT_TO_CSS_RATIO } from "./textPositionTransforms";

Expand Down
3 changes: 1 addition & 2 deletions src/lib/labelary.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { LabelConfig } from '../types/ObjectType';

import type { LabelConfig } from '../types/LabelConfig';
const TIMEOUT_MS = 10_000;
const DEFAULT_HOST = 'https://api.labelary.com';

Expand Down
2 changes: 1 addition & 1 deletion src/lib/printPreview.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { generateZPL } from "./zplGenerator";
import { fetchPreview } from "./labelary";
import type { LabelConfig } from "../types/ObjectType";
import type { LabelConfig } from "../types/LabelConfig";
import type { LabelObject } from "../types/Group";
import type { Variable } from "../types/Variable";
import { applyBindingToTree, type ActiveCsvRow } from "./variableBinding";
Expand Down
7 changes: 2 additions & 5 deletions src/lib/realtimeClock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@
* reject, and the parser never round-trips an impossible date.
*/

// `realtimeClockIsoRegex` is declared on `labelConfigSchema` side
// (src/types/ObjectType.ts) so the schema can hoist the shape check
// without `types → lib` cross-import. Re-export here for consumers
// that want both the validator and the parse/format pair together.
export { realtimeClockIsoRegex } from '../types/ObjectType';
// Re-export so consumers can grab the regex and parse/format helpers together.
export { realtimeClockIsoRegex } from '../types/PrinterProfile';

/** Returns the current local time as the ISO datetime-local string
* shape (`YYYY-MM-DDTHH:MM:SS`). Used by the ^ST "Now" button to
Expand Down
3 changes: 1 addition & 2 deletions src/lib/zplGenerator.printerSettings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { describe, it, expect } from "vitest";
import { generateZPL } from "./zplGenerator";
import { generateSetupScript } from "./zplSetupScript";
import { parseZPL } from "./zplParser";
import type { LabelConfig } from "../types/ObjectType";

import type { LabelConfig } from "../types/LabelConfig";
const base: LabelConfig = { widthMm: 100, heightMm: 50, dpmm: 8 };

describe("Printer Settings Modal Tab 1 — generator", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/zplGenerator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { describe, it, expect } from 'vitest';
import { zlibSync } from 'fflate';
import { generateZPL, generateMultiPageZPL, generateBatchZpl } from './zplGenerator';
import { parseZPL } from './zplParser';
import type { LabelConfig } from '../types/ObjectType';
import type { LabelConfig } from '../types/LabelConfig';
import type { GroupObject, LabelObject } from '../types/Group';
import { defined, props } from '../test/helpers';

Expand Down
7 changes: 4 additions & 3 deletions src/lib/zplGenerator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mmToDots } from './coordinates';
import { ObjectRegistry } from '../registry';
import { getEntry } from '../registry';
import { fdField, stripZplCommandChars } from '../registry/zplHelpers';
import {
extractTemplateRefs,
Expand All @@ -12,7 +12,8 @@ import {
isDefaultClockChars,
} from './fcTemplate';
import { getObjectStringContent } from './variableBinding';
import type { CustomFontMapping, LabelConfig, ZplEmitContext } from '../types/ObjectType';
import type { CustomFontMapping, LabelConfig } from '../types/LabelConfig';
import type { ZplEmitContext } from '../types/ZplEmit';
import type { Variable } from '../types/Variable';
import { isGroup, type LabelObject, type Page } from '../types/Group';
import { getFontBytes } from './fontCache';
Expand Down Expand Up @@ -418,7 +419,7 @@ export function generateZPL(
const emitLeaf = (obj: LabelObject): string[] => {
if (obj.includeInExport === false) return [];
if (isGroup(obj)) return obj.children.flatMap(emitLeaf);
const zpl = ObjectRegistry[obj.type]?.toZPL(obj, emitCtx) ?? '';
const zpl = getEntry(obj.type)?.toZPL(obj, emitCtx) ?? '';
return obj.comment
? [`^FX${stripZplCommandChars(obj.comment)}\n${zpl}`]
: [zpl];
Expand Down
2 changes: 1 addition & 1 deletion src/lib/zplImportService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { parseZPL, type ImportFinding, type ImportFindingKind, type ImportReport } from "./zplParser";
import { pruneUndefined } from "./pruneUndefined";
import type { LabelConfig } from "../types/ObjectType";
import type { LabelConfig } from "../types/LabelConfig";
import type { PrinterProfile } from "../types/PrinterProfile";
import type { LabelObject } from "../types/Group";
import { uniqueVariableName, type Variable } from "../types/Variable";
Expand Down
2 changes: 1 addition & 1 deletion src/lib/zplParser/context.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { LabelObject } from "../../types/Group";
import type { LabelConfig } from "../../types/ObjectType";
import type { LabelConfig } from "../../types/LabelConfig";
import type { PrinterProfile } from "../../types/PrinterProfile";
import type { Variable } from "../../types/Variable";
import type { TextProps } from "../../registry/text";
Expand Down
2 changes: 1 addition & 1 deletion src/lib/zplParser/handlers/fields.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CustomFontMapping } from "../../../types/ObjectType";
import type { CustomFontMapping } from "../../../types/LabelConfig";
import { FN_NUMBER_MAX, FN_NUMBER_MIN } from "../../../types/Variable";
import type { SerialProps } from "../../../registry/serial";
import { getDefaultTextH, getDefaultTextW, type ParserState } from "../context";
Expand Down
14 changes: 2 additions & 12 deletions src/lib/zplParser/handlers/labelConfig.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
import type { LabelConfig } from "../../../types/ObjectType";
import {
DARKNESS_INSTANT_RANGE,
DARKNESS_PERMANENT_RANGE,
MAX_LABEL_LENGTH_RANGE,
SPEED_RANGE,
isMediaFeedMode,
isMediaMode,
isMediaTracking,
isMediaType,
isPrintOrientation,
} from "../../../types/ObjectType";
import type { LabelConfig } from "../../../types/LabelConfig";
import { DARKNESS_INSTANT_RANGE, DARKNESS_PERMANENT_RANGE, MAX_LABEL_LENGTH_RANGE, SPEED_RANGE, isMediaFeedMode, isMediaMode, isMediaTracking, isMediaType, isPrintOrientation } from "../../../types/LabelConfig";
import { parseIntOrUndef } from "../../inputParse";
import { firstChar, inRange, int, strParam } from "../helpers";
import type { Handler } from "../types";
Expand Down
12 changes: 1 addition & 11 deletions src/lib/zplParser/handlers/setupScript.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
import type { PrinterProfile } from "../../../types/PrinterProfile";
import {
CLOCK_TOLERANCE_RANGE,
HEAD_TEST_INTERVAL_RANGE,
PRINTER_NAME_MAX_LEN,
TEAR_OFF_ADJUST_RANGE,
isClockFormat,
isClockLanguage,
isPrinterLocale,
isZplMode,
setupScriptUnsafeCharRegex,
} from "../../../types/ObjectType";
import { CLOCK_TOLERANCE_RANGE, HEAD_TEST_INTERVAL_RANGE, PRINTER_NAME_MAX_LEN, TEAR_OFF_ADJUST_RANGE, isClockFormat, isClockLanguage, isPrinterLocale, isZplMode, setupScriptUnsafeCharRegex } from "../../../types/PrinterProfile";
import { parseIntOrUndef } from "../../inputParse";
import { parseRealtimeClock } from "../../realtimeClock";
import { inRange, strParam } from "../helpers";
Expand Down
Loading