@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,798 @@
|
|
|
1
|
+
import { mkdir, readdir, writeFile, lstat, open, unlink, rm, realpath } from 'node:fs/promises';
|
|
2
|
+
import { constants, lstatSync, unlinkSync, renameSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { resolve, relative } from 'node:path';
|
|
4
|
+
import { randomUUID } from 'node:crypto';
|
|
5
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
6
|
+
import { atomicWrite } from '../server/files';
|
|
7
|
+
import { documentEntry } from '../server/render';
|
|
8
|
+
import { withCommentLock } from '../server/comments';
|
|
9
|
+
import { assetUsage } from './usage';
|
|
10
|
+
import { ensureDocumentAssetAdapter } from './adapter';
|
|
11
|
+
import type { DocumentState } from '../shared/types';
|
|
12
|
+
import { prepareLogo, prepareFonts, type PreparedFile, type UploadFile } from './imports';
|
|
13
|
+
import {
|
|
14
|
+
AssetError,
|
|
15
|
+
assetHash,
|
|
16
|
+
assetDirectory,
|
|
17
|
+
assetRevisionPath,
|
|
18
|
+
assetFile,
|
|
19
|
+
safeAssetPath,
|
|
20
|
+
assertAssetId,
|
|
21
|
+
assertKind,
|
|
22
|
+
validAssetId,
|
|
23
|
+
readAssetHead,
|
|
24
|
+
readAssetRevision,
|
|
25
|
+
readThemeAssetDefaults,
|
|
26
|
+
parseThemeAssetDefaults,
|
|
27
|
+
resolveThemeAssetDefaults,
|
|
28
|
+
parseDocumentAssets,
|
|
29
|
+
revisionFiles,
|
|
30
|
+
} from './files';
|
|
31
|
+
import type {
|
|
32
|
+
AssetKind,
|
|
33
|
+
AssetRevision,
|
|
34
|
+
AssetHead,
|
|
35
|
+
AssetInspection,
|
|
36
|
+
AssetCatalog,
|
|
37
|
+
AssetSummary,
|
|
38
|
+
AssetFile,
|
|
39
|
+
LogoRevision,
|
|
40
|
+
FontRevision,
|
|
41
|
+
ThemeAssetDefaults,
|
|
42
|
+
DocumentAssets,
|
|
43
|
+
AssetUsage,
|
|
44
|
+
LogoBinding,
|
|
45
|
+
ArchivedThemeDefault,
|
|
46
|
+
} from '../shared/assets';
|
|
47
|
+
import { fontCanBeDefault } from '../shared/assets';
|
|
48
|
+
export { AssetError } from './files';
|
|
49
|
+
type Meta = {
|
|
50
|
+
id?: string;
|
|
51
|
+
name: string;
|
|
52
|
+
description?: string;
|
|
53
|
+
variationName?: string;
|
|
54
|
+
variationDescription?: string;
|
|
55
|
+
};
|
|
56
|
+
export type RevisionEdit = {
|
|
57
|
+
expectedRevision: string;
|
|
58
|
+
name?: string;
|
|
59
|
+
description?: string;
|
|
60
|
+
defaultVariation?: string;
|
|
61
|
+
variation?: {
|
|
62
|
+
id: string;
|
|
63
|
+
name?: string;
|
|
64
|
+
description?: string;
|
|
65
|
+
};
|
|
66
|
+
removeVariation?: string;
|
|
67
|
+
removeFace?: string;
|
|
68
|
+
};
|
|
69
|
+
const slug = (value: string) =>
|
|
70
|
+
value
|
|
71
|
+
.normalize('NFKD')
|
|
72
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
73
|
+
.toLowerCase()
|
|
74
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
75
|
+
.replace(/^-|-$/g, '')
|
|
76
|
+
.slice(0, 65)
|
|
77
|
+
.replace(/-$/, '') || 'asset';
|
|
78
|
+
function label(value: unknown, name: string, optional = false) {
|
|
79
|
+
if (value === undefined && optional) return '';
|
|
80
|
+
if (typeof value !== 'string' || value.length > (name.includes('name') ? 200 : 4000) || (!optional && !value.trim()))
|
|
81
|
+
throw new AssetError(`Enter ${name}${name.includes('name') ? ' (up to 200 characters)' : ''}.`);
|
|
82
|
+
return value.trim();
|
|
83
|
+
}
|
|
84
|
+
const defaultsRevision = (defaults: ThemeAssetDefaults) => assetHash(JSON.stringify(defaults));
|
|
85
|
+
function withoutContents(prepared: PreparedFile): AssetFile {
|
|
86
|
+
const { contents: _, ...file } = prepared;
|
|
87
|
+
return file;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Recover interrupted acquisition while preserving fresh reservations and live owners. */
|
|
91
|
+
function releaseAbandonedAssetLock(lock: string) {
|
|
92
|
+
try {
|
|
93
|
+
const before = lstatSync(lock);
|
|
94
|
+
if (!before.isFile() || before.isSymbolicLink() || before.size > 128) return;
|
|
95
|
+
let pid: number | undefined;
|
|
96
|
+
try { pid = (JSON.parse(readFileSync(lock, 'utf8')) as { pid?: number } | null)?.pid; }
|
|
97
|
+
catch (error) { if (!(error instanceof SyntaxError)) throw error; }
|
|
98
|
+
if (Number.isSafeInteger(pid) && pid! > 0) {
|
|
99
|
+
try { process.kill(pid!, 0); return; }
|
|
100
|
+
catch (error) { if ((error as NodeJS.ErrnoException).code !== 'ESRCH') return; }
|
|
101
|
+
} else if (Date.now() - before.mtimeMs < 30_000) return;
|
|
102
|
+
const current = lstatSync(lock);
|
|
103
|
+
if (current.dev === before.dev && current.ino === before.ino && current.mtimeMs === before.mtimeMs) unlinkSync(lock);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Cross-process lock shared by app and CLI. Slow parsing happens before acquiring it. */
|
|
110
|
+
async function withAssets<T>(root: string, run: () => Promise<T>) {
|
|
111
|
+
const runtime = resolve(root, '.opendoc');
|
|
112
|
+
await mkdir(runtime, { recursive: true });
|
|
113
|
+
safeAssetPath(root, runtime, true);
|
|
114
|
+
const lock = resolve(runtime, 'assets.lock');
|
|
115
|
+
let handle;
|
|
116
|
+
const start = Date.now();
|
|
117
|
+
while (!handle) {
|
|
118
|
+
try {
|
|
119
|
+
handle = await open(
|
|
120
|
+
lock,
|
|
121
|
+
constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW,
|
|
122
|
+
0o600,
|
|
123
|
+
);
|
|
124
|
+
} catch (error) {
|
|
125
|
+
if ((error as NodeJS.ErrnoException).code !== 'EEXIST') throw error;
|
|
126
|
+
releaseAbandonedAssetLock(lock);
|
|
127
|
+
if (Date.now() - start > 5000)
|
|
128
|
+
throw new AssetError('The asset library is busy. Try again when the other change finishes.', 409);
|
|
129
|
+
await delay(25);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
await handle.writeFile(JSON.stringify({ pid: process.pid }));
|
|
134
|
+
return await run();
|
|
135
|
+
} finally {
|
|
136
|
+
await handle.close();
|
|
137
|
+
await unlink(lock).catch(() => {});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
export class AssetStore {
|
|
141
|
+
constructor(
|
|
142
|
+
private root: string,
|
|
143
|
+
private states?: () => DocumentState[],
|
|
144
|
+
) {}
|
|
145
|
+
private async folder(kind: AssetKind, id: string) {
|
|
146
|
+
const path = assetDirectory(this.root, kind, id);
|
|
147
|
+
for (const directory of [
|
|
148
|
+
resolve(this.root, 'assets'),
|
|
149
|
+
resolve(path, '..'),
|
|
150
|
+
path,
|
|
151
|
+
resolve(path, 'files'),
|
|
152
|
+
resolve(path, 'revisions'),
|
|
153
|
+
]) {
|
|
154
|
+
await mkdir(directory, { recursive: true });
|
|
155
|
+
safeAssetPath(this.root, directory, true);
|
|
156
|
+
}
|
|
157
|
+
return path;
|
|
158
|
+
}
|
|
159
|
+
private async files(kind: AssetKind, id: string, files: PreparedFile[]) {
|
|
160
|
+
await this.folder(kind, id);
|
|
161
|
+
for (const file of files) {
|
|
162
|
+
if (assetHash(file.contents) !== file.hash)
|
|
163
|
+
throw new AssetError('Prepared asset bytes changed before publication.');
|
|
164
|
+
const path = resolve(assetDirectory(this.root, kind, id), file.file);
|
|
165
|
+
if (!/^files\/[a-f0-9]{64}\.(png|svg|ttf|otf|pdf)$/.test(file.file))
|
|
166
|
+
throw new AssetError('Invalid prepared asset path.');
|
|
167
|
+
try {
|
|
168
|
+
await writeFile(path, file.contents, { flag: 'wx' });
|
|
169
|
+
} catch (error) {
|
|
170
|
+
if ((error as NodeJS.ErrnoException).code !== 'EEXIST') throw error;
|
|
171
|
+
assetFile(this.root, kind, id, file);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
private head(kind: AssetKind, id: string, expected?: string, allowArchived = false): AssetHead {
|
|
176
|
+
const head = readAssetHead(this.root, kind, id);
|
|
177
|
+
if (expected === undefined || expected !== head.revision)
|
|
178
|
+
throw new AssetError('This asset changed in another window or agent. Reload it before saving.', 409);
|
|
179
|
+
if (head.archived && !allowArchived) throw new AssetError('Restore this archived asset before editing it.', 409);
|
|
180
|
+
if (head.builtIn && !allowArchived)
|
|
181
|
+
throw new AssetError('Built-in fonts are read-only. Import a separate family to customize it.');
|
|
182
|
+
return head;
|
|
183
|
+
}
|
|
184
|
+
private async publish(value: Omit<LogoRevision, 'revision'> | Omit<FontRevision, 'revision'>, previous?: AssetHead) {
|
|
185
|
+
const revision = assetHash(JSON.stringify(value));
|
|
186
|
+
const record = { ...value, revision } as AssetRevision;
|
|
187
|
+
await this.folder(record.kind, record.id);
|
|
188
|
+
const path = assetRevisionPath(this.root, record.kind, record.id, revision);
|
|
189
|
+
try {
|
|
190
|
+
await writeFile(path, JSON.stringify(record, null, 2) + '\n', { flag: 'wx' });
|
|
191
|
+
} catch (error) {
|
|
192
|
+
if ((error as NodeJS.ErrnoException).code !== 'EEXIST') throw error;
|
|
193
|
+
}
|
|
194
|
+
readAssetRevision(this.root, record.kind, record.id, revision);
|
|
195
|
+
for (const file of revisionFiles(record)) assetFile(this.root, record.kind, record.id, file);
|
|
196
|
+
await atomicWrite(
|
|
197
|
+
resolve(assetDirectory(this.root, record.kind, record.id), 'asset.json'),
|
|
198
|
+
JSON.stringify(
|
|
199
|
+
{ version: 1, id: record.id, kind: record.kind, revision, ...(previous?.builtIn ? { builtIn: true } : {}) },
|
|
200
|
+
null,
|
|
201
|
+
2,
|
|
202
|
+
) + '\n',
|
|
203
|
+
);
|
|
204
|
+
return record;
|
|
205
|
+
}
|
|
206
|
+
private async newId(kind: AssetKind, name: string, id?: string) {
|
|
207
|
+
if (id) {
|
|
208
|
+
assertAssetId(id);
|
|
209
|
+
try {
|
|
210
|
+
readAssetHead(this.root, kind, id);
|
|
211
|
+
throw new AssetError(
|
|
212
|
+
'That asset ID already exists. Choose another name or add a version to the existing asset.',
|
|
213
|
+
409,
|
|
214
|
+
);
|
|
215
|
+
} catch (error) {
|
|
216
|
+
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;
|
|
217
|
+
}
|
|
218
|
+
return id;
|
|
219
|
+
}
|
|
220
|
+
const base = slug(name);
|
|
221
|
+
for (let n = 1; n < 10000; n++) {
|
|
222
|
+
const candidate = n === 1 ? base : `${base}-${n}`;
|
|
223
|
+
try {
|
|
224
|
+
await lstat(resolve(assetDirectory(this.root, kind, candidate), 'asset.json'));
|
|
225
|
+
} catch (error) {
|
|
226
|
+
if ((error as NodeJS.ErrnoException).code === 'ENOENT') return candidate;
|
|
227
|
+
throw error;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
throw new AssetError('Choose a different asset name.');
|
|
231
|
+
}
|
|
232
|
+
async list(kind?: AssetKind, includeArchived = false): Promise<AssetCatalog> {
|
|
233
|
+
if (kind) assertKind(kind);
|
|
234
|
+
const items: AssetSummary[] = [],
|
|
235
|
+
issues: string[] = [];
|
|
236
|
+
for (const category of kind ? [kind] : (['logo', 'font'] as AssetKind[])) {
|
|
237
|
+
const parent = resolve(this.root, 'assets', category === 'logo' ? 'logos' : 'fonts');
|
|
238
|
+
let entries;
|
|
239
|
+
try {
|
|
240
|
+
safeAssetPath(this.root, parent, true);
|
|
241
|
+
entries = await readdir(parent, { withFileTypes: true });
|
|
242
|
+
} catch (error) {
|
|
243
|
+
if ((error as NodeJS.ErrnoException).code === 'ENOENT') continue;
|
|
244
|
+
issues.push((error as Error).message);
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
for (const entry of entries) {
|
|
248
|
+
if (!entry.isDirectory() || !validAssetId(entry.name)) continue;
|
|
249
|
+
try {
|
|
250
|
+
const head = readAssetHead(this.root, category, entry.name);
|
|
251
|
+
if (head.archived && !includeArchived) continue;
|
|
252
|
+
const asset = readAssetRevision(this.root, category, head.id, head.revision);
|
|
253
|
+
let error: string | undefined;
|
|
254
|
+
try {
|
|
255
|
+
for (const file of revisionFiles(asset)) assetFile(this.root, category, head.id, file);
|
|
256
|
+
} catch (failure) {
|
|
257
|
+
error = (failure as Error).message;
|
|
258
|
+
}
|
|
259
|
+
items.push({
|
|
260
|
+
id: head.id,
|
|
261
|
+
kind: category,
|
|
262
|
+
name: asset.name,
|
|
263
|
+
description: asset.description,
|
|
264
|
+
revision: head.revision,
|
|
265
|
+
archived: !!head.archived,
|
|
266
|
+
builtIn: head.builtIn,
|
|
267
|
+
count: asset.kind === 'logo' ? asset.variations.length : asset.faces.length,
|
|
268
|
+
...(asset.kind === 'logo'
|
|
269
|
+
? { preview: asset.variations.find((v) => v.id === asset.defaultVariation)!.image }
|
|
270
|
+
: { compatibility: asset.compatibility }),
|
|
271
|
+
...(error ? { error } : {}),
|
|
272
|
+
});
|
|
273
|
+
} catch (error) {
|
|
274
|
+
if ((error as NodeJS.ErrnoException).code === 'ENOENT') continue;
|
|
275
|
+
items.push({
|
|
276
|
+
id: entry.name,
|
|
277
|
+
kind: category,
|
|
278
|
+
name: entry.name,
|
|
279
|
+
description: '',
|
|
280
|
+
revision: '',
|
|
281
|
+
archived: false,
|
|
282
|
+
count: 0,
|
|
283
|
+
error: (error as Error).message,
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return { items: items.sort((a, b) => a.name.localeCompare(b.name)), issues };
|
|
289
|
+
}
|
|
290
|
+
async inspect(kind: AssetKind, id: string, revision?: string): Promise<AssetInspection> {
|
|
291
|
+
const head = readAssetHead(this.root, kind, id);
|
|
292
|
+
const asset = readAssetRevision(this.root, kind, id, revision ?? head.revision);
|
|
293
|
+
const versions: AssetInspection['versions'] = [];
|
|
294
|
+
for (const name of await readdir(resolve(assetDirectory(this.root, kind, id), 'revisions'))) {
|
|
295
|
+
if (!/^[a-f0-9]{64}\.json$/.test(name)) continue;
|
|
296
|
+
try {
|
|
297
|
+
const value = readAssetRevision(this.root, kind, id, name.slice(0, -5));
|
|
298
|
+
versions.push({ revision: value.revision, createdAt: value.createdAt, name: value.name });
|
|
299
|
+
} catch {
|
|
300
|
+
/* A malformed historical neighbor never hides valid versions. */
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return {
|
|
304
|
+
head,
|
|
305
|
+
asset,
|
|
306
|
+
versions: versions.sort((a, b) => b.createdAt.localeCompare(a.createdAt)),
|
|
307
|
+
folder: relative(this.root, assetDirectory(this.root, kind, id)),
|
|
308
|
+
usage: await this.usage(kind, id),
|
|
309
|
+
examples:
|
|
310
|
+
kind === 'logo'
|
|
311
|
+
? [
|
|
312
|
+
`npx opendoc assets bind <document> logo ${id} --revision ${asset.revision}`,
|
|
313
|
+
'<Logo width={120} />',
|
|
314
|
+
`<Logo variation="${asset.kind === 'logo' ? asset.variations[0].id : ''}" width={120} />`,
|
|
315
|
+
]
|
|
316
|
+
: [`npx opendoc assets bind <document> body-font ${id} --revision ${asset.revision}`],
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
async createLogo(meta: Meta, file: UploadFile) {
|
|
320
|
+
const name = label(meta.name, 'a logo name'),
|
|
321
|
+
description = label(meta.description, 'logo guidance', true);
|
|
322
|
+
const prepared = await prepareLogo(file);
|
|
323
|
+
const id = await withAssets(this.root, async () => {
|
|
324
|
+
const id = await this.newId('logo', name, meta.id);
|
|
325
|
+
await this.files('logo', id, [prepared.original, prepared.image]);
|
|
326
|
+
await this.publish({
|
|
327
|
+
version: 1,
|
|
328
|
+
kind: 'logo',
|
|
329
|
+
id,
|
|
330
|
+
name,
|
|
331
|
+
description,
|
|
332
|
+
createdAt: new Date().toISOString(),
|
|
333
|
+
defaultVariation: 'default',
|
|
334
|
+
variations: [
|
|
335
|
+
{
|
|
336
|
+
id: 'default',
|
|
337
|
+
name: label(meta.variationName ?? 'Default', 'a variation name'),
|
|
338
|
+
description: label(meta.variationDescription, 'variation guidance', true),
|
|
339
|
+
original: withoutContents(prepared.original),
|
|
340
|
+
image: withoutContents(prepared.image),
|
|
341
|
+
},
|
|
342
|
+
],
|
|
343
|
+
});
|
|
344
|
+
return id;
|
|
345
|
+
});
|
|
346
|
+
return this.inspect('logo', id);
|
|
347
|
+
}
|
|
348
|
+
async createFont(
|
|
349
|
+
meta: {
|
|
350
|
+
id?: string;
|
|
351
|
+
name?: string;
|
|
352
|
+
description?: string;
|
|
353
|
+
},
|
|
354
|
+
files: UploadFile[],
|
|
355
|
+
) {
|
|
356
|
+
const prepared = await prepareFonts(this.root, files);
|
|
357
|
+
const name = label(meta.name ?? prepared.name, 'a font name'),
|
|
358
|
+
description = label(meta.description ?? prepared.description, 'font guidance', true);
|
|
359
|
+
const id = await withAssets(this.root, async () => {
|
|
360
|
+
const id = await this.newId('font', name, meta.id);
|
|
361
|
+
await this.files('font', id, [
|
|
362
|
+
...prepared.faces.map((f) => f.file),
|
|
363
|
+
...(prepared.specimen ? [prepared.specimen] : []),
|
|
364
|
+
]);
|
|
365
|
+
await this.publish({
|
|
366
|
+
version: 1,
|
|
367
|
+
kind: 'font',
|
|
368
|
+
id,
|
|
369
|
+
name,
|
|
370
|
+
description,
|
|
371
|
+
createdAt: new Date().toISOString(),
|
|
372
|
+
faces: prepared.faces.map((face) => ({ ...face, file: withoutContents(face.file) })),
|
|
373
|
+
compatibility: prepared.compatibility,
|
|
374
|
+
...(prepared.specimen ? { specimen: withoutContents(prepared.specimen) } : {}),
|
|
375
|
+
});
|
|
376
|
+
return id;
|
|
377
|
+
});
|
|
378
|
+
return this.inspect('font', id);
|
|
379
|
+
}
|
|
380
|
+
async revise(kind: AssetKind, id: string, input: RevisionEdit) {
|
|
381
|
+
if (
|
|
382
|
+
!input ||
|
|
383
|
+
typeof input !== 'object' ||
|
|
384
|
+
Array.isArray(input) ||
|
|
385
|
+
Object.keys(input).some(
|
|
386
|
+
(key) =>
|
|
387
|
+
![
|
|
388
|
+
'expectedRevision',
|
|
389
|
+
'name',
|
|
390
|
+
'description',
|
|
391
|
+
'defaultVariation',
|
|
392
|
+
'variation',
|
|
393
|
+
'removeVariation',
|
|
394
|
+
'removeFace',
|
|
395
|
+
].includes(key),
|
|
396
|
+
)
|
|
397
|
+
)
|
|
398
|
+
throw new AssetError('Invalid asset revision fields.');
|
|
399
|
+
if (
|
|
400
|
+
input.variation &&
|
|
401
|
+
(typeof input.variation !== 'object' ||
|
|
402
|
+
Array.isArray(input.variation) ||
|
|
403
|
+
Object.keys(input.variation).some((key) => !['id', 'name', 'description'].includes(key)))
|
|
404
|
+
)
|
|
405
|
+
throw new AssetError('Invalid variation guidance fields.');
|
|
406
|
+
let changedFaces: Awaited<ReturnType<typeof prepareFonts>> | undefined;
|
|
407
|
+
if (kind === 'font' && input.removeFace) {
|
|
408
|
+
const current = this.head(kind, id, input.expectedRevision),
|
|
409
|
+
record = readAssetRevision(this.root, kind, id, current.revision);
|
|
410
|
+
if (record.kind !== 'font') throw new AssetError('Choose a font family.');
|
|
411
|
+
if (!record.faces.some((face) => face.id === input.removeFace))
|
|
412
|
+
throw new AssetError('The font face was not found.', 404);
|
|
413
|
+
const remaining = record.faces.filter((face) => face.id !== input.removeFace);
|
|
414
|
+
if (!remaining.length) throw new AssetError('Keep at least one face or archive this family.');
|
|
415
|
+
changedFaces = await prepareFonts(
|
|
416
|
+
this.root,
|
|
417
|
+
remaining.map((face) => ({
|
|
418
|
+
filename: face.file.file,
|
|
419
|
+
bytes: readFileSync(assetFile(this.root, 'font', id, face.file)),
|
|
420
|
+
})),
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
await withAssets(this.root, async () => {
|
|
424
|
+
const head = this.head(kind, id, input.expectedRevision);
|
|
425
|
+
const old = readAssetRevision(this.root, kind, id, head.revision);
|
|
426
|
+
const { revision: _, ...next } = old;
|
|
427
|
+
if (input.name !== undefined) next.name = label(input.name, 'an asset name');
|
|
428
|
+
if (input.description !== undefined) next.description = label(input.description, 'asset guidance', true);
|
|
429
|
+
next.createdAt = new Date().toISOString();
|
|
430
|
+
if (next.kind === 'logo') {
|
|
431
|
+
if (input.removeFace) throw new AssetError('Choose a font family to remove a face.');
|
|
432
|
+
if (input.variation) {
|
|
433
|
+
const variant = next.variations.find((v) => v.id === input.variation!.id);
|
|
434
|
+
if (!variant) throw new AssetError('Variation not found.', 404);
|
|
435
|
+
if (input.variation.name !== undefined) variant.name = label(input.variation.name, 'a variation name');
|
|
436
|
+
if (input.variation.description !== undefined)
|
|
437
|
+
variant.description = label(input.variation.description, 'variation guidance', true);
|
|
438
|
+
}
|
|
439
|
+
if (input.removeVariation) {
|
|
440
|
+
if (!next.variations.some((v) => v.id === input.removeVariation))
|
|
441
|
+
throw new AssetError('The variation was not found.', 404);
|
|
442
|
+
next.variations = next.variations.filter((v) => v.id !== input.removeVariation);
|
|
443
|
+
}
|
|
444
|
+
if (input.defaultVariation) next.defaultVariation = input.defaultVariation;
|
|
445
|
+
if (!next.variations.some((v) => v.id === next.defaultVariation))
|
|
446
|
+
throw new AssetError('Choose another default before removing this variation.');
|
|
447
|
+
} else {
|
|
448
|
+
if (input.variation || input.defaultVariation || input.removeVariation)
|
|
449
|
+
throw new AssetError('Choose a logo to edit its variations.');
|
|
450
|
+
if (input.removeFace) {
|
|
451
|
+
next.faces = next.faces.filter((f) => f.id !== input.removeFace);
|
|
452
|
+
if (!next.faces.length) throw new AssetError('Keep at least one face or archive this family.');
|
|
453
|
+
next.compatibility = changedFaces!.compatibility;
|
|
454
|
+
if (changedFaces!.specimen) {
|
|
455
|
+
await this.files('font', id, [changedFaces!.specimen]);
|
|
456
|
+
next.specimen = withoutContents(changedFaces!.specimen);
|
|
457
|
+
} else delete next.specimen;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
await this.publish(next, head);
|
|
461
|
+
});
|
|
462
|
+
return this.inspect(kind, id);
|
|
463
|
+
}
|
|
464
|
+
async addVariation(
|
|
465
|
+
id: string,
|
|
466
|
+
meta: {
|
|
467
|
+
expectedRevision: string;
|
|
468
|
+
id?: string;
|
|
469
|
+
name: string;
|
|
470
|
+
description?: string;
|
|
471
|
+
replaceId?: string;
|
|
472
|
+
},
|
|
473
|
+
file: UploadFile,
|
|
474
|
+
) {
|
|
475
|
+
const name = label(meta.name, 'a variation name'),
|
|
476
|
+
prepared = await prepareLogo(file);
|
|
477
|
+
await withAssets(this.root, async () => {
|
|
478
|
+
const head = this.head('logo', id, meta.expectedRevision),
|
|
479
|
+
old = readAssetRevision(this.root, 'logo', id, head.revision);
|
|
480
|
+
if (old.kind !== 'logo') throw new AssetError('Choose a logo.');
|
|
481
|
+
const { revision: _, ...next } = old;
|
|
482
|
+
next.createdAt = new Date().toISOString();
|
|
483
|
+
let variantId = meta.replaceId ?? meta.id ?? slug(name);
|
|
484
|
+
assertAssetId(variantId);
|
|
485
|
+
const oldVariant = next.variations.find((v) => v.id === variantId);
|
|
486
|
+
if (meta.replaceId && !oldVariant) throw new AssetError('The variation to replace was not found.', 404);
|
|
487
|
+
if (!meta.replaceId && oldVariant) {
|
|
488
|
+
if (meta.id) throw new AssetError('That variation ID already exists.', 409);
|
|
489
|
+
variantId = `${variantId}-${randomUUID().slice(0, 6)}`;
|
|
490
|
+
}
|
|
491
|
+
await this.files('logo', id, [prepared.original, prepared.image]);
|
|
492
|
+
const variation = {
|
|
493
|
+
id: variantId,
|
|
494
|
+
name,
|
|
495
|
+
description: label(meta.description ?? oldVariant?.description, 'variation guidance', true),
|
|
496
|
+
original: withoutContents(prepared.original),
|
|
497
|
+
image: withoutContents(prepared.image),
|
|
498
|
+
};
|
|
499
|
+
next.variations = meta.replaceId
|
|
500
|
+
? next.variations.map((v) => (v.id === variantId ? variation : v))
|
|
501
|
+
: [...next.variations, variation];
|
|
502
|
+
await this.publish(next, head);
|
|
503
|
+
});
|
|
504
|
+
return this.inspect('logo', id);
|
|
505
|
+
}
|
|
506
|
+
async addFaces(
|
|
507
|
+
id: string,
|
|
508
|
+
meta: {
|
|
509
|
+
expectedRevision: string;
|
|
510
|
+
},
|
|
511
|
+
files: UploadFile[],
|
|
512
|
+
) {
|
|
513
|
+
const before = this.head('font', id, meta.expectedRevision),
|
|
514
|
+
old = readAssetRevision(this.root, 'font', id, before.revision);
|
|
515
|
+
if (old.kind !== 'font') throw new AssetError('Choose a font family.');
|
|
516
|
+
const incoming = await prepareFonts(this.root, files);
|
|
517
|
+
if (incoming.faces[0].family !== old.faces[0].family)
|
|
518
|
+
throw new AssetError('Add faces from the same font family. Import a different family as a separate asset.');
|
|
519
|
+
const keys = new Set(incoming.faces.map((f) => `${f.weight}:${f.style}`));
|
|
520
|
+
const combined: UploadFile[] = [
|
|
521
|
+
...old.faces
|
|
522
|
+
.filter((f) => !keys.has(`${f.weight}:${f.style}`))
|
|
523
|
+
.map((face) => ({
|
|
524
|
+
filename: face.file.file.split('/').pop()!,
|
|
525
|
+
bytes: readFileSync(assetFile(this.root, 'font', id, face.file)),
|
|
526
|
+
})),
|
|
527
|
+
...files,
|
|
528
|
+
];
|
|
529
|
+
const prepared = await prepareFonts(this.root, combined);
|
|
530
|
+
await withAssets(this.root, async () => {
|
|
531
|
+
const head = this.head('font', id, meta.expectedRevision);
|
|
532
|
+
await this.files('font', id, [
|
|
533
|
+
...prepared.faces.map((f) => f.file),
|
|
534
|
+
...(prepared.specimen ? [prepared.specimen] : []),
|
|
535
|
+
]);
|
|
536
|
+
await this.publish(
|
|
537
|
+
{
|
|
538
|
+
version: 1,
|
|
539
|
+
kind: 'font',
|
|
540
|
+
id,
|
|
541
|
+
name: old.name,
|
|
542
|
+
description: old.description,
|
|
543
|
+
createdAt: new Date().toISOString(),
|
|
544
|
+
faces: prepared.faces.map((face) => ({
|
|
545
|
+
...face,
|
|
546
|
+
id: old.faces.find((f) => f.weight === face.weight && f.style === face.style)?.id ?? face.id,
|
|
547
|
+
file: withoutContents(face.file),
|
|
548
|
+
})),
|
|
549
|
+
compatibility: prepared.compatibility,
|
|
550
|
+
...(prepared.specimen ? { specimen: withoutContents(prepared.specimen) } : {}),
|
|
551
|
+
},
|
|
552
|
+
head,
|
|
553
|
+
);
|
|
554
|
+
});
|
|
555
|
+
return this.inspect('font', id);
|
|
556
|
+
}
|
|
557
|
+
async defaults(themeId: string) {
|
|
558
|
+
assertAssetId(themeId);
|
|
559
|
+
try {
|
|
560
|
+
safeAssetPath(this.root, resolve(this.root, 'themes', themeId, 'index.ts'));
|
|
561
|
+
} catch (error) {
|
|
562
|
+
if ((error as NodeJS.ErrnoException).code === 'ENOENT')
|
|
563
|
+
throw new AssetError(`Theme ${themeId} was not found. Choose an available theme.`, 404);
|
|
564
|
+
throw error;
|
|
565
|
+
}
|
|
566
|
+
const defaults = readThemeAssetDefaults(this.root, themeId);
|
|
567
|
+
return { defaults, revision: defaultsRevision(defaults) };
|
|
568
|
+
}
|
|
569
|
+
private validateDefaults(defaults: ThemeAssetDefaults) {
|
|
570
|
+
const parsed = parseThemeAssetDefaults(defaults);
|
|
571
|
+
resolveThemeAssetDefaults(this.root, parsed);
|
|
572
|
+
return parsed;
|
|
573
|
+
}
|
|
574
|
+
async setDefaults(themeId: string, defaults: ThemeAssetDefaults, expectedRevision: string) {
|
|
575
|
+
assertAssetId(themeId);
|
|
576
|
+
await withAssets(this.root, async () => {
|
|
577
|
+
safeAssetPath(this.root, resolve(this.root, 'themes', themeId), true);
|
|
578
|
+
const before = await this.defaults(themeId);
|
|
579
|
+
if (before.revision !== expectedRevision)
|
|
580
|
+
throw new AssetError('These theme defaults changed. Reload them before saving.', 409);
|
|
581
|
+
await atomicWrite(
|
|
582
|
+
resolve(this.root, 'themes', themeId, 'assets.json'),
|
|
583
|
+
JSON.stringify(this.validateDefaults(defaults), null, 2) + '\n',
|
|
584
|
+
);
|
|
585
|
+
});
|
|
586
|
+
return this.defaults(themeId);
|
|
587
|
+
}
|
|
588
|
+
async archive(kind: AssetKind, id: string, expectedRevision: string, clearDefaults = false) {
|
|
589
|
+
await withAssets(this.root, async () => {
|
|
590
|
+
const head = this.head(kind, id, expectedRevision, true);
|
|
591
|
+
if (head.builtIn) throw new AssetError('Built-in fonts stay available.');
|
|
592
|
+
if (head.archived) return;
|
|
593
|
+
const affected: ArchivedThemeDefault[] = [];
|
|
594
|
+
for (const theme of await this.themeIds()) {
|
|
595
|
+
const defaults = readThemeAssetDefaults(this.root, theme),
|
|
596
|
+
next = structuredClone(defaults);
|
|
597
|
+
if (kind === 'logo' && next.logo?.id === id) delete next.logo;
|
|
598
|
+
if (kind === 'font') {
|
|
599
|
+
if (next.bodyFont === id) delete next.bodyFont;
|
|
600
|
+
if (next.headingFont === id) delete next.headingFont;
|
|
601
|
+
}
|
|
602
|
+
if (JSON.stringify(next) !== JSON.stringify(defaults))
|
|
603
|
+
affected.push({ id: theme, defaults, cleared: defaultsRevision(next) });
|
|
604
|
+
}
|
|
605
|
+
if (affected.length && !clearDefaults)
|
|
606
|
+
throw new AssetError('This asset is a theme default. Confirm clearing those defaults when archiving.', 409);
|
|
607
|
+
const written: ArchivedThemeDefault[] = [];
|
|
608
|
+
try {
|
|
609
|
+
for (const item of affected) {
|
|
610
|
+
const next = structuredClone(item.defaults);
|
|
611
|
+
if (kind === 'logo') delete next.logo;
|
|
612
|
+
else {
|
|
613
|
+
if (next.bodyFont === id) delete next.bodyFont;
|
|
614
|
+
if (next.headingFont === id) delete next.headingFont;
|
|
615
|
+
}
|
|
616
|
+
await atomicWrite(resolve(this.root, 'themes', item.id, 'assets.json'), JSON.stringify(next, null, 2) + '\n');
|
|
617
|
+
written.push(item);
|
|
618
|
+
}
|
|
619
|
+
await atomicWrite(
|
|
620
|
+
resolve(assetDirectory(this.root, kind, id), 'asset.json'),
|
|
621
|
+
JSON.stringify({ ...head, archived: true, archivedDefaults: affected }, null, 2) + '\n',
|
|
622
|
+
);
|
|
623
|
+
} catch (error) {
|
|
624
|
+
for (const item of written)
|
|
625
|
+
await atomicWrite(
|
|
626
|
+
resolve(this.root, 'themes', item.id, 'assets.json'),
|
|
627
|
+
JSON.stringify(item.defaults, null, 2) + '\n',
|
|
628
|
+
);
|
|
629
|
+
throw error;
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
return this.inspect(kind, id);
|
|
633
|
+
}
|
|
634
|
+
async restore(kind: AssetKind, id: string, expectedRevision: string) {
|
|
635
|
+
await withAssets(this.root, async () => {
|
|
636
|
+
const head = this.head(kind, id, expectedRevision, true);
|
|
637
|
+
if (!head.archived) return;
|
|
638
|
+
for (const item of head.archivedDefaults ?? []) {
|
|
639
|
+
let current;
|
|
640
|
+
try { current = await this.defaults(item.id); }
|
|
641
|
+
catch (error) {
|
|
642
|
+
// A deleted theme is no longer an undo target; restoring an asset must
|
|
643
|
+
// never recreate that theme or strand an otherwise valid asset.
|
|
644
|
+
if (error instanceof AssetError && error.status === 404) continue;
|
|
645
|
+
throw error;
|
|
646
|
+
}
|
|
647
|
+
if (current.revision === item.cleared)
|
|
648
|
+
await atomicWrite(
|
|
649
|
+
resolve(this.root, 'themes', item.id, 'assets.json'),
|
|
650
|
+
JSON.stringify(item.defaults, null, 2) + '\n',
|
|
651
|
+
);
|
|
652
|
+
}
|
|
653
|
+
const { archivedDefaults: _, archived: __, ...restored } = head;
|
|
654
|
+
await atomicWrite(
|
|
655
|
+
resolve(assetDirectory(this.root, kind, id), 'asset.json'),
|
|
656
|
+
JSON.stringify(restored, null, 2) + '\n',
|
|
657
|
+
);
|
|
658
|
+
});
|
|
659
|
+
return this.inspect(kind, id);
|
|
660
|
+
}
|
|
661
|
+
/** Serialize against document deletion and detect file-first edits before publication. */
|
|
662
|
+
private async changeBindings(documentId: string, change: (bindings: DocumentAssets) => boolean | Promise<boolean>) {
|
|
663
|
+
const root = await realpath(this.root);
|
|
664
|
+
const entry = await documentEntry(root, documentId),
|
|
665
|
+
folder = resolve(entry, '..');
|
|
666
|
+
const originalFolder = await lstat(folder);
|
|
667
|
+
const changed = () =>
|
|
668
|
+
new AssetError(
|
|
669
|
+
'This document or its asset choices changed in another window or agent. Reload it before saving. Nothing was overwritten.',
|
|
670
|
+
409,
|
|
671
|
+
);
|
|
672
|
+
const verifyFolder = () => {
|
|
673
|
+
try {
|
|
674
|
+
safeAssetPath(root, folder, true);
|
|
675
|
+
safeAssetPath(root, entry);
|
|
676
|
+
const info = lstatSync(folder);
|
|
677
|
+
if (info.dev !== originalFolder.dev || info.ino !== originalFolder.ino) throw changed();
|
|
678
|
+
} catch {
|
|
679
|
+
throw changed();
|
|
680
|
+
}
|
|
681
|
+
};
|
|
682
|
+
const file = resolve(folder, 'assets.json');
|
|
683
|
+
const snapshot = () => {
|
|
684
|
+
try {
|
|
685
|
+
safeAssetPath(root, file);
|
|
686
|
+
const info = lstatSync(file);
|
|
687
|
+
if (info.size > 256000) throw new AssetError('Document asset metadata is too large.');
|
|
688
|
+
return { text: readFileSync(file, 'utf8'), dev: info.dev, ino: info.ino };
|
|
689
|
+
} catch (error) {
|
|
690
|
+
if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined;
|
|
691
|
+
throw error;
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
return withCommentLock(root, documentId, () =>
|
|
695
|
+
withAssets(root, async () => {
|
|
696
|
+
verifyFolder();
|
|
697
|
+
let expected = snapshot();
|
|
698
|
+
const bindings = expected ? parseDocumentAssets(JSON.parse(expected.text)) : ({ version: 1 } as DocumentAssets);
|
|
699
|
+
const adapt = await change(bindings);
|
|
700
|
+
if (adapt) {
|
|
701
|
+
const prepared = await ensureDocumentAssetAdapter(root, documentId);
|
|
702
|
+
// A first legacy upgrade creates only this known empty manifest. Any
|
|
703
|
+
// different bytes belong to another writer and must win the conflict.
|
|
704
|
+
if (!expected && prepared.changed) {
|
|
705
|
+
const created = snapshot();
|
|
706
|
+
if (!created || created.text !== '{"version":1}\n') throw changed();
|
|
707
|
+
expected = created;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
const pending = resolve(folder, `.assets-${randomUUID()}.tmp`);
|
|
711
|
+
try {
|
|
712
|
+
// Never mkdir a document here: deletion must not resurrect a partial folder.
|
|
713
|
+
await writeFile(pending, JSON.stringify(bindings, null, 2) + '\n', { flag: 'wx' });
|
|
714
|
+
verifyFolder();
|
|
715
|
+
const current = snapshot();
|
|
716
|
+
if (
|
|
717
|
+
!!current !== !!expected ||
|
|
718
|
+
(current &&
|
|
719
|
+
expected &&
|
|
720
|
+
(current.dev !== expected.dev || current.ino !== expected.ino || current.text !== expected.text))
|
|
721
|
+
)
|
|
722
|
+
throw changed();
|
|
723
|
+
// Match the text-edit commit path: no awaits between final checks and rename.
|
|
724
|
+
renameSync(pending, file);
|
|
725
|
+
return bindings;
|
|
726
|
+
} finally {
|
|
727
|
+
await rm(pending, { force: true }).catch(() => {});
|
|
728
|
+
}
|
|
729
|
+
}),
|
|
730
|
+
);
|
|
731
|
+
}
|
|
732
|
+
async bind(
|
|
733
|
+
documentId: string,
|
|
734
|
+
role: 'logo' | 'body-font' | 'heading-font',
|
|
735
|
+
assetId: string,
|
|
736
|
+
options: {
|
|
737
|
+
revision?: string;
|
|
738
|
+
variation?: string;
|
|
739
|
+
name?: string;
|
|
740
|
+
} = {},
|
|
741
|
+
) {
|
|
742
|
+
if (!['logo', 'body-font', 'heading-font'].includes(role))
|
|
743
|
+
throw new AssetError('Choose logo, body-font, or heading-font.');
|
|
744
|
+
return this.changeBindings(documentId, (bindings) => {
|
|
745
|
+
const kind = role === 'logo' ? 'logo' : 'font',
|
|
746
|
+
head = readAssetHead(this.root, kind, assetId);
|
|
747
|
+
if (head.archived) throw new AssetError('Restore this asset before adding it to a document.');
|
|
748
|
+
const record = readAssetRevision(this.root, kind, assetId, options.revision ?? head.revision);
|
|
749
|
+
for (const file of revisionFiles(record)) assetFile(this.root, kind, assetId, file);
|
|
750
|
+
if (record.kind === 'font' && !fontCanBeDefault(record))
|
|
751
|
+
throw new AssetError('This family is not ready for body or heading text.');
|
|
752
|
+
const pin: LogoBinding = { id: assetId, revision: record.revision };
|
|
753
|
+
if (options.variation) {
|
|
754
|
+
if (record.kind !== 'logo' || !record.variations.some((v) => v.id === options.variation))
|
|
755
|
+
throw new AssetError('Choose an existing logo variation.');
|
|
756
|
+
pin.variation = options.variation;
|
|
757
|
+
}
|
|
758
|
+
if (role === 'logo') {
|
|
759
|
+
if (options.name) {
|
|
760
|
+
assertAssetId(options.name);
|
|
761
|
+
bindings.logos = { ...bindings.logos, [options.name]: pin };
|
|
762
|
+
} else bindings.logo = pin;
|
|
763
|
+
} else bindings[role === 'body-font' ? 'bodyFont' : 'headingFont'] = pin;
|
|
764
|
+
return role !== 'logo';
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
async unbind(documentId: string, role: 'logo' | 'body-font' | 'heading-font', name?: string) {
|
|
768
|
+
if (!['logo', 'body-font', 'heading-font'].includes(role))
|
|
769
|
+
throw new AssetError('Choose logo, body-font, or heading-font.');
|
|
770
|
+
return this.changeBindings(documentId, (bindings) => {
|
|
771
|
+
const adapt = !!(
|
|
772
|
+
(role === 'body-font' && bindings.bodyFont) ||
|
|
773
|
+
(role === 'heading-font' && bindings.headingFont)
|
|
774
|
+
);
|
|
775
|
+
if (role === 'logo') {
|
|
776
|
+
if (name) {
|
|
777
|
+
assertAssetId(name);
|
|
778
|
+
if (bindings.logos) delete bindings.logos[name];
|
|
779
|
+
} else delete bindings.logo;
|
|
780
|
+
} else if (role === 'body-font') delete bindings.bodyFont;
|
|
781
|
+
else delete bindings.headingFont;
|
|
782
|
+
return adapt;
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
private async themeIds() {
|
|
786
|
+
try {
|
|
787
|
+
return (await readdir(resolve(this.root, 'themes'), { withFileTypes: true }))
|
|
788
|
+
.filter((e) => e.isDirectory() && validAssetId(e.name))
|
|
789
|
+
.map((e) => e.name);
|
|
790
|
+
} catch (error) {
|
|
791
|
+
if ((error as NodeJS.ErrnoException).code === 'ENOENT') return [];
|
|
792
|
+
throw error;
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
async usage(kind: AssetKind, id: string): Promise<AssetUsage> {
|
|
796
|
+
return assetUsage(this.root, kind, id, this.states?.());
|
|
797
|
+
}
|
|
798
|
+
}
|