@seedprotocol/sdk 0.7.9 → 0.7.10-next.1353.g74aeeed

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.
Files changed (136) hide show
  1. package/README.md +1 -1
  2. package/dist/{BaseFileManager-BAlySv8w.js → BaseFileManager-DLou1TZS.js} +5 -1
  3. package/dist/BaseFileManager-DLou1TZS.js.map +1 -0
  4. package/dist/{Item-Bf4kWKpH.js → Item-oPnmIehk.js} +571 -346
  5. package/dist/Item-oPnmIehk.js.map +1 -0
  6. package/dist/{ModelProperty-BlaEgb_U.js → ModelProperty-D2vJozmW.js} +95 -62
  7. package/dist/ModelProperty-D2vJozmW.js.map +1 -0
  8. package/dist/{Schema-J_1f6p0c.js → Schema-BMXRF4j9.js} +88 -52
  9. package/dist/Schema-BMXRF4j9.js.map +1 -0
  10. package/dist/{SchemaValidationService-CnmKyzR-.js → SchemaValidationService-CieGrj5c.js} +5 -5
  11. package/dist/{SchemaValidationService-CnmKyzR-.js.map → SchemaValidationService-CieGrj5c.js.map} +1 -1
  12. package/dist/{errors-C1qUEZ7A.js → browserSupport-C64rX-2I.js} +38 -2
  13. package/dist/browserSupport-C64rX-2I.js.map +1 -0
  14. package/dist/{configurePlatform-CiOJ1R3q.js → configurePlatform-WkmvqeTO.js} +2 -2
  15. package/dist/{configurePlatform-CiOJ1R3q.js.map → configurePlatform-WkmvqeTO.js.map} +1 -1
  16. package/dist/{detachRowsBeforeDelete-sEaUwlOU.js → detachRowsBeforeDelete-BZr_0iZU.js} +2 -2
  17. package/dist/{detachRowsBeforeDelete-sEaUwlOU.js.map → detachRowsBeforeDelete-BZr_0iZU.js.map} +1 -1
  18. package/dist/dist/{BaseFileManager-BAlySv8w.d.ts → BaseFileManager-DLou1TZS.d.ts} +3 -1
  19. package/dist/dist/BaseFileManager-DLou1TZS.d.ts.map +1 -0
  20. package/dist/dist/{configurePlatform-CiOJ1R3q.d.ts → configurePlatform-WkmvqeTO.d.ts} +1 -1
  21. package/dist/dist/configurePlatform-WkmvqeTO.d.ts.map +1 -0
  22. package/dist/dist/{index-D0V-mjCV.d.ts → index-BjWk0x4-.d.ts} +1 -1
  23. package/dist/dist/{index-D0V-mjCV.d.ts.map → index-BjWk0x4-.d.ts.map} +1 -1
  24. package/dist/dist/{index.node-CYPemH-t.d.ts → index.node-BfiBriEq.d.ts} +7 -1
  25. package/dist/dist/{index.node-CYPemH-t.d.ts.map → index.node-BfiBriEq.d.ts.map} +1 -1
  26. package/dist/dist/platform.node.d.ts +2 -2
  27. package/dist/{eas-wB_fQ8Tc.js → eas-FZPPqxqe.js} +5 -5
  28. package/dist/{eas-wB_fQ8Tc.js.map → eas-FZPPqxqe.js.map} +1 -1
  29. package/dist/{errors-DLSoqSHG.js → errors-CnT0fSMK.js} +185 -97
  30. package/dist/errors-CnT0fSMK.js.map +1 -0
  31. package/dist/{getPublishPayload-BnIwpwz1.js → getPublishPayload-DKuEaq96.js} +8 -8
  32. package/dist/{getPublishPayload-BnIwpwz1.js.map → getPublishPayload-DKuEaq96.js.map} +1 -1
  33. package/dist/{getPublishPendingDiff-D6_-A5ns.js → getPublishPendingDiff-CH5xLMjU.js} +7 -7
  34. package/dist/{getPublishPendingDiff-D6_-A5ns.js.map → getPublishPendingDiff-CH5xLMjU.js.map} +1 -1
  35. package/dist/{getPublishUploads-sS6JfPgz.js → getPublishUploads-DivYpgNw.js} +7 -7
  36. package/dist/{getPublishUploads-sS6JfPgz.js.map → getPublishUploads-DivYpgNw.js.map} +1 -1
  37. package/dist/{index-D0V-mjCV.js → index-BjWk0x4-.js} +2 -2
  38. package/dist/index-BjWk0x4-.js.map +1 -0
  39. package/dist/{index-CYGWPoOx.js → index-CZMWKXLM.js} +7 -7
  40. package/dist/index-CZMWKXLM.js.map +1 -0
  41. package/dist/{index-BVBmz_cc.js → index-DXRhFg1N.js} +7 -7
  42. package/dist/index-DXRhFg1N.js.map +1 -0
  43. package/dist/{index-DmTtj1nk.js → index-Gh42_47r.js} +402 -20
  44. package/dist/index-Gh42_47r.js.map +1 -0
  45. package/dist/{index.browser-CUmBVYen.js → index.browser-DQstVvRV.js} +46 -10
  46. package/dist/index.browser-DQstVvRV.js.map +1 -0
  47. package/dist/{index.node-CYPemH-t.js → index.node-BfiBriEq.js} +31 -4
  48. package/dist/index.node-BfiBriEq.js.map +1 -0
  49. package/dist/main.js +17 -16
  50. package/dist/main.js.map +1 -1
  51. package/dist/{modelPropertyRecordSchemas-C7UgA5TH.js → modelPropertyRecordSchemas-DEe-lYhn.js} +5 -5
  52. package/dist/{modelPropertyRecordSchemas-C7UgA5TH.js.map → modelPropertyRecordSchemas-DEe-lYhn.js.map} +1 -1
  53. package/dist/node.js +8 -8
  54. package/dist/platform.browser.js +6 -6
  55. package/dist/platform.node.js +4 -4
  56. package/dist/{property-BxUYznH0.js → property-iNW1N3vm.js} +8 -8
  57. package/dist/{property-BxUYznH0.js.map → property-iNW1N3vm.js.map} +1 -1
  58. package/dist/{publishGraph-EcB40Uii.js → publishGraph-CRn_N3NT.js} +5 -5
  59. package/dist/{publishGraph-EcB40Uii.js.map → publishGraph-CRn_N3NT.js.map} +1 -1
  60. package/dist/{readHtmlBodyForStorageSeed-D6KPtWoR.js → readHtmlBodyForStorageSeed-B7HgPmq6.js} +10 -10
  61. package/dist/{readHtmlBodyForStorageSeed-D6KPtWoR.js.map → readHtmlBodyForStorageSeed-B7HgPmq6.js.map} +1 -1
  62. package/dist/src/Item/Item.d.ts +26 -5
  63. package/dist/src/Item/Item.d.ts.map +1 -1
  64. package/dist/src/ItemProperty/ItemProperty.d.ts +20 -5
  65. package/dist/src/ItemProperty/ItemProperty.d.ts.map +1 -1
  66. package/dist/src/ItemProperty/loadProperty.d.ts.map +1 -1
  67. package/dist/src/ItemProperty/propertyWrite.d.ts.map +1 -1
  68. package/dist/src/ItemProperty/service/actors/hydrateFromDb.d.ts.map +1 -1
  69. package/dist/src/Model/Model.d.ts +45 -34
  70. package/dist/src/Model/Model.d.ts.map +1 -1
  71. package/dist/src/ModelProperty/ModelProperty.d.ts +31 -13
  72. package/dist/src/ModelProperty/ModelProperty.d.ts.map +1 -1
  73. package/dist/src/Schema/Schema.d.ts +36 -27
  74. package/dist/src/Schema/Schema.d.ts.map +1 -1
  75. package/dist/src/archive/exportArchive.d.ts +57 -0
  76. package/dist/src/archive/exportArchive.d.ts.map +1 -0
  77. package/dist/src/browser/db/Db.d.ts +5 -0
  78. package/dist/src/browser/db/Db.d.ts.map +1 -1
  79. package/dist/src/browser/helpers/FileManager.d.ts.map +1 -1
  80. package/dist/src/browser/helpers/tolerantWebAccess.d.ts +12 -1
  81. package/dist/src/browser/helpers/tolerantWebAccess.d.ts.map +1 -1
  82. package/dist/src/client/ClientManager.d.ts +14 -4
  83. package/dist/src/client/ClientManager.d.ts.map +1 -1
  84. package/dist/src/db/Db/BaseDb.d.ts +2 -0
  85. package/dist/src/db/Db/BaseDb.d.ts.map +1 -1
  86. package/dist/src/helpers/FileManager/errors.d.ts +11 -0
  87. package/dist/src/helpers/FileManager/errors.d.ts.map +1 -1
  88. package/dist/src/helpers/browserSupport.d.ts +23 -0
  89. package/dist/src/helpers/browserSupport.d.ts.map +1 -0
  90. package/dist/src/helpers/cachedPropertyRefresh.d.ts +6 -6
  91. package/dist/src/helpers/cachedPropertyRefresh.d.ts.map +1 -1
  92. package/dist/src/helpers/entity/entityCache.d.ts +45 -3
  93. package/dist/src/helpers/entity/entityCache.d.ts.map +1 -1
  94. package/dist/src/helpers/entity/entityLifecycle.d.ts +21 -3
  95. package/dist/src/helpers/entity/entityLifecycle.d.ts.map +1 -1
  96. package/dist/src/helpers/propertyDefinition.d.ts +2 -0
  97. package/dist/src/helpers/propertyDefinition.d.ts.map +1 -1
  98. package/dist/src/helpers/schemaApply.d.ts.map +1 -1
  99. package/dist/src/helpers/tabCoordinator.d.ts +9 -2
  100. package/dist/src/helpers/tabCoordinator.d.ts.map +1 -1
  101. package/dist/src/index.d.ts +4 -1
  102. package/dist/src/index.d.ts.map +1 -1
  103. package/dist/src/interfaces/IDb.d.ts +6 -0
  104. package/dist/src/interfaces/IDb.d.ts.map +1 -1
  105. package/dist/src/node/db/Db.d.ts +6 -0
  106. package/dist/src/node/db/Db.d.ts.map +1 -1
  107. package/dist/src/outbox/conflicts.d.ts.map +1 -1
  108. package/dist/src/outbox/outbox.d.ts +6 -0
  109. package/dist/src/outbox/outbox.d.ts.map +1 -1
  110. package/dist/src/types/index.d.ts +16 -0
  111. package/dist/src/types/index.d.ts.map +1 -1
  112. package/dist/{syncDbWithEas-CA7PvBgu.js → syncDbWithEas-FuyqoEKk.js} +14 -14
  113. package/dist/{syncDbWithEas-CA7PvBgu.js.map → syncDbWithEas-FuyqoEKk.js.map} +1 -1
  114. package/dist/{tabEvents-CaVmngqr.js → tabEvents-DT5ez6io.js} +38 -12
  115. package/dist/tabEvents-DT5ez6io.js.map +1 -0
  116. package/dist/{tolerantWebAccess-BJqViq08.js → tolerantWebAccess-zEseJ2zT.js} +53 -13
  117. package/dist/tolerantWebAccess-zEseJ2zT.js.map +1 -0
  118. package/dist/{updateSeedRevokedAt-BL9Bg-G7.js → updateSeedRevokedAt-B9JRwr5T.js} +3 -3
  119. package/dist/{updateSeedRevokedAt-BL9Bg-G7.js.map → updateSeedRevokedAt-B9JRwr5T.js.map} +1 -1
  120. package/package.json +10 -12
  121. package/dist/BaseFileManager-BAlySv8w.js.map +0 -1
  122. package/dist/Item-Bf4kWKpH.js.map +0 -1
  123. package/dist/ModelProperty-BlaEgb_U.js.map +0 -1
  124. package/dist/Schema-J_1f6p0c.js.map +0 -1
  125. package/dist/dist/BaseFileManager-BAlySv8w.d.ts.map +0 -1
  126. package/dist/dist/configurePlatform-CiOJ1R3q.d.ts.map +0 -1
  127. package/dist/errors-C1qUEZ7A.js.map +0 -1
  128. package/dist/errors-DLSoqSHG.js.map +0 -1
  129. package/dist/index-BVBmz_cc.js.map +0 -1
  130. package/dist/index-CYGWPoOx.js.map +0 -1
  131. package/dist/index-D0V-mjCV.js.map +0 -1
  132. package/dist/index-DmTtj1nk.js.map +0 -1
  133. package/dist/index.browser-CUmBVYen.js.map +0 -1
  134. package/dist/index.node-CYPemH-t.js.map +0 -1
  135. package/dist/tabEvents-CaVmngqr.js.map +0 -1
  136. package/dist/tolerantWebAccess-BJqViq08.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"getPublishUploads-sS6JfPgz.js","sources":["../../src/helpers/htmlEmbeddedDataUriPublish.ts","../../src/helpers/mapWithConcurrency.ts","../../src/helpers/compositeUpload.ts","../../src/db/read/getPublishUploads.ts"],"sourcesContent":["import { INTERNAL_STORAGE_MODEL_FILE_IDS } from '@/helpers/constants'\nimport { parseFragment } from 'parse5'\nimport type { DefaultTreeAdapterTypes } from 'parse5'\nimport { eq } from 'drizzle-orm'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { htmlEmbeddedImageCoPublish } from '@/seedSchema/HtmlEmbeddedImageCoPublishSchema'\nimport { BaseFileManager } from '@/helpers/FileManager/BaseFileManager'\nimport { getPublicArweaveRawUrl, normalizeRelationPropertyValue, resolveSeedIdsFromRefString } from '@seedprotocol/arweave'\nimport { getContentHash } from '@/helpers/crypto'\nimport { isValidEasAttestationUid } from '@seedprotocol/eas'\nimport { Item } from '@/Item/Item'\nimport { waitForEntityReady } from '@/helpers/entity/entityLifecycle'\nimport { ModelPropertyDataTypes, normalizeDataType, type HtmlEmbeddedDataUriPolicy } from '@/helpers/property'\nimport { findSeedRow } from '@/db/read/findSeedRow'\nimport { storageSeedTransactionId } from '@/storageValue/resolve'\nimport {\n getPublishGraph,\n publishGraphItemNodes,\n type EmbeddedImageRow,\n type PublishGraphNode,\n} from '@/db/read/publishGraph'\nimport { getExtensionForMimeType } from '@/helpers/mimeTypes'\n\nexport const HTML_EMBEDDED_MAX_IMAGES_PER_DOC = 50\nexport const HTML_EMBEDDED_MAX_IMAGE_BYTES = 5 * 1024 * 1024\nexport const HTML_EMBEDDED_MAX_TOTAL_BYTES = 25 * 1024 * 1024\n\nconst DATA_URI_IMAGE = /^data:(image\\/[a-zA-Z0-9.+-]+);base64,([\\s\\S]*)$/i\n\nconst MIME_NORMALIZE: Record<string, string> = {\n 'image/jpg': 'image/jpeg',\n}\n\nfunction normalizeMime(m: string): string {\n const lower = m.toLowerCase().trim()\n return MIME_NORMALIZE[lower] ?? lower\n}\n\nconst ALLOWED_MIMES = new Set([\n 'image/png',\n 'image/jpeg',\n 'image/webp',\n 'image/gif',\n 'image/svg+xml',\n])\n\nexport type HtmlEmbeddedExtractEntry = {\n dataUri: string\n stableKey: string\n byteLength: number\n mimeType: string\n /** The image's decoded bytes. */\n bytes: Uint8Array\n}\n\nexport class HtmlEmbeddedDataUriLimitError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'HtmlEmbeddedDataUriLimitError'\n }\n}\n\nexport function resolveEffectiveHtmlEmbeddedDataUriPolicy(\n propertyDef: { dataType?: string; htmlEmbeddedDataUriPolicy?: HtmlEmbeddedDataUriPolicy } | undefined,\n publishLevel?: HtmlEmbeddedDataUriPolicy,\n): HtmlEmbeddedDataUriPolicy {\n const fromProp = propertyDef?.htmlEmbeddedDataUriPolicy\n if (fromProp === 'materialize' || fromProp === 'preserve') return fromProp\n if (publishLevel === 'materialize' || publishLevel === 'preserve') return publishLevel\n return 'materialize'\n}\n\nfunction getAttr(node: DefaultTreeAdapterTypes.Element, name: string): string | undefined {\n const a = node.attrs?.find((x) => x.name === name)\n return a?.value\n}\n\n/**\n * Walk fragment tree; collect unique data:image base64 URIs with limits.\n */\nexport async function extractDataUriImagesFromHtml(html: string): Promise<HtmlEmbeddedExtractEntry[]> {\n const fragment = parseFragment(html)\n const found: HtmlEmbeddedExtractEntry[] = []\n const seenUris = new Set<string>()\n let totalBytes = 0\n\n const walk = async (node: DefaultTreeAdapterTypes.ChildNode): Promise<void> => {\n if (node.nodeName === '#text' || node.nodeName === '#comment') return\n const el = node as DefaultTreeAdapterTypes.Element\n if (el.tagName === 'img') {\n const src = getAttr(el, 'src')?.trim()\n if (src && src.startsWith('data:image/')) {\n const m = DATA_URI_IMAGE.exec(src)\n if (m) {\n const mimeRaw = normalizeMime(m[1]!)\n if (!ALLOWED_MIMES.has(mimeRaw)) {\n throw new HtmlEmbeddedDataUriLimitError(\n `Unsupported embedded image type: ${mimeRaw}. Allowed: ${[...ALLOWED_MIMES].join(', ')}`,\n )\n }\n let binary: Uint8Array\n try {\n const b64 = m[2]!.replace(/\\s/g, '')\n binary = Uint8Array.from(atob(b64), (c) => c.charCodeAt(0))\n } catch {\n throw new HtmlEmbeddedDataUriLimitError('Invalid base64 in embedded image data URI')\n }\n const byteLength = binary.byteLength\n if (byteLength > HTML_EMBEDDED_MAX_IMAGE_BYTES) {\n throw new HtmlEmbeddedDataUriLimitError(\n `Embedded image exceeds max size (${HTML_EMBEDDED_MAX_IMAGE_BYTES} bytes)`,\n )\n }\n totalBytes += byteLength\n if (totalBytes > HTML_EMBEDDED_MAX_TOTAL_BYTES) {\n throw new HtmlEmbeddedDataUriLimitError(\n `Total embedded image size exceeds max (${HTML_EMBEDDED_MAX_TOTAL_BYTES} bytes)`,\n )\n }\n if (!seenUris.has(src)) {\n if (seenUris.size >= HTML_EMBEDDED_MAX_IMAGES_PER_DOC) {\n throw new HtmlEmbeddedDataUriLimitError(\n `Too many distinct embedded images (max ${HTML_EMBEDDED_MAX_IMAGES_PER_DOC})`,\n )\n }\n seenUris.add(src)\n const stableKey = await getContentHash(binary)\n found.push({ dataUri: src, stableKey, byteLength, mimeType: mimeRaw, bytes: binary })\n }\n }\n }\n }\n const parent = el as DefaultTreeAdapterTypes.ParentNode\n if (parent.childNodes) {\n for (const c of parent.childNodes) await walk(c)\n }\n }\n\n for (const c of fragment.childNodes) await walk(c as DefaultTreeAdapterTypes.ChildNode)\n return found\n}\n\nfunction escapeAttributeValue(value: string): string {\n return value.replace(/&/g, '&amp;').replace(/\"/g, '&quot;')\n}\n\n/**\n * Rewrite attribute values of `html` by splicing each new value into the original string: every\n * byte other than the rewritten attributes stays as written. Re-serializing the parsed tree would\n * not round-trip (parse5 drops the newline the parser eats after `<pre>`/`<textarea>`/`<listing>`,\n * a fragment parse drops doctype/html/head/body, and quoting, case and line endings are normalized),\n * and sealed Html must not change with the serializer.\n *\n * `rewrite` gets each attribute's (entity-decoded) value and returns its new value, or undefined to\n * leave it. A rewritten attribute is written as `name=\"value\"`.\n */\nfunction rewriteHtmlAttributes(\n html: string,\n rewrite: (element: DefaultTreeAdapterTypes.Element, attrName: string, value: string) => string | undefined,\n): string {\n const fragment = parseFragment(html, { sourceCodeLocationInfo: true })\n const edits: { start: number; end: number; text: string }[] = []\n const walk = (node: DefaultTreeAdapterTypes.ChildNode): void => {\n if (node.nodeName === '#text' || node.nodeName === '#comment') return\n const el = node as DefaultTreeAdapterTypes.Element\n if (el.attrs?.length) {\n for (const attr of el.attrs) {\n if (attr.prefix) continue\n const next = rewrite(el, attr.name, attr.value)\n const location = el.sourceCodeLocation?.attrs?.[attr.name]\n if (next === undefined || !location) continue\n edits.push({\n start: location.startOffset,\n end: location.endOffset,\n text: `${attr.name}=\"${escapeAttributeValue(next)}\"`,\n })\n }\n }\n const parent = el as DefaultTreeAdapterTypes.ParentNode\n if (parent.childNodes) {\n for (const c of parent.childNodes) walk(c)\n }\n }\n for (const c of fragment.childNodes) walk(c as DefaultTreeAdapterTypes.ChildNode)\n\n let out = html\n for (const edit of edits.sort((a, b) => b.start - a.start)) {\n out = out.slice(0, edit.start) + edit.text + out.slice(edit.end)\n }\n return out\n}\n\n/**\n * Replace `data:image/...` `<img src>` values with Arweave URLs (keyed by data URI). Only those\n * `src` attributes change; the rest of the Html is kept byte for byte.\n */\nexport function replaceDataUrisInParsedHtml(\n html: string,\n replacements: Map<string, string>,\n): string {\n if (replacements.size === 0) return html\n return rewriteHtmlAttributes(html, (el, attrName, value) => {\n if (el.tagName !== 'img' || attrName !== 'src') return undefined\n return replacements.get(value.trim())\n })\n}\n\n/**\n * `seed:property/<propertyName>` in Html stands for the Arweave URL of the same item's\n * `<propertyName>` storage property (Image, File or Json). Publish uploads that property first,\n * then rewrites the placeholder to its gateway URL before the Html is uploaded, so Html can show a\n * file published alongside it without embedding it (e.g. `<img class=\"u-featured\"\n * src=\"seed:property/featureImage\">`).\n */\nexport const SEED_PROPERTY_REF_PREFIX = 'seed:property/'\nconst SEED_PROPERTY_REF = /^seed:property\\/([A-Za-z_$][A-Za-z0-9_$]*)$/\n/** Attributes whose whole (trimmed) value may be a `seed:property/` placeholder. */\nconst SEED_PROPERTY_REF_ATTRIBUTES = new Set(['src', 'href', 'poster'])\n\nconst seedPropertyRefName = (attrName: string, value: string): string | undefined =>\n SEED_PROPERTY_REF_ATTRIBUTES.has(attrName) ? SEED_PROPERTY_REF.exec(value.trim())?.[1] : undefined\n\n/** A `seed:property/` placeholder that names no usable property, or whose upload is unknown. */\nexport class HtmlSeedPropertyRefError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'HtmlSeedPropertyRefError'\n }\n}\n\n/** Property names referenced by `seed:property/<name>` placeholders in `html`, each once. */\nexport function findSeedPropertyRefsInHtml(html: string): string[] {\n if (!html.includes(SEED_PROPERTY_REF_PREFIX)) return []\n const names = new Set<string>()\n rewriteHtmlAttributes(html, (_el, attrName, value) => {\n const name = seedPropertyRefName(attrName, value)\n if (name) names.add(name)\n return undefined\n })\n return [...names]\n}\n\n/** Replace `seed:property/<name>` placeholders with `urlByPropertyName.get(name)`; other bytes are kept. */\nexport function replaceSeedPropertyRefsInHtml(html: string, urlByPropertyName: Map<string, string>): string {\n if (urlByPropertyName.size === 0) return html\n return rewriteHtmlAttributes(html, (_el, attrName, value) => {\n const name = seedPropertyRefName(attrName, value)\n return name ? urlByPropertyName.get(name) : undefined\n })\n}\n\nconst SEED_PROPERTY_REF_DATA_TYPES = [\n ModelPropertyDataTypes.Image,\n ModelPropertyDataTypes.File,\n ModelPropertyDataTypes.Json,\n] as string[]\n\n/**\n * The storage property of `node` a `seed:property/<name>` placeholder names, and the seed it holds.\n * Html properties are refused: an Html seed may itself be deferred to after the rewrite.\n */\nfunction resolveSeedPropertyRefTarget(\n node: PublishGraphNode,\n propertyName: string,\n): { seedLocalId?: string; seedUid?: string } {\n const property = node.properties.find((p) => p.key === propertyName)\n if (!property) {\n throw new HtmlSeedPropertyRefError(\n `Html references ${SEED_PROPERTY_REF_PREFIX}${propertyName}, but ${node.modelName} has no property ${propertyName}`,\n )\n }\n const def = property.definition\n const dataType = normalizeDataType(def.dataType)\n const storageType = dataType === ModelPropertyDataTypes.Relation ? normalizeDataType(def.refValueType) : dataType\n if (!SEED_PROPERTY_REF_DATA_TYPES.includes(storageType)) {\n throw new HtmlSeedPropertyRefError(\n `Html references ${SEED_PROPERTY_REF_PREFIX}${propertyName}, but ${propertyName} is ${def.dataType}; ` +\n `only Image, File and Json properties can be referenced`,\n )\n }\n const ids = resolveSeedIdsFromRefString(normalizeRelationPropertyValue(property.row?.propertyValue) ?? '')\n if (!ids.seedLocalId && !ids.seedUid) {\n throw new HtmlSeedPropertyRefError(\n `Html references ${SEED_PROPERTY_REF_PREFIX}${propertyName}, but ${propertyName} has no value`,\n )\n }\n return ids\n}\n\nconst ARWEAVE_TX_ID = /^[a-z0-9_-]{43}$/i\n\n/**\n * The Arweave tx of the storage seed a placeholder names: uploaded in this publish's phase 1, or,\n * when not uploaded now, the transaction it was published with (its storageTransactionId row).\n */\nasync function resolveSeedPropertyRefTxId(\n node: PublishGraphNode,\n propertyName: string,\n txBySeedLocalId: Map<string, string>,\n): Promise<string> {\n const target = resolveSeedPropertyRefTarget(node, propertyName)\n const uploaded = target.seedLocalId ? txBySeedLocalId.get(target.seedLocalId) : undefined\n if (uploaded) return uploaded\n\n const recorded = await storageSeedTransactionId(target)\n if (recorded && ARWEAVE_TX_ID.test(recorded)) return recorded\n\n throw new HtmlSeedPropertyRefError(\n `Html references ${SEED_PROPERTY_REF_PREFIX}${propertyName}, but ${propertyName} was not uploaded ` +\n `in this publish and has no published transaction`,\n )\n}\n\nexport type PrepareHtmlEmbeddedImagesResult = {\n /** Html storage seed local ids that must be uploaded in phase 2 (after image txs + rewrite). */\n deferredHtmlSeedLocalIds: string[]\n}\n\n/**\n * Name of the file holding an embedded image's bytes in the images folder: `<imageSeedLocalId>.<ext>`,\n * the extension following the image's MIME type (one of {@link ALLOWED_MIMES}).\n */\nexport function embeddedImageFileName(imageSeedLocalId: string, mimeType: string): string {\n return `${imageSeedLocalId}.${getExtensionForMimeType(mimeType) ?? 'bin'}`\n}\n\n/** Path of the file {@link createImageItemFromBytes} wrote for an Image seed, or undefined if there is none. */\nexport async function findEmbeddedImageFilePath(imageSeedLocalId: string): Promise<string | undefined> {\n for (const mimeType of ALLOWED_MIMES) {\n const filePath = BaseFileManager.getFilesPath('images', embeddedImageFileName(imageSeedLocalId, mimeType))\n if (await BaseFileManager.pathExists(filePath)) return filePath\n }\n return undefined\n}\n\n/**\n * Create an Image item for an embedded image and write its bytes to the images folder, where publish\n * reads them for upload ({@link findEmbeddedImageFilePath}). Its storageTransactionId stays empty\n * until the upload writes the transaction id, as for any other storage seed.\n */\nexport async function createImageItemFromBytes(\n bytes: Uint8Array,\n mimeType: string,\n): Promise<{ seedLocalId: string }> {\n const imageItem = await Item.create({\n modelName: 'Image',\n modelFileId: INTERNAL_STORAGE_MODEL_FILE_IDS.image,\n })\n await waitForEntityReady(imageItem, { timeout: 60_000 })\n const filePath = BaseFileManager.getFilesPath('images', embeddedImageFileName(imageItem.seedLocalId, mimeType))\n await BaseFileManager.createDirIfNotExists(BaseFileManager.getFilesPath('images'))\n const data = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength) as ArrayBuffer\n try {\n await BaseFileManager.saveFile(filePath, data)\n } catch {\n const fs = await BaseFileManager.getFs()\n fs.writeFileSync(filePath, bytes)\n }\n const { seedLocalId } = imageItem\n // Publish reads the image from its rows when it uploads and attests it\n imageItem.unload()\n return { seedLocalId }\n}\n\n/** The Html properties of a node with a stored Html seed and file name. */\nconst htmlValuesOf = (node: PublishGraphNode) =>\n node.properties.flatMap((property) => {\n if (normalizeDataType(property.definition.dataType) !== ModelPropertyDataTypes.Html) return []\n const htmlSeedLocalId = property.row?.propertyValue?.trim()\n const fileName = property.row?.refResolvedValue\n return htmlSeedLocalId && fileName ? [{ property, htmlSeedLocalId, filePath: `${BaseFileManager.getFilesPath('html')}/${fileName}` }] : []\n })\n\n/**\n * Scan Html storage properties, materialize embedded images as Image items, insert co-publish rows.\n * Call before phase-1 Arweave tx build. Does not rewrite Html files yet.\n */\nexport async function prepareHtmlEmbeddedImagesForPublish(\n item: { seedLocalId: string; modelName?: string },\n publishPolicy: HtmlEmbeddedDataUriPolicy | undefined,\n): Promise<PrepareHtmlEmbeddedImagesResult> {\n const appDb = BaseDb.getAppDb()\n if (!appDb) {\n return { deferredHtmlSeedLocalIds: [] }\n }\n const deferred = new Set<string>()\n // The item's own Html, and the Html of the draft items published with it: each gets its embedded\n // images materialized and co-published (rows keyed by the item owning the Html property).\n const graph = await getPublishGraph(item)\n for (const node of publishGraphItemNodes(graph)) {\n await prepareHtmlEmbeddedImagesOfNode(appDb, node, publishPolicy, deferred)\n }\n\n return { deferredHtmlSeedLocalIds: [...deferred] }\n}\n\n/**\n * An embedded image an earlier attempt materialized for this data URI that can be used again: its\n * Image seed is still a local draft and its file is there.\n */\nasync function reusableImage(row: EmbeddedImageRow | undefined): Promise<string | undefined> {\n if (!row) return undefined\n const seed = await findSeedRow({ localId: row.imageSeedLocalId })\n if (!seed || isValidEasAttestationUid(seed.uid)) return undefined\n return (await findEmbeddedImageFilePath(row.imageSeedLocalId)) ? row.imageSeedLocalId : undefined\n}\n\nasync function prepareHtmlEmbeddedImagesOfNode(\n appDb: NonNullable<ReturnType<typeof BaseDb.getAppDb>>,\n node: PublishGraphNode,\n publishPolicy: HtmlEmbeddedDataUriPolicy | undefined,\n deferred: Set<string>,\n): Promise<void> {\n // An earlier attempt's rows: their images are reused for the same Html and data URI\n const earlier = node.embeddedImages\n const kept: EmbeddedImageRow[] = []\n\n for (const { property, htmlSeedLocalId, filePath } of htmlValuesOf(node)) {\n if (!(await BaseFileManager.pathExists(filePath))) continue\n const html = await BaseFileManager.readFileAsString(filePath)\n\n // seed:property/ placeholders are filled in after phase 1 whatever the data URI policy. A\n // placeholder naming no usable property fails here, before anything is uploaded.\n const refs = findSeedPropertyRefsInHtml(html)\n for (const name of refs) resolveSeedPropertyRefTarget(node, name)\n if (refs.length > 0) deferred.add(htmlSeedLocalId)\n\n // The policy is the row's definition (a schema file's htmlEmbeddedDataUriPolicy or a code-defined one)\n const policy = resolveEffectiveHtmlEmbeddedDataUriPolicy(property.definition, publishPolicy)\n if (policy !== 'materialize') continue\n\n const extracted = await extractDataUriImagesFromHtml(html)\n if (extracted.length === 0) continue\n\n deferred.add(htmlSeedLocalId)\n\n for (const ent of extracted) {\n const previous = earlier.find((r) => r.htmlSeedLocalId.trim() === htmlSeedLocalId && r.stableKey === ent.stableKey)\n const reused = await reusableImage(previous)\n if (reused) {\n kept.push(previous!)\n continue\n }\n const { seedLocalId: imageSeedLocalId } = await createImageItemFromBytes(ent.bytes, ent.mimeType)\n if (previous) await appDb.delete(htmlEmbeddedImageCoPublish).where(eq(htmlEmbeddedImageCoPublish.id, previous.id))\n await appDb.insert(htmlEmbeddedImageCoPublish).values({\n parentSeedLocalId: node.seedLocalId,\n htmlSeedLocalId,\n imageSeedLocalId,\n stableKey: ent.stableKey,\n createdAt: Date.now(),\n }).onConflictDoNothing()\n }\n }\n\n // Rows for Html or data URIs no longer there\n for (const row of earlier) {\n if (kept.includes(row)) continue\n await appDb.delete(htmlEmbeddedImageCoPublish).where(eq(htmlEmbeddedImageCoPublish.id, row.id))\n }\n}\n\nexport type UploadedTx = { txId: string; seedLocalId?: string; versionLocalId?: string }\n\n/**\n * After phase-1 uploads, rewrite Html files on disk: data URI → Arweave gateway URL, and\n * `seed:property/<name>` → the gateway URL of that property's upload.\n *\n * `deferredHtmlSeedLocalIds` (from {@link prepareHtmlEmbeddedImagesForPublish}) limits the rewrite to\n * the Html held back from phase 1; without it, every Html of the item and its co-published drafts is\n * considered.\n */\nexport async function rewriteHtmlEmbeddedImagesOnDisk(\n parentSeedLocalId: string,\n uploadedTransactions: UploadedTx[],\n deferredHtmlSeedLocalIds?: string[],\n): Promise<void> {\n const appDb = BaseDb.getAppDb()\n if (!appDb) return\n\n const txBySeedLocalId = new Map<string, string>()\n for (const u of uploadedTransactions) {\n if (u.seedLocalId && u.txId) {\n txBySeedLocalId.set(u.seedLocalId.trim(), u.txId.trim())\n }\n }\n const deferred = deferredHtmlSeedLocalIds\n ? new Set(deferredHtmlSeedLocalIds.map((id) => id.trim()))\n : undefined\n\n // The parent's Html and that of the draft items published with it (see prepareHtmlEmbeddedImagesForPublish).\n const graph = await getPublishGraph({ seedLocalId: parentSeedLocalId })\n for (const node of publishGraphItemNodes(graph)) {\n await rewriteHtmlEmbeddedImagesOfNode(node, txBySeedLocalId, deferred)\n }\n}\n\nasync function rewriteHtmlEmbeddedImagesOfNode(\n node: PublishGraphNode,\n txBySeedLocalId: Map<string, string>,\n deferred: Set<string> | undefined,\n): Promise<void> {\n for (const { htmlSeedLocalId, filePath } of htmlValuesOf(node)) {\n if (deferred && !deferred.has(htmlSeedLocalId)) continue\n if (!(await BaseFileManager.pathExists(filePath))) continue\n\n const html = await BaseFileManager.readFileAsString(filePath)\n\n const replacements = new Map<string, string>()\n const entries = await extractDataUriImagesFromHtml(html)\n for (const r of node.embeddedImages) {\n if (r.htmlSeedLocalId.trim() !== htmlSeedLocalId) continue\n const txId = txBySeedLocalId.get(r.imageSeedLocalId.trim())\n const dataUri = entries.find((e) => e.stableKey === r.stableKey)?.dataUri\n if (txId && dataUri) replacements.set(dataUri, getPublicArweaveRawUrl(txId))\n }\n\n const urlByPropertyName = new Map<string, string>()\n for (const name of findSeedPropertyRefsInHtml(html)) {\n const txId = await resolveSeedPropertyRefTxId(node, name, txBySeedLocalId)\n urlByPropertyName.set(name, getPublicArweaveRawUrl(txId))\n }\n\n const newHtml = replaceSeedPropertyRefsInHtml(replaceDataUrisInParsedHtml(html, replacements), urlByPropertyName)\n if (newHtml === html) continue\n\n try {\n await BaseFileManager.saveFile(filePath, newHtml)\n } catch {\n const fs = await BaseFileManager.getFs()\n fs.writeFileSync(filePath, newHtml)\n }\n }\n}\n\n/**\n * Remove co-publish rows after a successful publish for this parent seed.\n */\nexport async function clearHtmlEmbeddedImageCoPublishRows(parentSeedLocalId: string): Promise<void> {\n const appDb = BaseDb.getAppDb()\n if (!appDb || !parentSeedLocalId) return\n await appDb\n .delete(htmlEmbeddedImageCoPublish)\n .where(eq(htmlEmbeddedImageCoPublish.parentSeedLocalId, parentSeedLocalId.trim()))\n}\n","/**\n * `Promise.all(items.map(fn))` with at most `limit` calls in flight. Results keep the input order.\n * Rejects with the first error (by time); after that no new calls start, though calls already in\n * flight run to completion.\n */\nexport async function mapWithConcurrency<T, R>(\n items: readonly T[],\n limit: number,\n fn: (item: T, index: number) => Promise<R>,\n): Promise<R[]> {\n const results = new Array<R>(items.length)\n const workerCount = Math.max(1, Math.min(Math.floor(limit) || 1, items.length))\n let next = 0\n let failed = false\n\n const worker = async (): Promise<void> => {\n while (!failed && next < items.length) {\n const index = next++\n try {\n results[index] = await fn(items[index]!, index)\n } catch (error) {\n failed = true\n throw error\n }\n }\n }\n\n await Promise.all(Array.from({ length: workerCount }, worker))\n return results\n}\n","/**\n * Composite uploads: several ItemStorage files of one item in a single Arweave transaction.\n *\n * Producer: `getPublishUploads.ts` (`processUploadPropertyData`), for an item with a\n * `storageTransactionId` property and ItemStorage properties (e.g. a Post's `html` and `json`).\n * Consumer: the download worker (`browser/workers/filesDownload.ts`), which keeps its own copy of\n * {@link decodeCompositeUpload} because it runs from a string; a test keeps the two in step.\n *\n * Format (unchanged for text children, so composites already on Arweave still read):\n *\n * ===FILE_SEPARATOR===<name>===FILE_SEPARATOR===<utf-8 text> (repeated per child)\n *\n * A child that is not valid UTF-8 text (or whose text contains the separator) is written as\n * base64 under the name `<name>;base64`. Composites written before this suffix existed converted\n * every child to text, which corrupted binary children; those bytes cannot be recovered.\n */\nexport const COMPOSITE_SEPARATOR = '===FILE_SEPARATOR==='\nexport const COMPOSITE_BASE64_SUFFIX = ';base64'\n\nexport type CompositeChild = { name: string; bytes: Uint8Array }\n\nconst bytesToBase64 = (bytes: Uint8Array): string => {\n let binary = ''\n const chunk = 0x8000\n for (let i = 0; i < bytes.length; i += chunk) {\n binary += String.fromCharCode(...bytes.subarray(i, i + chunk))\n }\n return btoa(binary)\n}\n\nconst base64ToBytes = (base64: string): Uint8Array | undefined => {\n try {\n const binary = atob(base64.replace(/\\s/g, ''))\n const out = new Uint8Array(binary.length)\n for (let i = 0; i < binary.length; i++) out[i] = binary.charCodeAt(i)\n return out\n } catch {\n return undefined\n }\n}\n\n/** The child's text when it can travel as text: valid UTF-8, no NUL bytes, no separator. */\nconst childAsText = (bytes: Uint8Array): string | undefined => {\n if (bytes.includes(0)) return undefined\n let text: string\n try {\n text = new TextDecoder('utf-8', { fatal: true }).decode(bytes)\n } catch {\n return undefined\n }\n return text.includes(COMPOSITE_SEPARATOR) ? undefined : text\n}\n\nexport const encodeCompositeUpload = (children: CompositeChild[]): Uint8Array => {\n let composite = ''\n for (const { name, bytes } of children) {\n const text = childAsText(bytes)\n composite +=\n text !== undefined\n ? `${COMPOSITE_SEPARATOR}${name}${COMPOSITE_SEPARATOR}${text}`\n : `${COMPOSITE_SEPARATOR}${name}${COMPOSITE_BASE64_SUFFIX}${COMPOSITE_SEPARATOR}${bytesToBase64(bytes)}`\n }\n return new TextEncoder().encode(composite)\n}\n\nconst SEPARATOR_BYTES = new TextEncoder().encode(COMPOSITE_SEPARATOR)\n\n/** True when `bytes` start with the composite separator (checked on bytes, before any text heuristics). */\nexport const isCompositeUpload = (bytes: Uint8Array): boolean =>\n bytes.length >= SEPARATOR_BYTES.length && SEPARATOR_BYTES.every((b, i) => bytes[i] === b)\n\n/** Children of a composite, or `undefined` when `bytes` are not a well-formed composite. */\nexport const decodeCompositeUpload = (bytes: Uint8Array): CompositeChild[] | undefined => {\n if (!isCompositeUpload(bytes)) return undefined\n const parts = new TextDecoder('utf-8').decode(bytes).split(COMPOSITE_SEPARATOR).slice(1)\n if (parts.length % 2 !== 0) return undefined\n const encoder = new TextEncoder()\n const children: CompositeChild[] = []\n for (let i = 0; i < parts.length; i += 2) {\n const rawName = parts[i]!\n const content = parts[i + 1]!\n if (rawName.endsWith(COMPOSITE_BASE64_SUFFIX)) {\n const decoded = base64ToBytes(content)\n if (!decoded) return undefined\n children.push({ name: rawName.slice(0, -COMPOSITE_BASE64_SUFFIX.length), bytes: decoded })\n } else {\n children.push({ name: rawName, bytes: encoder.encode(content) })\n }\n }\n return children\n}\n","import { BaseFileManager } from '@/helpers'\nimport { getItemStorageLocalFileName, getItemStorageSubdir } from '@/helpers/storageDir'\nimport { storageUploadPath } from '@/storageValue/resolve'\nimport { BaseArweaveClient } from '@seedprotocol/arweave'\nimport debug from 'debug'\nimport { buildArweaveContentTags, getContentSha256 } from '@/helpers/arweaveContentTags'\nimport type { TransactionTag } from '@seedprotocol/arweave'\nimport type { PublishUpload, PublishUploadData } from '@/types/publish'\nimport { findEmbeddedImageFilePath } from '@/helpers/htmlEmbeddedDataUriPublish'\nimport { ModelPropertyDataTypes, isDataType } from '@/helpers/property'\nimport { resolveUploadMimeType } from '@/helpers/mimeTypes'\nimport { mapWithConcurrency } from '@/helpers/mapWithConcurrency'\nimport { encodeCompositeUpload, type CompositeChild } from '@/helpers/compositeUpload'\nimport {\n getPublishGraph,\n type PublishGraph,\n type PublishGraphNode,\n type PublishGraphProperty,\n} from '@/db/read/publishGraph'\n\nconst logger = debug('seedSdk:item:getPublishUploads')\n\n/** L1 transactions {@link getPublishUploads} creates at once (each asks the gateway for price and anchor). */\nexport const CREATE_TRANSACTION_CONCURRENCY = 4\n\n/** Optional tags merged into each Arweave tx after Content-SHA-256 / Content-Type. */\nexport type GetPublishUploadsOptions = {\n arweaveUploadTags?: TransactionTag[]\n /**\n * Html storage seed local ids to skip (phase 1 of two-phase embedded-image publish).\n */\n deferHtmlStorageSeedLocalIds?: string[]\n /**\n * When set, only Html storage seeds in this list are included (phase 2). Non-Html storage uploads are omitted.\n */\n onlyHtmlStorageSeedLocalIds?: string[]\n}\n\ntype UploadTarget = Pick<\n PublishUploadData,\n 'itemPropertyName' | 'itemPropertyLocalId' | 'seedLocalId' | 'versionLocalId'\n>\n\n/**\n * One upload a publish makes, before its bytes are read: a storage seed's file, an embedded\n * image's file, or a composite of a node's ItemStorage files. Keyed by the seed whose\n * storageTransactionId attests it.\n */\nexport type PublishUploadSource = UploadTarget & {\n /** A single file (`filePath`), or a composite of ItemStorage files (`children`). */\n filePath?: string\n children?: { name: string; filePath: string }[]\n /** A saved ItemStorage edit whose file is gone: the paths tried, per property. */\n missingLocalEdits?: { name: string; tried: string[] }[]\n}\n\nconst toUint8Array = async (data: Buffer | Blob): Promise<Uint8Array> => {\n if (typeof Blob !== 'undefined' && data instanceof Blob) {\n return new Uint8Array(await data.arrayBuffer())\n }\n return new Uint8Array(data as Buffer)\n}\n\n/** A local file's bytes plus its MIME type: the Blob's own type, else the name's extension, else a sniff of the bytes. */\nconst readUploadFile = async (\n filePath: string,\n fileName: string = filePath,\n): Promise<{ bytes: Uint8Array; contentType: string | undefined }> => {\n const data = await BaseFileManager.readFileAsBuffer(filePath)\n const bytes = await toUint8Array(data)\n const sourceType = typeof Blob !== 'undefined' && data instanceof Blob ? data.type : undefined\n return { bytes, contentType: resolveUploadMimeType({ sourceType, fileName, bytes }) }\n}\n\n/**\n * The one place an upload's bytes become a {@link PublishUploadData}: everything after this\n * (Content-SHA-256, tags, the L1 transaction or the bundler DataItem, signing) works from what it\n * returns. A future private-publish option that encrypts content belongs here, before the hash and\n * tags are computed, so both publish paths pick it up.\n */\nconst buildPublishUploadData = (\n data: Uint8Array,\n contentType: string | undefined,\n target: UploadTarget,\n options: GetPublishUploadsOptions | undefined,\n): PublishUploadData => {\n const contentHash = getContentSha256(data)\n return {\n data,\n contentHash,\n contentType,\n tags: buildArweaveContentTags(contentHash, contentType, options?.arweaveUploadTags),\n ...target,\n }\n}\n\nconst isUsablePath = (filePath: string | void | null | undefined): filePath is string =>\n !!filePath && !filePath.endsWith('undefined') && !filePath.endsWith('null')\n\n/**\n * Local file of one ItemStorage property of a node. Tries, in order: its current row's\n * refResolvedValue + localStorageDir, then (for a local draft, or no row) the name saveItemStorage\n * gives a new file (`<seedUid or seedLocalId><extension>` in the model's storage directory). A\n * published or derived row is never swapped for a local file of another name: that file would be\n * older content.\n *\n * `missingLocalEdit` lists the paths tried when nothing exists although the row is a saved local\n * edit (no attestation uid, not derived from one, refResolvedValue set by saveItemStorage): that\n * edit's file should be there. A published or derived row without a file (e.g. content not\n * downloaded, or a property the composite never had) is skipped.\n */\nexport const resolveItemStorageChildFile = async (\n node: Pick<PublishGraphNode, 'seedLocalId' | 'seedUid'>,\n property: Pick<PublishGraphProperty, 'definition' | 'row'>,\n): Promise<{ filePath?: string; missingLocalEdit?: string[] }> => {\n const tried: string[] = []\n const tryPath = async (filePath: string | void | null | undefined): Promise<string | undefined> => {\n if (!isUsablePath(filePath) || tried.includes(filePath)) return undefined\n tried.push(filePath)\n return (await BaseFileManager.pathExists(filePath)) ? filePath : undefined\n }\n\n const { row, definition } = property\n const dir = getItemStorageSubdir(definition.localStorageDir || row?.localStorageDir)\n\n if (row?.refResolvedValue) {\n const fromRow = await tryPath(BaseFileManager.getFilesPath(dir, row.refResolvedValue))\n if (fromRow) return { filePath: fromRow }\n }\n\n const isLocalDraft = !!row && !row.uid && row.derivedFromUid == null\n const seedIds = !row || isLocalDraft ? [row?.seedUid, node.seedUid, row?.seedLocalId, node.seedLocalId] : []\n for (const seedId of seedIds) {\n if (!seedId) continue\n const derived = await tryPath(\n BaseFileManager.getFilesPath(dir, getItemStorageLocalFileName(seedId, definition.filenameSuffix)),\n )\n if (derived) return { filePath: derived }\n }\n\n // saveItemStorage sets refResolvedValue on the draft row once the file is written. A draft row\n // without one is the empty row createNewItem makes for every model property: nothing to upload.\n return isLocalDraft && !!row?.refResolvedValue ? { missingLocalEdit: tried } : {}\n}\n\nconst slotOf = (node: PublishGraphNode) => node.properties.find((p) => p.kind === 'storageTransaction')\n\n/** Where an upload attesting through `node`'s storageTransactionId is recorded. */\nconst slotTarget = (node: PublishGraphNode): UploadTarget => {\n const slot = slotOf(node)\n return {\n seedLocalId: node.seedLocalId,\n itemPropertyName: slot?.key ?? 'storageTransactionId',\n itemPropertyLocalId: slot?.row?.localId ?? '',\n versionLocalId: slot?.row?.versionLocalId ?? node.version.localId ?? '',\n }\n}\n\n/** A node's own files: the ItemStorage properties beside its storageTransactionId, as one composite. */\nasync function compositeSource(node: PublishGraphNode): Promise<PublishUploadSource | undefined> {\n if (!slotOf(node)) return undefined\n const children: { name: string; filePath: string }[] = []\n const missingLocalEdits: { name: string; tried: string[] }[] = []\n for (const property of node.properties) {\n if (property.kind !== 'itemStorage') continue\n const { filePath, missingLocalEdit } = await resolveItemStorageChildFile(node, property)\n if (filePath) children.push({ name: property.key, filePath })\n else if (missingLocalEdit) missingLocalEdits.push({ name: property.key, tried: missingLocalEdit })\n }\n if (children.length === 0 && missingLocalEdits.length === 0) return undefined\n return { ...slotTarget(node), children, ...(missingLocalEdits.length ? { missingLocalEdits } : {}) }\n}\n\n/** The file of a storage seed this publish attests, named by the referring property's row. */\nasync function storageSeedSource(owner: PublishGraphNode, property: PublishGraphProperty): Promise<PublishUploadSource | undefined> {\n const target = property.refs[0]?.node\n const refResolvedValue = property.row?.refResolvedValue\n if (!target || !refResolvedValue) return undefined\n const filePath = storageUploadPath({\n dataType: property.definition.refValueType ?? property.definition.dataType,\n refResolvedValue,\n localStorageDir: property.row?.localStorageDir,\n })\n if (!(await BaseFileManager.pathExists(filePath))) return undefined\n return {\n seedLocalId: target.seedLocalId,\n itemPropertyName: property.key,\n itemPropertyLocalId: property.row?.localId ?? '',\n versionLocalId: property.row?.versionLocalId ?? owner.version.localId ?? '',\n filePath,\n }\n}\n\nconst isHtmlStorageProperty = (property: PublishGraphProperty): boolean =>\n isDataType(property.definition.refValueType ?? property.definition.dataType, ModelPropertyDataTypes.Html)\n\n/**\n * Every upload a publish makes, in graph order (the root's first), one per attesting seed. The\n * options select the phases of a publish with Html-embedded images: phase 1 defers the listed Html\n * storage seeds, phase 2 uploads only those.\n */\nexport async function getPublishUploadSources(\n graph: PublishGraph,\n options?: GetPublishUploadsOptions,\n): Promise<PublishUploadSource[]> {\n const onlyHtml = options?.onlyHtmlStorageSeedLocalIds?.length ? new Set(options.onlyHtmlStorageSeedLocalIds) : undefined\n const deferHtml = new Set(options?.deferHtmlStorageSeedLocalIds ?? [])\n const sources: PublishUploadSource[] = []\n const add = (source: PublishUploadSource | undefined) => {\n if (source && !sources.some((s) => s.seedLocalId === source.seedLocalId)) sources.push(source)\n }\n\n for (const node of [graph.root, ...graph.nodes.filter((n) => n !== graph.root)]) {\n if (!onlyHtml) add(await compositeSource(node))\n if (node.kind !== 'root' && node.kind !== 'draft') continue\n for (const property of node.properties) {\n if (property.kind !== 'storageSeed' || property.deferred) continue\n const seedLocalId = property.refs[0]?.node?.seedLocalId\n if (!seedLocalId) continue\n if (isHtmlStorageProperty(property) ? deferHtml.has(seedLocalId) || (onlyHtml && !onlyHtml.has(seedLocalId)) : onlyHtml) continue\n add(await storageSeedSource(node, property))\n }\n if (onlyHtml) continue\n for (const row of node.embeddedImages) {\n const image = graph.nodes.find((n) => n.seedLocalId === row.imageSeedLocalId && n.kind === 'embeddedImage')\n const filePath = image ? await findEmbeddedImageFilePath(image.seedLocalId) : undefined\n if (image && filePath) add({ ...slotTarget(image), filePath })\n }\n }\n return sources\n}\n\n/** The bytes of one source; a missing local ItemStorage edit fails the publish. */\nasync function readSource(source: PublishUploadSource, options: GetPublishUploadsOptions | undefined): Promise<PublishUploadData> {\n const { filePath, children, missingLocalEdits, ...target } = source\n const missing = missingLocalEdits?.[0]\n if (missing) {\n // Uploading without it would publish a composite that silently lacks this edit.\n throw new Error(\n `Cannot publish ${source.seedLocalId}: the local file for ${missing.name} ` +\n `was not found (looked in ${missing.tried.join(', ')})`,\n )\n }\n if (children) {\n // Composite of the node's ItemStorage files; see helpers/compositeUpload.ts for the format.\n // Children are read as bytes: a binary child is base64-framed instead of decoded as text.\n const parts: CompositeChild[] = []\n for (const child of children) parts.push({ name: child.name, bytes: (await readUploadFile(child.filePath)).bytes })\n return buildPublishUploadData(encodeCompositeUpload(parts), 'application/octet-stream', target, options)\n }\n const { bytes, contentType } = await readUploadFile(filePath!)\n return buildPublishUploadData(bytes, contentType, target, options)\n}\n\n/** Fails like a publish would when an item's relation names a seed that isn't there. */\nfunction assertRefsResolve(graph: PublishGraph): void {\n for (const broken of graph.brokenRefs) {\n if (broken.list) continue\n throw new Error(\n broken.reason === 'invalid'\n ? `Invalid relation value for ${broken.propertyKey}: expected local seed id or 0x uid`\n : `No relatedItem found for ${broken.propertyKey}`,\n )\n }\n}\n\n/**\n * True if publish would include at least one Arweave upload (local file / storage seed present,\n * or a saved local edit whose file is missing, which the upload then reports). Reads rows and\n * file metadata only, for routing (e.g. skip the Arweave steps).\n */\nexport async function itemHasPublishUploadCandidates(item: { seedLocalId: string; modelName?: string }): Promise<boolean> {\n const graph = await getPublishGraph(item)\n assertRefsResolve(graph)\n return (await getPublishUploadSources(graph)).length > 0\n}\n\n/**\n * Upload data for a publish of `item`: its own, and that of every seed the publish attests with it\n * (see publishGraph.ts). Raw bytes plus Content-SHA-256 / Content-Type / configured tags; no\n * Arweave transaction is created, so this does not touch the network. The bundler path in\n * `@seedprotocol/publish` signs these as DataItems; {@link getPublishUploads} turns them into L1\n * transactions.\n */\nexport const getPublishUploadData = async (\n item: { seedLocalId: string; modelName?: string },\n options?: GetPublishUploadsOptions,\n): Promise<PublishUploadData[]> => {\n const graph = await getPublishGraph(item)\n assertRefsResolve(graph)\n const sources = await getPublishUploadSources(graph, options)\n logger('%d uploads for %s', sources.length, item.seedLocalId)\n const uploads: PublishUploadData[] = []\n for (const source of sources) uploads.push(await readSource(source, options))\n return uploads\n}\n\n/**\n * Arweave L1 transactions for a publish of `item`: {@link getPublishUploadData}, each made into an\n * unsigned transaction carrying the same tags.\n */\nexport const getPublishUploads = async (\n item: { seedLocalId: string; modelName?: string },\n options?: GetPublishUploadsOptions,\n): Promise<PublishUpload[]> => {\n const uploadData = await getPublishUploadData(item, options)\n // Each createTransaction fetches the price / anchor from the gateway: run a few at once.\n return mapWithConcurrency(uploadData, CREATE_TRANSACTION_CONCURRENCY, async (upload) => ({\n itemPropertyName: upload.itemPropertyName,\n itemPropertyLocalId: upload.itemPropertyLocalId,\n seedLocalId: upload.seedLocalId,\n versionLocalId: upload.versionLocalId,\n transactionToSign: await BaseArweaveClient.createTransaction(upload.data, {\n tags: upload.tags.length ? upload.tags : undefined,\n }),\n }))\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAuBO,MAAM,gCAAgC,GAAG;MACnC,6BAA6B,GAAG,CAAC,GAAG,IAAI,GAAG;MAC3C,6BAA6B,GAAG,EAAE,GAAG,IAAI,GAAG;AAEzD,MAAM,cAAc,GAAG,mDAAmD;AAE1E,MAAM,cAAc,GAA2B;AAC7C,IAAA,WAAW,EAAE,YAAY;CAC1B;AAED,SAAS,aAAa,CAAC,CAAS,EAAA;IAC9B,MAAM,KAAK,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE;AACpC,IAAA,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,KAAK;AACvC;AAEA,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IAC5B,WAAW;IACX,YAAY;IACZ,YAAY;IACZ,WAAW;IACX,eAAe;AAChB,CAAA,CAAC;AAWI,MAAO,6BAA8B,SAAQ,KAAK,CAAA;AACtD,IAAA,WAAA,CAAY,OAAe,EAAA;QACzB,KAAK,CAAC,OAAO,CAAC;AACd,QAAA,IAAI,CAAC,IAAI,GAAG,+BAA+B;IAC7C;AACD;AAEK,SAAU,yCAAyC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KACN;IAC5B,MAAM,UAAU,GAAG,MAAM,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC;;AAE5D,IAAA,OAAO,kBAAkB,CAAC,UAAU,EAAE,8BAA8B,EAAE,OAAO,MAAM,MAAM;QACvF,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;QACzC,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;QAC/C,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,iBAAiB,EAAE,MAAM,iBAAiB,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,EAAE;AACxE,YAAA,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,GAAG,SAAS;SACnD,CAAC;AACH,KAAA,CAAC,CAAC;AACL,CAAC;;;;;;;;;;;;"}
