@agimon-ai/doompi-author 0.0.1-alpha.2 → 0.0.1-alpha.21
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.
- package/README.md +5 -1
- package/dist/apiContracts.cjs +316 -0
- package/dist/apiContracts.cjs.map +1 -0
- package/dist/apiContracts.d.mts +53 -0
- package/dist/apiContracts.d.mts.map +1 -0
- package/dist/apiContracts.mjs +311 -0
- package/dist/apiContracts.mjs.map +1 -0
- package/dist/authorCommand-B90ghX5J.mjs +226 -0
- package/dist/authorCommand-B90ghX5J.mjs.map +1 -0
- package/dist/authorCommand-Cd5dnLF7.cjs +315 -0
- package/dist/authorCommand-Cd5dnLF7.cjs.map +1 -0
- package/dist/authorFacade-B9-Re3Ga.mjs +75 -0
- package/dist/authorFacade-B9-Re3Ga.mjs.map +1 -0
- package/dist/authorFacade-BvCSzZ5K.cjs +104 -0
- package/dist/authorFacade-BvCSzZ5K.cjs.map +1 -0
- package/dist/authorFacade-RZ6EXlR5.d.mts +113 -0
- package/dist/authorFacade-RZ6EXlR5.d.mts.map +1 -0
- package/dist/authorFacade.cjs +26 -0
- package/dist/authorFacade.d.mts +3 -0
- package/dist/authorFacade.mjs +3 -0
- package/dist/extensions/pi.cjs +172 -1
- package/dist/extensions/pi.cjs.map +1 -0
- package/dist/extensions/pi.d.mts +6 -2
- package/dist/extensions/pi.d.mts.map +1 -0
- package/dist/extensions/pi.mjs +167 -1
- package/dist/extensions/pi.mjs.map +1 -0
- package/dist/extensions/server.cjs +659 -0
- package/dist/extensions/server.cjs.map +1 -0
- package/dist/extensions/server.d.mts +5 -0
- package/dist/extensions/server.d.mts.map +1 -0
- package/dist/extensions/server.mjs +652 -0
- package/dist/extensions/server.mjs.map +1 -0
- package/dist/extensions/web.mjs +4231 -0
- package/dist/extensions/web.mjs.map +1 -0
- package/dist/index-Btm_xNOb.d.mts +386 -0
- package/dist/index-Btm_xNOb.d.mts.map +1 -0
- package/dist/index.cjs +35 -1
- package/dist/index.d.mts +2 -21
- package/dist/index.mjs +4 -1
- package/dist/monitor-7T5YF6px.mjs +70 -0
- package/dist/monitor-7T5YF6px.mjs.map +1 -0
- package/dist/monitor-BxY8s_AX.cjs +81 -0
- package/dist/monitor-BxY8s_AX.cjs.map +1 -0
- package/dist/structuredDocuments-Bg6DIqu5.cjs +960 -0
- package/dist/structuredDocuments-Bg6DIqu5.cjs.map +1 -0
- package/dist/structuredDocuments-CzMYD0Bq.mjs +810 -0
- package/dist/structuredDocuments-CzMYD0Bq.mjs.map +1 -0
- package/package.json +48 -38
- package/src/types/authorPreview.ts +76 -0
- package/src/types/webAuthor.ts +1 -1
- package/dist/_virtual/_rolldown/runtime.cjs +0 -1
- package/dist/adapters/authorApi.cjs +0 -2
- package/dist/adapters/authorApi.cjs.map +0 -1
- package/dist/adapters/authorBridgeApi.cjs +0 -2
- package/dist/adapters/authorBridgeApi.cjs.map +0 -1
- package/dist/adapters/authorDocumentApi.cjs +0 -2
- package/dist/adapters/authorDocumentApi.cjs.map +0 -1
- package/dist/adapters/pi/authorBridgeClient.cjs +0 -2
- package/dist/adapters/pi/authorBridgeClient.cjs.map +0 -1
- package/dist/adapters/pi/authorTools.cjs +0 -2
- package/dist/adapters/pi/authorTools.cjs.map +0 -1
- package/dist/adapters/pi/extension.cjs +0 -2
- package/dist/adapters/pi/extension.cjs.map +0 -1
- package/dist/adapters/structuredDocuments/common.cjs +0 -2
- package/dist/adapters/structuredDocuments/common.cjs.map +0 -1
- package/dist/adapters/structuredDocuments/csv.cjs +0 -7
- package/dist/adapters/structuredDocuments/csv.cjs.map +0 -1
- package/dist/adapters/structuredDocuments/index.cjs +0 -2
- package/dist/adapters/structuredDocuments/index.cjs.map +0 -1
- package/dist/adapters/structuredDocuments/markdownSlides.cjs +0 -6
- package/dist/adapters/structuredDocuments/markdownSlides.cjs.map +0 -1
- package/dist/adapters/structuredDocuments/ooxmlArchive.cjs +0 -2
- package/dist/adapters/structuredDocuments/ooxmlArchive.cjs.map +0 -1
- package/dist/adapters/structuredDocuments/pptx.cjs +0 -2
- package/dist/adapters/structuredDocuments/pptx.cjs.map +0 -1
- package/dist/adapters/structuredDocuments/xlsx.cjs +0 -2
- package/dist/adapters/structuredDocuments/xlsx.cjs.map +0 -1
- package/dist/adapters/structuredDocuments/xmlText.cjs +0 -2
- package/dist/adapters/structuredDocuments/xmlText.cjs.map +0 -1
- package/dist/adapters/webAuthorChannel.cjs +0 -2
- package/dist/adapters/webAuthorChannel.cjs.map +0 -1
- package/dist/commands/doomAuthorCommand.cjs +0 -2
- package/dist/commands/doomAuthorCommand.cjs.map +0 -1
- package/dist/container/index.cjs +0 -2
- package/dist/container/index.cjs.map +0 -1
- package/dist/extensions/pi.d.cts +0 -2
- package/dist/index.d.cts +0 -21
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/engine/helpers/union.d.cts +0 -6
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/engine/helpers/union.d.cts.map +0 -1
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/engine/helpers/union.d.mts +0 -6
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/engine/helpers/union.d.mts.map +0 -1
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/_optional.d.cts +0 -7
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/_optional.d.cts.map +0 -1
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/_optional.d.mts +0 -7
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/_optional.d.mts.map +0 -1
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/object.d.cts +0 -12
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/object.d.cts.map +0 -1
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/object.d.mts +0 -12
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/object.d.mts.map +0 -1
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/properties.d.cts +0 -12
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/properties.d.cts.map +0 -1
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/properties.d.mts +0 -12
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/properties.d.mts.map +0 -1
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/record.d.cts +0 -9
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/record.d.cts.map +0 -1
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/record.d.mts +0 -9
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/record.d.mts.map +0 -1
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/schema.d.cts +0 -4
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/schema.d.cts.map +0 -1
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/schema.d.mts +0 -4
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/schema.d.mts.map +0 -1
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/string.d.cts +0 -9
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/string.d.cts.map +0 -1
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/string.d.mts +0 -9
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/string.d.mts.map +0 -1
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/unknown.d.cts +0 -8
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/unknown.d.cts.map +0 -1
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/unknown.d.mts +0 -8
- package/dist/node_modules/.pnpm/typebox@1.3.25/node_modules/typebox/build/type/types/unknown.d.mts.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/authorApi.d.cts +0 -15
- package/dist/packages/minor/doompi-author/src/adapters/authorApi.d.cts.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/authorApi.d.mts +0 -15
- package/dist/packages/minor/doompi-author/src/adapters/authorApi.d.mts.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/authorApi.mjs +0 -2
- package/dist/packages/minor/doompi-author/src/adapters/authorApi.mjs.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/authorBridgeApi.d.cts +0 -6
- package/dist/packages/minor/doompi-author/src/adapters/authorBridgeApi.d.cts.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/authorBridgeApi.d.mts +0 -6
- package/dist/packages/minor/doompi-author/src/adapters/authorBridgeApi.d.mts.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/authorBridgeApi.mjs +0 -2
- package/dist/packages/minor/doompi-author/src/adapters/authorBridgeApi.mjs.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/authorDocumentApi.d.cts +0 -11
- package/dist/packages/minor/doompi-author/src/adapters/authorDocumentApi.d.cts.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/authorDocumentApi.d.mts +0 -11
- package/dist/packages/minor/doompi-author/src/adapters/authorDocumentApi.d.mts.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/authorDocumentApi.mjs +0 -2
- package/dist/packages/minor/doompi-author/src/adapters/authorDocumentApi.mjs.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/pi/authorBridgeClient.d.cts +0 -18
- package/dist/packages/minor/doompi-author/src/adapters/pi/authorBridgeClient.d.cts.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/pi/authorBridgeClient.d.mts +0 -18
- package/dist/packages/minor/doompi-author/src/adapters/pi/authorBridgeClient.d.mts.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/pi/authorBridgeClient.mjs +0 -2
- package/dist/packages/minor/doompi-author/src/adapters/pi/authorBridgeClient.mjs.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/pi/authorTools.d.cts +0 -9
- package/dist/packages/minor/doompi-author/src/adapters/pi/authorTools.d.cts.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/pi/authorTools.d.mts +0 -9
- package/dist/packages/minor/doompi-author/src/adapters/pi/authorTools.d.mts.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/pi/authorTools.mjs +0 -2
- package/dist/packages/minor/doompi-author/src/adapters/pi/authorTools.mjs.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/pi/extension.d.cts +0 -19
- package/dist/packages/minor/doompi-author/src/adapters/pi/extension.d.cts.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/pi/extension.d.mts +0 -19
- package/dist/packages/minor/doompi-author/src/adapters/pi/extension.d.mts.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/pi/extension.mjs +0 -2
- package/dist/packages/minor/doompi-author/src/adapters/pi/extension.mjs.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/common.mjs +0 -2
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/common.mjs.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/csv.d.cts +0 -7
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/csv.d.cts.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/csv.d.mts +0 -7
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/csv.d.mts.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/csv.mjs +0 -7
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/csv.mjs.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/index.d.cts +0 -13
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/index.d.cts.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/index.d.mts +0 -13
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/index.d.mts.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/index.mjs +0 -2
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/index.mjs.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/markdownSlides.d.cts +0 -7
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/markdownSlides.d.cts.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/markdownSlides.d.mts +0 -7
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/markdownSlides.d.mts.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/markdownSlides.mjs +0 -6
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/markdownSlides.mjs.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/ooxmlArchive.d.cts +0 -13
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/ooxmlArchive.d.cts.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/ooxmlArchive.d.mts +0 -13
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/ooxmlArchive.d.mts.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/ooxmlArchive.mjs +0 -2
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/ooxmlArchive.mjs.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/pptx.d.cts +0 -7
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/pptx.d.cts.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/pptx.d.mts +0 -7
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/pptx.d.mts.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/pptx.mjs +0 -2
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/pptx.mjs.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/xlsx.d.cts +0 -7
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/xlsx.d.cts.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/xlsx.d.mts +0 -7
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/xlsx.d.mts.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/xlsx.mjs +0 -2
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/xlsx.mjs.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/xmlText.mjs +0 -2
- package/dist/packages/minor/doompi-author/src/adapters/structuredDocuments/xmlText.mjs.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/webAuthorChannel.d.cts +0 -6
- package/dist/packages/minor/doompi-author/src/adapters/webAuthorChannel.d.cts.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/webAuthorChannel.d.mts +0 -6
- package/dist/packages/minor/doompi-author/src/adapters/webAuthorChannel.d.mts.map +0 -1
- package/dist/packages/minor/doompi-author/src/adapters/webAuthorChannel.mjs +0 -2
- package/dist/packages/minor/doompi-author/src/adapters/webAuthorChannel.mjs.map +0 -1
- package/dist/packages/minor/doompi-author/src/commands/doomAuthorCommand.mjs +0 -2
- package/dist/packages/minor/doompi-author/src/commands/doomAuthorCommand.mjs.map +0 -1
- package/dist/packages/minor/doompi-author/src/container/index.d.cts +0 -5
- package/dist/packages/minor/doompi-author/src/container/index.d.cts.map +0 -1
- package/dist/packages/minor/doompi-author/src/container/index.d.mts +0 -5
- package/dist/packages/minor/doompi-author/src/container/index.d.mts.map +0 -1
- package/dist/packages/minor/doompi-author/src/container/index.mjs +0 -2
- package/dist/packages/minor/doompi-author/src/container/index.mjs.map +0 -1
- package/dist/packages/minor/doompi-author/src/schemas/authorTools.d.cts +0 -16
- package/dist/packages/minor/doompi-author/src/schemas/authorTools.d.cts.map +0 -1
- package/dist/packages/minor/doompi-author/src/schemas/authorTools.d.mts +0 -16
- package/dist/packages/minor/doompi-author/src/schemas/authorTools.d.mts.map +0 -1
- package/dist/packages/minor/doompi-author/src/schemas/authorTools.mjs +0 -2
- package/dist/packages/minor/doompi-author/src/schemas/authorTools.mjs.map +0 -1
- package/dist/packages/minor/doompi-author/src/services/authorBridgeState.d.cts +0 -31
- package/dist/packages/minor/doompi-author/src/services/authorBridgeState.d.cts.map +0 -1
- package/dist/packages/minor/doompi-author/src/services/authorBridgeState.d.mts +0 -31
- package/dist/packages/minor/doompi-author/src/services/authorBridgeState.d.mts.map +0 -1
- package/dist/packages/minor/doompi-author/src/services/authorBridgeState.mjs +0 -2
- package/dist/packages/minor/doompi-author/src/services/authorBridgeState.mjs.map +0 -1
- package/dist/packages/minor/doompi-author/src/services/authorCatalog.d.cts +0 -10
- package/dist/packages/minor/doompi-author/src/services/authorCatalog.d.cts.map +0 -1
- package/dist/packages/minor/doompi-author/src/services/authorCatalog.d.mts +0 -10
- package/dist/packages/minor/doompi-author/src/services/authorCatalog.d.mts.map +0 -1
- package/dist/packages/minor/doompi-author/src/services/authorMode.d.cts +0 -19
- package/dist/packages/minor/doompi-author/src/services/authorMode.d.cts.map +0 -1
- package/dist/packages/minor/doompi-author/src/services/authorMode.d.mts +0 -19
- package/dist/packages/minor/doompi-author/src/services/authorMode.d.mts.map +0 -1
- package/dist/packages/minor/doompi-author/src/services/authorMode.mjs +0 -3
- package/dist/packages/minor/doompi-author/src/services/authorMode.mjs.map +0 -1
- package/dist/packages/minor/doompi-author/src/services/extensionService.d.cts +0 -7
- package/dist/packages/minor/doompi-author/src/services/extensionService.d.cts.map +0 -1
- package/dist/packages/minor/doompi-author/src/services/extensionService.d.mts +0 -7
- package/dist/packages/minor/doompi-author/src/services/extensionService.d.mts.map +0 -1
- package/dist/packages/minor/doompi-author/src/services/extensionService.mjs +0 -2
- package/dist/packages/minor/doompi-author/src/services/extensionService.mjs.map +0 -1
- package/dist/packages/minor/doompi-author/src/types/author.d.cts +0 -39
- package/dist/packages/minor/doompi-author/src/types/author.d.cts.map +0 -1
- package/dist/packages/minor/doompi-author/src/types/author.d.mts +0 -39
- package/dist/packages/minor/doompi-author/src/types/author.d.mts.map +0 -1
- package/dist/packages/minor/doompi-author/src/types/author.mjs +0 -2
- package/dist/packages/minor/doompi-author/src/types/author.mjs.map +0 -1
- package/dist/packages/minor/doompi-author/src/types/authorApi.d.cts +0 -23
- package/dist/packages/minor/doompi-author/src/types/authorApi.d.cts.map +0 -1
- package/dist/packages/minor/doompi-author/src/types/authorApi.d.mts +0 -23
- package/dist/packages/minor/doompi-author/src/types/authorApi.d.mts.map +0 -1
- package/dist/packages/minor/doompi-author/src/types/authorApi.mjs +0 -2
- package/dist/packages/minor/doompi-author/src/types/authorApi.mjs.map +0 -1
- package/dist/packages/minor/doompi-author/src/types/extension.d.cts +0 -16
- package/dist/packages/minor/doompi-author/src/types/extension.d.cts.map +0 -1
- package/dist/packages/minor/doompi-author/src/types/extension.d.mts +0 -16
- package/dist/packages/minor/doompi-author/src/types/extension.d.mts.map +0 -1
- package/dist/packages/minor/doompi-author/src/types/structuredDocuments.d.cts +0 -60
- package/dist/packages/minor/doompi-author/src/types/structuredDocuments.d.cts.map +0 -1
- package/dist/packages/minor/doompi-author/src/types/structuredDocuments.d.mts +0 -60
- package/dist/packages/minor/doompi-author/src/types/structuredDocuments.d.mts.map +0 -1
- package/dist/packages/minor/doompi-author/src/types/webAuthor.d.cts +0 -67
- package/dist/packages/minor/doompi-author/src/types/webAuthor.d.cts.map +0 -1
- package/dist/packages/minor/doompi-author/src/types/webAuthor.d.mts +0 -67
- package/dist/packages/minor/doompi-author/src/types/webAuthor.d.mts.map +0 -1
- package/dist/packages/minor/doompi-author/src/types/webAuthor.mjs +0 -2
- package/dist/packages/minor/doompi-author/src/types/webAuthor.mjs.map +0 -1
- package/dist/schemas/authorTools.cjs +0 -2
- package/dist/schemas/authorTools.cjs.map +0 -1
- package/dist/services/authorBridgeState.cjs +0 -2
- package/dist/services/authorBridgeState.cjs.map +0 -1
- package/dist/services/authorMode.cjs +0 -3
- package/dist/services/authorMode.cjs.map +0 -1
- package/dist/services/extensionService.cjs +0 -2
- package/dist/services/extensionService.cjs.map +0 -1
- package/dist/sessionApi.cjs +0 -1
- package/dist/sessionApi.d.cts +0 -7
- package/dist/sessionApi.d.mts +0 -7
- package/dist/sessionApi.mjs +0 -1
- package/dist/types/author.cjs +0 -2
- package/dist/types/author.cjs.map +0 -1
- package/dist/types/authorApi.cjs +0 -2
- package/dist/types/authorApi.cjs.map +0 -1
- package/dist/types/webAuthor.cjs +0 -2
- package/dist/types/webAuthor.cjs.map +0 -1
- package/dist/webHub.cjs +0 -1
- package/dist/webHub.d.cts +0 -2
- package/dist/webHub.d.mts +0 -2
- package/dist/webHub.mjs +0 -1
- package/src/exports/webClient.ts +0 -76
- package/src/web/api/authorBroker.ts +0 -14
- package/src/web/api/authorBrowserBridge.ts +0 -225
- package/src/web/api/authorFiles.ts +0 -219
- package/src/web/api/authorMedia.ts +0 -19
- package/src/web/api/authorRuntime.ts +0 -164
- package/src/web/components/AuthorDocumentPanel.tsx +0 -232
- package/src/web/components/AuthorGridOverlay.tsx +0 -81
- package/src/web/components/AuthorMediaPreview.tsx +0 -41
- package/src/web/components/AuthorMediaView.tsx +0 -356
- package/src/web/components/AuthorPanel.tsx +0 -105
- package/src/web/components/AuthorRegionDrafts.tsx +0 -102
- package/src/web/components/AuthorRequestLog.tsx +0 -179
- package/src/web/components/AuthorStructuredView.tsx +0 -121
- package/src/web/components/AuthorTextView.tsx +0 -97
- package/src/web/components/AuthorToolPalette.tsx +0 -103
- package/src/web/components/AuthorVideoControls.tsx +0 -111
- package/src/web/components/DescribeAuthorToolsToolCard.tsx +0 -50
- package/src/web/components/OpenAuthoringFileToolCard.tsx +0 -66
- package/src/web/components/UseAuthorToolsToolCard.tsx +0 -50
- package/src/web/index.ts +0 -68
- package/src/web/lib/authorGrid.ts +0 -124
- package/src/web/lib/authorRegions.ts +0 -30
- package/src/web/lib/authorViewportTypes.ts +0 -202
- package/src/web/lib/describeAuthorToolsToolRender.ts +0 -20
- package/src/web/lib/useAuthorToolsToolRender.ts +0 -20
- package/src/web/stores/authorCapture.ts +0 -322
- package/src/web/stores/authorGridTools.ts +0 -316
- package/src/web/stores/authorProfiles.ts +0 -130
- package/src/web/stores/authorRequestLifecycle.ts +0 -82
- package/src/web/stores/authorStore.ts +0 -60
- package/src/web/stores/authorWorkspaceStore.ts +0 -525
- package/src/web/tsconfig.json +0 -22
|
@@ -0,0 +1,960 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
//#endregion
|
|
23
|
+
let csv_parse_sync = require("csv-parse/sync");
|
|
24
|
+
let node_crypto = require("node:crypto");
|
|
25
|
+
let node_path = require("node:path");
|
|
26
|
+
node_path = __toESM(node_path, 1);
|
|
27
|
+
let saxes = require("saxes");
|
|
28
|
+
let yauzl = require("yauzl");
|
|
29
|
+
yauzl = __toESM(yauzl, 1);
|
|
30
|
+
let yazl = require("yazl");
|
|
31
|
+
yazl = __toESM(yazl, 1);
|
|
32
|
+
//#region src/models/authorBridgeState.ts
|
|
33
|
+
const AUTHOR_REQUEST_TIMEOUT_MS = 15e3;
|
|
34
|
+
const AUTHOR_OWNER_LEASE_MS = 1e4;
|
|
35
|
+
var AuthorBridgeError = class extends Error {
|
|
36
|
+
status;
|
|
37
|
+
constructor(message, status = 409) {
|
|
38
|
+
super(message);
|
|
39
|
+
this.status = status;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
function createAuthorBridgeState(options) {
|
|
43
|
+
const { now, issueToken, scheduleTimeout } = options;
|
|
44
|
+
const timeoutMs = options.requestTimeoutMs ?? 15e3;
|
|
45
|
+
const leaseMs = options.leaseMs ?? 1e4;
|
|
46
|
+
let owner;
|
|
47
|
+
let pending;
|
|
48
|
+
let delivery;
|
|
49
|
+
let deliveryWaiter;
|
|
50
|
+
const tombstones = /* @__PURE__ */ new Set();
|
|
51
|
+
const rememberCancellation = (requestId) => {
|
|
52
|
+
tombstones.add(requestId);
|
|
53
|
+
if (tombstones.size > 100) tombstones.delete(tombstones.values().next().value);
|
|
54
|
+
};
|
|
55
|
+
const publishDelivery = (value) => {
|
|
56
|
+
if (deliveryWaiter === void 0) delivery = value;
|
|
57
|
+
else {
|
|
58
|
+
const waiter = deliveryWaiter;
|
|
59
|
+
deliveryWaiter = void 0;
|
|
60
|
+
waiter.resolve(value);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const rejectPending = (reason, sendCancel) => {
|
|
64
|
+
const current = pending;
|
|
65
|
+
if (current === void 0) return;
|
|
66
|
+
pending = void 0;
|
|
67
|
+
current.cancelTimer();
|
|
68
|
+
current.removeAbort?.();
|
|
69
|
+
rememberCancellation(current.request.requestId);
|
|
70
|
+
if (sendCancel) publishDelivery({
|
|
71
|
+
...current.request,
|
|
72
|
+
kind: "cancel"
|
|
73
|
+
});
|
|
74
|
+
current.reject(new AuthorBridgeError(reason, 503));
|
|
75
|
+
};
|
|
76
|
+
const liveOwner = () => {
|
|
77
|
+
if (owner === void 0) throw new AuthorBridgeError("No Author viewport is registered.", 503);
|
|
78
|
+
if (owner.expiresAt <= now()) {
|
|
79
|
+
rejectPending("The Author viewport lease expired.", false);
|
|
80
|
+
owner = void 0;
|
|
81
|
+
throw new AuthorBridgeError("The Author viewport lease expired.", 503);
|
|
82
|
+
}
|
|
83
|
+
return owner;
|
|
84
|
+
};
|
|
85
|
+
const assertOwner = (bindingId, generation, ownerToken) => {
|
|
86
|
+
const current = liveOwner();
|
|
87
|
+
if (current.bindingId !== bindingId || current.generation !== generation || current.ownerToken !== ownerToken) throw new AuthorBridgeError("Stale Author viewport binding.");
|
|
88
|
+
return current;
|
|
89
|
+
};
|
|
90
|
+
const assertRequest = (bindingId, generation, ownerToken, catalogToken, requestId) => {
|
|
91
|
+
if (assertOwner(bindingId, generation, ownerToken).catalogToken !== catalogToken) throw new AuthorBridgeError("Stale Author catalog token.");
|
|
92
|
+
if (tombstones.has(requestId)) throw new AuthorBridgeError("The Author request was already cancelled.");
|
|
93
|
+
if (pending?.request.requestId !== requestId) throw new AuthorBridgeError("Stale Author request.");
|
|
94
|
+
return pending;
|
|
95
|
+
};
|
|
96
|
+
return {
|
|
97
|
+
register(bindingId, generation) {
|
|
98
|
+
if (bindingId === "" || !Number.isSafeInteger(generation) || generation < 0) throw new AuthorBridgeError("Invalid Author registration.", 400);
|
|
99
|
+
if (owner !== void 0 && owner.expiresAt > now()) {
|
|
100
|
+
if (owner.bindingId !== bindingId) throw new AuthorBridgeError("Another Author viewport owns the lease.");
|
|
101
|
+
if (generation < owner.generation) throw new AuthorBridgeError("Stale Author generation.");
|
|
102
|
+
if (generation === owner.generation) {
|
|
103
|
+
owner.expiresAt = now() + leaseMs;
|
|
104
|
+
return {
|
|
105
|
+
kind: "accepted",
|
|
106
|
+
generation,
|
|
107
|
+
ownerToken: owner.ownerToken,
|
|
108
|
+
...owner.catalogToken === void 0 ? {} : { catalogToken: owner.catalogToken },
|
|
109
|
+
leaseMs
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
rejectPending("The Author viewport generation changed.", false);
|
|
114
|
+
delivery = void 0;
|
|
115
|
+
const current = {
|
|
116
|
+
bindingId,
|
|
117
|
+
generation,
|
|
118
|
+
ownerToken: issueToken(),
|
|
119
|
+
expiresAt: now() + leaseMs,
|
|
120
|
+
tools: []
|
|
121
|
+
};
|
|
122
|
+
owner = current;
|
|
123
|
+
return {
|
|
124
|
+
kind: "accepted",
|
|
125
|
+
generation,
|
|
126
|
+
ownerToken: current.ownerToken,
|
|
127
|
+
leaseMs
|
|
128
|
+
};
|
|
129
|
+
},
|
|
130
|
+
catalog(bindingId, generation, ownerToken, tools) {
|
|
131
|
+
const current = assertOwner(bindingId, generation, ownerToken);
|
|
132
|
+
if (!Array.isArray(tools) || tools.length > 15) throw new AuthorBridgeError("Invalid Author catalog.", 400);
|
|
133
|
+
const names = /* @__PURE__ */ new Set();
|
|
134
|
+
for (const tool of tools) {
|
|
135
|
+
if (typeof tool !== "object" || tool === null || typeof tool.name !== "string" || !/^[a-z][a-z0-9_]{0,29}$/.test(tool.name) || typeof tool.label !== "string" || typeof tool.description !== "string" || typeof tool.inputSchema !== "object" || tool.inputSchema === null || Array.isArray(tool.inputSchema) || names.has(tool.name)) throw new AuthorBridgeError("Invalid Author catalog.", 400);
|
|
136
|
+
names.add(tool.name);
|
|
137
|
+
}
|
|
138
|
+
if (pending !== void 0) throw new AuthorBridgeError("Cannot replace the Author catalog during a request.");
|
|
139
|
+
current.tools = tools.map((tool) => ({
|
|
140
|
+
...tool,
|
|
141
|
+
inputSchema: { ...tool.inputSchema }
|
|
142
|
+
}));
|
|
143
|
+
current.catalogToken = issueToken();
|
|
144
|
+
current.expiresAt = now() + leaseMs;
|
|
145
|
+
return {
|
|
146
|
+
kind: "accepted",
|
|
147
|
+
generation,
|
|
148
|
+
ownerToken,
|
|
149
|
+
catalogToken: current.catalogToken,
|
|
150
|
+
leaseMs
|
|
151
|
+
};
|
|
152
|
+
},
|
|
153
|
+
describe() {
|
|
154
|
+
const current = liveOwner();
|
|
155
|
+
if (current.catalogToken === void 0) throw new AuthorBridgeError("The Author viewport has no catalog.", 503);
|
|
156
|
+
return {
|
|
157
|
+
catalogToken: current.catalogToken,
|
|
158
|
+
tools: current.tools
|
|
159
|
+
};
|
|
160
|
+
},
|
|
161
|
+
invoke(input, signal) {
|
|
162
|
+
let current;
|
|
163
|
+
try {
|
|
164
|
+
current = liveOwner();
|
|
165
|
+
if (current.catalogToken !== input.catalogToken) throw new AuthorBridgeError("The Author capability catalog changed.");
|
|
166
|
+
if (!current.tools.some((tool) => tool.name === input.name)) throw new AuthorBridgeError(`Unknown Author capability: ${input.name}`, 404);
|
|
167
|
+
if (pending !== void 0) throw new AuthorBridgeError("Another Author request is already pending.");
|
|
168
|
+
if (signal?.aborted) throw signal.reason instanceof Error ? signal.reason : /* @__PURE__ */ new Error("Author request cancelled.");
|
|
169
|
+
} catch (error) {
|
|
170
|
+
return Promise.reject(error);
|
|
171
|
+
}
|
|
172
|
+
const request = {
|
|
173
|
+
kind: "request",
|
|
174
|
+
generation: current.generation,
|
|
175
|
+
ownerToken: current.ownerToken,
|
|
176
|
+
catalogToken: current.catalogToken,
|
|
177
|
+
requestId: issueToken(),
|
|
178
|
+
name: input.name,
|
|
179
|
+
arguments: input.arguments
|
|
180
|
+
};
|
|
181
|
+
return new Promise((resolve, reject) => {
|
|
182
|
+
const cancel = (reason) => rejectPending(reason, true);
|
|
183
|
+
const cancelTimer = scheduleTimeout(() => cancel("The Author request timed out."), Math.min(timeoutMs, current.expiresAt - now()));
|
|
184
|
+
pending = {
|
|
185
|
+
request,
|
|
186
|
+
resolve,
|
|
187
|
+
reject,
|
|
188
|
+
cancelTimer
|
|
189
|
+
};
|
|
190
|
+
if (signal !== void 0) {
|
|
191
|
+
const onAbort = () => cancel("The Author request was cancelled.");
|
|
192
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
193
|
+
pending.removeAbort = () => signal.removeEventListener("abort", onAbort);
|
|
194
|
+
}
|
|
195
|
+
publishDelivery(request);
|
|
196
|
+
});
|
|
197
|
+
},
|
|
198
|
+
async next(bindingId, generation, ownerToken, signal) {
|
|
199
|
+
assertOwner(bindingId, generation, ownerToken);
|
|
200
|
+
if (delivery !== void 0) {
|
|
201
|
+
const value = delivery;
|
|
202
|
+
delivery = void 0;
|
|
203
|
+
return value;
|
|
204
|
+
}
|
|
205
|
+
if (deliveryWaiter !== void 0) throw new AuthorBridgeError("An Author delivery poll is already active.");
|
|
206
|
+
return await new Promise((resolve, reject) => {
|
|
207
|
+
let waiter;
|
|
208
|
+
const onAbort = () => {
|
|
209
|
+
if (deliveryWaiter === waiter) deliveryWaiter = void 0;
|
|
210
|
+
reject(signal?.reason ?? /* @__PURE__ */ new Error("Author delivery poll cancelled."));
|
|
211
|
+
};
|
|
212
|
+
waiter = {
|
|
213
|
+
resolve(value) {
|
|
214
|
+
signal?.removeEventListener("abort", onAbort);
|
|
215
|
+
resolve(value);
|
|
216
|
+
},
|
|
217
|
+
reject
|
|
218
|
+
};
|
|
219
|
+
deliveryWaiter = waiter;
|
|
220
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
221
|
+
});
|
|
222
|
+
},
|
|
223
|
+
result(bindingId, generation, ownerToken, catalogToken, requestId, result) {
|
|
224
|
+
const current = assertRequest(bindingId, generation, ownerToken, catalogToken, requestId);
|
|
225
|
+
pending = void 0;
|
|
226
|
+
current.cancelTimer();
|
|
227
|
+
current.removeAbort?.();
|
|
228
|
+
current.resolve({
|
|
229
|
+
catalogToken,
|
|
230
|
+
name: current.request.name,
|
|
231
|
+
result
|
|
232
|
+
});
|
|
233
|
+
},
|
|
234
|
+
cancelled(bindingId, generation, ownerToken, catalogToken, requestId) {
|
|
235
|
+
const current = assertRequest(bindingId, generation, ownerToken, catalogToken, requestId);
|
|
236
|
+
pending = void 0;
|
|
237
|
+
current.cancelTimer();
|
|
238
|
+
current.removeAbort?.();
|
|
239
|
+
rememberCancellation(requestId);
|
|
240
|
+
current.reject(new AuthorBridgeError("The Author viewport cancelled the request."));
|
|
241
|
+
},
|
|
242
|
+
disconnect(bindingId, generation) {
|
|
243
|
+
if (owner?.bindingId !== bindingId || owner.generation !== generation) return;
|
|
244
|
+
rejectPending("The Author viewport disconnected.", false);
|
|
245
|
+
owner = void 0;
|
|
246
|
+
delivery = void 0;
|
|
247
|
+
},
|
|
248
|
+
close() {
|
|
249
|
+
rejectPending("The Author bridge closed.", false);
|
|
250
|
+
owner = void 0;
|
|
251
|
+
delivery = void 0;
|
|
252
|
+
deliveryWaiter?.reject(/* @__PURE__ */ new Error("The Author bridge closed."));
|
|
253
|
+
deliveryWaiter = void 0;
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
function digestOf(value) {
|
|
258
|
+
return (0, node_crypto.createHash)("sha256").update(value).digest("hex");
|
|
259
|
+
}
|
|
260
|
+
function parsedDocument(format, bytes, fragments, metadata = {}) {
|
|
261
|
+
return {
|
|
262
|
+
manifest: {
|
|
263
|
+
format,
|
|
264
|
+
sourceDigest: digestOf(bytes),
|
|
265
|
+
byteLength: bytes.byteLength,
|
|
266
|
+
fragmentCount: fragments.length,
|
|
267
|
+
metadata
|
|
268
|
+
},
|
|
269
|
+
fragments,
|
|
270
|
+
renderModel: renderModel(format, fragments)
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
function renderModel(format, fragments) {
|
|
274
|
+
return {
|
|
275
|
+
format,
|
|
276
|
+
blocks: fragments.map(({ id, text, readOnly }) => ({
|
|
277
|
+
id,
|
|
278
|
+
text,
|
|
279
|
+
readOnly: readOnly === true
|
|
280
|
+
}))
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
function preflight(document, operations, validate, binding) {
|
|
284
|
+
const fragments = new Map(document.fragments.map((fragment) => [fragment.id, fragment]));
|
|
285
|
+
const seen = /* @__PURE__ */ new Set();
|
|
286
|
+
const issues = [];
|
|
287
|
+
const log = [];
|
|
288
|
+
let replacementBytes = 0;
|
|
289
|
+
for (const operation of operations) {
|
|
290
|
+
const fragment = fragments.get(operation.fragmentId);
|
|
291
|
+
if (!fragment) {
|
|
292
|
+
issues.push({
|
|
293
|
+
code: "unknown-fragment",
|
|
294
|
+
message: "The operation names an unknown fragment.",
|
|
295
|
+
fragmentId: operation.fragmentId
|
|
296
|
+
});
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
if (seen.has(operation.fragmentId)) {
|
|
300
|
+
issues.push({
|
|
301
|
+
code: "duplicate-operation",
|
|
302
|
+
message: "A fragment may be replaced only once.",
|
|
303
|
+
fragmentId: operation.fragmentId
|
|
304
|
+
});
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
seen.add(operation.fragmentId);
|
|
308
|
+
const operationBytes = new TextEncoder().encode(operation.replacement).byteLength;
|
|
309
|
+
replacementBytes += operationBytes;
|
|
310
|
+
if (operationBytes > 10485760 || replacementBytes > 104857600) {
|
|
311
|
+
issues.push({
|
|
312
|
+
code: "replacement-limit",
|
|
313
|
+
message: "Replacement content exceeds the document mutation limits.",
|
|
314
|
+
fragmentId: operation.fragmentId
|
|
315
|
+
});
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
if (fragment.readOnly === true) {
|
|
319
|
+
issues.push({
|
|
320
|
+
code: "read-only",
|
|
321
|
+
message: "The fragment is read-only.",
|
|
322
|
+
fragmentId: operation.fragmentId
|
|
323
|
+
});
|
|
324
|
+
continue;
|
|
325
|
+
}
|
|
326
|
+
const issue = validate?.(operation, fragment);
|
|
327
|
+
if (issue) issues.push(issue);
|
|
328
|
+
else log.push({
|
|
329
|
+
...operation,
|
|
330
|
+
previous: fragment.text
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
const digest = digestOf(JSON.stringify({
|
|
334
|
+
format: document.manifest.format,
|
|
335
|
+
binding,
|
|
336
|
+
sourceDigest: document.manifest.sourceDigest,
|
|
337
|
+
operations: log,
|
|
338
|
+
issues
|
|
339
|
+
}));
|
|
340
|
+
return {
|
|
341
|
+
accepted: issues.length === 0,
|
|
342
|
+
digest,
|
|
343
|
+
sourceDigest: document.manifest.sourceDigest,
|
|
344
|
+
operations: log,
|
|
345
|
+
issues
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
function requireAccepted(report, expectedDigest) {
|
|
349
|
+
if (!report.accepted || report.digest !== expectedDigest) throw new Error("An accepted, current preflight report digest is required.");
|
|
350
|
+
}
|
|
351
|
+
function decodeUtf8(bytes) {
|
|
352
|
+
const text = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
353
|
+
if (text.includes("\0")) throw new Error("NUL bytes are not supported.");
|
|
354
|
+
return text;
|
|
355
|
+
}
|
|
356
|
+
//#endregion
|
|
357
|
+
//#region src/services/structuredDocuments/csv.ts
|
|
358
|
+
const FORMULA_TRIGGER = /^\s*[=+\-@]/;
|
|
359
|
+
const MAX_CELLS = 1e6;
|
|
360
|
+
function detectDialect(text) {
|
|
361
|
+
const recordDelimiter = text.includes("\r\n") ? "\r\n" : "\n";
|
|
362
|
+
const firstRecord = text.split(/\r?\n/, 1)[0] ?? "";
|
|
363
|
+
return {
|
|
364
|
+
delimiter: [
|
|
365
|
+
",",
|
|
366
|
+
";",
|
|
367
|
+
" ",
|
|
368
|
+
"|"
|
|
369
|
+
].reduce((best, candidate) => firstRecord.split(candidate).length > firstRecord.split(best).length ? candidate : best),
|
|
370
|
+
quote: "\"",
|
|
371
|
+
recordDelimiter
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
function normalizeDialect(text, requestedDialect) {
|
|
375
|
+
if (requestedDialect !== void 0 && (typeof requestedDialect !== "object" || requestedDialect === null || Array.isArray(requestedDialect))) throw new Error("CSV dialect must be an object.");
|
|
376
|
+
const dialect = {
|
|
377
|
+
...detectDialect(text),
|
|
378
|
+
...requestedDialect
|
|
379
|
+
};
|
|
380
|
+
if (![
|
|
381
|
+
",",
|
|
382
|
+
";",
|
|
383
|
+
" ",
|
|
384
|
+
"|"
|
|
385
|
+
].includes(dialect.delimiter)) throw new Error("Invalid CSV delimiter.");
|
|
386
|
+
if (!["\"", "'"].includes(dialect.quote)) throw new Error("Invalid CSV quote.");
|
|
387
|
+
if (!["\n", "\r\n"].includes(dialect.recordDelimiter)) throw new Error("Invalid CSV record delimiter.");
|
|
388
|
+
return dialect;
|
|
389
|
+
}
|
|
390
|
+
function parseCsv(source, requestedDialect) {
|
|
391
|
+
const bytes = typeof source === "string" ? new TextEncoder().encode(source) : source;
|
|
392
|
+
if (bytes.byteLength > 26214400) throw new Error("CSV input exceeds the size limit.");
|
|
393
|
+
const text = decodeUtf8(bytes);
|
|
394
|
+
const dialect = normalizeDialect(text, requestedDialect);
|
|
395
|
+
const records = (0, csv_parse_sync.parse)(text, {
|
|
396
|
+
bom: true,
|
|
397
|
+
delimiter: dialect.delimiter,
|
|
398
|
+
quote: dialect.quote,
|
|
399
|
+
record_delimiter: [dialect.recordDelimiter],
|
|
400
|
+
relax_column_count: false,
|
|
401
|
+
skip_empty_lines: false
|
|
402
|
+
});
|
|
403
|
+
if (records.reduce((total, row) => total + row.length, 0) > MAX_CELLS) throw new Error("CSV input has too many cells.");
|
|
404
|
+
return parsedDocument("csv", bytes, records.flatMap((row, rowIndex) => row.map((text, columnIndex) => {
|
|
405
|
+
if (FORMULA_TRIGGER.test(text)) throw new Error(`CSV formula trigger rejected at row ${rowIndex + 1}.`);
|
|
406
|
+
return {
|
|
407
|
+
id: `cell:${rowIndex + 1}:${columnIndex + 1}`,
|
|
408
|
+
kind: "cell",
|
|
409
|
+
text,
|
|
410
|
+
location: `row ${rowIndex + 1}, column ${columnIndex + 1}`
|
|
411
|
+
};
|
|
412
|
+
})), {
|
|
413
|
+
rows: records.length,
|
|
414
|
+
columns: records.reduce((maximum, row) => Math.max(maximum, row.length), 0),
|
|
415
|
+
delimiter: dialect.delimiter,
|
|
416
|
+
quote: dialect.quote,
|
|
417
|
+
recordDelimiter: dialect.recordDelimiter
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
function preflightCsv(source, operations, dialect) {
|
|
421
|
+
const bytes = typeof source === "string" ? new TextEncoder().encode(source) : source;
|
|
422
|
+
const normalizedDialect = normalizeDialect(decodeUtf8(bytes), dialect);
|
|
423
|
+
return preflight(parseCsv(bytes, normalizedDialect), operations, (operation) => FORMULA_TRIGGER.test(operation.replacement) ? {
|
|
424
|
+
code: "formula-trigger",
|
|
425
|
+
message: "CSV values may not begin with a formula trigger.",
|
|
426
|
+
fragmentId: operation.fragmentId
|
|
427
|
+
} : void 0, { dialect: normalizedDialect });
|
|
428
|
+
}
|
|
429
|
+
function encodeCell(value, dialect) {
|
|
430
|
+
const escaped = value.replaceAll(dialect.quote, dialect.quote + dialect.quote);
|
|
431
|
+
return value.includes(dialect.delimiter) || value.includes(dialect.quote) || /[\r\n]/.test(value) ? `${dialect.quote}${escaped}${dialect.quote}` : escaped;
|
|
432
|
+
}
|
|
433
|
+
function serializeCsv(source, operations, acceptedReportDigest, requestedDialect) {
|
|
434
|
+
const dialect = normalizeDialect(typeof source === "string" ? source : decodeUtf8(source), requestedDialect);
|
|
435
|
+
const document = parseCsv(source, dialect);
|
|
436
|
+
const report = preflightCsv(source, operations, dialect);
|
|
437
|
+
requireAccepted(report, acceptedReportDigest);
|
|
438
|
+
const replacements = new Map(report.operations.map((operation) => [operation.fragmentId, operation.replacement]));
|
|
439
|
+
const fragments = new Map(document.fragments.map((fragment) => [fragment.id, fragment]));
|
|
440
|
+
const rows = Number(document.manifest.metadata.rows);
|
|
441
|
+
const columns = Number(document.manifest.metadata.columns);
|
|
442
|
+
const outputRows = [];
|
|
443
|
+
for (let row = 1; row <= rows; row += 1) {
|
|
444
|
+
const values = [];
|
|
445
|
+
for (let column = 1; column <= columns; column += 1) {
|
|
446
|
+
const id = `cell:${row}:${column}`;
|
|
447
|
+
const fragment = fragments.get(id);
|
|
448
|
+
if (fragment) values.push(encodeCell(replacements.get(id) ?? fragment.text, dialect));
|
|
449
|
+
}
|
|
450
|
+
outputRows.push(values.join(dialect.delimiter));
|
|
451
|
+
}
|
|
452
|
+
const bytes = new TextEncoder().encode(outputRows.join(dialect.recordDelimiter));
|
|
453
|
+
return {
|
|
454
|
+
bytes,
|
|
455
|
+
operationLog: report.operations,
|
|
456
|
+
manifest: parseCsv(bytes, dialect).manifest
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
//#endregion
|
|
460
|
+
//#region src/services/structuredDocuments/markdownSlides.ts
|
|
461
|
+
const SLIDE_SEPARATOR = /^(?:---|\*\*\*)[ \t]*$/m;
|
|
462
|
+
const MAX_SLIDES = 1e3;
|
|
463
|
+
function parseMarkdownSlides(source) {
|
|
464
|
+
const bytes = typeof source === "string" ? new TextEncoder().encode(source) : source;
|
|
465
|
+
if (bytes.byteLength > 26214400) throw new Error("Markdown input exceeds the size limit.");
|
|
466
|
+
const slides = decodeUtf8(bytes).split(SLIDE_SEPARATOR);
|
|
467
|
+
if (slides.length > MAX_SLIDES) throw new Error("Markdown input has too many slides.");
|
|
468
|
+
const fragments = slides.map((slide, index) => ({
|
|
469
|
+
id: `slide:${index + 1}`,
|
|
470
|
+
kind: "slide",
|
|
471
|
+
text: slide.replace(/^\r?\n+|\r?\n+$/g, ""),
|
|
472
|
+
location: `slide ${index + 1}`
|
|
473
|
+
}));
|
|
474
|
+
return parsedDocument("markdown-slides", bytes, fragments, { slideCount: fragments.length });
|
|
475
|
+
}
|
|
476
|
+
function preflightMarkdownSlides(source, operations) {
|
|
477
|
+
return preflight(parseMarkdownSlides(source), operations);
|
|
478
|
+
}
|
|
479
|
+
function serializeMarkdownSlides(source, operations, acceptedReportDigest) {
|
|
480
|
+
const document = parseMarkdownSlides(source);
|
|
481
|
+
const report = preflight(document, operations);
|
|
482
|
+
requireAccepted(report, acceptedReportDigest);
|
|
483
|
+
const replacements = new Map(report.operations.map((operation) => [operation.fragmentId, operation.replacement]));
|
|
484
|
+
const output = document.fragments.map((fragment) => replacements.get(fragment.id) ?? fragment.text).join("\n\n---\n\n");
|
|
485
|
+
const bytes = new TextEncoder().encode(output);
|
|
486
|
+
return {
|
|
487
|
+
bytes,
|
|
488
|
+
operationLog: report.operations,
|
|
489
|
+
manifest: parseMarkdownSlides(bytes).manifest
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
//#endregion
|
|
493
|
+
//#region src/services/structuredDocuments/ooxmlArchive.ts
|
|
494
|
+
function normalizedEntryName(name) {
|
|
495
|
+
const slashName = name.replaceAll("\\", "/");
|
|
496
|
+
if (slashName.startsWith("/") || /^[A-Za-z]:/.test(slashName)) throw new Error("Absolute archive entry path rejected.");
|
|
497
|
+
const normalized = node_path.default.posix.normalize(slashName);
|
|
498
|
+
if (normalized === ".." || normalized.startsWith("..") || normalized.includes("/../")) throw new Error("Archive path traversal rejected.");
|
|
499
|
+
return normalized.replace(/^\.\//, "");
|
|
500
|
+
}
|
|
501
|
+
function openArchive(bytes) {
|
|
502
|
+
return new Promise((resolve, reject) => {
|
|
503
|
+
yauzl.default.fromBuffer(bytes, {
|
|
504
|
+
lazyEntries: true,
|
|
505
|
+
decodeStrings: true,
|
|
506
|
+
validateEntrySizes: true
|
|
507
|
+
}, (error, zipFile) => {
|
|
508
|
+
if (error || !zipFile) reject(error ?? /* @__PURE__ */ new Error("Malformed ZIP archive."));
|
|
509
|
+
else resolve(zipFile);
|
|
510
|
+
});
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
function readEntry(zipFile, entry) {
|
|
514
|
+
return new Promise((resolve, reject) => {
|
|
515
|
+
zipFile.openReadStream(entry, (error, stream) => {
|
|
516
|
+
if (error || !stream) {
|
|
517
|
+
reject(error ?? /* @__PURE__ */ new Error("Could not read archive entry."));
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
const chunks = [];
|
|
521
|
+
stream.on("data", (chunk) => chunks.push(chunk));
|
|
522
|
+
stream.once("error", reject);
|
|
523
|
+
stream.once("end", () => resolve(Buffer.concat(chunks)));
|
|
524
|
+
});
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
function validateXml(name, data) {
|
|
528
|
+
if (data.byteLength > 10485760) throw new Error(`XML entry exceeds its size limit: ${name}`);
|
|
529
|
+
const xml = new TextDecoder("utf-8", { fatal: true }).decode(data);
|
|
530
|
+
const withoutDeclaration = xml.replace(/^\uFEFF?\s*<\?xml\s[^?]*\?>/i, "");
|
|
531
|
+
if (/<!DOCTYPE|<!ENTITY|<\?/i.test(withoutDeclaration)) throw new Error(`Unsafe XML construct rejected: ${name}`);
|
|
532
|
+
const parser = new saxes.SaxesParser({ xmlns: true });
|
|
533
|
+
let parseError;
|
|
534
|
+
parser.on("error", (error) => {
|
|
535
|
+
parseError = error;
|
|
536
|
+
});
|
|
537
|
+
parser.write(xml).close();
|
|
538
|
+
if (parseError) throw new Error(`Malformed XML entry: ${name}`);
|
|
539
|
+
if (/TargetMode\s*=\s*["']External["']/i.test(xml)) throw new Error("External OOXML relationship rejected.");
|
|
540
|
+
if (/<(?:\w+:)?(?:workbookProtection|sheetProtection|documentProtection|modifyVerifier)\b/i.test(xml)) throw new Error("Protected OOXML content rejected.");
|
|
541
|
+
}
|
|
542
|
+
async function readOoxmlArchive(source) {
|
|
543
|
+
if (source.byteLength > 26214400) throw new Error("OOXML archive exceeds the compressed size limit.");
|
|
544
|
+
const zipFile = await openArchive(Buffer.from(source));
|
|
545
|
+
return await new Promise((resolve, reject) => {
|
|
546
|
+
const entries = [];
|
|
547
|
+
const names = /* @__PURE__ */ new Set();
|
|
548
|
+
let expanded = 0;
|
|
549
|
+
const fail = (error) => {
|
|
550
|
+
zipFile.close();
|
|
551
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
552
|
+
};
|
|
553
|
+
zipFile.once("error", fail);
|
|
554
|
+
zipFile.on("entry", (entry) => {
|
|
555
|
+
(async () => {
|
|
556
|
+
if (entries.length >= 4096) throw new Error("OOXML archive has too many entries.");
|
|
557
|
+
if ((entry.generalPurposeBitFlag & 1) !== 0) throw new Error("Encrypted OOXML archive rejected.");
|
|
558
|
+
if ((entry.externalFileAttributes >>> 16 & 61440) === 40960) throw new Error("Archive symlink rejected.");
|
|
559
|
+
if (entry.compressionMethod !== 0 && entry.compressionMethod !== 8) throw new Error("Unsupported ZIP compression method.");
|
|
560
|
+
const name = normalizedEntryName(entry.fileName);
|
|
561
|
+
if (!name || names.has(name)) throw new Error("Duplicate normalized archive entry rejected.");
|
|
562
|
+
names.add(name);
|
|
563
|
+
expanded += entry.uncompressedSize;
|
|
564
|
+
if (expanded > 104857600) throw new Error("OOXML archive exceeds the expanded size limit.");
|
|
565
|
+
if (entry.uncompressedSize > Math.max(1, entry.compressedSize) * 100) throw new Error("OOXML archive compression ratio exceeds the limit.");
|
|
566
|
+
const lower = name.toLowerCase();
|
|
567
|
+
if (lower === "encryptedpackage" || lower === "encryptioninfo" || lower.includes("vbaproject") || lower.includes("_xmlsignatures") || lower.endsWith(".bin")) throw new Error("Encrypted, signed, or macro-enabled OOXML content rejected.");
|
|
568
|
+
const data = name.endsWith("/") ? Buffer.alloc(0) : await readEntry(zipFile, entry);
|
|
569
|
+
if (/\.xml$|\.rels$/i.test(name)) validateXml(name, data);
|
|
570
|
+
entries.push({
|
|
571
|
+
name,
|
|
572
|
+
data,
|
|
573
|
+
compressionMethod: entry.compressionMethod
|
|
574
|
+
});
|
|
575
|
+
zipFile.readEntry();
|
|
576
|
+
})().catch(fail);
|
|
577
|
+
});
|
|
578
|
+
zipFile.once("end", () => {
|
|
579
|
+
if (!names.has("[Content_Types].xml")) {
|
|
580
|
+
fail(/* @__PURE__ */ new Error("Unsupported OOXML archive: missing content types."));
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
resolve({
|
|
584
|
+
entries,
|
|
585
|
+
byName: new Map(entries.map((entry) => [entry.name, entry]))
|
|
586
|
+
});
|
|
587
|
+
});
|
|
588
|
+
zipFile.readEntry();
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
function assertOoxmlKind(archive, kind) {
|
|
592
|
+
const contentTypes = archive.byName.get("[Content_Types].xml")?.data.toString("utf8") ?? "";
|
|
593
|
+
const required = kind === "pptx" ? "presentationml.presentation.main+xml" : "spreadsheetml.sheet.main+xml";
|
|
594
|
+
if (!contentTypes.includes(required)) throw new Error(`Unsupported OOXML archive: not a ${kind.toUpperCase()} document.`);
|
|
595
|
+
if (/macroEnabled|vnd\.ms-office\.vbaProject/i.test(contentTypes)) throw new Error("Macro-enabled OOXML content rejected.");
|
|
596
|
+
}
|
|
597
|
+
async function writeOoxmlArchive(archive, replacements) {
|
|
598
|
+
const zipFile = new yazl.default.ZipFile();
|
|
599
|
+
const chunks = [];
|
|
600
|
+
const output = new Promise((resolve, reject) => {
|
|
601
|
+
zipFile.outputStream.on("data", (chunk) => chunks.push(chunk));
|
|
602
|
+
zipFile.outputStream.once("error", reject);
|
|
603
|
+
zipFile.outputStream.once("end", () => resolve(Buffer.concat(chunks)));
|
|
604
|
+
});
|
|
605
|
+
for (const entry of archive.entries) if (entry.name.endsWith("/")) zipFile.addEmptyDirectory(entry.name);
|
|
606
|
+
else zipFile.addBuffer(replacements.get(entry.name) ?? entry.data, entry.name, { compress: entry.compressionMethod === 8 });
|
|
607
|
+
zipFile.end();
|
|
608
|
+
return await output;
|
|
609
|
+
}
|
|
610
|
+
//#endregion
|
|
611
|
+
//#region src/services/structuredDocuments/xmlText.ts
|
|
612
|
+
function decodeXmlText(value) {
|
|
613
|
+
return value.replaceAll("<", "<").replaceAll(">", ">").replaceAll(""", "\"").replaceAll("'", "'").replaceAll("&", "&");
|
|
614
|
+
}
|
|
615
|
+
function encodeXmlText(value) {
|
|
616
|
+
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
617
|
+
}
|
|
618
|
+
function replaceRange(source, start, end, replacement) {
|
|
619
|
+
return source.slice(0, start) + replacement + source.slice(end);
|
|
620
|
+
}
|
|
621
|
+
//#endregion
|
|
622
|
+
//#region src/services/structuredDocuments/pptx.ts
|
|
623
|
+
async function stateOf$1(source) {
|
|
624
|
+
const archive = await readOoxmlArchive(source);
|
|
625
|
+
assertOoxmlKind(archive, "pptx");
|
|
626
|
+
const fragments = [];
|
|
627
|
+
const ranges = /* @__PURE__ */ new Map();
|
|
628
|
+
const slideEntries = archive.entries.filter((entry) => /^ppt\/slides\/slide\d+\.xml$/i.test(entry.name)).sort((left, right) => left.name.localeCompare(right.name, void 0, { numeric: true }));
|
|
629
|
+
for (const entry of slideEntries) {
|
|
630
|
+
const paragraphs = entry.data.toString("utf8").matchAll(/<a:p(?:\s[^>]*)?>([\s\S]*?)<\/a:p>/g);
|
|
631
|
+
let runIndex = 0;
|
|
632
|
+
for (const paragraph of paragraphs) {
|
|
633
|
+
const body = paragraph[1] ?? "";
|
|
634
|
+
const runCount = (body.match(/<a:r(?:\s[^>]*)?>/g) ?? []).length;
|
|
635
|
+
const textCount = (body.match(/<a:t(?:\s[^>]*)?>/g) ?? []).length;
|
|
636
|
+
if (textCount === 0) continue;
|
|
637
|
+
if (runCount !== 1 || textCount !== 1) throw new Error("Unsupported PPTX paragraph with multiple text styles.");
|
|
638
|
+
const textMatch = /<a:t(?:\s[^>]*)?>([\s\S]*?)<\/a:t>/.exec(body);
|
|
639
|
+
if (!textMatch) throw new Error("Malformed PPTX text run.");
|
|
640
|
+
runIndex += 1;
|
|
641
|
+
const id = `${entry.name}#text:${runIndex}`;
|
|
642
|
+
const paragraphStart = paragraph.index ?? 0;
|
|
643
|
+
const bodyOffset = paragraph[0].indexOf(body);
|
|
644
|
+
const textOffset = body.indexOf(textMatch[1] ?? "", textMatch.index);
|
|
645
|
+
const start = paragraphStart + bodyOffset + textOffset;
|
|
646
|
+
const end = start + (textMatch[1]?.length ?? 0);
|
|
647
|
+
fragments.push({
|
|
648
|
+
id,
|
|
649
|
+
kind: "text-run",
|
|
650
|
+
text: decodeXmlText(textMatch[1] ?? ""),
|
|
651
|
+
location: entry.name
|
|
652
|
+
});
|
|
653
|
+
ranges.set(id, {
|
|
654
|
+
entry: entry.name,
|
|
655
|
+
start,
|
|
656
|
+
end
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
return {
|
|
661
|
+
archive,
|
|
662
|
+
document: parsedDocument("pptx", source, fragments, { slides: slideEntries.length }),
|
|
663
|
+
ranges
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
async function parsePptx(source) {
|
|
667
|
+
return (await stateOf$1(source)).document;
|
|
668
|
+
}
|
|
669
|
+
async function preflightPptx(source, operations) {
|
|
670
|
+
return preflight((await stateOf$1(source)).document, operations);
|
|
671
|
+
}
|
|
672
|
+
async function serializePptx(source, operations, acceptedReportDigest) {
|
|
673
|
+
const state = await stateOf$1(source);
|
|
674
|
+
const report = preflight(state.document, operations);
|
|
675
|
+
requireAccepted(report, acceptedReportDigest);
|
|
676
|
+
const byEntry = /* @__PURE__ */ new Map();
|
|
677
|
+
for (const operation of report.operations) {
|
|
678
|
+
const range = state.ranges.get(operation.fragmentId);
|
|
679
|
+
if (!range) throw new Error("PPTX text run changed during serialization.");
|
|
680
|
+
const list = byEntry.get(range.entry) ?? [];
|
|
681
|
+
list.push({
|
|
682
|
+
start: range.start,
|
|
683
|
+
end: range.end,
|
|
684
|
+
replacement: encodeXmlText(operation.replacement)
|
|
685
|
+
});
|
|
686
|
+
byEntry.set(range.entry, list);
|
|
687
|
+
}
|
|
688
|
+
const replacements = /* @__PURE__ */ new Map();
|
|
689
|
+
for (const [entryName, edits] of byEntry) {
|
|
690
|
+
let xml = state.archive.byName.get(entryName)?.data.toString("utf8") ?? "";
|
|
691
|
+
for (const edit of edits.sort((left, right) => right.start - left.start)) xml = replaceRange(xml, edit.start, edit.end, edit.replacement);
|
|
692
|
+
replacements.set(entryName, Buffer.from(xml));
|
|
693
|
+
}
|
|
694
|
+
const bytes = await writeOoxmlArchive(state.archive, replacements);
|
|
695
|
+
return {
|
|
696
|
+
bytes,
|
|
697
|
+
operationLog: report.operations,
|
|
698
|
+
manifest: (await parsePptx(bytes)).manifest
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
//#endregion
|
|
702
|
+
//#region src/services/structuredDocuments/xlsx.ts
|
|
703
|
+
function textNodes(xml) {
|
|
704
|
+
return [...xml.matchAll(/<(?:\w+:)?t(?:\s[^>]*)?>([\s\S]*?)<\/(?:\w+:)?t>/g)].map((match) => decodeXmlText(match[1] ?? "")).join("");
|
|
705
|
+
}
|
|
706
|
+
function sharedStrings(archive) {
|
|
707
|
+
const xml = archive.byName.get("xl/sharedStrings.xml")?.data.toString("utf8");
|
|
708
|
+
if (!xml) return [];
|
|
709
|
+
return [...xml.matchAll(/<si(?:\s[^>]*)?>([\s\S]*?)<\/si>/g)].map((match) => {
|
|
710
|
+
const body = match[1] ?? "";
|
|
711
|
+
return {
|
|
712
|
+
text: textNodes(body),
|
|
713
|
+
multiRun: [...body.matchAll(/<(?:\w+:)?r(?:\s[^>]*)?>/g)].length > 1
|
|
714
|
+
};
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
function attribute(attributes, name) {
|
|
718
|
+
return new RegExp(`\\s${name}=["']([^"']*)["']`).exec(attributes)?.[1];
|
|
719
|
+
}
|
|
720
|
+
async function stateOf(source) {
|
|
721
|
+
const archive = await readOoxmlArchive(source);
|
|
722
|
+
assertOoxmlKind(archive, "xlsx");
|
|
723
|
+
const shared = sharedStrings(archive);
|
|
724
|
+
const fragments = [];
|
|
725
|
+
const ranges = /* @__PURE__ */ new Map();
|
|
726
|
+
const worksheets = archive.entries.filter((entry) => /^xl\/worksheets\/sheet\d+\.xml$/i.test(entry.name)).sort((left, right) => left.name.localeCompare(right.name, void 0, { numeric: true }));
|
|
727
|
+
for (const entry of worksheets) {
|
|
728
|
+
const xml = entry.data.toString("utf8");
|
|
729
|
+
for (const match of xml.matchAll(/<c(\s[^>]*)>([\s\S]*?)<\/c>/g)) {
|
|
730
|
+
const attributes = match[1] ?? "";
|
|
731
|
+
const body = match[2] ?? "";
|
|
732
|
+
const reference = attribute(attributes, "r");
|
|
733
|
+
if (!reference) continue;
|
|
734
|
+
const type = attribute(attributes, "t");
|
|
735
|
+
const formula = /<f(?:\s[^>]*)?>[\s\S]*?<\/f>|<f\s*\/>/.test(body);
|
|
736
|
+
const value = /<v(?:\s[^>]*)?>([\s\S]*?)<\/v>/.exec(body)?.[1] ?? "";
|
|
737
|
+
let text;
|
|
738
|
+
let multiRun = false;
|
|
739
|
+
if (type === "s") {
|
|
740
|
+
const index = Number(value);
|
|
741
|
+
const sharedString = shared[index];
|
|
742
|
+
if (!Number.isInteger(index) || sharedString === void 0) throw new Error(`Malformed shared string cell: ${reference}`);
|
|
743
|
+
text = sharedString.text;
|
|
744
|
+
multiRun = sharedString.multiRun;
|
|
745
|
+
} else if (type === "inlineStr") {
|
|
746
|
+
text = textNodes(body);
|
|
747
|
+
multiRun = [...body.matchAll(/<(?:\w+:)?r(?:\s[^>]*)?>/g)].length > 1;
|
|
748
|
+
} else text = decodeXmlText(value);
|
|
749
|
+
const id = `${entry.name}#cell:${reference}`;
|
|
750
|
+
fragments.push({
|
|
751
|
+
id,
|
|
752
|
+
kind: "cell",
|
|
753
|
+
text,
|
|
754
|
+
readOnly: formula || multiRun,
|
|
755
|
+
location: `${entry.name}!${reference}`
|
|
756
|
+
});
|
|
757
|
+
ranges.set(id, {
|
|
758
|
+
entry: entry.name,
|
|
759
|
+
start: match.index,
|
|
760
|
+
end: match.index + match[0].length,
|
|
761
|
+
attributes
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
return {
|
|
766
|
+
archive,
|
|
767
|
+
document: parsedDocument("xlsx", source, fragments, { worksheets: worksheets.length }),
|
|
768
|
+
ranges
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
async function parseXlsx(source) {
|
|
772
|
+
return (await stateOf(source)).document;
|
|
773
|
+
}
|
|
774
|
+
async function preflightXlsx(source, operations) {
|
|
775
|
+
return preflight((await stateOf(source)).document, operations, (operation) => /^\s*=/.test(operation.replacement) ? {
|
|
776
|
+
code: "formula-input",
|
|
777
|
+
message: "Formula input is not accepted.",
|
|
778
|
+
fragmentId: operation.fragmentId
|
|
779
|
+
} : void 0);
|
|
780
|
+
}
|
|
781
|
+
async function serializeXlsx(source, operations, acceptedReportDigest) {
|
|
782
|
+
const state = await stateOf(source);
|
|
783
|
+
const report = await preflightXlsx(source, operations);
|
|
784
|
+
requireAccepted(report, acceptedReportDigest);
|
|
785
|
+
const byEntry = /* @__PURE__ */ new Map();
|
|
786
|
+
for (const operation of report.operations) {
|
|
787
|
+
const range = state.ranges.get(operation.fragmentId);
|
|
788
|
+
if (!range) throw new Error("XLSX cell changed during serialization.");
|
|
789
|
+
const list = byEntry.get(range.entry) ?? [];
|
|
790
|
+
list.push({
|
|
791
|
+
...range,
|
|
792
|
+
replacement: operation.replacement
|
|
793
|
+
});
|
|
794
|
+
byEntry.set(range.entry, list);
|
|
795
|
+
}
|
|
796
|
+
const replacements = /* @__PURE__ */ new Map();
|
|
797
|
+
for (const [entryName, edits] of byEntry) {
|
|
798
|
+
let xml = state.archive.byName.get(entryName)?.data.toString("utf8") ?? "";
|
|
799
|
+
for (const edit of edits.sort((left, right) => right.start - left.start)) {
|
|
800
|
+
const cell = `<c${edit.attributes.replace(/\st=["'][^"']*["']/, "") + " t=\"inlineStr\""}><is><t>${encodeXmlText(edit.replacement)}</t></is></c>`;
|
|
801
|
+
xml = replaceRange(xml, edit.start, edit.end, cell);
|
|
802
|
+
}
|
|
803
|
+
replacements.set(entryName, Buffer.from(xml));
|
|
804
|
+
}
|
|
805
|
+
const bytes = await writeOoxmlArchive(state.archive, replacements);
|
|
806
|
+
return {
|
|
807
|
+
bytes,
|
|
808
|
+
operationLog: report.operations,
|
|
809
|
+
manifest: (await parseXlsx(bytes)).manifest
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
//#endregion
|
|
813
|
+
//#region src/services/structuredDocuments/index.ts
|
|
814
|
+
async function parseStructuredDocument(format, bytes, csvDialect) {
|
|
815
|
+
if (format === "markdown-slides") return parseMarkdownSlides(bytes);
|
|
816
|
+
if (format === "csv") return parseCsv(bytes, csvDialect);
|
|
817
|
+
if (format === "pptx") return await parsePptx(bytes);
|
|
818
|
+
return await parseXlsx(bytes);
|
|
819
|
+
}
|
|
820
|
+
async function preflightStructuredDocument(format, bytes, operations, csvDialect) {
|
|
821
|
+
if (format === "markdown-slides") return preflightMarkdownSlides(bytes, operations);
|
|
822
|
+
if (format === "csv") return preflightCsv(bytes, operations, csvDialect);
|
|
823
|
+
if (format === "pptx") return await preflightPptx(bytes, operations);
|
|
824
|
+
return await preflightXlsx(bytes, operations);
|
|
825
|
+
}
|
|
826
|
+
async function serializeStructuredDocument(format, bytes, operations, acceptedReportDigest, csvDialect) {
|
|
827
|
+
if (format === "markdown-slides") return serializeMarkdownSlides(bytes, operations, acceptedReportDigest);
|
|
828
|
+
if (format === "csv") return serializeCsv(bytes, operations, acceptedReportDigest, csvDialect);
|
|
829
|
+
if (format === "pptx") return await serializePptx(bytes, operations, acceptedReportDigest);
|
|
830
|
+
return await serializeXlsx(bytes, operations, acceptedReportDigest);
|
|
831
|
+
}
|
|
832
|
+
//#endregion
|
|
833
|
+
Object.defineProperty(exports, "AUTHOR_OWNER_LEASE_MS", {
|
|
834
|
+
enumerable: true,
|
|
835
|
+
get: function() {
|
|
836
|
+
return AUTHOR_OWNER_LEASE_MS;
|
|
837
|
+
}
|
|
838
|
+
});
|
|
839
|
+
Object.defineProperty(exports, "AUTHOR_REQUEST_TIMEOUT_MS", {
|
|
840
|
+
enumerable: true,
|
|
841
|
+
get: function() {
|
|
842
|
+
return AUTHOR_REQUEST_TIMEOUT_MS;
|
|
843
|
+
}
|
|
844
|
+
});
|
|
845
|
+
Object.defineProperty(exports, "AuthorBridgeError", {
|
|
846
|
+
enumerable: true,
|
|
847
|
+
get: function() {
|
|
848
|
+
return AuthorBridgeError;
|
|
849
|
+
}
|
|
850
|
+
});
|
|
851
|
+
Object.defineProperty(exports, "__toESM", {
|
|
852
|
+
enumerable: true,
|
|
853
|
+
get: function() {
|
|
854
|
+
return __toESM;
|
|
855
|
+
}
|
|
856
|
+
});
|
|
857
|
+
Object.defineProperty(exports, "createAuthorBridgeState", {
|
|
858
|
+
enumerable: true,
|
|
859
|
+
get: function() {
|
|
860
|
+
return createAuthorBridgeState;
|
|
861
|
+
}
|
|
862
|
+
});
|
|
863
|
+
Object.defineProperty(exports, "parseCsv", {
|
|
864
|
+
enumerable: true,
|
|
865
|
+
get: function() {
|
|
866
|
+
return parseCsv;
|
|
867
|
+
}
|
|
868
|
+
});
|
|
869
|
+
Object.defineProperty(exports, "parseMarkdownSlides", {
|
|
870
|
+
enumerable: true,
|
|
871
|
+
get: function() {
|
|
872
|
+
return parseMarkdownSlides;
|
|
873
|
+
}
|
|
874
|
+
});
|
|
875
|
+
Object.defineProperty(exports, "parsePptx", {
|
|
876
|
+
enumerable: true,
|
|
877
|
+
get: function() {
|
|
878
|
+
return parsePptx;
|
|
879
|
+
}
|
|
880
|
+
});
|
|
881
|
+
Object.defineProperty(exports, "parseStructuredDocument", {
|
|
882
|
+
enumerable: true,
|
|
883
|
+
get: function() {
|
|
884
|
+
return parseStructuredDocument;
|
|
885
|
+
}
|
|
886
|
+
});
|
|
887
|
+
Object.defineProperty(exports, "parseXlsx", {
|
|
888
|
+
enumerable: true,
|
|
889
|
+
get: function() {
|
|
890
|
+
return parseXlsx;
|
|
891
|
+
}
|
|
892
|
+
});
|
|
893
|
+
Object.defineProperty(exports, "preflightCsv", {
|
|
894
|
+
enumerable: true,
|
|
895
|
+
get: function() {
|
|
896
|
+
return preflightCsv;
|
|
897
|
+
}
|
|
898
|
+
});
|
|
899
|
+
Object.defineProperty(exports, "preflightMarkdownSlides", {
|
|
900
|
+
enumerable: true,
|
|
901
|
+
get: function() {
|
|
902
|
+
return preflightMarkdownSlides;
|
|
903
|
+
}
|
|
904
|
+
});
|
|
905
|
+
Object.defineProperty(exports, "preflightPptx", {
|
|
906
|
+
enumerable: true,
|
|
907
|
+
get: function() {
|
|
908
|
+
return preflightPptx;
|
|
909
|
+
}
|
|
910
|
+
});
|
|
911
|
+
Object.defineProperty(exports, "preflightStructuredDocument", {
|
|
912
|
+
enumerable: true,
|
|
913
|
+
get: function() {
|
|
914
|
+
return preflightStructuredDocument;
|
|
915
|
+
}
|
|
916
|
+
});
|
|
917
|
+
Object.defineProperty(exports, "preflightXlsx", {
|
|
918
|
+
enumerable: true,
|
|
919
|
+
get: function() {
|
|
920
|
+
return preflightXlsx;
|
|
921
|
+
}
|
|
922
|
+
});
|
|
923
|
+
Object.defineProperty(exports, "readOoxmlArchive", {
|
|
924
|
+
enumerable: true,
|
|
925
|
+
get: function() {
|
|
926
|
+
return readOoxmlArchive;
|
|
927
|
+
}
|
|
928
|
+
});
|
|
929
|
+
Object.defineProperty(exports, "serializeCsv", {
|
|
930
|
+
enumerable: true,
|
|
931
|
+
get: function() {
|
|
932
|
+
return serializeCsv;
|
|
933
|
+
}
|
|
934
|
+
});
|
|
935
|
+
Object.defineProperty(exports, "serializeMarkdownSlides", {
|
|
936
|
+
enumerable: true,
|
|
937
|
+
get: function() {
|
|
938
|
+
return serializeMarkdownSlides;
|
|
939
|
+
}
|
|
940
|
+
});
|
|
941
|
+
Object.defineProperty(exports, "serializePptx", {
|
|
942
|
+
enumerable: true,
|
|
943
|
+
get: function() {
|
|
944
|
+
return serializePptx;
|
|
945
|
+
}
|
|
946
|
+
});
|
|
947
|
+
Object.defineProperty(exports, "serializeStructuredDocument", {
|
|
948
|
+
enumerable: true,
|
|
949
|
+
get: function() {
|
|
950
|
+
return serializeStructuredDocument;
|
|
951
|
+
}
|
|
952
|
+
});
|
|
953
|
+
Object.defineProperty(exports, "serializeXlsx", {
|
|
954
|
+
enumerable: true,
|
|
955
|
+
get: function() {
|
|
956
|
+
return serializeXlsx;
|
|
957
|
+
}
|
|
958
|
+
});
|
|
959
|
+
|
|
960
|
+
//# sourceMappingURL=structuredDocuments-Bg6DIqu5.cjs.map
|