@capyclaw/browser-workbench 0.1.19 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/contract/browser-contract.json +45 -19
- package/node_modules/@capyclaw/asset-service/dsh-suite.json +1 -1
- package/node_modules/@capyclaw/asset-service/package.json +1 -1
- package/node_modules/@capyclaw/asset-service/src/index.mjs +10 -4
- package/node_modules/@capyclaw/document-workbench/package.json +6 -3
- package/node_modules/@capyclaw/document-workbench/src/client/index.mjs +56 -3
- package/node_modules/@capyclaw/document-workbench/src/client/visibility.mjs +112 -0
- package/node_modules/@capyclaw/document-workbench/src/model/manifest.mjs +6 -4
- package/node_modules/@capyclaw/document-workbench/src/model/ops.mjs +7 -2
- package/node_modules/@capyclaw/document-workbench/src/session/index.mjs +8 -0
- package/node_modules/@capyclaw/document-workbench/src/store/file-backend.mjs +17 -10
- package/node_modules/@capyclaw/document-workbench/src/store/projection.mjs +39 -0
- package/node_modules/@capyclaw/document-workbench/src/testing/index.mjs +14 -11
- package/node_modules/@capyclaw/foundation/abi/assets.mjs +26 -0
- package/node_modules/@capyclaw/foundation/abi/bridge.mjs +3 -1
- package/node_modules/@capyclaw/foundation/abi/index.mjs +15 -0
- package/node_modules/@capyclaw/foundation/abi/loader.mjs +8 -1
- package/node_modules/@capyclaw/foundation/abi/spec.mjs +5 -2
- package/node_modules/@capyclaw/foundation/abi/version.mjs +63 -5
- package/node_modules/@capyclaw/foundation/abi/visibility.mjs +90 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/lifecycle-hook.mjs +21 -4
- package/node_modules/@capyclaw/foundation/lib/host/caps.mjs +5 -1
- package/node_modules/@capyclaw/foundation/lib/host/contract.mjs +5 -2
- package/node_modules/@capyclaw/foundation/lib/host/dsh.mjs +4 -0
- package/node_modules/@capyclaw/foundation/lib/host/memory.mjs +29 -2
- package/node_modules/@capyclaw/foundation/lib/kernel.mjs +13 -3
- package/node_modules/@capyclaw/foundation/lib/subsystems/net.mjs +12 -2
- package/node_modules/@capyclaw/foundation/package.json +1 -1
- package/node_modules/@capyclaw/plugin-kit/package.json +3 -1
- package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat-worker.js +5 -2
- package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat.mjs +26 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/lease.mjs +3 -1
- package/node_modules/@capyclaw/plugin-kit/src/service/static.mjs +79 -0
- package/node_modules/@capyclaw/plugin-kit/src/workspace/manager.mjs +13 -5
- package/node_modules/@capyclaw/service-host/dsh-suite.json +1 -1
- package/node_modules/@capyclaw/service-host/package.json +1 -1
- package/node_modules/@capyclaw/service-host/src/index.mjs +18 -19
- package/node_modules/@capyclaw/tool-host/dsh-suite.json +2 -2
- package/node_modules/@capyclaw/tool-host/lib/host.mjs +34 -4
- package/node_modules/@capyclaw/tool-host/package.json +1 -1
- package/node_modules/@capyclaw/tool-host/src/admit-images.mjs +80 -0
- package/node_modules/@capyclaw/tool-host/src/caller-session.mjs +25 -0
- package/node_modules/@capyclaw/tool-host/src/index.mjs +59 -14
- package/node_modules/@capyclaw/tool-host/src/mode-gate.mjs +272 -0
- package/node_modules/playwright/LICENSE +202 -0
- package/node_modules/playwright/NOTICE +5 -0
- package/node_modules/playwright/README.md +318 -0
- package/node_modules/playwright/ThirdPartyNotices.txt +14 -0
- package/node_modules/playwright/cli.js +19 -0
- package/node_modules/playwright/index.d.ts +17 -0
- package/node_modules/playwright/index.js +17 -0
- package/node_modules/playwright/index.mjs +18 -0
- package/node_modules/playwright/lib/agents/agentParser.js +89 -0
- package/node_modules/playwright/lib/agents/copilot-setup-steps.yml +34 -0
- package/node_modules/playwright/lib/agents/generateAgents.js +395 -0
- package/node_modules/playwright/lib/agents/playwright-test-coverage.prompt.md +31 -0
- package/node_modules/playwright/lib/agents/playwright-test-generate.prompt.md +8 -0
- package/node_modules/playwright/lib/agents/playwright-test-generator.agent.md +88 -0
- package/node_modules/playwright/lib/agents/playwright-test-heal.prompt.md +6 -0
- package/node_modules/playwright/lib/agents/playwright-test-healer.agent.md +56 -0
- package/node_modules/playwright/lib/agents/playwright-test-plan.prompt.md +9 -0
- package/node_modules/playwright/lib/agents/playwright-test-planner.agent.md +74 -0
- package/node_modules/playwright/lib/cli/reportActions.js +78 -0
- package/node_modules/playwright/lib/cli/testActions.js +217 -0
- package/node_modules/playwright/lib/common/index.js +2937 -0
- package/node_modules/playwright/lib/common/index.js.txt +33 -0
- package/node_modules/playwright/lib/errorContext.js +129 -0
- package/node_modules/playwright/lib/globals.js +58 -0
- package/node_modules/playwright/lib/index.js +827 -0
- package/node_modules/playwright/lib/isomorphic.js +260 -0
- package/node_modules/playwright/lib/isomorphic.js.txt +9 -0
- package/node_modules/playwright/lib/loader/loaderProcessEntry.js +34 -0
- package/node_modules/playwright/lib/loader/loaderProcessEntry.js.txt +9 -0
- package/node_modules/playwright/lib/matchers/expect.js +13496 -0
- package/node_modules/playwright/lib/matchers/expect.js.LICENSE +640 -0
- package/node_modules/playwright/lib/matchers/expect.js.txt +67 -0
- package/node_modules/playwright/lib/package.js +47 -0
- package/node_modules/playwright/lib/program.js +242 -0
- package/node_modules/playwright/lib/runner/index.js +8721 -0
- package/node_modules/playwright/lib/runner/index.js.txt +62 -0
- package/node_modules/playwright/lib/transform/babelBundle.js +72490 -0
- package/node_modules/playwright/lib/transform/babelBundle.js.LICENSE +2384 -0
- package/node_modules/playwright/lib/transform/babelBundle.js.txt +328 -0
- package/node_modules/playwright/lib/transform/esmLoader.js +8066 -0
- package/node_modules/playwright/lib/transform/esmLoader.js.LICENSE +355 -0
- package/node_modules/playwright/lib/transform/esmLoader.js.txt +60 -0
- package/node_modules/playwright/lib/util.js +373 -0
- package/node_modules/playwright/lib/worker/workerProcessEntry.js +1860 -0
- package/node_modules/playwright/lib/worker/workerProcessEntry.js.txt +19 -0
- package/node_modules/playwright/package.json +50 -0
- package/node_modules/playwright/test.d.ts +18 -0
- package/node_modules/playwright/test.js +24 -0
- package/node_modules/playwright/test.mjs +35 -0
- package/node_modules/playwright/types/test.d.ts +11191 -0
- package/node_modules/playwright/types/testReporter.d.ts +950 -0
- package/node_modules/playwright-core/LICENSE +202 -0
- package/node_modules/playwright-core/NOTICE +5 -0
- package/node_modules/playwright-core/README.md +3 -0
- package/node_modules/playwright-core/ThirdPartyNotices.txt +13 -0
- package/node_modules/playwright-core/bin/install_media_pack.ps1 +5 -0
- package/node_modules/playwright-core/bin/install_webkit_wsl.ps1 +33 -0
- package/node_modules/playwright-core/bin/reinstall_chrome_beta_linux.sh +42 -0
- package/node_modules/playwright-core/bin/reinstall_chrome_beta_mac.sh +13 -0
- package/node_modules/playwright-core/bin/reinstall_chrome_beta_win.ps1 +24 -0
- package/node_modules/playwright-core/bin/reinstall_chrome_stable_linux.sh +42 -0
- package/node_modules/playwright-core/bin/reinstall_chrome_stable_mac.sh +12 -0
- package/node_modules/playwright-core/bin/reinstall_chrome_stable_win.ps1 +24 -0
- package/node_modules/playwright-core/bin/reinstall_msedge_beta_linux.sh +48 -0
- package/node_modules/playwright-core/bin/reinstall_msedge_beta_mac.sh +11 -0
- package/node_modules/playwright-core/bin/reinstall_msedge_beta_win.ps1 +23 -0
- package/node_modules/playwright-core/bin/reinstall_msedge_dev_linux.sh +48 -0
- package/node_modules/playwright-core/bin/reinstall_msedge_dev_mac.sh +11 -0
- package/node_modules/playwright-core/bin/reinstall_msedge_dev_win.ps1 +23 -0
- package/node_modules/playwright-core/bin/reinstall_msedge_stable_linux.sh +48 -0
- package/node_modules/playwright-core/bin/reinstall_msedge_stable_mac.sh +11 -0
- package/node_modules/playwright-core/bin/reinstall_msedge_stable_win.ps1 +24 -0
- package/node_modules/playwright-core/browsers.json +52 -0
- package/node_modules/playwright-core/cli.js +22 -0
- package/node_modules/playwright-core/index.d.ts +17 -0
- package/node_modules/playwright-core/index.js +17 -0
- package/node_modules/playwright-core/index.mjs +28 -0
- package/node_modules/playwright-core/lib/bootstrap.js +149 -0
- package/node_modules/playwright-core/lib/coreBundle.js +78041 -0
- package/node_modules/playwright-core/lib/entry/cliDaemon.js +5 -0
- package/node_modules/playwright-core/lib/entry/dashboardApp.js +3 -0
- package/node_modules/playwright-core/lib/entry/mcp.js +10 -0
- package/node_modules/playwright-core/lib/entry/oopBrowserDownload.js +3 -0
- package/node_modules/playwright-core/lib/package.js +50 -0
- package/node_modules/playwright-core/lib/server/chromium/appIcon.png +0 -0
- package/node_modules/playwright-core/lib/server/electron/loader.js +123 -0
- package/node_modules/playwright-core/lib/serverRegistry.js +1939 -0
- package/node_modules/playwright-core/lib/serverRegistry.js.LICENSE +65 -0
- package/node_modules/playwright-core/lib/tools/cli-client/channelSessions.js +141 -0
- package/node_modules/playwright-core/lib/tools/cli-client/cli.js +7 -0
- package/node_modules/playwright-core/lib/tools/cli-client/help.json +808 -0
- package/node_modules/playwright-core/lib/tools/cli-client/minimist.js +128 -0
- package/node_modules/playwright-core/lib/tools/cli-client/output.js +352 -0
- package/node_modules/playwright-core/lib/tools/cli-client/program.js +422 -0
- package/node_modules/playwright-core/lib/tools/cli-client/registry.js +180 -0
- package/node_modules/playwright-core/lib/tools/cli-client/session.js +261 -0
- package/node_modules/playwright-core/lib/tools/dashboard/appIcon.png +0 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/SKILL.md +493 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/element-attributes.md +23 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/playwright-tests.md +39 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/pr-attachments.md +60 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/request-mocking.md +87 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/running-code.md +245 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/session-management.md +227 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/storage-state.md +275 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/test-generation.md +433 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/tracing.md +139 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/video-recording.md +216 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/SKILL.md +136 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/gallery-spec.md +144 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/migration.md +89 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/react.md +69 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/typing.md +173 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/vue.md +77 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-trace/SKILL.md +174 -0
- package/node_modules/playwright-core/lib/tools/utils/extension.js +112 -0
- package/node_modules/playwright-core/lib/tools/utils/socketConnection.js +108 -0
- package/node_modules/playwright-core/lib/utilsBundle.js +86078 -0
- package/node_modules/playwright-core/lib/utilsBundle.js.LICENSE +1890 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/codeMirrorModule--QdMvsKi.css +1 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/codeMirrorModule-CQ8RZGBm.js +32 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/codicon-DCmgc-ay.ttf +0 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-1bWoP6pv.svg +1 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-beta-k3eOH_eK.svg +1 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-nightly-Cp5nfeDT.svg +1 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/index-AwgwcYie.css +1 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/index-hRvO4yU2.js +12 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/safari-na3_-uQk.svg +1 -0
- package/node_modules/playwright-core/lib/vite/dashboard/index.html +29 -0
- package/node_modules/playwright-core/lib/vite/dashboard/playwright-logo.svg +24 -0
- package/node_modules/playwright-core/lib/vite/htmlReport/index.html +16 -0
- package/node_modules/playwright-core/lib/vite/htmlReport/report.css +2 -0
- package/node_modules/playwright-core/lib/vite/htmlReport/report.js +32 -0
- package/node_modules/playwright-core/lib/vite/recorder/assets/codeMirrorModule--QdMvsKi.css +1 -0
- package/node_modules/playwright-core/lib/vite/recorder/assets/codeMirrorModule-DK72OMRi.js +32 -0
- package/node_modules/playwright-core/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
- package/node_modules/playwright-core/lib/vite/recorder/assets/index-BZpYJZ-P.css +1 -0
- package/node_modules/playwright-core/lib/vite/recorder/assets/index-Cn0mmDuv.js +129 -0
- package/node_modules/playwright-core/lib/vite/recorder/index.html +29 -0
- package/node_modules/playwright-core/lib/vite/recorder/playwright-logo.svg +9 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/assets/codeMirrorModule-BEB2e8M3.js +32 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/assets/defaultSettingsView-D-g2vrvf.js +184 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/assets/urlMatch-L3liM589.js +1 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/assets/xtermModule-B794rD2Z.js +7 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/codeMirrorModule.-QdMvsKi.css +1 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/defaultSettingsView.C8BeHuxd.css +1 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/index.B_TqY17P.css +1 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/index.html +44 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/index.oNry3Hjv.js +1 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/manifest.webmanifest +16 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/playwright-logo.svg +9 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/snapshot.B_Jk1wbt.js +1 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/snapshot.html +10 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/sw.bundle.js +4 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.CYwC_gH1.js +5 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.CyMfwkXJ.css +1 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.html +18 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/xtermModule.kHJ-D0s7.css +1 -0
- package/node_modules/playwright-core/lib/webp_codec.LICENSE +173 -0
- package/node_modules/playwright-core/lib/webp_codec.wasm +0 -0
- package/node_modules/playwright-core/lib/xdg-open +1267 -0
- package/node_modules/playwright-core/package.json +34 -0
- package/node_modules/playwright-core/types/protocol.d.ts +24776 -0
- package/node_modules/playwright-core/types/structs.d.ts +52 -0
- package/node_modules/playwright-core/types/types.d.ts +27167 -0
- package/package.json +10 -8
- package/plugin.mjs +13 -1
- package/server/activate-log.mjs +66 -0
- package/server/contract.mjs +1 -1
- package/server/embedded-host.mjs +23 -2
- package/server/engine.mjs +11 -4
- package/server/routes/api.mjs +2 -2
- package/server/shared/SHARED_MANIFEST.json +4 -4
- package/server/workbench-framework.mjs +34 -0
- package/ui/app.js +87 -10
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"contractVersion": "1.3.0",
|
|
3
|
-
"packageVersion": "0.1.
|
|
3
|
+
"packageVersion": "0.1.21",
|
|
4
4
|
"toolCount": 18,
|
|
5
5
|
"tools": [
|
|
6
6
|
{
|
|
@@ -632,6 +632,7 @@
|
|
|
632
632
|
"features": [
|
|
633
633
|
"browser.contract"
|
|
634
634
|
],
|
|
635
|
+
"domain": "",
|
|
635
636
|
"tools": [
|
|
636
637
|
{
|
|
637
638
|
"name": "browser_capabilities",
|
|
@@ -651,7 +652,8 @@
|
|
|
651
652
|
"additionalProperties": false
|
|
652
653
|
},
|
|
653
654
|
"kind": "read",
|
|
654
|
-
"since": "1.0.0"
|
|
655
|
+
"since": "1.0.0",
|
|
656
|
+
"domain": ""
|
|
655
657
|
}
|
|
656
658
|
]
|
|
657
659
|
},
|
|
@@ -670,6 +672,7 @@
|
|
|
670
672
|
"features": [
|
|
671
673
|
"browser.navigation"
|
|
672
674
|
],
|
|
675
|
+
"domain": "",
|
|
673
676
|
"tools": [
|
|
674
677
|
{
|
|
675
678
|
"name": "browser_navigate",
|
|
@@ -694,7 +697,8 @@
|
|
|
694
697
|
"additionalProperties": false
|
|
695
698
|
},
|
|
696
699
|
"kind": "write",
|
|
697
|
-
"since": "1.0.0"
|
|
700
|
+
"since": "1.0.0",
|
|
701
|
+
"domain": ""
|
|
698
702
|
}
|
|
699
703
|
]
|
|
700
704
|
},
|
|
@@ -713,6 +717,7 @@
|
|
|
713
717
|
"features": [
|
|
714
718
|
"browser.snapshot"
|
|
715
719
|
],
|
|
720
|
+
"domain": "",
|
|
716
721
|
"tools": [
|
|
717
722
|
{
|
|
718
723
|
"name": "browser_snapshot",
|
|
@@ -729,7 +734,8 @@
|
|
|
729
734
|
"additionalProperties": false
|
|
730
735
|
},
|
|
731
736
|
"kind": "read",
|
|
732
|
-
"since": "1.0.0"
|
|
737
|
+
"since": "1.0.0",
|
|
738
|
+
"domain": ""
|
|
733
739
|
}
|
|
734
740
|
]
|
|
735
741
|
},
|
|
@@ -748,6 +754,7 @@
|
|
|
748
754
|
"features": [
|
|
749
755
|
"browser.interaction"
|
|
750
756
|
],
|
|
757
|
+
"domain": "",
|
|
751
758
|
"tools": [
|
|
752
759
|
{
|
|
753
760
|
"name": "browser_click",
|
|
@@ -779,7 +786,8 @@
|
|
|
779
786
|
"additionalProperties": false
|
|
780
787
|
},
|
|
781
788
|
"kind": "write",
|
|
782
|
-
"since": "1.0.0"
|
|
789
|
+
"since": "1.0.0",
|
|
790
|
+
"domain": ""
|
|
783
791
|
},
|
|
784
792
|
{
|
|
785
793
|
"name": "browser_drag",
|
|
@@ -838,7 +846,8 @@
|
|
|
838
846
|
"additionalProperties": false
|
|
839
847
|
},
|
|
840
848
|
"kind": "write",
|
|
841
|
-
"since": "1.2.0"
|
|
849
|
+
"since": "1.2.0",
|
|
850
|
+
"domain": ""
|
|
842
851
|
},
|
|
843
852
|
{
|
|
844
853
|
"name": "browser_fill",
|
|
@@ -873,7 +882,8 @@
|
|
|
873
882
|
"additionalProperties": false
|
|
874
883
|
},
|
|
875
884
|
"kind": "write",
|
|
876
|
-
"since": "1.0.0"
|
|
885
|
+
"since": "1.0.0",
|
|
886
|
+
"domain": ""
|
|
877
887
|
},
|
|
878
888
|
{
|
|
879
889
|
"name": "browser_press",
|
|
@@ -903,7 +913,8 @@
|
|
|
903
913
|
"additionalProperties": false
|
|
904
914
|
},
|
|
905
915
|
"kind": "write",
|
|
906
|
-
"since": "1.0.0"
|
|
916
|
+
"since": "1.0.0",
|
|
917
|
+
"domain": ""
|
|
907
918
|
},
|
|
908
919
|
{
|
|
909
920
|
"name": "browser_select",
|
|
@@ -934,7 +945,8 @@
|
|
|
934
945
|
"additionalProperties": false
|
|
935
946
|
},
|
|
936
947
|
"kind": "write",
|
|
937
|
-
"since": "1.0.0"
|
|
948
|
+
"since": "1.0.0",
|
|
949
|
+
"domain": ""
|
|
938
950
|
},
|
|
939
951
|
{
|
|
940
952
|
"name": "browser_upload",
|
|
@@ -973,7 +985,8 @@
|
|
|
973
985
|
"additionalProperties": false
|
|
974
986
|
},
|
|
975
987
|
"kind": "write",
|
|
976
|
-
"since": "1.3.0"
|
|
988
|
+
"since": "1.3.0",
|
|
989
|
+
"domain": ""
|
|
977
990
|
},
|
|
978
991
|
{
|
|
979
992
|
"name": "browser_scroll",
|
|
@@ -1002,7 +1015,8 @@
|
|
|
1002
1015
|
"additionalProperties": false
|
|
1003
1016
|
},
|
|
1004
1017
|
"kind": "write",
|
|
1005
|
-
"since": "1.0.0"
|
|
1018
|
+
"since": "1.0.0",
|
|
1019
|
+
"domain": ""
|
|
1006
1020
|
},
|
|
1007
1021
|
{
|
|
1008
1022
|
"name": "browser_act",
|
|
@@ -1116,7 +1130,8 @@
|
|
|
1116
1130
|
"additionalProperties": false
|
|
1117
1131
|
},
|
|
1118
1132
|
"kind": "write",
|
|
1119
|
-
"since": "1.1.0"
|
|
1133
|
+
"since": "1.1.0",
|
|
1134
|
+
"domain": ""
|
|
1120
1135
|
}
|
|
1121
1136
|
]
|
|
1122
1137
|
},
|
|
@@ -1135,6 +1150,7 @@
|
|
|
1135
1150
|
"features": [
|
|
1136
1151
|
"browser.tabs"
|
|
1137
1152
|
],
|
|
1153
|
+
"domain": "",
|
|
1138
1154
|
"tools": [
|
|
1139
1155
|
{
|
|
1140
1156
|
"name": "browser_tabs",
|
|
@@ -1166,7 +1182,8 @@
|
|
|
1166
1182
|
"additionalProperties": false
|
|
1167
1183
|
},
|
|
1168
1184
|
"kind": "control",
|
|
1169
|
-
"since": "1.0.0"
|
|
1185
|
+
"since": "1.0.0",
|
|
1186
|
+
"domain": ""
|
|
1170
1187
|
}
|
|
1171
1188
|
]
|
|
1172
1189
|
},
|
|
@@ -1186,6 +1203,7 @@
|
|
|
1186
1203
|
"features": [
|
|
1187
1204
|
"browser.screenshot"
|
|
1188
1205
|
],
|
|
1206
|
+
"domain": "",
|
|
1189
1207
|
"tools": [
|
|
1190
1208
|
{
|
|
1191
1209
|
"name": "browser_screenshot",
|
|
@@ -1206,7 +1224,8 @@
|
|
|
1206
1224
|
"additionalProperties": false
|
|
1207
1225
|
},
|
|
1208
1226
|
"kind": "read",
|
|
1209
|
-
"since": "1.0.0"
|
|
1227
|
+
"since": "1.0.0",
|
|
1228
|
+
"domain": ""
|
|
1210
1229
|
}
|
|
1211
1230
|
]
|
|
1212
1231
|
},
|
|
@@ -1225,6 +1244,7 @@
|
|
|
1225
1244
|
"features": [
|
|
1226
1245
|
"browser.session"
|
|
1227
1246
|
],
|
|
1247
|
+
"domain": "",
|
|
1228
1248
|
"tools": [
|
|
1229
1249
|
{
|
|
1230
1250
|
"name": "browser_status",
|
|
@@ -1235,7 +1255,8 @@
|
|
|
1235
1255
|
"additionalProperties": false
|
|
1236
1256
|
},
|
|
1237
1257
|
"kind": "read",
|
|
1238
|
-
"since": "1.0.0"
|
|
1258
|
+
"since": "1.0.0",
|
|
1259
|
+
"domain": ""
|
|
1239
1260
|
},
|
|
1240
1261
|
{
|
|
1241
1262
|
"name": "browser_wait",
|
|
@@ -1261,7 +1282,8 @@
|
|
|
1261
1282
|
"additionalProperties": false
|
|
1262
1283
|
},
|
|
1263
1284
|
"kind": "control",
|
|
1264
|
-
"since": "1.0.0"
|
|
1285
|
+
"since": "1.0.0",
|
|
1286
|
+
"domain": ""
|
|
1265
1287
|
},
|
|
1266
1288
|
{
|
|
1267
1289
|
"name": "browser_history",
|
|
@@ -1287,7 +1309,8 @@
|
|
|
1287
1309
|
"additionalProperties": false
|
|
1288
1310
|
},
|
|
1289
1311
|
"kind": "control",
|
|
1290
|
-
"since": "1.0.0"
|
|
1312
|
+
"since": "1.0.0",
|
|
1313
|
+
"domain": ""
|
|
1291
1314
|
},
|
|
1292
1315
|
{
|
|
1293
1316
|
"name": "browser_close",
|
|
@@ -1298,7 +1321,8 @@
|
|
|
1298
1321
|
"additionalProperties": false
|
|
1299
1322
|
},
|
|
1300
1323
|
"kind": "control",
|
|
1301
|
-
"since": "1.0.0"
|
|
1324
|
+
"since": "1.0.0",
|
|
1325
|
+
"domain": ""
|
|
1302
1326
|
}
|
|
1303
1327
|
]
|
|
1304
1328
|
},
|
|
@@ -1317,6 +1341,7 @@
|
|
|
1317
1341
|
"features": [
|
|
1318
1342
|
"browser.evaluate"
|
|
1319
1343
|
],
|
|
1344
|
+
"domain": "",
|
|
1320
1345
|
"tools": [
|
|
1321
1346
|
{
|
|
1322
1347
|
"name": "browser_evaluate",
|
|
@@ -1341,7 +1366,8 @@
|
|
|
1341
1366
|
"additionalProperties": false
|
|
1342
1367
|
},
|
|
1343
1368
|
"kind": "write",
|
|
1344
|
-
"since": "1.0.0"
|
|
1369
|
+
"since": "1.0.0",
|
|
1370
|
+
"domain": ""
|
|
1345
1371
|
}
|
|
1346
1372
|
]
|
|
1347
1373
|
}
|
|
@@ -13,6 +13,7 @@ import fs from 'node:fs'
|
|
|
13
13
|
import path from 'node:path'
|
|
14
14
|
import { send, readBody } from '@capyclaw/plugin-kit/service/http'
|
|
15
15
|
import { createServiceApi } from '@capyclaw/plugin-kit/service/api'
|
|
16
|
+
import { ASSET_URL_PREFIX } from '@capyclaw/foundation/abi'
|
|
16
17
|
|
|
17
18
|
function sha256(buffer) {
|
|
18
19
|
return crypto.createHash('sha256').update(buffer).digest('hex')
|
|
@@ -40,7 +41,7 @@ export function createWorkspaceAssetStore({ storeClient, workId = 'main' } = {})
|
|
|
40
41
|
const id = sha256(buffer)
|
|
41
42
|
const key = `assets/${id}`
|
|
42
43
|
storeClient.put(workId, key, buffer, { contentType })
|
|
43
|
-
return { id, key, url:
|
|
44
|
+
return { id, key, url: `${ASSET_URL_PREFIX}${id}`, size: buffer.length, contentType }
|
|
44
45
|
},
|
|
45
46
|
get(id) {
|
|
46
47
|
if (!validId(id)) return null
|
|
@@ -84,7 +85,7 @@ export function createFileAssetStore({ dir } = {}) {
|
|
|
84
85
|
const metaTmp = `${metaFile}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`
|
|
85
86
|
fs.writeFileSync(metaTmp, JSON.stringify({ contentType, size: buffer.length }))
|
|
86
87
|
fs.renameSync(metaTmp, metaFile)
|
|
87
|
-
return { id, key: id, url:
|
|
88
|
+
return { id, key: id, url: `${ASSET_URL_PREFIX}${id}`, size: buffer.length, contentType }
|
|
88
89
|
},
|
|
89
90
|
get(id) {
|
|
90
91
|
if (!validId(id)) return null
|
|
@@ -192,7 +193,7 @@ function safeContentType(type) {
|
|
|
192
193
|
*/
|
|
193
194
|
export function createAssetRoutes({ assetStore, basePath = '', maxUploadBytes = 10 * 1024 * 1024 } = {}) {
|
|
194
195
|
const prefix = basePath === '/' ? '' : String(basePath || '').replace(/\/+$/, '')
|
|
195
|
-
const getPrefixes = [
|
|
196
|
+
const getPrefixes = [ASSET_URL_PREFIX, prefix ? `${prefix}${ASSET_URL_PREFIX}` : null].filter(Boolean)
|
|
196
197
|
const postPaths = new Set(['/assets', prefix ? `${prefix}/assets` : null].filter(Boolean))
|
|
197
198
|
return async function assetRoutes(req, res, u) {
|
|
198
199
|
const p = u.pathname
|
|
@@ -200,7 +201,12 @@ export function createAssetRoutes({ assetStore, basePath = '', maxUploadBytes =
|
|
|
200
201
|
const getPrefix = getPrefixes.find((candidate) => p.startsWith(candidate))
|
|
201
202
|
if (getPrefix) {
|
|
202
203
|
if (!assetStore) { send(req, res, 404, { error: 'asset store unavailable' }); return true }
|
|
203
|
-
|
|
204
|
+
let id
|
|
205
|
+
try { id = decodeURIComponent(p.slice(getPrefix.length)) } catch {
|
|
206
|
+
/* 畸形百分号编码(如 /assets/%zz):decodeURIComponent 抛 URIError,
|
|
207
|
+
* 不包会一路冒成 500。这是客户端错误,回 400。 */
|
|
208
|
+
send(req, res, 400, { error: 'malformed asset id encoding' }); return true
|
|
209
|
+
}
|
|
204
210
|
if (!validId(id)) { send(req, res, 404, { error: 'asset not found' }); return true }
|
|
205
211
|
const asset = assetStore.get(id)
|
|
206
212
|
if (!asset) { send(req, res, 404, { error: 'asset not found' }); return true }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capyclaw/document-workbench",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "通用文档工作台框架:版本化文档会话、命令注册、桥路由、浏览器编辑器客户端与截图协议。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.mjs",
|
|
@@ -13,16 +13,19 @@
|
|
|
13
13
|
"./ops": "./src/ops/index.mjs",
|
|
14
14
|
"./bridge": "./src/bridge/index.mjs",
|
|
15
15
|
"./client": "./src/client/index.mjs",
|
|
16
|
+
"./client/visibility": "./src/client/visibility.mjs",
|
|
16
17
|
"./screenshot": "./src/client/screenshot.mjs",
|
|
17
18
|
"./testing": "./src/testing/index.mjs",
|
|
18
19
|
"./package.json": "./package.json",
|
|
19
|
-
"./store/file-backend": "./src/store/file-backend.mjs"
|
|
20
|
+
"./store/file-backend": "./src/store/file-backend.mjs",
|
|
21
|
+
"./store/projection": "./src/store/projection.mjs"
|
|
20
22
|
},
|
|
21
23
|
"publishConfig": {
|
|
22
24
|
"access": "public"
|
|
23
25
|
},
|
|
24
26
|
"dependencies": {
|
|
25
|
-
"@capyclaw/plugin-kit": "^0.2.0"
|
|
27
|
+
"@capyclaw/plugin-kit": "^0.2.0",
|
|
28
|
+
"@capyclaw/foundation": "^0.1.1"
|
|
26
29
|
},
|
|
27
30
|
"files": [
|
|
28
31
|
"src/",
|
|
@@ -11,13 +11,27 @@
|
|
|
11
11
|
* 一条不变量替代散落的自觉检查,漏检也不会污染共享画面。
|
|
12
12
|
* D 确定性停机——stop() 可 await(排水在飞 pump/shoot),调用方确知旧 client 安静后
|
|
13
13
|
* 再 restore 新会话,取代「睡 3.5s 再 re-assert」的补丁。
|
|
14
|
+
*
|
|
15
|
+
* 表面生命周期(docs/SURFACE-LIFECYCLE-STANDARD.md P2/P3):本客户端的桥接/仲裁面
|
|
16
|
+
* (claimLoop / pump / 心跳 / pushState)永远在线、与可见性无关,绝不节流;新增的
|
|
17
|
+
* 可见性订阅只把宿主信号转成 onVisibility 回调,由编辑器适配器挂起渲染面。
|
|
14
18
|
*/
|
|
15
19
|
|
|
20
|
+
import { createVisibilitySubscriber } from './visibility.mjs'
|
|
21
|
+
/* 心跳节奏单一真源(P2-13b):与 plugin-kit heartbeat-worker 同拍,消除 4s/3s 漂移。
|
|
22
|
+
* 该常量模块零依赖、browser-safe,可被本客户端 bundle 直接 import。 */
|
|
23
|
+
import { HEARTBEAT_INTERVAL_MS } from '@capyclaw/plugin-kit/editor/heartbeat'
|
|
24
|
+
|
|
25
|
+
/* 订阅器连同协议常量一并透出,消费者从 /client 一个入口即可拿到。 */
|
|
26
|
+
export { createVisibilitySubscriber } from './visibility.mjs'
|
|
27
|
+
|
|
16
28
|
const DEFAULTS = {
|
|
17
29
|
pollTimeoutSec: 3,
|
|
18
30
|
claimRetryMs: 800,
|
|
19
31
|
activeClaimRetryMs: 1500,
|
|
20
|
-
|
|
32
|
+
/* 心跳间隔取 plugin-kit 单一真源 HEARTBEAT_INTERVAL_MS(3s),与 heartbeat-worker.js
|
|
33
|
+
* 的 setInterval 字面量同拍(worker 侧由 plugin-kit drift 测试钉死,防再次漂移)。 */
|
|
34
|
+
heartbeatMs: HEARTBEAT_INTERVAL_MS,
|
|
21
35
|
stateDebounceMs: 800,
|
|
22
36
|
errorRetryMs: 500,
|
|
23
37
|
shotIdleMs: 3000,
|
|
@@ -61,6 +75,9 @@ export function createEditorClient({
|
|
|
61
75
|
intervals = {},
|
|
62
76
|
onStatus = () => {},
|
|
63
77
|
onNote = () => {},
|
|
78
|
+
/* 渲染面可见性回调(标准 §4):宿主信号 → 适配器挂起/恢复渲染。
|
|
79
|
+
* 只影响渲染面;桥接面节奏不受它驱动(P2/P3)。 */
|
|
80
|
+
onVisibility = () => {},
|
|
64
81
|
} = {}) {
|
|
65
82
|
if (typeof api !== 'function') throw new Error('createEditorClient 需要 api(path, init)')
|
|
66
83
|
if (!adapter || typeof adapter.load !== 'function' || typeof adapter.dump !== 'function') {
|
|
@@ -99,6 +116,10 @@ export function createEditorClient({
|
|
|
99
116
|
wakeFlag: false,
|
|
100
117
|
wakeResolve: null,
|
|
101
118
|
wakeListeners: [],
|
|
119
|
+
/* 渲染面可见性(标准 §3/§4):初始 foreground,宿主信号驱动迁移。
|
|
120
|
+
* 订阅器在 claimLoop 注册唤醒监听处创建并 start,stop() 一并摘除。 */
|
|
121
|
+
visibilityState: 'foreground',
|
|
122
|
+
visibilitySubscriber: null,
|
|
102
123
|
/* A:结构化取消——stop 即 abort,在飞请求立刻 reject。 */
|
|
103
124
|
abort: new AbortController(),
|
|
104
125
|
/* D:可 await 停机排水——记录在飞 pump/shoot 任务,stop 等它们 settle。 */
|
|
@@ -251,7 +272,9 @@ export function createEditorClient({
|
|
|
251
272
|
/* 影子不监听单例 storage 事件(它不写单例键,也不因 GUI 写键而待命);
|
|
252
273
|
* 影子的待命/让位一律由租约状态驱动。 */
|
|
253
274
|
if (!shadow && storage && typeof window !== 'undefined' && window.addEventListener) {
|
|
254
|
-
|
|
275
|
+
/* 登记进 st.wakeListeners:stop() 统一摘除。就地换会话反复 create/stop 时
|
|
276
|
+
* 匿名监听会连同整个 st(含截图缓存)泄漏在 window 上。 */
|
|
277
|
+
const onSingleton = (event) => {
|
|
255
278
|
if (event.key === st.singletonKey && event.newValue && event.newValue !== st.clientId) {
|
|
256
279
|
if (st.active) {
|
|
257
280
|
st.active = false
|
|
@@ -260,7 +283,9 @@ export function createEditorClient({
|
|
|
260
283
|
note('')
|
|
261
284
|
}
|
|
262
285
|
}
|
|
263
|
-
}
|
|
286
|
+
}
|
|
287
|
+
window.addEventListener('storage', onSingleton)
|
|
288
|
+
st.wakeListeners.push([window, 'storage', onSingleton])
|
|
264
289
|
}
|
|
265
290
|
|
|
266
291
|
/* 网络恢复 / 回到前台 / 标签页重新可见时立即唤醒重试,不等满退避间隔。
|
|
@@ -277,6 +302,23 @@ export function createEditorClient({
|
|
|
277
302
|
st.wakeListeners.push([document, 'visibilitychange', onVisible])
|
|
278
303
|
}
|
|
279
304
|
|
|
305
|
+
/* 渲染面可见性订阅(标准 §4 信号通道):宿主 postMessage → onVisibility,
|
|
306
|
+
* 编辑器适配器据此挂起/恢复渲染。上面的 online/focus/visibilitychange 只是
|
|
307
|
+
* 桥接面的「回来即唤醒重连」,与表面可见性正交,两者互不替代。
|
|
308
|
+
*
|
|
309
|
+
* P2/P3 边界:本订阅【只】驱动渲染面。claimLoop 的 claim 重试、pump 长轮询、
|
|
310
|
+
* 心跳(Worker 4s / 主线程降级 3s)、pushState 防抖 800ms 在任何可见性状态
|
|
311
|
+
* 下都保持原节奏——隐藏绝不释放租约、绝不打断 AI 写入(标准 §5 桥接面列)。 */
|
|
312
|
+
if (!st.visibilitySubscriber) {
|
|
313
|
+
st.visibilitySubscriber = createVisibilitySubscriber({
|
|
314
|
+
onState: (state) => {
|
|
315
|
+
st.visibilityState = state
|
|
316
|
+
onVisibility(state)
|
|
317
|
+
},
|
|
318
|
+
})
|
|
319
|
+
st.visibilitySubscriber.start()
|
|
320
|
+
}
|
|
321
|
+
|
|
280
322
|
/* 从第一刻就开始看内容:待命窗口也要跟上,不能等抢到租约才第一次读。
|
|
281
323
|
* pump() 自己幂等(st.pumping 守着),activate() 里再调一次是空操作;
|
|
282
324
|
* 写、截图、回执仍然只由 active 窗口做。 */
|
|
@@ -587,6 +629,14 @@ export function createEditorClient({
|
|
|
587
629
|
try { target.removeEventListener(type, handler) } catch { /* ignore */ }
|
|
588
630
|
}
|
|
589
631
|
st.wakeListeners = []
|
|
632
|
+
/* 渲染面订阅对称拆卸(P6):摘除 message/visibilitychange 监听,不泄漏。 */
|
|
633
|
+
try { st.visibilitySubscriber?.stop() } catch { /* ignore */ }
|
|
634
|
+
st.visibilitySubscriber = null
|
|
635
|
+
/* 单例键只进不出会让 localStorage 键随会话数无界累积(ppt 每会话一个键)。
|
|
636
|
+
* 停用时若键仍归本 client 所有则删除;归别的窗口则不动。 */
|
|
637
|
+
if (!shadow && storage) {
|
|
638
|
+
try { if (storage.getItem(st.singletonKey) === st.clientId) storage.removeItem(st.singletonKey) } catch { /* quota / privacy mode */ }
|
|
639
|
+
}
|
|
590
640
|
wake()
|
|
591
641
|
try { st.unsubscribe?.() } catch { /* ignore */ }
|
|
592
642
|
st.unsubscribe = null
|
|
@@ -601,6 +651,9 @@ export function createEditorClient({
|
|
|
601
651
|
|
|
602
652
|
return {
|
|
603
653
|
state: st,
|
|
654
|
+
/* 渲染面当前可见性(标准 §3):foreground/background/hidden/detached。
|
|
655
|
+
* 只读投影;迁移由宿主信号驱动,桥接面不读它来节流。 */
|
|
656
|
+
get visibilityState() { return st.visibilityState },
|
|
604
657
|
claim,
|
|
605
658
|
ensureLinked,
|
|
606
659
|
restore,
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* iframe 侧可见性订阅器(表面生命周期标准 §4 统一信号通道)。
|
|
3
|
+
*
|
|
4
|
+
* 宿主(portal-hud + window-kit)是表面可见性的唯一真源:iframe 被宿主
|
|
5
|
+
* display:none 时,iframe 内部 document.hidden 并不改变(它只跟随顶层 tab),
|
|
6
|
+
* 所以「被藏起来」只能由宿主经 postMessage 显式告知。本订阅器把宿主信号
|
|
7
|
+
* 转成 onState 回调,交给编辑器适配器去挂起/恢复渲染面。
|
|
8
|
+
*
|
|
9
|
+
* 平面边界(标准 P2/P3):本模块只服务渲染面。桥接/仲裁面(claimLoop /
|
|
10
|
+
* pump / 心跳 / pushState)与权威/数据面永远在线、与可见性无关——订阅器
|
|
11
|
+
* 不持有也不节流任何桥接定时器。
|
|
12
|
+
*
|
|
13
|
+
* 协议常量唯一真源在 @capyclaw/foundation/abi(visibility.mjs),这里只
|
|
14
|
+
* import + re-export,绝不私设第二份。该 ABI 层是纯 JS(无 node:* 依赖),
|
|
15
|
+
* 保持本文件 browser-safe,可随编辑器客户端一起打进前端 bundle。
|
|
16
|
+
*/
|
|
17
|
+
import {
|
|
18
|
+
SURFACE_LIFECYCLE_VERSION,
|
|
19
|
+
VISIBILITY_ACK_MESSAGE,
|
|
20
|
+
VISIBILITY_DEFAULTS,
|
|
21
|
+
VISIBILITY_MESSAGE,
|
|
22
|
+
VISIBILITY_STATES,
|
|
23
|
+
isVisibilityState,
|
|
24
|
+
normalizeVisibilityState,
|
|
25
|
+
} from '@capyclaw/foundation/abi'
|
|
26
|
+
|
|
27
|
+
/* 顺带 re-export 协议常量,消费者不必再记一遍 foundation 的子路径。 */
|
|
28
|
+
export {
|
|
29
|
+
SURFACE_LIFECYCLE_VERSION,
|
|
30
|
+
VISIBILITY_ACK_MESSAGE,
|
|
31
|
+
VISIBILITY_DEFAULTS,
|
|
32
|
+
VISIBILITY_MESSAGE,
|
|
33
|
+
VISIBILITY_STATES,
|
|
34
|
+
isVisibilityState,
|
|
35
|
+
normalizeVisibilityState,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 创建可见性订阅器。
|
|
40
|
+
* @param {object} [opts]
|
|
41
|
+
* @param {(state: string, data?: object) => void} [opts.onState] 状态迁移回调(渲染面据此挂起/恢复)
|
|
42
|
+
* @param {Window} [opts.win] 目标窗口,默认 globalThis.window(Node 下缺省则 start 为空操作)
|
|
43
|
+
* @param {boolean} [opts.sendAck] 是否向宿主回执(默认 true;独立打开兜底路径永远无 ack)
|
|
44
|
+
* @returns {{ start: () => void, stop: () => void, readonly state: string }}
|
|
45
|
+
*/
|
|
46
|
+
export function createVisibilitySubscriber({ onState = () => {}, win = globalThis.window, sendAck = true } = {}) {
|
|
47
|
+
/* 初始前台:宁可多渲染,不可假挂起(与 normalizeVisibilityState 的兜底同向)。 */
|
|
48
|
+
let state = 'foreground'
|
|
49
|
+
let started = false
|
|
50
|
+
/* 登记所有监听,stop() 统一摘除(对称装填/拆卸 P6,不泄漏)。 */
|
|
51
|
+
const listeners = []
|
|
52
|
+
|
|
53
|
+
/* 状态迁移:只在变化时更新内部 state 并回调,避免重复信号抖动渲染面。 */
|
|
54
|
+
const transition = (next, data) => {
|
|
55
|
+
if (next === state) return
|
|
56
|
+
state = next
|
|
57
|
+
onState(state, data)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* 宿主 → iframe 的可见性信号:同源 + 协议类型双重校验后才认。 */
|
|
61
|
+
const onMessage = (event) => {
|
|
62
|
+
const origin = win && win.location && win.location.origin
|
|
63
|
+
if (event.origin !== origin) return /* 跨源消息一律忽略 */
|
|
64
|
+
const data = event.data
|
|
65
|
+
if (!data || data.type !== VISIBILITY_MESSAGE) return /* 换会话等其他消息正交,不碰 */
|
|
66
|
+
const next = normalizeVisibilityState(data.state) /* 非法/缺省 → foreground */
|
|
67
|
+
transition(next, data)
|
|
68
|
+
/* 回执无条件发(即使状态未变):宿主靠 ack 确认页面响应了信号,
|
|
69
|
+
* 超过 visibilityAckTimeoutMs 没回执会被判半挂起(标准 §4 兜底)。 */
|
|
70
|
+
if (sendAck && event.source) {
|
|
71
|
+
event.source.postMessage({ type: VISIBILITY_ACK_MESSAGE, state, sid: data.sid }, event.origin)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* 独立打开(非嵌入)兜底:没有宿主下发信号,退回 tab 级 visibilitychange。
|
|
76
|
+
* 注意这只是「顶层 tab 可见性」,不是表面可见性——嵌入时绝不走这条路。 */
|
|
77
|
+
const onDocVisibility = () => {
|
|
78
|
+
const doc = win && win.document
|
|
79
|
+
transition(doc && doc.hidden ? 'hidden' : 'foreground')
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function start() {
|
|
83
|
+
if (started || !win || typeof win.addEventListener !== 'function') return
|
|
84
|
+
started = true
|
|
85
|
+
win.addEventListener('message', onMessage)
|
|
86
|
+
listeners.push([win, 'message', onMessage])
|
|
87
|
+
/* win.parent === win ⇔ 顶层独立打开;嵌入(parent !== win)时宿主才是
|
|
88
|
+
* 真源,忽略自身 visibilitychange 作为表面状态(标准 §4 禁止项)。 */
|
|
89
|
+
if (win.parent === win) {
|
|
90
|
+
const doc = win.document
|
|
91
|
+
if (doc && typeof doc.addEventListener === 'function') {
|
|
92
|
+
doc.addEventListener('visibilitychange', onDocVisibility)
|
|
93
|
+
listeners.push([doc, 'visibilitychange', onDocVisibility])
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function stop() {
|
|
99
|
+
if (!started) return /* 幂等:重复 stop / 未 start 都安全 */
|
|
100
|
+
started = false
|
|
101
|
+
for (const [target, type, handler] of listeners) {
|
|
102
|
+
try { target.removeEventListener(type, handler) } catch { /* ignore */ }
|
|
103
|
+
}
|
|
104
|
+
listeners.length = 0
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
start,
|
|
109
|
+
stop,
|
|
110
|
+
get state() { return state },
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* 就能得到统一的清单;工具只认清单,不认具体引擎。
|
|
7
7
|
*
|
|
8
8
|
* schema:
|
|
9
|
-
* pages(doc) → 页面数组(默认 doc.pages /
|
|
9
|
+
* pages(doc) → 页面数组(默认 doc.pages / 数组本身 / [doc];业务形状如
|
|
10
|
+
* PPT 的 deck.slides 由套件经 schema.pages 显式声明,内核不猜)
|
|
10
11
|
* pageId(page, index) → 页面 ID(默认 page.id / 'p{index}')
|
|
11
12
|
* nodes(page, pageIndex) → 该页顶层节点数组(默认 page.elements / page.children / 空)
|
|
12
13
|
* children(node) → 子节点数组(分组、表格单元格;缺省无嵌套)
|
|
@@ -21,12 +22,13 @@ import { nodePath } from './ids.mjs'
|
|
|
21
22
|
|
|
22
23
|
const isObj = (value) => !!value && typeof value === 'object' && !Array.isArray(value)
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
/** 默认分页:只认形状无关的通用信封(数组本身 / doc.pages / 单对象当一页)。
|
|
26
|
+
* 业务形状(PPT 的 slides / deck.slides 等)由套件适配层经 schema.pages 显式传入,
|
|
27
|
+
* 内核不再猜测——见 infrastructure-review-2026-11-23 M5。导出供 ops 复用同一语义。 */
|
|
28
|
+
export function defaultPages(doc) {
|
|
25
29
|
if (Array.isArray(doc)) return doc
|
|
26
30
|
if (!isObj(doc)) return []
|
|
27
31
|
if (Array.isArray(doc.pages)) return doc.pages
|
|
28
|
-
if (Array.isArray(doc.slides)) return doc.slides
|
|
29
|
-
if (isObj(doc.deck) && Array.isArray(doc.deck.slides)) return doc.deck.slides
|
|
30
32
|
return [doc]
|
|
31
33
|
}
|
|
32
34
|
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* 也可以直接用 applyPlan 做纯树改写(工具侧无引擎也能跑,便于测试)。
|
|
8
8
|
*/
|
|
9
9
|
import { locate } from './locate.mjs'
|
|
10
|
+
import { defaultPages } from './manifest.mjs'
|
|
10
11
|
|
|
11
12
|
const isObj = (value) => !!value && typeof value === 'object' && !Array.isArray(value)
|
|
12
13
|
|
|
@@ -59,7 +60,9 @@ export function planEdit(manifest, edits) {
|
|
|
59
60
|
function listAt(doc, schema, path) {
|
|
60
61
|
const parsed = parsePath(path)
|
|
61
62
|
if (!parsed) return null
|
|
62
|
-
|
|
63
|
+
/* 默认分页与 buildManifest 同一语义(通用信封,不猜业务形状);
|
|
64
|
+
* PPT 的 slides/deck.slides 解释由套件经 schema.pages 显式传入。 */
|
|
65
|
+
const pagesOf = schema.pages || defaultPages
|
|
63
66
|
const nodesOf = schema.nodes || ((p) => (Array.isArray(p?.elements) ? p.elements : Array.isArray(p?.children) ? p.children : []))
|
|
64
67
|
const childrenOf = typeof schema.children === 'function' ? schema.children : () => null
|
|
65
68
|
const page = pagesOf(doc)?.[parsed.page]
|
|
@@ -117,7 +120,9 @@ export function applyPlan(doc, plan, schema = {}) {
|
|
|
117
120
|
const skipped = []
|
|
118
121
|
for (const op of plan) {
|
|
119
122
|
if (op.op === 'insert') {
|
|
120
|
-
|
|
123
|
+
/* 与 listAt/buildManifest 共用 defaultPages(含 [doc] 兜底):
|
|
124
|
+
* 单对象文档(无 pages 包裹)的 insert 也能落到默认页。 */
|
|
125
|
+
const pagesOf = schema.pages || defaultPages
|
|
121
126
|
const nodesOf = schema.nodes || ((p) => (Array.isArray(p?.elements) ? p.elements : p.children || []))
|
|
122
127
|
const page = pagesOf(next)?.[op.page]
|
|
123
128
|
if (!page) { skipped.push({ op, reason: 'NO_PAGE' }); continue }
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* owner 租约组合成稳定的 DocumentSession API。
|
|
4
4
|
*
|
|
5
5
|
* 领域文档放在 documentKey 下;summary/onApplied 由调用方提供。
|
|
6
|
+
* shape(可选形状标签,如 'ppt.deck')随 checkpoint 写入,供套件投影识别;
|
|
7
|
+
* checkpoint 列表的业务字段由 backend 的 project 声明叠加,内核只回通用信封。
|
|
6
8
|
*/
|
|
7
9
|
import {
|
|
8
10
|
applyAck, applyPush, applyServer, applyShotRequest, applyShotResult,
|
|
@@ -41,6 +43,7 @@ export class DocumentSession {
|
|
|
41
43
|
checkpointDocument = null,
|
|
42
44
|
stateCompact = true,
|
|
43
45
|
pendingTtl = PENDING_TTL,
|
|
46
|
+
shape = null,
|
|
44
47
|
} = {}) {
|
|
45
48
|
if (!backend) throw new Error('DocumentSession 需要 backend')
|
|
46
49
|
this.backend = backend
|
|
@@ -51,6 +54,9 @@ export class DocumentSession {
|
|
|
51
54
|
this.checkpointDocument = checkpointDocument
|
|
52
55
|
this.stateCompact = stateCompact !== false
|
|
53
56
|
this.pendingTtl = Number(pendingTtl) || PENDING_TTL
|
|
57
|
+
/* 形状标签(如 'ppt.deck'):写进 checkpoint payload 供套件投影识别新格式;
|
|
58
|
+
* 缺省不写(旧格式不变),旧 payload 无标签时套件 projector 按键名兜底。 */
|
|
59
|
+
this.shape = typeof shape === 'string' && shape ? shape : null
|
|
54
60
|
this.dir = backend.dir || ''
|
|
55
61
|
this.file = backend.file || ''
|
|
56
62
|
this.journalFile = backend.journalFile || ''
|
|
@@ -251,6 +257,8 @@ export class DocumentSession {
|
|
|
251
257
|
seq: this.doc.seq | 0,
|
|
252
258
|
appliedSeq: this.doc.applied_seq | 0,
|
|
253
259
|
pending,
|
|
260
|
+
/* 通用信封 + 形状标签:业务形状的解释归套件投影,内核只记录标签。 */
|
|
261
|
+
...(this.shape ? { shape: this.shape } : {}),
|
|
254
262
|
...summary,
|
|
255
263
|
title: this.doc.title || summary.title || '',
|
|
256
264
|
[this.documentKey]: this.doc[this.documentKey]
|