@halonicjs/testing 0.0.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +41 -1
- package/dist/adapters/http-kit/src/address-checking.d.ts +19 -0
- package/dist/adapters/http-kit/src/address-checking.js +1 -0
- package/dist/adapters/http-kit/src/address-class.d.ts +34 -0
- package/dist/adapters/http-kit/src/address-class.js +109 -0
- package/dist/adapters/http-kit/src/index.d.ts +3 -0
- package/dist/adapters/http-kit/src/index.js +2 -0
- package/dist/adapters/http-kit/src/ip-address.d.ts +23 -0
- package/dist/adapters/http-kit/src/ip-address.js +89 -0
- package/dist/adapters/integration-kit/src/auth-placement.d.ts +40 -0
- package/dist/adapters/integration-kit/src/auth-placement.js +102 -0
- package/dist/adapters/integration-kit/src/current-secret-forms.d.ts +28 -0
- package/dist/adapters/integration-kit/src/current-secret-forms.js +60 -0
- package/dist/adapters/integration-kit/src/declaration.d.ts +15 -0
- package/dist/adapters/integration-kit/src/declaration.js +78 -0
- package/dist/adapters/integration-kit/src/host.d.ts +34 -0
- package/dist/adapters/integration-kit/src/host.js +31 -0
- package/dist/adapters/integration-kit/src/index.d.ts +16 -0
- package/dist/adapters/integration-kit/src/index.js +22 -0
- package/dist/adapters/integration-kit/src/leak-attempt.d.ts +16 -0
- package/dist/adapters/integration-kit/src/leak-attempt.js +19 -0
- package/dist/adapters/integration-kit/src/limited-http.d.ts +55 -0
- package/dist/adapters/integration-kit/src/limited-http.js +225 -0
- package/dist/adapters/integration-kit/src/load-problem.d.ts +20 -0
- package/dist/adapters/integration-kit/src/load-problem.js +1 -0
- package/dist/adapters/integration-kit/src/loader.d.ts +131 -0
- package/dist/adapters/integration-kit/src/loader.js +251 -0
- package/dist/adapters/integration-kit/src/local-address.d.ts +15 -0
- package/dist/adapters/integration-kit/src/local-address.js +25 -0
- package/dist/adapters/integration-kit/src/own-request.d.ts +33 -0
- package/dist/adapters/integration-kit/src/own-request.js +36 -0
- package/dist/adapters/integration-kit/src/plugin-load.d.ts +14 -0
- package/dist/adapters/integration-kit/src/plugin-load.js +58 -0
- package/dist/adapters/integration-kit/src/policy.d.ts +83 -0
- package/dist/adapters/integration-kit/src/policy.js +37 -0
- package/dist/adapters/integration-kit/src/request-body.d.ts +38 -0
- package/dist/adapters/integration-kit/src/request-body.js +68 -0
- package/dist/adapters/integration-kit/src/request-log.d.ts +25 -0
- package/dist/adapters/integration-kit/src/request-log.js +17 -0
- package/dist/adapters/integration-kit/src/response-body.d.ts +27 -0
- package/dist/adapters/integration-kit/src/response-body.js +117 -0
- package/dist/adapters/integration-kit/src/scoped-tokens.d.ts +14 -0
- package/dist/adapters/integration-kit/src/scoped-tokens.js +27 -0
- package/dist/adapters/integration-kit/src/secret-filter.d.ts +84 -0
- package/dist/adapters/integration-kit/src/secret-filter.js +220 -0
- package/dist/adapters/integration-kit/src/secret-in-request.d.ts +62 -0
- package/dist/adapters/integration-kit/src/secret-in-request.js +139 -0
- package/dist/adapters/integration-kit/src/secret-placement.d.ts +46 -0
- package/dist/adapters/integration-kit/src/secret-placement.js +160 -0
- package/dist/adapters/integration-kit/src/sign-in-placement.d.ts +29 -0
- package/dist/adapters/integration-kit/src/sign-in-placement.js +92 -0
- package/dist/adapters/integration-kit/src/wait.d.ts +16 -0
- package/dist/adapters/integration-kit/src/wait.js +35 -0
- package/dist/core/events/src/add-usage.d.ts +10 -0
- package/dist/core/events/src/add-usage.js +27 -0
- package/dist/core/events/src/agent-resume.d.ts +24 -0
- package/dist/core/events/src/agent-resume.js +1 -0
- package/dist/core/events/src/blocked-sites.d.ts +57 -0
- package/dist/core/events/src/blocked-sites.js +89 -0
- package/dist/core/events/src/home-path.d.ts +13 -0
- package/dist/core/events/src/home-path.js +26 -0
- package/dist/core/events/src/index.d.ts +17 -0
- package/dist/core/events/src/index.js +10 -0
- package/dist/core/events/src/run-basics.d.ts +228 -0
- package/dist/core/events/src/run-basics.js +1 -0
- package/dist/core/events/src/run-event.d.ts +478 -0
- package/dist/core/events/src/run-event.js +1 -0
- package/dist/core/events/src/run-reads.d.ts +25 -0
- package/dist/core/events/src/run-reads.js +44 -0
- package/dist/core/events/src/run-sends.d.ts +47 -0
- package/dist/core/events/src/run-sends.js +68 -0
- package/dist/core/events/src/run-summary.d.ts +108 -0
- package/dist/core/events/src/run-summary.js +1 -0
- package/dist/core/events/src/sandbox-blocked.d.ts +42 -0
- package/dist/core/events/src/sandbox-blocked.js +26 -0
- package/dist/core/events/src/sandbox-opened-read.d.ts +17 -0
- package/dist/core/events/src/sandbox-opened-read.js +63 -0
- package/dist/core/events/src/sandbox-opened.d.ts +94 -0
- package/dist/core/events/src/sandbox-opened.js +52 -0
- package/dist/core/events/src/summarize.d.ts +14 -0
- package/dist/core/events/src/summarize.js +192 -0
- package/dist/core/events/src/timeline-entry.d.ts +21 -0
- package/dist/core/events/src/timeline-entry.js +106 -0
- package/dist/core/events/src/upgrade.d.ts +23 -0
- package/dist/core/events/src/upgrade.js +49 -0
- package/dist/core/format/src/compact.d.ts +30 -0
- package/dist/core/format/src/compact.js +72 -0
- package/dist/core/format/src/index.d.ts +39 -0
- package/dist/core/format/src/index.js +25 -0
- package/dist/core/format/src/integration/index.d.ts +7 -0
- package/dist/core/format/src/integration/index.js +10 -0
- package/dist/core/format/src/json-schema.d.ts +26 -0
- package/dist/core/format/src/json-schema.js +48 -0
- package/dist/core/format/src/kind.d.ts +65 -0
- package/dist/core/format/src/kind.js +1 -0
- package/dist/core/format/src/kinds/agent/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/agent/kind.js +10 -0
- package/dist/core/format/src/kinds/agent/sandbox-fields.d.ts +99 -0
- package/dist/core/format/src/kinds/agent/sandbox-fields.js +216 -0
- package/dist/core/format/src/kinds/agent/schema.d.ts +147 -0
- package/dist/core/format/src/kinds/agent/schema.js +107 -0
- package/dist/core/format/src/kinds/agent/working-folder-start.d.ts +74 -0
- package/dist/core/format/src/kinds/agent/working-folder-start.js +312 -0
- package/dist/core/format/src/kinds/collection/kind.d.ts +8 -0
- package/dist/core/format/src/kinds/collection/kind.js +14 -0
- package/dist/core/format/src/kinds/collection/schema.d.ts +89 -0
- package/dist/core/format/src/kinds/collection/schema.js +90 -0
- package/dist/core/format/src/kinds/connector/is-local.d.ts +10 -0
- package/dist/core/format/src/kinds/connector/is-local.js +43 -0
- package/dist/core/format/src/kinds/connector/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/connector/kind.js +218 -0
- package/dist/core/format/src/kinds/connector/schema.d.ts +74 -0
- package/dist/core/format/src/kinds/connector/schema.js +143 -0
- package/dist/core/format/src/kinds/deployments/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/deployments/kind.js +49 -0
- package/dist/core/format/src/kinds/deployments/schema.d.ts +77 -0
- package/dist/core/format/src/kinds/deployments/schema.js +94 -0
- package/dist/core/format/src/kinds/hub/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/hub/kind.js +10 -0
- package/dist/core/format/src/kinds/hub/schema.d.ts +54 -0
- package/dist/core/format/src/kinds/hub/schema.js +34 -0
- package/dist/core/format/src/kinds/integration/approved-sign-ins.d.ts +62 -0
- package/dist/core/format/src/kinds/integration/approved-sign-ins.js +125 -0
- package/dist/core/format/src/kinds/integration/host-key.d.ts +7 -0
- package/dist/core/format/src/kinds/integration/host-key.js +8 -0
- package/dist/core/format/src/kinds/integration/kind.d.ts +18 -0
- package/dist/core/format/src/kinds/integration/kind.js +175 -0
- package/dist/core/format/src/kinds/integration/parse-sheet.d.ts +19 -0
- package/dist/core/format/src/kinds/integration/parse-sheet.js +24 -0
- package/dist/core/format/src/kinds/integration/policy.d.ts +112 -0
- package/dist/core/format/src/kinds/integration/policy.js +327 -0
- package/dist/core/format/src/kinds/integration/schema.d.ts +410 -0
- package/dist/core/format/src/kinds/integration/schema.js +359 -0
- package/dist/core/format/src/kinds/integration/sign-in-checks.d.ts +13 -0
- package/dist/core/format/src/kinds/integration/sign-in-checks.js +120 -0
- package/dist/core/format/src/kinds/integration/sign-in-urls.d.ts +19 -0
- package/dist/core/format/src/kinds/integration/sign-in-urls.js +47 -0
- package/dist/core/format/src/kinds/knowledge/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/knowledge/kind.js +13 -0
- package/dist/core/format/src/kinds/knowledge/schema.d.ts +18 -0
- package/dist/core/format/src/kinds/knowledge/schema.js +25 -0
- package/dist/core/format/src/kinds/models/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/models/kind.js +10 -0
- package/dist/core/format/src/kinds/models/schema.d.ts +92 -0
- package/dist/core/format/src/kinds/models/schema.js +38 -0
- package/dist/core/format/src/kinds/plugin/backend.d.ts +22 -0
- package/dist/core/format/src/kinds/plugin/backend.js +31 -0
- package/dist/core/format/src/kinds/plugin/checks.d.ts +13 -0
- package/dist/core/format/src/kinds/plugin/checks.js +137 -0
- package/dist/core/format/src/kinds/plugin/kind.d.ts +8 -0
- package/dist/core/format/src/kinds/plugin/kind.js +16 -0
- package/dist/core/format/src/kinds/plugin/problems.d.ts +24 -0
- package/dist/core/format/src/kinds/plugin/problems.js +65 -0
- package/dist/core/format/src/kinds/plugin/schema.d.ts +672 -0
- package/dist/core/format/src/kinds/plugin/schema.js +261 -0
- package/dist/core/format/src/kinds/plugin/setting-values.d.ts +17 -0
- package/dist/core/format/src/kinds/plugin/setting-values.js +38 -0
- package/dist/core/format/src/kinds/plugin/ui-checks.d.ts +8 -0
- package/dist/core/format/src/kinds/plugin/ui-checks.js +85 -0
- package/dist/core/format/src/kinds/provider/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/provider/kind.js +24 -0
- package/dist/core/format/src/kinds/provider/schema.d.ts +17 -0
- package/dist/core/format/src/kinds/provider/schema.js +22 -0
- package/dist/core/format/src/kinds/routine/kind.d.ts +8 -0
- package/dist/core/format/src/kinds/routine/kind.js +62 -0
- package/dist/core/format/src/kinds/routine/schema.d.ts +94 -0
- package/dist/core/format/src/kinds/routine/schema.js +115 -0
- package/dist/core/format/src/kinds/routine/webhook-headers.d.ts +9 -0
- package/dist/core/format/src/kinds/routine/webhook-headers.js +26 -0
- package/dist/core/format/src/kinds/runtime/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/runtime/kind.js +13 -0
- package/dist/core/format/src/kinds/runtime/schema.d.ts +10 -0
- package/dist/core/format/src/kinds/runtime/schema.js +12 -0
- package/dist/core/format/src/kinds/skill/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/skill/kind.js +10 -0
- package/dist/core/format/src/kinds/skill/schema.d.ts +17 -0
- package/dist/core/format/src/kinds/skill/schema.js +17 -0
- package/dist/core/format/src/kinds/skill/scripts-folder.d.ts +27 -0
- package/dist/core/format/src/kinds/skill/scripts-folder.js +37 -0
- package/dist/core/format/src/kinds/workflow/kind.d.ts +8 -0
- package/dist/core/format/src/kinds/workflow/kind.js +14 -0
- package/dist/core/format/src/kinds/workflow/schema.d.ts +162 -0
- package/dist/core/format/src/kinds/workflow/schema.js +106 -0
- package/dist/core/format/src/kinds/workflow-test/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/workflow-test/kind.js +14 -0
- package/dist/core/format/src/kinds/workflow-test/schema.d.ts +67 -0
- package/dist/core/format/src/kinds/workflow-test/schema.js +59 -0
- package/dist/core/format/src/kinds/workspace/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/workspace/kind.js +10 -0
- package/dist/core/format/src/kinds/workspace/schema.d.ts +72 -0
- package/dist/core/format/src/kinds/workspace/schema.js +66 -0
- package/dist/core/format/src/parse-file.d.ts +69 -0
- package/dist/core/format/src/parse-file.js +105 -0
- package/dist/core/format/src/recording/format.d.ts +81 -0
- package/dist/core/format/src/recording/format.js +102 -0
- package/dist/core/format/src/recording/index.d.ts +1 -0
- package/dist/core/format/src/recording/index.js +3 -0
- package/dist/core/format/src/registry.d.ts +64 -0
- package/dist/core/format/src/registry.js +61 -0
- package/dist/core/format/src/reserved.d.ts +20 -0
- package/dist/core/format/src/reserved.js +30 -0
- package/dist/core/format/src/shared/fields.d.ts +34 -0
- package/dist/core/format/src/shared/fields.js +74 -0
- package/dist/core/format/src/shared/guard.d.ts +32 -0
- package/dist/core/format/src/shared/guard.js +16 -0
- package/dist/core/format/src/shared/key-in-value.d.ts +28 -0
- package/dist/core/format/src/shared/key-in-value.js +82 -0
- package/dist/core/format/src/shared/legacy-keys.d.ts +8 -0
- package/dist/core/format/src/shared/legacy-keys.js +17 -0
- package/dist/core/format/src/shared/program-start.d.ts +60 -0
- package/dist/core/format/src/shared/program-start.js +99 -0
- package/dist/core/format/src/shared/relative-path.d.ts +29 -0
- package/dist/core/format/src/shared/relative-path.js +50 -0
- package/dist/core/format/src/shared/secret-name.d.ts +24 -0
- package/dist/core/format/src/shared/secret-name.js +107 -0
- package/dist/core/format/src/source.d.ts +16 -0
- package/dist/core/format/src/source.js +73 -0
- package/dist/core/ports/src/agent-placement-store.d.ts +74 -0
- package/dist/core/ports/src/agent-placement-store.js +27 -0
- package/dist/core/ports/src/agent-runs-not-available.d.ts +21 -0
- package/dist/core/ports/src/agent-runs-not-available.js +25 -0
- package/dist/core/ports/src/blob-store.d.ts +45 -0
- package/dist/core/ports/src/blob-store.js +24 -0
- package/dist/core/ports/src/cant-try-error.d.ts +35 -0
- package/dist/core/ports/src/cant-try-error.js +44 -0
- package/dist/core/ports/src/chat.d.ts +127 -0
- package/dist/core/ports/src/chat.js +1 -0
- package/dist/core/ports/src/clock.d.ts +7 -0
- package/dist/core/ports/src/clock.js +2 -0
- package/dist/core/ports/src/connection-settings-store.d.ts +57 -0
- package/dist/core/ports/src/connection-settings-store.js +2 -0
- package/dist/core/ports/src/connector-client.d.ts +303 -0
- package/dist/core/ports/src/connector-client.js +19 -0
- package/dist/core/ports/src/coordination.d.ts +84 -0
- package/dist/core/ports/src/coordination.js +2 -0
- package/dist/core/ports/src/definition-store.d.ts +229 -0
- package/dist/core/ports/src/definition-store.js +122 -0
- package/dist/core/ports/src/digest.d.ts +14 -0
- package/dist/core/ports/src/digest.js +2 -0
- package/dist/core/ports/src/folder-reader.d.ts +89 -0
- package/dist/core/ports/src/folder-reader.js +2 -0
- package/dist/core/ports/src/harness-bridge-server.d.ts +198 -0
- package/dist/core/ports/src/harness-bridge-server.js +37 -0
- package/dist/core/ports/src/harness-sign-in-command.d.ts +27 -0
- package/dist/core/ports/src/harness-sign-in-command.js +31 -0
- package/dist/core/ports/src/harness.d.ts +283 -0
- package/dist/core/ports/src/harness.js +45 -0
- package/dist/core/ports/src/host-settings-store.d.ts +116 -0
- package/dist/core/ports/src/host-settings-store.js +106 -0
- package/dist/core/ports/src/http-client.d.ts +27 -0
- package/dist/core/ports/src/http-client.js +2 -0
- package/dist/core/ports/src/id-generator.d.ts +14 -0
- package/dist/core/ports/src/id-generator.js +2 -0
- package/dist/core/ports/src/index.d.ts +45 -0
- package/dist/core/ports/src/index.js +44 -0
- package/dist/core/ports/src/instruction-trust-store.d.ts +81 -0
- package/dist/core/ports/src/instruction-trust-store.js +43 -0
- package/dist/core/ports/src/integration.d.ts +242 -0
- package/dist/core/ports/src/integration.js +31 -0
- package/dist/core/ports/src/knowledge-provider.d.ts +65 -0
- package/dist/core/ports/src/knowledge-provider.js +2 -0
- package/dist/core/ports/src/llm-cache.d.ts +13 -0
- package/dist/core/ports/src/llm-cache.js +2 -0
- package/dist/core/ports/src/llm-provider.d.ts +186 -0
- package/dist/core/ports/src/llm-provider.js +139 -0
- package/dist/core/ports/src/model-price.d.ts +34 -0
- package/dist/core/ports/src/model-price.js +25 -0
- package/dist/core/ports/src/password-hasher.d.ts +63 -0
- package/dist/core/ports/src/password-hasher.js +2 -0
- package/dist/core/ports/src/plugin-folder-writer.d.ts +104 -0
- package/dist/core/ports/src/plugin-folder-writer.js +95 -0
- package/dist/core/ports/src/port-versions.d.ts +47 -0
- package/dist/core/ports/src/port-versions.js +80 -0
- package/dist/core/ports/src/program-probe.d.ts +69 -0
- package/dist/core/ports/src/program-probe.js +2 -0
- package/dist/core/ports/src/provider-default-base-url.d.ts +10 -0
- package/dist/core/ports/src/provider-default-base-url.js +18 -0
- package/dist/core/ports/src/record-store.d.ts +79 -0
- package/dist/core/ports/src/record-store.js +108 -0
- package/dist/core/ports/src/resource-probe.d.ts +59 -0
- package/dist/core/ports/src/resource-probe.js +2 -0
- package/dist/core/ports/src/run-executor.d.ts +303 -0
- package/dist/core/ports/src/run-executor.js +2 -0
- package/dist/core/ports/src/run-failure-error.d.ts +49 -0
- package/dist/core/ports/src/run-failure-error.js +47 -0
- package/dist/core/ports/src/run-store.d.ts +194 -0
- package/dist/core/ports/src/run-store.js +131 -0
- package/dist/core/ports/src/run-target-not-found.d.ts +34 -0
- package/dist/core/ports/src/run-target-not-found.js +41 -0
- package/dist/core/ports/src/sandbox-setting-store.d.ts +68 -0
- package/dist/core/ports/src/sandbox-setting-store.js +33 -0
- package/dist/core/ports/src/sandbox.d.ts +364 -0
- package/dist/core/ports/src/sandbox.js +70 -0
- package/dist/core/ports/src/scheduler.d.ts +85 -0
- package/dist/core/ports/src/scheduler.js +2 -0
- package/dist/core/ports/src/secrets.d.ts +201 -0
- package/dist/core/ports/src/secrets.js +200 -0
- package/dist/core/ports/src/token-store.d.ts +19 -0
- package/dist/core/ports/src/token-store.js +2 -0
- package/dist/core/ports/src/tool-approval-store.d.ts +253 -0
- package/dist/core/ports/src/tool-approval-store.js +116 -0
- package/dist/core/ports/src/trust-store.d.ts +72 -0
- package/dist/core/ports/src/trust-store.js +2 -0
- package/dist/core/ports/src/unfenced-run-consent-store.d.ts +43 -0
- package/dist/core/ports/src/unfenced-run-consent-store.js +2 -0
- package/dist/core/ports/src/vcs-status.d.ts +8 -0
- package/dist/core/ports/src/vcs-status.js +90 -0
- package/dist/core/ports/src/vcs.d.ts +394 -0
- package/dist/core/ports/src/vcs.js +48 -0
- package/dist/core/schema-kit/src/builders.d.ts +50 -0
- package/dist/core/schema-kit/src/builders.js +72 -0
- package/dist/core/schema-kit/src/depth.d.ts +15 -0
- package/dist/core/schema-kit/src/depth.js +37 -0
- package/dist/core/schema-kit/src/index.d.ts +6 -0
- package/dist/core/schema-kit/src/index.js +6 -0
- package/dist/core/schema-kit/src/issue.d.ts +22 -0
- package/dist/core/schema-kit/src/issue.js +23 -0
- package/dist/core/schema-kit/src/json-schema.d.ts +23 -0
- package/dist/core/schema-kit/src/json-schema.js +22 -0
- package/dist/core/schema-kit/src/parse.d.ts +17 -0
- package/dist/core/schema-kit/src/parse.js +25 -0
- package/dist/core/schema-kit/src/schema.d.ts +12 -0
- package/dist/core/schema-kit/src/schema.js +1 -0
- package/dist/core/std/src/amount.d.ts +13 -0
- package/dist/core/std/src/amount.js +22 -0
- package/dist/core/std/src/ascii-host.d.ts +18 -0
- package/dist/core/std/src/ascii-host.js +110 -0
- package/dist/core/std/src/assert.d.ts +39 -0
- package/dist/core/std/src/assert.js +59 -0
- package/dist/core/std/src/base64url.d.ts +23 -0
- package/dist/core/std/src/base64url.js +65 -0
- package/dist/core/std/src/canonical-json.d.ts +18 -0
- package/dist/core/std/src/canonical-json.js +56 -0
- package/dist/core/std/src/clock.d.ts +27 -0
- package/dist/core/std/src/clock.js +33 -0
- package/dist/core/std/src/constant-time.d.ts +16 -0
- package/dist/core/std/src/constant-time.js +26 -0
- package/dist/core/std/src/content-digest.d.ts +24 -0
- package/dist/core/std/src/content-digest.js +28 -0
- package/dist/core/std/src/deep-clone.d.ts +15 -0
- package/dist/core/std/src/deep-clone.js +59 -0
- package/dist/core/std/src/deep-equal.d.ts +23 -0
- package/dist/core/std/src/deep-equal.js +64 -0
- package/dist/core/std/src/emitter.d.ts +42 -0
- package/dist/core/std/src/emitter.js +74 -0
- package/dist/core/std/src/error-kind.d.ts +88 -0
- package/dist/core/std/src/error-kind.js +98 -0
- package/dist/core/std/src/hex.d.ts +10 -0
- package/dist/core/std/src/hex.js +16 -0
- package/dist/core/std/src/hidden-characters.d.ts +19 -0
- package/dist/core/std/src/hidden-characters.js +54 -0
- package/dist/core/std/src/ids.d.ts +45 -0
- package/dist/core/std/src/ids.js +49 -0
- package/dist/core/std/src/index.d.ts +30 -0
- package/dist/core/std/src/index.js +31 -0
- package/dist/core/std/src/keyed-queue.d.ts +18 -0
- package/dist/core/std/src/keyed-queue.js +32 -0
- package/dist/core/std/src/line-diff.d.ts +83 -0
- package/dist/core/std/src/line-diff.js +179 -0
- package/dist/core/std/src/line-merge.d.ts +63 -0
- package/dist/core/std/src/line-merge.js +138 -0
- package/dist/core/std/src/plain-data.d.ts +32 -0
- package/dist/core/std/src/plain-data.js +57 -0
- package/dist/core/std/src/posix-path.d.ts +61 -0
- package/dist/core/std/src/posix-path.js +121 -0
- package/dist/core/std/src/public-suffixes.generated.d.ts +9 -0
- package/dist/core/std/src/public-suffixes.generated.js +10429 -0
- package/dist/core/std/src/registrable-domain.d.ts +10 -0
- package/dist/core/std/src/registrable-domain.js +62 -0
- package/dist/core/std/src/result.d.ts +55 -0
- package/dist/core/std/src/result.js +52 -0
- package/dist/core/std/src/secret-scrubber.d.ts +54 -0
- package/dist/core/std/src/secret-scrubber.js +124 -0
- package/dist/core/std/src/secret-shape.d.ts +20 -0
- package/dist/core/std/src/secret-shape.js +53 -0
- package/dist/core/std/src/secret-variable-name.d.ts +12 -0
- package/dist/core/std/src/secret-variable-name.js +34 -0
- package/dist/core/std/src/site-name.d.ts +35 -0
- package/dist/core/std/src/site-name.js +111 -0
- package/dist/core/std/src/stop-signal.d.ts +44 -0
- package/dist/core/std/src/stop-signal.js +77 -0
- package/dist/core/std/src/text.d.ts +28 -0
- package/dist/core/std/src/text.js +54 -0
- package/dist/core/std/src/url-host.d.ts +35 -0
- package/dist/core/std/src/url-host.js +170 -0
- package/dist/core/std/src/utf8.d.ts +23 -0
- package/dist/core/std/src/utf8.js +110 -0
- package/dist/core/std/src/version.d.ts +48 -0
- package/dist/core/std/src/version.js +103 -0
- package/dist/core/yaml/src/depth.d.ts +14 -0
- package/dist/core/yaml/src/depth.js +140 -0
- package/dist/core/yaml/src/edit-data.d.ts +47 -0
- package/dist/core/yaml/src/edit-data.js +286 -0
- package/dist/core/yaml/src/edit-text.d.ts +92 -0
- package/dist/core/yaml/src/edit-text.js +267 -0
- package/dist/core/yaml/src/edit.d.ts +47 -0
- package/dist/core/yaml/src/edit.js +198 -0
- package/dist/core/yaml/src/index.d.ts +5 -0
- package/dist/core/yaml/src/index.js +4 -0
- package/dist/core/yaml/src/problem.d.ts +20 -0
- package/dist/core/yaml/src/problem.js +1 -0
- package/dist/core/yaml/src/read.d.ts +47 -0
- package/dist/core/yaml/src/read.js +130 -0
- package/dist/core/yaml/src/splice-node.d.ts +47 -0
- package/dist/core/yaml/src/splice-node.js +333 -0
- package/dist/core/yaml/src/splice.d.ts +13 -0
- package/dist/core/yaml/src/splice.js +174 -0
- package/dist/core/yaml/src/unsupported.d.ts +26 -0
- package/dist/core/yaml/src/unsupported.js +70 -0
- package/dist/core/yaml/src/write.d.ts +35 -0
- package/dist/core/yaml/src/write.js +44 -0
- package/dist/testing/integration/src/canaries.d.ts +14 -0
- package/dist/testing/integration/src/canaries.js +17 -0
- package/dist/testing/integration/src/checks.d.ts +37 -0
- package/dist/testing/integration/src/checks.js +195 -0
- package/dist/testing/integration/src/describe.d.ts +35 -0
- package/dist/testing/integration/src/describe.js +74 -0
- package/dist/testing/integration/src/failure.d.ts +6 -0
- package/dist/testing/integration/src/failure.js +8 -0
- package/dist/testing/integration/src/fake-wait.d.ts +18 -0
- package/dist/testing/integration/src/fake-wait.js +21 -0
- package/dist/testing/integration/src/index.d.ts +10 -0
- package/dist/testing/integration/src/index.js +11 -0
- package/dist/testing/integration/src/load.d.ts +14 -0
- package/dist/testing/integration/src/load.js +47 -0
- package/dist/testing/integration/src/plugin-folder.d.ts +23 -0
- package/dist/testing/integration/src/plugin-folder.js +59 -0
- package/dist/testing/integration/src/plugin.d.ts +32 -0
- package/dist/testing/integration/src/plugin.js +57 -0
- package/dist/testing/integration/src/recording.d.ts +84 -0
- package/dist/testing/integration/src/recording.js +164 -0
- package/dist/testing/integration/src/run.d.ts +60 -0
- package/dist/testing/integration/src/run.js +81 -0
- package/dist/testing/integration/src/source-scan.d.ts +16 -0
- package/dist/testing/integration/src/source-scan.js +40 -0
- package/package.json +34 -3
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gives out a {@link StopSignal} and tells it to stop.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* const source = new StopSource();
|
|
6
|
+
* void runHarness(source.signal);
|
|
7
|
+
* source.stop(new Error("The engine stopped."));
|
|
8
|
+
*/
|
|
9
|
+
export class StopSource {
|
|
10
|
+
signal;
|
|
11
|
+
#reason;
|
|
12
|
+
#listeners = new Set();
|
|
13
|
+
constructor() {
|
|
14
|
+
const source = this;
|
|
15
|
+
this.signal = {
|
|
16
|
+
get stopped() {
|
|
17
|
+
return source.#reason !== undefined;
|
|
18
|
+
},
|
|
19
|
+
get reason() {
|
|
20
|
+
return source.#reason;
|
|
21
|
+
},
|
|
22
|
+
throwIfStopped() {
|
|
23
|
+
if (source.#reason !== undefined)
|
|
24
|
+
throw source.#reason;
|
|
25
|
+
},
|
|
26
|
+
onStop: (listener) => this.#onStop(listener),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Tells the signal to stop with `reason`, and each listener once. A second
|
|
31
|
+
* call changes nothing.
|
|
32
|
+
*
|
|
33
|
+
* @throws the error of the one listener that threw, or an `AggregateError`
|
|
34
|
+
* when several did; the other listeners still run
|
|
35
|
+
*/
|
|
36
|
+
stop(reason) {
|
|
37
|
+
if (this.#reason !== undefined)
|
|
38
|
+
return;
|
|
39
|
+
this.#reason = reason;
|
|
40
|
+
this.#callListeners();
|
|
41
|
+
}
|
|
42
|
+
#onStop(listener) {
|
|
43
|
+
// Wrapped, so adding the same function twice gives two independent listeners.
|
|
44
|
+
const entry = () => listener();
|
|
45
|
+
this.#listeners.add(entry);
|
|
46
|
+
if (this.#reason !== undefined) {
|
|
47
|
+
// Called later rather than now, so the caller has its remove function
|
|
48
|
+
// first. A listener that throws here is an unhandled rejection.
|
|
49
|
+
void Promise.resolve().then(() => this.#callListeners());
|
|
50
|
+
}
|
|
51
|
+
return () => {
|
|
52
|
+
this.#listeners.delete(entry);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** Calls and removes every listener, like `Emitter.emit` does with errors. */
|
|
56
|
+
#callListeners() {
|
|
57
|
+
const listeners = [...this.#listeners];
|
|
58
|
+
const errors = [];
|
|
59
|
+
for (const listener of listeners) {
|
|
60
|
+
// A listener that an earlier one removed is skipped, as `AbortSignal` does.
|
|
61
|
+
if (!this.#listeners.delete(listener))
|
|
62
|
+
continue;
|
|
63
|
+
try {
|
|
64
|
+
listener();
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
errors.push(error);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (errors.length === 1) {
|
|
71
|
+
throw errors[0];
|
|
72
|
+
}
|
|
73
|
+
if (errors.length > 1) {
|
|
74
|
+
throw new AggregateError(errors, `${errors.length} stop listeners failed.`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turns a display name into a file-safe id: lowercase ASCII letters and digits
|
|
3
|
+
* joined by single hyphens. Spaces and underscores both become hyphens
|
|
4
|
+
* ("snake_case" becomes "snake-case"), and accents are dropped ("Café" becomes
|
|
5
|
+
* "cafe"), as in the old Studio. Hyphens at either end are dropped, so the id
|
|
6
|
+
* can't be read as a command-line flag ("_a_" becomes "a"). A name with nothing
|
|
7
|
+
* usable left ("___", "!!! - !!!") becomes "item".
|
|
8
|
+
*
|
|
9
|
+
* @param name - the name a person typed
|
|
10
|
+
* @returns the id
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* slugify("Weekly Report"); // "weekly-report"
|
|
14
|
+
* slugify("Café crème!"); // "cafe-creme"
|
|
15
|
+
*/
|
|
16
|
+
export declare function slugify(name: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Returns `base` when no existing name uses it, otherwise the first free
|
|
19
|
+
* `base-2`, `base-3` and so on.
|
|
20
|
+
*
|
|
21
|
+
* @param base - the name to start from, usually a slug
|
|
22
|
+
* @param taken - the names already in use
|
|
23
|
+
* @returns a name that isn't in `taken`
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* uniqueName("report", ["report", "report-2"]); // "report-3"
|
|
27
|
+
*/
|
|
28
|
+
export declare function uniqueName(base: string, taken: Iterable<string>): string;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** What `slugify` returns when nothing usable is left of the name. */
|
|
2
|
+
const fallbackSlug = "item";
|
|
3
|
+
/**
|
|
4
|
+
* Turns a display name into a file-safe id: lowercase ASCII letters and digits
|
|
5
|
+
* joined by single hyphens. Spaces and underscores both become hyphens
|
|
6
|
+
* ("snake_case" becomes "snake-case"), and accents are dropped ("Café" becomes
|
|
7
|
+
* "cafe"), as in the old Studio. Hyphens at either end are dropped, so the id
|
|
8
|
+
* can't be read as a command-line flag ("_a_" becomes "a"). A name with nothing
|
|
9
|
+
* usable left ("___", "!!! - !!!") becomes "item".
|
|
10
|
+
*
|
|
11
|
+
* @param name - the name a person typed
|
|
12
|
+
* @returns the id
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* slugify("Weekly Report"); // "weekly-report"
|
|
16
|
+
* slugify("Café crème!"); // "cafe-creme"
|
|
17
|
+
*/
|
|
18
|
+
export function slugify(name) {
|
|
19
|
+
const slug = name
|
|
20
|
+
.toLowerCase()
|
|
21
|
+
// Splits "é" into "e" and a combining accent, which the next step removes.
|
|
22
|
+
.normalize("NFKD")
|
|
23
|
+
.replace(/[^\w\s-]/g, "")
|
|
24
|
+
.trim()
|
|
25
|
+
.replace(/[\s_]+/g, "-")
|
|
26
|
+
.replace(/-+/g, "-")
|
|
27
|
+
.replace(/^-|-$/g, "");
|
|
28
|
+
if (slug === "") {
|
|
29
|
+
return fallbackSlug;
|
|
30
|
+
}
|
|
31
|
+
return slug;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Returns `base` when no existing name uses it, otherwise the first free
|
|
35
|
+
* `base-2`, `base-3` and so on.
|
|
36
|
+
*
|
|
37
|
+
* @param base - the name to start from, usually a slug
|
|
38
|
+
* @param taken - the names already in use
|
|
39
|
+
* @returns a name that isn't in `taken`
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* uniqueName("report", ["report", "report-2"]); // "report-3"
|
|
43
|
+
*/
|
|
44
|
+
export function uniqueName(base, taken) {
|
|
45
|
+
const used = new Set(taken);
|
|
46
|
+
if (!used.has(base)) {
|
|
47
|
+
return base;
|
|
48
|
+
}
|
|
49
|
+
let suffix = 2;
|
|
50
|
+
while (used.has(`${base}-${suffix}`)) {
|
|
51
|
+
suffix++;
|
|
52
|
+
}
|
|
53
|
+
return `${base}-${suffix}`;
|
|
54
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** The host of a URL, as a name or an address. */
|
|
2
|
+
export type UrlHost = {
|
|
3
|
+
readonly kind: "domain";
|
|
4
|
+
readonly name: string;
|
|
5
|
+
}
|
|
6
|
+
/** Four numbers from 0 to 255. */
|
|
7
|
+
| {
|
|
8
|
+
readonly kind: "ipv4";
|
|
9
|
+
readonly octets: readonly number[];
|
|
10
|
+
}
|
|
11
|
+
/** Eight numbers from 0 to 65535, the groups of the address in order. */
|
|
12
|
+
| {
|
|
13
|
+
readonly kind: "ipv6";
|
|
14
|
+
readonly groups: readonly number[];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Reads the host of an `http` or `https` URL the way a browser would, for
|
|
18
|
+
* the cases that decide where a request goes: user info before an `@`, a
|
|
19
|
+
* port, a trailing dot, an IPv4 address written as `127.1`, `2130706433` or
|
|
20
|
+
* `0x7f.0.0.1`, and an IPv6 address in brackets. The core has no `URL`
|
|
21
|
+
* class, so it is read by hand.
|
|
22
|
+
*
|
|
23
|
+
* It does not give the full IDNA mapping, so a host with any non-ASCII
|
|
24
|
+
* character, a percent-encoded host, other schemes and anything it doesn't
|
|
25
|
+
* fully understand give `undefined`.
|
|
26
|
+
* Callers that need a safe answer treat that as "unknown".
|
|
27
|
+
*
|
|
28
|
+
* @param url - the URL as written
|
|
29
|
+
* @returns the host, or `undefined` when it is not an `http(s)` URL with a host this reader understands
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* urlHost("http://127.1:8080"); // { kind: "ipv4", octets: [127, 0, 0, 1] }
|
|
33
|
+
* urlHost("http://localhost@evil.example"); // { kind: "domain", name: "evil.example" }
|
|
34
|
+
*/
|
|
35
|
+
export declare function urlHost(url: string): UrlHost | undefined;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { asciiHost } from "./ascii-host.js";
|
|
2
|
+
const urlShape = /^(https?):\/\/([^/?#\\]*)/i;
|
|
3
|
+
const maxPort = 65535;
|
|
4
|
+
const forbiddenInDomain = /[\s#%/:<>?@[\\\]^|]/;
|
|
5
|
+
/**
|
|
6
|
+
* Reads the host of an `http` or `https` URL the way a browser would, for
|
|
7
|
+
* the cases that decide where a request goes: user info before an `@`, a
|
|
8
|
+
* port, a trailing dot, an IPv4 address written as `127.1`, `2130706433` or
|
|
9
|
+
* `0x7f.0.0.1`, and an IPv6 address in brackets. The core has no `URL`
|
|
10
|
+
* class, so it is read by hand.
|
|
11
|
+
*
|
|
12
|
+
* It does not give the full IDNA mapping, so a host with any non-ASCII
|
|
13
|
+
* character, a percent-encoded host, other schemes and anything it doesn't
|
|
14
|
+
* fully understand give `undefined`.
|
|
15
|
+
* Callers that need a safe answer treat that as "unknown".
|
|
16
|
+
*
|
|
17
|
+
* @param url - the URL as written
|
|
18
|
+
* @returns the host, or `undefined` when it is not an `http(s)` URL with a host this reader understands
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* urlHost("http://127.1:8080"); // { kind: "ipv4", octets: [127, 0, 0, 1] }
|
|
22
|
+
* urlHost("http://localhost@evil.example"); // { kind: "domain", name: "evil.example" }
|
|
23
|
+
*/
|
|
24
|
+
export function urlHost(url) {
|
|
25
|
+
const match = urlShape.exec(trimEdges(url));
|
|
26
|
+
if (match === null) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
const authority = (match[2] ?? "").slice((match[2] ?? "").lastIndexOf("@") + 1);
|
|
30
|
+
if (authority.startsWith("[")) {
|
|
31
|
+
return ipv6Host(authority);
|
|
32
|
+
}
|
|
33
|
+
const colon = authority.indexOf(":");
|
|
34
|
+
const text = colon === -1 ? authority : authority.slice(0, colon);
|
|
35
|
+
if (colon !== -1 && !isPort(authority.slice(colon + 1))) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
return nameOrIpv4(text);
|
|
39
|
+
}
|
|
40
|
+
/** A port is digits only, or empty, and fits in 16 bits. */
|
|
41
|
+
function isPort(text) {
|
|
42
|
+
return /^\d*$/.test(text) && (text === "" || Number(text) <= maxPort);
|
|
43
|
+
}
|
|
44
|
+
function ipv6Host(authority) {
|
|
45
|
+
const end = authority.indexOf("]");
|
|
46
|
+
const after = authority.slice(end + 1);
|
|
47
|
+
if (end === -1 || !(after === "" || (after.startsWith(":") && isPort(after.slice(1))))) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
const groups = parseIpv6(authority.slice(1, end));
|
|
51
|
+
return groups === undefined ? undefined : { kind: "ipv6", groups };
|
|
52
|
+
}
|
|
53
|
+
function nameOrIpv4(text) {
|
|
54
|
+
// Non-ASCII hosts would need the full IDNA mapping, so a wrong guess is worse than none.
|
|
55
|
+
if (text === "" ||
|
|
56
|
+
hasNonAscii(text) ||
|
|
57
|
+
forbiddenInDomain.test(text) ||
|
|
58
|
+
hasControlCharacter(text)) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
const name = asciiHost(text.endsWith(".") ? text.slice(0, -1) : text);
|
|
62
|
+
const labels = name.split(".");
|
|
63
|
+
if (labels.some((label) => label === "")) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
if (!endsInNumber(labels)) {
|
|
67
|
+
return { kind: "domain", name };
|
|
68
|
+
}
|
|
69
|
+
const octets = parseIpv4(labels);
|
|
70
|
+
return octets === undefined ? undefined : { kind: "ipv4", octets };
|
|
71
|
+
}
|
|
72
|
+
/** A host whose last label is a number is an IPv4 address or nothing (WHATWG "ends in a number"). */
|
|
73
|
+
function endsInNumber(labels) {
|
|
74
|
+
const last = labels[labels.length - 1] ?? "";
|
|
75
|
+
return /^(\d+|0x[0-9a-f]*)$/.test(last);
|
|
76
|
+
}
|
|
77
|
+
function parseIpv4(labels) {
|
|
78
|
+
if (labels.length > 4) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
const numbers = labels.map(ipv4Number);
|
|
82
|
+
if (numbers.some((number) => number === undefined)) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
const values = numbers;
|
|
86
|
+
const last = values[values.length - 1];
|
|
87
|
+
const head = values.slice(0, -1);
|
|
88
|
+
if (head.some((value) => value > 255) || last >= 256 ** (5 - values.length)) {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
let address = last;
|
|
92
|
+
head.forEach((value, index) => {
|
|
93
|
+
address += value * 256 ** (3 - index);
|
|
94
|
+
});
|
|
95
|
+
return [24, 16, 8, 0].map((shift) => Math.floor(address / 2 ** shift) % 256);
|
|
96
|
+
}
|
|
97
|
+
function ipv4Number(label) {
|
|
98
|
+
if (/^0x[0-9a-f]*$/.test(label)) {
|
|
99
|
+
return label.length === 2 ? 0 : Number.parseInt(label.slice(2), 16);
|
|
100
|
+
}
|
|
101
|
+
if (/^0[0-7]+$/.test(label)) {
|
|
102
|
+
return Number.parseInt(label, 8);
|
|
103
|
+
}
|
|
104
|
+
// A leading 0 means octal, so `09` is not a number.
|
|
105
|
+
return /^(0|[1-9]\d*)$/.test(label) ? Number.parseInt(label, 10) : undefined;
|
|
106
|
+
}
|
|
107
|
+
function parseIpv6(text) {
|
|
108
|
+
const sides = text.split("::");
|
|
109
|
+
if (sides.length > 2) {
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
const head = groupsOf(sides[0] ?? "", sides.length === 1);
|
|
113
|
+
const tail = sides.length === 2 ? groupsOf(sides[1] ?? "", true) : [];
|
|
114
|
+
if (head === undefined || tail === undefined) {
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
if (sides.length === 1) {
|
|
118
|
+
return head.length === 8 ? head : undefined;
|
|
119
|
+
}
|
|
120
|
+
const missing = 8 - head.length - tail.length;
|
|
121
|
+
return missing < 1 ? undefined : [...head, ...new Array(missing).fill(0), ...tail];
|
|
122
|
+
}
|
|
123
|
+
/** The groups of one side of an IPv6 address; the end of the address may be an IPv4 address that makes two. */
|
|
124
|
+
function groupsOf(side, endsAddress) {
|
|
125
|
+
if (side === "") {
|
|
126
|
+
return [];
|
|
127
|
+
}
|
|
128
|
+
const parts = side.split(":");
|
|
129
|
+
const groups = [];
|
|
130
|
+
for (const [index, part] of parts.entries()) {
|
|
131
|
+
if (index === parts.length - 1 && part.includes(".")) {
|
|
132
|
+
const octets = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/
|
|
133
|
+
.exec(part)
|
|
134
|
+
?.slice(1)
|
|
135
|
+
.map(Number);
|
|
136
|
+
if (!endsAddress || octets === undefined || octets.some((octet) => octet > 255)) {
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
groups.push(octets[0] * 256 + octets[1], octets[2] * 256 + octets[3]);
|
|
140
|
+
}
|
|
141
|
+
else if (/^[0-9a-f]{1,4}$/i.test(part)) {
|
|
142
|
+
groups.push(Number.parseInt(part, 16));
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
return undefined;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return groups;
|
|
149
|
+
}
|
|
150
|
+
function hasControlCharacter(text) {
|
|
151
|
+
return [...text].some((character) => {
|
|
152
|
+
const code = character.codePointAt(0) ?? 0;
|
|
153
|
+
return code < 0x20 || code === 0x7f;
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
/** What the URL rules strip from both ends: control characters and the space, not Unicode spaces. */
|
|
157
|
+
function trimEdges(text) {
|
|
158
|
+
let start = 0;
|
|
159
|
+
let end = text.length;
|
|
160
|
+
while (start < end && text.charCodeAt(start) <= 0x20) {
|
|
161
|
+
start += 1;
|
|
162
|
+
}
|
|
163
|
+
while (end > start && text.charCodeAt(end - 1) <= 0x20) {
|
|
164
|
+
end -= 1;
|
|
165
|
+
}
|
|
166
|
+
return text.slice(start, end);
|
|
167
|
+
}
|
|
168
|
+
function hasNonAscii(text) {
|
|
169
|
+
return [...text].some((character) => (character.codePointAt(0) ?? 0) > 0x7f);
|
|
170
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encodes text as UTF-8. A lone surrogate, which has no UTF-8 form, becomes
|
|
3
|
+
* U+FFFD, as `TextEncoder` does.
|
|
4
|
+
*
|
|
5
|
+
* @param text - the text to encode
|
|
6
|
+
* @returns the UTF-8 bytes
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* encodeUtf8("é"); // Uint8Array [0xc3, 0xa9]
|
|
10
|
+
*/
|
|
11
|
+
export declare function encodeUtf8(text: string): Uint8Array;
|
|
12
|
+
/**
|
|
13
|
+
* Decodes UTF-8 bytes as text. Each invalid sequence becomes one U+FFFD, the
|
|
14
|
+
* same way `TextDecoder` does it. A byte order mark at the start is dropped,
|
|
15
|
+
* as `TextDecoder` drops it by default.
|
|
16
|
+
*
|
|
17
|
+
* @param bytes - the bytes to decode
|
|
18
|
+
* @returns the text
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* decodeUtf8(new Uint8Array([0xc3, 0xa9])); // "é"
|
|
22
|
+
*/
|
|
23
|
+
export declare function decodeUtf8(bytes: Uint8Array): string;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// The core has no TextEncoder or TextDecoder (they come from the DOM and Node
|
|
2
|
+
// type libraries, which the core doesn't load), so UTF-8 is written here. Both
|
|
3
|
+
// directions follow the WHATWG Encoding Standard, so they give exactly the same
|
|
4
|
+
// bytes and text as TextEncoder and TextDecoder.
|
|
5
|
+
/** U+FFFD, written in place of anything that isn't valid. */
|
|
6
|
+
const replacementCharacter = 0xfffd;
|
|
7
|
+
/**
|
|
8
|
+
* Encodes text as UTF-8. A lone surrogate, which has no UTF-8 form, becomes
|
|
9
|
+
* U+FFFD, as `TextEncoder` does.
|
|
10
|
+
*
|
|
11
|
+
* @param text - the text to encode
|
|
12
|
+
* @returns the UTF-8 bytes
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* encodeUtf8("é"); // Uint8Array [0xc3, 0xa9]
|
|
16
|
+
*/
|
|
17
|
+
export function encodeUtf8(text) {
|
|
18
|
+
const bytes = [];
|
|
19
|
+
for (const character of text) {
|
|
20
|
+
// for…of walks code points, so a valid surrogate pair arrives as one.
|
|
21
|
+
let codePoint = character.codePointAt(0) ?? replacementCharacter;
|
|
22
|
+
if (codePoint >= 0xd800 && codePoint <= 0xdfff) {
|
|
23
|
+
codePoint = replacementCharacter;
|
|
24
|
+
}
|
|
25
|
+
if (codePoint < 0x80) {
|
|
26
|
+
bytes.push(codePoint);
|
|
27
|
+
}
|
|
28
|
+
else if (codePoint < 0x800) {
|
|
29
|
+
bytes.push(0xc0 | (codePoint >> 6), 0x80 | (codePoint & 0x3f));
|
|
30
|
+
}
|
|
31
|
+
else if (codePoint < 0x10000) {
|
|
32
|
+
bytes.push(0xe0 | (codePoint >> 12), 0x80 | ((codePoint >> 6) & 0x3f), 0x80 | (codePoint & 0x3f));
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
bytes.push(0xf0 | (codePoint >> 18), 0x80 | ((codePoint >> 12) & 0x3f), 0x80 | ((codePoint >> 6) & 0x3f), 0x80 | (codePoint & 0x3f));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return Uint8Array.from(bytes);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Decodes UTF-8 bytes as text. Each invalid sequence becomes one U+FFFD, the
|
|
42
|
+
* same way `TextDecoder` does it. A byte order mark at the start is dropped,
|
|
43
|
+
* as `TextDecoder` drops it by default.
|
|
44
|
+
*
|
|
45
|
+
* @param bytes - the bytes to decode
|
|
46
|
+
* @returns the text
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* decodeUtf8(new Uint8Array([0xc3, 0xa9])); // "é"
|
|
50
|
+
*/
|
|
51
|
+
export function decodeUtf8(bytes) {
|
|
52
|
+
const codePoints = [];
|
|
53
|
+
let index = startsWithByteOrderMark(bytes) ? 3 : 0;
|
|
54
|
+
while (index < bytes.length) {
|
|
55
|
+
const sequence = readSequence(bytes, index);
|
|
56
|
+
codePoints.push(sequence.codePoint);
|
|
57
|
+
index += sequence.length;
|
|
58
|
+
}
|
|
59
|
+
let text = "";
|
|
60
|
+
// In chunks, because String.fromCodePoint takes its arguments on the stack.
|
|
61
|
+
const chunkSize = 8192;
|
|
62
|
+
for (let start = 0; start < codePoints.length; start += chunkSize) {
|
|
63
|
+
text += String.fromCodePoint(...codePoints.slice(start, start + chunkSize));
|
|
64
|
+
}
|
|
65
|
+
return text;
|
|
66
|
+
}
|
|
67
|
+
function startsWithByteOrderMark(bytes) {
|
|
68
|
+
return bytes[0] === 0xef && bytes[1] === 0xbb && bytes[2] === 0xbf;
|
|
69
|
+
}
|
|
70
|
+
/** Reads the sequence that starts at `start`, following the WHATWG UTF-8 decoder. */
|
|
71
|
+
function readSequence(bytes, start) {
|
|
72
|
+
const lead = bytes[start] ?? 0;
|
|
73
|
+
if (lead < 0x80) {
|
|
74
|
+
return { codePoint: lead, length: 1 };
|
|
75
|
+
}
|
|
76
|
+
const shape = sequenceShape(lead);
|
|
77
|
+
if (shape === undefined) {
|
|
78
|
+
return { codePoint: replacementCharacter, length: 1 };
|
|
79
|
+
}
|
|
80
|
+
let codePoint = lead & shape.leadMask;
|
|
81
|
+
let lower = shape.secondLower;
|
|
82
|
+
let upper = shape.secondUpper;
|
|
83
|
+
for (let offset = 1; offset < shape.length; offset++) {
|
|
84
|
+
const next = bytes[start + offset];
|
|
85
|
+
if (next === undefined || next < lower || next > upper) {
|
|
86
|
+
// The bytes read so far are one invalid sequence; `next` starts a new one.
|
|
87
|
+
return { codePoint: replacementCharacter, length: offset };
|
|
88
|
+
}
|
|
89
|
+
codePoint = (codePoint << 6) | (next & 0x3f);
|
|
90
|
+
lower = 0x80;
|
|
91
|
+
upper = 0xbf;
|
|
92
|
+
}
|
|
93
|
+
return { codePoint, length: shape.length };
|
|
94
|
+
}
|
|
95
|
+
function sequenceShape(lead) {
|
|
96
|
+
if (lead >= 0xc2 && lead <= 0xdf) {
|
|
97
|
+
return { length: 2, leadMask: 0x1f, secondLower: 0x80, secondUpper: 0xbf };
|
|
98
|
+
}
|
|
99
|
+
if (lead >= 0xe0 && lead <= 0xef) {
|
|
100
|
+
const secondLower = lead === 0xe0 ? 0xa0 : 0x80;
|
|
101
|
+
const secondUpper = lead === 0xed ? 0x9f : 0xbf;
|
|
102
|
+
return { length: 3, leadMask: 0x0f, secondLower, secondUpper };
|
|
103
|
+
}
|
|
104
|
+
if (lead >= 0xf0 && lead <= 0xf4) {
|
|
105
|
+
const secondLower = lead === 0xf0 ? 0x90 : 0x80;
|
|
106
|
+
const secondUpper = lead === 0xf4 ? 0x8f : 0xbf;
|
|
107
|
+
return { length: 4, leadMask: 0x07, secondLower, secondUpper };
|
|
108
|
+
}
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A version in semver's form, such as 0.169.0-alpha.6: three numbers and
|
|
3
|
+
* the pieces of an optional pre-release part. A build part (`+…`) is read
|
|
4
|
+
* but not kept, because it never changes the order.
|
|
5
|
+
*/
|
|
6
|
+
export interface Version {
|
|
7
|
+
readonly major: number;
|
|
8
|
+
readonly minor: number;
|
|
9
|
+
readonly patch: number;
|
|
10
|
+
/** The pre-release pieces, such as `["alpha", 6]`; empty for a release. */
|
|
11
|
+
readonly prerelease: readonly (string | number)[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Reads a version from text that is nothing but the version. Finding it in a
|
|
15
|
+
* program's output, such as "codex-cli 0.167.0", is the caller's part.
|
|
16
|
+
*
|
|
17
|
+
* @param text - the version, such as "0.169.0-alpha.6"
|
|
18
|
+
* @returns the version, or `undefined` when the text is anything else
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* readVersion("0.169.0-alpha.6"); // { major: 0, minor: 169, patch: 0, prerelease: ["alpha", 6] }
|
|
22
|
+
* readVersion("v0.169.0"); // undefined
|
|
23
|
+
*/
|
|
24
|
+
export declare function readVersion(text: string): Version | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Writes a version the usual way, such as "0.169.0-alpha.6".
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* formatVersion({ major: 2, minor: 1, patch: 321, prerelease: [] }); // "2.1.321"
|
|
30
|
+
*/
|
|
31
|
+
export declare function formatVersion(version: Version): string;
|
|
32
|
+
/**
|
|
33
|
+
* Compares two versions in semver's order.
|
|
34
|
+
*
|
|
35
|
+
* @returns a negative number when `a` comes first, a positive one when `b`
|
|
36
|
+
* does, and 0 when they are equal
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* compareVersions(readVersion("0.167.0-alpha.6")!, readVersion("0.167.0")!); // negative
|
|
40
|
+
*/
|
|
41
|
+
export declare function compareVersions(a: Version, b: Version): number;
|
|
42
|
+
/**
|
|
43
|
+
* Whether `version` is `minimum` or newer.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* isAtLeast(readVersion("0.167.0")!, readVersion("0.166.0")!); // true
|
|
47
|
+
*/
|
|
48
|
+
export declare function isAtLeast(version: Version, minimum: Version): boolean;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// A number without leading zeros, as semver writes them.
|
|
2
|
+
const number = "(?:0|[1-9]\\d*)";
|
|
3
|
+
// One pre-release piece: a number, or a word of letters, digits and hyphens.
|
|
4
|
+
const prereleasePiece = `(?:${number}|\\d*[A-Za-z-][0-9A-Za-z-]*)`;
|
|
5
|
+
// One build piece: any letters, digits and hyphens.
|
|
6
|
+
const buildPiece = "[0-9A-Za-z-]+";
|
|
7
|
+
const versionPattern = new RegExp(`^(${number})\\.(${number})\\.(${number})` +
|
|
8
|
+
`(?:-(${prereleasePiece}(?:\\.${prereleasePiece})*))?` +
|
|
9
|
+
`(?:\\+${buildPiece}(?:\\.${buildPiece})*)?$`);
|
|
10
|
+
/**
|
|
11
|
+
* Reads a version from text that is nothing but the version. Finding it in a
|
|
12
|
+
* program's output, such as "codex-cli 0.167.0", is the caller's part.
|
|
13
|
+
*
|
|
14
|
+
* @param text - the version, such as "0.169.0-alpha.6"
|
|
15
|
+
* @returns the version, or `undefined` when the text is anything else
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* readVersion("0.169.0-alpha.6"); // { major: 0, minor: 169, patch: 0, prerelease: ["alpha", 6] }
|
|
19
|
+
* readVersion("v0.169.0"); // undefined
|
|
20
|
+
*/
|
|
21
|
+
export function readVersion(text) {
|
|
22
|
+
const match = versionPattern.exec(text);
|
|
23
|
+
if (match === null) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
const [, major, minor, patch, prerelease] = match;
|
|
27
|
+
return {
|
|
28
|
+
major: Number(major),
|
|
29
|
+
minor: Number(minor),
|
|
30
|
+
patch: Number(patch),
|
|
31
|
+
prerelease: prerelease === undefined ? [] : prerelease.split(".").map(readPrereleasePiece),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** A pre-release piece of digits only is a number; any other is a word. */
|
|
35
|
+
function readPrereleasePiece(piece) {
|
|
36
|
+
return /^\d+$/.test(piece) ? Number(piece) : piece;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Writes a version the usual way, such as "0.169.0-alpha.6".
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* formatVersion({ major: 2, minor: 1, patch: 321, prerelease: [] }); // "2.1.321"
|
|
43
|
+
*/
|
|
44
|
+
export function formatVersion(version) {
|
|
45
|
+
const release = `${version.major}.${version.minor}.${version.patch}`;
|
|
46
|
+
if (version.prerelease.length === 0) {
|
|
47
|
+
return release;
|
|
48
|
+
}
|
|
49
|
+
return `${release}-${version.prerelease.join(".")}`;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Compares two versions in semver's order.
|
|
53
|
+
*
|
|
54
|
+
* @returns a negative number when `a` comes first, a positive one when `b`
|
|
55
|
+
* does, and 0 when they are equal
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* compareVersions(readVersion("0.167.0-alpha.6")!, readVersion("0.167.0")!); // negative
|
|
59
|
+
*/
|
|
60
|
+
export function compareVersions(a, b) {
|
|
61
|
+
return (a.major - b.major ||
|
|
62
|
+
a.minor - b.minor ||
|
|
63
|
+
a.patch - b.patch ||
|
|
64
|
+
comparePrereleases(a.prerelease, b.prerelease));
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Whether `version` is `minimum` or newer.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* isAtLeast(readVersion("0.167.0")!, readVersion("0.166.0")!); // true
|
|
71
|
+
*/
|
|
72
|
+
export function isAtLeast(version, minimum) {
|
|
73
|
+
return compareVersions(version, minimum) >= 0;
|
|
74
|
+
}
|
|
75
|
+
/** A release (no pieces) comes after any pre-release of the same version. */
|
|
76
|
+
function comparePrereleases(a, b) {
|
|
77
|
+
if (a.length === 0 || b.length === 0) {
|
|
78
|
+
return b.length - a.length;
|
|
79
|
+
}
|
|
80
|
+
for (let index = 0; index < Math.min(a.length, b.length); index++) {
|
|
81
|
+
const order = comparePrereleasePieces(a[index], b[index]);
|
|
82
|
+
if (order !== 0) {
|
|
83
|
+
return order;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return a.length - b.length;
|
|
87
|
+
}
|
|
88
|
+
/** Numbers by value and before words; words in ASCII order. */
|
|
89
|
+
function comparePrereleasePieces(a, b) {
|
|
90
|
+
if (typeof a === "number" && typeof b === "number") {
|
|
91
|
+
return a - b;
|
|
92
|
+
}
|
|
93
|
+
if (typeof a === "number") {
|
|
94
|
+
return -1;
|
|
95
|
+
}
|
|
96
|
+
if (typeof b === "number") {
|
|
97
|
+
return 1;
|
|
98
|
+
}
|
|
99
|
+
if (a === b) {
|
|
100
|
+
return 0;
|
|
101
|
+
}
|
|
102
|
+
return a < b ? -1 : 1;
|
|
103
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds where lists and maps first nest deeper than `maxDepth`, by reading
|
|
3
|
+
* the text as tokens, without building any tree. The `yaml` library builds
|
|
4
|
+
* the whole tree before we can look at it, so a hostile file such as five
|
|
5
|
+
* million `[` would use up memory first. This pass needs memory for the
|
|
6
|
+
* open levels only, and stops at the first one past the limit.
|
|
7
|
+
*
|
|
8
|
+
* Block levels are counted from indentation. The count can be a little
|
|
9
|
+
* higher than the real depth in odd layouts; `findUnsupported` still checks
|
|
10
|
+
* the exact tree afterwards.
|
|
11
|
+
*
|
|
12
|
+
* @returns the offset of the first list or map past the limit, or `undefined`
|
|
13
|
+
*/
|
|
14
|
+
export declare function findDepthOffset(text: string, maxDepth: number): number | undefined;
|