@capyclaw/offline-ddr0 0.0.0-stage → 1.9.1
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/LICENSE +21 -0
- package/README.md +441 -2
- package/client/client.js +603 -0
- package/cordis.patch.yml +13 -0
- package/docs/STORAGE-MIGRATION.md +136 -0
- package/lib/atomic.mjs +40 -0
- package/lib/http-cache.mjs +42 -0
- package/lib/inbox.mjs +64 -0
- package/lib/media.mjs +242 -0
- package/lib/migrate-json.mjs +101 -0
- package/lib/mirror-index.mjs +105 -0
- package/lib/mirror.mjs +123 -0
- package/lib/proxy.mjs +188 -0
- package/lib/remote.mjs +158 -0
- package/lib/render.mjs +93 -0
- package/lib/repository.mjs +71 -0
- package/lib/store.mjs +610 -0
- package/lib/surface.mjs +74 -0
- package/lib/sync-ui.mjs +108 -0
- package/lib/sync.mjs +433 -0
- package/lib/wire.mjs +211 -0
- package/lib/workstore-repository.mjs +316 -0
- package/lib/workstore.mjs +348 -0
- package/mirror/files/00001.html +2045 -0
- package/mirror/files/00002.json +1 -0
- package/mirror/files/00003.json +1 -0
- package/mirror/files/00004.json +1 -0
- package/mirror/files/00005.json +1 -0
- package/mirror/files/00006.json +1 -0
- package/mirror/files/00007.json +1 -0
- package/mirror/files/00008.json +1 -0
- package/mirror/files/00009.json +1 -0
- package/mirror/files/00010.json +1 -0
- package/mirror/files/00011.json +1 -0
- package/mirror/files/00012.json +1 -0
- package/mirror/files/00013.json +1 -0
- package/mirror/files/00014.json +1 -0
- package/mirror/files/00015.json +1 -0
- package/mirror/files/00016.json +1 -0
- package/mirror/files/00017.json +1 -0
- package/mirror/files/00018.json +1 -0
- package/mirror/files/00019.json +1 -0
- package/mirror/files/00020.json +1 -0
- package/mirror/files/00021.json +1 -0
- package/mirror/files/00022.json +1 -0
- package/mirror/files/00023.js +205 -0
- package/mirror/files/00024.json +1 -0
- package/mirror/files/00025.json +1 -0
- package/mirror/files/00026.json +1 -0
- package/mirror/files/00027.js +51 -0
- package/mirror/files/00028.json +1 -0
- package/mirror/files/00029.json +1 -0
- package/mirror/files/00030.json +1 -0
- package/mirror/files/00031.json +1 -0
- package/mirror/files/00032.json +1 -0
- package/mirror/files/00033.json +1 -0
- package/mirror/files/00034.json +1 -0
- package/mirror/files/00035.json +1 -0
- package/mirror/files/00036.json +1 -0
- package/mirror/files/00037.json +1 -0
- package/mirror/files/00038.json +1 -0
- package/mirror/files/00039.json +1 -0
- package/mirror/files/00040.js +2311 -0
- package/mirror/files/00041.json +1 -0
- package/mirror/files/00042.json +1 -0
- package/mirror/files/00043.json +1 -0
- package/mirror/files/00044.json +1 -0
- package/mirror/files/00045.js +575 -0
- package/mirror/files/00046.json +1 -0
- package/mirror/files/00047.js +575 -0
- package/mirror/files/00048.js +575 -0
- package/mirror/files/00049.json +1 -0
- package/mirror/files/00050.json +1 -0
- package/mirror/files/00051.json +1 -0
- package/mirror/files/00052.json +1 -0
- package/mirror/files/00053.js +575 -0
- package/mirror/files/00054.json +1 -0
- package/mirror/files/00055.json +1 -0
- package/mirror/files/00056.js +575 -0
- package/mirror/files/00057.json +1 -0
- package/mirror/files/00058.json +1 -0
- package/mirror/files/00059.js +360 -0
- package/mirror/files/00060.json +1 -0
- package/mirror/files/00061.json +1 -0
- package/mirror/files/00062.json +1 -0
- package/mirror/files/00063.json +1 -0
- package/mirror/files/00064.json +1 -0
- package/mirror/files/00065.js +144 -0
- package/mirror/files/00066.js +7 -0
- package/mirror/files/00067.json +1 -0
- package/mirror/files/00068.json +1 -0
- package/mirror/files/00069.json +1 -0
- package/mirror/files/00070.json +1 -0
- package/mirror/files/00071.json +1 -0
- package/mirror/files/00072.json +1 -0
- package/mirror/files/00073.js +1 -0
- package/mirror/files/00074.json +1 -0
- package/mirror/files/00075.json +1 -0
- package/mirror/files/00076.json +1 -0
- package/mirror/files/00077.js +45 -0
- package/mirror/files/00078.js +1348 -0
- package/mirror/files/00079.json +1 -0
- package/mirror/files/00080.json +1 -0
- package/mirror/files/00081.js +1 -0
- package/mirror/files/00082.json +1 -0
- package/mirror/files/00083.json +1 -0
- package/mirror/files/00084.js +7 -0
- package/mirror/files/00085.json +1 -0
- package/mirror/files/00086.json +1 -0
- package/mirror/files/00087.js +7 -0
- package/mirror/files/00088.json +1 -0
- package/mirror/files/00089.json +1 -0
- package/mirror/files/00090.js +7 -0
- package/mirror/files/00091.json +1 -0
- package/mirror/files/00092.json +1 -0
- package/mirror/files/00093.js +102 -0
- package/mirror/files/00094.json +1 -0
- package/mirror/files/00095.json +1 -0
- package/mirror/files/00096.json +1 -0
- package/mirror/files/00097.json +1 -0
- package/mirror/files/00098.json +1 -0
- package/mirror/files/00099.json +1 -0
- package/mirror/files/00100.json +1 -0
- package/mirror/files/00101.js +102 -0
- package/mirror/files/00102.json +1 -0
- package/mirror/files/00103.json +1 -0
- package/mirror/files/00104.json +1 -0
- package/mirror/files/00105.json +1 -0
- package/mirror/files/00106.json +1 -0
- package/mirror/files/00107.js +110 -0
- package/mirror/files/00108.json +1 -0
- package/mirror/files/00109.json +1 -0
- package/mirror/files/00110.json +1 -0
- package/mirror/files/00111.json +1 -0
- package/mirror/files/00112.json +1 -0
- package/mirror/files/00113.json +1 -0
- package/mirror/files/00114.json +1 -0
- package/mirror/files/00115.json +1 -0
- package/mirror/files/00116.json +1 -0
- package/mirror/files/00117.json +1 -0
- package/mirror/files/00118.json +1 -0
- package/mirror/files/00119.json +1 -0
- package/mirror/files/00120.json +1 -0
- package/mirror/files/00121.json +1 -0
- package/mirror/files/00122.json +1 -0
- package/mirror/files/00123.json +1 -0
- package/mirror/files/00124.json +1 -0
- package/mirror/files/00125.json +1 -0
- package/mirror/files/00126.json +1 -0
- package/mirror/files/00127.json +1 -0
- package/mirror/files/00128.json +1 -0
- package/mirror/files/00129.json +1 -0
- package/mirror/files/00130.json +1 -0
- package/mirror/files/00131.json +1 -0
- package/mirror/files/00132.js +110 -0
- package/mirror/files/00133.json +1 -0
- package/mirror/files/00134.json +1 -0
- package/mirror/files/00135.json +1 -0
- package/mirror/files/00136.json +1 -0
- package/mirror/files/00137.js +26 -0
- package/mirror/files/00138.json +1 -0
- package/mirror/files/00139.json +1 -0
- package/mirror/files/00140.json +1 -0
- package/mirror/files/00141.json +1 -0
- package/mirror/files/00142.json +1 -0
- package/mirror/files/00143.json +1 -0
- package/mirror/files/00144.js +26 -0
- package/mirror/files/00145.json +1 -0
- package/mirror/files/00146.json +1 -0
- package/mirror/files/00147.js +29 -0
- package/mirror/files/00148.json +1 -0
- package/mirror/files/00149.json +1 -0
- package/mirror/files/00150.js +23 -0
- package/mirror/files/00151.json +1 -0
- package/mirror/files/00152.json +1 -0
- package/mirror/files/00153.js +719 -0
- package/mirror/files/00154.js +9575 -0
- package/mirror/files/00155.js +108 -0
- package/mirror/files/00156.js +379 -0
- package/mirror/files/00157.js +48 -0
- package/mirror/files/00158.json +16 -0
- package/mirror/manifest.json +1582 -0
- package/node_modules/@capyclaw/asset-service/README.md +48 -0
- package/node_modules/@capyclaw/asset-service/cordis.patch.yml +4 -0
- package/node_modules/@capyclaw/asset-service/dsh-suite.json +29 -0
- package/node_modules/@capyclaw/asset-service/lib/host.mjs +14 -0
- package/node_modules/@capyclaw/asset-service/package.json +59 -0
- package/node_modules/@capyclaw/asset-service/src/index.mjs +310 -0
- package/node_modules/@capyclaw/foundation/README.md +51 -0
- package/node_modules/@capyclaw/foundation/abi/assets.mjs +26 -0
- package/node_modules/@capyclaw/foundation/abi/bridge.mjs +88 -0
- package/node_modules/@capyclaw/foundation/abi/errors.mjs +63 -0
- package/node_modules/@capyclaw/foundation/abi/index.mjs +50 -0
- package/node_modules/@capyclaw/foundation/abi/kinds.mjs +271 -0
- package/node_modules/@capyclaw/foundation/abi/loader.mjs +352 -0
- package/node_modules/@capyclaw/foundation/abi/schema.mjs +98 -0
- package/node_modules/@capyclaw/foundation/abi/spec.mjs +258 -0
- package/node_modules/@capyclaw/foundation/abi/validate.mjs +24 -0
- package/node_modules/@capyclaw/foundation/abi/version.mjs +140 -0
- package/node_modules/@capyclaw/foundation/abi/visibility.mjs +90 -0
- package/node_modules/@capyclaw/foundation/cordis.patch.yml +5 -0
- package/node_modules/@capyclaw/foundation/kit/index.mjs +6 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/client-panel.mjs +98 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/host-event.mjs +35 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/http-router.mjs +69 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/lifecycle-hook.mjs +72 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/own-server.mjs +113 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/raw.mjs +69 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/runtime-driver.mjs +120 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/service-provider.mjs +77 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/skill-provider.mjs +56 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/tool-provider.mjs +50 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/ui-panel.mjs +64 -0
- package/node_modules/@capyclaw/foundation/lib/ctx-service.mjs +42 -0
- package/node_modules/@capyclaw/foundation/lib/host/caps.mjs +38 -0
- package/node_modules/@capyclaw/foundation/lib/host/contract.mjs +88 -0
- package/node_modules/@capyclaw/foundation/lib/host/dsh.mjs +54 -0
- package/node_modules/@capyclaw/foundation/lib/host/memory.mjs +187 -0
- package/node_modules/@capyclaw/foundation/lib/host.mjs +23 -0
- package/node_modules/@capyclaw/foundation/lib/kernel.mjs +195 -0
- package/node_modules/@capyclaw/foundation/lib/skill/scan.mjs +115 -0
- package/node_modules/@capyclaw/foundation/lib/subsystems/events.mjs +60 -0
- package/node_modules/@capyclaw/foundation/lib/subsystems/log.mjs +51 -0
- package/node_modules/@capyclaw/foundation/lib/subsystems/net.mjs +198 -0
- package/node_modules/@capyclaw/foundation/package.json +53 -0
- package/node_modules/@capyclaw/foundation/runtime/index.mjs +20 -0
- package/node_modules/@capyclaw/plugin-kit/INTEGRATION.md +100 -0
- package/node_modules/@capyclaw/plugin-kit/README.md +70 -0
- package/node_modules/@capyclaw/plugin-kit/bin/sync.mjs +103 -0
- package/node_modules/@capyclaw/plugin-kit/package.json +71 -0
- package/node_modules/@capyclaw/plugin-kit/src/cli.mjs +56 -0
- package/node_modules/@capyclaw/plugin-kit/src/config.mjs +142 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat-worker.js +132 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat.mjs +26 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/lease.mjs +60 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/shadow.mjs +219 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/transport.js +13 -0
- package/node_modules/@capyclaw/plugin-kit/src/index.mjs +13 -0
- package/node_modules/@capyclaw/plugin-kit/src/pack.mjs +230 -0
- package/node_modules/@capyclaw/plugin-kit/src/runtime/context.mjs +128 -0
- package/node_modules/@capyclaw/plugin-kit/src/self-contained.mjs +307 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/api.mjs +45 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/http.mjs +113 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/mcp-http.mjs +150 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/server.mjs +131 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/static.mjs +79 -0
- package/node_modules/@capyclaw/plugin-kit/src/skills/provider.mjs +82 -0
- package/node_modules/@capyclaw/plugin-kit/src/store/blob-store.mjs +109 -0
- package/node_modules/@capyclaw/plugin-kit/src/store/content-store.mjs +17 -0
- package/node_modules/@capyclaw/plugin-kit/src/store/journal-store.mjs +89 -0
- package/node_modules/@capyclaw/plugin-kit/src/tools/result.mjs +57 -0
- package/node_modules/@capyclaw/plugin-kit/src/tools/validate.mjs +150 -0
- package/node_modules/@capyclaw/plugin-kit/src/tuning.mjs +82 -0
- package/node_modules/@capyclaw/plugin-kit/src/util/fs-lock.mjs +132 -0
- package/node_modules/@capyclaw/plugin-kit/src/util/http.mjs +130 -0
- package/node_modules/@capyclaw/plugin-kit/src/workspace/manager.mjs +664 -0
- package/node_modules/@capyclaw/plugin-kit/src/zip.mjs +181 -0
- package/node_modules/@capyclaw/service-host/README.md +86 -0
- package/node_modules/@capyclaw/service-host/cordis.patch.yml +4 -0
- package/node_modules/@capyclaw/service-host/dsh-suite.json +29 -0
- package/node_modules/@capyclaw/service-host/lib/host.mjs +22 -0
- package/node_modules/@capyclaw/service-host/package.json +60 -0
- package/node_modules/@capyclaw/service-host/src/index.mjs +570 -0
- package/node_modules/@capyclaw/service-host/src/tuning.mjs +63 -0
- package/node_modules/@capyclaw/suite-kit/README.md +289 -0
- package/node_modules/@capyclaw/suite-kit/bin/dsh-domain.mjs +98 -0
- package/node_modules/@capyclaw/suite-kit/bin/dsh-suite.mjs +174 -0
- package/node_modules/@capyclaw/suite-kit/client/embed.js +35 -0
- package/node_modules/@capyclaw/suite-kit/domain.schema.json +129 -0
- package/node_modules/@capyclaw/suite-kit/package.json +58 -0
- package/node_modules/@capyclaw/suite-kit/src/activation-registry.mjs +184 -0
- package/node_modules/@capyclaw/suite-kit/src/artifacts.mjs +131 -0
- package/node_modules/@capyclaw/suite-kit/src/capability.mjs +181 -0
- package/node_modules/@capyclaw/suite-kit/src/compose.mjs +201 -0
- package/node_modules/@capyclaw/suite-kit/src/domain.mjs +138 -0
- package/node_modules/@capyclaw/suite-kit/src/embed.mjs +81 -0
- package/node_modules/@capyclaw/suite-kit/src/host.mjs +230 -0
- package/node_modules/@capyclaw/suite-kit/src/index.mjs +24 -0
- package/node_modules/@capyclaw/suite-kit/src/manifest.mjs +263 -0
- package/node_modules/@capyclaw/suite-kit/src/orchestration.mjs +100 -0
- package/node_modules/@capyclaw/suite-kit/src/profile.mjs +584 -0
- package/node_modules/@capyclaw/suite-kit/src/surface.mjs +28 -0
- package/node_modules/@capyclaw/suite-kit/suite.schema.json +128 -0
- package/node_modules/@capyclaw/work-store/README.md +83 -0
- package/node_modules/@capyclaw/work-store/STANDARD.md +263 -0
- package/node_modules/@capyclaw/work-store/cordis.patch.yml +3 -0
- package/node_modules/@capyclaw/work-store/dsh-suite.json +33 -0
- package/node_modules/@capyclaw/work-store/icon.svg +7 -0
- package/node_modules/@capyclaw/work-store/lib/host.mjs +21 -0
- package/node_modules/@capyclaw/work-store/package.json +68 -0
- package/node_modules/@capyclaw/work-store/src/backend.mjs +90 -0
- package/node_modules/@capyclaw/work-store/src/db.mjs +199 -0
- package/node_modules/@capyclaw/work-store/src/envelope.mjs +132 -0
- package/node_modules/@capyclaw/work-store/src/index.mjs +571 -0
- package/node_modules/@capyclaw/work-store/src/interop.mjs +70 -0
- package/node_modules/@capyclaw/work-store/src/refs.mjs +99 -0
- package/node_modules/@capyclaw/work-store/src/routes.mjs +135 -0
- package/package.json +82 -4
- package/plugin.mjs +644 -0
- package/static/index.html +2068 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"status":"ok","item":{"id":3687,"ref":"WORKS-3687","name":"PPT 演示示例:装饰器只读放映","tags":"外接,示例","image_url":"","thumb_url":"","emoji":"📑","status":3,"visible_to":[],"is_pinned":false,"is_locked":false,"ban_hidden":false,"author":"站长","author_id":1,"author_username":"root","author_avatar":"emoji:🦔","view_count":323,"like_count":1,"favorite_count":0,"fork_count":0,"referenced_count":0,"latest_version":16,"default_version":16,"forked_from_ref":"","fork_base_version":0,"description":"# PPT 演示示例\n\n点顶图查看 PPTist 只读放映(数据 = WORKFLOW-SOURCE 分节的幻灯片数据 JSON;编辑请用 ddr0.com/apps/works/3682/)。","description_truncated":false,"description_next_offset":97,"brief":"PPT 幻灯片顶图点击只读放映。","created_at":"2026-10-12T16:31:08.036525+08:00","last_published_at":"2026-11-08T13:59:02.302828+08:00","updated_at":"2026-11-08T13:59:02.301529+08:00","code_url":"/api/works/works/3687/version/16/js","has_code":true,"view":{"kind":"code","decorator":"WORKS-3686@15","source":"%%%WORKS-WORKFLOW-SOURCE%%%"},"launch":{"type":"runtime","runtime":{"contract":"work-v1","work_ref":"WORKS-3687","code_url":"/api/works/works/3687/version/16/js","caps_url":"","decorator":"WORKS-3686@15"}},"item_type":"works","delivery_adopted":null,"delivery_published":null,"is_favorited":false,"references":[{"ref":"WORKS-3686","name":"PPT 演示文档装饰器套件","kind":"works","version":15,"follow":false,"work_version":16,"created_at":"2026-11-08T13:59:02.333329+08:00"}],"attachments":[]}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"liked":true,"favorited":false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Work.register({ mount(ctx) { ctx.stage.innerHTML = '<div style="padding:24px;opacity:.7">本作品的看点在顶图:点顶图开 PPT 幻灯片只读放映(WORKFLOW-SOURCE 分节数据)。</div>'; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"status":"ok","item":{"id":3691,"ref":"WORKS-3691","name":"纯笔迹画板装饰器套件","tags":"外接,套件","image_url":"","thumb_url":"","emoji":"✒️","status":3,"visible_to":[],"is_pinned":false,"is_locked":false,"ban_hidden":false,"author":"站长","author_id":1,"author_username":"root","author_avatar":"emoji:🦔","view_count":162,"like_count":0,"favorite_count":0,"fork_count":0,"referenced_count":1,"latest_version":6,"default_version":6,"forked_from_ref":"","fork_base_version":0,"description":"[TOC]\n\n# 纯笔迹画板装饰器套件\n\nMETA `view.decorator` 的渲染套件(flow-kit 形):宿主作品声明 decorator\n钉版本套件后,顶图点击在标准容器(WorkView 沙箱)内打开**一支笔、\n一张白纸**的零持久化墨迹画板。\n\n## 数据契约(画板设置 · 严格声明制)\n\n数据分节放画板的全部设置——**内核不预设任何设置,没有就是没有**:\n\n```json\n{\"paper\": {\"fill\": \"#ffffff\"},\n \"pen\": {\"ink\": \"#1a1a1a\", \"base\": 3.2, \"pressureGain\": 1, \"steady\": 0.55}}\n```\n\n- `pen` **完整声明**才有笔:`ink` 墨色(合法 CSS 色)+ `base` 满压\n 线宽(>0)+ `pressureGain` 压感响应(≥0,0 = 恒宽)+ `steady` 稳笔\n 系数(0 ≤ s < 1)。任一缺失/非法 = 没有这支笔——指针零落墨,\n 画不出任何笔迹(不补全、不预设)。\n- `paper.fill` 声明且合法才画底色;缺席/非法 = 无底。\n- 空/坏 viewDoc = 空板(无底无笔)。\n\n## 架构(纯内核 + 打包注入)\n\n套件源码两层:`source_code/` = 纯笔迹内核(笔迹采集状态机、只增账本、\n抽稀——零参数、零资源、零 DOM);`packaging_program_1/` = 打包时注入的\n具体实现(canvas 双层、指针接线、Work 契约装配、数据分节配置解析)。\n换笔换纸 = 宿主数据分节声明即可(零重构建),内核不动;后续迭代一律\n走打包程序推送。\n\n## 用法\n\n宿主作品 .works 的 META view 声明(decorator 钉本套件版本)+ 数据分节\n放画板设置(pen/paper);宿主无需 CODE 分节(decorator 形态宿主 CODE\n零运行期消费者)。\n\n## 特性\n\n- 压感笔迹:数位板压感采样、速度积分线宽、稳笔滤波;鼠标以速度代\n 压感(慢画粗、快画细)。\n- 两层画布单向写入、每笔只写自己的包围盒;落笔即终态,无撤回。\n- **零持久化**:不落盘、不读写 localStorage,刷新即新画板;无保存/\n 导入/导出/发布通道。","description_truncated":false,"description_next_offset":1009,"brief":"一支笔一张白纸,零持久化墨迹画板。","created_at":"2026-10-13T20:53:20.468784+08:00","last_published_at":"2026-11-06T22:19:08.269562+08:00","updated_at":"2026-11-06T22:19:08.260801+08:00","code_url":"/api/works/works/3691/version/6/js","has_code":true,"launch":{"type":"document","document":{"path":"/apps/works/doc/3691"}},"item_type":"works","delivery_adopted":null,"delivery_published":null,"is_favorited":false,"references":[],"attachments":[]}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"liked":false,"favorited":false}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @caps flow-kit,work-caps
|
|
3
|
+
* 纯笔迹画板装饰器套件 —— 纯笔迹内核(source_code/)+ 打包时注入的
|
|
4
|
+
* 具体实现(本层):META view.decorator 渲染套件,一支笔一张白纸,
|
|
5
|
+
* 零持久化墨迹画板(无保存/导入/导出/发布通道)。
|
|
6
|
+
*/
|
|
7
|
+
"use strict";(()=>{var I=Object.defineProperty;var A=(o,t,e)=>t in o?I(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var d=(o,t,e)=>A(o,typeof t!="symbol"?t+"":t,e);function p(o,t){return Math.round(o*t)/t}var C=class{constructor(t,e,n,i,s){this.nib=t;d(this,"pts",[]);d(this,"x");d(this,"y");d(this,"t");d(this,"v",.6);d(this,"n",0);d(this,"w");this.x=e,this.y=n,this.t=i,this.w=this.width(.6,s)*this.rampAt(0),this.pts.push([p(e,2),p(n,2),p(this.w,4),0])}width(t,e){let{base:n,pressureGain:i}=this.nib;if(i<=0)return n;let s=Math.min(1,i),r=n*.25;return e>=0?r+(n-r)*s*Math.pow(Math.min(1,e),1.2)*(.75+.25*Math.exp(-t/1.6)):r+(n-r)*s*Math.exp(-t/.75)}rampAt(t){return this.nib.pressureGain>0?Math.min(1,.35+t*.16):1}add(t,e,n,i){let s=this.x+(t-this.x)*this.nib.steady,r=this.y+(e-this.y)*this.nib.steady,l=Math.hypot(s-this.x,r-this.y),h=Math.max(1,n-this.t);if(l<1.2)return null;this.v+=(Math.min(8,l/h)-this.v)*.3,this.n++;let a=this.width(this.v,i)*this.rampAt(this.n);this.w+=(a-this.w)*(this.nib.pressureGain>0?.28:1),this.x=s,this.y=r,this.t=n;let f=[p(s,2),p(r,2),p(this.w,4),Math.min(250,Math.round(h))];return this.pts.push(f),f}end(t,e,n){if(Math.hypot(t-this.x,e-this.y)>1.2&&this.pts.length>1){let s=this.nib.pressureGain>0?.6:1,r=[p(t,2),p(e,2),p(this.w*s,4),Math.min(250,Math.max(1,Math.round(n-this.t)))];return this.pts.push(r),r}return null}};function B(o){let t=1/0,e=1/0,n=-1/0,i=-1/0;for(let[s,r,l]of o){let h=Math.max(l,1)/2+1;s-h<t&&(t=s-h),s+h>n&&(n=s+h),r-h<e&&(e=r-h),r+h>i&&(i=r+h)}return{x0:t,y0:e,x1:n,y1:i}}var E=class{constructor(){d(this,"list",[])}get strokes(){return this.list}get count(){return this.list.length}commit(t){let e={pts:t.slice(),bbox:B(t)};return this.list.push(e),e}};var F="ink-board-suite-stage",W=16,D=18,H=.35,G=40,U=2.5,N=(o,t)=>[(o[0]+t[0])/2,(o[1]+t[1])/2,(o[2]+t[2])/2,0],O=o=>typeof o=="object"&&o!==null,L=o=>typeof o=="number"&&Number.isFinite(o)?o:null,M=typeof document<"u"?document.createElement("canvas").getContext("2d"):null;function _(o){if(typeof o!="string"||!o.trim()||!M)return null;let t=o.trim(),e="#123456";return M.fillStyle=e,M.fillStyle=t,M.fillStyle===e&&t.toLowerCase()!==e?null:M.fillStyle}var k={paperFill:null,pen:null};function z(o){if(!O(o))return null;let t=_(o.ink),e=L(o.base),n=L(o.pressureGain),i=L(o.steady);return t===null||e===null||e<=0||n===null||n<0||i===null||i<0||i>=1?null:{ink:t,nib:{base:e,pressureGain:n,steady:i}}}function j(o){let t=(o||"").trim();if(!t)return k;try{let e=JSON.parse(t);if(!O(e))return k;let n=O(e.paper)?e.paper:{};return{paperFill:_(n.fill),pen:z(e.pen)}}catch{return k}}var T=class{constructor(t,e=k){this.stage=t;this.paper=document.createElement("canvas");this.inkCv=document.createElement("canvas");this.tailCv=document.createElement("canvas");this.sheet=new E;this.pen=null;this.live=[];this.rect=null;this.ro=null;this.w=0;this.h=0;this.deposited=0;this.hot=null;this.hist=[];this.onDown=t=>{if(t.button!==0||this.pen||!this.penConf)return;try{this.tailCv.setPointerCapture(t.pointerId)}catch{}let[e,n]=this.local(t);this.pen=new C(this.penConf.nib,e,n,t.timeStamp,this.pressure(t)),this.live=this.pen.pts,this.deposited=0,this.hot=[e,n],this.hist=[{x:e,y:n,t:t.timeStamp}],this.paintTail(),t.preventDefault()};this.onMove=t=>{if(!this.pen)return;let e=typeof t.getCoalescedEvents=="function"?t.getCoalescedEvents():[],n=e.length?e:[t],i=n[n.length-1],[s,r]=this.local(i),l=i.timeStamp;this.hist.push({x:s,y:r,t:l});let h=l-80;for(;this.hist.length>6||this.hist.length>2&&this.hist[0].t<h;)this.hist.shift();for(let a of n){let[f,m]=this.local(a);this.sample(f,m,a.timeStamp,this.pressure(a))}t.preventDefault()};this.onUp=t=>{let e=this.pen;if(!e)return;let[n,i]=this.local(t);this.sample(n,i,t.timeStamp,this.pressure(t)),e.end(n,i,t.timeStamp),this.finishStroke()};this.penConf=e.pen,this.paperFill=e.paperFill,this.stage.dataset.mark=F,this.stage.innerHTML="",this.stage.style.position||(this.stage.style.position="relative");for(let s of[this.paper,this.inkCv,this.tailCv])s.style.position="absolute",s.style.inset="0",s.style.width="100%",s.style.height="100%",s.style.touchAction="none",this.stage.appendChild(s);let n=this.inkCv.getContext("2d");if(!n)throw new Error("canvas 2d \u4E0D\u53EF\u7528");this.ink=n;let i=this.tailCv.getContext("2d");if(!i)throw new Error("canvas 2d \u4E0D\u53EF\u7528");this.tail=i,this.tailCv.addEventListener("pointerdown",this.onDown),this.tailCv.addEventListener("pointermove",this.onMove),this.tailCv.addEventListener("pointerup",this.onUp),this.tailCv.addEventListener("pointercancel",this.onUp),this.resize(),typeof ResizeObserver=="function"&&(this.ro=new ResizeObserver(()=>this.resize()),this.ro.observe(this.stage))}destroy(){this.ro?.disconnect(),this.ro=null,this.tailCv.removeEventListener("pointerdown",this.onDown),this.tailCv.removeEventListener("pointermove",this.onMove),this.tailCv.removeEventListener("pointerup",this.onUp),this.tailCv.removeEventListener("pointercancel",this.onUp),this.pen=null,this.hot=null,this.hist=[],this.stage.innerHTML=""}resize(){let t=Math.round(this.stage.clientWidth),e=Math.round(this.stage.clientHeight);if(e===0&&!this.stage.style.height&&(this.stage.style.height="100vh",e=Math.round(this.stage.clientHeight)),t===0&&!this.stage.style.width&&(this.stage.style.width="100vw",t=Math.round(this.stage.clientWidth)),t=Math.max(1,t),e=Math.max(1,e),t===this.w&&e===this.h)return;this.w=t,this.h=e;let n=window.devicePixelRatio||1;for(let s of[this.paper,this.inkCv,this.tailCv])s.width=Math.round(t*n),s.height=Math.round(e*n);let i=this.paper.getContext("2d");i&&(i.setTransform(n,0,0,n,0,0),this.paperFill&&(i.fillStyle=this.paperFill,i.fillRect(0,0,t,e))),this.ink.setTransform(n,0,0,n,0,0),this.ink.lineCap="round",this.ink.lineJoin="round",this.penConf&&(this.ink.strokeStyle=this.penConf.ink,this.ink.fillStyle=this.penConf.ink),this.tail.setTransform(n,0,0,n,0,0),this.tail.lineCap="round",this.tail.lineJoin="round",this.penConf&&(this.tail.strokeStyle=this.penConf.ink,this.tail.fillStyle=this.penConf.ink),this.rect=null,this.replay(),this.deposited=this.live.length}replay(){this.ink.clearRect(0,0,this.w,this.h);for(let t of this.sheet.strokes)this.drawStroke(t.pts);this.live.length&&this.drawStroke(this.live)}drawStroke(t){this.drawSegs(this.ink,t,0,t.length)}drawSegs(t,e,n,i){let s=e.length;if(s===1){n<=0&&this.dotOn(t,e[0]);return}for(let r=Math.max(0,n);r<Math.min(i,s);r++){let l=r===0?e[0]:N(e[r-1],e[r]),h=r>=s-1?e[s-1]:N(e[r],e[r+1]),a=e[r],f=Math.hypot(a[0]-l[0],a[1]-l[1])+Math.hypot(h[0]-a[0],h[1]-a[1]),m=Math.max(1,Math.ceil(f/U)),y=l[0],P=l[1];for(let b=1;b<=m;b++){let c=b/m,u=1-c,g=u*u*l[0]+2*u*c*a[0]+c*c*h[0],x=u*u*l[1]+2*u*c*a[1]+c*c*h[1];t.lineWidth=Math.max(.5,l[2]+(h[2]-l[2])*(c-.5/m)),t.beginPath(),t.moveTo(y,P),t.lineTo(g,x),t.stroke(),y=g,P=x}}}dotOn(t,e){t.beginPath(),t.arc(e[0],e[1],Math.max(.4,e[2]/2),0,Math.PI*2),t.fill()}sample(t,e,n,i){this.hot=[t,e];let s=this.pen;if(s){if(s.add(t,e,n,i)){let r=s.pts.length-1;this.drawSegs(this.ink,s.pts,r-1,r),this.deposited=r}this.paintTail()}}paintTail(){this.tail.clearRect(0,0,this.w,this.h);let t=this.pen,e=this.penConf;if(!t||!e||!this.hot)return;let n=t.pts,i=n.length,s=n[i-1];if(i===1){this.dotOn(this.tail,s);return}if(!(Math.hypot(this.hot[0]-s[0],this.hot[1]-s[1])>1.2)){this.drawSegs(this.tail,n,i-1,i);return}let l=e.nib.pressureGain>0?.6:1,h=[p(this.hot[0],2),p(this.hot[1],2),p(s[2]*l,4),0],a=this.predictTail();a&&(this.tail.save(),this.tail.globalAlpha=H,this.drawSegs(this.tail,[h,[a[0],a[1],s[2],0]],0,2),this.tail.restore()),this.drawSegs(this.tail,[n[i-2],s,h],1,3)}predictTail(){let t=this.hist,e=t.length;if(e<3)return null;let n=t[e-1],i=e-1;for(;i>0&&n.t-t[i-1].t<=G;)i--;i=Math.min(i,e-3);let s=e-i;if(n.t-t[i].t<1)return null;let r=0,l=0,h=0,a=0,f=0,m=0;for(let v=i;v<e;v++){let w=t[v].t-n.t;r+=w,l+=t[v].x,h+=t[v].y,a+=w*w,f+=w*t[v].x,m+=w*t[v].y}let y=s*a-r*r;if(!(y>1e-9))return null;let P=(s*f-r*l)/y,b=(s*m-r*h)/y,c=n.x+P*W,u=n.y+b*W,g=c-n.x,x=u-n.y,S=Math.hypot(g,x);return S<2?null:(S>D&&(c=n.x+g/S*D,u=n.y+x/S*D),[c,u])}local(t){return this.rect||(this.rect=this.tailCv.getBoundingClientRect()),[t.clientX-this.rect.left,t.clientY-this.rect.top]}pressure(t){return t.pointerType==="mouse"?-1:t.pressure>0?t.pressure:.5}finishStroke(){let t=this.pen;t&&(this.drawSegs(this.ink,t.pts,this.deposited,t.pts.length),this.sheet.commit(t.pts),this.pen=null,this.live=[],this.deposited=0,this.hot=null,this.hist=[],this.tail.clearRect(0,0,this.w,this.h))}demo(){if(this.pen||!this.penConf)return;let t=this.w/2,e=this.h/2,n=Math.min(this.w,this.h)*.32,i=performance.now(),s=t+n*Math.sin(Math.PI/6);this.pen=new C(this.penConf.nib,s,e,i,.4),this.live=this.pen.pts,this.deposited=0,this.hot=[s,e],this.hist=[{x:s,y:e,t:i}],this.paintTail();let r=140;for(let h=1;h<=r;h++){let a=h/r*Math.PI*2;this.sample(t+n*Math.sin(a*1.5+Math.PI/6),e+n*.72*Math.sin(a*2),i+h*12,.3+.65*Math.abs(Math.sin(a*1.5)))}let l=this.pen;l&&l.end(s,e,i+(r+1)*12),this.finishStroke()}},R=null;if(typeof window<"u"&&window.Work)window.Work.register({mount:o=>{R=new T(o.stage,j(o.viewDoc)),requestAnimationFrame(()=>o.ready?.())},destroy:()=>{R?.destroy(),R=null}});else{let o=document.querySelector("#app")??document.body;R=new T(o,k)}})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"status":"ok","item":{"id":3692,"ref":"WORKS-3692","name":"纯笔迹画板示例:一支笔一张白纸","tags":"外接,示例,绘画","image_url":"","thumb_url":"","emoji":"🎳","status":3,"visible_to":[],"is_pinned":true,"is_locked":false,"ban_hidden":false,"author":"站长","author_id":1,"author_username":"root","author_avatar":"emoji:🦔","view_count":314,"like_count":1,"favorite_count":2,"fork_count":0,"referenced_count":0,"latest_version":17,"default_version":17,"forked_from_ref":"","fork_base_version":0,"description":"# 纯笔迹画板示例\n\n点顶图打开墨迹画板(笔与纸面 = 数据分节声明:完整声明 pen 才有笔、声明 paper.fill 才有底色;不声明就没有——空板;落笔即终态、刷新即新画板)。","description_truncated":false,"description_next_offset":92,"brief":"META view.decorator 示例:顶图点击打开零持久化墨迹画板。","created_at":"2026-10-13T20:53:22.582620+08:00","last_published_at":"2026-11-08T21:21:56.730569+08:00","updated_at":"2026-11-08T21:21:56.725359+08:00","code_url":"","has_code":false,"view":{"kind":"code","decorator":"WORKS-3691@5","source":"%%%WORKS-WORKFLOW-SOURCE%%%"},"launch":{"type":"runtime","runtime":{"contract":"work-v1","work_ref":"WORKS-3692","code_url":"","caps_url":"","decorator":"WORKS-3691@5"}},"item_type":"works","delivery_adopted":null,"delivery_published":null,"is_favorited":true,"references":[{"ref":"WORKS-3691","name":"纯笔迹画板装饰器套件","kind":"works","version":5,"follow":false,"work_version":17,"created_at":"2026-11-08T21:21:56.774317+08:00"}],"attachments":[]}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"liked":true,"favorited":true}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @caps flow-kit,work-caps
|
|
3
|
+
* 纯笔迹画板装饰器套件 —— 纯笔迹内核(source_code/)+ 打包时注入的
|
|
4
|
+
* 具体实现(本层):META view.decorator 渲染套件,一支笔一张白纸,
|
|
5
|
+
* 零持久化墨迹画板(无保存/导入/导出/发布通道)。
|
|
6
|
+
*/
|
|
7
|
+
"use strict";(()=>{var W=Object.defineProperty;var N=(o,t,e)=>t in o?W(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var d=(o,t,e)=>N(o,typeof t!="symbol"?t+"":t,e);function p(o,t){return Math.round(o*t)/t}var x=class{constructor(t,e,n,i,s){this.nib=t;d(this,"pts",[]);d(this,"x");d(this,"y");d(this,"t");d(this,"v",.6);d(this,"n",0);d(this,"w");this.x=e,this.y=n,this.t=i,this.w=this.width(.6,s)*this.rampAt(0),this.pts.push([p(e,2),p(n,2),p(this.w,4),0])}width(t,e){let{base:n,pressureGain:i}=this.nib;if(i<=0)return n;let s=Math.min(1,i),r=n*.25;return e>=0?r+(n-r)*s*Math.pow(Math.min(1,e),1.2)*(.75+.25*Math.exp(-t/1.6)):r+(n-r)*s*Math.exp(-t/.75)}rampAt(t){return this.nib.pressureGain>0?Math.min(1,.35+t*.16):1}add(t,e,n,i){let s=this.x+(t-this.x)*this.nib.steady,r=this.y+(e-this.y)*this.nib.steady,a=Math.hypot(s-this.x,r-this.y),h=Math.max(1,n-this.t);if(a<1.2)return null;this.v+=(Math.min(8,a/h)-this.v)*.3,this.n++;let l=this.width(this.v,i)*this.rampAt(this.n);this.w+=(l-this.w)*(this.nib.pressureGain>0?.28:1),this.x=s,this.y=r,this.t=n;let f=[p(s,2),p(r,2),p(this.w,4),Math.min(250,Math.round(h))];return this.pts.push(f),f}end(t,e,n){if(Math.hypot(t-this.x,e-this.y)>1.2&&this.pts.length>1){let s=this.nib.pressureGain>0?.6:1,r=[p(t,2),p(e,2),p(this.w*s,4),Math.min(250,Math.max(1,Math.round(n-this.t)))];return this.pts.push(r),r}return null}};function _(o){let t=1/0,e=1/0,n=-1/0,i=-1/0;for(let[s,r,a]of o){let h=Math.max(a,1)/2+1;s-h<t&&(t=s-h),s+h>n&&(n=s+h),r-h<e&&(e=r-h),r+h>i&&(i=r+h)}return{x0:t,y0:e,x1:n,y1:i}}var M=class{constructor(){d(this,"list",[])}get strokes(){return this.list}get count(){return this.list.length}commit(t){let e={pts:t.slice(),bbox:_(t)};return this.list.push(e),e}};var A="ink-board-suite-stage",g=16,S=18,B=.35,I=2.5,L=(o,t)=>[(o[0]+t[0])/2,(o[1]+t[1])/2,(o[2]+t[2])/2,0],R=o=>typeof o=="object"&&o!==null,E=o=>typeof o=="number"&&Number.isFinite(o)?o:null,w=typeof document<"u"?document.createElement("canvas").getContext("2d"):null;function O(o){if(typeof o!="string"||!o.trim()||!w)return null;let t=o.trim(),e="#123456";return w.fillStyle=e,w.fillStyle=t,w.fillStyle===e&&t.toLowerCase()!==e?null:w.fillStyle}var C={paperFill:null,pen:null};function F(o){if(!R(o))return null;let t=O(o.ink),e=E(o.base),n=E(o.pressureGain),i=E(o.steady);return t===null||e===null||e<=0||n===null||n<0||i===null||i<0||i>=1?null:{ink:t,nib:{base:e,pressureGain:n,steady:i}}}function H(o){let t=(o||"").trim();if(!t)return C;try{let e=JSON.parse(t);if(!R(e))return C;let n=R(e.paper)?e.paper:{};return{paperFill:O(n.fill),pen:F(e.pen)}}catch{return C}}var P=class{constructor(t,e=C){this.stage=t;this.paper=document.createElement("canvas");this.inkCv=document.createElement("canvas");this.tailCv=document.createElement("canvas");this.sheet=new M;this.pen=null;this.live=[];this.rect=null;this.ro=null;this.w=0;this.h=0;this.deposited=0;this.hot=null;this.hist=[];this.onDown=t=>{if(t.button!==0||this.pen||!this.penConf)return;try{this.tailCv.setPointerCapture(t.pointerId)}catch{}let[e,n]=this.local(t);this.pen=new x(this.penConf.nib,e,n,t.timeStamp,this.pressure(t)),this.live=this.pen.pts,this.deposited=0,this.hot=[e,n],this.hist=[{x:e,y:n,t:t.timeStamp}],this.paintTail(),t.preventDefault()};this.onMove=t=>{if(!this.pen)return;let e=typeof t.getCoalescedEvents=="function"?t.getCoalescedEvents():[],n=e.length?e:[t],i=n[n.length-1],[s,r]=this.local(i),a=i.timeStamp;this.hist.push({x:s,y:r,t:a});let h=a-80;for(;this.hist.length>6||this.hist.length>2&&this.hist[0].t<h;)this.hist.shift();for(let l of n){let[f,m]=this.local(l);this.sample(f,m,l.timeStamp,this.pressure(l))}t.preventDefault()};this.onUp=t=>{let e=this.pen;if(!e)return;let[n,i]=this.local(t);this.sample(n,i,t.timeStamp,this.pressure(t)),e.end(n,i,t.timeStamp),this.finishStroke()};this.penConf=e.pen,this.paperFill=e.paperFill,this.stage.dataset.mark=A,this.stage.innerHTML="",this.stage.style.position||(this.stage.style.position="relative");for(let s of[this.paper,this.inkCv,this.tailCv])s.style.position="absolute",s.style.inset="0",s.style.width="100%",s.style.height="100%",s.style.touchAction="none",this.stage.appendChild(s);let n=this.inkCv.getContext("2d");if(!n)throw new Error("canvas 2d \u4E0D\u53EF\u7528");this.ink=n;let i=this.tailCv.getContext("2d");if(!i)throw new Error("canvas 2d \u4E0D\u53EF\u7528");this.tail=i,this.tailCv.addEventListener("pointerdown",this.onDown),this.tailCv.addEventListener("pointermove",this.onMove),this.tailCv.addEventListener("pointerup",this.onUp),this.tailCv.addEventListener("pointercancel",this.onUp),this.resize(),typeof ResizeObserver=="function"&&(this.ro=new ResizeObserver(()=>this.resize()),this.ro.observe(this.stage))}destroy(){this.ro?.disconnect(),this.ro=null,this.tailCv.removeEventListener("pointerdown",this.onDown),this.tailCv.removeEventListener("pointermove",this.onMove),this.tailCv.removeEventListener("pointerup",this.onUp),this.tailCv.removeEventListener("pointercancel",this.onUp),this.pen=null,this.hot=null,this.hist=[],this.stage.innerHTML=""}resize(){let t=Math.round(this.stage.clientWidth),e=Math.round(this.stage.clientHeight);if(e===0&&!this.stage.style.height&&(this.stage.style.height="100vh",e=Math.round(this.stage.clientHeight)),t===0&&!this.stage.style.width&&(this.stage.style.width="100vw",t=Math.round(this.stage.clientWidth)),t=Math.max(1,t),e=Math.max(1,e),t===this.w&&e===this.h)return;this.w=t,this.h=e;let n=window.devicePixelRatio||1;for(let s of[this.paper,this.inkCv,this.tailCv])s.width=Math.round(t*n),s.height=Math.round(e*n);let i=this.paper.getContext("2d");i&&(i.setTransform(n,0,0,n,0,0),this.paperFill&&(i.fillStyle=this.paperFill,i.fillRect(0,0,t,e))),this.ink.setTransform(n,0,0,n,0,0),this.ink.lineCap="round",this.ink.lineJoin="round",this.penConf&&(this.ink.strokeStyle=this.penConf.ink,this.ink.fillStyle=this.penConf.ink),this.tail.setTransform(n,0,0,n,0,0),this.tail.lineCap="round",this.tail.lineJoin="round",this.penConf&&(this.tail.strokeStyle=this.penConf.ink,this.tail.fillStyle=this.penConf.ink),this.rect=null,this.replay(),this.deposited=this.live.length}replay(){this.ink.clearRect(0,0,this.w,this.h);for(let t of this.sheet.strokes)this.drawStroke(t.pts);this.live.length&&this.drawStroke(this.live)}drawStroke(t){this.drawSegs(this.ink,t,0,t.length)}drawSegs(t,e,n,i){let s=e.length;if(s===1){n<=0&&this.dotOn(t,e[0]);return}for(let r=Math.max(0,n);r<Math.min(i,s);r++){let a=r===0?e[0]:L(e[r-1],e[r]),h=r>=s-1?e[s-1]:L(e[r],e[r+1]),l=e[r],f=Math.hypot(l[0]-a[0],l[1]-a[1])+Math.hypot(h[0]-l[0],h[1]-l[1]),m=Math.max(1,Math.ceil(f/I)),v=a[0],y=a[1];for(let b=1;b<=m;b++){let c=b/m,u=1-c,T=u*u*a[0]+2*u*c*l[0]+c*c*h[0],D=u*u*a[1]+2*u*c*l[1]+c*c*h[1];t.lineWidth=Math.max(.5,a[2]+(h[2]-a[2])*(c-.5/m)),t.beginPath(),t.moveTo(v,y),t.lineTo(T,D),t.stroke(),v=T,y=D}}}dotOn(t,e){t.beginPath(),t.arc(e[0],e[1],Math.max(.4,e[2]/2),0,Math.PI*2),t.fill()}sample(t,e,n,i){this.hot=[t,e];let s=this.pen;if(s){if(s.add(t,e,n,i)){let r=s.pts.length-1;this.drawSegs(this.ink,s.pts,r-1,r),this.deposited=r}this.paintTail()}}paintTail(){this.tail.clearRect(0,0,this.w,this.h);let t=this.pen,e=this.penConf;if(!t||!e||!this.hot)return;let n=t.pts,i=n.length,s=n[i-1];if(i===1){this.dotOn(this.tail,s);return}if(!(Math.hypot(this.hot[0]-s[0],this.hot[1]-s[1])>1.2)){this.drawSegs(this.tail,n,i-1,i);return}let a=e.nib.pressureGain>0?.6:1,h=[p(this.hot[0],2),p(this.hot[1],2),p(s[2]*a,4),0],l=this.predictTail();l&&(this.tail.save(),this.tail.globalAlpha=B,this.drawSegs(this.tail,[h,[l[0],l[1],s[2],0]],0,2),this.tail.restore()),this.drawSegs(this.tail,[n[i-2],s,h],1,3)}predictTail(){let t=this.hist;if(t.length<3)return null;let e=t[t.length-3],n=t[t.length-2],i=t[t.length-1],s=n.t-e.t,r=i.t-n.t;if(s<=0||r<=0)return null;let a=(n.x-e.x)/s,h=(n.y-e.y)/s,l=(i.x-n.x)/r,f=(i.y-n.y)/r,m=2/(s+r),v=i.x+l*g+.5*(l-a)*m*g*g,y=i.y+f*g+.5*(f-h)*m*g*g,b=v-i.x,c=y-i.y,u=Math.hypot(b,c);return u<2?null:(u>S&&(v=i.x+b/u*S,y=i.y+c/u*S),[v,y])}local(t){return this.rect||(this.rect=this.tailCv.getBoundingClientRect()),[t.clientX-this.rect.left,t.clientY-this.rect.top]}pressure(t){return t.pointerType==="mouse"?-1:t.pressure>0?t.pressure:.5}finishStroke(){let t=this.pen;t&&(this.drawSegs(this.ink,t.pts,this.deposited,t.pts.length),this.sheet.commit(t.pts),this.pen=null,this.live=[],this.deposited=0,this.hot=null,this.hist=[],this.tail.clearRect(0,0,this.w,this.h))}demo(){if(this.pen||!this.penConf)return;let t=this.w/2,e=this.h/2,n=Math.min(this.w,this.h)*.32,i=performance.now(),s=t+n*Math.sin(Math.PI/6);this.pen=new x(this.penConf.nib,s,e,i,.4),this.live=this.pen.pts,this.deposited=0,this.hot=[s,e],this.hist=[{x:s,y:e,t:i}],this.paintTail();let r=140;for(let h=1;h<=r;h++){let l=h/r*Math.PI*2;this.sample(t+n*Math.sin(l*1.5+Math.PI/6),e+n*.72*Math.sin(l*2),i+h*12,.3+.65*Math.abs(Math.sin(l*1.5)))}let a=this.pen;a&&a.end(s,e,i+(r+1)*12),this.finishStroke()}},k=null;if(typeof window<"u"&&window.Work)window.Work.register({mount:o=>{k=new P(o.stage,H(o.viewDoc)),requestAnimationFrame(()=>o.ready?.())},destroy:()=>{k?.destroy(),k=null}});else{let o=document.querySelector("#app")??document.body;k=new P(o,C)}})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"status":"ok","item":{"id":3693,"ref":"WORKS-3693","name":"Squiggle 笔迹文档示例:一张涂鸦","tags":"外接,示例,绘画","image_url":"","thumb_url":"","emoji":"📄","status":3,"visible_to":[],"is_pinned":true,"is_locked":false,"ban_hidden":false,"author":"站长","author_id":1,"author_username":"root","author_avatar":"emoji:🦔","view_count":189,"like_count":0,"favorite_count":1,"fork_count":0,"referenced_count":0,"latest_version":8,"default_version":8,"forked_from_ref":"","fork_base_version":0,"description":"# Squiggle 笔迹文档示例\n\n点顶图打开笔迹文档渲染(纸面底色与笔迹参数 = 数据分节 paper/pens 的完整声明,没声明就没有;本作品的数据分节放着这张涂鸦的笔画数据与外观声明)。","description_truncated":false,"description_next_offset":98,"brief":"顶图点击只读渲染一张笔迹文档。","created_at":"2026-10-13T21:37:48.370854+08:00","last_published_at":"2026-10-14T01:37:39.337375+08:00","updated_at":"2026-10-14T01:37:39.336283+08:00","code_url":"","has_code":false,"view":{"kind":"code","decorator":"WORKS-3579@7","source":"%%%WORKS-WORKFLOW-SOURCE%%%"},"launch":{"type":"runtime","runtime":{"contract":"work-v1","work_ref":"WORKS-3693","code_url":"","caps_url":"","decorator":"WORKS-3579@7"}},"item_type":"works","delivery_adopted":null,"delivery_published":null,"is_favorited":false,"references":[{"ref":"WORKS-3579","name":"Squiggle 笔迹文档装饰器套件","kind":"works","version":7,"follow":false,"work_version":8,"created_at":"2026-10-14T01:37:39.356398+08:00"}],"attachments":[]}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"liked":false,"favorited":false}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @caps flow-kit,work-caps
|
|
3
|
+
* Squiggle 笔迹文档装饰器套件 —— 纯抽象内核(source_code/,零图片
|
|
4
|
+
* 零配置数值)+ 打包时注入的具体实现(本层):META view.decorator
|
|
5
|
+
* 渲染套件,只读渲染宿主数据分节里的 DrawingDocument JSON。
|
|
6
|
+
*/
|
|
7
|
+
"use strict";(()=>{var P=t=>typeof t=="object"&&t!==null,R=t=>typeof t=="number"&&Number.isFinite(t)&&t>0,U=(t,e)=>{if(!P(t))throw new Error(`${e} must be an object`);if(t.mode!=="pen"&&t.mode!=="eraser")throw new Error(`${e}.mode must be "pen" or "eraser"`);if(!Array.isArray(t.pts))throw new Error(`${e}.pts must be an array`);let n=t.pts.map((i,o)=>{if(!Array.isArray(i)||i.length!==4)throw new Error(`${e}.pts[${o}] must be an array of four numbers`);if(!i.every(r=>typeof r=="number"&&Number.isFinite(r)))throw new Error(`${e}.pts[${o}] must contain only finite numbers`);return[i[0],i[1],i[2],i[3]]});return{mode:t.mode,pts:n}};function Y(t,e="strokes"){if(!Array.isArray(t))throw new Error(`${e} must be an array`);return t.map((n,i)=>U(n,`${e}[${i}]`))}function Q(t){if(!P(t))throw new Error("drawing document must be an object");if(!R(t.width))throw new Error("drawing document.width must be a finite positive number");if(!R(t.height))throw new Error("drawing document.height must be a finite positive number");if(t.background!=="paper"&&t.background!=="transparent")throw new Error('drawing document.background must be "paper" or "transparent"');return{width:t.width,height:t.height,background:t.background,strokes:Y(t.strokes,"drawing document.strokes")}}function A(t){let e=t;if(typeof t=="string")try{e=JSON.parse(t)}catch(n){let i=n instanceof Error?n.message:String(n);throw new Error(`invalid drawing document JSON: ${i}`)}return Q(e)}var L=(t,e)=>[(t[0]+e[0])/2,(t[1]+e[1])/2,(t[2]+e[2])/2,0];function F(t,e){return e.alpha*(1-e.fade+e.fade*Math.min(1,t/(e.base*e.nib)))}function*V(t,e){let n=t.length;for(let i=0;i<n;i++){let o=i===0?t[0]:L(t[i-1],t[i]),r=i>=n-1?t[n-1]:L(t[i],t[i+1]),a=t[i],m=Math.hypot(a[0]-o[0],a[1]-o[1])+Math.hypot(r[0]-a[0],r[1]-a[1]),l=Math.max(1,Math.ceil(m/2.5)),h=o[0],c=o[1];for(let p=1;p<=l;p++){let u=p/l,f=1-u,s=f*f*o[0]+2*f*u*a[0]+u*u*r[0],d=f*f*o[1]+2*f*u*a[1]+u*u*r[1],g=o[2]+(r[2]-o[2])*(u-.5/l);yield{x0:h,y0:c,x1:s,y1:d,w:g,alpha:F(g,e)},h=s,c=d}}}function z(t,e){return{x:t[0],y:t[1],r:t[2]/2,alpha:F(t[2],e)}}function H(t){let e=1e9,n=1e9,i=-1e9,o=-1e9;for(let r of t){let a=r[2]/2+5;r[0]-a<e&&(e=r[0]-a),r[0]+a>i&&(i=r[0]+a),r[1]-a<n&&(n=r[1]-a),r[1]+a>o&&(o=r[1]+a)}return i>e&&o>n?[e,n,i,o]:null}function N(t){let e=t>>>0;return function(){e=e+1831565813>>>0;let n=Math.imul(e^e>>>15,1|e);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}var X=t=>Math.pow(2,Math.round(Math.log2(t)*2)/2);function W(t,e,n=1){e=X(e);let i=t+e.toFixed(4)+":"+n,o=256,r=new Uint8ClampedArray(o*o*4),a=N(t==="print"?11:7),m=Math.max(1,1.6*e),l=Math.ceil(o/m)+2,h=new Float32Array(l*l);for(let p=0;p<h.length;p++)h[p]=a();let c=Math.round(o/m);c<1&&(c=1);for(let p=0;p<o;p++)for(let u=0;u<o;u++){let f=u/o*c,s=p/o*c,d=Math.floor(f),g=Math.floor(s),y=f-d,w=s-g,E=h[g%c*l+d%c],J=h[g%c*l+(d+1)%c],T=h[(g+1)%c*l+d%c],B=h[(g+1)%c*l+(d+1)%c];y=y*y*(3-2*y),w=w*w*(3-2*w);let k=(E+(J-E)*y)*(1-w)+(T+(B-T)*y)*w;k=k*.7+a()*.3;let b=(p*o+u)*4;r[b]=r[b+1]=r[b+2]=0;let x=G=>Math.round(255*(1-n)+n*G);t==="pencil"?r[b+3]=k>.3?x(255):k>.22?x(120):x(0):t==="print"?r[b+3]=x(k>.12?255:90):r[b+3]=x(k>.2?255:150)}return{key:i,size:o,rgba:r}}var q="squiggle-doc-suite-stage",M=t=>typeof t=="object"&&t!==null,K=t=>typeof t=="number"&&Number.isFinite(t)?t:null,C=t=>{let e=K(t);return e===null||e<0||e>1?null:e},$=t=>{let e=K(t);return e===null||e<=0?null:e},v=typeof document<"u"?document.createElement("canvas").getContext("2d"):null;function j(t){if(typeof t!="string"||!t.trim()||!v)return null;let e=t.trim(),n="#123456";return v.fillStyle=n,v.fillStyle=e,v.fillStyle===n&&e.toLowerCase()!==n?null:v.fillStyle}var Z=t=>t==="pencil"||t==="marker"||t==="print"?t:t===null?null:void 0;function I(t,e){if(!M(t))return null;let n=j(t.color),i=C(t.alpha),o=Z(t.mask),r=C(t.grain),a=$(t.base),m=$(t.nib),l=C(t.fade);return n===null||i===null||o===void 0||r===null||a===null||m===null||l===null?null:{color:n,alpha:i,mask:o,grain:r,base:a,nib:m,fade:l,op:e}}function tt(t){let e=M(t.pens)?t.pens:{},n=M(t.paper)?t.paper:{};return{paperFill:j(n.fill),pen:I(e.pen,"source-over"),eraser:I(e.eraser,"destination-out")}}var O="squiggle-doc-suite-style";if(typeof document<"u"&&!document.getElementById(O)){let t=document.createElement("style");t.id=O,t.textContent="html,body{margin:0;width:100%;height:100%}#app{width:100%;height:100vh}",document.head.appendChild(t)}var D=class{constructor(e,n,i){this.stage=e;this.conf=i;this.paper=document.createElement("canvas");this.inkCv=document.createElement("canvas");this.scratch=document.createElement("canvas");this.ro=null;this.w=0;this.h=0;this.s=1;this.ox=0;this.oy=0;this.tiles=new Map;this.patSeq=0;this.patCache=new Map;this.stage.dataset.mark=q,this.stage.innerHTML="",this.stage.style.position||(this.stage.style.position="relative");for(let r of[this.paper,this.inkCv])r.style.position="absolute",r.style.inset="0",r.style.width="100%",r.style.height="100%",r.style.touchAction="none",this.stage.appendChild(r);let o=this.inkCv.getContext("2d");if(!o)throw new Error("canvas 2d \u4E0D\u53EF\u7528");this.ink=o,this.doc=n,this.layout(),typeof ResizeObserver=="function"&&(this.ro=new ResizeObserver(()=>this.layout()),this.ro.observe(this.stage))}destroy(){this.ro?.disconnect(),this.ro=null,this.stage.innerHTML=""}layout(){let e=Math.round(this.stage.clientWidth),n=Math.round(this.stage.clientHeight);if(n===0&&!this.stage.style.height&&(this.stage.style.height="100vh",n=Math.round(this.stage.clientHeight)),e===0&&!this.stage.style.width&&(this.stage.style.width="100vw",e=Math.round(this.stage.clientWidth)),e=Math.max(1,e),n=Math.max(1,n),e===this.w&&n===this.h)return;this.w=e,this.h=n;let i=window.devicePixelRatio||1;for(let r of[this.paper,this.inkCv])r.width=Math.round(e*i),r.height=Math.round(n*i);this.scratch.width=this.inkCv.width,this.scratch.height=this.inkCv.height,this.s=Math.min(e/this.doc.width,n/this.doc.height),this.ox=(e-this.doc.width*this.s)/2,this.oy=(n-this.doc.height*this.s)/2;let o=this.paper.getContext("2d");o&&(o.setTransform(1,0,0,1,0,0),o.clearRect(0,0,this.paper.width,this.paper.height),this.doc.background==="paper"&&this.conf.paperFill&&(o.fillStyle=this.conf.paperFill,o.fillRect(0,0,this.paper.width,this.paper.height))),this.render()}render(){this.ink.setTransform(1,0,0,1,0,0),this.ink.clearRect(0,0,this.inkCv.width,this.inkCv.height);for(let e of this.doc.strokes)this.stroke(e)}row(e){return e.mode==="pen"?this.conf.pen:this.conf.eraser}stroke(e){let n=this.row(e);if(!n)return;let i=window.devicePixelRatio||1,o=this.s*i,r=this.ox*i,a=this.oy*i,m=H(e.pts);if(!m)return;let l=Math.max(0,Math.floor(m[0]*o+r)-2),h=Math.max(0,Math.floor(m[1]*o+a)-2),c=Math.min(this.inkCv.width,Math.ceil(m[2]*o+r)+2),p=Math.min(this.inkCv.height,Math.ceil(m[3]*o+a)+2);if(c<=l||p<=h)return;let u=c-l,f=p-h,s=this.scratch.getContext("2d");if(s){if(s.setTransform(1,0,0,1,0,0),s.clearRect(l,h,u,f),s.save(),s.beginPath(),s.rect(l,h,u,f),s.clip(),s.setTransform(o,0,0,o,r,a),s.lineCap=s.lineJoin="round",s.strokeStyle=s.fillStyle=n.color,e.pts.length===1){let d=z(e.pts[0],n);s.globalAlpha=d.alpha,s.beginPath(),s.arc(d.x,d.y,d.r,0,6.2832),s.fill()}else for(let d of V(e.pts,n))s.lineWidth=d.w,s.globalAlpha=d.alpha,s.beginPath(),s.moveTo(d.x0,d.y0),s.lineTo(d.x1,d.y1),s.stroke();s.restore(),n.mask&&(s.save(),s.setTransform(1,0,0,1,0,0),s.beginPath(),s.rect(l,h,u,f),s.clip(),s.globalCompositeOperation="destination-in",s.fillStyle=this.pattern(s,n.mask,o,n.grain),s.fillRect(l,h,u,f),s.restore()),this.ink.save(),this.ink.setTransform(1,0,0,1,0,0),this.ink.globalAlpha=1,this.ink.globalCompositeOperation=n.op,this.ink.drawImage(this.scratch,l,h,u,f,l,h,u,f),this.ink.restore()}}pattern(e,n,i,o){let r=W(n,i,o),a=this.tiles.get(r.key);if(!a){a=document.createElement("canvas"),a.width=a.height=r.size;let p=a.getContext("2d");if(p){let u=p.createImageData(r.size,r.size);u.data.set(r.rgba),p.putImageData(u,0,0)}this.tiles.set(r.key,a)}let m=e.canvas,h=(m.__id||(m.__id=++this.patSeq))+":"+r.key,c=this.patCache.get(h);return c||(c=e.createPattern(a,"repeat"),this.patCache.set(h,c)),c}};function et(t){let e=(t||"").trim();if(!e)return null;try{let n=JSON.parse(e);return!n||typeof n!="object"||Array.isArray(n)?null:(n.background!=="paper"&&n.background!=="transparent"&&(n.background="paper"),{doc:A(n),conf:tt(n)})}catch{return null}}var S=null;function nt(t,e,n,i){S=new D(t,e,n),requestAnimationFrame(()=>i?.())}function _(t,e){t.dataset.mark=q,t.innerHTML="",requestAnimationFrame(()=>e?.())}if(typeof window<"u"&&window.Work)window.Work.register({mount:t=>{let e=et(t.viewDoc);e?nt(t.stage,e.doc,e.conf,t.ready):_(t.stage,t.ready)},destroy:()=>{S?.destroy(),S=null}});else{let t=document.querySelector("#app")??document.body;_(t)}})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"status":"ok","item":{"id":3700,"ref":"WORKS-3700","name":"HexGL 反重力赛车","tags":"外接,游戏,WebGL,3D","image_url":"","thumb_url":"","emoji":"🏎️","status":3,"visible_to":[],"is_pinned":false,"is_locked":false,"ban_hidden":false,"author":"站长","author_id":1,"author_username":"root","author_avatar":"emoji:🦔","view_count":208,"like_count":1,"favorite_count":1,"fork_count":0,"referenced_count":0,"latest_version":13,"default_version":13,"forked_from_ref":"","fork_base_version":0,"description":"# HexGL 反重力赛车游戏\n\n一款完整的 3D WebGL 反重力赛车游戏,点击即玩。\n\n## 特性\n\n- **真 3D 渲染**:WebGL + Three.js 引擎,完整后期特效\n- **流畅物理**:碰撞检测、高度图采样、飞船动力学\n- **多控制模式**:支持键盘、触摸、游戏手柄\n- **单文件部署**:所有资源内联,无需加载\n\n## 游戏玩法\n\n驾驶反重力飞船在未来赛道上飞驰,收集加速道具,避免碰撞,挑战最快圈速。\n\n## 操作说明\n\n- **键盘**:方向键控制,空格刹车\n- **触摸**:屏幕左右滑动转向\n- **手柄**:摇杆/十字键控制\n\n## 技术实现\n\n基于 HexGL 开源项目(MIT License),TypeScript 重构版,采用 Vite 构建单文件 HTML,Three.js (legacy) 渲染引擎。\n\n原作者:Thibaut Despoulain (BKcore)","description_truncated":false,"description_next_offset":411,"brief":"完整的 3D WebGL 反重力赛车游戏,点击即玩","created_at":"2026-10-15T01:34:31.771174+08:00","last_published_at":"2026-11-07T18:56:02.266663+08:00","updated_at":"2026-11-07T18:56:02.261952+08:00","code_url":"/api/works/works/3700/version/13/js","has_code":true,"view":{"kind":"code"},"launch":{"type":"runtime","runtime":{"contract":"work-v1","work_ref":"WORKS-3700","code_url":"/api/works/works/3700/version/13/js","caps_url":"","decorator":""}},"item_type":"works","delivery_adopted":null,"delivery_published":null,"is_favorited":true,"references":[],"attachments":[]}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"liked":true,"favorited":true}
|