1
+ {"version":3,"file":"getPublishUploads-DivYpgNw.js","sources":["../../src/helpers/htmlEmbeddedDataUriPublish.ts","../../src/helpers/mapWithConcurrency.ts","../../src/helpers/compositeUpload.ts","../../src/db/read/getPublishUploads.ts"],"sourcesContent":["import { INTERNAL_STORAGE_MODEL_FILE_IDS } from '@/helpers/constants'\nimport { parseFragment } from 'parse5'\nimport type { DefaultTreeAdapterTypes } from 'parse5'\nimport { eq } from 'drizzle-orm'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { htmlEmbeddedImageCoPublish } from '@/seedSchema/HtmlEmbeddedImageCoPublishSchema'\nimport { BaseFileManager } from '@/helpers/FileManager/BaseFileManager'\nimport { getPublicArweaveRawUrl, normalizeRelationPropertyValue, resolveSeedIdsFromRefString } from '@seedprotocol/arweave'\nimport { getContentHash } from '@/helpers/crypto'\nimport { isValidEasAttestationUid } from '@seedprotocol/eas'\nimport { Item } from '@/Item/Item'\nimport { waitForEntityReady } from '@/helpers/entity/entityLifecycle'\nimport { ModelPropertyDataTypes, normalizeDataType, type HtmlEmbeddedDataUriPolicy } from '@/helpers/property'\nimport { findSeedRow } from '@/db/read/findSeedRow'\nimport { storageSeedTransactionId } from '@/storageValue/resolve'\nimport {\n getPublishGraph,\n publishGraphItemNodes,\n type EmbeddedImageRow,\n type PublishGraphNode,\n} from '@/db/read/publishGraph'\nimport { getExtensionForMimeType } from '@/helpers/mimeTypes'\n\nexport const HTML_EMBEDDED_MAX_IMAGES_PER_DOC = 50\nexport const HTML_EMBEDDED_MAX_IMAGE_BYTES = 5 * 1024 * 1024\nexport const HTML_EMBEDDED_MAX_TOTAL_BYTES = 25 * 1024 * 1024\n\nconst DATA_URI_IMAGE = /^data:(image\\/[a-zA-Z0-9.+-]+);base64,([\\s\\S]*)$/i\n\nconst MIME_NORMALIZE: Record<string, string> = {\n 'image/jpg': 'image/jpeg',\n}\n\nfunction normalizeMime(m: string): string {\n const lower = m.toLowerCase().trim()\n return MIME_NORMALIZE[lower] ?? lower\n}\n\nconst ALLOWED_MIMES = new Set([\n 'image/png',\n 'image/jpeg',\n 'image/webp',\n 'image/gif',\n 'image/svg+xml',\n])\n\nexport type HtmlEmbeddedExtractEntry = {\n dataUri: string\n stableKey: string\n byteLength: number\n mimeType: string\n /** The image's decoded bytes. */\n bytes: Uint8Array\n}\n\nexport class HtmlEmbeddedDataUriLimitError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'HtmlEmbeddedDataUriLimitError'\n }\n}\n\nexport function resolveEffectiveHtmlEmbeddedDataUriPolicy(\n propertyDef: { dataType?: string; htmlEmbeddedDataUriPolicy?: HtmlEmbeddedDataUriPolicy } | undefined,\n publishLevel?: HtmlEmbeddedDataUriPolicy,\n): HtmlEmbeddedDataUriPolicy {\n const fromProp = propertyDef?.htmlEmbeddedDataUriPolicy\n if (fromProp === 'materialize' || fromProp === 'preserve') return fromProp\n if (publishLevel === 'materialize' || publishLevel === 'preserve') return publishLevel\n return 'materialize'\n}\n\nfunction getAttr(node: DefaultTreeAdapterTypes.Element, name: string): string | undefined {\n const a = node.attrs?.find((x) => x.name === name)\n return a?.value\n}\n\n/**\n * Walk fragment tree; collect unique data:image base64 URIs with limits.\n */\nexport async function extractDataUriImagesFromHtml(html: string): Promise<HtmlEmbeddedExtractEntry[]> {\n const fragment = parseFragment(html)\n const found: HtmlEmbeddedExtractEntry[] = []\n const seenUris = new Set<string>()\n let totalBytes = 0\n\n const walk = async (node: DefaultTreeAdapterTypes.ChildNode): Promise<void> => {\n if (node.nodeName === '#text' || node.nodeName === '#comment') return\n const el = node as DefaultTreeAdapterTypes.Element\n if (el.tagName === 'img') {\n const src = getAttr(el, 'src')?.trim()\n if (src && src.startsWith('data:image/')) {\n const m = DATA_URI_IMAGE.exec(src)\n if (m) {\n const mimeRaw = normalizeMime(m[1]!)\n if (!ALLOWED_MIMES.has(mimeRaw)) {\n throw new HtmlEmbeddedDataUriLimitError(\n `Unsupported embedded image type: ${mimeRaw}. Allowed: ${[...ALLOWED_MIMES].join(', ')}`,\n )\n }\n let binary: Uint8Array\n try {\n const b64 = m[2]!.replace(/\\s/g, '')\n binary = Uint8Array.from(atob(b64), (c) => c.charCodeAt(0))\n } catch {\n throw new HtmlEmbeddedDataUriLimitError('Invalid base64 in embedded image data URI')\n }\n const byteLength = binary.byteLength\n if (byteLength > HTML_EMBEDDED_MAX_IMAGE_BYTES) {\n throw new HtmlEmbeddedDataUriLimitError(\n `Embedded image exceeds max size (${HTML_EMBEDDED_MAX_IMAGE_BYTES} bytes)`,\n )\n }\n totalBytes += byteLength\n if (totalBytes > HTML_EMBEDDED_MAX_TOTAL_BYTES) {\n throw new HtmlEmbeddedDataUriLimitError(\n `Total embedded image size exceeds max (${HTML_EMBEDDED_MAX_TOTAL_BYTES} bytes)`,\n )\n }\n if (!seenUris.has(src)) {\n if (seenUris.size >= HTML_EMBEDDED_MAX_IMAGES_PER_DOC) {\n throw new HtmlEmbeddedDataUriLimitError(\n `Too many distinct embedded images (max ${HTML_EMBEDDED_MAX_IMAGES_PER_DOC})`,\n )\n }\n seenUris.add(src)\n const stableKey = await getContentHash(binary)\n found.push({ dataUri: src, stableKey, byteLength, mimeType: mimeRaw, bytes: binary })\n }\n }\n }\n }\n const parent = el as DefaultTreeAdapterTypes.ParentNode\n if (parent.childNodes) {\n for (const c of parent.childNodes) await walk(c)\n }\n }\n\n for (const c of fragment.childNodes) await walk(c as DefaultTreeAdapterTypes.ChildNode)\n return found\n}\n\nfunction escapeAttributeValue(value: string): string {\n return value.replace(/&/g, '&amp;').replace(/\"/g, '&quot;')\n}\n\n/**\n * Rewrite attribute values of `html` by splicing each new value into the original string: every\n * byte other than the rewritten attributes stays as written. Re-serializing the parsed tree would\n * not round-trip (parse5 drops the newline the parser eats after `<pre>`/`<textarea>`/`<listing>`,\n * a fragment parse drops doctype/html/head/body, and quoting, case and line endings are normalized),\n * and sealed Html must not change with the serializer.\n *\n * `rewrite` gets each attribute's (entity-decoded) value and returns its new value, or undefined to\n * leave it. A rewritten attribute is written as `name=\"value\"`.\n */\nfunction rewriteHtmlAttributes(\n html: string,\n rewrite: (element: DefaultTreeAdapterTypes.Element, attrName: string, value: string) => string | undefined,\n): string {\n const fragment = parseFragment(html, { sourceCodeLocationInfo: true })\n const edits: { start: number; end: number; text: string }[] = []\n const walk = (node: DefaultTreeAdapterTypes.ChildNode): void => {\n if (node.nodeName === '#text' || node.nodeName === '#comment') return\n const el = node as DefaultTreeAdapterTypes.Element\n if (el.attrs?.length) {\n for (const attr of el.attrs) {\n if (attr.prefix) continue\n const next = rewrite(el, attr.name, attr.value)\n const location = el.sourceCodeLocation?.attrs?.[attr.name]\n if (next === undefined || !location) continue\n edits.push({\n start: location.startOffset,\n end: location.endOffset,\n text: `${attr.name}=\"${escapeAttributeValue(next)}\"`,\n })\n }\n }\n const parent = el as DefaultTreeAdapterTypes.ParentNode\n if (parent.childNodes) {\n for (const c of parent.childNodes) walk(c)\n }\n }\n for (const c of fragment.childNodes) walk(c as DefaultTreeAdapterTypes.ChildNode)\n\n let out = html\n for (const edit of edits.sort((a, b) => b.start - a.start)) {\n out = out.slice(0, edit.start) + edit.text + out.slice(edit.end)\n }\n return out\n}\n\n/**\n * Replace `data:image/...` `<img src>` values with Arweave URLs (keyed by data URI). Only those\n * `src` attributes change; the rest of the Html is kept byte for byte.\n */\nexport function replaceDataUrisInParsedHtml(\n html: string,\n replacements: Map<string, string>,\n): string {\n if (replacements.size === 0) return html\n return rewriteHtmlAttributes(html, (el, attrName, value) => {\n if (el.tagName !== 'img' || attrName !== 'src') return undefined\n return replacements.get(value.trim())\n })\n}\n\n/**\n * `seed:property/<propertyName>` in Html stands for the Arweave URL of the same item's\n * `<propertyName>` storage property (Image, File or Json). Publish uploads that property first,\n * then rewrites the placeholder to its gateway URL before the Html is uploaded, so Html can show a\n * file published alongside it without embedding it (e.g. `<img class=\"u-featured\"\n * src=\"seed:property/featureImage\">`).\n */\nexport const SEED_PROPERTY_REF_PREFIX = 'seed:property/'\nconst SEED_PROPERTY_REF = /^seed:property\\/([A-Za-z_$][A-Za-z0-9_$]*)$/\n/** Attributes whose whole (trimmed) value may be a `seed:property/` placeholder. */\nconst SEED_PROPERTY_REF_ATTRIBUTES = new Set(['src', 'href', 'poster'])\n\nconst seedPropertyRefName = (attrName: string, value: string): string | undefined =>\n SEED_PROPERTY_REF_ATTRIBUTES.has(attrName) ? SEED_PROPERTY_REF.exec(value.trim())?.[1] : undefined\n\n/** A `seed:property/` placeholder that names no usable property, or whose upload is unknown. */\nexport class HtmlSeedPropertyRefError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'HtmlSeedPropertyRefError'\n }\n}\n\n/** Property names referenced by `seed:property/<name>` placeholders in `html`, each once. */\nexport function findSeedPropertyRefsInHtml(html: string): string[] {\n if (!html.includes(SEED_PROPERTY_REF_PREFIX)) return []\n const names = new Set<string>()\n rewriteHtmlAttributes(html, (_el, attrName, value) => {\n const name = seedPropertyRefName(attrName, value)\n if (name) names.add(name)\n return undefined\n })\n return [...names]\n}\n\n/** Replace `seed:property/<name>` placeholders with `urlByPropertyName.get(name)`; other bytes are kept. */\nexport function replaceSeedPropertyRefsInHtml(html: string, urlByPropertyName: Map<string, string>): string {\n if (urlByPropertyName.size === 0) return html\n return rewriteHtmlAttributes(html, (_el, attrName, value) => {\n const name = seedPropertyRefName(attrName, value)\n return name ? urlByPropertyName.get(name) : undefined\n })\n}\n\nconst SEED_PROPERTY_REF_DATA_TYPES = [\n ModelPropertyDataTypes.Image,\n ModelPropertyDataTypes.File,\n ModelPropertyDataTypes.Json,\n] as string[]\n\n/**\n * The storage property of `node` a `seed:property/<name>` placeholder names, and the seed it holds.\n * Html properties are refused: an Html seed may itself be deferred to after the rewrite.\n */\nfunction resolveSeedPropertyRefTarget(\n node: PublishGraphNode,\n propertyName: string,\n): { seedLocalId?: string; seedUid?: string } {\n const property = node.properties.find((p) => p.key === propertyName)\n if (!property) {\n throw new HtmlSeedPropertyRefError(\n `Html references ${SEED_PROPERTY_REF_PREFIX}${propertyName}, but ${node.modelName} has no property ${propertyName}`,\n )\n }\n const def = property.definition\n const dataType = normalizeDataType(def.dataType)\n const storageType = dataType === ModelPropertyDataTypes.Relation ? normalizeDataType(def.refValueType) : dataType\n if (!SEED_PROPERTY_REF_DATA_TYPES.includes(storageType)) {\n throw new HtmlSeedPropertyRefError(\n `Html references ${SEED_PROPERTY_REF_PREFIX}${propertyName}, but ${propertyName} is ${def.dataType}; ` +\n `only Image, File and Json properties can be referenced`,\n )\n }\n const ids = resolveSeedIdsFromRefString(normalizeRelationPropertyValue(property.row?.propertyValue) ?? '')\n if (!ids.seedLocalId && !ids.seedUid) {\n throw new HtmlSeedPropertyRefError(\n `Html references ${SEED_PROPERTY_REF_PREFIX}${propertyName}, but ${propertyName} has no value`,\n )\n }\n return ids\n}\n\nconst ARWEAVE_TX_ID = /^[a-z0-9_-]{43}$/i\n\n/**\n * The Arweave tx of the storage seed a placeholder names: uploaded in this publish's phase 1, or,\n * when not uploaded now, the transaction it was published with (its storageTransactionId row).\n */\nasync function resolveSeedPropertyRefTxId(\n node: PublishGraphNode,\n propertyName: string,\n txBySeedLocalId: Map<string, string>,\n): Promise<string> {\n const target = resolveSeedPropertyRefTarget(node, propertyName)\n const uploaded = target.seedLocalId ? txBySeedLocalId.get(target.seedLocalId) : undefined\n if (uploaded) return uploaded\n\n const recorded = await storageSeedTransactionId(target)\n if (recorded && ARWEAVE_TX_ID.test(recorded)) return recorded\n\n throw new HtmlSeedPropertyRefError(\n `Html references ${SEED_PROPERTY_REF_PREFIX}${propertyName}, but ${propertyName} was not uploaded ` +\n `in this publish and has no published transaction`,\n )\n}\n\nexport type PrepareHtmlEmbeddedImagesResult = {\n /** Html storage seed local ids that must be uploaded in phase 2 (after image txs + rewrite). */\n deferredHtmlSeedLocalIds: string[]\n}\n\n/**\n * Name of the file holding an embedded image's bytes in the images folder: `<imageSeedLocalId>.<ext>`,\n * the extension following the image's MIME type (one of {@link ALLOWED_MIMES}).\n */\nexport function embeddedImageFileName(imageSeedLocalId: string, mimeType: string): string {\n return `${imageSeedLocalId}.${getExtensionForMimeType(mimeType) ?? 'bin'}`\n}\n\n/** Path of the file {@link createImageItemFromBytes} wrote for an Image seed, or undefined if there is none. */\nexport async function findEmbeddedImageFilePath(imageSeedLocalId: string): Promise<string | undefined> {\n for (const mimeType of ALLOWED_MIMES) {\n const filePath = BaseFileManager.getFilesPath('images', embeddedImageFileName(imageSeedLocalId, mimeType))\n if (await BaseFileManager.pathExists(filePath)) return filePath\n }\n return undefined\n}\n\n/**\n * Create an Image item for an embedded image and write its bytes to the images folder, where publish\n * reads them for upload ({@link findEmbeddedImageFilePath}). Its storageTransactionId stays empty\n * until the upload writes the transaction id, as for any other storage seed.\n */\nexport async function createImageItemFromBytes(\n bytes: Uint8Array,\n mimeType: string,\n): Promise<{ seedLocalId: string }> {\n const imageItem = await Item.create({\n modelName: 'Image',\n modelFileId: INTERNAL_STORAGE_MODEL_FILE_IDS.image,\n })\n await waitForEntityReady(imageItem, { timeout: 60_000 })\n const filePath = BaseFileManager.getFilesPath('images', embeddedImageFileName(imageItem.seedLocalId, mimeType))\n await BaseFileManager.createDirIfNotExists(BaseFileManager.getFilesPath('images'))\n const data = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength) as ArrayBuffer\n try {\n await BaseFileManager.saveFile(filePath, data)\n } catch {\n const fs = await BaseFileManager.getFs()\n fs.writeFileSync(filePath, bytes)\n }\n const { seedLocalId } = imageItem\n // Publish reads the image from its rows when it uploads and attests it\n imageItem.unload()\n return { seedLocalId }\n}\n\n/** The Html properties of a node with a stored Html seed and file name. */\nconst htmlValuesOf = (node: PublishGraphNode) =>\n node.properties.flatMap((property) => {\n if (normalizeDataType(property.definition.dataType) !== ModelPropertyDataTypes.Html) return []\n const htmlSeedLocalId = property.row?.propertyValue?.trim()\n const fileName = property.row?.refResolvedValue\n return htmlSeedLocalId && fileName ? [{ property, htmlSeedLocalId, filePath: `${BaseFileManager.getFilesPath('html')}/${fileName}` }] : []\n })\n\n/**\n * Scan Html storage properties, materialize embedded images as Image items, insert co-publish rows.\n * Call before phase-1 Arweave tx build. Does not rewrite Html files yet.\n */\nexport async function prepareHtmlEmbeddedImagesForPublish(\n item: { seedLocalId: string; modelName?: string },\n publishPolicy: HtmlEmbeddedDataUriPolicy | undefined,\n): Promise<PrepareHtmlEmbeddedImagesResult> {\n const appDb = BaseDb.getAppDb()\n if (!appDb) {\n return { deferredHtmlSeedLocalIds: [] }\n }\n const deferred = new Set<string>()\n // The item's own Html, and the Html of the draft items published with it: each gets its embedded\n // images materialized and co-published (rows keyed by the item owning the Html property).\n const graph = await getPublishGraph(item)\n for (const node of publishGraphItemNodes(graph)) {\n await prepareHtmlEmbeddedImagesOfNode(appDb, node, publishPolicy, deferred)\n }\n\n return { deferredHtmlSeedLocalIds: [...deferred] }\n}\n\n/**\n * An embedded image an earlier attempt materialized for this data URI that can be used again: its\n * Image seed is still a local draft and its file is there.\n */\nasync function reusableImage(row: EmbeddedImageRow | undefined): Promise<string | undefined> {\n if (!row) return undefined\n const seed = await findSeedRow({ localId: row.imageSeedLocalId })\n if (!seed || isValidEasAttestationUid(seed.uid)) return undefined\n return (await findEmbeddedImageFilePath(row.imageSeedLocalId)) ? row.imageSeedLocalId : undefined\n}\n\nasync function prepareHtmlEmbeddedImagesOfNode(\n appDb: NonNullable<ReturnType<typeof BaseDb.getAppDb>>,\n node: PublishGraphNode,\n publishPolicy: HtmlEmbeddedDataUriPolicy | undefined,\n deferred: Set<string>,\n): Promise<void> {\n // An earlier attempt's rows: their images are reused for the same Html and data URI\n const earlier = node.embeddedImages\n const kept: EmbeddedImageRow[] = []\n\n for (const { property, htmlSeedLocalId, filePath } of htmlValuesOf(node)) {\n if (!(await BaseFileManager.pathExists(filePath))) continue\n const html = await BaseFileManager.readFileAsString(filePath)\n\n // seed:property/ placeholders are filled in after phase 1 whatever the data URI policy. A\n // placeholder naming no usable property fails here, before anything is uploaded.\n const refs = findSeedPropertyRefsInHtml(html)\n for (const name of refs) resolveSeedPropertyRefTarget(node, name)\n if (refs.length > 0) deferred.add(htmlSeedLocalId)\n\n // The policy is the row's definition (a schema file's htmlEmbeddedDataUriPolicy or a code-defined one)\n const policy = resolveEffectiveHtmlEmbeddedDataUriPolicy(property.definition, publishPolicy)\n if (policy !== 'materialize') continue\n\n const extracted = await extractDataUriImagesFromHtml(html)\n if (extracted.length === 0) continue\n\n deferred.add(htmlSeedLocalId)\n\n for (const ent of extracted) {\n const previous = earlier.find((r) => r.htmlSeedLocalId.trim() === htmlSeedLocalId && r.stableKey === ent.stableKey)\n const reused = await reusableImage(previous)\n if (reused) {\n kept.push(previous!)\n continue\n }\n const { seedLocalId: imageSeedLocalId } = await createImageItemFromBytes(ent.bytes, ent.mimeType)\n if (previous) await appDb.delete(htmlEmbeddedImageCoPublish).where(eq(htmlEmbeddedImageCoPublish.id, previous.id))\n await appDb.insert(htmlEmbeddedImageCoPublish).values({\n parentSeedLocalId: node.seedLocalId,\n htmlSeedLocalId,\n imageSeedLocalId,\n stableKey: ent.stableKey,\n createdAt: Date.now(),\n }).onConflictDoNothing()\n }\n }\n\n // Rows for Html or data URIs no longer there\n for (const row of earlier) {\n if (kept.includes(row)) continue\n await appDb.delete(htmlEmbeddedImageCoPublish).where(eq(htmlEmbeddedImageCoPublish.id, row.id))\n }\n}\n\nexport type UploadedTx = { txId: string; seedLocalId?: string; versionLocalId?: string }\n\n/**\n * After phase-1 uploads, rewrite Html files on disk: data URI → Arweave gateway URL, and\n * `seed:property/<name>` → the gateway URL of that property's upload.\n *\n * `deferredHtmlSeedLocalIds` (from {@link prepareHtmlEmbeddedImagesForPublish}) limits the rewrite to\n * the Html held back from phase 1; without it, every Html of the item and its co-published drafts is\n * considered.\n */\nexport async function rewriteHtmlEmbeddedImagesOnDisk(\n parentSeedLocalId: string,\n uploadedTransactions: UploadedTx[],\n deferredHtmlSeedLocalIds?: string[],\n): Promise<void> {\n const appDb = BaseDb.getAppDb()\n if (!appDb) return\n\n const txBySeedLocalId = new Map<string, string>()\n for (const u of uploadedTransactions) {\n if (u.seedLocalId && u.txId) {\n txBySeedLocalId.set(u.seedLocalId.trim(), u.txId.trim())\n }\n }\n const deferred = deferredHtmlSeedLocalIds\n ? new Set(deferredHtmlSeedLocalIds.map((id) => id.trim()))\n : undefined\n\n // The parent's Html and that of the draft items published with it (see prepareHtmlEmbeddedImagesForPublish).\n const graph = await getPublishGraph({ seedLocalId: parentSeedLocalId })\n for (const node of publishGraphItemNodes(graph)) {\n await rewriteHtmlEmbeddedImagesOfNode(node, txBySeedLocalId, deferred)\n }\n}\n\nasync function rewriteHtmlEmbeddedImagesOfNode(\n node: PublishGraphNode,\n txBySeedLocalId: Map<string, string>,\n deferred: Set<string> | undefined,\n): Promise<void> {\n for (const { htmlSeedLocalId, filePath } of htmlValuesOf(node)) {\n if (deferred && !deferred.has(htmlSeedLocalId)) continue\n if (!(await BaseFileManager.pathExists(filePath))) continue\n\n const html = await BaseFileManager.readFileAsString(filePath)\n\n const replacements = new Map<string, string>()\n const entries = await extractDataUriImagesFromHtml(html)\n for (const r of node.embeddedImages) {\n if (r.htmlSeedLocalId.trim() !== htmlSeedLocalId) continue\n const txId = txBySeedLocalId.get(r.imageSeedLocalId.trim())\n const dataUri = entries.find((e) => e.stableKey === r.stableKey)?.dataUri\n if (txId && dataUri) replacements.set(dataUri, getPublicArweaveRawUrl(txId))\n }\n\n const urlByPropertyName = new Map<string, string>()\n for (const name of findSeedPropertyRefsInHtml(html)) {\n const txId = await resolveSeedPropertyRefTxId(node, name, txBySeedLocalId)\n urlByPropertyName.set(name, getPublicArweaveRawUrl(txId))\n }\n\n const newHtml = replaceSeedPropertyRefsInHtml(replaceDataUrisInParsedHtml(html, replacements), urlByPropertyName)\n if (newHtml === html) continue\n\n try {\n await BaseFileManager.saveFile(filePath, newHtml)\n } catch {\n const fs = await BaseFileManager.getFs()\n fs.writeFileSync(filePath, newHtml)\n }\n }\n}\n\n/**\n * Remove co-publish rows after a successful publish for this parent seed.\n */\nexport async function clearHtmlEmbeddedImageCoPublishRows(parentSeedLocalId: string): Promise<void> {\n const appDb = BaseDb.getAppDb()\n if (!appDb || !parentSeedLocalId) return\n await appDb\n .delete(htmlEmbeddedImageCoPublish)\n .where(eq(htmlEmbeddedImageCoPublish.parentSeedLocalId, parentSeedLocalId.trim()))\n}\n","/**\n * `Promise.all(items.map(fn))` with at most `limit` calls in flight. Results keep the input order.\n * Rejects with the first error (by time); after that no new calls start, though calls already in\n * flight run to completion.\n */\nexport async function mapWithConcurrency<T, R>(\n items: readonly T[],\n limit: number,\n fn: (item: T, index: number) => Promise<R>,\n): Promise<R[]> {\n const results = new Array<R>(items.length)\n const workerCount = Math.max(1, Math.min(Math.floor(limit) || 1, items.length))\n let next = 0\n let failed = false\n\n const worker = async (): Promise<void> => {\n while (!failed && next < items.length) {\n const index = next++\n try {\n results[index] = await fn(items[index]!, index)\n } catch (error) {\n failed = true\n throw error\n }\n }\n }\n\n await Promise.all(Array.from({ length: workerCount }, worker))\n return results\n}\n","/**\n * Composite uploads: several ItemStorage files of one item in a single Arweave transaction.\n *\n * Producer: `getPublishUploads.ts` (`processUploadPropertyData`), for an item with a\n * `storageTransactionId` property and ItemStorage properties (e.g. a Post's `html` and `json`).\n * Consumer: the download worker (`browser/workers/filesDownload.ts`), which keeps its own copy of\n * {@link decodeCompositeUpload} because it runs from a string; a test keeps the two in step.\n *\n * Format (unchanged for text children, so composites already on Arweave still read):\n *\n * ===FILE_SEPARATOR===<name>===FILE_SEPARATOR===<utf-8 text> (repeated per child)\n *\n * A child that is not valid UTF-8 text (or whose text contains the separator) is written as\n * base64 under the name `<name>;base64`. Composites written before this suffix existed converted\n * every child to text, which corrupted binary children; those bytes cannot be recovered.\n */\nexport const COMPOSITE_SEPARATOR = '===FILE_SEPARATOR==='\nexport const COMPOSITE_BASE64_SUFFIX = ';base64'\n\nexport type CompositeChild = { name: string; bytes: Uint8Array }\n\nconst bytesToBase64 = (bytes: Uint8Array): string => {\n let binary = ''\n const chunk = 0x8000\n for (let i = 0; i < bytes.length; i += chunk) {\n binary += String.fromCharCode(...bytes.subarray(i, i + chunk))\n }\n return btoa(binary)\n}\n\nconst base64ToBytes = (base64: string): Uint8Array | undefined => {\n try {\n const binary = atob(base64.replace(/\\s/g, ''))\n const out = new Uint8Array(binary.length)\n for (let i = 0; i < binary.length; i++) out[i] = binary.charCodeAt(i)\n return out\n } catch {\n return undefined\n }\n}\n\n/** The child's text when it can travel as text: valid UTF-8, no NUL bytes, no separator. */\nconst childAsText = (bytes: Uint8Array): string | undefined => {\n if (bytes.includes(0)) return undefined\n let text: string\n try {\n text = new TextDecoder('utf-8', { fatal: true }).decode(bytes)\n } catch {\n return undefined\n }\n return text.includes(COMPOSITE_SEPARATOR) ? undefined : text\n}\n\nexport const encodeCompositeUpload = (children: CompositeChild[]): Uint8Array => {\n let composite = ''\n for (const { name, bytes } of children) {\n const text = childAsText(bytes)\n composite +=\n text !== undefined\n ? `${COMPOSITE_SEPARATOR}${name}${COMPOSITE_SEPARATOR}${text}`\n : `${COMPOSITE_SEPARATOR}${name}${COMPOSITE_BASE64_SUFFIX}${COMPOSITE_SEPARATOR}${bytesToBase64(bytes)}`\n }\n return new TextEncoder().encode(composite)\n}\n\nconst SEPARATOR_BYTES = new TextEncoder().encode(COMPOSITE_SEPARATOR)\n\n/** True when `bytes` start with the composite separator (checked on bytes, before any text heuristics). */\nexport const isCompositeUpload = (bytes: Uint8Array): boolean =>\n bytes.length >= SEPARATOR_BYTES.length && SEPARATOR_BYTES.every((b, i) => bytes[i] === b)\n\n/** Children of a composite, or `undefined` when `bytes` are not a well-formed composite. */\nexport const decodeCompositeUpload = (bytes: Uint8Array): CompositeChild[] | undefined => {\n if (!isCompositeUpload(bytes)) return undefined\n const parts = new TextDecoder('utf-8').decode(bytes).split(COMPOSITE_SEPARATOR).slice(1)\n if (parts.length % 2 !== 0) return undefined\n const encoder = new TextEncoder()\n const children: CompositeChild[] = []\n for (let i = 0; i < parts.length; i += 2) {\n const rawName = parts[i]!\n const content = parts[i + 1]!\n if (rawName.endsWith(COMPOSITE_BASE64_SUFFIX)) {\n const decoded = base64ToBytes(content)\n if (!decoded) return undefined\n children.push({ name: rawName.slice(0, -COMPOSITE_BASE64_SUFFIX.length), bytes: decoded })\n } else {\n children.push({ name: rawName, bytes: encoder.encode(content) })\n }\n }\n return children\n}\n","import { BaseFileManager } from '@/helpers'\nimport { getItemStorageLocalFileName, getItemStorageSubdir } from '@/helpers/storageDir'\nimport { storageUploadPath } from '@/storageValue/resolve'\nimport { BaseArweaveClient } from '@seedprotocol/arweave'\nimport debug from 'debug'\nimport { buildArweaveContentTags, getContentSha256 } from '@/helpers/arweaveContentTags'\nimport type { TransactionTag } from '@seedprotocol/arweave'\nimport type { PublishUpload, PublishUploadData } from '@/types/publish'\nimport { findEmbeddedImageFilePath } from '@/helpers/htmlEmbeddedDataUriPublish'\nimport { ModelPropertyDataTypes, isDataType } from '@/helpers/property'\nimport { resolveUploadMimeType } from '@/helpers/mimeTypes'\nimport { mapWithConcurrency } from '@/helpers/mapWithConcurrency'\nimport { encodeCompositeUpload, type CompositeChild } from '@/helpers/compositeUpload'\nimport {\n getPublishGraph,\n type PublishGraph,\n type PublishGraphNode,\n type PublishGraphProperty,\n} from '@/db/read/publishGraph'\n\nconst logger = debug('seedSdk:item:getPublishUploads')\n\n/** L1 transactions {@link getPublishUploads} creates at once (each asks the gateway for price and anchor). */\nexport const CREATE_TRANSACTION_CONCURRENCY = 4\n\n/** Optional tags merged into each Arweave tx after Content-SHA-256 / Content-Type. */\nexport type GetPublishUploadsOptions = {\n arweaveUploadTags?: TransactionTag[]\n /**\n * Html storage seed local ids to skip (phase 1 of two-phase embedded-image publish).\n */\n deferHtmlStorageSeedLocalIds?: string[]\n /**\n * When set, only Html storage seeds in this list are included (phase 2). Non-Html storage uploads are omitted.\n */\n onlyHtmlStorageSeedLocalIds?: string[]\n}\n\ntype UploadTarget = Pick<\n PublishUploadData,\n 'itemPropertyName' | 'itemPropertyLocalId' | 'seedLocalId' | 'versionLocalId'\n>\n\n/**\n * One upload a publish makes, before its bytes are read: a storage seed's file, an embedded\n * image's file, or a composite of a node's ItemStorage files. Keyed by the seed whose\n * storageTransactionId attests it.\n */\nexport type PublishUploadSource = UploadTarget & {\n /** A single file (`filePath`), or a composite of ItemStorage files (`children`). */\n filePath?: string\n children?: { name: string; filePath: string }[]\n /** A saved ItemStorage edit whose file is gone: the paths tried, per property. */\n missingLocalEdits?: { name: string; tried: string[] }[]\n}\n\nconst toUint8Array = async (data: Buffer | Blob): Promise<Uint8Array> => {\n if (typeof Blob !== 'undefined' && data instanceof Blob) {\n return new Uint8Array(await data.arrayBuffer())\n }\n return new Uint8Array(data as Buffer)\n}\n\n/** A local file's bytes plus its MIME type: the Blob's own type, else the name's extension, else a sniff of the bytes. */\nconst readUploadFile = async (\n filePath: string,\n fileName: string = filePath,\n): Promise<{ bytes: Uint8Array; contentType: string | undefined }> => {\n const data = await BaseFileManager.readFileAsBuffer(filePath)\n const bytes = await toUint8Array(data)\n const sourceType = typeof Blob !== 'undefined' && data instanceof Blob ? data.type : undefined\n return { bytes, contentType: resolveUploadMimeType({ sourceType, fileName, bytes }) }\n}\n\n/**\n * The one place an upload's bytes become a {@link PublishUploadData}: everything after this\n * (Content-SHA-256, tags, the L1 transaction or the bundler DataItem, signing) works from what it\n * returns. A future private-publish option that encrypts content belongs here, before the hash and\n * tags are computed, so both publish paths pick it up.\n */\nconst buildPublishUploadData = (\n data: Uint8Array,\n contentType: string | undefined,\n target: UploadTarget,\n options: GetPublishUploadsOptions | undefined,\n): PublishUploadData => {\n const contentHash = getContentSha256(data)\n return {\n data,\n contentHash,\n contentType,\n tags: buildArweaveContentTags(contentHash, contentType, options?.arweaveUploadTags),\n ...target,\n }\n}\n\nconst isUsablePath = (filePath: string | void | null | undefined): filePath is string =>\n !!filePath && !filePath.endsWith('undefined') && !filePath.endsWith('null')\n\n/**\n * Local file of one ItemStorage property of a node. Tries, in order: its current row's\n * refResolvedValue + localStorageDir, then (for a local draft, or no row) the name saveItemStorage\n * gives a new file (`<seedUid or seedLocalId><extension>` in the model's storage directory). A\n * published or derived row is never swapped for a local file of another name: that file would be\n * older content.\n *\n * `missingLocalEdit` lists the paths tried when nothing exists although the row is a saved local\n * edit (no attestation uid, not derived from one, refResolvedValue set by saveItemStorage): that\n * edit's file should be there. A published or derived row without a file (e.g. content not\n * downloaded, or a property the composite never had) is skipped.\n */\nexport const resolveItemStorageChildFile = async (\n node: Pick<PublishGraphNode, 'seedLocalId' | 'seedUid'>,\n property: Pick<PublishGraphProperty, 'definition' | 'row'>,\n): Promise<{ filePath?: string; missingLocalEdit?: string[] }> => {\n const tried: string[] = []\n const tryPath = async (filePath: string | void | null | undefined): Promise<string | undefined> => {\n if (!isUsablePath(filePath) || tried.includes(filePath)) return undefined\n tried.push(filePath)\n return (await BaseFileManager.pathExists(filePath)) ? filePath : undefined\n }\n\n const { row, definition } = property\n const dir = getItemStorageSubdir(definition.localStorageDir || row?.localStorageDir)\n\n if (row?.refResolvedValue) {\n const fromRow = await tryPath(BaseFileManager.getFilesPath(dir, row.refResolvedValue))\n if (fromRow) return { filePath: fromRow }\n }\n\n const isLocalDraft = !!row && !row.uid && row.derivedFromUid == null\n const seedIds = !row || isLocalDraft ? [row?.seedUid, node.seedUid, row?.seedLocalId, node.seedLocalId] : []\n for (const seedId of seedIds) {\n if (!seedId) continue\n const derived = await tryPath(\n BaseFileManager.getFilesPath(dir, getItemStorageLocalFileName(seedId, definition.filenameSuffix)),\n )\n if (derived) return { filePath: derived }\n }\n\n // saveItemStorage sets refResolvedValue on the draft row once the file is written. A draft row\n // without one is the empty row createNewItem makes for every model property: nothing to upload.\n return isLocalDraft && !!row?.refResolvedValue ? { missingLocalEdit: tried } : {}\n}\n\nconst slotOf = (node: PublishGraphNode) => node.properties.find((p) => p.kind === 'storageTransaction')\n\n/** Where an upload attesting through `node`'s storageTransactionId is recorded. */\nconst slotTarget = (node: PublishGraphNode): UploadTarget => {\n const slot = slotOf(node)\n return {\n seedLocalId: node.seedLocalId,\n itemPropertyName: slot?.key ?? 'storageTransactionId',\n itemPropertyLocalId: slot?.row?.localId ?? '',\n versionLocalId: slot?.row?.versionLocalId ?? node.version.localId ?? '',\n }\n}\n\n/** A node's own files: the ItemStorage properties beside its storageTransactionId, as one composite. */\nasync function compositeSource(node: PublishGraphNode): Promise<PublishUploadSource | undefined> {\n if (!slotOf(node)) return undefined\n const children: { name: string; filePath: string }[] = []\n const missingLocalEdits: { name: string; tried: string[] }[] = []\n for (const property of node.properties) {\n if (property.kind !== 'itemStorage') continue\n const { filePath, missingLocalEdit } = await resolveItemStorageChildFile(node, property)\n if (filePath) children.push({ name: property.key, filePath })\n else if (missingLocalEdit) missingLocalEdits.push({ name: property.key, tried: missingLocalEdit })\n }\n if (children.length === 0 && missingLocalEdits.length === 0) return undefined\n return { ...slotTarget(node), children, ...(missingLocalEdits.length ? { missingLocalEdits } : {}) }\n}\n\n/** The file of a storage seed this publish attests, named by the referring property's row. */\nasync function storageSeedSource(owner: PublishGraphNode, property: PublishGraphProperty): Promise<PublishUploadSource | undefined> {\n const target = property.refs[0]?.node\n const refResolvedValue = property.row?.refResolvedValue\n if (!target || !refResolvedValue) return undefined\n const filePath = storageUploadPath({\n dataType: property.definition.refValueType ?? property.definition.dataType,\n refResolvedValue,\n localStorageDir: property.row?.localStorageDir,\n })\n if (!(await BaseFileManager.pathExists(filePath))) return undefined\n return {\n seedLocalId: target.seedLocalId,\n itemPropertyName: property.key,\n itemPropertyLocalId: property.row?.localId ?? '',\n versionLocalId: property.row?.versionLocalId ?? owner.version.localId ?? '',\n filePath,\n }\n}\n\nconst isHtmlStorageProperty = (property: PublishGraphProperty): boolean =>\n isDataType(property.definition.refValueType ?? property.definition.dataType, ModelPropertyDataTypes.Html)\n\n/**\n * Every upload a publish makes, in graph order (the root's first), one per attesting seed. The\n * options select the phases of a publish with Html-embedded images: phase 1 defers the listed Html\n * storage seeds, phase 2 uploads only those.\n */\nexport async function getPublishUploadSources(\n graph: PublishGraph,\n options?: GetPublishUploadsOptions,\n): Promise<PublishUploadSource[]> {\n const onlyHtml = options?.onlyHtmlStorageSeedLocalIds?.length ? new Set(options.onlyHtmlStorageSeedLocalIds) : undefined\n const deferHtml = new Set(options?.deferHtmlStorageSeedLocalIds ?? [])\n const sources: PublishUploadSource[] = []\n const add = (source: PublishUploadSource | undefined) => {\n if (source && !sources.some((s) => s.seedLocalId === source.seedLocalId)) sources.push(source)\n }\n\n for (const node of [graph.root, ...graph.nodes.filter((n) => n !== graph.root)]) {\n if (!onlyHtml) add(await compositeSource(node))\n if (node.kind !== 'root' && node.kind !== 'draft') continue\n for (const property of node.properties) {\n if (property.kind !== 'storageSeed' || property.deferred) continue\n const seedLocalId = property.refs[0]?.node?.seedLocalId\n if (!seedLocalId) continue\n if (isHtmlStorageProperty(property) ? deferHtml.has(seedLocalId) || (onlyHtml && !onlyHtml.has(seedLocalId)) : onlyHtml) continue\n add(await storageSeedSource(node, property))\n }\n if (onlyHtml) continue\n for (const row of node.embeddedImages) {\n const image = graph.nodes.find((n) => n.seedLocalId === row.imageSeedLocalId && n.kind === 'embeddedImage')\n const filePath = image ? await findEmbeddedImageFilePath(image.seedLocalId) : undefined\n if (image && filePath) add({ ...slotTarget(image), filePath })\n }\n }\n return sources\n}\n\n/** The bytes of one source; a missing local ItemStorage edit fails the publish. */\nasync function readSource(source: PublishUploadSource, options: GetPublishUploadsOptions | undefined): Promise<PublishUploadData> {\n const { filePath, children, missingLocalEdits, ...target } = source\n const missing = missingLocalEdits?.[0]\n if (missing) {\n // Uploading without it would publish a composite that silently lacks this edit.\n throw new Error(\n `Cannot publish ${source.seedLocalId}: the local file for ${missing.name} ` +\n `was not found (looked in ${missing.tried.join(', ')})`,\n )\n }\n if (children) {\n // Composite of the node's ItemStorage files; see helpers/compositeUpload.ts for the format.\n // Children are read as bytes: a binary child is base64-framed instead of decoded as text.\n const parts: CompositeChild[] = []\n for (const child of children) parts.push({ name: child.name, bytes: (await readUploadFile(child.filePath)).bytes })\n return buildPublishUploadData(encodeCompositeUpload(parts), 'application/octet-stream', target, options)\n }\n const { bytes, contentType } = await readUploadFile(filePath!)\n return buildPublishUploadData(bytes, contentType, target, options)\n}\n\n/** Fails like a publish would when an item's relation names a seed that isn't there. */\nfunction assertRefsResolve(graph: PublishGraph): void {\n for (const broken of graph.brokenRefs) {\n if (broken.list) continue\n throw new Error(\n broken.reason === 'invalid'\n ? `Invalid relation value for ${broken.propertyKey}: expected local seed id or 0x uid`\n : `No relatedItem found for ${broken.propertyKey}`,\n )\n }\n}\n\n/**\n * True if publish would include at least one Arweave upload (local file / storage seed present,\n * or a saved local edit whose file is missing, which the upload then reports). Reads rows and\n * file metadata only, for routing (e.g. skip the Arweave steps).\n */\nexport async function itemHasPublishUploadCandidates(item: { seedLocalId: string; modelName?: string }): Promise<boolean> {\n const graph = await getPublishGraph(item)\n assertRefsResolve(graph)\n return (await getPublishUploadSources(graph)).length > 0\n}\n\n/**\n * Upload data for a publish of `item`: its own, and that of every seed the publish attests with it\n * (see publishGraph.ts). Raw bytes plus Content-SHA-256 / Content-Type / configured tags; no\n * Arweave transaction is created, so this does not touch the network. The bundler path in\n * `@seedprotocol/publish` signs these as DataItems; {@link getPublishUploads} turns them into L1\n * transactions.\n */\nexport const getPublishUploadData = async (\n item: { seedLocalId: string; modelName?: string },\n options?: GetPublishUploadsOptions,\n): Promise<PublishUploadData[]> => {\n const graph = await getPublishGraph(item)\n assertRefsResolve(graph)\n const sources = await getPublishUploadSources(graph, options)\n logger('%d uploads for %s', sources.length, item.seedLocalId)\n const uploads: PublishUploadData[] = []\n for (const source of sources) uploads.push(await readSource(source, options))\n return uploads\n}\n\n/**\n * Arweave L1 transactions for a publish of `item`: {@link getPublishUploadData}, each made into an\n * unsigned transaction carrying the same tags.\n */\nexport const getPublishUploads = async (\n item: { seedLocalId: string; modelName?: string },\n options?: GetPublishUploadsOptions,\n): Promise<PublishUpload[]> => {\n const uploadData = await getPublishUploadData(item, options)\n // Each createTransaction fetches the price / anchor from the gateway: run a few at once.\n return mapWithConcurrency(uploadData, CREATE_TRANSACTION_CONCURRENCY, async (upload) => ({\n itemPropertyName: upload.itemPropertyName,\n itemPropertyLocalId: upload.itemPropertyLocalId,\n seedLocalId: upload.seedLocalId,\n versionLocalId: upload.versionLocalId,\n transactionToSign: await BaseArweaveClient.createTransaction(upload.data, {\n tags: upload.tags.length ? upload.tags : undefined,\n }),\n }))\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAuBO,MAAM,gCAAgC,GAAG;MACnC,6BAA6B,GAAG,CAAC,GAAG,IAAI,GAAG;MAC3C,6BAA6B,GAAG,EAAE,GAAG,IAAI,GAAG;AAEzD,MAAM,cAAc,GAAG,mDAAmD;AAE1E,MAAM,cAAc,GAA2B;AAC7C,IAAA,WAAW,EAAE,YAAY;CAC1B;AAED,SAAS,aAAa,CAAC,CAAS,EAAA;IAC9B,MAAM,KAAK,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE;AACpC,IAAA,OAAO,cAAc,CAAC,KA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D,MAAM,CAAC,mBAAmB,EAAE,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC;IAC7D,MAAM,OAAO,GAAwB,EAAE;IACvC,KAAK,MAAM,MAAM,IAAI,OAAO;QAAE,OAAO,CAAC,IAAI,CAAC,MAAM,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC7E,IAAA,OAAO,OAAO;AAChB;AAEA;;;AAGG;AACI,MAAM,iBAAiB,GAAG,OAC/B,IAAiD,EACjD,OAAkC,KACN;IAC5B,MAAM,UAAU,GAAG,MAAM,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC;;AAE5D,IAAA,OAAO,kBAAkB,CAAC,UAAU,EAAE,8BAA8B,EAAE,OAAO,MAAM,MAAM;QACvF,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;QACzC,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;QAC/C,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,iBAAiB,EAAE,MAAM,iBAAiB,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,EAAE;AACxE,YAAA,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,GAAG,SAAS;SACnD,CAAC;AACH,KAAA,CAAC,CAAC;AACL,CAAC;;;;;;;;;;;;"}
@@ -1,4 +1,4 @@
1
- import { m as metadata, a as appState, e as arweaveL1FinalizeJobs, c as config, f as easSyncProcesses, g as entityChanges, h as htmlEmbeddedImageCoPublish, i as modelRelations, j as modelSchemas, b as modelUids, d as models, k as modelsRelations, p as pendingWrites, l as properties, n as propertiesRelations, o as propertyUidRelations, q as propertyUids, r as publishProcesses, t as schemas, s as seeds, u as uploadProcesses, v as versions } from './BaseFileManager-BAlySv8w.js';
1
+ import { m as metadata, a as appState, e as arweaveL1FinalizeJobs, c as config, f as easSyncProcesses, g as entityChanges, h as htmlEmbeddedImageCoPublish, i as modelRelations, j as modelSchemas, b as modelUids, d as models, k as modelsRelations, p as pendingWrites, l as properties, n as propertiesRelations, o as propertyUidRelations, q as propertyUids, r as publishProcesses, t as schemas, s as seeds, u as uploadProcesses, v as versions } from './BaseFileManager-DLou1TZS.js';
2
2
 
3
3
  var schema = /*#__PURE__*/Object.freeze({
4
4
  __proto__: null,
@@ -27,4 +27,4 @@ var schema = /*#__PURE__*/Object.freeze({
27
27
  });
28
28
 
29
29
  export { schema as s };
30
- //# sourceMappingURL=index-D0V-mjCV.js.map
30
+ //# sourceMappingURL=index-BjWk0x4-.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BjWk0x4-.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,10 +1,10 @@
1
- import { a as appendOutboxOpAndWait, m as markPropertyConflictsResolved, g as getOutboxOps, o as outboxOpResult, w as waitForOutboxOp, b as waitForPendingOutboxOps } from './Item-Bf4kWKpH.js';
2
- export { O as OUTBOX_DEFER_MS, c as OUTBOX_MAX_ATTEMPTS, d as OUTBOX_PRUNE_AFTER_MS, e as OUTBOX_PRUNE_FAILED_AFTER_MS, f as OUTBOX_RETRY_DELAYS_MS, h as OutboxOpDeferredError, i as OutboxOpFailedError, j as OutboxOpRejectedError, k as appendOutboxOp, l as drainOutbox, n as getItemConflicts, p as getPendingSetValue, q as getPropertyConflict, r as outboxOpValue, s as pruneOutbox, t as registerOutboxApplier, u as startOutbox } from './Item-Bf4kWKpH.js';
3
- import { d as deleteFiles, s as startItemOutbox, t as throwItemWriteError } from './errors-DLSoqSHG.js';
4
- export { R as RelationTargetError, a as applyCreateItem, b as applyDelete, c as applyItemStorageValue, e as applyStorageValue } from './errors-DLSoqSHG.js';
5
- import './tabEvents-CaVmngqr.js';
1
+ import { a as appendOutboxOpAndWait, m as markPropertyConflictsResolved, g as getOutboxOps, o as outboxOpResult, w as waitForOutboxOp, b as waitForPendingOutboxOps } from './Item-oPnmIehk.js';
2
+ export { O as OUTBOX_DEFER_MS, c as OUTBOX_MAX_ATTEMPTS, d as OUTBOX_PRUNE_AFTER_MS, e as OUTBOX_PRUNE_FAILED_AFTER_MS, f as OUTBOX_RETRY_DELAYS_MS, h as OutboxOpDeferredError, i as OutboxOpFailedError, j as OutboxOpRejectedError, k as appendOutboxOp, l as drainOutbox, n as getItemConflicts, p as getPendingSetValue, q as getPropertyConflict, r as outboxOpValue, s as pruneOutbox, t as registerOutboxApplier, u as startOutbox } from './Item-oPnmIehk.js';
3
+ import { d as deleteFiles, s as startItemOutbox, t as throwItemWriteError } from './errors-CnT0fSMK.js';
4
+ export { R as RelationTargetError, a as applyCreateItem, b as applyDelete, c as applyItemStorageValue, e as applyStorageValue } from './errors-CnT0fSMK.js';
5
+ import './tabEvents-DT5ez6io.js';
6
6
  import 'debug';
7
- import './BaseFileManager-BAlySv8w.js';
7
+ import './BaseFileManager-DLou1TZS.js';
8
8
  import 'drizzle-orm/sqlite-core';
9
9
  import 'drizzle-orm';
10
10
  import 'xstate';
@@ -24,4 +24,4 @@ import '@seedprotocol/query';
24
24
 
25
25
 
26
26
  export { appendOutboxOpAndWait, deleteFiles, getOutboxOps, markPropertyConflictsResolved, outboxOpResult, startItemOutbox, throwItemWriteError, waitForOutboxOp, waitForPendingOutboxOps };
27
- //# sourceMappingURL=index-CYGWPoOx.js.map
27
+ //# sourceMappingURL=index-CZMWKXLM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-CZMWKXLM.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,14 +1,14 @@
1
- export { M as Model, T as TModelSchema, f as TModelValues } from './errors-DLSoqSHG.js';
2
- import { M as ModelPropertyDataTypes } from './tabEvents-CaVmngqr.js';
3
- export { D as DEFAULT_TEXT_MAX_LENGTH, P as Property, T as THtmlEmbeddedDataUriPolicy, a as TProperty, b as TPropertyConstructor, c as TPropertyDataType, d as TPropertyDefs, e as TStorageType, f as TValidationRules, i as isDataType, n as normalizeDataType, g as normalizePropertyRecordSchema } from './tabEvents-CaVmngqr.js';
4
- export { getModelPropertyDefinitions, getPropertySchema, resolvePropertyKey } from './property-BxUYznH0.js';
1
+ export { M as Model, T as TModelSchema, f as TModelValues } from './errors-CnT0fSMK.js';
2
+ import { M as ModelPropertyDataTypes } from './tabEvents-DT5ez6io.js';
3
+ export { D as DEFAULT_TEXT_MAX_LENGTH, P as Property, T as THtmlEmbeddedDataUriPolicy, a as TProperty, b as TPropertyConstructor, c as TPropertyDataType, d as TPropertyDefs, e as TStorageType, f as TValidationRules, i as isDataType, n as normalizeDataType, g as normalizePropertyRecordSchema } from './tabEvents-DT5ez6io.js';
4
+ export { getModelPropertyDefinitions, getPropertySchema, resolvePropertyKey } from './property-iNW1N3vm.js';
5
5
  import 'xstate';
6
- import './Item-Bf4kWKpH.js';
6
+ import './Item-oPnmIehk.js';
7
7
  import 'debug';
8
8
  import 'pluralize';
9
9
  import '@seedprotocol/eas';
10
10
  import 'drizzle-orm';
11
- import './BaseFileManager-BAlySv8w.js';
11
+ import './BaseFileManager-DLou1TZS.js';
12
12
  import 'drizzle-orm/sqlite-core';
13
13
  import 'rxjs';
14
14
  import 'lodash-es';
@@ -24,4 +24,4 @@ import '@noble/hashes/sha256';
24
24
 
25
25
 
26
26
  export { ModelPropertyDataTypes };
27
- //# sourceMappingURL=index-BVBmz_cc.js.map
27
+ //# sourceMappingURL=index-DXRhFg1N.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-DXRhFg1N.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;"}