@celljs/ta-host 4.8.0 → 4.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +33 -5
- package/README.md +33 -5
- package/cell.schema.json +4 -0
- package/cell.yml +2 -0
- package/esm/node/client-tool-broker.d.ts +11 -3
- package/esm/node/client-tool-broker.js +23 -3
- package/esm/node/host-protocol.d.ts +22 -1
- package/esm/node/host-protocol.js +1 -0
- package/esm/node/index.d.ts +4 -0
- package/esm/node/index.js +4 -0
- package/esm/node/live-run.d.ts +22 -0
- package/esm/node/live-run.js +58 -0
- package/esm/node/message-page.d.ts +17 -0
- package/esm/node/message-page.js +71 -0
- package/esm/node/package-server-impl.d.ts +9 -1
- package/esm/node/package-server-impl.js +16 -1
- package/esm/node/relay-bridge.d.ts +9 -1
- package/esm/node/relay-bridge.js +44 -4
- package/esm/node/session-catalog.d.ts +69 -0
- package/esm/node/session-catalog.js +211 -0
- package/esm/node/session-info-util.d.ts +4 -1
- package/esm/node/session-info-util.js +8 -3
- package/esm/node/settings-store.d.ts +1 -4
- package/esm/node/settings-store.js +11 -3
- package/esm/node/sign-in/access-server-impl.d.ts +19 -0
- package/esm/node/sign-in/access-server-impl.js +82 -0
- package/esm/node/sign-in/access-store.d.ts +65 -0
- package/esm/node/sign-in/access-store.js +175 -0
- package/esm/node/sign-in/index.d.ts +7 -0
- package/esm/node/sign-in/index.js +8 -0
- package/esm/node/sign-in/sign-in-flow.d.ts +58 -0
- package/esm/node/sign-in/sign-in-flow.js +104 -0
- package/esm/node/sign-in/sign-in-middleware.d.ts +10 -0
- package/esm/node/sign-in/sign-in-middleware.js +48 -0
- package/esm/node/sign-in/sign-in-pages.d.ts +31 -0
- package/esm/node/sign-in/sign-in-pages.js +118 -0
- package/esm/node/sign-in/sign-in-provider.d.ts +135 -0
- package/esm/node/sign-in/sign-in-provider.js +225 -0
- package/esm/node/sign-in/ta-sign-in.d.ts +10 -0
- package/esm/node/sign-in/ta-sign-in.js +32 -0
- package/esm/node/ta-access.d.ts +7 -0
- package/esm/node/ta-access.js +30 -1
- package/esm/node/ta-server-impl.d.ts +8 -3
- package/esm/node/ta-server-impl.js +25 -6
- package/esm/node/ta-session-factory.d.ts +1 -1
- package/esm/node/ta-session-factory.js +14 -4
- package/esm/node/ta-session-registry.d.ts +2 -0
- package/esm/node/ta-session-registry.js +23 -3
- package/esm/node/ta-session.d.ts +24 -2
- package/esm/node/ta-session.js +83 -6
- package/esm/node/temporary-packages.d.ts +46 -0
- package/esm/node/temporary-packages.js +114 -0
- package/esm/node/temporary-purge.d.ts +13 -0
- package/esm/node/temporary-purge.js +51 -0
- package/esm/node/web-extension-catalog.d.ts +28 -1
- package/esm/node/web-extension-catalog.js +173 -5
- package/esm/node/web-extension-util.d.ts +5 -1
- package/esm/node/web-extension-util.js +36 -5
- package/esm/node/workspace-service.js +1 -1
- package/lib/node/client-tool-broker.d.ts +11 -3
- package/lib/node/client-tool-broker.js +23 -3
- package/lib/node/host-protocol.d.ts +22 -1
- package/lib/node/host-protocol.js +2 -1
- package/lib/node/index.d.ts +4 -0
- package/lib/node/index.js +4 -0
- package/lib/node/live-run.d.ts +23 -0
- package/lib/node/live-run.js +62 -0
- package/lib/node/message-page.d.ts +18 -0
- package/lib/node/message-page.js +74 -0
- package/lib/node/package-server-impl.d.ts +9 -1
- package/lib/node/package-server-impl.js +15 -0
- package/lib/node/relay-bridge.d.ts +9 -1
- package/lib/node/relay-bridge.js +43 -3
- package/lib/node/session-catalog.d.ts +70 -0
- package/lib/node/session-catalog.js +214 -0
- package/lib/node/session-info-util.d.ts +4 -1
- package/lib/node/session-info-util.js +7 -2
- package/lib/node/settings-store.d.ts +1 -4
- package/lib/node/settings-store.js +11 -3
- package/lib/node/sign-in/access-server-impl.d.ts +20 -0
- package/lib/node/sign-in/access-server-impl.js +85 -0
- package/lib/node/sign-in/access-store.d.ts +66 -0
- package/lib/node/sign-in/access-store.js +179 -0
- package/lib/node/sign-in/index.d.ts +8 -0
- package/lib/node/sign-in/index.js +24 -0
- package/lib/node/sign-in/sign-in-flow.d.ts +59 -0
- package/lib/node/sign-in/sign-in-flow.js +108 -0
- package/lib/node/sign-in/sign-in-middleware.d.ts +11 -0
- package/lib/node/sign-in/sign-in-middleware.js +51 -0
- package/lib/node/sign-in/sign-in-pages.d.ts +32 -0
- package/lib/node/sign-in/sign-in-pages.js +121 -0
- package/lib/node/sign-in/sign-in-provider.d.ts +136 -0
- package/lib/node/sign-in/sign-in-provider.js +232 -0
- package/lib/node/sign-in/ta-sign-in.d.ts +11 -0
- package/lib/node/sign-in/ta-sign-in.js +35 -0
- package/lib/node/ta-access.d.ts +7 -0
- package/lib/node/ta-access.js +30 -1
- package/lib/node/ta-server-impl.d.ts +8 -3
- package/lib/node/ta-server-impl.js +24 -5
- package/lib/node/ta-session-factory.d.ts +1 -1
- package/lib/node/ta-session-factory.js +14 -4
- package/lib/node/ta-session-registry.d.ts +2 -0
- package/lib/node/ta-session-registry.js +23 -3
- package/lib/node/ta-session.d.ts +24 -2
- package/lib/node/ta-session.js +83 -6
- package/lib/node/temporary-packages.d.ts +47 -0
- package/lib/node/temporary-packages.js +118 -0
- package/lib/node/temporary-purge.d.ts +14 -0
- package/lib/node/temporary-purge.js +54 -0
- package/lib/node/web-extension-catalog.d.ts +28 -1
- package/lib/node/web-extension-catalog.js +172 -4
- package/lib/node/web-extension-util.d.ts +5 -1
- package/lib/node/web-extension-util.js +36 -5
- package/lib/node/workspace-service.js +1 -1
- package/package.json +17 -12
- package/esm/node/auth-server-impl.js.map +0 -1
- package/esm/node/client-channel.js.map +0 -1
- package/esm/node/client-tool-broker.js.map +0 -1
- package/esm/node/event-log.js.map +0 -1
- package/esm/node/exec-environment-factory.js.map +0 -1
- package/esm/node/extension-data-notifier.js.map +0 -1
- package/esm/node/extension-data.js.map +0 -1
- package/esm/node/extension-providers.js.map +0 -1
- package/esm/node/host-protocol.js.map +0 -1
- package/esm/node/index.js.map +0 -1
- package/esm/node/module.js.map +0 -1
- package/esm/node/package-host-extension.js.map +0 -1
- package/esm/node/package-hosts.js.map +0 -1
- package/esm/node/package-server-impl.js.map +0 -1
- package/esm/node/package-switch.js.map +0 -1
- package/esm/node/receipt-book.js.map +0 -1
- package/esm/node/relay-bridge.js.map +0 -1
- package/esm/node/remote/index.js.map +0 -1
- package/esm/node/remote/pi-directories.js.map +0 -1
- package/esm/node/remote/port-forwards.js.map +0 -1
- package/esm/node/remote/remote-hosts.js.map +0 -1
- package/esm/node/remote/remote-protocol.js.map +0 -1
- package/esm/node/remote/remote-server-impl.js.map +0 -1
- package/esm/node/remote-ui-context.js.map +0 -1
- package/esm/node/session-files.js.map +0 -1
- package/esm/node/session-info-util.js.map +0 -1
- package/esm/node/session-storage/file-session-storage.js.map +0 -1
- package/esm/node/session-storage/index.js.map +0 -1
- package/esm/node/session-storage/session-storage-protocol.js.map +0 -1
- package/esm/node/session-storage/stored-session.js.map +0 -1
- package/esm/node/settings-server-impl.js.map +0 -1
- package/esm/node/settings-store.js.map +0 -1
- package/esm/node/ta-access.js.map +0 -1
- package/esm/node/ta-errors.js.map +0 -1
- package/esm/node/ta-event-util.js.map +0 -1
- package/esm/node/ta-server-impl.js.map +0 -1
- package/esm/node/ta-session-factory.js.map +0 -1
- package/esm/node/ta-session-registry.js.map +0 -1
- package/esm/node/ta-session.js.map +0 -1
- package/esm/node/terminal-protocol.js.map +0 -1
- package/esm/node/terminal-service.js.map +0 -1
- package/esm/node/terminal-util.js.map +0 -1
- package/esm/node/web-extension-catalog.js.map +0 -1
- package/esm/node/web-extension-util.js.map +0 -1
- package/esm/node/working-directory.js.map +0 -1
- package/esm/node/workspace-files.js.map +0 -1
- package/esm/node/workspace-protocol.js.map +0 -1
- package/esm/node/workspace-server-impl.js.map +0 -1
- package/esm/node/workspace-service.js.map +0 -1
- package/esm/node/workspace-util.js.map +0 -1
- package/lib/node/auth-server-impl.d.ts.map +0 -1
- package/lib/node/auth-server-impl.js.map +0 -1
- package/lib/node/auth-server-impl.spec.d.ts +0 -2
- package/lib/node/auth-server-impl.spec.d.ts.map +0 -1
- package/lib/node/auth-server-impl.spec.js +0 -47
- package/lib/node/auth-server-impl.spec.js.map +0 -1
- package/lib/node/client-channel.d.ts.map +0 -1
- package/lib/node/client-channel.js.map +0 -1
- package/lib/node/client-channel.spec.d.ts +0 -2
- package/lib/node/client-channel.spec.d.ts.map +0 -1
- package/lib/node/client-channel.spec.js +0 -106
- package/lib/node/client-channel.spec.js.map +0 -1
- package/lib/node/client-tool-broker.d.ts.map +0 -1
- package/lib/node/client-tool-broker.js.map +0 -1
- package/lib/node/client-tool-broker.spec.d.ts +0 -2
- package/lib/node/client-tool-broker.spec.d.ts.map +0 -1
- package/lib/node/client-tool-broker.spec.js +0 -49
- package/lib/node/client-tool-broker.spec.js.map +0 -1
- package/lib/node/event-log.d.ts.map +0 -1
- package/lib/node/event-log.js.map +0 -1
- package/lib/node/event-log.spec.d.ts +0 -2
- package/lib/node/event-log.spec.d.ts.map +0 -1
- package/lib/node/event-log.spec.js +0 -48
- package/lib/node/event-log.spec.js.map +0 -1
- package/lib/node/exec-environment-factory.d.ts.map +0 -1
- package/lib/node/exec-environment-factory.js.map +0 -1
- package/lib/node/extension-data-notifier.d.ts.map +0 -1
- package/lib/node/extension-data-notifier.js.map +0 -1
- package/lib/node/extension-data-notifier.spec.d.ts +0 -2
- package/lib/node/extension-data-notifier.spec.d.ts.map +0 -1
- package/lib/node/extension-data-notifier.spec.js +0 -35
- package/lib/node/extension-data-notifier.spec.js.map +0 -1
- package/lib/node/extension-data.d.ts.map +0 -1
- package/lib/node/extension-data.js.map +0 -1
- package/lib/node/extension-data.spec.d.ts +0 -2
- package/lib/node/extension-data.spec.d.ts.map +0 -1
- package/lib/node/extension-data.spec.js +0 -99
- package/lib/node/extension-data.spec.js.map +0 -1
- package/lib/node/extension-providers.d.ts.map +0 -1
- package/lib/node/extension-providers.js.map +0 -1
- package/lib/node/host-protocol.d.ts.map +0 -1
- package/lib/node/host-protocol.js.map +0 -1
- package/lib/node/index.d.ts.map +0 -1
- package/lib/node/index.js.map +0 -1
- package/lib/node/module.d.ts.map +0 -1
- package/lib/node/module.js.map +0 -1
- package/lib/node/package-host-extension.d.ts.map +0 -1
- package/lib/node/package-host-extension.js.map +0 -1
- package/lib/node/package-hosts.d.ts.map +0 -1
- package/lib/node/package-hosts.js.map +0 -1
- package/lib/node/package-hosts.spec.d.ts +0 -2
- package/lib/node/package-hosts.spec.d.ts.map +0 -1
- package/lib/node/package-hosts.spec.js +0 -53
- package/lib/node/package-hosts.spec.js.map +0 -1
- package/lib/node/package-server-impl.d.ts.map +0 -1
- package/lib/node/package-server-impl.js.map +0 -1
- package/lib/node/package-switch.d.ts.map +0 -1
- package/lib/node/package-switch.js.map +0 -1
- package/lib/node/receipt-book.d.ts.map +0 -1
- package/lib/node/receipt-book.js.map +0 -1
- package/lib/node/receipt-book.spec.d.ts +0 -2
- package/lib/node/receipt-book.spec.d.ts.map +0 -1
- package/lib/node/receipt-book.spec.js +0 -39
- package/lib/node/receipt-book.spec.js.map +0 -1
- package/lib/node/relay-bridge.d.ts.map +0 -1
- package/lib/node/relay-bridge.js.map +0 -1
- package/lib/node/remote/index.d.ts.map +0 -1
- package/lib/node/remote/index.js.map +0 -1
- package/lib/node/remote/pi-directories.d.ts.map +0 -1
- package/lib/node/remote/pi-directories.js.map +0 -1
- package/lib/node/remote/port-forwards.d.ts.map +0 -1
- package/lib/node/remote/port-forwards.js.map +0 -1
- package/lib/node/remote/remote-hosts.d.ts.map +0 -1
- package/lib/node/remote/remote-hosts.js.map +0 -1
- package/lib/node/remote/remote-protocol.d.ts.map +0 -1
- package/lib/node/remote/remote-protocol.js.map +0 -1
- package/lib/node/remote/remote-server-impl.d.ts.map +0 -1
- package/lib/node/remote/remote-server-impl.js.map +0 -1
- package/lib/node/remote/remote.spec.d.ts +0 -2
- package/lib/node/remote/remote.spec.d.ts.map +0 -1
- package/lib/node/remote/remote.spec.js +0 -130
- package/lib/node/remote/remote.spec.js.map +0 -1
- package/lib/node/remote-ui-context.d.ts.map +0 -1
- package/lib/node/remote-ui-context.js.map +0 -1
- package/lib/node/remote-ui-context.spec.d.ts +0 -2
- package/lib/node/remote-ui-context.spec.d.ts.map +0 -1
- package/lib/node/remote-ui-context.spec.js +0 -85
- package/lib/node/remote-ui-context.spec.js.map +0 -1
- package/lib/node/session-files.d.ts.map +0 -1
- package/lib/node/session-files.js.map +0 -1
- package/lib/node/session-files.spec.d.ts +0 -2
- package/lib/node/session-files.spec.d.ts.map +0 -1
- package/lib/node/session-files.spec.js +0 -51
- package/lib/node/session-files.spec.js.map +0 -1
- package/lib/node/session-info-util.d.ts.map +0 -1
- package/lib/node/session-info-util.js.map +0 -1
- package/lib/node/session-info-util.spec.d.ts +0 -2
- package/lib/node/session-info-util.spec.d.ts.map +0 -1
- package/lib/node/session-info-util.spec.js +0 -22
- package/lib/node/session-info-util.spec.js.map +0 -1
- package/lib/node/session-storage/file-session-storage.d.ts.map +0 -1
- package/lib/node/session-storage/file-session-storage.js.map +0 -1
- package/lib/node/session-storage/file-session-storage.spec.d.ts +0 -2
- package/lib/node/session-storage/file-session-storage.spec.d.ts.map +0 -1
- package/lib/node/session-storage/file-session-storage.spec.js +0 -70
- package/lib/node/session-storage/file-session-storage.spec.js.map +0 -1
- package/lib/node/session-storage/index.d.ts.map +0 -1
- package/lib/node/session-storage/index.js.map +0 -1
- package/lib/node/session-storage/session-storage-protocol.d.ts.map +0 -1
- package/lib/node/session-storage/session-storage-protocol.js.map +0 -1
- package/lib/node/session-storage/stored-session.d.ts.map +0 -1
- package/lib/node/session-storage/stored-session.js.map +0 -1
- package/lib/node/session-storage/stored-session.spec.d.ts +0 -2
- package/lib/node/session-storage/stored-session.spec.d.ts.map +0 -1
- package/lib/node/session-storage/stored-session.spec.js +0 -73
- package/lib/node/session-storage/stored-session.spec.js.map +0 -1
- package/lib/node/settings-server-impl.d.ts.map +0 -1
- package/lib/node/settings-server-impl.js.map +0 -1
- package/lib/node/settings-store.d.ts.map +0 -1
- package/lib/node/settings-store.js.map +0 -1
- package/lib/node/settings-store.spec.d.ts +0 -2
- package/lib/node/settings-store.spec.d.ts.map +0 -1
- package/lib/node/settings-store.spec.js +0 -148
- package/lib/node/settings-store.spec.js.map +0 -1
- package/lib/node/ta-access.d.ts.map +0 -1
- package/lib/node/ta-access.js.map +0 -1
- package/lib/node/ta-access.spec.d.ts +0 -2
- package/lib/node/ta-access.spec.d.ts.map +0 -1
- package/lib/node/ta-access.spec.js +0 -33
- package/lib/node/ta-access.spec.js.map +0 -1
- package/lib/node/ta-errors.d.ts.map +0 -1
- package/lib/node/ta-errors.js.map +0 -1
- package/lib/node/ta-errors.spec.d.ts +0 -2
- package/lib/node/ta-errors.spec.d.ts.map +0 -1
- package/lib/node/ta-errors.spec.js +0 -25
- package/lib/node/ta-errors.spec.js.map +0 -1
- package/lib/node/ta-event-util.d.ts.map +0 -1
- package/lib/node/ta-event-util.js.map +0 -1
- package/lib/node/ta-event-util.spec.d.ts +0 -2
- package/lib/node/ta-event-util.spec.d.ts.map +0 -1
- package/lib/node/ta-event-util.spec.js +0 -28
- package/lib/node/ta-event-util.spec.js.map +0 -1
- package/lib/node/ta-server-impl.d.ts.map +0 -1
- package/lib/node/ta-server-impl.js.map +0 -1
- package/lib/node/ta-session-factory.d.ts.map +0 -1
- package/lib/node/ta-session-factory.js.map +0 -1
- package/lib/node/ta-session-registry.d.ts.map +0 -1
- package/lib/node/ta-session-registry.js.map +0 -1
- package/lib/node/ta-session.d.ts.map +0 -1
- package/lib/node/ta-session.js.map +0 -1
- package/lib/node/terminal-protocol.d.ts.map +0 -1
- package/lib/node/terminal-protocol.js.map +0 -1
- package/lib/node/terminal-service.d.ts.map +0 -1
- package/lib/node/terminal-service.js.map +0 -1
- package/lib/node/terminal-service.spec.d.ts +0 -2
- package/lib/node/terminal-service.spec.d.ts.map +0 -1
- package/lib/node/terminal-service.spec.js +0 -110
- package/lib/node/terminal-service.spec.js.map +0 -1
- package/lib/node/terminal-util.d.ts.map +0 -1
- package/lib/node/terminal-util.js.map +0 -1
- package/lib/node/terminal-util.spec.d.ts +0 -2
- package/lib/node/terminal-util.spec.d.ts.map +0 -1
- package/lib/node/terminal-util.spec.js +0 -95
- package/lib/node/terminal-util.spec.js.map +0 -1
- package/lib/node/web-extension-catalog.d.ts.map +0 -1
- package/lib/node/web-extension-catalog.js.map +0 -1
- package/lib/node/web-extension-catalog.spec.d.ts +0 -2
- package/lib/node/web-extension-catalog.spec.d.ts.map +0 -1
- package/lib/node/web-extension-catalog.spec.js +0 -157
- package/lib/node/web-extension-catalog.spec.js.map +0 -1
- package/lib/node/web-extension-util.d.ts.map +0 -1
- package/lib/node/web-extension-util.js.map +0 -1
- package/lib/node/working-directory.d.ts.map +0 -1
- package/lib/node/working-directory.js.map +0 -1
- package/lib/node/workspace-files.d.ts.map +0 -1
- package/lib/node/workspace-files.js.map +0 -1
- package/lib/node/workspace-files.spec.d.ts +0 -2
- package/lib/node/workspace-files.spec.d.ts.map +0 -1
- package/lib/node/workspace-files.spec.js +0 -133
- package/lib/node/workspace-files.spec.js.map +0 -1
- package/lib/node/workspace-protocol.d.ts.map +0 -1
- package/lib/node/workspace-protocol.js.map +0 -1
- package/lib/node/workspace-server-impl.d.ts.map +0 -1
- package/lib/node/workspace-server-impl.js.map +0 -1
- package/lib/node/workspace-service.d.ts.map +0 -1
- package/lib/node/workspace-service.js.map +0 -1
- package/lib/node/workspace-service.spec.d.ts +0 -2
- package/lib/node/workspace-service.spec.d.ts.map +0 -1
- package/lib/node/workspace-service.spec.js +0 -113
- package/lib/node/workspace-service.spec.js.map +0 -1
- package/lib/node/workspace-util.d.ts.map +0 -1
- package/lib/node/workspace-util.js.map +0 -1
- package/lib/node/workspace-util.spec.d.ts +0 -2
- package/lib/node/workspace-util.spec.d.ts.map +0 -1
- package/lib/node/workspace-util.spec.js +0 -44
- package/lib/node/workspace-util.spec.js.map +0 -1
- package/src/node/auth-server-impl.spec.ts +0 -49
- package/src/node/auth-server-impl.ts +0 -258
- package/src/node/client-channel.spec.ts +0 -117
- package/src/node/client-channel.ts +0 -94
- package/src/node/client-tool-broker.spec.ts +0 -53
- package/src/node/client-tool-broker.ts +0 -106
- package/src/node/event-log.spec.ts +0 -52
- package/src/node/event-log.ts +0 -59
- package/src/node/exec-environment-factory.ts +0 -66
- package/src/node/extension-data-notifier.spec.ts +0 -34
- package/src/node/extension-data-notifier.ts +0 -124
- package/src/node/extension-data.spec.ts +0 -105
- package/src/node/extension-data.ts +0 -180
- package/src/node/extension-providers.ts +0 -49
- package/src/node/host-protocol.ts +0 -62
- package/src/node/index.ts +0 -39
- package/src/node/module.ts +0 -4
- package/src/node/package-host-extension.ts +0 -23
- package/src/node/package-hosts.spec.ts +0 -54
- package/src/node/package-hosts.ts +0 -204
- package/src/node/package-server-impl.ts +0 -87
- package/src/node/package-switch.ts +0 -80
- package/src/node/receipt-book.spec.ts +0 -41
- package/src/node/receipt-book.ts +0 -40
- package/src/node/relay-bridge.ts +0 -94
- package/src/node/remote/index.ts +0 -5
- package/src/node/remote/pi-directories.ts +0 -49
- package/src/node/remote/port-forwards.ts +0 -148
- package/src/node/remote/remote-hosts.ts +0 -170
- package/src/node/remote/remote-protocol.ts +0 -57
- package/src/node/remote/remote-server-impl.ts +0 -60
- package/src/node/remote/remote.spec.ts +0 -142
- package/src/node/remote-ui-context.spec.ts +0 -93
- package/src/node/remote-ui-context.ts +0 -197
- package/src/node/session-files.spec.ts +0 -52
- package/src/node/session-files.ts +0 -41
- package/src/node/session-info-util.spec.ts +0 -23
- package/src/node/session-info-util.ts +0 -55
- package/src/node/session-storage/file-session-storage.spec.ts +0 -72
- package/src/node/session-storage/file-session-storage.ts +0 -145
- package/src/node/session-storage/index.ts +0 -3
- package/src/node/session-storage/session-storage-protocol.ts +0 -81
- package/src/node/session-storage/stored-session.spec.ts +0 -80
- package/src/node/session-storage/stored-session.ts +0 -149
- package/src/node/settings-server-impl.ts +0 -42
- package/src/node/settings-store.spec.ts +0 -158
- package/src/node/settings-store.ts +0 -327
- package/src/node/ta-access.spec.ts +0 -36
- package/src/node/ta-access.ts +0 -156
- package/src/node/ta-errors.spec.ts +0 -25
- package/src/node/ta-errors.ts +0 -75
- package/src/node/ta-event-util.spec.ts +0 -29
- package/src/node/ta-event-util.ts +0 -23
- package/src/node/ta-server-impl.ts +0 -341
- package/src/node/ta-session-factory.ts +0 -216
- package/src/node/ta-session-registry.ts +0 -75
- package/src/node/ta-session.ts +0 -241
- package/src/node/terminal-protocol.ts +0 -18
- package/src/node/terminal-service.spec.ts +0 -119
- package/src/node/terminal-service.ts +0 -291
- package/src/node/terminal-util.spec.ts +0 -109
- package/src/node/terminal-util.ts +0 -197
- package/src/node/web-extension-catalog.spec.ts +0 -172
- package/src/node/web-extension-catalog.ts +0 -177
- package/src/node/web-extension-util.ts +0 -144
- package/src/node/working-directory.ts +0 -71
- package/src/node/workspace-files.spec.ts +0 -145
- package/src/node/workspace-files.ts +0 -256
- package/src/node/workspace-protocol.ts +0 -24
- package/src/node/workspace-server-impl.ts +0 -108
- package/src/node/workspace-service.spec.ts +0 -123
- package/src/node/workspace-service.ts +0 -235
- package/src/node/workspace-util.spec.ts +0 -47
- package/src/node/workspace-util.ts +0 -103
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'bun:test';
|
|
2
|
-
import { PipeDiscipline, TerminalUtil, TtyMarker } from './terminal-util';
|
|
3
|
-
|
|
4
|
-
describe('TerminalUtil', () => {
|
|
5
|
-
it('reads the platform', () => {
|
|
6
|
-
expect(TerminalUtil.parsePlatform('Darwin\n/usr/bin/script\n/bin/zsh', '/bin/sh')).toEqual({ system: 'Darwin', script: true, shell: '/bin/zsh' });
|
|
7
|
-
expect(TerminalUtil.parsePlatform('Linux\n\n', '/bin/sh')).toEqual({ system: 'Linux', script: false, shell: '/bin/sh' });
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('runs the shell on a pseudo-terminal when script is there', () => {
|
|
11
|
-
const mac = TerminalUtil.launch({ system: 'Darwin', script: true, shell: '/bin/zsh' }, 100, 30);
|
|
12
|
-
expect(mac).toMatchObject({ command: '/bin/sh', pty: true });
|
|
13
|
-
expect(mac.args[1]).toStartWith('cat | { script -q /dev/null /bin/sh -c ');
|
|
14
|
-
expect(mac.args[1]).toContain('stty cols 100 rows 30');
|
|
15
|
-
expect(mac.args[1]).toContain('/bin/zsh');
|
|
16
|
-
expect(mac.args[1]).toContain('BASH_SILENCE_DEPRECATION_WARNING=1');
|
|
17
|
-
expect(mac.args[1]).toEndWith('kill $$; }');
|
|
18
|
-
const linux = TerminalUtil.launch({ system: 'Linux', script: true, shell: '/bin/bash' }, 80, 24);
|
|
19
|
-
expect(linux.args[1]).toStartWith('cat | { script -qefc ');
|
|
20
|
-
expect(linux.args[1]).toContain(' /dev/null; code=$?');
|
|
21
|
-
expect(TerminalUtil.launch({ system: 'Linux', script: false, shell: '/bin/bash' }, 80, 24)).toEqual({ command: '/bin/bash', args: ['-i'], pty: false });
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('resizes with the stty of the system', () => {
|
|
25
|
-
expect(TerminalUtil.resizeCommand({ system: 'Linux', script: true, shell: '' }, '/dev/pts/3', 120, 40)).toBe("stty -F '/dev/pts/3' cols 120 rows 40");
|
|
26
|
-
expect(TerminalUtil.resizeCommand({ system: 'Darwin', script: true, shell: '' }, '/dev/ttys001', 80, 24)).toBe(
|
|
27
|
-
"stty -f '/dev/ttys001' cols 80 rows 24",
|
|
28
|
-
);
|
|
29
|
-
expect(TerminalUtil.hangUpCommand('/dev/pts/3')).toBe("kill -HUP $(ps -t 'pts/3' -o pid=)");
|
|
30
|
-
expect(TerminalUtil.size(0, 80)).toBe(1);
|
|
31
|
-
expect(TerminalUtil.size(Number.NaN, 80)).toBe(80);
|
|
32
|
-
expect(TerminalUtil.size(99999, 80)).toBe(1000);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
describe('TerminalUtil.takeExitCode', () => {
|
|
37
|
-
it('takes the code the wrapper printed', () => {
|
|
38
|
-
expect(TerminalUtil.takeExitCode('bye\x1b]1337;ta-exit=3\x07')).toEqual({ text: 'bye', exitCode: 3 });
|
|
39
|
-
expect(TerminalUtil.takeExitCode('plain')).toEqual({ text: 'plain' });
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
describe('TtyMarker', () => {
|
|
44
|
-
it('takes the name of the terminal out of the output, in pieces too', () => {
|
|
45
|
-
const marker = new TtyMarker();
|
|
46
|
-
expect(marker.feed('^D\x1b]1337;ta-')).toBe('');
|
|
47
|
-
expect(marker.feed('tty=/dev/ttys004\x07$ ')).toBe('^D$ ');
|
|
48
|
-
expect(marker.tty).toBe('/dev/ttys004');
|
|
49
|
-
expect(marker.feed('more')).toBe('more');
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('gives up after a while, and gives back what it held', () => {
|
|
53
|
-
const marker = new TtyMarker();
|
|
54
|
-
expect(marker.feed('x'.repeat(5000))).toHaveLength(5000);
|
|
55
|
-
expect(marker.tty).toBeUndefined();
|
|
56
|
-
const early = new TtyMarker();
|
|
57
|
-
early.feed('bye');
|
|
58
|
-
expect(early.flush()).toBe('bye');
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
describe('PipeDiscipline', () => {
|
|
63
|
-
it('echoes, edits the line, and sends it on Enter', () => {
|
|
64
|
-
const discipline = new PipeDiscipline();
|
|
65
|
-
expect(discipline.input('lsx')).toEqual({ echo: 'lsx', send: '' });
|
|
66
|
-
expect(discipline.input('\x7f')).toEqual({ echo: '\b \b', send: '' });
|
|
67
|
-
expect(discipline.input('\x1b[A -l\r')).toEqual({ echo: ' -l\r\n', send: 'ls -l\n' });
|
|
68
|
-
discipline.input('oops');
|
|
69
|
-
expect(discipline.input('\x03').echo).toBe('^C\r\n');
|
|
70
|
-
expect(discipline.input('\r').send).toBe('\n');
|
|
71
|
-
discipline.input('ab');
|
|
72
|
-
expect(discipline.input('\x15').echo).toBe('\b \b\b \b');
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('turns line feeds into what a terminal shows', () => {
|
|
76
|
-
expect(new PipeDiscipline().output('a\nb\r\n')).toBe('a\r\nb\r\n');
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
describe('TerminalUtil.tail', () => {
|
|
81
|
-
it('keeps the end, from the start of a line', () => {
|
|
82
|
-
expect(TerminalUtil.tail('abc', 10)).toBe('abc');
|
|
83
|
-
expect(TerminalUtil.tail('one\r\n\x1b[31mtwo\r\nthree', 12)).toBe('three');
|
|
84
|
-
expect(TerminalUtil.tail('abcdefgh', 3)).toBe('fgh');
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
describe('TerminalUtil.UTF8_LOCALE', () => {
|
|
89
|
-
const ctype = (env: Record<string, string>) =>
|
|
90
|
-
new TextDecoder()
|
|
91
|
-
.decode(
|
|
92
|
-
Bun.spawnSync(['/bin/sh', '-c', `${TerminalUtil.UTF8_LOCALE}; printf '%s|%s' "$LC_CTYPE" "$LC_ALL"`], {
|
|
93
|
-
env: { PATH: process.env.PATH ?? '/usr/bin:/bin', ...env },
|
|
94
|
-
}).stdout,
|
|
95
|
-
)
|
|
96
|
-
.split('|');
|
|
97
|
-
|
|
98
|
-
it('gives a shell without a UTF-8 locale one for its characters', () => {
|
|
99
|
-
const [lcCtype, lcAll] = ctype({ LANG: 'C' });
|
|
100
|
-
expect(lcCtype).toMatch(/utf-?8$/i);
|
|
101
|
-
expect(lcAll).toBe('');
|
|
102
|
-
expect(ctype({ LC_ALL: 'POSIX' }).every(value => /utf-?8$/i.test(value))).toBe(true);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('leaves a UTF-8 locale as it is', () => {
|
|
106
|
-
expect(ctype({ LANG: 'zh_CN.UTF-8' })).toEqual(['', '']);
|
|
107
|
-
expect(ctype({ LC_CTYPE: 'en_US.utf8' })).toEqual(['en_US.utf8', '']);
|
|
108
|
-
});
|
|
109
|
-
});
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import { WorkspaceUtil } from './workspace-util';
|
|
2
|
-
|
|
3
|
-
/** What the environment has for a shell: its system (`uname -s`), `script` and the user's shell. */
|
|
4
|
-
export interface TerminalPlatform {
|
|
5
|
-
system: string;
|
|
6
|
-
script: boolean;
|
|
7
|
-
shell: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface TerminalLaunch {
|
|
11
|
-
command: string;
|
|
12
|
-
args: string[];
|
|
13
|
-
/** Runs on a pseudo-terminal: the shell echoes and edits lines itself. */
|
|
14
|
-
pty: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** The shell prints the name of its terminal first, between these, so that resizing can find it. */
|
|
18
|
-
const TTY_START = '\x1b]1337;ta-tty=';
|
|
19
|
-
const TTY_END = '\x07';
|
|
20
|
-
const ESC = '\x1b';
|
|
21
|
-
const EXIT_MARK = new RegExp(`${ESC}\\]1337;ta-exit=(\\d+)\x07`);
|
|
22
|
-
/** Sequences of keys (arrows, F-keys): they mean nothing to a line. */
|
|
23
|
-
const KEY_SEQUENCE = new RegExp(`${ESC}(?:\\[[0-9;?]*[ -/]*[@-~]|O.|.)?`, 'g');
|
|
24
|
-
/** The name comes first or not at all: after this much output, nobody looks for it. */
|
|
25
|
-
const TTY_SEARCH_CHARS = 4096;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Shells without node-pty: `script` (BSD's or util-linux's) gives one a pseudo-terminal; without it the
|
|
29
|
-
* shell runs on pipes, and {@link PipeDiscipline} does what the terminal would.
|
|
30
|
-
*/
|
|
31
|
-
export namespace TerminalUtil {
|
|
32
|
-
/** A full reset of the terminal (RIS): its screen, scrollback and modes. */
|
|
33
|
-
export const RESET = '\x1bc';
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* At most `max` characters of the end of `text`, from the start of a line when it is cut, so that it
|
|
37
|
-
* does not start inside a control sequence or a character.
|
|
38
|
-
*/
|
|
39
|
-
export function tail(text: string, max: number): string {
|
|
40
|
-
if (text.length <= max) {
|
|
41
|
-
return text;
|
|
42
|
-
}
|
|
43
|
-
const cut = text.slice(-max);
|
|
44
|
-
const line = cut.indexOf('\n');
|
|
45
|
-
return line < 0 ? cut : cut.slice(line + 1);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* A shell started by ssh or by an app of the desktop often has no locale (`C`): it then reads
|
|
50
|
-
* Chinese, typed or pasted, as bytes it cannot show (`<ffffffff>`), and programs print `?`. When
|
|
51
|
-
* the locale is not UTF-8, the shell gets one for its characters (LC_CTYPE, and LC_ALL when set):
|
|
52
|
-
* C.UTF-8 where the system has it, else en_US.UTF-8; its messages and formats stay as they were.
|
|
53
|
-
*/
|
|
54
|
-
export const UTF8_LOCALE = [
|
|
55
|
-
'case "${LC_ALL:-${LC_CTYPE:-$LANG}}" in *[Uu][Tt][Ff]-8*|*[Uu][Tt][Ff]8*) ;; *)',
|
|
56
|
-
"ta_utf8=$(locale -a 2>/dev/null | grep -i -x -m 1 -E 'c\\.utf-?8|en_us\\.utf-?8'); ta_utf8=${ta_utf8:-en_US.UTF-8};",
|
|
57
|
-
'[ -n "$LC_ALL" ] && export LC_ALL="$ta_utf8"; export LC_CTYPE="$ta_utf8"; unset ta_utf8;;',
|
|
58
|
-
'esac',
|
|
59
|
-
].join(' ');
|
|
60
|
-
|
|
61
|
-
/** The command that tells the platform: three lines. */
|
|
62
|
-
export const PROBE = 'uname -s; command -v script; printf %s "$SHELL"';
|
|
63
|
-
|
|
64
|
-
export function parsePlatform(output: string, fallbackShell: string): TerminalPlatform {
|
|
65
|
-
const [system = '', script = '', shell = ''] = output.split('\n').map(line => line.trim());
|
|
66
|
-
return { system, script: script.length > 0, shell: shell || fallbackShell };
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* The shell, on a pseudo-terminal when `script` is there. `script` reads a pipe, not the socket
|
|
71
|
-
* the server hands it (BSD's refuses one): `cat` sits between. When the shell ends, the wrapper
|
|
72
|
-
* prints its code and ends itself, so that `cat` ends with it.
|
|
73
|
-
*/
|
|
74
|
-
export function launch(platform: TerminalPlatform, cols: number, rows: number): TerminalLaunch {
|
|
75
|
-
const quote = WorkspaceUtil.quote;
|
|
76
|
-
const boot = [
|
|
77
|
-
// macOS's bash 3.2 otherwise asks to switch to zsh on each start.
|
|
78
|
-
'export TERM=xterm-256color BASH_SILENCE_DEPRECATION_WARNING=1',
|
|
79
|
-
UTF8_LOCALE,
|
|
80
|
-
// Sized before it says its name: a resize that waited for the name comes after this size.
|
|
81
|
-
`stty cols ${cols} rows ${rows} 2>/dev/null`,
|
|
82
|
-
`printf '\\033]1337;ta-tty=%s\\007' "$(tty)"`,
|
|
83
|
-
`exec ${quote(platform.shell)} -i`,
|
|
84
|
-
].join('; ');
|
|
85
|
-
let script: string | undefined;
|
|
86
|
-
if (platform.script && platform.system === 'Linux') {
|
|
87
|
-
// -e: util-linux's script ends with 0 unless asked for the code of the shell.
|
|
88
|
-
script = `script -qefc ${quote(`/bin/sh -c ${quote(boot)}`)} /dev/null`;
|
|
89
|
-
} else if (platform.script && /^(Darwin|FreeBSD|OpenBSD|NetBSD)$/.test(platform.system)) {
|
|
90
|
-
script = `script -q /dev/null /bin/sh -c ${quote(boot)}`;
|
|
91
|
-
}
|
|
92
|
-
if (script) {
|
|
93
|
-
const wrapper = `cat | { ${script}; code=$?; printf '\\033]1337;ta-exit=%s\\007' "$code"; kill $$; }`;
|
|
94
|
-
return { command: '/bin/sh', args: ['-c', wrapper], pty: true };
|
|
95
|
-
}
|
|
96
|
-
return { command: platform.shell, args: /cmd(\.exe)?$/i.test(platform.shell) ? [] : ['-i'], pty: false };
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/** Ends every program of the terminal `tty`, not only the shell. */
|
|
100
|
-
export function hangUpCommand(tty: string): string {
|
|
101
|
-
return `kill -HUP $(ps -t ${WorkspaceUtil.quote(tty.replace(/^\/dev\//, ''))} -o pid=)`;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/** The code the wrapper of {@link launch} printed, taken out of the output. */
|
|
105
|
-
export function takeExitCode(text: string): { text: string; exitCode?: number } {
|
|
106
|
-
const found = EXIT_MARK.exec(text);
|
|
107
|
-
return found ? { text: text.replace(EXIT_MARK, ''), exitCode: Number(found[1]) } : { text };
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/** Sets the size of the terminal `tty`; its programs get SIGWINCH. */
|
|
111
|
-
export function resizeCommand(platform: TerminalPlatform, tty: string, cols: number, rows: number): string {
|
|
112
|
-
const flag = platform.system === 'Linux' ? '-F' : '-f';
|
|
113
|
-
return `stty ${flag} ${WorkspaceUtil.quote(tty)} cols ${cols} rows ${rows}`;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/** At least one column and row, whole numbers, not absurd. */
|
|
117
|
-
export function size(value: number, fallback: number): number {
|
|
118
|
-
return Number.isFinite(value) ? Math.min(1000, Math.max(1, Math.floor(value))) : fallback;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/** Takes the name of the terminal out of the first output of the shell. */
|
|
123
|
-
export class TtyMarker {
|
|
124
|
-
tty?: string;
|
|
125
|
-
protected head = '';
|
|
126
|
-
protected done = false;
|
|
127
|
-
|
|
128
|
-
/** The output without the name. */
|
|
129
|
-
feed(text: string): string {
|
|
130
|
-
if (this.done) {
|
|
131
|
-
return text;
|
|
132
|
-
}
|
|
133
|
-
this.head += text;
|
|
134
|
-
const start = this.head.indexOf(TTY_START);
|
|
135
|
-
const end = start < 0 ? -1 : this.head.indexOf(TTY_END, start);
|
|
136
|
-
if (end >= 0) {
|
|
137
|
-
this.tty = this.head.slice(start + TTY_START.length, end).trim() || undefined;
|
|
138
|
-
return this.finish(this.head.slice(0, start) + this.head.slice(end + TTY_END.length));
|
|
139
|
-
}
|
|
140
|
-
if (this.head.length > TTY_SEARCH_CHARS) {
|
|
141
|
-
return this.finish(this.head);
|
|
142
|
-
}
|
|
143
|
-
return '';
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/** What it holds, when the shell ended before naming its terminal. */
|
|
147
|
-
flush(): string {
|
|
148
|
-
return this.done ? '' : this.finish(this.head);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
protected finish(text: string): string {
|
|
152
|
-
this.done = true;
|
|
153
|
-
this.head = '';
|
|
154
|
-
return text;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* The line discipline of a terminal for a shell on pipes: it echoes what the user types, edits the
|
|
160
|
-
* line (backspace, Ctrl+U, Ctrl+C) and sends it whole on Enter; output gets `\r\n` for `\n`.
|
|
161
|
-
*/
|
|
162
|
-
export class PipeDiscipline {
|
|
163
|
-
protected line = '';
|
|
164
|
-
|
|
165
|
-
/** What to show, and what to send to the shell. */
|
|
166
|
-
input(data: string): { echo: string; send: string } {
|
|
167
|
-
let echo = '';
|
|
168
|
-
let send = '';
|
|
169
|
-
const text = data.replace(KEY_SEQUENCE, '');
|
|
170
|
-
for (const char of Array.from(text)) {
|
|
171
|
-
if (char === '\r' || char === '\n') {
|
|
172
|
-
send += `${this.line}\n`;
|
|
173
|
-
echo += '\r\n';
|
|
174
|
-
this.line = '';
|
|
175
|
-
} else if (char === '\x7f' || char === '\b') {
|
|
176
|
-
if (this.line) {
|
|
177
|
-
this.line = Array.from(this.line).slice(0, -1).join('');
|
|
178
|
-
echo += '\b \b';
|
|
179
|
-
}
|
|
180
|
-
} else if (char === '\x03') {
|
|
181
|
-
echo += '^C\r\n';
|
|
182
|
-
this.line = '';
|
|
183
|
-
} else if (char === '\x15') {
|
|
184
|
-
echo += '\b \b'.repeat(Array.from(this.line).length);
|
|
185
|
-
this.line = '';
|
|
186
|
-
} else if (char === '\t' || char >= ' ') {
|
|
187
|
-
this.line += char;
|
|
188
|
-
echo += char;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
return { echo, send };
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
output(text: string): string {
|
|
195
|
-
return text.replace(/\r?\n/g, '\r\n');
|
|
196
|
-
}
|
|
197
|
-
}
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, it } from 'bun:test';
|
|
2
|
-
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
-
import { tmpdir } from 'node:os';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
import { WebExtensionCatalogImpl } from './web-extension-catalog';
|
|
6
|
-
import { WebExtensionUtil } from './web-extension-util';
|
|
7
|
-
|
|
8
|
-
const WEB = 'export default function (pi) { pi.ui.setWidget("hello", () => "hi"); }\n';
|
|
9
|
-
|
|
10
|
-
function write(file: string, content: string) {
|
|
11
|
-
mkdirSync(join(file, '..'), { recursive: true });
|
|
12
|
-
writeFileSync(file, content);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
describe('WebExtensionUtil', () => {
|
|
16
|
-
let root: string;
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
root = mkdtempSync(join(tmpdir(), 'ta-web-ext-'));
|
|
19
|
-
});
|
|
20
|
-
afterEach(() => rmSync(root, { recursive: true, force: true }));
|
|
21
|
-
|
|
22
|
-
it('reads pi.web of package.json, and only modules inside the package', () => {
|
|
23
|
-
write(
|
|
24
|
-
join(root, 'package.json'),
|
|
25
|
-
JSON.stringify({ name: 'notes', version: '1.0.0', pi: { web: ['./web.js', '../outside.js', 'missing.js', 'style.css'] } }),
|
|
26
|
-
);
|
|
27
|
-
write(join(root, 'web.js'), WEB);
|
|
28
|
-
write(join(root, 'style.css'), '');
|
|
29
|
-
const [info, ...rest] = WebExtensionUtil.describe({ root, scope: 'user', origin: 'directory', source: root });
|
|
30
|
-
expect(rest).toEqual([]);
|
|
31
|
-
expect(info).toMatchObject({ name: 'notes', version: '1.0.0', entry: 'web.js', scope: 'user', hash: WebExtensionUtil.hash(WEB) });
|
|
32
|
-
expect(() => WebExtensionUtil.read({ root, scope: 'user', origin: 'directory', source: root }, '../outside.js')).toThrow('outside its package');
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('takes the modules of web/ when package.json does not say', () => {
|
|
36
|
-
write(join(root, 'package.json'), JSON.stringify({ pi: { extensions: ['./index.ts'] } }));
|
|
37
|
-
write(join(root, 'web/b.mjs'), WEB);
|
|
38
|
-
write(join(root, 'web/a.js'), WEB);
|
|
39
|
-
write(join(root, 'web/notes.md'), '');
|
|
40
|
-
expect(WebExtensionUtil.describe({ root, scope: 'user', origin: 'directory', source: root }).map(info => info.entry)).toEqual([
|
|
41
|
-
'web/a.js',
|
|
42
|
-
'web/b.mjs',
|
|
43
|
-
]);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('keeps the id when the file changes and changes the hash', () => {
|
|
47
|
-
const pkg = { root, scope: 'user' as const, origin: 'directory' as const, source: root };
|
|
48
|
-
write(join(root, 'package.json'), JSON.stringify({ pi: { web: ['web.js'] } }));
|
|
49
|
-
write(join(root, 'web.js'), WEB);
|
|
50
|
-
const before = WebExtensionUtil.describe(pkg)[0];
|
|
51
|
-
write(join(root, 'web.js'), `${WEB}// changed\n`);
|
|
52
|
-
const after = WebExtensionUtil.describe(pkg)[0];
|
|
53
|
-
expect(after.id).toBe(before.id);
|
|
54
|
-
expect(after.hash).not.toBe(before.hash);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
describe('WebExtensionCatalogImpl', () => {
|
|
59
|
-
let home: string;
|
|
60
|
-
let cwd: string;
|
|
61
|
-
let catalog: WebExtensionCatalogImpl;
|
|
62
|
-
const packageDir = process.env.PI_PACKAGE_DIR;
|
|
63
|
-
beforeEach(() => {
|
|
64
|
-
home = mkdtempSync(join(tmpdir(), 'ta-web-cat-'));
|
|
65
|
-
// The packages that come with ta, as its build lays them out.
|
|
66
|
-
process.env.PI_PACKAGE_DIR = join(home, 'pi');
|
|
67
|
-
mkdirSync(join(home, 'pi/packages'), { recursive: true });
|
|
68
|
-
cwd = join(home, 'project');
|
|
69
|
-
mkdirSync(cwd);
|
|
70
|
-
const agentDir = join(home, 'agent');
|
|
71
|
-
catalog = new WebExtensionCatalogImpl();
|
|
72
|
-
Object.assign(catalog, { codingAgentOptions: { agentDir }, directories: { toPi: (location: string) => location, fromPi: (dir: string) => dir } });
|
|
73
|
-
// A directory in extensions/, and a package of the packages setting elsewhere.
|
|
74
|
-
write(join(agentDir, 'extensions/notes/package.json'), JSON.stringify({ name: 'notes', pi: { web: ['web.js'] } }));
|
|
75
|
-
write(join(agentDir, 'extensions/notes/web.js'), WEB);
|
|
76
|
-
write(join(agentDir, 'extensions/cli-only/package.json'), JSON.stringify({ name: 'cli-only', pi: { extensions: ['index.ts'] } }));
|
|
77
|
-
write(join(home, 'pomodoro/package.json'), JSON.stringify({ name: 'pomodoro', pi: { web: ['web.js'] } }));
|
|
78
|
-
write(join(home, 'pomodoro/web.js'), WEB);
|
|
79
|
-
write(join(agentDir, 'settings.json'), JSON.stringify({ packages: [join(home, 'pomodoro')] }));
|
|
80
|
-
});
|
|
81
|
-
afterEach(() => {
|
|
82
|
-
rmSync(home, { recursive: true, force: true });
|
|
83
|
-
if (packageDir === undefined) {
|
|
84
|
-
delete process.env.PI_PACKAGE_DIR;
|
|
85
|
-
} else {
|
|
86
|
-
process.env.PI_PACKAGE_DIR = packageDir;
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('lists the web extensions of packages and extension directories', async () => {
|
|
91
|
-
const list = await catalog.list(cwd);
|
|
92
|
-
expect(list.map(info => [info.name, info.origin]).sort()).toEqual([
|
|
93
|
-
['notes', 'directory'],
|
|
94
|
-
['pomodoro', 'package'],
|
|
95
|
-
]);
|
|
96
|
-
const notes = list.find(info => info.name === 'notes')!;
|
|
97
|
-
expect(await catalog.read(cwd, notes.id)).toEqual({ id: notes.id, hash: notes.hash, code: WEB });
|
|
98
|
-
await expect(catalog.read(cwd, 'nope')).rejects.toThrow('No package has the web extension nope');
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('removes a package from the setting, and a directory from extensions/', async () => {
|
|
102
|
-
const list = await catalog.list(cwd);
|
|
103
|
-
await catalog.remove(cwd, list.find(info => info.name === 'pomodoro')!.id);
|
|
104
|
-
await catalog.remove(cwd, list.find(info => info.name === 'notes')!.id);
|
|
105
|
-
expect(await catalog.list(cwd)).toEqual([]);
|
|
106
|
-
expect(existsSync(join(home, 'pomodoro/web.js'))).toBe(true);
|
|
107
|
-
expect(existsSync(join(home, 'agent/extensions/notes'))).toBe(false);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it('lists built-in packages, turns them off and on, and does not remove them', async () => {
|
|
111
|
-
write(join(home, 'pi/packages/ta-channels/package.json'), JSON.stringify({ name: '@celljs/ta-channels', pi: { web: ['web/index.js'] } }));
|
|
112
|
-
write(join(home, 'pi/packages/ta-channels/web/index.js'), WEB);
|
|
113
|
-
const builtin = () => catalog.list(cwd).then(list => list.find(info => info.origin === 'builtin')!);
|
|
114
|
-
expect(await builtin()).toMatchObject({ name: '@celljs/ta-channels', scope: 'user', enabled: true });
|
|
115
|
-
await catalog.setEnabled(cwd, '@celljs/ta-channels', false);
|
|
116
|
-
expect(await builtin()).toMatchObject({ enabled: false });
|
|
117
|
-
expect(JSON.parse(readFileSync(join(home, 'agent/ta.json'), 'utf8'))).toEqual({ disabledPackages: ['@celljs/ta-channels'] });
|
|
118
|
-
await catalog.setEnabled(cwd, '@celljs/ta-channels', true);
|
|
119
|
-
expect(await builtin()).toMatchObject({ enabled: true });
|
|
120
|
-
await expect(catalog.remove(cwd, (await builtin()).id)).rejects.toThrow('cannot be removed');
|
|
121
|
-
await expect(catalog.setEnabled(cwd, 'notes', false)).rejects.toThrow('neither a package that comes with Ta nor the id');
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('lists every package, with what it holds, also those without a web extension', async () => {
|
|
125
|
-
const list = await catalog.packages(cwd);
|
|
126
|
-
const cliOnly = list.find(info => info.name === 'cli-only')!;
|
|
127
|
-
expect(cliOnly).toMatchObject({ origin: 'directory', scope: 'user', resources: ['extensions'], root: join(home, 'agent/extensions/cli-only') });
|
|
128
|
-
expect(list.find(info => info.name === 'notes')).toMatchObject({ resources: ['web'] });
|
|
129
|
-
expect(list.find(info => info.name === 'pomodoro')).toMatchObject({ origin: 'package', source: join(home, 'pomodoro') });
|
|
130
|
-
await catalog.removePackage(cwd, cliOnly.id);
|
|
131
|
-
expect(existsSync(join(home, 'agent/extensions/cli-only'))).toBe(false);
|
|
132
|
-
await expect(catalog.removePackage(cwd, 'nope')).rejects.toThrow('No package has the id nope');
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it('installs a package as ta install does, for the user', async () => {
|
|
136
|
-
write(join(home, 'timer/package.json'), JSON.stringify({ name: 'timer', pi: { extensions: ['index.ts'] } }));
|
|
137
|
-
await catalog.install(cwd, join(home, 'timer'), 'user');
|
|
138
|
-
expect(JSON.parse(readFileSync(join(home, 'agent/settings.json'), 'utf8')).packages).toHaveLength(2);
|
|
139
|
-
expect((await catalog.packages(cwd)).map(info => info.name)).toContain('timer');
|
|
140
|
-
await expect(catalog.install(cwd, ' ', 'user')).rejects.toThrow('source of one line');
|
|
141
|
-
await expect(catalog.install(cwd, 'npm:a\nb', 'user')).rejects.toThrow('source of one line');
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it('turns the other packages off and on as pi config does, and those with only a web extension in ta.json', async () => {
|
|
145
|
-
write(join(home, 'agent/extensions/cli-only/index.ts'), 'export default function () {}\n');
|
|
146
|
-
write(join(home, 'pomodoro/index.ts'), 'export default function () {}\n');
|
|
147
|
-
write(join(home, 'pomodoro/package.json'), JSON.stringify({ name: 'pomodoro', pi: { web: ['web.js'], extensions: ['index.ts'] } }));
|
|
148
|
-
const byName = async (name: string) => (await catalog.packages(cwd)).find(info => info.name === name)!;
|
|
149
|
-
const settings = () => JSON.parse(readFileSync(join(home, 'agent/settings.json'), 'utf8'));
|
|
150
|
-
expect((await byName('cli-only')).enabled).toBe(true);
|
|
151
|
-
|
|
152
|
-
// In extensions/: a pattern in the extensions list of the settings.
|
|
153
|
-
await catalog.setEnabled(cwd, (await byName('cli-only')).id, false);
|
|
154
|
-
expect(settings().extensions).toEqual(['-extensions/cli-only/index.ts']);
|
|
155
|
-
expect((await byName('cli-only')).enabled).toBe(false);
|
|
156
|
-
await catalog.setEnabled(cwd, (await byName('cli-only')).id, true);
|
|
157
|
-
expect(settings().extensions).toEqual(['+extensions/cli-only/index.ts']);
|
|
158
|
-
expect((await byName('cli-only')).enabled).toBe(true);
|
|
159
|
-
|
|
160
|
-
// A package of the setting: a filter of its entry; its web extension follows.
|
|
161
|
-
await catalog.setEnabled(cwd, (await byName('pomodoro')).id, false);
|
|
162
|
-
expect(settings().packages).toEqual([{ source: join(home, 'pomodoro'), extensions: ['-index.ts'] }]);
|
|
163
|
-
expect((await catalog.list(cwd)).find(info => info.name === 'pomodoro')).toMatchObject({ enabled: false });
|
|
164
|
-
|
|
165
|
-
// Only a web extension: ta.json.
|
|
166
|
-
await catalog.setEnabled(cwd, (await byName('notes')).id, false);
|
|
167
|
-
expect(JSON.parse(readFileSync(join(home, 'agent/ta.json'), 'utf8')).disabledWeb).toEqual([join(home, 'agent/extensions/notes')]);
|
|
168
|
-
expect((await catalog.list(cwd)).find(info => info.name === 'notes')).toMatchObject({ enabled: false });
|
|
169
|
-
await catalog.setEnabled(cwd, (await byName('notes')).id, true);
|
|
170
|
-
expect((await byName('notes')).enabled).toBe(true);
|
|
171
|
-
});
|
|
172
|
-
});
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { rmSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { CODING_AGENT_OPTIONS, type CodingAgentOptions, type PiSdk, PiSdkUtil } from '@celljs/ai-coding-agent';
|
|
4
|
-
import { Autowired, Component, Value } from '@celljs/core';
|
|
5
|
-
import { TaBrand } from '@celljs/ta-harness/lib/node/ta-brand';
|
|
6
|
-
import { TaPackages } from '@celljs/ta-harness/lib/node/ta-packages';
|
|
7
|
-
import type { TaPackageInfo, TaSettingsScope, TaWebExtensionInfo, TaWebExtensionSource } from '@celljs/ta-protocol';
|
|
8
|
-
import { WebExtensionCatalog } from './host-protocol';
|
|
9
|
-
import { PackageSwitch } from './package-switch';
|
|
10
|
-
import { PiDirectories } from './remote/remote-protocol';
|
|
11
|
-
import { TaErrors } from './ta-errors';
|
|
12
|
-
import { type WebExtensionPackage, WebExtensionUtil } from './web-extension-util';
|
|
13
|
-
|
|
14
|
-
type PackageManager = InstanceType<PiSdk['DefaultPackageManager']>;
|
|
15
|
-
type SettingsManager = ReturnType<PiSdk['SettingsManager']['create']>;
|
|
16
|
-
|
|
17
|
-
interface Loaded {
|
|
18
|
-
packages: WebExtensionPackage[];
|
|
19
|
-
manager: PackageManager;
|
|
20
|
-
settings: SettingsManager;
|
|
21
|
-
trusted: boolean;
|
|
22
|
-
projectDir: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Finds packages, and their web extensions, where pi finds extensions: in the packages that come with ta, in the packages of
|
|
27
|
-
* its `packages` setting, and in the package directories of `extensions/`, of the user and, in a trusted
|
|
28
|
-
* project, of the project.
|
|
29
|
-
*/
|
|
30
|
-
@Component(WebExtensionCatalog)
|
|
31
|
-
export class WebExtensionCatalogImpl implements WebExtensionCatalog {
|
|
32
|
-
@Value(CODING_AGENT_OPTIONS)
|
|
33
|
-
protected readonly codingAgentOptions?: CodingAgentOptions;
|
|
34
|
-
|
|
35
|
-
@Autowired(PiDirectories)
|
|
36
|
-
protected readonly directories: PiDirectories;
|
|
37
|
-
|
|
38
|
-
async packages(cwd: string): Promise<TaPackageInfo[]> {
|
|
39
|
-
const { packages } = await this.load(cwd);
|
|
40
|
-
return packages.map(pkg => WebExtensionUtil.describePackage(pkg));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async install(cwd: string, source: string, scope: TaSettingsScope): Promise<void> {
|
|
44
|
-
const trimmed = typeof source === 'string' ? source.trim() : '';
|
|
45
|
-
if (!trimmed || /[\r\n]/.test(trimmed)) {
|
|
46
|
-
throw TaErrors.invalidArgument('A package needs a source of one line.', 'Pass npm:<name>, git:<repository>, a URL of a repository or a path.');
|
|
47
|
-
}
|
|
48
|
-
const { manager, trusted } = await this.load(cwd);
|
|
49
|
-
if (scope === 'project' && !trusted) {
|
|
50
|
-
throw TaErrors.invalidArgument(`The project ${cwd} is not trusted.`, 'Trust it first, or install the package for the user.');
|
|
51
|
-
}
|
|
52
|
-
await manager.installAndPersist(trimmed, { local: scope === 'project' });
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async removePackage(cwd: string, id: string): Promise<void> {
|
|
56
|
-
const { packages, manager } = await this.load(cwd);
|
|
57
|
-
const pkg = packages.find(candidate => WebExtensionUtil.describePackage(candidate).id === id);
|
|
58
|
-
if (!pkg) {
|
|
59
|
-
throw TaErrors.invalidArgument(`No package has the id ${id}.`, 'listPackages lists the ones there are; the package may have moved or gone.');
|
|
60
|
-
}
|
|
61
|
-
await this.removeRoot(pkg, manager);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
async list(cwd: string): Promise<TaWebExtensionInfo[]> {
|
|
65
|
-
const { packages } = await this.load(cwd);
|
|
66
|
-
return packages.flatMap(pkg => WebExtensionUtil.describe(pkg));
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async read(cwd: string, id: string): Promise<TaWebExtensionSource> {
|
|
70
|
-
const { pkg, info } = await this.find(cwd, id);
|
|
71
|
-
const code = WebExtensionUtil.read(pkg, info.entry);
|
|
72
|
-
return { id, hash: WebExtensionUtil.hash(code), code };
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
async remove(cwd: string, id: string): Promise<void> {
|
|
76
|
-
const { pkg } = await this.find(cwd, id);
|
|
77
|
-
await this.removeRoot(pkg, (await this.load(cwd)).manager);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
async setEnabled(cwd: string, nameOrId: string, enabled: boolean): Promise<void> {
|
|
81
|
-
if (TaPackages.builtins().some(pkg => pkg.name === nameOrId)) {
|
|
82
|
-
TaPackages.setEnabled(this.agentDir(), nameOrId, enabled);
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
const loaded = await this.load(cwd);
|
|
86
|
-
const pkg = loaded.packages.find(candidate => candidate.origin !== 'builtin' && WebExtensionUtil.describePackage(candidate).id === nameOrId);
|
|
87
|
-
if (!pkg) {
|
|
88
|
-
throw TaErrors.invalidArgument(
|
|
89
|
-
`${nameOrId} is neither a package that comes with Ta nor the id of a package.`,
|
|
90
|
-
'Pass the name of a built-in package, or an id of listPackages.',
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
const resources = PackageSwitch.resourcesOf(await this.resolve(loaded.manager), pkg.root);
|
|
94
|
-
if (resources.length === 0) {
|
|
95
|
-
// Only a web extension: pi has nothing of it to turn off.
|
|
96
|
-
TaPackages.setWebEnabled(this.agentDir(), pkg.root, enabled);
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
PackageSwitch.set(loaded.settings, resources, enabled, { agentDir: this.agentDir(), projectDir: loaded.projectDir });
|
|
100
|
-
await loaded.settings.flush();
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
protected async removeRoot(pkg: WebExtensionPackage, manager: PackageManager): Promise<void> {
|
|
104
|
-
if (pkg.origin === 'builtin') {
|
|
105
|
-
const { name } = WebExtensionUtil.describePackage(pkg);
|
|
106
|
-
throw TaErrors.invalidArgument(`${name} comes with Ta and cannot be removed.`, 'Turn it off with setPackageEnabled instead.');
|
|
107
|
-
}
|
|
108
|
-
if (pkg.origin === 'directory') {
|
|
109
|
-
rmSync(pkg.root, { recursive: true, force: true });
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
await manager.removeAndPersist(pkg.source, { local: pkg.scope === 'project' });
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
protected agentDir(): string {
|
|
116
|
-
return this.codingAgentOptions?.agentDir ?? TaBrand.agentDir();
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
protected async find(cwd: string, id: string): Promise<{ pkg: WebExtensionPackage; info: TaWebExtensionInfo }> {
|
|
120
|
-
const { packages } = await this.load(cwd);
|
|
121
|
-
for (const pkg of packages) {
|
|
122
|
-
const info = WebExtensionUtil.describe(pkg).find(candidate => candidate.id === id);
|
|
123
|
-
if (info) {
|
|
124
|
-
return { pkg, info };
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
throw TaErrors.invalidArgument(
|
|
128
|
-
`No package has the web extension ${id}.`,
|
|
129
|
-
'listWebExtensions lists the ones there are; the package may have moved or gone.',
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/** What pi loads now; a package not installed yet is left out, not installed. */
|
|
134
|
-
protected resolve(manager: PackageManager) {
|
|
135
|
-
return manager.resolve(async () => 'skip');
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
protected async load(location: string): Promise<Loaded> {
|
|
139
|
-
const cwd = this.directories.toPi(location);
|
|
140
|
-
const sdk = await PiSdkUtil.load();
|
|
141
|
-
const agentDir = this.codingAgentOptions?.agentDir ?? sdk.getAgentDir();
|
|
142
|
-
const trusted = new sdk.ProjectTrustStore(agentDir).get(cwd) ?? !sdk.hasTrustRequiringProjectResources(cwd);
|
|
143
|
-
const settingsManager = sdk.SettingsManager.create(cwd, agentDir, { projectTrusted: trusted });
|
|
144
|
-
const manager = new sdk.DefaultPackageManager({ cwd, agentDir, settingsManager });
|
|
145
|
-
const found = new Map<string, WebExtensionPackage>();
|
|
146
|
-
const off = TaPackages.disabled(agentDir);
|
|
147
|
-
for (const pkg of TaPackages.builtins()) {
|
|
148
|
-
found.set(pkg.root, { root: pkg.root, scope: 'user', origin: 'builtin', source: pkg.root, enabled: !off.has(pkg.name) });
|
|
149
|
-
}
|
|
150
|
-
for (const pkg of manager.listConfiguredPackages()) {
|
|
151
|
-
if (pkg.installedPath && (pkg.scope === 'user' || trusted) && !found.has(pkg.installedPath)) {
|
|
152
|
-
found.set(pkg.installedPath, { root: pkg.installedPath, scope: pkg.scope, origin: 'package', source: pkg.source });
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
const directories: [string, WebExtensionPackage['scope']][] = [[join(agentDir, 'extensions'), 'user']];
|
|
156
|
-
if (trusted) {
|
|
157
|
-
directories.push([join(cwd, sdk.CONFIG_DIR_NAME, 'extensions'), 'project']);
|
|
158
|
-
}
|
|
159
|
-
for (const [directory, scope] of directories) {
|
|
160
|
-
for (const root of WebExtensionUtil.packageDirectories(directory)) {
|
|
161
|
-
if (!found.has(root)) {
|
|
162
|
-
found.set(root, { root, scope, origin: 'directory', source: root });
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
// The others are on while pi loads any of theirs, or, with only a web extension, unless turned off in ta.json.
|
|
167
|
-
const resolved = await this.resolve(manager);
|
|
168
|
-
const webOff = TaPackages.disabledWeb(agentDir);
|
|
169
|
-
for (const pkg of found.values()) {
|
|
170
|
-
if (pkg.origin !== 'builtin') {
|
|
171
|
-
const resources = PackageSwitch.resourcesOf(resolved, pkg.root);
|
|
172
|
-
pkg.enabled = resources.length > 0 ? PackageSwitch.isEnabled(resources) : !webOff.has(pkg.root);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
return { packages: [...found.values()], manager, settings: settingsManager, trusted, projectDir: join(cwd, sdk.CONFIG_DIR_NAME) };
|
|
176
|
-
}
|
|
177
|
-
}
|