{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ideskset.com/schema/deskpack.schema.json",
  "title": "Deskset widget manifest (deskpack.json)",
  "type": "object",
  "required": ["id", "name", "version"],
  "properties": {
    "$schema": { "type": "string" },
    "id": {
      "type": "string",
      "minLength": 3,
      "maxLength": 64,
      "pattern": "^[a-z0-9][a-z0-9._-]{2,63}$",
      "description": "Reverse-DNS identifier (3–64 characters), unique to you (com.yourname.widget). Never change it after publishing."
    },
    "name": { "type": "string", "maxLength": 120, "description": "English name (also the fallback)." },
    "nameZh": { "type": "string", "maxLength": 120, "description": "Chinese name, shown when the app runs in Chinese." },
    "version": { "type": "string", "description": "Semantic version. A higher version upgrades installed copies." },
    "description": { "type": "string", "maxLength": 2000 },
    "descriptionZh": { "type": "string", "maxLength": 2000 },
    "defaultLocale": {
      "type": "string",
      "minLength": 2,
      "maxLength": 35,
      "pattern": "^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$",
      "default": "en",
      "description": "Default BCP-47 locale tag (e.g. \"en\", \"zh-Hans\", \"ja\", \"pt-BR\") used as the primary fallback when resolving translations from locales/<tag>.json."
    },
    "author": { "type": "string", "maxLength": 120 },
    "category": { "enum": ["time", "productivity", "media", "info", "system", "community"] },
    "icon": { "type": "string", "maxLength": 120, "description": "SF Symbol name, e.g. \"timer\"." },
    "sizes": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": { "enum": ["small", "medium", "large", "custom"] },
      "description": "Canonical values: \"small\" (164×164), \"medium\" (344×164), \"large\" (344×344), and \"custom\" (freeform, default 420×220) points. Any slot can override its dimensions in `sizeDimensions`."
    },
    "sizeDimensions": {
      "type": "object",
      "description": "Optional per-size dimension overrides in points (keyed by small / medium / large / custom).",
      "propertyNames": { "enum": ["small", "medium", "large", "custom"] },
      "additionalProperties": {
        "type": "object",
        "required": ["width", "height"],
        "properties": {
          "width": { "type": "number", "minimum": 80, "maximum": 1600 },
          "height": { "type": "number", "minimum": 80, "maximum": 1200 },
          "minWidth": { "type": "number", "minimum": 80, "maximum": 1600 },
          "minHeight": { "type": "number", "minimum": 80, "maximum": 1200 },
          "maxWidth": { "type": "number", "minimum": 80, "maximum": 1600 },
          "maxHeight": { "type": "number", "minimum": 80, "maximum": 1200 }
        }
      }
    },
    "styles": {
      "type": "array",
      "uniqueItems": true,
      "items": { "enum": ["glass", "minimal", "modern", "pure", "bare"] },
      "description": "Optional visual variants supported by this widget. Declare [\"glass\", \"minimal\"] to expose per-widget Glass / Minimal switching in the Edit Widget panel and Widget Studio."
    },
    "accentColor": { "type": "string", "pattern": "^#[0-9A-Fa-f]{6}$" },
    "minimumAppVersion": { "type": "string", "pattern": "^\\d+\\.\\d+(\\.\\d+)?$", "default": "1.0.0" },
    "entry": { "type": "string", "default": "index.tsx", "description": "TS/TSX/JS entry file; its default export is the widget." },
    "dependencies": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id"],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 3,
            "maxLength": 64,
            "pattern": "^[a-z0-9][a-z0-9._-]{2,63}$"
          },
          "versionRange": {
            "type": "string",
            "maxLength": 64,
            "default": "*"
          }
        }
      },
      "description": "Optional data-provider or extension packages this widget depends on."
    },
    "options": {
      "type": "object",
      "description": "User settings shown in the widget's edit panel; read them from useWidget().settings[key].",
      "propertyNames": { "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$", "not": { "pattern": "^(appearance|desktop)\\." } },
      "additionalProperties": {
        "type": "object",
        "required": ["type"],
        "properties": {
          "type": { "enum": ["string", "number", "boolean", "choice", "color"] },
          "label": { "type": "string", "maxLength": 120 },
          "labelZh": { "type": "string", "maxLength": 120 },
          "labelEn": { "type": "string", "maxLength": 120 },
          "default": {},
          "min": { "type": "number" },
          "max": { "type": "number" },
          "choices": { "type": "array", "items": { "type": "string", "minLength": 1, "maxLength": 256 }, "minItems": 1, "maxItems": 64 },
          "group": { "enum": ["content", "interaction", "desktop"] },
          "order": { "type": "integer" }
        },
        "if": {
          "properties": { "type": { "const": "string" } }
        },
        "then": {
          "properties": { "default": { "type": "string", "maxLength": 2048 } }
        }
      }
    }
  }
}
