@ryanyahya/opendoc 0.4.0
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/.agents/skills/opendoc-apply-comments/SKILL.md +30 -0
- package/.agents/skills/opendoc-apply-comments/agents/openai.yaml +4 -0
- package/.agents/skills/opendoc-create/SKILL.md +63 -0
- package/.agents/skills/opendoc-create/agents/openai.yaml +6 -0
- package/.agents/skills/opendoc-create-template/SKILL.md +50 -0
- package/.agents/skills/opendoc-create-template/agents/openai.yaml +4 -0
- package/.agents/skills/opendoc-create-template/references/structured-reports.md +11 -0
- package/.agents/skills/opendoc-create-theme/SKILL.md +40 -0
- package/.agents/skills/opendoc-create-theme/agents/openai.yaml +4 -0
- package/.agents/skills/opendoc-current-document/SKILL.md +32 -0
- package/.agents/skills/opendoc-current-document/agents/openai.yaml +4 -0
- package/.agents/skills/opendoc-current-document/references/context-fields.md +20 -0
- package/.agents/skills/opendoc-review-document/SKILL.md +60 -0
- package/.agents/skills/opendoc-review-document/agents/openai.yaml +4 -0
- package/AGENTS.md +69 -0
- package/CONTRIBUTING.md +38 -0
- package/LICENSE +21 -0
- package/README.md +179 -0
- package/SECURITY.md +9 -0
- package/THIRD_PARTY.md +49 -0
- package/VALIDATION.md +99 -0
- package/bin/opendoc.mjs +6 -0
- package/dist/assets/Markdown-sNZyjJi7.js +29 -0
- package/dist/assets/OpenDocSerif-Regular-D3OXs9A9.ttf +0 -0
- package/dist/assets/OpenDocSerif-Semibold-CjL9oDRo.ttf +0 -0
- package/dist/assets/geist-latin-ext-wght-italic-XgKbg5n7.woff2 +0 -0
- package/dist/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/dist/assets/geist-latin-wght-italic-dTnRTFFJ.woff2 +0 -0
- package/dist/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/dist/assets/index-DdrZ6ozO.css +1 -0
- package/dist/assets/index-DgNBz7mL.js +39 -0
- package/dist/assets/pdf-B7Emtyld.js +54 -0
- package/dist/assets/pdf.worker.min-Dswkl-cV.mjs +29 -0
- package/dist/assets/wordmark-DsqLlZpb.png +0 -0
- package/dist/index.html +17 -0
- package/docs/APPEARANCE.md +21 -0
- package/docs/ASSETS.md +176 -0
- package/docs/AUTHORING.md +178 -0
- package/docs/HEADLESS.md +120 -0
- package/docs/MEDIA.md +112 -0
- package/docs/PROJECTS.md +55 -0
- package/docs/PROSE.md +15 -0
- package/docs/SELECTION.md +59 -0
- package/docs/TEMPLATES.md +55 -0
- package/docs/THEMES.md +106 -0
- package/node_modules/@formepdf/core/LICENSE +21 -0
- package/node_modules/@formepdf/core/README.md +53 -0
- package/node_modules/@formepdf/core/dist/attachments.d.ts +55 -0
- package/node_modules/@formepdf/core/dist/attachments.js +59 -0
- package/node_modules/@formepdf/core/dist/extract.d.ts +8 -0
- package/node_modules/@formepdf/core/dist/extract.js +56 -0
- package/node_modules/@formepdf/core/dist/index.d.ts +311 -0
- package/node_modules/@formepdf/core/dist/index.js +167 -0
- package/node_modules/@formepdf/core/dist/layout.d.ts +132 -0
- package/node_modules/@formepdf/core/dist/layout.js +240 -0
- package/node_modules/@formepdf/core/dist/shared/browserHelpers.d.ts +19 -0
- package/node_modules/@formepdf/core/dist/shared/browserHelpers.js +128 -0
- package/node_modules/@formepdf/core/package.json +35 -0
- package/node_modules/@formepdf/core/pkg-node/LICENSE +21 -0
- package/node_modules/@formepdf/core/pkg-node/README.md +84 -0
- package/node_modules/@formepdf/core/pkg-node/forme.d.ts +39 -0
- package/node_modules/@formepdf/core/pkg-node/forme.js +394 -0
- package/node_modules/@formepdf/core/pkg-node/forme_bg.wasm +0 -0
- package/node_modules/@formepdf/core/pkg-node/forme_bg.wasm.d.ts +21 -0
- package/node_modules/@formepdf/core/pkg-node/package.json +25 -0
- package/node_modules/@formepdf/react/README.md +70 -0
- package/node_modules/@formepdf/react/dist/charts.d.ts +72 -0
- package/node_modules/@formepdf/react/dist/charts.js +338 -0
- package/node_modules/@formepdf/react/dist/components.d.ts +533 -0
- package/node_modules/@formepdf/react/dist/components.js +608 -0
- package/node_modules/@formepdf/react/dist/expr.d.ts +20 -0
- package/node_modules/@formepdf/react/dist/expr.js +39 -0
- package/node_modules/@formepdf/react/dist/font.d.ts +2 -0
- package/node_modules/@formepdf/react/dist/font.js +1 -0
- package/node_modules/@formepdf/react/dist/index.d.ts +11 -0
- package/node_modules/@formepdf/react/dist/index.js +15 -0
- package/node_modules/@formepdf/react/dist/render.d.ts +12 -0
- package/node_modules/@formepdf/react/dist/render.js +15 -0
- package/node_modules/@formepdf/react/dist/serialize.d.ts +12 -0
- package/node_modules/@formepdf/react/dist/serialize.js +1470 -0
- package/node_modules/@formepdf/react/dist/stylesheet.d.ts +4 -0
- package/node_modules/@formepdf/react/dist/stylesheet.js +5 -0
- package/node_modules/@formepdf/react/dist/template-proxy.d.ts +38 -0
- package/node_modules/@formepdf/react/dist/template-proxy.js +100 -0
- package/node_modules/@formepdf/react/dist/types.d.ts +287 -0
- package/node_modules/@formepdf/react/dist/types.js +1 -0
- package/node_modules/@formepdf/react/package.json +41 -0
- package/node_modules/@formepdf/shared/README.md +7 -0
- package/node_modules/@formepdf/shared/dist/canvas.d.ts +6 -0
- package/node_modules/@formepdf/shared/dist/canvas.js +43 -0
- package/node_modules/@formepdf/shared/dist/charts.d.ts +100 -0
- package/node_modules/@formepdf/shared/dist/charts.js +98 -0
- package/node_modules/@formepdf/shared/dist/encode.d.ts +27 -0
- package/node_modules/@formepdf/shared/dist/encode.js +93 -0
- package/node_modules/@formepdf/shared/dist/font.d.ts +13 -0
- package/node_modules/@formepdf/shared/dist/font.js +52 -0
- package/node_modules/@formepdf/shared/dist/index.d.ts +10 -0
- package/node_modules/@formepdf/shared/dist/index.js +15 -0
- package/node_modules/@formepdf/shared/dist/parser.d.ts +30 -0
- package/node_modules/@formepdf/shared/dist/parser.js +756 -0
- package/node_modules/@formepdf/shared/dist/semantics.d.ts +15 -0
- package/node_modules/@formepdf/shared/dist/semantics.js +44 -0
- package/node_modules/@formepdf/shared/dist/style.d.ts +7 -0
- package/node_modules/@formepdf/shared/dist/style.js +1024 -0
- package/node_modules/@formepdf/shared/dist/types.d.ts +743 -0
- package/node_modules/@formepdf/shared/dist/types.js +2 -0
- package/node_modules/@formepdf/shared/package.json +35 -0
- package/node_modules/@types/node/LICENSE +21 -0
- package/node_modules/@types/node/README.md +15 -0
- package/node_modules/@types/node/assert/strict.d.ts +111 -0
- package/node_modules/@types/node/assert.d.ts +1078 -0
- package/node_modules/@types/node/async_hooks.d.ts +603 -0
- package/node_modules/@types/node/buffer.buffer.d.ts +472 -0
- package/node_modules/@types/node/buffer.d.ts +1934 -0
- package/node_modules/@types/node/child_process.d.ts +1476 -0
- package/node_modules/@types/node/cluster.d.ts +578 -0
- package/node_modules/@types/node/compatibility/disposable.d.ts +14 -0
- package/node_modules/@types/node/compatibility/index.d.ts +9 -0
- package/node_modules/@types/node/compatibility/indexable.d.ts +20 -0
- package/node_modules/@types/node/compatibility/iterators.d.ts +20 -0
- package/node_modules/@types/node/console.d.ts +452 -0
- package/node_modules/@types/node/constants.d.ts +21 -0
- package/node_modules/@types/node/crypto.d.ts +4545 -0
- package/node_modules/@types/node/dgram.d.ts +600 -0
- package/node_modules/@types/node/diagnostics_channel.d.ts +576 -0
- package/node_modules/@types/node/dns/promises.d.ts +503 -0
- package/node_modules/@types/node/dns.d.ts +923 -0
- package/node_modules/@types/node/domain.d.ts +170 -0
- package/node_modules/@types/node/events.d.ts +976 -0
- package/node_modules/@types/node/fs/promises.d.ts +1306 -0
- package/node_modules/@types/node/fs.d.ts +4463 -0
- package/node_modules/@types/node/globals.d.ts +172 -0
- package/node_modules/@types/node/globals.typedarray.d.ts +38 -0
- package/node_modules/@types/node/http.d.ts +2097 -0
- package/node_modules/@types/node/http2.d.ts +2843 -0
- package/node_modules/@types/node/https.d.ts +579 -0
- package/node_modules/@types/node/index.d.ts +98 -0
- package/node_modules/@types/node/inspector.d.ts +253 -0
- package/node_modules/@types/node/inspector.generated.d.ts +4052 -0
- package/node_modules/@types/node/module.d.ts +891 -0
- package/node_modules/@types/node/net.d.ts +1076 -0
- package/node_modules/@types/node/os.d.ts +506 -0
- package/node_modules/@types/node/package.json +145 -0
- package/node_modules/@types/node/path.d.ts +200 -0
- package/node_modules/@types/node/perf_hooks.d.ts +968 -0
- package/node_modules/@types/node/process.d.ts +2084 -0
- package/node_modules/@types/node/punycode.d.ts +117 -0
- package/node_modules/@types/node/querystring.d.ts +152 -0
- package/node_modules/@types/node/readline/promises.d.ts +161 -0
- package/node_modules/@types/node/readline.d.ts +594 -0
- package/node_modules/@types/node/repl.d.ts +428 -0
- package/node_modules/@types/node/sea.d.ts +162 -0
- package/node_modules/@types/node/sqlite.d.ts +722 -0
- package/node_modules/@types/node/stream/consumers.d.ts +38 -0
- package/node_modules/@types/node/stream/promises.d.ts +90 -0
- package/node_modules/@types/node/stream/web.d.ts +573 -0
- package/node_modules/@types/node/stream.d.ts +1694 -0
- package/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/node_modules/@types/node/test.d.ts +2265 -0
- package/node_modules/@types/node/timers/promises.d.ts +108 -0
- package/node_modules/@types/node/timers.d.ts +287 -0
- package/node_modules/@types/node/tls.d.ts +1319 -0
- package/node_modules/@types/node/trace_events.d.ts +197 -0
- package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +468 -0
- package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +34 -0
- package/node_modules/@types/node/ts5.6/index.d.ts +98 -0
- package/node_modules/@types/node/tty.d.ts +208 -0
- package/node_modules/@types/node/url.d.ts +984 -0
- package/node_modules/@types/node/util.d.ts +2606 -0
- package/node_modules/@types/node/v8.d.ts +920 -0
- package/node_modules/@types/node/vm.d.ts +1053 -0
- package/node_modules/@types/node/wasi.d.ts +181 -0
- package/node_modules/@types/node/web-globals/abortcontroller.d.ts +34 -0
- package/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
- package/node_modules/@types/node/web-globals/events.d.ts +97 -0
- package/node_modules/@types/node/web-globals/fetch.d.ts +55 -0
- package/node_modules/@types/node/web-globals/navigator.d.ts +22 -0
- package/node_modules/@types/node/web-globals/storage.d.ts +24 -0
- package/node_modules/@types/node/web-globals/streams.d.ts +22 -0
- package/node_modules/@types/node/worker_threads.d.ts +819 -0
- package/node_modules/@types/node/zlib.d.ts +747 -0
- package/node_modules/@types/react/LICENSE +21 -0
- package/node_modules/@types/react/README.md +15 -0
- package/node_modules/@types/react/canary.d.ts +129 -0
- package/node_modules/@types/react/compiler-runtime.d.ts +4 -0
- package/node_modules/@types/react/experimental.d.ts +184 -0
- package/node_modules/@types/react/global.d.ts +166 -0
- package/node_modules/@types/react/index.d.ts +4378 -0
- package/node_modules/@types/react/jsx-dev-runtime.d.ts +33 -0
- package/node_modules/@types/react/jsx-runtime.d.ts +24 -0
- package/node_modules/@types/react/package.json +210 -0
- package/node_modules/@types/react/ts5.0/canary.d.ts +129 -0
- package/node_modules/@types/react/ts5.0/experimental.d.ts +184 -0
- package/node_modules/@types/react/ts5.0/global.d.ts +166 -0
- package/node_modules/@types/react/ts5.0/index.d.ts +4365 -0
- package/node_modules/@types/react/ts5.0/jsx-dev-runtime.d.ts +33 -0
- package/node_modules/@types/react/ts5.0/jsx-runtime.d.ts +24 -0
- package/node_modules/csstype/LICENSE +19 -0
- package/node_modules/csstype/README.md +291 -0
- package/node_modules/csstype/index.d.ts +22569 -0
- package/node_modules/csstype/index.js.flow +6863 -0
- package/node_modules/csstype/package.json +70 -0
- package/node_modules/entities/LICENSE +11 -0
- package/node_modules/entities/decode.d.ts +1 -0
- package/node_modules/entities/decode.js +3 -0
- package/node_modules/entities/dist/commonjs/decode-codepoint.d.ts +19 -0
- package/node_modules/entities/dist/commonjs/decode-codepoint.d.ts.map +1 -0
- package/node_modules/entities/dist/commonjs/decode-codepoint.js +77 -0
- package/node_modules/entities/dist/commonjs/decode-codepoint.js.map +1 -0
- package/node_modules/entities/dist/commonjs/decode.d.ts +209 -0
- package/node_modules/entities/dist/commonjs/decode.d.ts.map +1 -0
- package/node_modules/entities/dist/commonjs/decode.js +511 -0
- package/node_modules/entities/dist/commonjs/decode.js.map +1 -0
- package/node_modules/entities/dist/commonjs/encode.d.ts +22 -0
- package/node_modules/entities/dist/commonjs/encode.d.ts.map +1 -0
- package/node_modules/entities/dist/commonjs/encode.js +73 -0
- package/node_modules/entities/dist/commonjs/encode.js.map +1 -0
- package/node_modules/entities/dist/commonjs/escape.d.ts +43 -0
- package/node_modules/entities/dist/commonjs/escape.d.ts.map +1 -0
- package/node_modules/entities/dist/commonjs/escape.js +121 -0
- package/node_modules/entities/dist/commonjs/escape.js.map +1 -0
- package/node_modules/entities/dist/commonjs/generated/decode-data-html.d.ts +2 -0
- package/node_modules/entities/dist/commonjs/generated/decode-data-html.d.ts.map +1 -0
- package/node_modules/entities/dist/commonjs/generated/decode-data-html.js +10 -0
- package/node_modules/entities/dist/commonjs/generated/decode-data-html.js.map +1 -0
- package/node_modules/entities/dist/commonjs/generated/decode-data-xml.d.ts +2 -0
- package/node_modules/entities/dist/commonjs/generated/decode-data-xml.d.ts.map +1 -0
- package/node_modules/entities/dist/commonjs/generated/decode-data-xml.js +10 -0
- package/node_modules/entities/dist/commonjs/generated/decode-data-xml.js.map +1 -0
- package/node_modules/entities/dist/commonjs/generated/encode-html.d.ts +8 -0
- package/node_modules/entities/dist/commonjs/generated/encode-html.d.ts.map +1 -0
- package/node_modules/entities/dist/commonjs/generated/encode-html.js +13 -0
- package/node_modules/entities/dist/commonjs/generated/encode-html.js.map +1 -0
- package/node_modules/entities/dist/commonjs/index.d.ts +96 -0
- package/node_modules/entities/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/entities/dist/commonjs/index.js +131 -0
- package/node_modules/entities/dist/commonjs/index.js.map +1 -0
- package/node_modules/entities/dist/commonjs/package.json +3 -0
- package/node_modules/entities/dist/esm/decode-codepoint.d.ts +19 -0
- package/node_modules/entities/dist/esm/decode-codepoint.d.ts.map +1 -0
- package/node_modules/entities/dist/esm/decode-codepoint.js +72 -0
- package/node_modules/entities/dist/esm/decode-codepoint.js.map +1 -0
- package/node_modules/entities/dist/esm/decode.d.ts +209 -0
- package/node_modules/entities/dist/esm/decode.d.ts.map +1 -0
- package/node_modules/entities/dist/esm/decode.js +497 -0
- package/node_modules/entities/dist/esm/decode.js.map +1 -0
- package/node_modules/entities/dist/esm/encode.d.ts +22 -0
- package/node_modules/entities/dist/esm/encode.d.ts.map +1 -0
- package/node_modules/entities/dist/esm/encode.js +69 -0
- package/node_modules/entities/dist/esm/encode.js.map +1 -0
- package/node_modules/entities/dist/esm/escape.d.ts +43 -0
- package/node_modules/entities/dist/esm/escape.d.ts.map +1 -0
- package/node_modules/entities/dist/esm/escape.js +117 -0
- package/node_modules/entities/dist/esm/escape.js.map +1 -0
- package/node_modules/entities/dist/esm/generated/decode-data-html.d.ts +2 -0
- package/node_modules/entities/dist/esm/generated/decode-data-html.d.ts.map +1 -0
- package/node_modules/entities/dist/esm/generated/decode-data-html.js +7 -0
- package/node_modules/entities/dist/esm/generated/decode-data-html.js.map +1 -0
- package/node_modules/entities/dist/esm/generated/decode-data-xml.d.ts +2 -0
- package/node_modules/entities/dist/esm/generated/decode-data-xml.d.ts.map +1 -0
- package/node_modules/entities/dist/esm/generated/decode-data-xml.js +7 -0
- package/node_modules/entities/dist/esm/generated/decode-data-xml.js.map +1 -0
- package/node_modules/entities/dist/esm/generated/encode-html.d.ts +8 -0
- package/node_modules/entities/dist/esm/generated/encode-html.d.ts.map +1 -0
- package/node_modules/entities/dist/esm/generated/encode-html.js +10 -0
- package/node_modules/entities/dist/esm/generated/encode-html.js.map +1 -0
- package/node_modules/entities/dist/esm/index.d.ts +96 -0
- package/node_modules/entities/dist/esm/index.d.ts.map +1 -0
- package/node_modules/entities/dist/esm/index.js +107 -0
- package/node_modules/entities/dist/esm/index.js.map +1 -0
- package/node_modules/entities/dist/esm/package.json +3 -0
- package/node_modules/entities/escape.d.ts +1 -0
- package/node_modules/entities/escape.js +3 -0
- package/node_modules/entities/package.json +118 -0
- package/node_modules/entities/readme.md +122 -0
- package/node_modules/entities/src/decode-codepoint.ts +81 -0
- package/node_modules/entities/src/decode.spec.ts +320 -0
- package/node_modules/entities/src/decode.ts +620 -0
- package/node_modules/entities/src/encode.spec.ts +78 -0
- package/node_modules/entities/src/encode.ts +77 -0
- package/node_modules/entities/src/escape.spec.ts +14 -0
- package/node_modules/entities/src/escape.ts +148 -0
- package/node_modules/entities/src/generated/.eslintrc.json +10 -0
- package/node_modules/entities/src/generated/decode-data-html.ts +8 -0
- package/node_modules/entities/src/generated/decode-data-xml.ts +8 -0
- package/node_modules/entities/src/generated/encode-html.ts +17 -0
- package/node_modules/entities/src/index.spec.ts +125 -0
- package/node_modules/entities/src/index.ts +188 -0
- package/node_modules/parse5/LICENSE +19 -0
- package/node_modules/parse5/README.md +38 -0
- package/node_modules/parse5/dist/cjs/common/doctype.d.ts +4 -0
- package/node_modules/parse5/dist/cjs/common/doctype.js +118 -0
- package/node_modules/parse5/dist/cjs/common/error-codes.d.ts +67 -0
- package/node_modules/parse5/dist/cjs/common/error-codes.js +66 -0
- package/node_modules/parse5/dist/cjs/common/foreign-content.d.ts +9 -0
- package/node_modules/parse5/dist/cjs/common/foreign-content.js +237 -0
- package/node_modules/parse5/dist/cjs/common/html.d.ts +289 -0
- package/node_modules/parse5/dist/cjs/common/html.js +528 -0
- package/node_modules/parse5/dist/cjs/common/token.d.ts +84 -0
- package/node_modules/parse5/dist/cjs/common/token.js +24 -0
- package/node_modules/parse5/dist/cjs/common/unicode.d.ts +42 -0
- package/node_modules/parse5/dist/cjs/common/unicode.js +70 -0
- package/node_modules/parse5/dist/cjs/index.d.ts +71 -0
- package/node_modules/parse5/dist/cjs/index.js +54 -0
- package/node_modules/parse5/dist/cjs/package.json +1 -0
- package/node_modules/parse5/dist/cjs/parser/formatting-element-list.d.ts +36 -0
- package/node_modules/parse5/dist/cjs/parser/formatting-element-list.js +114 -0
- package/node_modules/parse5/dist/cjs/parser/index.d.ts +221 -0
- package/node_modules/parse5/dist/cjs/parser/index.js +3240 -0
- package/node_modules/parse5/dist/cjs/parser/open-element-stack.d.ts +53 -0
- package/node_modules/parse5/dist/cjs/parser/open-element-stack.js +328 -0
- package/node_modules/parse5/dist/cjs/serializer/index.d.ts +60 -0
- package/node_modules/parse5/dist/cjs/serializer/index.js +172 -0
- package/node_modules/parse5/dist/cjs/tokenizer/index.d.ts +247 -0
- package/node_modules/parse5/dist/cjs/tokenizer/index.js +2714 -0
- package/node_modules/parse5/dist/cjs/tokenizer/preprocessor.d.ts +36 -0
- package/node_modules/parse5/dist/cjs/tokenizer/preprocessor.js +200 -0
- package/node_modules/parse5/dist/cjs/tree-adapters/default.d.ts +84 -0
- package/node_modules/parse5/dist/cjs/tree-adapters/default.js +176 -0
- package/node_modules/parse5/dist/cjs/tree-adapters/interface.d.ts +255 -0
- package/node_modules/parse5/dist/cjs/tree-adapters/interface.js +2 -0
- package/node_modules/parse5/dist/common/doctype.d.ts +4 -0
- package/node_modules/parse5/dist/common/doctype.js +114 -0
- package/node_modules/parse5/dist/common/error-codes.d.ts +67 -0
- package/node_modules/parse5/dist/common/error-codes.js +63 -0
- package/node_modules/parse5/dist/common/foreign-content.d.ts +9 -0
- package/node_modules/parse5/dist/common/foreign-content.js +228 -0
- package/node_modules/parse5/dist/common/html.d.ts +289 -0
- package/node_modules/parse5/dist/common/html.js +523 -0
- package/node_modules/parse5/dist/common/token.d.ts +84 -0
- package/node_modules/parse5/dist/common/token.js +20 -0
- package/node_modules/parse5/dist/common/unicode.d.ts +42 -0
- package/node_modules/parse5/dist/common/unicode.js +62 -0
- package/node_modules/parse5/dist/index.d.ts +71 -0
- package/node_modules/parse5/dist/index.js +42 -0
- package/node_modules/parse5/dist/parser/formatting-element-list.d.ts +36 -0
- package/node_modules/parse5/dist/parser/formatting-element-list.js +110 -0
- package/node_modules/parse5/dist/parser/index.d.ts +221 -0
- package/node_modules/parse5/dist/parser/index.js +3245 -0
- package/node_modules/parse5/dist/parser/open-element-stack.d.ts +53 -0
- package/node_modules/parse5/dist/parser/open-element-stack.js +324 -0
- package/node_modules/parse5/dist/serializer/index.d.ts +60 -0
- package/node_modules/parse5/dist/serializer/index.js +168 -0
- package/node_modules/parse5/dist/tokenizer/index.d.ts +247 -0
- package/node_modules/parse5/dist/tokenizer/index.js +2710 -0
- package/node_modules/parse5/dist/tokenizer/preprocessor.d.ts +36 -0
- package/node_modules/parse5/dist/tokenizer/preprocessor.js +196 -0
- package/node_modules/parse5/dist/tree-adapters/default.d.ts +84 -0
- package/node_modules/parse5/dist/tree-adapters/default.js +173 -0
- package/node_modules/parse5/dist/tree-adapters/interface.d.ts +255 -0
- package/node_modules/parse5/dist/tree-adapters/interface.js +1 -0
- package/node_modules/parse5/package.json +50 -0
- package/node_modules/undici-types/LICENSE +21 -0
- package/node_modules/undici-types/README.md +6 -0
- package/node_modules/undici-types/agent.d.ts +31 -0
- package/node_modules/undici-types/api.d.ts +43 -0
- package/node_modules/undici-types/balanced-pool.d.ts +29 -0
- package/node_modules/undici-types/cache.d.ts +36 -0
- package/node_modules/undici-types/client.d.ts +108 -0
- package/node_modules/undici-types/connector.d.ts +34 -0
- package/node_modules/undici-types/content-type.d.ts +21 -0
- package/node_modules/undici-types/cookies.d.ts +28 -0
- package/node_modules/undici-types/diagnostics-channel.d.ts +66 -0
- package/node_modules/undici-types/dispatcher.d.ts +256 -0
- package/node_modules/undici-types/env-http-proxy-agent.d.ts +21 -0
- package/node_modules/undici-types/errors.d.ts +149 -0
- package/node_modules/undici-types/eventsource.d.ts +61 -0
- package/node_modules/undici-types/fetch.d.ts +209 -0
- package/node_modules/undici-types/file.d.ts +39 -0
- package/node_modules/undici-types/filereader.d.ts +54 -0
- package/node_modules/undici-types/formdata.d.ts +108 -0
- package/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/node_modules/undici-types/global-origin.d.ts +7 -0
- package/node_modules/undici-types/handlers.d.ts +15 -0
- package/node_modules/undici-types/header.d.ts +4 -0
- package/node_modules/undici-types/index.d.ts +71 -0
- package/node_modules/undici-types/interceptors.d.ts +17 -0
- package/node_modules/undici-types/mock-agent.d.ts +50 -0
- package/node_modules/undici-types/mock-client.d.ts +25 -0
- package/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/node_modules/undici-types/mock-interceptor.d.ts +93 -0
- package/node_modules/undici-types/mock-pool.d.ts +25 -0
- package/node_modules/undici-types/package.json +55 -0
- package/node_modules/undici-types/patch.d.ts +33 -0
- package/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/node_modules/undici-types/pool.d.ts +39 -0
- package/node_modules/undici-types/proxy-agent.d.ts +28 -0
- package/node_modules/undici-types/readable.d.ts +65 -0
- package/node_modules/undici-types/retry-agent.d.ts +8 -0
- package/node_modules/undici-types/retry-handler.d.ts +116 -0
- package/node_modules/undici-types/util.d.ts +18 -0
- package/node_modules/undici-types/webidl.d.ts +228 -0
- package/node_modules/undici-types/websocket.d.ts +150 -0
- package/package.json +80 -0
- package/scripts/rebuild-forme.mjs +61 -0
- package/src/app/AppearanceControl.tsx +44 -0
- package/src/app/AssetThemeDefaults.tsx +87 -0
- package/src/app/AssetsBrowser.tsx +273 -0
- package/src/app/CommentDock.tsx +108 -0
- package/src/app/CreateDocumentDialog.tsx +51 -0
- package/src/app/DocumentActions.tsx +69 -0
- package/src/app/DocumentCard.tsx +50 -0
- package/src/app/DocumentViewControl.tsx +31 -0
- package/src/app/DocumentsBrowser.tsx +70 -0
- package/src/app/ExportHistoryDialog.tsx +86 -0
- package/src/app/ExportMenu.tsx +127 -0
- package/src/app/GuideDialog.tsx +80 -0
- package/src/app/InspectionLayer.tsx +77 -0
- package/src/app/LogoUploadDialog.tsx +92 -0
- package/src/app/Markdown.tsx +34 -0
- package/src/app/MaterialsBrowser.tsx +149 -0
- package/src/app/PageNumberInput.tsx +56 -0
- package/src/app/Pdf.tsx +561 -0
- package/src/app/ProjectDialogs.tsx +100 -0
- package/src/app/Reader.tsx +769 -0
- package/src/app/SearchField.tsx +13 -0
- package/src/app/Sidebar.tsx +86 -0
- package/src/app/SkillIndex.tsx +30 -0
- package/src/app/TemplatesBrowser.tsx +149 -0
- package/src/app/ThemesBrowser.tsx +159 -0
- package/src/app/api.ts +47 -0
- package/src/app/appearance.ts +35 -0
- package/src/app/assets.css +139 -0
- package/src/app/catalogPreview.ts +20 -0
- package/src/app/colors.css +167 -0
- package/src/app/comment-dock.css +53 -0
- package/src/app/commentDrafts.ts +67 -0
- package/src/app/componentCorrection.ts +17 -0
- package/src/app/edit-workbench.css +87 -0
- package/src/app/editSession.ts +238 -0
- package/src/app/editorRecovery.ts +25 -0
- package/src/app/export-history.css +31 -0
- package/src/app/export.css +17 -0
- package/src/app/guideLinks.ts +21 -0
- package/src/app/guides.css +40 -0
- package/src/app/main.tsx +221 -0
- package/src/app/materials.css +53 -0
- package/src/app/pdfLoading.ts +12 -0
- package/src/app/pdfSelection.ts +112 -0
- package/src/app/projects.css +63 -0
- package/src/app/reader-toolbar.css +65 -0
- package/src/app/selection.css +150 -0
- package/src/app/sidebar.css +60 -0
- package/src/app/skills.css +7 -0
- package/src/app/style.css +1061 -0
- package/src/app/templates.css +49 -0
- package/src/app/themes.css +80 -0
- package/src/app/ui/Icon.tsx +92 -0
- package/src/app/ui/README.md +27 -0
- package/src/app/ui/fonts.css +36 -0
- package/src/app/ui/index.tsx +223 -0
- package/src/app/ui/ui.css +388 -0
- package/src/app/useReaderPreview.ts +19 -0
- package/src/app/useTextEditing.ts +155 -0
- package/src/assets/adapter.ts +122 -0
- package/src/assets/files.ts +378 -0
- package/src/assets/import-worker.ts +294 -0
- package/src/assets/imports.ts +124 -0
- package/src/assets/index.ts +60 -0
- package/src/assets/store.ts +798 -0
- package/src/assets/usage.ts +118 -0
- package/src/cli/check.ts +25 -0
- package/src/cli/init.ts +119 -0
- package/src/cli/lock.ts +34 -0
- package/src/cli/main.ts +118 -0
- package/src/cli/process.ts +19 -0
- package/src/cli/start.ts +96 -0
- package/src/cli/update.ts +348 -0
- package/src/cli/workspace.ts +94 -0
- package/src/document/index.tsx +641 -0
- package/src/document/page.tsx +53 -0
- package/src/document/text-targets.tsx +162 -0
- package/src/media/files.ts +124 -0
- package/src/media/render.ts +63 -0
- package/src/rendering/resolve-sources.ts +84 -0
- package/src/runtime/jsx-dev-runtime.ts +2 -0
- package/src/runtime/jsx-runtime.ts +2 -0
- package/src/runtime/paths.ts +12 -0
- package/src/server/assets-cli.ts +162 -0
- package/src/server/assets-http.ts +100 -0
- package/src/server/client.ts +50 -0
- package/src/server/clipboard.ts +22 -0
- package/src/server/comments-cli.ts +64 -0
- package/src/server/comments.ts +130 -0
- package/src/server/create-cli.ts +33 -0
- package/src/server/create.ts +228 -0
- package/src/server/dependencies.ts +91 -0
- package/src/server/documents.ts +143 -0
- package/src/server/edits.ts +249 -0
- package/src/server/export-batch.ts +105 -0
- package/src/server/export-errors.ts +2 -0
- package/src/server/export-file.ts +57 -0
- package/src/server/export-inputs.ts +66 -0
- package/src/server/export-preview.ts +69 -0
- package/src/server/export.ts +32 -0
- package/src/server/exports.ts +283 -0
- package/src/server/files.ts +21 -0
- package/src/server/guides.ts +71 -0
- package/src/server/index.ts +432 -0
- package/src/server/materials.ts +39 -0
- package/src/server/media-cli.ts +73 -0
- package/src/server/media-mutations.ts +168 -0
- package/src/server/pptx.ts +160 -0
- package/src/server/preflight.ts +129 -0
- package/src/server/projects-cli.ts +29 -0
- package/src/server/projects.ts +187 -0
- package/src/server/render-error.ts +9 -0
- package/src/server/render-source.ts +24 -0
- package/src/server/render.ts +48 -0
- package/src/server/review-cli.ts +40 -0
- package/src/server/review.ts +161 -0
- package/src/server/selection.ts +23 -0
- package/src/server/source-overrides.ts +97 -0
- package/src/server/templates-cli.ts +51 -0
- package/src/server/templates.ts +186 -0
- package/src/server/text-layout.ts +41 -0
- package/src/server/text-source.ts +307 -0
- package/src/server/themes-cli.ts +59 -0
- package/src/server/themes.ts +215 -0
- package/src/server/ttf2eot.d.ts +3 -0
- package/src/server/worker.ts +166 -0
- package/src/server/workspace.ts +242 -0
- package/src/shared/anchors.ts +69 -0
- package/src/shared/assets.ts +154 -0
- package/src/shared/export.ts +34 -0
- package/src/shared/media.ts +33 -0
- package/src/shared/projects.ts +19 -0
- package/src/shared/selection.ts +94 -0
- package/src/shared/skill-index.ts +14 -0
- package/src/shared/starters.ts +19 -0
- package/src/shared/templates.ts +18 -0
- package/src/shared/themes.ts +24 -0
- package/src/shared/types.ts +39 -0
- package/src/template/index.ts +27 -0
- package/src/themes/index.ts +3 -0
- package/src/themes/neutral.ts +20 -0
- package/src/themes/types.ts +110 -0
- package/starter/assets/brand/wordmark.png +0 -0
- package/starter/assets/fonts/InterUI-LICENSE.txt +93 -0
- package/starter/assets/fonts/InterUI-Medium.ttf +0 -0
- package/starter/assets/fonts/InterUI-Regular.ttf +0 -0
- package/starter/assets/fonts/InterUI-source.json +19 -0
- package/starter/assets/fonts/OpenDocMono-Regular.ttf +0 -0
- package/starter/assets/fonts/OpenDocSans-Italic.ttf +0 -0
- package/starter/assets/fonts/OpenDocSans-Regular.ttf +0 -0
- package/starter/assets/fonts/OpenDocSans-Semibold.ttf +0 -0
- package/starter/assets/fonts/OpenDocSans-SemiboldItalic.ttf +0 -0
- package/starter/assets/fonts/OpenDocSerif-Italic.ttf +0 -0
- package/starter/assets/fonts/OpenDocSerif-Regular.ttf +0 -0
- package/starter/assets/fonts/OpenDocSerif-Semibold.ttf +0 -0
- package/starter/assets/fonts/OpenDocSerif-SemiboldItalic.ttf +0 -0
- package/starter/assets/fonts/SourceCode-LICENSE.md +93 -0
- package/starter/assets/fonts/SourceSans-LICENSE.md +93 -0
- package/starter/assets/fonts/SourceSerif-LICENSE.md +93 -0
- package/starter/assets/fonts/geist/OFL.txt +93 -0
- package/starter/assets/fonts/geist/asset.json +7 -0
- package/starter/assets/fonts/geist/files/1a9874b3be0fc168692a3d2327bccb4d28835653d3b91537a755296a467a83e3.ttf +0 -0
- package/starter/assets/fonts/geist/files/a8eefb873ba9c9020665f8a98302697ce1f3b79ab2deef6ee508c0ca6a82e876.ttf +0 -0
- package/starter/assets/fonts/geist/files/ccce59465ae5c61930ada5453834f60500fbd95084d85db63e0e65fad0125455.ttf +0 -0
- package/starter/assets/fonts/geist/files/f5e95110d70593672515080bee9148463ada0a7f77b89ed65a3d43cb2b0ff83a.pdf +0 -0
- package/starter/assets/fonts/geist/revisions/9a2bc12fb2f23cb27bc227087e63e1407bb804ee0586480bd6b7966ec69fb474.json +60 -0
- package/starter/assets/fonts/inter/OFL.txt +93 -0
- package/starter/assets/fonts/inter/asset.json +7 -0
- package/starter/assets/fonts/inter/files/1b08e7fc267a5c7e1d614100f604b83e7e8a0be241f0f288faa2b3ac93a683ba.ttf +0 -0
- package/starter/assets/fonts/inter/files/5b6f0c6f26e5c554a64cdcc3a9b5d802b7f9aec6206f1dbcfcdcad7b5860a2a9.ttf +0 -0
- package/starter/assets/fonts/inter/files/957db8560d510a198a7d0333fae7b6b444b00c20801581126273978d778eb3c3.pdf +0 -0
- package/starter/assets/fonts/inter/files/b37284b5701b6b168dfc770aa1a4ac492106422fd3ba76bc7641e37434e8019c.ttf +0 -0
- package/starter/assets/fonts/inter/files/c1811d32ac0f6eed1bbf57529f2ecdfc6c717d48a969dd864942436315a1b198.ttf +0 -0
- package/starter/assets/fonts/inter/files/e7a1aaf7eda9f2fad4131725fa556265ec75ca7b2d756260173a040363e8d4f7.ttf +0 -0
- package/starter/assets/fonts/inter/files/ef8f755d933b9310804cc9152f1f18cb2ac460d6b05054ec913d889c9f11f79e.ttf +0 -0
- package/starter/assets/fonts/inter/revisions/600391517c413963b71e278a57c26c40366c81fa3939a6b9755f446206766d12.json +99 -0
- package/starter/assets/fonts/inter/source.json +57 -0
- package/starter/assets/fonts/lato/OFL.txt +93 -0
- package/starter/assets/fonts/lato/asset.json +7 -0
- package/starter/assets/fonts/lato/files/4a6b566dbb28adb473a8789ce5169306f42f0c8a070ac92bae93636f36348b0d.pdf +0 -0
- package/starter/assets/fonts/lato/files/5adeb6b334d8fb99ef053bc052b952773d544315e0e1d668a12c0ce8bd51375c.ttf +0 -0
- package/starter/assets/fonts/lato/files/62c1b7f0d2e74b45960154c3520efc337b553db0961bfdc950d5618334596cc8.ttf +0 -0
- package/starter/assets/fonts/lato/files/71b8b7decbe75a881ed267be539d402bd1e9420b799658aada4e0d1bd5af803c.ttf +0 -0
- package/starter/assets/fonts/lato/files/8a0aace75d33794eece4b28187bfc1df0bbd2888b5d8a56e01788c8d65d16be1.ttf +0 -0
- package/starter/assets/fonts/lato/files/d636e4683231f931eda222d588e944d082bfd3bdba02f928bee461c0f185b251.ttf +0 -0
- package/starter/assets/fonts/lato/files/e399c44efe1387100531d26c7e4800c5d12251b890d6654a3098c7c679cb1786.ttf +0 -0
- package/starter/assets/fonts/lato/revisions/49ccb93400a9d466fab7d9843b1ecf8916ec6d47a475dd79a597a22eb39616bc.json +99 -0
- package/starter/assets/fonts/lato/source.json +57 -0
- package/starter/assets/fonts/merriweather/OFL.txt +93 -0
- package/starter/assets/fonts/merriweather/asset.json +7 -0
- package/starter/assets/fonts/merriweather/files/1c54f91b910454251c4c2b7bd4e472e1abf265fba7ca3c0ef2eee2f41324099e.ttf +0 -0
- package/starter/assets/fonts/merriweather/files/8bde8da2bb7f0265e27ba0481f70bb48d0f98a976c145f2f239c648ddd6532e0.pdf +0 -0
- package/starter/assets/fonts/merriweather/files/90b7db4460fcd1a5ca49575c2668a793f3cd6447664d312a068d690e1c01e6bc.ttf +0 -0
- package/starter/assets/fonts/merriweather/files/afff81272b7653417bb6f8bef57add055b1f9fda36f27eba5f32b40752bd08da.ttf +0 -0
- package/starter/assets/fonts/merriweather/files/e029d3b71e5bae3877c73f4f2b15af28db16593d49b0aed2a328d37ff7075846.ttf +0 -0
- package/starter/assets/fonts/merriweather/files/e9864a6790bf712a04e20f3662b206a1535186ed3e877fd859dd5fb9682335df.ttf +0 -0
- package/starter/assets/fonts/merriweather/files/fa71baebdd20a7d0de2e5e445a5922530fe9e1d740efbe791f113b682d3cb093.ttf +0 -0
- package/starter/assets/fonts/merriweather/revisions/1888e390b3e4f38a3d7cd2dc1bb805aeb6ce13f986a97656f0265fd436bc91d2.json +99 -0
- package/starter/assets/fonts/merriweather/source.json +57 -0
- package/starter/assets/fonts/open-sans/OFL.txt +92 -0
- package/starter/assets/fonts/open-sans/asset.json +7 -0
- package/starter/assets/fonts/open-sans/files/1bc0594a83762b2c25d38915a34464b7fec6088298ca22d151757bf98d6700ec.ttf +0 -0
- package/starter/assets/fonts/open-sans/files/47ed1cfaa7ffca04a04ab850b2938fd52c09d1b44cfa3e2980878e166b0cbd87.ttf +0 -0
- package/starter/assets/fonts/open-sans/files/574939af301f07df8e21cfff279465c5981dd9d9cf62086f7515897df951c6f5.pdf +0 -0
- package/starter/assets/fonts/open-sans/files/6d3884d0d57c1b67e9c50c54eca7b69c535c114e76bd7a9cfda0258588185553.ttf +0 -0
- package/starter/assets/fonts/open-sans/files/733eb93b167e6d45de09aa768f6c0355647c2c26f5416dbc7407a08ed41e81c6.ttf +0 -0
- package/starter/assets/fonts/open-sans/files/75367e6da7d914eaed87883ba51b2a2b5816b5cdbb39f96ec5c81a5b032bfd5a.ttf +0 -0
- package/starter/assets/fonts/open-sans/files/ff4fdc11204e0edd14e9a0bb6c374b847a9093b0ec2c16702e03afca79ac4ef7.ttf +0 -0
- package/starter/assets/fonts/open-sans/revisions/bbbe3a4915b9bccbc883c0decb4097511c43b6bd09ae22a1516aff128c219bc5.json +99 -0
- package/starter/assets/fonts/open-sans/source.json +57 -0
- package/starter/assets/fonts/roboto/OFL.txt +93 -0
- package/starter/assets/fonts/roboto/asset.json +7 -0
- package/starter/assets/fonts/roboto/files/22d45d989248a624252b8382067ac56550212fa675dcdbaf12f03d297dd87a58.pdf +0 -0
- package/starter/assets/fonts/roboto/files/35757eaa996b3359022f47f164a67ee9eac04971af24c5b8fbd4b89e844ff190.ttf +0 -0
- package/starter/assets/fonts/roboto/files/4d3035883c531846bd1ce2dc89f36d932e72dc114f56062c7e3a9cdd74f3d3ea.ttf +0 -0
- package/starter/assets/fonts/roboto/files/be7639306a4fc4a02ce2ae2ff59eb1335e4db4a7379dd0a384ed7cc053817789.ttf +0 -0
- package/starter/assets/fonts/roboto/files/d2920cbb1b60a3fd11fbf22049286e43a6baf522d37fdf1e7c89562319bcfea5.ttf +0 -0
- package/starter/assets/fonts/roboto/files/dece7c71bbe61710787f0839c722c65e87355dd2eb4a823e6b5488121ff81e4b.ttf +0 -0
- package/starter/assets/fonts/roboto/files/f478ba88b0292e685e487901dfbb1401457d32d6ebee4030cdfd5698235bffa8.ttf +0 -0
- package/starter/assets/fonts/roboto/revisions/bda5e2d84c17313373dd2dbf3e64fe0dd450c7e1b59e6929e69557e122fe976e.json +99 -0
- package/starter/assets/fonts/roboto/source.json +57 -0
- package/starter/assets/logos/opendoc/asset.json +6 -0
- package/starter/assets/logos/opendoc/files/831d5ccd9eb6709cc8439ea257c03d81452e81a28a3d1eedbd6a3b7daff687b6.png +0 -0
- package/starter/assets/logos/opendoc/revisions/834dde8926ddb81de687254195a168bb13bfb77803307f1257de1f2228be63b2.json +33 -0
- package/starter/assets/ui-fonts/geist/OFL.txt +93 -0
- package/starter/assets/ui-fonts/geist/geist-latin-ext-wght-italic.woff2 +0 -0
- package/starter/assets/ui-fonts/geist/geist-latin-ext-wght-normal.woff2 +0 -0
- package/starter/assets/ui-fonts/geist/geist-latin-wght-italic.woff2 +0 -0
- package/starter/assets/ui-fonts/geist/geist-latin-wght-normal.woff2 +0 -0
- package/starter/assets/ui-fonts/geist/source.json +26 -0
- package/starter/documents/welcome/assets.json +7 -0
- package/starter/documents/welcome/index.tsx +160 -0
- package/starter/documents/welcome/media/.gitkeep +0 -0
- package/starter/documents/welcome/media/paper-architecture/image.png +0 -0
- package/starter/documents/welcome/media/paper-architecture/meta.json +9 -0
- package/starter/documents/welcome/media/paper-architecture/prompt.txt +1 -0
- package/starter/documents/welcome/media/studio-rhythm/chart.svg +2343 -0
- package/starter/documents/welcome/media/studio-rhythm/data.json +234 -0
- package/starter/documents/welcome/media/studio-rhythm/generation.json +9 -0
- package/starter/documents/welcome/media/studio-rhythm/image.png +0 -0
- package/starter/documents/welcome/media/studio-rhythm/meta.json +11 -0
- package/starter/documents/welcome/media/studio-rhythm/recipe.py +79 -0
- package/starter/documents/welcome/theme.tsx +5 -0
- package/starter/documents/welcome-presentation/assets.json +7 -0
- package/starter/documents/welcome-presentation/index.tsx +166 -0
- package/starter/documents/welcome-presentation/media/.gitkeep +0 -0
- package/starter/documents/welcome-presentation/media/paper-architecture/image.png +0 -0
- package/starter/documents/welcome-presentation/media/paper-architecture/meta.json +9 -0
- package/starter/documents/welcome-presentation/media/paper-architecture/prompt.txt +1 -0
- package/starter/documents/welcome-presentation/media/studio-rhythm/chart.svg +1336 -0
- package/starter/documents/welcome-presentation/media/studio-rhythm/data.json +234 -0
- package/starter/documents/welcome-presentation/media/studio-rhythm/generation.json +9 -0
- package/starter/documents/welcome-presentation/media/studio-rhythm/image.png +0 -0
- package/starter/documents/welcome-presentation/media/studio-rhythm/meta.json +13 -0
- package/starter/documents/welcome-presentation/media/studio-rhythm/recipe.py +49 -0
- package/starter/documents/welcome-presentation/theme.tsx +5 -0
- package/starter/projects.json +17 -0
- package/starter/templates/AGENTS.md +9 -0
- package/starter/templates/_shared/BusinessLogo.tsx +14 -0
- package/starter/templates/_shared/Pricing.tsx +40 -0
- package/starter/templates/_shared/commerce.ts +93 -0
- package/starter/templates/brand-guidelines/AGENTS.md +32 -0
- package/starter/templates/brand-guidelines/index.tsx +62 -0
- package/starter/templates/brand-guidelines/preview.tsx +181 -0
- package/starter/templates/brand-guidelines/starter.tsx +179 -0
- package/starter/templates/brand-guidelines/template.json +15 -0
- package/starter/templates/business-proposal/AGENTS.md +13 -0
- package/starter/templates/business-proposal/README.md +36 -0
- package/starter/templates/business-proposal/data.json +37 -0
- package/starter/templates/business-proposal/examples/long.json +142 -0
- package/starter/templates/business-proposal/examples/sparse.json +17 -0
- package/starter/templates/business-proposal/examples/typical.json +37 -0
- package/starter/templates/business-proposal/index.tsx +59 -0
- package/starter/templates/business-proposal/preview.tsx +47 -0
- package/starter/templates/business-proposal/schema.ts +14 -0
- package/starter/templates/business-proposal/starter.tsx +18 -0
- package/starter/templates/business-proposal/template.json +11 -0
- package/starter/templates/company-profile/AGENTS.md +48 -0
- package/starter/templates/company-profile/index.tsx +69 -0
- package/starter/templates/company-profile/preview.tsx +185 -0
- package/starter/templates/company-profile/starter.tsx +186 -0
- package/starter/templates/company-profile/template.json +15 -0
- package/starter/templates/consulting-report/AGENTS.md +11 -0
- package/starter/templates/consulting-report/README.md +13 -0
- package/starter/templates/consulting-report/RESEARCH.md +10 -0
- package/starter/templates/consulting-report/index.tsx +44 -0
- package/starter/templates/consulting-report/preview.tsx +39 -0
- package/starter/templates/consulting-report/starter.tsx +15 -0
- package/starter/templates/consulting-report/template.json +11 -0
- package/starter/templates/editorial-essay/AGENTS.md +11 -0
- package/starter/templates/editorial-essay/README.md +11 -0
- package/starter/templates/editorial-essay/index.tsx +30 -0
- package/starter/templates/editorial-essay/preview.tsx +26 -0
- package/starter/templates/editorial-essay/starter.tsx +15 -0
- package/starter/templates/editorial-essay/template.json +11 -0
- package/starter/templates/executive-brief/AGENTS.md +9 -0
- package/starter/templates/executive-brief/README.md +11 -0
- package/starter/templates/executive-brief/index.tsx +33 -0
- package/starter/templates/executive-brief/preview.tsx +37 -0
- package/starter/templates/executive-brief/starter.tsx +11 -0
- package/starter/templates/executive-brief/template.json +11 -0
- package/starter/templates/image-story/AGENTS.md +37 -0
- package/starter/templates/image-story/index.tsx +106 -0
- package/starter/templates/image-story/preview.tsx +33 -0
- package/starter/templates/image-story/starter.tsx +24 -0
- package/starter/templates/image-story/template.json +13 -0
- package/starter/templates/invoice/AGENTS.md +13 -0
- package/starter/templates/invoice/README.md +40 -0
- package/starter/templates/invoice/data.json +61 -0
- package/starter/templates/invoice/examples/long.json +241 -0
- package/starter/templates/invoice/examples/sparse.json +33 -0
- package/starter/templates/invoice/examples/typical.json +61 -0
- package/starter/templates/invoice/index.tsx +57 -0
- package/starter/templates/invoice/preview.tsx +12 -0
- package/starter/templates/invoice/schema.ts +45 -0
- package/starter/templates/invoice/starter.tsx +12 -0
- package/starter/templates/invoice/template.json +11 -0
- package/starter/templates/literary-text/AGENTS.md +9 -0
- package/starter/templates/literary-text/README.md +11 -0
- package/starter/templates/literary-text/index.tsx +31 -0
- package/starter/templates/literary-text/preview.tsx +20 -0
- package/starter/templates/literary-text/starter.tsx +11 -0
- package/starter/templates/literary-text/template.json +11 -0
- package/starter/templates/magazine-feature/AGENTS.md +11 -0
- package/starter/templates/magazine-feature/README.md +13 -0
- package/starter/templates/magazine-feature/index.tsx +41 -0
- package/starter/templates/magazine-feature/preview.tsx +34 -0
- package/starter/templates/magazine-feature/starter.tsx +15 -0
- package/starter/templates/magazine-feature/template.json +11 -0
- package/starter/templates/monthly-report/AGENTS.md +11 -0
- package/starter/templates/monthly-report/README.md +24 -0
- package/starter/templates/monthly-report/data.json +131 -0
- package/starter/templates/monthly-report/examples/long.json +519 -0
- package/starter/templates/monthly-report/examples/sparse.json +20 -0
- package/starter/templates/monthly-report/examples/typical.json +37 -0
- package/starter/templates/monthly-report/index.tsx +92 -0
- package/starter/templates/monthly-report/preview.tsx +14 -0
- package/starter/templates/monthly-report/schema.ts +127 -0
- package/starter/templates/monthly-report/starter.tsx +13 -0
- package/starter/templates/monthly-report/template.json +11 -0
- package/starter/templates/pitch-deck/AGENTS.md +32 -0
- package/starter/templates/pitch-deck/index.tsx +46 -0
- package/starter/templates/pitch-deck/preview.tsx +142 -0
- package/starter/templates/pitch-deck/starter.tsx +140 -0
- package/starter/templates/pitch-deck/template.json +15 -0
- package/starter/templates/proposal-deck/AGENTS.md +25 -0
- package/starter/templates/proposal-deck/index.tsx +52 -0
- package/starter/templates/proposal-deck/preview.tsx +172 -0
- package/starter/templates/proposal-deck/starter.tsx +168 -0
- package/starter/templates/proposal-deck/template.json +7 -0
- package/starter/templates/quotation/AGENTS.md +13 -0
- package/starter/templates/quotation/README.md +42 -0
- package/starter/templates/quotation/data.json +64 -0
- package/starter/templates/quotation/examples/long.json +272 -0
- package/starter/templates/quotation/examples/sparse.json +31 -0
- package/starter/templates/quotation/examples/typical.json +64 -0
- package/starter/templates/quotation/index.tsx +51 -0
- package/starter/templates/quotation/preview.tsx +12 -0
- package/starter/templates/quotation/schema.ts +27 -0
- package/starter/templates/quotation/starter.tsx +12 -0
- package/starter/templates/quotation/template.json +11 -0
- package/starter/templates/scientific-paper/AGENTS.md +11 -0
- package/starter/templates/scientific-paper/README.md +13 -0
- package/starter/templates/scientific-paper/index.tsx +47 -0
- package/starter/templates/scientific-paper/preview.tsx +43 -0
- package/starter/templates/scientific-paper/starter.tsx +15 -0
- package/starter/templates/scientific-paper/template.json +11 -0
- package/starter/themes/Specimen.tsx +54 -0
- package/starter/themes/civic-spectrum/components.tsx +92 -0
- package/starter/themes/civic-spectrum/design.md +70 -0
- package/starter/themes/civic-spectrum/index.ts +57 -0
- package/starter/themes/civic-spectrum/preview.tsx +66 -0
- package/starter/themes/field-manual/components.tsx +106 -0
- package/starter/themes/field-manual/design.md +72 -0
- package/starter/themes/field-manual/index.ts +57 -0
- package/starter/themes/field-manual/preview.tsx +82 -0
- package/starter/themes/index.ts +3 -0
- package/starter/themes/mckinsey-consulting/components.tsx +69 -0
- package/starter/themes/mckinsey-consulting/design.md +68 -0
- package/starter/themes/mckinsey-consulting/index.ts +60 -0
- package/starter/themes/mckinsey-consulting/preview.tsx +53 -0
- package/starter/themes/neutral/design.md +35 -0
- package/starter/themes/neutral/index.ts +21 -0
- package/starter/themes/neutral/preview.tsx +4 -0
- package/starter/themes/opendoc-neutral/components.tsx +77 -0
- package/starter/themes/opendoc-neutral/design.md +70 -0
- package/starter/themes/opendoc-neutral/index.ts +54 -0
- package/starter/themes/opendoc-neutral/preview.tsx +43 -0
- package/starter/themes/types.ts +3 -0
- package/tsconfig.workspace.json +24 -0
- package/vendor/formepdf/LICENSE +21 -0
- package/vendor/formepdf/README.md +97 -0
- package/vendor/formepdf/font-subset.patch +228 -0
- package/vendor/formepdf/text-writer.patch +507 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import type { TextEditInput, TextSourceValue, TextTarget } from '../shared/selection';
|
|
2
|
+
import { componentCorrection } from './componentCorrection';
|
|
3
|
+
|
|
4
|
+
export type PendingTextEdit = Pick<TextEditInput, 'targetId' | 'start' | 'end' | 'replacement'>;
|
|
5
|
+
export interface DraftTextEdit extends PendingTextEdit { sourceId: string }
|
|
6
|
+
export interface EditSessionBaseline { revision: number; hash: string; targets: TextTarget[] }
|
|
7
|
+
export interface EditSession extends EditSessionBaseline {
|
|
8
|
+
pending: DraftTextEdit[];
|
|
9
|
+
past: DraftTextEdit[][];
|
|
10
|
+
future: DraftTextEdit[][];
|
|
11
|
+
group?: { sourceId: string; at: number };
|
|
12
|
+
}
|
|
13
|
+
export interface EditSessionUpdate { session: EditSession; error?: string }
|
|
14
|
+
|
|
15
|
+
const HISTORY_LIMIT = 50;
|
|
16
|
+
const GROUP_MS = 500;
|
|
17
|
+
const MAX_REPLACEMENT = 8_000;
|
|
18
|
+
const STORAGE_PREFIX = 'opendoc:text-draft:';
|
|
19
|
+
|
|
20
|
+
/** Identity always belongs to the captured source, never the changing preview offsets. */
|
|
21
|
+
export function sourceIdentity(source: TextSourceValue): string {
|
|
22
|
+
return JSON.stringify([source.file, source.digest, source.start, source.end]);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function sourceBindings(targets: TextTarget[]) {
|
|
26
|
+
const bindings = new Map<string, { targetId: string; start: number; end: number; value: string }>();
|
|
27
|
+
for (const target of targets) for (const run of target.runs) {
|
|
28
|
+
if (!run.source || run.protected || run.source.value !== target.text.slice(run.start, run.end)) continue;
|
|
29
|
+
const id = sourceIdentity(run.source);
|
|
30
|
+
if (!bindings.has(id)) bindings.set(id, { targetId: target.id, start: run.start, end: run.end, value: run.source.value });
|
|
31
|
+
}
|
|
32
|
+
return bindings;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function createSession(baseline: EditSessionBaseline): EditSession {
|
|
36
|
+
return { revision: baseline.revision, hash: baseline.hash, targets: structuredClone(baseline.targets), pending: [], past: [], future: [] };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** An idle session must not bring old source text back after an external update. */
|
|
40
|
+
export function sessionForDocument(session: EditSession | null, document: { revision: number; hash?: string }): EditSession | null {
|
|
41
|
+
if (!session) return null;
|
|
42
|
+
return session.pending.length || session.future.length || (session.revision === document.revision && session.hash === document.hash) ? session : null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** These targets are for editing; page geometry still belongs to the rendered PDF. */
|
|
46
|
+
export function materializeTarget(session: EditSession, targetId: string): TextTarget | undefined {
|
|
47
|
+
const target = session.targets.find(target => target.id === targetId);
|
|
48
|
+
if (!target) return undefined;
|
|
49
|
+
const replacements = new Map(session.pending.map(edit => [edit.sourceId, edit.replacement]));
|
|
50
|
+
if (!target.runs.some(run => run.source && replacements.has(sourceIdentity(run.source)))) return target;
|
|
51
|
+
let text = '', cursor = 0;
|
|
52
|
+
const runs = target.runs.map(run => {
|
|
53
|
+
text += target.text.slice(cursor, run.start);
|
|
54
|
+
const start = text.length;
|
|
55
|
+
const replacement = run.source && replacements.get(sourceIdentity(run.source));
|
|
56
|
+
const value = typeof replacement === 'string' ? replacement : target.text.slice(run.start, run.end);
|
|
57
|
+
text += value;
|
|
58
|
+
cursor = run.end;
|
|
59
|
+
return { ...run, start, end: text.length, ...(run.source ? { source: { ...run.source, value } } : {}) };
|
|
60
|
+
});
|
|
61
|
+
text += target.text.slice(cursor);
|
|
62
|
+
return { ...target, text, runs };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function pendingEdits(session: EditSession): PendingTextEdit[] {
|
|
66
|
+
return session.pending.map(({ targetId, start, end, replacement }) => ({ targetId, start, end, replacement }));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function equalEdits(left: DraftTextEdit[], right: DraftTextEdit[]) {
|
|
70
|
+
return left.length === right.length && left.every((edit, index) => edit.sourceId === right[index].sourceId && edit.replacement === right[index].replacement);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function updateComponent(session: EditSession, targetId: string, text: string, now = Date.now()): EditSessionUpdate {
|
|
74
|
+
const target = materializeTarget(session, targetId);
|
|
75
|
+
if (!target) return { session, error: 'This component is no longer available.' };
|
|
76
|
+
if (text === target.text) return { session };
|
|
77
|
+
const correction = componentCorrection(target, text);
|
|
78
|
+
if (!correction) return { session, error: 'Change one text value at a time. Formatting and generated content need an agent.' };
|
|
79
|
+
if (correction.replacement.length > MAX_REPLACEMENT) return { session, error: 'Keep each text value under 8,000 characters.' };
|
|
80
|
+
const run = target.runs.find(run => run.source && !run.protected && run.start === correction.start && run.end === correction.end);
|
|
81
|
+
if (!run?.source) return { session, error: 'This text value is no longer editable.' };
|
|
82
|
+
const sourceId = sourceIdentity(run.source);
|
|
83
|
+
const binding = sourceBindings(session.targets).get(sourceId);
|
|
84
|
+
if (!binding) return { session, error: 'This text value is no longer editable.' };
|
|
85
|
+
const pending = session.pending.filter(edit => edit.sourceId !== sourceId);
|
|
86
|
+
if (correction.replacement !== binding.value) {
|
|
87
|
+
const edit = { sourceId, targetId: binding.targetId, start: binding.start, end: binding.end, replacement: correction.replacement };
|
|
88
|
+
// Keep a stable order when typing so history compares values, not edit order.
|
|
89
|
+
const previousIndex = session.pending.findIndex(edit => edit.sourceId === sourceId);
|
|
90
|
+
pending.splice(previousIndex < 0 ? pending.length : previousIndex, 0, edit);
|
|
91
|
+
}
|
|
92
|
+
if (equalEdits(pending, session.pending)) return { session };
|
|
93
|
+
const grouped = session.group?.sourceId === sourceId && now >= session.group.at && now - session.group.at <= GROUP_MS;
|
|
94
|
+
let past = grouped ? session.past : [...session.past, session.pending].slice(-HISTORY_LIMIT);
|
|
95
|
+
// Typing back to the beginning of a group should not leave an empty undo step.
|
|
96
|
+
const cancelled = past.length > 0 && equalEdits(pending, past[past.length - 1]);
|
|
97
|
+
if (cancelled) past = past.slice(0, -1);
|
|
98
|
+
return { session: { ...session, pending, past, future: [], group: cancelled ? undefined : { sourceId, at: now } } };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function undo(session: EditSession): EditSession {
|
|
102
|
+
if (!session.past.length) return session;
|
|
103
|
+
return { ...session, pending: session.past[session.past.length - 1], past: session.past.slice(0, -1), future: [...session.future, session.pending].slice(-HISTORY_LIMIT), group: undefined };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function redo(session: EditSession): EditSession {
|
|
107
|
+
if (!session.future.length) return session;
|
|
108
|
+
return { ...session, pending: session.future[session.future.length - 1], past: [...session.past, session.pending].slice(-HISTORY_LIMIT), future: session.future.slice(0, -1), group: undefined };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Rebase only after an explicit refresh; ambiguous or externally changed values stay untouched. */
|
|
112
|
+
export function rebaseSession(session: EditSession, baseline: EditSessionBaseline): EditSessionUpdate {
|
|
113
|
+
const next = createSession(baseline);
|
|
114
|
+
const bindings = sourceBindings(next.targets);
|
|
115
|
+
const pending = new Map<string, DraftTextEdit>();
|
|
116
|
+
const conflict = (): EditSessionUpdate => ({ session, error: 'Some edited text changed outside this draft. Keep the draft open and ask your agent to reconcile it.' });
|
|
117
|
+
for (const edit of session.pending) {
|
|
118
|
+
let nextSourceId: string | undefined;
|
|
119
|
+
for (const previousTarget of session.targets) {
|
|
120
|
+
const previousRuns = previousTarget.runs.filter(run => run.source && sourceIdentity(run.source) === edit.sourceId);
|
|
121
|
+
if (!previousRuns.length) continue;
|
|
122
|
+
const target = next.targets.find(target => target.id === previousTarget.id);
|
|
123
|
+
if (!target || target.stable === false || previousTarget.stable === false) return conflict();
|
|
124
|
+
for (const previousRun of previousRuns) {
|
|
125
|
+
const source = previousRun.source!;
|
|
126
|
+
const identity = (source as TextSourceValue & { bindingId?: string }).bindingId ?? sourceIdentity(source);
|
|
127
|
+
let candidates = target.runs.filter(run => run.source && !run.protected
|
|
128
|
+
&& ((run.source as TextSourceValue & { bindingId?: string }).bindingId ?? sourceIdentity(run.source)) === identity);
|
|
129
|
+
if (!candidates.length && target.text === previousTarget.text) {
|
|
130
|
+
candidates = target.runs.filter(run => run.source && !run.protected && run.start === previousRun.start && run.end === previousRun.end
|
|
131
|
+
&& run.source.file === source.file && run.source.kind === source.kind && run.source.value === source.value);
|
|
132
|
+
}
|
|
133
|
+
if (!candidates.length || new Set(candidates.map(run => sourceIdentity(run.source!))).size !== 1
|
|
134
|
+
|| candidates.some(run => run.source!.value !== source.value || target.text.slice(run.start, run.end) !== source.value)) return conflict();
|
|
135
|
+
const id = sourceIdentity(candidates[0].source!);
|
|
136
|
+
if (nextSourceId && nextSourceId !== id) return conflict();
|
|
137
|
+
nextSourceId = id;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (!nextSourceId) return conflict();
|
|
141
|
+
const binding = bindings.get(nextSourceId);
|
|
142
|
+
if (!binding) return conflict();
|
|
143
|
+
const existing = pending.get(nextSourceId);
|
|
144
|
+
if (existing && existing.replacement !== edit.replacement) return conflict();
|
|
145
|
+
pending.set(nextSourceId, { sourceId: nextSourceId, targetId: binding.targetId, start: binding.start, end: binding.end, replacement: edit.replacement });
|
|
146
|
+
}
|
|
147
|
+
next.pending = [...pending.values()];
|
|
148
|
+
next.past = next.pending.length ? [[]] : [];
|
|
149
|
+
return { session: next };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
type SessionStorage = Pick<Storage, 'getItem' | 'setItem' | 'removeItem'>;
|
|
153
|
+
type UnknownRecord = Record<string, unknown>;
|
|
154
|
+
function record(value: unknown): value is UnknownRecord { return !!value && typeof value === 'object' && !Array.isArray(value); }
|
|
155
|
+
function integer(value: unknown): value is number { return Number.isSafeInteger(value) && (value as number) >= 0; }
|
|
156
|
+
function finite(value: unknown): value is number { return typeof value === 'number' && Number.isFinite(value); }
|
|
157
|
+
function optionalString(value: unknown) { return value === undefined || typeof value === 'string'; }
|
|
158
|
+
function optionalBoolean(value: unknown) { return value === undefined || typeof value === 'boolean'; }
|
|
159
|
+
|
|
160
|
+
function validSource(value: unknown): value is TextSourceValue {
|
|
161
|
+
return record(value) && typeof value.file === 'string' && value.file.length > 0 && typeof value.digest === 'string' && value.digest.length > 0
|
|
162
|
+
&& integer(value.start) && integer(value.end) && value.end > value.start
|
|
163
|
+
&& ['jsx-text', 'jsx-attribute', 'string', 'json-string'].includes(value.kind as string) && typeof value.value === 'string'
|
|
164
|
+
&& optionalString(value.bindingId) && (value.linkedOccurrences === undefined || integer(value.linkedOccurrences));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function validTarget(value: unknown): value is TextTarget {
|
|
168
|
+
if (!record(value) || typeof value.id !== 'string' || !value.id || typeof value.blockId !== 'string' || !value.blockId || typeof value.slot !== 'string'
|
|
169
|
+
|| typeof value.text !== 'string' || !optionalBoolean(value.stable) || !optionalString(value.reason) || !Array.isArray(value.runs) || !Array.isArray(value.lines)) return false;
|
|
170
|
+
const text = value.text;
|
|
171
|
+
let previousEnd = 0;
|
|
172
|
+
for (const run of value.runs) {
|
|
173
|
+
if (!record(run) || !integer(run.start) || !integer(run.end) || run.start < previousEnd || run.end < run.start || run.end > text.length
|
|
174
|
+
|| !optionalBoolean(run.protected) || !optionalString(run.reason) || (run.source !== undefined && (!validSource(run.source) || run.source.value !== text.slice(run.start, run.end)))) return false;
|
|
175
|
+
previousEnd = run.end;
|
|
176
|
+
}
|
|
177
|
+
return value.lines.every(line => record(line) && integer(line.page) && line.page > 0 && finite(line.x) && finite(line.y) && finite(line.width) && line.width >= 0
|
|
178
|
+
&& finite(line.height) && line.height >= 0 && typeof line.text === 'string' && integer(line.start) && integer(line.end) && line.end >= line.start && line.end <= text.length);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** Validate against the saved baseline so source drift preserves a recoverable, stale draft. */
|
|
182
|
+
function restoredSession(value: unknown): EditSession | undefined {
|
|
183
|
+
if (!record(value) || value.version !== 1 || !record(value.session)) return undefined;
|
|
184
|
+
const session = value.session;
|
|
185
|
+
if (!integer(session.revision) || typeof session.hash !== 'string' || !session.hash || !Array.isArray(session.targets) || !session.targets.every(validTarget)
|
|
186
|
+
|| new Set(session.targets.map(target => target.id)).size !== session.targets.length) return undefined;
|
|
187
|
+
const targets = session.targets;
|
|
188
|
+
const sourceValues = new Map<string, string>();
|
|
189
|
+
for (const target of targets) for (const run of target.runs) if (run.source) {
|
|
190
|
+
const key = sourceIdentity(run.source);
|
|
191
|
+
if (sourceValues.has(key) && sourceValues.get(key) !== run.source.value) return undefined;
|
|
192
|
+
sourceValues.set(key, run.source.value);
|
|
193
|
+
}
|
|
194
|
+
const bindings = sourceBindings(targets);
|
|
195
|
+
function validSnapshot(snapshot: unknown): snapshot is DraftTextEdit[] {
|
|
196
|
+
if (!Array.isArray(snapshot) || snapshot.length > bindings.size) return false;
|
|
197
|
+
const ids = new Set<string>();
|
|
198
|
+
for (const edit of snapshot) {
|
|
199
|
+
if (!record(edit) || typeof edit.sourceId !== 'string' || ids.has(edit.sourceId) || typeof edit.replacement !== 'string' || edit.replacement.length > MAX_REPLACEMENT) return false;
|
|
200
|
+
const binding = bindings.get(edit.sourceId);
|
|
201
|
+
if (!binding || edit.targetId !== binding.targetId || edit.start !== binding.start || edit.end !== binding.end || edit.replacement === binding.value) return false;
|
|
202
|
+
ids.add(edit.sourceId);
|
|
203
|
+
}
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
if (!validSnapshot(session.pending) || !Array.isArray(session.past) || session.past.length > HISTORY_LIMIT || !session.past.every(validSnapshot)
|
|
207
|
+
|| !Array.isArray(session.future) || session.future.length > HISTORY_LIMIT || !session.future.every(validSnapshot)) return undefined;
|
|
208
|
+
// A reload is a fresh typing group. Only validated fields survive restoration.
|
|
209
|
+
return { revision: session.revision, hash: session.hash, targets, pending: session.pending, past: session.past, future: session.future };
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** Inject sessionStorage at the UI boundary; the model is also usable without a browser. */
|
|
213
|
+
export function createSessionStore(storage: SessionStorage | (() => SessionStorage)) {
|
|
214
|
+
const access = () => typeof storage === 'function' ? storage() : storage;
|
|
215
|
+
const key = (documentId: string) => `${STORAGE_PREFIX}${encodeURIComponent(documentId)}`;
|
|
216
|
+
return {
|
|
217
|
+
read(documentId: string, current?: Pick<EditSessionBaseline, 'revision' | 'hash'>): { session: EditSession; stale: boolean } | undefined {
|
|
218
|
+
try {
|
|
219
|
+
const raw = access().getItem(key(documentId));
|
|
220
|
+
if (raw === null) return undefined;
|
|
221
|
+
const session = restoredSession(JSON.parse(raw));
|
|
222
|
+
if (!session) { access().removeItem(key(documentId)); return undefined; }
|
|
223
|
+
return { session, stale: !!current && (session.revision !== current.revision || session.hash !== current.hash) };
|
|
224
|
+
} catch {
|
|
225
|
+
try { access().removeItem(key(documentId)); } catch { /* Storage itself may be unavailable. */ }
|
|
226
|
+
return undefined;
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
write(documentId: string, session: EditSession): boolean {
|
|
230
|
+
try { access().setItem(key(documentId), JSON.stringify({ version: 1, session: { ...session, group: undefined, past: session.past.slice(-HISTORY_LIMIT), future: session.future.slice(-HISTORY_LIMIT) } })); return true; }
|
|
231
|
+
catch { return false; }
|
|
232
|
+
},
|
|
233
|
+
clear(documentId: string): boolean {
|
|
234
|
+
try { access().removeItem(key(documentId)); return true; }
|
|
235
|
+
catch { return false; }
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface EditorBaseline { hash: string; revision: number; text: string }
|
|
2
|
+
export interface OpenEditorRecord { targetId: string; text: string; baseline?: EditorBaseline }
|
|
3
|
+
export interface EditorRecovery { record: OpenEditorRecord; stage: boolean; error?: string }
|
|
4
|
+
|
|
5
|
+
export function readOpenEditor(value: unknown): OpenEditorRecord | undefined {
|
|
6
|
+
if (!value || typeof value !== 'object') return undefined;
|
|
7
|
+
const record = value as Partial<OpenEditorRecord>;
|
|
8
|
+
if (typeof record.targetId !== 'string' || typeof record.text !== 'string' || record.text.length > 8000) return undefined;
|
|
9
|
+
const baseline = record.baseline;
|
|
10
|
+
return { targetId: record.targetId, text: record.text, ...(baseline && typeof baseline.hash === 'string' && Number.isInteger(baseline.revision) && typeof baseline.text === 'string' ? { baseline } : {}) };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Raw editor recovery cannot establish a new source baseline for old wording. */
|
|
14
|
+
export function recoverEditor(record: OpenEditorRecord, current: EditorBaseline, pending?: EditorBaseline, typing = false): EditorRecovery {
|
|
15
|
+
const unchanged = !!record.baseline && record.text === record.baseline.text;
|
|
16
|
+
// A validated pending session already owns this exact text and its source guards.
|
|
17
|
+
// An untouched older editor must also not undo a newer accepted draft on restore.
|
|
18
|
+
if (pending && (record.text === pending.text || (!typing && unchanged))) return { record: { ...record, text: pending.text, baseline: pending }, stage: false };
|
|
19
|
+
if (!record.baseline && record.text === current.text) return { record: { ...record, baseline: current }, stage: false };
|
|
20
|
+
if (!record.baseline) return { record, stage: false, error: 'This recovered text needs review before it can join your draft.' };
|
|
21
|
+
const matches = record.baseline.hash === current.hash && record.baseline.revision === current.revision;
|
|
22
|
+
if (matches) return { record, stage: record.text !== (pending?.text ?? current.text) };
|
|
23
|
+
if (unchanged && !typing) return { record: { ...record, text: current.text, baseline: current }, stage: false };
|
|
24
|
+
return { record, stage: false, error: 'The document changed. Your text is kept here for review.' };
|
|
25
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
.help-dialog.export-history-dialog { width: min(660px, calc(100vw - 32px)); max-width: 660px; max-height: min(780px, calc(100dvh - 48px)); display: flex; flex-direction: column; padding: 28px; }
|
|
2
|
+
.export-history-heading { display: flex; align-items: center; gap: 14px; padding-right: 26px; min-width: 0; }
|
|
3
|
+
.export-history-heading > div { min-width: 0; }
|
|
4
|
+
.help-dialog .export-history-heading h2 { margin: 0 0 5px; }
|
|
5
|
+
.help-dialog .export-history-heading p { margin: 0; overflow-wrap: anywhere; }
|
|
6
|
+
.export-history-symbol { color: var(--muted); display: grid; place-items: center; flex: 0 0 44px; height: 44px; background: var(--surface-alt); border: 1px solid var(--line); border-radius: 12px; }
|
|
7
|
+
.export-history-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 22px 0 8px; color: var(--muted); font-size: 12px; }
|
|
8
|
+
.export-history-summary .text-button { font-size: 12px; }
|
|
9
|
+
.export-history-content { overflow-y: auto; min-height: 110px; overscroll-behavior: contain; margin: 0 -8px; padding: 0 8px; }
|
|
10
|
+
.export-history-list { list-style: none; padding: 0; margin: 0; }
|
|
11
|
+
.export-history-row { display: flex; align-items: center; gap: 14px; padding: 16px 0; border-top: 1px solid var(--line); }
|
|
12
|
+
.export-history-paper { width: 40px; height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0; gap: 2px; color: var(--muted); background: var(--surface-alt); border: 1px solid var(--line); border-radius: 5px; }
|
|
13
|
+
.export-history-paper > span { font-size: 8px; font-weight: 650; letter-spacing: .08em; }
|
|
14
|
+
.export-history-details { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 6px; }
|
|
15
|
+
.export-history-details > a, .export-history-details > strong { font-size: 13px; font-weight: 550; line-height: 1.45; color: var(--ink); overflow-wrap: anywhere; text-decoration: none; }
|
|
16
|
+
.export-history-details > a:hover { text-decoration: underline; text-underline-offset: 3px; }
|
|
17
|
+
.export-history-details > span { font-size: 11px; color: var(--muted); line-height: 1.5; }
|
|
18
|
+
.export-history-actions { display: flex; align-items: center; gap: 2px; }
|
|
19
|
+
.export-history-actions .icon-button { width: 32px; height: 32px; }
|
|
20
|
+
.export-history-delete:hover:not(:disabled) { color: var(--destructive); }
|
|
21
|
+
.export-history-empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 32px 16px; gap: 12px; color: var(--muted); }
|
|
22
|
+
.export-history-empty strong { font-size: 14px; color: var(--ink); }
|
|
23
|
+
.export-history-empty p { font-size: 13px; margin: 0; }
|
|
24
|
+
.help-dialog .export-history-footnote { font-size: 11px; line-height: 1.6; color: var(--muted); padding-top: 16px; margin: 8px 0 0; border-top: 1px solid var(--line); }
|
|
25
|
+
@media (max-width: 520px) {
|
|
26
|
+
.help-dialog.export-history-dialog { padding: 22px 18px; }
|
|
27
|
+
.export-history-row { gap: 10px; flex-wrap: wrap; }
|
|
28
|
+
.export-history-actions { margin-left: auto; }
|
|
29
|
+
.export-history-paper { display: none; }
|
|
30
|
+
.export-history-details { flex-basis: calc(100% - 110px); }
|
|
31
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
.export-dropdown { width: 320px; }
|
|
2
|
+
.export-dropdown-body { padding: 8px; }
|
|
3
|
+
.export-dropdown-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
|
|
4
|
+
.export-dropdown-heading h2 { margin: 0; font-size: var(--title-size); line-height: var(--title-leading); font-weight: 500; }
|
|
5
|
+
.export-dropdown-heading .icon-button { margin: -4px -4px -4px 0; }
|
|
6
|
+
.export-dropdown-body > p { margin: 6px 0 0; color: var(--muted); font-size: var(--label-size); line-height: 1.5; }
|
|
7
|
+
.export-dropdown .export-filename { display: grid; gap: 8px; margin-top: 18px; }
|
|
8
|
+
.export-format { display: grid; gap: 8px; margin-top: 16px; }
|
|
9
|
+
.export-format .ui-select { width: 100%; justify-content: space-between; }
|
|
10
|
+
.export-file { display: flex; align-items: center; gap: 10px; padding-block: 16px 6px; }
|
|
11
|
+
.export-file > div { flex: 1; min-width: 0; }
|
|
12
|
+
.export-file strong { display: block; font-size: var(--label-size); font-weight: 500; overflow-wrap: anywhere; }
|
|
13
|
+
.export-file span { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); }
|
|
14
|
+
.export-status { padding: 10px; margin: 12px 0 0; background: var(--surface-raised); border: 1px solid var(--control-line); border-radius: var(--control-radius); font-size: var(--label-size); line-height: 1.5; }
|
|
15
|
+
.export-status p { margin: 6px 0 10px; }
|
|
16
|
+
.export-dropdown-body > .field-error { color: var(--destructive); }
|
|
17
|
+
.export-save { width: 100%; justify-content: center; margin-top: 16px; }
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type GuideLocation = { file: string; fragment?: string };
|
|
2
|
+
type GuideLink = { kind: 'guide'; location: GuideLocation } | { kind: 'external'; href: string };
|
|
3
|
+
|
|
4
|
+
/** Resolve links against the guide file, never the app's URL or navigation hash. */
|
|
5
|
+
export function resolveGuideLink(file: string, href: string): GuideLink | undefined {
|
|
6
|
+
href = href.trim();
|
|
7
|
+
if (!href) return undefined;
|
|
8
|
+
if (/^(https?:)?\/\//i.test(href)) return { kind: 'external', href };
|
|
9
|
+
if (/^[a-z][a-z\d+.-]*:/i.test(href) || href.includes('\\')) return undefined;
|
|
10
|
+
try {
|
|
11
|
+
const url = new URL(href, `https://guides.invalid/${file}`);
|
|
12
|
+
if (url.origin !== 'https://guides.invalid') return undefined;
|
|
13
|
+
const path = decodeURIComponent(url.pathname).replace(/^\/+/, '');
|
|
14
|
+
if (!path.endsWith('.md')) return undefined;
|
|
15
|
+
return { kind: 'guide', location: { file: path, ...(url.hash ? { fragment: decodeURIComponent(url.hash.slice(1)) } : {}) } };
|
|
16
|
+
} catch { return undefined; }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function guideHeadingSlug(text: string) {
|
|
20
|
+
return text.trim().toLowerCase().replace(/[^\p{L}\p{N}\s_-]/gu, '').replace(/\s+/g, '-');
|
|
21
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
.template-guide-trigger { margin-top: 12px; }
|
|
2
|
+
.help-dialog.template-guide-dialog { width: min(760px, calc(100vw - 32px)); max-width: 760px; padding: 0; overflow: hidden; display: flex; flex-direction: column; }
|
|
3
|
+
.template-guide-heading { position: relative; padding: 24px 64px 20px 32px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
|
|
4
|
+
.template-guide-dialog .template-guide-heading h2 { font-size: var(--title-size); line-height: var(--title-leading); font-weight: 500; margin: 0; }
|
|
5
|
+
.template-guide-dialog .template-guide-heading p { margin: 5px 0 0; font-size: 13px; }
|
|
6
|
+
.template-guide-body { padding: 28px 32px 36px; overflow-y: auto; overscroll-behavior: contain; min-height: 0; overflow-wrap: anywhere; }
|
|
7
|
+
.template-guide-body:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -4px; }
|
|
8
|
+
.template-guide-body > p:first-child, .template-guide-body > div > p:first-child { margin-top: 0; }
|
|
9
|
+
.markdown-body { font-size: 15px; line-height: 1.75; color: var(--ink); }
|
|
10
|
+
.template-guide-dialog .markdown-body :is(h1, h2, h3, h4, h5, h6) { font-family: inherit; color: var(--ink); line-height: 1.3; letter-spacing: -0.02em; margin: 1.6em 0 0.65em; font-weight: 600; }
|
|
11
|
+
.markdown-body h1 { font-size: 26px; }
|
|
12
|
+
.template-guide-dialog .markdown-body h2 { font-size: 21px; }
|
|
13
|
+
.markdown-body h3 { font-size: 18px; }
|
|
14
|
+
.markdown-body :is(h4, h5, h6) { font-size: 16px; }
|
|
15
|
+
.markdown-body > :first-child { margin-top: 0; }
|
|
16
|
+
.markdown-body > :last-child { margin-bottom: 0; }
|
|
17
|
+
.template-guide-dialog .markdown-body p { color: inherit; font-size: inherit; line-height: inherit; margin: 0 0 1em; }
|
|
18
|
+
.markdown-body :is(ul, ol) { padding-left: 24px; margin: 0 0 1em; }
|
|
19
|
+
.markdown-body li + li { margin-top: 0.4em; }
|
|
20
|
+
.markdown-body li > :is(ul, ol) { margin: 0.4em 0; }
|
|
21
|
+
.markdown-body li > p { margin-bottom: 0.5em; }
|
|
22
|
+
.markdown-body a { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; }
|
|
23
|
+
.markdown-body code { font-family: ui-monospace, monospace; font-size: 0.88em; background: var(--surface-alt); padding: 2px 5px; border-radius: 4px; }
|
|
24
|
+
.markdown-body pre { overflow-x: auto; padding: 16px; margin: 0 0 1em; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; line-height: 1.6; }
|
|
25
|
+
.markdown-body pre code { padding: 0; background: none; border-radius: 0; overflow-wrap: normal; }
|
|
26
|
+
.markdown-body blockquote { margin: 0 0 1em; padding: 2px 0 2px 18px; border-left: 3px solid var(--line-strong); color: var(--muted); }
|
|
27
|
+
.markdown-body blockquote > :last-child { margin-bottom: 0; }
|
|
28
|
+
.markdown-body hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
|
|
29
|
+
.markdown-body img { max-width: 100%; height: auto; }
|
|
30
|
+
.markdown-table { overflow-x: auto; margin-bottom: 1em; }
|
|
31
|
+
.markdown-body table { border-collapse: collapse; width: 100%; font-size: 14px; }
|
|
32
|
+
.markdown-body :is(th, td) { padding: 9px 12px; border: 1px solid var(--line); text-align: left; }
|
|
33
|
+
.markdown-body th { background: var(--surface); font-weight: 600; }
|
|
34
|
+
.markdown-body .contains-task-list { list-style: none; padding-left: 0; }
|
|
35
|
+
.markdown-body .task-list-item input { margin-right: 8px; }
|
|
36
|
+
.guide-back { margin-top: 8px; }
|
|
37
|
+
@media (max-width: 620px) {
|
|
38
|
+
.template-guide-heading { padding: 20px 56px 16px 20px; }
|
|
39
|
+
.template-guide-body { padding: 24px 20px 28px; }
|
|
40
|
+
}
|
package/src/app/main.tsx
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { ExportHistoryDialog } from "./ExportHistoryDialog";
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
|
+
import { createRoot } from "react-dom/client";
|
|
4
|
+
import { AssetsBrowser } from "./AssetsBrowser";
|
|
5
|
+
import { TemplatesBrowser } from "./TemplatesBrowser";
|
|
6
|
+
import { ThemesBrowser } from "./ThemesBrowser";
|
|
7
|
+
import { Reader } from "./Reader";
|
|
8
|
+
import { CreateDocumentDialog } from "./CreateDocumentDialog";
|
|
9
|
+
import { ProjectDialog, MoveDocumentDialog } from "./ProjectDialogs";
|
|
10
|
+
import { ProjectDocuments, DocumentsBrowser } from "./DocumentsBrowser";
|
|
11
|
+
import { Sidebar } from "./Sidebar";
|
|
12
|
+
import { AppearanceMenuItems } from "./AppearanceControl";
|
|
13
|
+
import { DocumentActionDialog, DocumentMenuItems, type DocumentActionHandler } from "./DocumentActions";
|
|
14
|
+
import { useAppearance } from "./appearance";
|
|
15
|
+
import { useDocumentView } from "./DocumentViewControl";
|
|
16
|
+
import { Icon } from "./ui/Icon";
|
|
17
|
+
import { Button, IconButton, UiProvider, useNotifications } from "./ui";
|
|
18
|
+
import { api } from "./api";
|
|
19
|
+
import type { ThemeSummary } from "../shared/themes";
|
|
20
|
+
import { documentName, documentFormat, type DocumentFormat, type DocumentState, type DocumentSummary } from "../shared/types";
|
|
21
|
+
import { emptyProjects, type Project, type ProjectsManifest } from "../shared/projects";
|
|
22
|
+
import "./style.css";
|
|
23
|
+
|
|
24
|
+
function route() {
|
|
25
|
+
const hash = location.hash.slice(1);
|
|
26
|
+
if (hash === "presentations") return { view: "presentations", id: "" };
|
|
27
|
+
if (hash === "themes" || hash.startsWith("themes/")) return { view: "themes", id: hash.slice(7) };
|
|
28
|
+
const [templatePath, templateQuery] = hash.split('?');
|
|
29
|
+
if (templatePath === "templates" || templatePath.startsWith("templates/")) return { view: "templates", id: templatePath.slice(10), templateFormat: new URLSearchParams(templateQuery).get('format') === 'presentation' ? 'presentation' as const : 'document' as const };
|
|
30
|
+
if (hash === "assets" || hash.startsWith("assets/")) return { view: "assets", id: hash.slice(7) || "media" };
|
|
31
|
+
if (hash === "media" || hash.startsWith("media/")) return { view: "assets", id: `media${hash.length > 5 ? `/${hash.slice(6)}` : ""}` };
|
|
32
|
+
if (hash.startsWith("project/")) return { view: "project", id: hash.slice(8) };
|
|
33
|
+
return hash.startsWith("document/")
|
|
34
|
+
? { view: "document", id: hash.slice(9) }
|
|
35
|
+
: { view: "library", id: "" };
|
|
36
|
+
}
|
|
37
|
+
const go = (hash: string) => { location.hash = hash; };
|
|
38
|
+
|
|
39
|
+
function App() {
|
|
40
|
+
const { appearance, changeAppearance } = useAppearance();
|
|
41
|
+
const { view: documentView, changeView: changeDocumentView } = useDocumentView();
|
|
42
|
+
const [current, setCurrent] = useState(route);
|
|
43
|
+
const lastBrowseRoute = useRef<ReturnType<typeof route> | null>(null);
|
|
44
|
+
useEffect(() => { if (current.view !== "document") lastBrowseRoute.current = current; }, [current]);
|
|
45
|
+
const [documents, setDocuments] = useState<DocumentSummary[]>([]);
|
|
46
|
+
const [themes, setThemes] = useState<ThemeSummary[]>([]);
|
|
47
|
+
const [manifest, setManifest] = useState<ProjectsManifest>(emptyProjects);
|
|
48
|
+
const [error, setError] = useState("");
|
|
49
|
+
const [connected, setConnected] = useState(true);
|
|
50
|
+
const [help, setHelp] = useState(false);
|
|
51
|
+
const [creationFormat, setCreationFormat] = useState<DocumentFormat>('document');
|
|
52
|
+
const [projectDialog, setProjectDialog] = useState<{ project: Project | null } | null>(null);
|
|
53
|
+
const notifications = useNotifications();
|
|
54
|
+
const [exportDocument, setExportDocument] = useState<DocumentSummary | null>(null);
|
|
55
|
+
const [documentAction, setDocumentAction] = useState<{ document: DocumentSummary; action: "rename" | "delete" } | null>(null);
|
|
56
|
+
const [duplicating, setDuplicating] = useState(false);
|
|
57
|
+
const copying = useRef(false);
|
|
58
|
+
const [moving, setMoving] = useState<DocumentSummary | null>(null);
|
|
59
|
+
const [generation, setGeneration] = useState(0);
|
|
60
|
+
const [loaded, setLoaded] = useState(false);
|
|
61
|
+
const refreshing = useRef<Promise<void> | null>(null);
|
|
62
|
+
const refreshAgain = useRef(false);
|
|
63
|
+
const requestAbort = useRef<AbortController | null>(null);
|
|
64
|
+
const refresh = useCallback(() => {
|
|
65
|
+
refreshAgain.current = true;
|
|
66
|
+
if (refreshing.current) return refreshing.current;
|
|
67
|
+
refreshing.current = (async () => {
|
|
68
|
+
do {
|
|
69
|
+
refreshAgain.current = false;
|
|
70
|
+
try {
|
|
71
|
+
const [next, projects, nextThemes] = await Promise.all([
|
|
72
|
+
api<DocumentSummary[]>("/api/documents?view=summary", { signal: requestAbort.current?.signal }),
|
|
73
|
+
api<ProjectsManifest>("/api/projects", { signal: requestAbort.current?.signal }),
|
|
74
|
+
api<ThemeSummary[]>("/api/themes", { signal: requestAbort.current?.signal }),
|
|
75
|
+
]);
|
|
76
|
+
if (requestAbort.current?.signal.aborted) return;
|
|
77
|
+
setManifest(projects);
|
|
78
|
+
setThemes(nextThemes);
|
|
79
|
+
setDocuments((previous) => {
|
|
80
|
+
const existing = new Map(previous.map((item) => [item.id, item]));
|
|
81
|
+
const merged = next.map((item) => {
|
|
82
|
+
const before = existing.get(item.id);
|
|
83
|
+
return before && JSON.stringify(before) === JSON.stringify(item) ? before : item;
|
|
84
|
+
});
|
|
85
|
+
return merged.length === previous.length && merged.every((item, index) => item === previous[index]) ? previous : merged;
|
|
86
|
+
});
|
|
87
|
+
setError(""); setLoaded(true); setGeneration((value) => value + 1);
|
|
88
|
+
} catch (error) { if (!requestAbort.current?.signal.aborted) setError((error as Error).message); }
|
|
89
|
+
} while (refreshAgain.current && !requestAbort.current?.signal.aborted);
|
|
90
|
+
})().finally(() => { refreshing.current = null; });
|
|
91
|
+
return refreshing.current;
|
|
92
|
+
}, []);
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
requestAbort.current = new AbortController();
|
|
95
|
+
void refresh();
|
|
96
|
+
let events: WebSocket;
|
|
97
|
+
let stopped = false;
|
|
98
|
+
let reconnectTimer: ReturnType<typeof setTimeout> | undefined;
|
|
99
|
+
let reconnectDelay = 500;
|
|
100
|
+
let refreshTimer: ReturnType<typeof setTimeout> | undefined;
|
|
101
|
+
const connect = () => {
|
|
102
|
+
events = new WebSocket(`${location.protocol === 'https:' ? 'wss:' : 'ws:'}//${location.host}/api/events`);
|
|
103
|
+
events.onopen = () => { reconnectDelay = 500; setConnected(true); };
|
|
104
|
+
events.onmessage = (event) => {
|
|
105
|
+
if (stopped || !['connected', 'changed'].includes(event.data)) return;
|
|
106
|
+
// Catch up after every connection, including changes during initial loading.
|
|
107
|
+
clearTimeout(refreshTimer); refreshTimer = setTimeout(() => void refresh(), 80);
|
|
108
|
+
};
|
|
109
|
+
events.onerror = () => { setConnected(false); events.close(); };
|
|
110
|
+
events.onclose = () => {
|
|
111
|
+
if (stopped) return;
|
|
112
|
+
setConnected(false);
|
|
113
|
+
reconnectTimer = setTimeout(connect, reconnectDelay);
|
|
114
|
+
reconnectDelay = Math.min(reconnectDelay * 2, 5_000);
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
connect();
|
|
118
|
+
const change = () => setCurrent(route());
|
|
119
|
+
window.addEventListener("hashchange", change);
|
|
120
|
+
return () => { stopped = true; clearTimeout(reconnectTimer); events.close(); clearTimeout(refreshTimer); requestAbort.current?.abort(); window.removeEventListener("hashchange", change); };
|
|
121
|
+
}, [refresh]);
|
|
122
|
+
const activeSummary = current.view === "document" ? documents.find(document => document.id === current.id) : undefined;
|
|
123
|
+
const [detail, setDetail] = useState<{ key: string; state: DocumentState }>();
|
|
124
|
+
const [detailAttempt, setDetailAttempt] = useState(0);
|
|
125
|
+
const [detailError, setDetailError] = useState('');
|
|
126
|
+
const detailKey = activeSummary ? JSON.stringify(activeSummary) : '';
|
|
127
|
+
const activeId = activeSummary?.id;
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
if (!activeId) return;
|
|
130
|
+
const controller = new AbortController();
|
|
131
|
+
setDetailError('');
|
|
132
|
+
void api<DocumentState>(`/api/documents/${activeId}`, { signal: controller.signal })
|
|
133
|
+
.then(state => { if (!controller.signal.aborted) setDetail({ key: detailKey, state }); })
|
|
134
|
+
.catch(error => { if (!controller.signal.aborted) setDetailError(error.message); });
|
|
135
|
+
return () => controller.abort();
|
|
136
|
+
}, [activeId, detailKey, detailAttempt]);
|
|
137
|
+
// Keep the previous PDF visible during a refresh, with currentness controls disabled.
|
|
138
|
+
const active: DocumentState | undefined = activeSummary ? detail?.key === detailKey ? detail.state : {
|
|
139
|
+
...activeSummary, status: 'rendering', artifact: detail?.state.id === activeSummary.id ? detail.state.artifact : undefined,
|
|
140
|
+
} : undefined;
|
|
141
|
+
const routeProjectId = current.view === "project" ? current.id : active?.projectId;
|
|
142
|
+
const project = manifest.projects.find(project => project.id === routeProjectId);
|
|
143
|
+
const origin = lastBrowseRoute.current;
|
|
144
|
+
const originProject = origin?.view === "project" ? manifest.projects.find(project => project.id === origin.id) : undefined;
|
|
145
|
+
const backHash = origin
|
|
146
|
+
? origin.view === "project" ? originProject ? `project/${originProject.id}` : "library" : `${origin.view}${origin.id ? `/${origin.id}` : ""}${origin.view === 'templates' && origin.templateFormat === 'presentation' ? '?format=presentation' : ''}`
|
|
147
|
+
: project ? `project/${project.id}` : activeSummary && documentFormat(activeSummary) === "presentation" ? "presentations" : "library";
|
|
148
|
+
const backLabel = origin
|
|
149
|
+
? origin.view === "project" ? originProject?.name ?? "Documents" : ({ library: "Documents", presentations: "Presentations", assets: "Media & Assets", templates: "Templates", themes: "Themes" }[origin.view] ?? "Documents")
|
|
150
|
+
: project?.name ?? (activeSummary && documentFormat(activeSummary) === "presentation" ? "Presentations" : "Documents");
|
|
151
|
+
const projectDocuments = documents.filter(document => document.projectId === project?.id);
|
|
152
|
+
useEffect(() => {
|
|
153
|
+
if (current.view !== "document" && current.view !== "assets" && current.view !== "themes") void api("/api/context", {
|
|
154
|
+
method: "POST", body: JSON.stringify({ projectId: current.view === "project" ? project?.id ?? null : null, documentId: null, blockId: null, page: 1, themeId: null, selectedAsset: null }),
|
|
155
|
+
}).catch(() => {});
|
|
156
|
+
}, [current.view, project?.id]);
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
document.title = active ? `${documentName(active)} · OpenDoc` : project ? `${project.name} · OpenDoc` : "OpenDoc";
|
|
159
|
+
}, [active?.artifact?.meta.title, active?.name, active?.id, project?.name]);
|
|
160
|
+
const onDocumentAction: DocumentActionHandler = (document, action) => {
|
|
161
|
+
if (action === "exports") { setExportDocument(document); return; }
|
|
162
|
+
if (action === "move") { setMoving(document); return; }
|
|
163
|
+
if (action !== "duplicate") { setDocumentAction({ document, action }); return; }
|
|
164
|
+
if (copying.current || !connected) return;
|
|
165
|
+
copying.current = true; setDuplicating(true);
|
|
166
|
+
void api<{ id: string; name: string }>(`/api/documents/${document.id}/duplicate`, { method: 'POST' }).then(async copy => {
|
|
167
|
+
await refresh();
|
|
168
|
+
notifications.success(`${copy.name} created`, { label: 'Open', onClick: () => go(`document/${copy.id}`) });
|
|
169
|
+
}).catch(error => notifications.error(error.message)).finally(() => { copying.current = false; setDuplicating(false); });
|
|
170
|
+
};
|
|
171
|
+
const createProject = () => setProjectDialog({ project: null });
|
|
172
|
+
const createDocument = (format: DocumentFormat = 'document') => { setCreationFormat(format); setHelp(true); };
|
|
173
|
+
return <div className={`app ${current.view === "document" ? "reading" : ""}`}>
|
|
174
|
+
{current.view !== "document" && <Sidebar view={current.view} projectId={project?.id} projects={manifest.projects} documents={documents} loaded={loaded} connected={connected} appearance={appearance} onAppearanceChange={changeAppearance} onCreateProject={createProject} onProjectSettings={project => setProjectDialog({ project })} />}
|
|
175
|
+
<main className="main">
|
|
176
|
+
{current.view === "document" && !active && <header className="topbar">
|
|
177
|
+
<IconButton label={`Back to ${backLabel}`} render={<a href={`#${backHash}`} />} nativeButton={false}><Icon name="left" /></IconButton>
|
|
178
|
+
<div className="breadcrumb"><a href={project ? `#project/${project.id}` : "#library"} title={project?.name ?? "Documents"}>{project?.name ?? "Documents"}</a><span>/</span><span>Document</span></div>
|
|
179
|
+
</header>}
|
|
180
|
+
{!connected && <div className="connection-banner" role="status">Connection lost. Reconnecting to OpenDoc. Editing and export will resume when the server returns.</div>}
|
|
181
|
+
{detailError && activeSummary && <div className="error-banner" role="alert"><span>{detailError}</span><Button onClick={() => setDetailAttempt(value => value + 1)}>Try again</Button></div>}
|
|
182
|
+
{error && <div className="error-banner" role="alert"><span>{error}</span><Button className="text-button" onClick={() => void refresh()}>Try again</Button></div>}
|
|
183
|
+
{current.view === "document" ? active ? <Reader key={active.id} state={active} generation={generation} connected={connected} onShowExports={() => setExportDocument(active)}
|
|
184
|
+
identity={<>
|
|
185
|
+
<IconButton label={`Back to ${backLabel}`} className="reader-back" render={<a href={`#${backHash}`} />} nativeButton={false}><Icon name="left" size={17} /></IconButton>
|
|
186
|
+
<div className="reader-document"><a href={project ? `#project/${project.id}` : "#library"} title={project?.name ?? "Documents"}>{project?.name ?? "Documents"}</a><span className="reader-context-separator" aria-hidden="true">/</span><span className="reader-document-title" title={documentName(active)}>{documentName(active)}</span></div>
|
|
187
|
+
</>}
|
|
188
|
+
options={<>
|
|
189
|
+
<DocumentMenuItems document={active} onAction={onDocumentAction} disabled={!connected || duplicating} />
|
|
190
|
+
<AppearanceMenuItems value={appearance} onChange={changeAppearance} />
|
|
191
|
+
</>}
|
|
192
|
+
/> : <div className="empty-state"><h1>{loaded ? "Document not found" : error ? "Workspace unavailable" : "Loading document…"}</h1><p>{loaded ? "Its source may have been moved or removed from this workspace." : "Opening your local workspace."}</p><Button onClick={() => go("library")}>Back to documents</Button></div>
|
|
193
|
+
: current.view === "project" ? project ? <ProjectDocuments key={project.id} project={project} documents={projectDocuments} loaded={loaded} view={documentView} onViewChange={changeDocumentView} onCreate={() => createDocument()} onCreatePresentation={() => createDocument('presentation')} onSettings={() => setProjectDialog({ project })} onAction={onDocumentAction} disabled={!connected || duplicating} /> : <div className="empty-state"><h1>{loaded ? "Project not found" : "Loading project…"}</h1><p>{loaded ? "It may have been removed. Your other projects are still available." : "Opening your local workspace."}</p><Button onClick={() => go("library")}>Back to documents</Button></div>
|
|
194
|
+
: current.view === "assets" ? <AssetsBrowser selection={current.id} generation={generation} documents={documents} themes={themes} connected={connected} />
|
|
195
|
+
: current.view === "templates" ? <TemplatesBrowser selection={current.id} generation={generation} format={current.templateFormat} />
|
|
196
|
+
: current.view === "themes" ? <ThemesBrowser connected={connected} themes={themes} selection={current.id} generation={generation} loaded={loaded} documents={documents} projects={manifest.projects} onRefresh={() => void refresh()} /> : <DocumentsBrowser key={current.view} format={current.view === 'presentations' ? 'presentation' : 'document'} projects={manifest.projects} documents={documents.filter(document => documentFormat(document) === (current.view === 'presentations' ? 'presentation' : 'document'))} loaded={loaded} view={documentView} onViewChange={changeDocumentView} onCreate={() => createDocument(current.view === 'presentations' ? 'presentation' : 'document')} onMove={setMoving} onAction={onDocumentAction} disabled={!connected || duplicating} />}
|
|
197
|
+
</main>
|
|
198
|
+
<CreateDocumentDialog format={creationFormat} open={help} onOpenChange={setHelp} project={project} />
|
|
199
|
+
<ProjectDialog themes={themes} open={Boolean(projectDialog)} project={projectDialog?.project ?? null} documentCount={documents.filter(document => document.projectId === projectDialog?.project?.id).length} connected={connected} onOpenChange={open => { if (!open) setProjectDialog(null); }} onSaved={saved => {
|
|
200
|
+
setManifest(previous => ({ ...previous, projects: previous.projects.some(project => project.id === saved.id) ? previous.projects.map(project => project.id === saved.id ? saved : project) : [...previous.projects, saved] }));
|
|
201
|
+
go(`project/${saved.id}`); void refresh();
|
|
202
|
+
}} onDeleted={() => { setManifest(previous => ({ ...previous, projects: previous.projects.filter(project => project.id !== projectDialog?.project?.id) })); go("library"); void refresh(); }} />
|
|
203
|
+
<ExportHistoryDialog document={exportDocument} connected={connected} onClose={() => setExportDocument(null)} />
|
|
204
|
+
<DocumentActionDialog selection={documentAction} connected={connected} onClose={() => setDocumentAction(null)} onRenamed={(id, name) => {
|
|
205
|
+
setDocuments(previous => previous.map(document => document.id === id ? { ...document, name } : document)); void refresh();
|
|
206
|
+
}} onDeleted={(document, restoreId) => {
|
|
207
|
+
setDocuments(previous => previous.filter(item => item.id !== document.id));
|
|
208
|
+
if (current.view === 'document' && current.id === document.id) go(document.projectId ? `project/${document.projectId}` : documentFormat(document) === 'presentation' ? 'presentations' : 'library');
|
|
209
|
+
void refresh();
|
|
210
|
+
notifications.success(`${documentName(document)} deleted`, { label: 'Undo', onClick: async () => {
|
|
211
|
+
await api(`/api/document-trash/${restoreId}/restore`, { method: 'POST' });
|
|
212
|
+
await refresh(); notifications.success(`${documentName(document)} restored`);
|
|
213
|
+
} });
|
|
214
|
+
}} />
|
|
215
|
+
<MoveDocumentDialog document={moving} projects={manifest.projects} connected={connected} onClose={() => setMoving(null)} onMoved={projectId => {
|
|
216
|
+
setDocuments(previous => previous.map(document => document.id === moving?.id ? { ...document, projectId } : document)); void refresh();
|
|
217
|
+
}} />
|
|
218
|
+
</div>;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
createRoot(document.getElementById("root")!).render(<UiProvider><App /></UiProvider>);
|