@celljs/ta-host 4.8.0 → 4.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +213 -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 +124 -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 +216 -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 +127 -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,235 +0,0 @@
|
|
|
1
|
-
import { dirname } from 'node:path';
|
|
2
|
-
import { Autowired, Component } from '@celljs/core';
|
|
3
|
-
import { type ExecEnvironment, ExecEnvironmentFactory } from '@celljs/ta-exec';
|
|
4
|
-
import type { TaCommandOutput, TaDirEntry, TaFileContent, TaRunCommandOptions } from '@celljs/ta-protocol';
|
|
5
|
-
import { TaErrors } from './ta-errors';
|
|
6
|
-
import { TaWorkspace } from './workspace-protocol';
|
|
7
|
-
import { MAX_FILE_BYTES, WorkspaceUtil } from './workspace-util';
|
|
8
|
-
|
|
9
|
-
/** The start of an output, up to `maxBytes`. */
|
|
10
|
-
class OutputBuffer {
|
|
11
|
-
protected readonly chunks: Uint8Array[] = [];
|
|
12
|
-
protected size = 0;
|
|
13
|
-
truncated = false;
|
|
14
|
-
|
|
15
|
-
constructor(protected readonly maxBytes: number) {}
|
|
16
|
-
|
|
17
|
-
add(data: Uint8Array): void {
|
|
18
|
-
if (this.size + data.length > this.maxBytes) {
|
|
19
|
-
this.truncated = true;
|
|
20
|
-
data = data.subarray(0, this.maxBytes - this.size);
|
|
21
|
-
}
|
|
22
|
-
if (data.length) {
|
|
23
|
-
this.chunks.push(data);
|
|
24
|
-
this.size += data.length;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
text(): string {
|
|
29
|
-
const decoder = new TextDecoder();
|
|
30
|
-
return this.chunks.map(chunk => decoder.decode(chunk, { stream: true })).join('') + decoder.decode();
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** What a command printed, cut at `maxBytes`. */
|
|
35
|
-
interface Output {
|
|
36
|
-
exitCode: number | null;
|
|
37
|
-
text: string;
|
|
38
|
-
bytes: Uint8Array;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const MAX_LIST_BYTES = 16 * 1024 * 1024;
|
|
42
|
-
const MAX_RUN_BYTES = 8 * 1024 * 1024;
|
|
43
|
-
const DEFAULT_RUN_TIMEOUT_MS = 30000;
|
|
44
|
-
const MAX_RUN_TIMEOUT_MS = 120000;
|
|
45
|
-
const COMMAND_TIMEOUT_MS = 30000;
|
|
46
|
-
const DEFAULT_FIND_LIMIT = 50;
|
|
47
|
-
/** Directories that `find` skips when there is neither git nor ripgrep to read .gitignore. */
|
|
48
|
-
const SKIPPED_DIRECTORIES = ['.git', 'node_modules'];
|
|
49
|
-
|
|
50
|
-
/** Runs each method with the files and programs of the environment of `cwd`. */
|
|
51
|
-
@Component(TaWorkspace)
|
|
52
|
-
export class DefaultTaWorkspace implements TaWorkspace {
|
|
53
|
-
@Autowired(ExecEnvironmentFactory)
|
|
54
|
-
protected readonly environments: ExecEnvironmentFactory;
|
|
55
|
-
|
|
56
|
-
/** Whether ripgrep is there; the same for all directories of one environment. */
|
|
57
|
-
protected ripgrep?: Promise<boolean>;
|
|
58
|
-
|
|
59
|
-
async listDirectory(cwd: string, path: string): Promise<TaDirEntry[]> {
|
|
60
|
-
const env = this.environments.create(cwd);
|
|
61
|
-
const target = WorkspaceUtil.inside(env.cwd, path);
|
|
62
|
-
const stat = await env.stat(target.absolute);
|
|
63
|
-
if (!stat?.isDirectory) {
|
|
64
|
-
throw TaErrors.invalidArgument(`${path} is not a directory.`, 'Pass the path of a directory inside the workspace.');
|
|
65
|
-
}
|
|
66
|
-
const entries = (await env.readdir(target.absolute)).filter(entry => entry.name !== '.git');
|
|
67
|
-
const listed = await Promise.all(
|
|
68
|
-
entries.map(async (entry): Promise<TaDirEntry> => {
|
|
69
|
-
const entryPath = WorkspaceUtil.join(target.relative, entry.name);
|
|
70
|
-
if (entry.isDirectory) {
|
|
71
|
-
return { name: entry.name, path: entryPath, kind: 'directory' };
|
|
72
|
-
}
|
|
73
|
-
// A link to a directory reads as a file here; stat follows it.
|
|
74
|
-
const info = await env.stat(WorkspaceUtil.join(target.absolute, entry.name)).catch(() => undefined);
|
|
75
|
-
return info?.isDirectory
|
|
76
|
-
? { name: entry.name, path: entryPath, kind: 'directory' }
|
|
77
|
-
: { name: entry.name, path: entryPath, kind: 'file', size: info?.size };
|
|
78
|
-
}),
|
|
79
|
-
);
|
|
80
|
-
return WorkspaceUtil.sortEntries(listed);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
async readFile(cwd: string, path: string): Promise<TaFileContent> {
|
|
84
|
-
const env = this.environments.create(cwd);
|
|
85
|
-
const target = WorkspaceUtil.inside(env.cwd, path);
|
|
86
|
-
const stat = await env.stat(target.absolute);
|
|
87
|
-
if (!stat || stat.isDirectory) {
|
|
88
|
-
throw TaErrors.invalidArgument(`${path} is not a file.`, 'Pass the path of a file inside the workspace.');
|
|
89
|
-
}
|
|
90
|
-
const truncated = stat.size > MAX_FILE_BYTES;
|
|
91
|
-
// A large file: only its start crosses, not the whole of it.
|
|
92
|
-
const bytes = truncated
|
|
93
|
-
? (await this.run(env, `head -c ${MAX_FILE_BYTES} -- ${WorkspaceUtil.quote(target.absolute)}`, MAX_FILE_BYTES)).bytes
|
|
94
|
-
: await env.readFile(target.absolute);
|
|
95
|
-
const content: TaFileContent = { path: target.relative, size: stat.size, binary: WorkspaceUtil.isBinary(bytes), truncated };
|
|
96
|
-
if (!content.binary) {
|
|
97
|
-
content.text = new TextDecoder().decode(bytes);
|
|
98
|
-
}
|
|
99
|
-
return content;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
async writeFile(cwd: string, path: string, text: string): Promise<void> {
|
|
103
|
-
const env = this.environments.create(cwd);
|
|
104
|
-
const target = WorkspaceUtil.inside(env.cwd, path);
|
|
105
|
-
const [stat, parent] = await Promise.all([env.stat(target.absolute), env.stat(dirname(target.absolute))]);
|
|
106
|
-
if (stat?.isDirectory || !parent?.isDirectory) {
|
|
107
|
-
throw TaErrors.invalidArgument(
|
|
108
|
-
`${path} cannot be written: it is a directory, or its directory is missing.`,
|
|
109
|
-
'Pass the path of a file inside an existing directory of the workspace.',
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
await env.writeFile(target.absolute, text);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
async uploadFile(cwd: string, path: string, data: Uint8Array, append: boolean): Promise<void> {
|
|
116
|
-
const env = this.environments.create(cwd);
|
|
117
|
-
const target = WorkspaceUtil.inside(env.cwd, path);
|
|
118
|
-
if (!target.relative || (await env.stat(target.absolute))?.isDirectory) {
|
|
119
|
-
throw TaErrors.invalidArgument(`${path || '.'} is a directory.`, 'Pass the path of a file inside the workspace.');
|
|
120
|
-
}
|
|
121
|
-
if (!append) {
|
|
122
|
-
await env.mkdir(dirname(target.absolute));
|
|
123
|
-
}
|
|
124
|
-
await env.writeFile(target.absolute, data, { append });
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
async findFiles(cwd: string, query: string, limit = DEFAULT_FIND_LIMIT): Promise<string[]> {
|
|
128
|
-
const env = this.environments.create(cwd);
|
|
129
|
-
return WorkspaceUtil.fuzzyFind(await this.listFiles(env), query, Math.max(1, limit));
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Without a shell: the program gets its arguments as they are. `/bin/sh` only closes the standard
|
|
134
|
-
* input (or feeds it `input`) and then becomes the program, so that a timeout kills the program.
|
|
135
|
-
*/
|
|
136
|
-
async runCommand(cwd: string, command: string, args: string[], options: TaRunCommandOptions = {}): Promise<TaCommandOutput> {
|
|
137
|
-
if (!command) {
|
|
138
|
-
throw TaErrors.invalidArgument('No program to run.', 'Pass the name or the path of a program, as git or rg.');
|
|
139
|
-
}
|
|
140
|
-
const env = this.environments.create(cwd);
|
|
141
|
-
const timeout = WorkspaceUtil.clamp(options.timeoutMs, DEFAULT_RUN_TIMEOUT_MS, MAX_RUN_TIMEOUT_MS);
|
|
142
|
-
const maxBytes = WorkspaceUtil.clamp(options.maxBytes, MAX_FILE_BYTES, MAX_RUN_BYTES);
|
|
143
|
-
const posix = !(env.local && process.platform === 'win32');
|
|
144
|
-
const input = options.input !== undefined;
|
|
145
|
-
const child = posix
|
|
146
|
-
? env.spawn('/bin/sh', ['-c', input ? 'printf %s "$TA_RUN_INPUT" | exec "$0" "$@"' : 'exec "$0" "$@" </dev/null', command, ...args], {
|
|
147
|
-
env: input ? { ...process.env, TA_RUN_INPUT: options.input } : undefined,
|
|
148
|
-
})
|
|
149
|
-
: env.spawn(command, args);
|
|
150
|
-
const stdout = new OutputBuffer(maxBytes);
|
|
151
|
-
const stderr = new OutputBuffer(maxBytes);
|
|
152
|
-
child.onStdout(data => stdout.add(data));
|
|
153
|
-
child.onStderr(data => stderr.add(data));
|
|
154
|
-
if (options.input !== undefined && !posix) {
|
|
155
|
-
child.write(options.input);
|
|
156
|
-
}
|
|
157
|
-
let timedOut = false;
|
|
158
|
-
const exitCode = await new Promise<number | null>(done => {
|
|
159
|
-
const timer = setTimeout(() => {
|
|
160
|
-
timedOut = true;
|
|
161
|
-
child.kill();
|
|
162
|
-
}, timeout);
|
|
163
|
-
child.onExit(code => {
|
|
164
|
-
clearTimeout(timer);
|
|
165
|
-
done(code);
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
return {
|
|
169
|
-
stdout: stdout.text(),
|
|
170
|
-
stderr: stderr.text(),
|
|
171
|
-
exitCode: timedOut ? null : exitCode,
|
|
172
|
-
truncated: stdout.truncated || stderr.truncated,
|
|
173
|
-
timedOut,
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/** The files of the directory: git's, ripgrep's, or all but SKIPPED_DIRECTORIES. */
|
|
178
|
-
protected async listFiles(env: ExecEnvironment): Promise<string[]> {
|
|
179
|
-
let command: string;
|
|
180
|
-
if (await this.inRepository(env)) {
|
|
181
|
-
command = 'git -c core.quotepath=off ls-files -co --exclude-standard';
|
|
182
|
-
} else if (await this.hasRipgrep(env)) {
|
|
183
|
-
command = 'rg --files --color never';
|
|
184
|
-
} else {
|
|
185
|
-
const skip = SKIPPED_DIRECTORIES.map(dir => `-name ${dir} -prune`).join(' -o ');
|
|
186
|
-
command = `find . \\( ${skip} \\) -o -type f -print`;
|
|
187
|
-
}
|
|
188
|
-
const { text } = await this.run(env, command, MAX_LIST_BYTES);
|
|
189
|
-
return text
|
|
190
|
-
.split('\n')
|
|
191
|
-
.map(line => line.replace(/^\.\//, ''))
|
|
192
|
-
.filter(Boolean);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
protected async inRepository(env: ExecEnvironment): Promise<boolean> {
|
|
196
|
-
return (await this.run(env, 'git rev-parse --is-inside-work-tree', 4096)).text.trim() === 'true';
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
protected hasRipgrep(env: ExecEnvironment): Promise<boolean> {
|
|
200
|
-
this.ripgrep ??= this.run(env, 'command -v rg', 4096).then(
|
|
201
|
-
result => result.exitCode === 0,
|
|
202
|
-
() => false,
|
|
203
|
-
);
|
|
204
|
-
return this.ripgrep;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/** Only what it prints on stdout; stops the command once it printed `maxBytes`: what came is enough. */
|
|
208
|
-
protected async run(env: ExecEnvironment, command: string, maxBytes: number): Promise<Output> {
|
|
209
|
-
const chunks: Uint8Array[] = [];
|
|
210
|
-
let size = 0;
|
|
211
|
-
const abort = new AbortController();
|
|
212
|
-
const { exitCode } = await env.exec(`${command} 2>/dev/null`, {
|
|
213
|
-
timeout: COMMAND_TIMEOUT_MS,
|
|
214
|
-
signal: abort.signal,
|
|
215
|
-
onData: data => {
|
|
216
|
-
if (size >= maxBytes) {
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
const piece = data.subarray(0, maxBytes - size);
|
|
220
|
-
chunks.push(piece);
|
|
221
|
-
size += piece.length;
|
|
222
|
-
if (size >= maxBytes) {
|
|
223
|
-
abort.abort();
|
|
224
|
-
}
|
|
225
|
-
},
|
|
226
|
-
});
|
|
227
|
-
const bytes = new Uint8Array(size);
|
|
228
|
-
let offset = 0;
|
|
229
|
-
for (const chunk of chunks) {
|
|
230
|
-
bytes.set(chunk, offset);
|
|
231
|
-
offset += chunk.length;
|
|
232
|
-
}
|
|
233
|
-
return { exitCode, bytes, text: new TextDecoder().decode(bytes) };
|
|
234
|
-
}
|
|
235
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'bun:test';
|
|
2
|
-
import { WorkspaceUtil } from './workspace-util';
|
|
3
|
-
|
|
4
|
-
describe('WorkspaceUtil', () => {
|
|
5
|
-
it('keeps paths inside the directory', () => {
|
|
6
|
-
expect(WorkspaceUtil.inside('/w', 'src/a.ts')).toEqual({ absolute: '/w/src/a.ts', relative: 'src/a.ts' });
|
|
7
|
-
expect(WorkspaceUtil.inside('/w', '')).toEqual({ absolute: '/w', relative: '' });
|
|
8
|
-
expect(WorkspaceUtil.inside('/w', 'a/../b')).toEqual({ absolute: '/w/b', relative: 'b' });
|
|
9
|
-
expect(WorkspaceUtil.inside('/w', '..foo').relative).toBe('..foo');
|
|
10
|
-
expect(() => WorkspaceUtil.inside('/w', '../x')).toThrow('outside');
|
|
11
|
-
expect(() => WorkspaceUtil.inside('/w', '/etc/passwd')).toThrow('outside');
|
|
12
|
-
expect(() => WorkspaceUtil.inside('/w', 'a/../../x')).toThrow('outside');
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('sorts directories first, then names as people do', () => {
|
|
16
|
-
const sorted = WorkspaceUtil.sortEntries([
|
|
17
|
-
{ name: 'file10', path: 'file10', kind: 'file' },
|
|
18
|
-
{ name: 'src', path: 'src', kind: 'directory' },
|
|
19
|
-
{ name: 'File2', path: 'File2', kind: 'file' },
|
|
20
|
-
{ name: 'a', path: 'a', kind: 'directory' },
|
|
21
|
-
]);
|
|
22
|
-
expect(sorted.map(entry => entry.name)).toEqual(['a', 'src', 'File2', 'file10']);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('tells binary from text', () => {
|
|
26
|
-
expect(WorkspaceUtil.isBinary(new TextEncoder().encode('hello'))).toBe(false);
|
|
27
|
-
expect(WorkspaceUtil.isBinary(new Uint8Array([0x89, 0x50, 0x00, 0x47]))).toBe(true);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('finds files loosely, the name before the directories', () => {
|
|
31
|
-
const paths = ['src/browser/app-view.tsx', 'src/node/view.ts', 'docs/overview.md', 'README.md'];
|
|
32
|
-
expect(WorkspaceUtil.fuzzyFind(paths, 'view', 10)).toEqual(['src/node/view.ts', 'src/browser/app-view.tsx', 'docs/overview.md']);
|
|
33
|
-
expect(WorkspaceUtil.fuzzyFind(paths, 'apvw', 10)).toEqual(['src/browser/app-view.tsx']);
|
|
34
|
-
expect(WorkspaceUtil.fuzzyFind(paths, 'zzz', 10)).toEqual([]);
|
|
35
|
-
expect(WorkspaceUtil.fuzzyFind(paths, '', 2)).toHaveLength(2);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('keeps limits within bounds', () => {
|
|
39
|
-
expect(WorkspaceUtil.clamp(undefined, 30, 120)).toBe(30);
|
|
40
|
-
expect(WorkspaceUtil.clamp(500, 30, 120)).toBe(120);
|
|
41
|
-
expect(WorkspaceUtil.clamp(-1, 30, 120)).toBe(1);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('quotes for the shell', () => {
|
|
45
|
-
expect(WorkspaceUtil.quote("it's")).toBe("'it'\\''s'");
|
|
46
|
-
});
|
|
47
|
-
});
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { isAbsolute, posix, relative, resolve, sep } from 'node:path';
|
|
2
|
-
import type { TaDirEntry } from '@celljs/ta-protocol';
|
|
3
|
-
import { TaErrors } from './ta-errors';
|
|
4
|
-
|
|
5
|
-
/** The largest file readFile returns whole. */
|
|
6
|
-
export const MAX_FILE_BYTES = 1024 * 1024;
|
|
7
|
-
const BINARY_PROBE_BYTES = 8000;
|
|
8
|
-
|
|
9
|
-
/** The pure parts of the workspace methods of ta serve: paths, sorting and matching names. */
|
|
10
|
-
export namespace WorkspaceUtil {
|
|
11
|
-
/** `path` inside `cwd`, absolute, and relative with `/`; throws when it leaves `cwd`. */
|
|
12
|
-
export function inside(cwd: string, path: string): { absolute: string; relative: string } {
|
|
13
|
-
const absolute = resolve(cwd, path || '.');
|
|
14
|
-
const rel = relative(cwd, absolute);
|
|
15
|
-
if (rel === '..' || rel.startsWith(`..${sep}`) || isAbsolute(rel)) {
|
|
16
|
-
throw TaErrors.invalidArgument(`The path ${path} is outside of ${cwd}.`, 'Pass a path inside the directory of the workspace.');
|
|
17
|
-
}
|
|
18
|
-
return { absolute, relative: rel.split(sep).join('/') };
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** Joins a relative path of a directory with a name, with `/`. */
|
|
22
|
-
export function join(dir: string, name: string): string {
|
|
23
|
-
return dir && dir !== '.' ? posix.join(dir, name) : name;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** Directories first, then by name as people sort (`file2` before `file10`). */
|
|
27
|
-
export function sortEntries(entries: TaDirEntry[]): TaDirEntry[] {
|
|
28
|
-
return [...entries].sort((a, b) => (a.kind === b.kind ? compareNames(a.name, b.name) : a.kind === 'directory' ? -1 : 1));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function compareNames(a: string, b: string): number {
|
|
32
|
-
return a.localeCompare(b, undefined, { numeric: true, sensitivity: 'base' }) || (a < b ? -1 : a > b ? 1 : 0);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** A NUL in the first bytes: not text. */
|
|
36
|
-
export function isBinary(bytes: Uint8Array): boolean {
|
|
37
|
-
const end = Math.min(bytes.length, BINARY_PROBE_BYTES);
|
|
38
|
-
for (let i = 0; i < end; i++) {
|
|
39
|
-
if (bytes[i] === 0) {
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* How well `path` matches `query` loosely: its characters in order, best when they start words of
|
|
48
|
-
* the file name; undefined when it does not match. Higher is better.
|
|
49
|
-
*/
|
|
50
|
-
export function fuzzyScore(path: string, query: string): number | undefined {
|
|
51
|
-
const q = query.replace(/\s+/g, '').toLowerCase();
|
|
52
|
-
if (!q) {
|
|
53
|
-
return 0;
|
|
54
|
-
}
|
|
55
|
-
const lower = path.toLowerCase();
|
|
56
|
-
const nameStart = lower.lastIndexOf('/') + 1;
|
|
57
|
-
let score = 0;
|
|
58
|
-
let from = 0;
|
|
59
|
-
let previous = -2;
|
|
60
|
-
for (const char of q) {
|
|
61
|
-
const index = lower.indexOf(char, from);
|
|
62
|
-
if (index < 0) {
|
|
63
|
-
return undefined;
|
|
64
|
-
}
|
|
65
|
-
const boundary = index === 0 || '/._- '.includes(lower[index - 1]) || (path[index] !== lower[index] && path[index - 1] === lower[index - 1]);
|
|
66
|
-
score += 1 + (index === previous + 1 ? 3 : 0) + (boundary ? 2 : 0) + (index >= nameStart ? 2 : 0);
|
|
67
|
-
previous = index;
|
|
68
|
-
from = index + 1;
|
|
69
|
-
}
|
|
70
|
-
const name = lower.slice(nameStart);
|
|
71
|
-
if (name.startsWith(q)) {
|
|
72
|
-
score += 10;
|
|
73
|
-
} else if (name.includes(q)) {
|
|
74
|
-
score += 5;
|
|
75
|
-
}
|
|
76
|
-
return score - path.length / 100;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/** The paths that match, best first. */
|
|
80
|
-
export function fuzzyFind(paths: string[], query: string, limit: number): string[] {
|
|
81
|
-
const scored: { path: string; score: number }[] = [];
|
|
82
|
-
for (const path of paths) {
|
|
83
|
-
const score = fuzzyScore(path, query);
|
|
84
|
-
if (score !== undefined) {
|
|
85
|
-
scored.push({ path, score });
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return scored
|
|
89
|
-
.sort((a, b) => b.score - a.score || compareNames(a.path, b.path))
|
|
90
|
-
.slice(0, limit)
|
|
91
|
-
.map(({ path }) => path);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/** A limit a caller asked for, within what the server allows. */
|
|
95
|
-
export function clamp(value: number | undefined, fallback: number, max: number): number {
|
|
96
|
-
return value === undefined || !Number.isFinite(value) ? fallback : Math.min(max, Math.max(1, Math.floor(value)));
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/** One argument for `/bin/sh`. */
|
|
100
|
-
export function quote(value: string): string {
|
|
101
|
-
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
102
|
-
}
|
|
103
|
-
}
|