From 1e75d3d4cab1e87643d4171b056fd303ba899ce9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josh=20Goldberg=20=E2=9C=A8?= Date: Sat, 16 Sep 2023 03:43:56 -0400 Subject: [PATCH] Formatted types/h* packages with dprint (#66529) * Formatted types/h* packages with dprint * fix: hapi unhappy * fix: hapi unhappy --------- Co-authored-by: johnnyreilly --- types/h2o2/h2o2-tests.ts | 113 +- types/h2o2/index.d.ts | 39 +- types/hafas-client/hafas-client-tests.ts | 201 +- types/hafas-client/index.d.ts | 92 +- types/hafas-client/p/avv/index.d.ts | 2 +- types/hafas-client/p/bart/index.d.ts | 2 +- types/hafas-client/p/bls/index.d.ts | 2 +- types/hafas-client/p/bvg/index.d.ts | 2 +- types/hafas-client/p/cfl/index.d.ts | 2 +- types/hafas-client/p/cmta/index.d.ts | 2 +- types/hafas-client/p/dart/index.d.ts | 2 +- .../hafas-client/p/db-busradar-nrw/index.d.ts | 2 +- types/hafas-client/p/db/index.d.ts | 2 +- types/hafas-client/p/hvv/index.d.ts | 2 +- types/hafas-client/p/insa/index.d.ts | 2 +- types/hafas-client/p/invg/index.d.ts | 2 +- types/hafas-client/p/irish-rail/index.d.ts | 2 +- types/hafas-client/p/ivb/index.d.ts | 2 +- types/hafas-client/p/kvb/index.d.ts | 2 +- types/hafas-client/p/mobil-nrw/index.d.ts | 2 +- types/hafas-client/p/mobiliteit-lu/index.d.ts | 2 +- types/hafas-client/p/nahsh/index.d.ts | 2 +- types/hafas-client/p/nvv/index.d.ts | 2 +- types/hafas-client/p/oebb/index.d.ts | 2 +- types/hafas-client/p/ooevv/index.d.ts | 2 +- types/hafas-client/p/pkp/index.d.ts | 2 +- types/hafas-client/p/rejseplanen/index.d.ts | 2 +- types/hafas-client/p/rmv/index.d.ts | 2 +- types/hafas-client/p/rsag/index.d.ts | 2 +- types/hafas-client/p/saarfahrplan/index.d.ts | 2 +- types/hafas-client/p/salzburg/index.d.ts | 2 +- .../hafas-client/p/sbahn-muenchen/index.d.ts | 2 +- types/hafas-client/p/sncb/index.d.ts | 2 +- types/hafas-client/p/stv/index.d.ts | 2 +- types/hafas-client/p/svv/index.d.ts | 2 +- types/hafas-client/p/tpg/index.d.ts | 2 +- types/hafas-client/p/vbb/index.d.ts | 2 +- types/hafas-client/p/vbn/index.d.ts | 2 +- types/hafas-client/p/vkg/index.d.ts | 2 +- types/hafas-client/p/vmt/index.d.ts | 2 +- types/hafas-client/p/vor/index.d.ts | 2 +- types/hafas-client/p/vos/index.d.ts | 2 +- types/hafas-client/p/vrn/index.d.ts | 2 +- types/hafas-client/p/vsn/index.d.ts | 2 +- types/hafas-client/p/vvt/index.d.ts | 2 +- types/hafas-client/p/vvv/index.d.ts | 2 +- types/hafas-client/p/zvv/index.d.ts | 2 +- types/halfmoon/halfmoon-tests.ts | 24 +- types/halfmoon/index.d.ts | 2 +- types/halogen/index.d.ts | 35 +- types/halogen/test/clip-loader.tsx | 27 +- types/halogen/test/fade-loader.tsx | 32 +- types/halogen/test/pacman-loader.tsx | 28 +- types/halogen/test/rotate-loader.tsx | 28 +- types/halogenium/index.d.ts | 78 +- types/halogenium/test/clip-loader.tsx | 27 +- types/halogenium/test/fade-loader.tsx | 32 +- types/halogenium/test/pacman-loader.tsx | 28 +- types/halogenium/test/rotate-loader.tsx | 28 +- types/hammerjs/hammerjs-tests.ts | 307 +- types/hammerjs/index.d.ts | 514 +- types/hammerjs/v1/hammerjs-tests.ts | 28 +- types/hammerjs/v1/index.d.ts | 2 - types/handbrake-js/handbrake-js-tests.ts | 20 +- types/handbrake-js/index.d.ts | 330 +- .../handlebars-helpers-tests.ts | 14 +- types/handlebars-helpers/index.d.ts | 7 +- .../handlebars-webpack-plugin-tests.ts | 32 +- types/handlebars-webpack-plugin/index.d.ts | 12 +- .../hapi-auth-basic/hapi-auth-basic-tests.ts | 28 +- types/hapi-auth-basic/index.d.ts | 15 +- .../hapi-auth-bearer-token-tests.ts | 24 +- types/hapi-auth-bearer-token/index.d.ts | 41 +- .../hapi-auth-cookie-tests.ts | 40 +- types/hapi-auth-cookie/index.d.ts | 15 +- .../hapi-decorators/hapi-decorators-tests.ts | 25 +- types/hapi-decorators/index.d.ts | 16 +- .../hapi-server-session-tests.ts | 16 +- types/hapi-server-session/index.d.ts | 7 +- types/hapi/index.d.ts | 366 +- types/hapi/test/request/auth.ts | 4 +- types/hapi/test/request/catch-all.ts | 12 +- types/hapi/test/request/event-types.ts | 36 +- types/hapi/test/request/get-log.ts | 14 +- types/hapi/test/request/methods.ts | 2 +- types/hapi/test/request/parameters.ts | 18 +- types/hapi/test/request/query.ts | 8 +- types/hapi/test/response/continue.ts | 12 +- types/hapi/test/response/error.ts | 20 +- types/hapi/test/response/redirect.ts | 10 +- types/hapi/test/response/response-events.ts | 14 +- types/hapi/test/response/response.ts | 26 +- types/hapi/test/route/adding-routes.ts | 26 +- types/hapi/test/route/config.ts | 42 +- types/hapi/test/route/ext.ts | 6 +- types/hapi/test/route/handler.ts | 2 +- types/hapi/test/route/route-options-pre.ts | 24 +- types/hapi/test/route/route-options.ts | 104 +- types/hapi/test/route/validation.ts | 26 +- types/hapi/test/server/server-app.ts | 12 +- types/hapi/test/server/server-auth-api.ts | 21 +- types/hapi/test/server/server-auth-default.ts | 24 +- types/hapi/test/server/server-auth-test.ts | 22 +- types/hapi/test/server/server-auth-verify.ts | 18 +- types/hapi/test/server/server-bind.ts | 14 +- .../test/server/server-cache-provision.ts | 14 +- types/hapi/test/server/server-cache.ts | 14 +- types/hapi/test/server/server-decoder.ts | 2 +- types/hapi/test/server/server-decorations.ts | 44 +- types/hapi/test/server/server-encoder.ts | 2 +- types/hapi/test/server/server-events-once.ts | 32 +- types/hapi/test/server/server-events.ts | 16 +- types/hapi/test/server/server-expose.ts | 14 +- types/hapi/test/server/server-info.ts | 2 +- types/hapi/test/server/server-inject.ts | 18 +- types/hapi/test/server/server-load.ts | 2 +- types/hapi/test/server/server-lookup.ts | 12 +- types/hapi/test/server/server-match.ts | 12 +- types/hapi/test/server/server-method.ts | 8 +- types/hapi/test/server/server-methods.ts | 4 +- types/hapi/test/server/server-mime.ts | 18 +- types/hapi/test/server/server-options.ts | 84 +- types/hapi/test/server/server-path.ts | 20 +- types/hapi/test/server/server-plugins.ts | 52 +- types/hapi/test/server/server-settings.ts | 8 +- types/hapi/test/server/server-start.ts | 4 +- types/hapi/test/server/server-state.ts | 16 +- types/hapi/test/server/server-stop.ts | 8 +- types/hapi/test/server/server-table.ts | 10 +- types/hapi/test/server/server-version.ts | 2 +- types/hapi/v12/hapi-tests.ts | 78 +- types/hapi/v12/index.d.ts | 389 +- types/hapi/v15/hapi-tests.ts | 104 +- types/hapi/v15/index.d.ts | 232 +- types/hapi/v16/index.d.ts | 314 +- types/hapi/v16/test/connection/table.ts | 15 +- types/hapi/v16/test/continuation/errors.ts | 19 +- .../getting-started/01-creating-a-server.ts | 7 +- .../test/getting-started/02-adding-routes.ts | 27 +- .../test/getting-started/04-using-plugins.ts | 50 +- types/hapi/v16/test/path/catch-all.ts | 14 +- types/hapi/v16/test/path/parameters.ts | 31 +- types/hapi/v16/test/plugins/options.ts | 19 +- types/hapi/v16/test/reply/continue.ts | 10 +- types/hapi/v16/test/reply/entity.ts | 20 +- types/hapi/v16/test/reply/redirect.ts | 8 +- types/hapi/v16/test/reply/reply.ts | 21 +- types/hapi/v16/test/reply/state_cookie.ts | 37 +- types/hapi/v16/test/request/event-types.ts | 25 +- .../v16/test/request/generate-response.ts | 7 +- types/hapi/v16/test/request/get-log.ts | 9 +- types/hapi/v16/test/request/log.ts | 11 +- types/hapi/v16/test/request/query.ts | 5 +- types/hapi/v16/test/request/set-method.ts | 10 +- types/hapi/v16/test/request/set-url.ts | 17 +- types/hapi/v16/test/request/tail.ts | 20 +- .../v16/test/response/error-representation.ts | 16 +- types/hapi/v16/test/response/error.ts | 27 +- types/hapi/v16/test/response/events.ts | 20 +- types/hapi/v16/test/response/flow-control.ts | 9 +- .../hapi/v16/test/route/additional-options.ts | 68 +- types/hapi/v16/test/route/auth.ts | 24 +- types/hapi/v16/test/route/config.ts | 43 +- types/hapi/v16/test/route/handler.ts | 10 +- types/hapi/v16/test/route/plugins.ts | 18 +- types/hapi/v16/test/route/prerequisites.ts | 35 +- types/hapi/v16/test/route/public-interface.ts | 10 +- types/hapi/v16/test/route/validate.ts | 27 +- types/hapi/v16/test/server/app.ts | 8 +- types/hapi/v16/test/server/auth.ts | 81 +- types/hapi/v16/test/server/bind.ts | 13 +- types/hapi/v16/test/server/cache.ts | 23 +- .../v16/test/server/connection-options.ts | 25 +- types/hapi/v16/test/server/connections.ts | 9 +- types/hapi/v16/test/server/decoder.ts | 7 +- types/hapi/v16/test/server/decorate.ts | 45 +- types/hapi/v16/test/server/dependency.ts | 17 +- types/hapi/v16/test/server/emit.ts | 11 +- types/hapi/v16/test/server/encoder.ts | 7 +- types/hapi/v16/test/server/event.ts | 11 +- types/hapi/v16/test/server/expose.ts | 19 +- types/hapi/v16/test/server/ext.ts | 36 +- types/hapi/v16/test/server/handler.ts | 45 +- types/hapi/v16/test/server/info.ts | 7 +- types/hapi/v16/test/server/initialize.ts | 6 +- types/hapi/v16/test/server/inject.ts | 14 +- types/hapi/v16/test/server/load.ts | 3 +- types/hapi/v16/test/server/log.ts | 8 +- types/hapi/v16/test/server/lookup.ts | 16 +- types/hapi/v16/test/server/match.ts | 16 +- types/hapi/v16/test/server/method.ts | 47 +- types/hapi/v16/test/server/methods.ts | 9 +- types/hapi/v16/test/server/mime.ts | 21 +- types/hapi/v16/test/server/new.ts | 68 +- types/hapi/v16/test/server/on.ts | 36 +- types/hapi/v16/test/server/once.ts | 13 +- types/hapi/v16/test/server/path.ts | 10 +- types/hapi/v16/test/server/plugins.ts | 10 +- types/hapi/v16/test/server/realm.ts | 4 +- types/hapi/v16/test/server/register.ts | 12 +- types/hapi/v16/test/server/route.ts | 27 +- types/hapi/v16/test/server/select.ts | 13 +- types/hapi/v16/test/server/settings.ts | 9 +- types/hapi/v16/test/server/start.ts | 8 +- types/hapi/v16/test/server/state.ts | 21 +- types/hapi/v16/test/server/stop.ts | 6 +- types/hapi/v16/test/server/table.ts | 13 +- types/hapi/v16/test/server/version.ts | 5 +- types/hapi/v17/index.d.ts | 358 +- types/hapi/v17/test/request/auth.ts | 4 +- types/hapi/v17/test/request/catch-all.ts | 12 +- types/hapi/v17/test/request/event-types.ts | 36 +- types/hapi/v17/test/request/get-log.ts | 14 +- types/hapi/v17/test/request/methods.ts | 2 +- types/hapi/v17/test/request/parameters.ts | 18 +- types/hapi/v17/test/request/query.ts | 8 +- types/hapi/v17/test/response/continue.ts | 12 +- types/hapi/v17/test/response/error.ts | 20 +- types/hapi/v17/test/response/redirect.ts | 10 +- .../hapi/v17/test/response/response-events.ts | 14 +- types/hapi/v17/test/response/response.ts | 26 +- types/hapi/v17/test/route/adding-routes.ts | 26 +- types/hapi/v17/test/route/config.ts | 42 +- types/hapi/v17/test/route/ext.ts | 6 +- types/hapi/v17/test/route/handler.ts | 2 +- .../hapi/v17/test/route/route-options-pre.ts | 24 +- types/hapi/v17/test/route/route-options.ts | 104 +- types/hapi/v17/test/route/validation.ts | 26 +- types/hapi/v17/test/server/server-app.ts | 12 +- types/hapi/v17/test/server/server-auth-api.ts | 21 +- .../v17/test/server/server-auth-default.ts | 24 +- .../hapi/v17/test/server/server-auth-test.ts | 22 +- .../v17/test/server/server-auth-verify.ts | 18 +- types/hapi/v17/test/server/server-bind.ts | 14 +- .../v17/test/server/server-cache-provision.ts | 14 +- types/hapi/v17/test/server/server-cache.ts | 14 +- types/hapi/v17/test/server/server-decoder.ts | 2 +- .../v17/test/server/server-decorations.ts | 44 +- types/hapi/v17/test/server/server-encoder.ts | 2 +- .../v17/test/server/server-events-once.ts | 32 +- types/hapi/v17/test/server/server-events.ts | 16 +- types/hapi/v17/test/server/server-expose.ts | 14 +- types/hapi/v17/test/server/server-info.ts | 2 +- types/hapi/v17/test/server/server-inject.ts | 16 +- types/hapi/v17/test/server/server-load.ts | 2 +- types/hapi/v17/test/server/server-lookup.ts | 12 +- types/hapi/v17/test/server/server-match.ts | 12 +- types/hapi/v17/test/server/server-method.ts | 8 +- types/hapi/v17/test/server/server-methods.ts | 4 +- types/hapi/v17/test/server/server-mime.ts | 18 +- types/hapi/v17/test/server/server-options.ts | 84 +- types/hapi/v17/test/server/server-path.ts | 20 +- types/hapi/v17/test/server/server-plugins.ts | 52 +- types/hapi/v17/test/server/server-settings.ts | 8 +- types/hapi/v17/test/server/server-start.ts | 4 +- types/hapi/v17/test/server/server-state.ts | 16 +- types/hapi/v17/test/server/server-stop.ts | 8 +- types/hapi/v17/test/server/server-table.ts | 10 +- types/hapi/v17/test/server/server-version.ts | 2 +- types/hapi/v8/hapi-tests.ts | 94 +- types/hapi/v8/index.d.ts | 319 +- types/hapi__b64/hapi__b64-tests.ts | 18 +- types/hapi__b64/index.d.ts | 4 +- types/hapi__basic/hapi__basic-tests.ts | 28 +- types/hapi__basic/index.d.ts | 15 +- types/hapi__bell/hapi__bell-tests.ts | 190 +- types/hapi__bell/index.d.ts | 456 +- types/hapi__call/hapi__call-tests.ts | 8 +- types/hapi__call/index.d.ts | 2 +- .../hapi__catbox-memcached-tests.ts | 8 +- types/hapi__catbox-memcached/index.d.ts | 2 +- .../hapi__catbox-memory-tests.ts | 4 +- types/hapi__catbox-memory/index.d.ts | 2 +- .../hapi__catbox-redis-tests.ts | 22 +- types/hapi__catbox-redis/index.d.ts | 98 +- types/hapi__catbox/hapi__catbox-tests.ts | 42 +- types/hapi__content/hapi__content-tests.ts | 4 +- types/hapi__content/index.d.ts | 10 +- types/hapi__cookie/hapi__cookie-tests.ts | 48 +- types/hapi__cookie/index.d.ts | 10 +- types/hapi__crumb/hapi__crumb-tests.ts | 24 +- types/hapi__crumb/index.d.ts | 6 +- types/hapi__glue/hapi__glue-tests.ts | 42 +- types/hapi__glue/index.d.ts | 20 +- types/hapi__h2o2/hapi__h2o2-tests.ts | 78 +- types/hapi__h2o2/index.d.ts | 30 +- types/hapi__hawk/hapi__hawk-tests.ts | 32 +- types/hapi__hawk/index.d.ts | 14 +- types/hapi__hawk/lib/browser.d.ts | 6 +- types/hapi__hawk/lib/client.d.ts | 8 +- types/hapi__hawk/lib/crypto.d.ts | 4 +- types/hapi__hawk/lib/plugin.d.ts | 2 +- types/hapi__hawk/lib/server.d.ts | 16 +- types/hapi__hawk/lib/utils.d.ts | 6 +- types/hapi__inert/hapi__inert-tests.ts | 58 +- types/hapi__inert/index.d.ts | 20 +- types/hapi__joi/hapi__joi-tests.ts | 191 +- types/hapi__joi/index.d.ts | 74 +- types/hapi__jwt/hapi__jwt-tests.ts | 38 +- types/hapi__jwt/index.d.ts | 34 +- types/hapi__pez/hapi__pez-tests.ts | 16 +- types/hapi__pez/index.d.ts | 10 +- types/hapi__shot/hapi__shot-tests.ts | 12 +- types/hapi__shot/index.d.ts | 2 +- types/hapi__sntp/hapi__sntp-tests.ts | 4 +- types/hapi__subtext/hapi__subtext-tests.ts | 18 +- types/hapi__subtext/index.d.ts | 58 +- types/hapi__vision/hapi__vision-tests.ts | 54 +- types/hapi__vision/index.d.ts | 28 +- types/hapi__yar/hapi__yar-tests.ts | 22 +- types/hapi__yar/index.d.ts | 10 +- .../hapipal__avocat/hapipal__avocat-tests.ts | 4 +- types/hapipal__avocat/index.d.ts | 5 +- .../hapipal__schmervice-tests.ts | 58 +- types/hapipal__schmervice/index.d.ts | 23 +- .../test/organization_service.ts | 10 +- .../hapipal__schmervice/test/user_service.ts | 10 +- types/hapipal__toys/hapipal__toys-tests.ts | 114 +- types/hapipal__toys/index.d.ts | 25 +- types/happo-cypress/happo-cypress-tests.ts | 32 +- .../happyguestmx__web-utilities-tests.ts | 2 +- types/happyguestmx__web-utilities/index.d.ts | 40 +- types/happypack/happypack-tests.ts | 6 +- types/happypack/index.d.ts | 2 +- types/har-format/index.d.ts | 62 +- types/har-format/test/har-format-tests.ts | 88 +- .../hard-source-webpack-plugin-tests.ts | 24 +- types/hard-source-webpack-plugin/index.d.ts | 12 +- types/hark/hark-tests.ts | 14 +- types/hark/index.d.ts | 6 +- types/harmon/harmon-tests.ts | 6 +- types/harmon/index.d.ts | 6 +- types/harmony-proxy/harmony-proxy-tests.ts | 6 +- types/harmony-proxy/index.d.ts | 32 +- types/has-bigints/has-bigints-tests.ts | 2 +- types/has-package-exports/conditional.d.ts | 2 +- .../has-package-exports-tests.ts | 14 +- types/has-package-exports/index.d.ts | 2 +- types/has-package-exports/pattern.d.ts | 2 +- .../has-package-self-reference-tests.ts | 6 +- types/has-package-self-reference/index.d.ts | 2 +- types/has-symbols/has-symbols-tests.ts | 4 +- types/has-values/has-values-tests.ts | 8 +- types/has/has-tests.ts | 16 +- types/hasbin/hasbin-tests.ts | 20 +- types/hash-chain/hash-chain-tests.ts | 2 +- types/hash-file/hash-file-tests.ts | 6 +- types/hash-stream/hash-stream-tests.ts | 14 +- types/hash-stream/index.d.ts | 14 +- types/hasher/hasher-tests.ts | 16 +- types/hasher/index.d.ts | 4 +- types/hashmap/hashmap-tests.ts | 4 +- types/hashmap/index.d.ts | 4 +- types/hashmap/v1/hashmap-tests.ts | 16 +- types/hashmap/v1/index.d.ts | 19 +- types/hashring/hashring-tests.ts | 26 +- types/hashring/index.d.ts | 223 +- types/hashset/hashset-tests.ts | 2 - types/hashset/index.d.ts | 15 +- types/hashtable/hashtable-tests.ts | 2 - types/hashtable/index.d.ts | 17 +- types/hast/hast-tests.ts | 82 +- types/hast/index.d.ts | 12 +- types/hast/v2/hast-tests.ts | 42 +- types/hast/v2/index.d.ts | 12 +- types/hasura/hasura-tests.ts | 82 +- types/hasura/index.d.ts | 310 +- types/hat/hat-tests.ts | 8 +- types/haversine/haversine-tests.ts | 62 +- types/haversine/index.d.ts | 29 +- types/hawk/hawk-tests.ts | 38 +- types/hawk/index.d.ts | 10 +- types/hawk/lib/browser.d.ts | 6 +- types/hawk/lib/client.d.ts | 8 +- types/hawk/lib/crypto.d.ts | 4 +- types/hawk/lib/server.d.ts | 12 +- types/hawk/lib/utils.d.ts | 6 +- .../haxball-headless-browser-tests.ts | 2 +- types/haxball-headless-browser/index.d.ts | 6 +- types/hbs/hbs-tests.ts | 20 +- types/hbs/index.d.ts | 2 +- .../hcaptcha__react-hcaptcha-tests.tsx | 4 +- types/hcaptcha__react-hcaptcha/index.d.ts | 6 +- .../hcaptcha__vue-hcaptcha-tests.ts | 12 +- types/hcaptcha__vue-hcaptcha/index.d.ts | 28 +- types/hdkey/hdkey-tests.ts | 14 +- types/he/he-tests.ts | 56 +- types/he/index.d.ts | 58 +- types/headroom/headroom-tests.ts | 14 +- types/heap/heap-tests.ts | 8 +- types/heap/index.d.ts | 6 +- types/heapdump/heapdump-tests.ts | 18 +- types/heapdump/index.d.ts | 5 +- types/heatmap.js/heatmap.js-tests.ts | 63 +- types/heatmap.js/index.d.ts | 34 +- types/heft-jest/mocked.d.ts | 26 +- types/heic-convert/heic-convert-tests.ts | 10 +- types/heic-convert/index.d.ts | 2 +- types/heic-decode/heic-decode-tests.ts | 2 +- types/hellojs/hellojs-tests.ts | 162 +- types/hellojs/index.d.ts | 34 +- .../hellosign-embedded-tests.ts | 24 +- types/hellosign-embedded/index.d.ts | 154 +- types/hellosign-sdk/hellosign-sdk-tests.ts | 370 +- types/hellosign-sdk/index.d.ts | 300 +- types/hepburn/hepburn-tests.ts | 44 +- types/heredatalens/heredatalens-tests.ts | 213 +- types/heredatalens/index.d.ts | 101 +- types/heremaps/heremaps-tests.ts | 74 +- types/heremaps/index.d.ts | 985 +++- types/heroku-client/heroku-client-tests.ts | 18 +- types/heroku-client/index.d.ts | 16 +- types/heroku-logger/heroku-logger-tests.ts | 16 +- types/hex-array/hex-array-tests.ts | 4 +- .../hex-color-regex/hex-color-regex-tests.ts | 2 +- types/hex-rgba/hex-rgba-tests.ts | 6 +- types/hex-to-uuid/hex-to-uuid-tests.ts | 4 +- types/hex2dec/hex2dec-tests.ts | 12 +- types/hexo-fs/hexo-fs-tests.ts | 28 +- types/hexo-fs/index.d.ts | 206 +- types/hexo-log/hexo-log-tests.ts | 28 +- types/hexo-log/index.d.ts | 8 +- types/hexo-util/hexo-util-tests.ts | 371 +- types/hexo-util/index.d.ts | 38 +- types/hexo/hexo-tests.ts | 266 +- types/hexo/index.d.ts | 74 +- types/hh-mm-ss/hh-mm-ss-tests.ts | 14 +- types/hid/hid-tests.ts | 4 +- types/hidefile/index.d.ts | 20 +- types/hidefile/test/hidefile-tests.cjs.ts | 2 +- types/hifo/hifo-tests.ts | 38 +- types/hifo/index.d.ts | 8 +- types/hig__button/hig__button-tests.tsx | 8 +- types/hig__button/index.d.ts | 24 +- types/highcharts-ng/highcharts-ng-tests.ts | 29 +- types/highcharts-ng/index.d.ts | 28 +- types/highland/highland-tests.ts | 51 +- types/highland/index.d.ts | 50 +- .../highlight-words-core-tests.ts | 6 +- types/highlightjs/highlightjs-tests.ts | 2 +- types/highlightjs/index.d.ts | 18 +- types/hijackresponse/hijackresponse-tests.ts | 4 +- types/hijackresponse/index.d.ts | 8 +- types/hippy__react/hippy__react-tests.tsx | 56 +- types/hippy__react/index.d.ts | 124 +- types/hiredis/hiredis-tests.ts | 2 +- types/hiredis/index.d.ts | 8 +- types/history-events/history-events-tests.ts | 28 +- types/history.js/history.js-tests.ts | 10 +- types/history.js/index.d.ts | 10 +- types/historykana/historykana-tests.ts | 2 +- types/hjson/hjson-tests.ts | 12 +- types/hjson/index.d.ts | 108 +- types/hl7/events/adt.event.d.ts | 6 +- types/hl7/events/base.event.d.ts | 4 +- types/hl7/events/index.d.ts | 12 +- types/hl7/events/omg.event.d.ts | 32 +- types/hl7/events/orm.event.d.ts | 36 +- types/hl7/events/oru.event.d.ts | 32 +- types/hl7/events/siu.event.d.ts | 4 +- types/hl7/hl7-tests.ts | 64 +- types/hl7/index.d.ts | 4 +- types/hl7/segments/ail.segment.d.ts | 24 +- types/hl7/segments/ais.segment.d.ts | 24 +- types/hl7/segments/index.d.ts | 16 +- types/hl7/segments/msh.segment.d.ts | 42 +- types/hl7/segments/obr.segment.d.ts | 96 +- types/hl7/segments/obx.segment.d.ts | 40 +- types/hl7/segments/orc.segment.d.ts | 62 +- types/hl7/segments/pid.segment.d.ts | 106 +- types/hl7/segments/pv1.segment.d.ts | 100 +- types/hls-parser/hls-parser-tests.ts | 22 +- types/hls-parser/index.d.ts | 32 +- types/hmac-blake2b/hmac-blake2b-tests.ts | 2 +- .../hmscore__react-native-hms-push/index.d.ts | 32 +- .../src/HmsPushEvent.d.ts | 26 +- .../src/HmsPushResultCode.d.ts | 168 +- .../src/LocalNotification/Importance.d.ts | 14 +- .../LocalNotificationAttributes.d.ts | 72 +- .../src/LocalNotification/Priority.d.ts | 10 +- .../src/LocalNotification/RepeatType.d.ts | 10 +- .../src/LocalNotification/Visibility.d.ts | 6 +- .../src/LocalNotification/index.d.ts | 10 +- .../src/RNRemoteMessage.d.ts | 90 +- .../src/RemoteDataMessage.d.ts | 4 +- .../src/RemoteMessageBuilder.d.ts | 16 +- .../src/ResultResponse.d.ts | 2 +- .../test/backgroundHandler-test.tsx | 10 +- .../test/localnotification-test.tsx | 128 +- .../test/main-test.tsx | 154 +- types/hoek/hoek-tests.ts | 94 +- types/hogan.js/hogan.js-tests.ts | 10 +- types/hogan.js/index.d.ts | 8 +- .../hoist-non-react-statics-tests.tsx | 34 +- types/hoist-non-react-statics/index.d.ts | 30 +- types/holderjs/holderjs-tests.ts | 4 +- types/honeybadger/honeybadger-tests.ts | 18 +- types/honeybadger/index.d.ts | 4 +- types/hooker/hooker-tests.ts | 70 +- types/hooker/index.d.ts | 13 +- types/hookrouter/hookrouter-tests.ts | 44 +- types/hookrouter/index.d.ts | 2 +- types/hopscotch/hopscotch-tests.ts | 94 +- types/hopscotch/index.d.ts | 274 +- .../host-validation/host-validation-tests.ts | 50 +- types/host-validation/index.d.ts | 11 +- .../hosted-git-info/hosted-git-info-tests.ts | 20 +- types/hosted-git-info/index.d.ts | 26 +- types/hostile/hostile-tests.ts | 12 +- types/hostile/index.d.ts | 4 +- .../hot-formula-parser-tests.ts | 46 +- types/hot-formula-parser/index.d.mts | 2 +- types/hot-formula-parser/index.d.ts | 796 +-- types/howler/howler-tests.ts | 28 +- types/howler/index.d.ts | 64 +- types/howler/test/globals.ts | 10 +- types/hoxy/hoxy-tests.ts | 18 +- types/hoxy/index.d.ts | 14 +- types/hpp/hpp-tests.ts | 10 +- types/hpp/index.d.ts | 2 +- types/hsl-to-hex/hsl-to-hex-tests.ts | 2 +- .../hsl-to-rgb-for-reals-tests.ts | 2 +- types/hsl-to-rgb-for-reals/index.d.ts | 6 +- types/html-docx-js/html-docx-js-tests.ts | 8 +- types/html-docx-js/index.d.ts | 2 +- .../html-encoding-sniffer-tests.ts | 6 +- .../html-entities-decoder-tests.ts | 2 +- types/html-entities-decoder/index.d.ts | 4 +- types/html-escape/html-escape-tests.ts | 4 +- types/html-escape/v1/html-escape-tests.ts | 4 +- types/html-escaper/html-escaper-tests.ts | 2 +- .../html-minifier-terser-tests.ts | 14 +- types/html-minifier/html-minifier-tests.ts | 8 +- types/html-minifier/index.d.ts | 6 +- types/html-minifier/v1/html-minifier-tests.ts | 7 +- types/html-minifier/v1/index.d.ts | 6 +- types/html-parser/html-parser-tests.ts | 24 +- types/html-parser/index.d.ts | 9 +- types/html-pdf-node/html-pdf-node-tests.ts | 8 +- types/html-pdf/html-pdf-tests.ts | 14 +- types/html-pdf/index.d.ts | 198 +- .../html-replace-webpack-plugin-tests.ts | 32 +- types/html-replace-webpack-plugin/index.d.ts | 2 +- types/html-tableify/html-tableify-tests.ts | 66 +- types/html-tableify/index.d.ts | 2 +- .../html-to-draftjs/html-to-draftjs-tests.ts | 6 +- types/html-to-draftjs/index.d.ts | 5 +- .../html-to-pdfmake/html-to-pdfmake-tests.ts | 4 +- types/html-to-pdfmake/index.d.ts | 8 +- types/html-to-rtf/html-to-rtf-tests.ts | 4 +- types/html-to-text/html-to-text-tests.ts | 207 +- types/html-to-text/index.d.ts | 37 +- .../html-to-text/lib/block-text-builder.d.ts | 4 +- types/html-truncate/html-truncate-tests.ts | 14 +- types/html-validator/html-validator-tests.ts | 12 +- types/html-validator/index.d.ts | 64 +- .../html-webpack-plugin-tests.ts | 88 +- types/html-webpack-plugin/index.d.ts | 40 +- .../html-webpack-template-tests.ts | 46 +- types/html-webpack-template/index.d.ts | 2 +- types/html/html-tests.ts | 14 +- types/html/index.d.ts | 4 +- types/html2json/html2json-tests.ts | 14 +- types/html2json/index.d.ts | 2 +- types/html4-id/test/html4-id-tests.cjs.ts | 4 +- types/html4-id/test/html4-id-tests.global.ts | 2 +- types/html5-history/html5-history-tests.ts | 2 +- types/html5-to-pdf/html5-to-pdf-tests.ts | 4 +- types/html5-to-pdf/index.d.ts | 6 +- types/html5plus/index.d.ts | 5062 +++++++++-------- .../html_codesniffer-tests.ts | 10 +- types/html_codesniffer/index.d.ts | 2 +- .../htmlbars-inline-precompile-tests.ts | 2 +- types/htmlhint/htmlhint-tests.ts | 34 +- types/htmlhint/index.d.ts | 10 +- types/htmlhint/reporter.d.ts | 2 +- types/htmlhint/rules.d.ts | 2 +- types/htmlhint/types.d.ts | 92 +- types/htmlparser2/htmlparser2-tests.ts | 10 +- types/htmlparser2/index.d.ts | 21 +- types/htmltojsx/htmltojsx-tests.ts | 6 +- types/htmltojsx/index.d.ts | 1 - types/http-agent/http-agent-tests.ts | 24 +- types/http-agent/index.d.ts | 4 +- types/http-assert/http-assert-tests.ts | 42 +- types/http-auth/index.d.ts | 23 +- types/http-auth/test/http-auth-tests.basic.ts | 10 +- .../test/http-auth-tests.basic_nofile.ts | 10 +- .../http-auth/test/http-auth-tests.digest.ts | 22 +- .../test/http-auth-tests.digest_nofile.ts | 10 +- .../http-auth/test/http-auth-tests.events.ts | 16 +- types/http-auth/test/http-auth-tests.https.ts | 16 +- types/http-auth/test/http-auth-tests.proxy.ts | 18 +- types/http-aws-es/index.d.ts | 2 +- .../http-build-query-tests.ts | 8 +- .../http-cache-semantics-tests.ts | 6 +- types/http-cache-semantics/index.d.ts | 2 +- types/http-codes/http-codes-tests.ts | 2 +- types/http-context/http-context-tests.ts | 20 +- types/http-context/index.d.ts | 6 +- types/http-errors/http-errors-tests.ts | 64 +- types/http-errors/index.d.ts | 94 +- types/http-headers/http-headers-tests.ts | 14 +- types/http-headers/index.d.ts | 4 +- .../http-link-header-tests.ts | 36 +- types/http-proxy/http-proxy-tests.ts | 320 +- types/http-proxy/index.d.ts | 59 +- types/http-rx/http-rx-tests.ts | 18 +- types/http-rx/index.d.ts | 4 +- types/http-server/http-server-tests.ts | 4 +- types/http-server/index.d.ts | 2 +- .../http-string-parser-tests.ts | 6 +- types/http-string-parser/index.d.ts | 1 - .../http-terminator/http-terminator-tests.ts | 6 +- types/http-terminator/index.d.ts | 4 +- types/httperr/httperr-tests.ts | 22 +- types/httperr/index.d.ts | 14 +- types/httpsnippet/httpsnippet-tests.ts | 10 +- types/httpsnippet/index.d.ts | 2 +- types/hubot/hubot-tests.ts | 40 +- types/hubot/index.d.ts | 8 +- types/hubspot-pace/hubspot-pace-tests.ts | 40 +- types/hubspot-pace/index.d.ts | 8 +- types/hull.js/hull.js-tests.ts | 4 +- .../human-crypto-keys-tests.ts | 6 +- types/human-crypto-keys/index.d.ts | 13 +- types/human-date/human-date-tests.ts | 8 +- types/human-date/index.d.ts | 6 +- types/human-format/human-format-tests.ts | 14 +- types/human-format/index.d.ts | 4 +- types/humane-js/humane-js-tests.ts | 32 +- types/humanize-ms/humanize-ms-tests.ts | 4 +- types/humanize-ms/index.d.ts | 2 +- types/humanize-plus/humanize-plus-tests.ts | 28 +- types/humanparser/humanparser-tests.ts | 6 +- types/humanparser/index.d.ts | 7 +- ...bee__styled-components-breakpoint-tests.ts | 2 +- .../index.d.ts | 26 +- .../hummer-env/components/BaseComponent.d.ts | 10 +- types/hummer-env/components/Button.d.ts | 2 +- types/hummer-env/components/CanvasView.d.ts | 2 +- .../components/HorizontalScroller.d.ts | 2 +- types/hummer-env/components/Image.d.ts | 4 +- types/hummer-env/components/Input.d.ts | 2 +- types/hummer-env/components/List.d.ts | 2 +- types/hummer-env/components/Scroller.d.ts | 2 +- types/hummer-env/components/Switch.d.ts | 2 +- types/hummer-env/components/Text.d.ts | 4 +- types/hummer-env/components/TextArea.d.ts | 2 +- types/hummer-env/components/View.d.ts | 2 +- types/hummer-env/components/ViewPager.d.ts | 2 +- types/hummer-env/hummer-env-tests.ts | 56 +- types/hummer-env/index.d.ts | 47 +- types/hummer-env/interface/event.ts | 40 +- types/hummer-env/interface/info.ts | 26 +- types/hummer-env/interface/style.d.ts | 54 +- types/hummus-recipe/hummus-recipe-tests.ts | 36 +- types/hummus-recipe/index.d.ts | 74 +- types/humps/index.d.ts | 44 +- types/humps/test/humps-tests.cjs.ts | 46 +- types/humps/test/humps-tests.global.ts | 42 +- .../hunspell-spellchecker-tests.ts | 14 +- types/hyco-ws/hyco-ws-tests.ts | 24 +- types/hyco-ws/index.d.ts | 4 +- types/hydra-box/Api.d.ts | 6 +- types/hydra-box/StoreResourceLoader.d.ts | 4 +- types/hydra-box/hydra-box-tests.ts | 80 +- types/hydra-box/index.d.ts | 16 +- types/hydra-box/middleware.d.ts | 14 +- .../hyggedyne__scrabbleify-tests.ts | 8 +- types/hyper-aws4/hyper-aws4-tests.ts | 6 +- types/hyper-function-component/index.d.ts | 30 +- .../hyperdeck-js-lib-tests.ts | 36 +- types/hyperdeck-js-lib/index.d.ts | 128 +- types/hyperscript/hyperscript-tests.ts | 105 +- types/hyperscript/index.d.ts | 3 +- .../hypertext-application-language-tests.ts | 4 +- types/hyphen/hyphen-tests.ts | 36 +- .../hyphenate-style-name-tests.ts | 4 +- types/hystrixjs/hystrixjs-tests.ts | 14 +- types/hystrixjs/index.d.ts | 15 +- 681 files changed, 14891 insertions(+), 13226 deletions(-) diff --git a/types/h2o2/h2o2-tests.ts b/types/h2o2/h2o2-tests.ts index 9cda55152dbe4d..fea26e3c766cc4 100644 --- a/types/h2o2/h2o2-tests.ts +++ b/types/h2o2/h2o2-tests.ts @@ -1,98 +1,97 @@ -import wreck = require('wreck'); -import h2o2 = require('h2o2'); -import hapi = require('hapi'); +import wreck = require("wreck"); +import h2o2 = require("h2o2"); +import hapi = require("hapi"); async function main() { const server = new hapi.Server({}); await server.register(h2o2); server.route({ - method: 'GET', - path: '/hproxyoptions', + method: "GET", + path: "/hproxyoptions", async handler(request, h) { // ResponseToolkit augmentation // https://github.com/hapijs/h2o2#hproxyoptions - return h.proxy({ host: 'example.com', port: 80, protocol: 'http' }); - } + return h.proxy({ host: "example.com", port: 80, protocol: "http" }); + }, }); server.route({ - method: 'GET', - path: '/using-the-host-port-protocol-options', + method: "GET", + path: "/using-the-host-port-protocol-options", handler: { // HandlerDecorations augmentation // https://github.com/hapijs/h2o2#using-the-host-port-protocol-options proxy: { - host: '10.33.33.1', - port: '443', - protocol: 'https' - } - } + host: "10.33.33.1", + port: "443", + protocol: "https", + }, + }, }); server.route({ - method: 'GET', - path: '/using-the-uri-option', + method: "GET", + path: "/using-the-uri-option", handler: { // HandlerDecorations augmentation // https://github.com/hapijs/h2o2#using-the-uri-option proxy: { - uri: 'https://some.upstream.service.com/that/has?what=you&want=todo' - } - } + uri: "https://some.upstream.service.com/that/has?what=you&want=todo", + }, + }, }); - server.route({ - method: 'GET', - path: '/custom-uri-template-values', + method: "GET", + path: "/custom-uri-template-values", handler: { // HandlerDecorations augmentation // https://github.com/hapijs/h2o2#custom-uri-template-values proxy: { - uri: '{protocol}://{host}:{port}/go/to/{path}' - } - } + uri: "{protocol}://{host}:{port}/go/to/{path}", + }, + }, }); server.route({ - method: 'GET', - path: '/custom-uri-template-values/{bar}', + method: "GET", + path: "/custom-uri-template-values/{bar}", handler: { // HandlerDecorations augmentation // https://github.com/hapijs/h2o2#custom-uri-template-values proxy: { - uri: 'https://some.upstream.service.com/some/path/to/{bar}' - } - } + uri: "https://some.upstream.service.com/some/path/to/{bar}", + }, + }, }); server.route({ - method: 'GET', - path: '/', + method: "GET", + path: "/", handler: { // HandlerDecorations augmentation // https://github.com/hapijs/h2o2#using-the-mapuri-and-onresponse-options proxy: { async mapUri(request) { - console.log('doing some additional stuff before redirecting'); + console.log("doing some additional stuff before redirecting"); return { - uri: 'https://some.upstream.service.com/' + uri: "https://some.upstream.service.com/", }; }, async onResponse(err, res, request, h, settings, ttl) { - console.log('receiving the response from the upstream.'); + console.log("receiving the response from the upstream."); const payload = await wreck.read(res, { json: true }); - console.log('some payload manipulation if you want to.') + console.log("some payload manipulation if you want to."); let response = h.response(payload); // TODO find a quicker way to do this for (let header in res.headers) { let value = res.headers[header]; if (value) { - if (typeof value === 'string') { + if (typeof value === "string") { value = [value]; } for (let v of value) { @@ -101,9 +100,9 @@ async function main() { } } return response; - } - } - } + }, + }, + }, }); await server.start(); @@ -122,35 +121,35 @@ async function main() { */ var proxyOptions: h2o2.ProxyHandlerOptions = { - host: '10.33.33.1', - port: '443', - protocol: 'https' // errors correctly if misspelt -} + host: "10.33.33.1", + port: "443", + protocol: "https", // errors correctly if misspelt +}; const badProtocolDemo: hapi.ServerRoute = { - method: 'GET', - path: '/', + method: "GET", + path: "/", handler: { proxy: { - host: '10.33.33.1', - port: '443' + host: "10.33.33.1", + port: "443", // port: null // detected as incompatible - } - } + }, + }, }; const replyViaToolkit: hapi.ServerRoute = { - method: 'GET', - path: '/', + method: "GET", + path: "/", async handler(req, h): Promise { return h.proxy({ - host: '10.33.33.1', - port: '443', - protocol: 'https' + host: "10.33.33.1", + port: "443", + protocol: "https", }); - } + }, }; if (!module.parent) { - main().then(() => console.log('done'), err => console.error(err.stack)); + main().then(() => console.log("done"), err => console.error(err.stack)); } diff --git a/types/h2o2/index.d.ts b/types/h2o2/index.d.ts index 9f9640327294c2..2190524916d830 100644 --- a/types/h2o2/index.d.ts +++ b/types/h2o2/index.d.ts @@ -6,17 +6,10 @@ /// -import http = require('http'); -import Boom = require('boom'); +import http = require("http"); +import Boom = require("boom"); -import { - Plugin, - Request, - ResponseObject, - ResponseToolkit, - Lifecycle, - RouteOptions, -} from 'hapi'; +import { Lifecycle, Plugin, Request, ResponseObject, ResponseToolkit, RouteOptions } from "hapi"; declare namespace h2o2 { /** `mapURI` return value */ @@ -35,7 +28,7 @@ declare namespace h2o2 { /** port - upstream service port. */ port?: number | string | undefined; /** protocol - protocol to use when making the request to the proxied host: */ - protocol?: 'http' | 'https' | undefined; + protocol?: "http" | "https" | undefined; /** uri - absolute URI used instead of host, port, protocol, path, and query. Cannot be used with host, port, protocol, or mapUri. */ uri?: string | undefined; /** passThrough - if set to true, it forwards the headers from the client to the upstream service, headers sent from the upstream service will also be forwarded to the client. Defaults to false. */ @@ -54,7 +47,7 @@ declare namespace h2o2 { timeout?: number | undefined; /** mapUri - a function used to map the request URI to the target `uri` and optional `headers` with which to make that request. Cannot be used together with `host`, `port`, `protocol`, or `uri`. * @param request - is the incoming request object. - */ + */ mapUri?: ((this: ProxyHandlerOptions, request: Request) => Promise) | undefined; /** * onResponse - a custom function for processing the response from the upstream service before sending to the client. Useful for custom error handling of responses from the proxied endpoint or other payload manipulation. @@ -65,15 +58,19 @@ declare namespace h2o2 { * @param settings - the proxy handler configuration. * @param ttl - the upstream TTL in milliseconds if proxy.ttl it set to 'upstream' and the upstream response included a valid 'Cache-Control' header with 'max-age'. */ - onResponse?: ((this: RouteOptions, - err: null | Boom, - res: http.IncomingMessage, - req: Request, - h: ResponseToolkit, - settings: ProxyHandlerOptions, - ttl: number) => Lifecycle.ReturnValue) | undefined; + onResponse?: + | (( + this: RouteOptions, + err: null | Boom, + res: http.IncomingMessage, + req: Request, + h: ResponseToolkit, + settings: ProxyHandlerOptions, + ttl: number, + ) => Lifecycle.ReturnValue) + | undefined; /** ttl - if set to 'upstream', applies the upstream response caching policy to the response using the response.ttl() method (or passed as an argument to the onResponse method if provided). */ - ttl?: 'upstream' | undefined; + ttl?: "upstream" | undefined; /** agent - a node http(s) agent to be used for connections to upstream server. @see {@link https://nodejs.org/api/http.html#http_class_http_agent} */ agent?: http.Agent | undefined; /** maxSockets - sets the maximum number of sockets available per outgoing proxy host connection. false means use the wreck module default value (Infinity). Does not affect non-proxy outgoing client connections. Defaults to Infinity. */ @@ -81,7 +78,7 @@ declare namespace h2o2 { } } -declare module 'hapi' { +declare module "hapi" { interface HandlerDecorations { /** * Proxies the request to an upstream endpoint. diff --git a/types/hafas-client/hafas-client-tests.ts b/types/hafas-client/hafas-client-tests.ts index 2002a23ff731db..8a5a724ed2c79d 100644 --- a/types/hafas-client/hafas-client-tests.ts +++ b/types/hafas-client/hafas-client-tests.ts @@ -1,115 +1,142 @@ -import { createClient, HafasClient, Profile } from 'hafas-client/index'; +import { createClient, HafasClient, Profile } from "hafas-client/index"; -import { profile as avvProfile } from 'hafas-client/p/avv/index'; -import { profile as bartProfile } from 'hafas-client/p/bart/index'; -import { profile as blsProfile } from 'hafas-client/p/bls/index'; -import { profile as bvgProfile } from 'hafas-client/p/bvg/index'; -import { profile as cflProfile } from 'hafas-client/p/cfl/index'; -import { profile as cmtaProfile } from 'hafas-client/p/cmta/index'; -import { profile as dartProfile } from 'hafas-client/p/dart/index'; -import { profile as dbProfile } from 'hafas-client/p/db/index'; -import { profile as dbbusradarnrwProfile } from 'hafas-client/p/db-busradar-nrw/index'; -import { profile as hvvProfile } from 'hafas-client/p/hvv/index'; -import { profile as insaProfile } from 'hafas-client/p/insa/index'; -import { profile as invgProfile } from 'hafas-client/p/invg/index'; -import { profile as irishrailProfile } from 'hafas-client/p/irish-rail/index'; -import { profile as ivbProfile } from 'hafas-client/p/ivb/index'; -import { profile as kvbProfile } from 'hafas-client/p/kvb/index'; -import { profile as mobilnrwProfile } from 'hafas-client/p/mobil-nrw/index'; -import { profile as mobiliteitluProfile } from 'hafas-client/p/mobiliteit-lu/index'; -import { profile as nahshProfile } from 'hafas-client/p/nahsh/index'; -import { profile as nvvProfile } from 'hafas-client/p/nvv/index'; -import { profile as oebbProfile } from 'hafas-client/p/oebb/index'; -import { profile as ooevvProfile } from 'hafas-client/p/ooevv/index'; -import { profile as pkpProfile } from 'hafas-client/p/pkp/index'; -import { profile as rejseplanenProfile } from 'hafas-client/p/rejseplanen/index'; -import { profile as rmvProfile } from 'hafas-client/p/rmv/index'; -import { profile as rsagProfile } from 'hafas-client/p/rsag/index'; -import { profile as saarfahrplanProfile } from 'hafas-client/p/saarfahrplan/index'; -import { profile as salzburgProfile } from 'hafas-client/p/salzburg/index'; -import { profile as sbahnmuenchenProfile } from 'hafas-client/p/sbahn-muenchen/index'; -import { profile as sncbProfile } from 'hafas-client/p/sncb/index'; -import { profile as stvProfile } from 'hafas-client/p/stv/index'; -import { profile as svvProfile } from 'hafas-client/p/svv/index'; -import { profile as tpgProfile } from 'hafas-client/p/tpg/index'; -import { profile as vbbProfile } from 'hafas-client/p/vbb/index'; -import { profile as vbnProfile } from 'hafas-client/p/vbn/index'; -import { profile as vkgProfile } from 'hafas-client/p/vkg/index'; -import { profile as vmtProfile } from 'hafas-client/p/vmt/index'; -import { profile as vorProfile } from 'hafas-client/p/vor/index'; -import { profile as vosProfile } from 'hafas-client/p/vos/index'; -import { profile as vrnProfile } from 'hafas-client/p/vrn/index'; -import { profile as vsnProfile } from 'hafas-client/p/vsn/index'; -import { profile as vvtProfile } from 'hafas-client/p/vvt/index'; -import { profile as vvvProfile } from 'hafas-client/p/vvv/index'; -import { profile as zvvProfile } from 'hafas-client/p/zvv/index'; +import { profile as avvProfile } from "hafas-client/p/avv/index"; +import { profile as bartProfile } from "hafas-client/p/bart/index"; +import { profile as blsProfile } from "hafas-client/p/bls/index"; +import { profile as bvgProfile } from "hafas-client/p/bvg/index"; +import { profile as cflProfile } from "hafas-client/p/cfl/index"; +import { profile as cmtaProfile } from "hafas-client/p/cmta/index"; +import { profile as dartProfile } from "hafas-client/p/dart/index"; +import { profile as dbbusradarnrwProfile } from "hafas-client/p/db-busradar-nrw/index"; +import { profile as dbProfile } from "hafas-client/p/db/index"; +import { profile as hvvProfile } from "hafas-client/p/hvv/index"; +import { profile as insaProfile } from "hafas-client/p/insa/index"; +import { profile as invgProfile } from "hafas-client/p/invg/index"; +import { profile as irishrailProfile } from "hafas-client/p/irish-rail/index"; +import { profile as ivbProfile } from "hafas-client/p/ivb/index"; +import { profile as kvbProfile } from "hafas-client/p/kvb/index"; +import { profile as mobilnrwProfile } from "hafas-client/p/mobil-nrw/index"; +import { profile as mobiliteitluProfile } from "hafas-client/p/mobiliteit-lu/index"; +import { profile as nahshProfile } from "hafas-client/p/nahsh/index"; +import { profile as nvvProfile } from "hafas-client/p/nvv/index"; +import { profile as oebbProfile } from "hafas-client/p/oebb/index"; +import { profile as ooevvProfile } from "hafas-client/p/ooevv/index"; +import { profile as pkpProfile } from "hafas-client/p/pkp/index"; +import { profile as rejseplanenProfile } from "hafas-client/p/rejseplanen/index"; +import { profile as rmvProfile } from "hafas-client/p/rmv/index"; +import { profile as rsagProfile } from "hafas-client/p/rsag/index"; +import { profile as saarfahrplanProfile } from "hafas-client/p/saarfahrplan/index"; +import { profile as salzburgProfile } from "hafas-client/p/salzburg/index"; +import { profile as sbahnmuenchenProfile } from "hafas-client/p/sbahn-muenchen/index"; +import { profile as sncbProfile } from "hafas-client/p/sncb/index"; +import { profile as stvProfile } from "hafas-client/p/stv/index"; +import { profile as svvProfile } from "hafas-client/p/svv/index"; +import { profile as tpgProfile } from "hafas-client/p/tpg/index"; +import { profile as vbbProfile } from "hafas-client/p/vbb/index"; +import { profile as vbnProfile } from "hafas-client/p/vbn/index"; +import { profile as vkgProfile } from "hafas-client/p/vkg/index"; +import { profile as vmtProfile } from "hafas-client/p/vmt/index"; +import { profile as vorProfile } from "hafas-client/p/vor/index"; +import { profile as vosProfile } from "hafas-client/p/vos/index"; +import { profile as vrnProfile } from "hafas-client/p/vrn/index"; +import { profile as vsnProfile } from "hafas-client/p/vsn/index"; +import { profile as vvtProfile } from "hafas-client/p/vvt/index"; +import { profile as vvvProfile } from "hafas-client/p/vvv/index"; +import { profile as zvvProfile } from "hafas-client/p/zvv/index"; const choose = (p: string): Profile => { switch (p) { - case 'bvgProfile': return bvgProfile; - case 'cflProfile': return cflProfile; - case 'cmtaProfile': return cmtaProfile; - case 'dbProfile': return dbProfile; - case 'dbbusradarnrwProfile': return dbbusradarnrwProfile; - case 'hvvProfile': return hvvProfile; - case 'insaProfile': return insaProfile; - case 'invgProfile': return invgProfile; - case 'mobiliteitProfile': return mobiliteitluProfile; - case 'nahshProfile': return nahshProfile; - case 'nvvProfile': return nvvProfile; - case 'oebbProfile': return oebbProfile; - case 'pkpProfile': return pkpProfile; - case 'rmvProfile': return rmvProfile; - case 'rsagProfile': return rsagProfile; - case 'saarfahrplanProfile': return saarfahrplanProfile; - case 'sbahnmuenchenProfile': return sbahnmuenchenProfile; - case 'sncbProfile': return sncbProfile; - case 'svvProfile': return svvProfile; - case 'vbbProfile': return vbbProfile; - case 'vbnProfile': return vbnProfile; - case 'vmtProfile': return vmtProfile; - case 'vrnProfile': return vrnProfile; - case 'vsnProfile': return vsnProfile; - case 'zvvProfile': return zvvProfile; - case 'rejseplanenProfile': return rejseplanenProfile; - default: return dbProfile; + case "bvgProfile": + return bvgProfile; + case "cflProfile": + return cflProfile; + case "cmtaProfile": + return cmtaProfile; + case "dbProfile": + return dbProfile; + case "dbbusradarnrwProfile": + return dbbusradarnrwProfile; + case "hvvProfile": + return hvvProfile; + case "insaProfile": + return insaProfile; + case "invgProfile": + return invgProfile; + case "mobiliteitProfile": + return mobiliteitluProfile; + case "nahshProfile": + return nahshProfile; + case "nvvProfile": + return nvvProfile; + case "oebbProfile": + return oebbProfile; + case "pkpProfile": + return pkpProfile; + case "rmvProfile": + return rmvProfile; + case "rsagProfile": + return rsagProfile; + case "saarfahrplanProfile": + return saarfahrplanProfile; + case "sbahnmuenchenProfile": + return sbahnmuenchenProfile; + case "sncbProfile": + return sncbProfile; + case "svvProfile": + return svvProfile; + case "vbbProfile": + return vbbProfile; + case "vbnProfile": + return vbnProfile; + case "vmtProfile": + return vmtProfile; + case "vrnProfile": + return vrnProfile; + case "vsnProfile": + return vsnProfile; + case "zvvProfile": + return zvvProfile; + case "rejseplanenProfile": + return rejseplanenProfile; + default: + return dbProfile; } }; -const client: HafasClient = createClient(choose('dbProfile'), 'client'); +const client: HafasClient = createClient(choose("dbProfile"), "client"); client.locations("", { results: 1 }) - .then(locations => { /* ... */ }) - .catch(() => { /* ... */ }); + .then(locations => {/* ... */}) + .catch(() => {/* ... */}); -client.journeys("", "", { results: 1, subStops: true, age: 65, routingMode: 'REALTIME' }) +client.journeys("", "", { results: 1, subStops: true, age: 65, routingMode: "REALTIME" }) .then(journeys => { if (journeys.journeys && journeys.journeys[0].legs.length > 0) { - if (journeys.journeys[0].legs[0].prognosedArrival === 'prognosed') { /* ... */ } + if (journeys.journeys[0].legs[0].prognosedArrival === "prognosed") { /* ... */ } } }) - .catch(() => { /* ... */ }); + .catch(() => {/* ... */}); if (client.radar) { client.radar({ north: 0, south: 0, west: 0, east: 0 }, { results: 1, duration: 10 }) - .then(movements => { /* ... */ }) - .catch(() => { /* ... */ }); + .then(movements => {/* ... */}) + .catch(() => {/* ... */}); } if (client.lines) { - client.lines('x', {}) - .then(lines => { /* ... */ }) - .catch(() => { /* ... */ }); + client.lines("x", {}) + .then(lines => {/* ... */}) + .catch(() => {/* ... */}); } if (client.serverInfo) { client.serverInfo({ versionInfo: true }) - .then(serverInfo => { /* ... */ }) - .catch(() => { /* ... */ }); + .then(serverInfo => {/* ... */}) + .catch(() => {/* ... */}); } if (client.journeysFromTrip) { - client.journeysFromTrip('x', { stop: { type: 'stop' } }, 'y', {}) - .then(journeys => { /* ... */ }) - .catch(() => { /* ... */ }); + client.journeysFromTrip("x", { stop: { type: "stop" } }, "y", {}) + .then(journeys => {/* ... */}) + .catch(() => {/* ... */}); } diff --git a/types/hafas-client/index.d.ts b/types/hafas-client/index.d.ts index c81ec0fc027784..b7fcc395b2c6ea 100644 --- a/types/hafas-client/index.d.ts +++ b/types/hafas-client/index.d.ts @@ -10,7 +10,7 @@ */ export interface ProductType { id: string; - mode: 'train' | 'bus' | 'watercraft' | 'taxi' | 'gondola' | 'aircraft' | 'car' | 'bicycle' | 'walking'; + mode: "train" | "bus" | "watercraft" | "taxi" | "gondola" | "aircraft" | "car" | "bicycle" | "walking"; name: string; short: string; bitmasks: number[]; @@ -40,7 +40,7 @@ export interface Profile { * A location object is used by other items to indicate their locations. */ export interface Location { - type: 'location'; + type: "location"; id?: string; name?: string; poi?: boolean; @@ -73,7 +73,7 @@ export interface ReisezentrumOpeningHours { * that may span across multiple levels or buildings. */ export interface Station { - type: 'station'; + type: "station"; id?: string; name?: string; station?: Station; @@ -101,7 +101,7 @@ export interface Ids { * A stop always belongs to a station. It may for example be a sign, a basic shelter or a railway platform. */ export interface Stop { - type: 'stop'; + type: "stop"; id?: string; name?: string; location?: Location; @@ -120,14 +120,14 @@ export interface Stop { * A region is a group of stations, for example a metropolitan area or a geographical or cultural region. */ export interface Region { - type: 'region'; + type: "region"; id: string; name: string; /** station ids */ stations: ReadonlyArray; } export interface Line { - type: 'line'; + type: "line"; id?: string; name?: string; adminCode?: string; @@ -135,7 +135,7 @@ export interface Line { additionalName?: string; product?: string; public?: boolean; - mode?: 'train' | 'bus' | 'watercraft' | 'taxi' | 'gondola' | 'aircraft' | 'car' | 'bicycle' | 'walking'; + mode?: "train" | "bus" | "watercraft" | "taxi" | "gondola" | "aircraft" | "car" | "bicycle" | "walking"; /** routes ids */ routes?: ReadonlyArray; operator?: Operator; @@ -154,10 +154,10 @@ export interface RealtimeDataUpdatedAt { * A route represents a single set of stations, of a single line. */ export interface Route { - type: 'route'; + type: "route"; id: string; line: string; - mode: 'train' | 'bus' | 'watercraft' | 'taxi' | 'gondola' | 'aircraft' | 'car' | 'bicycle' | 'walking'; + mode: "train" | "bus" | "watercraft" | "taxi" | "gondola" | "aircraft" | "car" | "bicycle" | "walking"; /** stop ids */ stops: ReadonlyArray; } @@ -176,28 +176,28 @@ export interface ArrivalDeparture { * It is specifically geared towards urban public transport, with frequent trains and homogenous travels. */ export interface Schedule { - type: 'schedule'; + type: "schedule"; id: string; route: string; - mode: 'train' | 'bus' | 'watercraft' | 'taxi' | 'gondola' | 'aircraft' | 'car' | 'bicycle' | 'walking'; + mode: "train" | "bus" | "watercraft" | "taxi" | "gondola" | "aircraft" | "car" | "bicycle" | "walking"; sequence: ReadonlyArray; /** array of Unix timestamps */ starts: ReadonlyArray; } export interface Operator { - type: 'operator'; + type: "operator"; id: string; name: string; } export interface Hint { - type: 'hint' | 'status' | 'foreign-id' | 'local-fare-zone' | 'stop-website' | 'stop-dhid' | 'transit-authority'; + type: "hint" | "status" | "foreign-id" | "local-fare-zone" | "stop-website" | "stop-dhid" | "transit-authority"; code?: string; summary?: string; text: string; tripId?: string; } export interface Status { - type: 'hint' | 'status' | 'foreign-id' | 'local-fare-zone' | 'stop-website' | 'stop-dhid' | 'transit-authority'; + type: "hint" | "status" | "foreign-id" | "local-fare-zone" | "stop-website" | "stop-dhid" | "transit-authority"; code?: string; summary?: string; text: string; @@ -223,7 +223,7 @@ export interface Event { sections?: string[]; } export interface Warning { - type: 'status' | 'warning'; + type: "status" | "warning"; id?: string; icon?: object; summary?: string; @@ -243,19 +243,19 @@ export interface Warning { toStops?: ReadonlyArray; } export interface Geometry { - type: 'Point'; + type: "Point"; coordinates: number[]; } export interface Feature { - type: 'Feature'; + type: "Feature"; properties: Station | Stop | Location | object; geometry: Geometry; } export interface FeatureCollection { - type: 'FeatureCollection'; + type: "FeatureCollection"; features: ReadonlyArray; } -export type PrognosisType = 'prognosed' | 'calculated'; +export type PrognosisType = "prognosed" | "calculated"; /** * A stopover represents a vehicle stopping at a stop/station at a specific time. */ @@ -423,7 +423,7 @@ export interface ScheduledDays { * It would typically be the result of a route planning algorithm. */ export interface Journey { - type: 'journey'; + type: "journey"; legs: ReadonlyArray; refreshToken?: string; remarks?: ReadonlyArray; @@ -581,8 +581,8 @@ export interface LoyaltyCard { discount?: number; class?: number; } -export type AgeGroup = 'B' | 'K' | 'Y' | 'E' | 'S'; -export type RoutingMode = 'OFF' | 'INFOS' | 'FULL' | 'REALTIME' | 'SERVER_DEFAULT' | 'HYBRID'; +export type AgeGroup = "B" | "K" | "Y" | "E" | "S"; +export type RoutingMode = "OFF" | "INFOS" | "FULL" | "REALTIME" | "SERVER_DEFAULT" | "HYBRID"; /** * JourneysOptions specific to Db Profile */ @@ -1083,13 +1083,20 @@ export interface HafasClient { * @param to uid of station * @param options options */ - journeys: (from: string | Station | Stop | Location, to: string | Station | Stop | Location, options: JourneysOptions | undefined) => Promise; + journeys: ( + from: string | Station | Stop | Location, + to: string | Station | Stop | Location, + options: JourneysOptions | undefined, + ) => Promise; /** * refreshes a Journey * @param refreshToken refreshToken must be a string, taken from {@link journey#refreshToken} * @param options options */ - refreshJourney?: (refreshToken: string, options: RefreshJourneyOptions | undefined) => Promise; + refreshJourney?: ( + refreshToken: string, + options: RefreshJourneyOptions | undefined, + ) => Promise; /** * Refetch information about a trip * @param id trip id, see {@link Leg#tripId} @@ -1102,13 +1109,19 @@ export interface HafasClient { * @param station uid of station * @param options options */ - departures: (station: string | Station | Stop | Location, options: DeparturesArrivalsOptions | undefined) => Promise; + departures: ( + station: string | Station | Stop | Location, + options: DeparturesArrivalsOptions | undefined, + ) => Promise; /** * Retrieves arrivals * @param station uid of station * @param options options */ - arrivals: (station: string | Station | Stop | Location, options: DeparturesArrivalsOptions | undefined) => Promise; + arrivals: ( + station: string | Station | Stop | Location, + options: DeparturesArrivalsOptions | undefined, + ) => Promise; /** * Retrieves journeys from trip id to station * @param fromTripId id of trip @@ -1116,13 +1129,21 @@ export interface HafasClient { * @param to uid of station or Station or Stop * @param options options */ - journeysFromTrip?: (fromTripId: string, previousStopover: StopOver, to: string | Station | Stop | Location, opt: JourneysFromTripOptions | undefined) => Promise; + journeysFromTrip?: ( + fromTripId: string, + previousStopover: StopOver, + to: string | Station | Stop | Location, + opt: JourneysFromTripOptions | undefined, + ) => Promise; /** * Retrieves locations or stops * @param name name of station * @param options options for search */ - locations: (name: string, options: LocationsOptions | undefined) => Promise>; + locations: ( + name: string, + options: LocationsOptions | undefined, + ) => Promise>; /** * Retrieves information about a stop * @param id uid of station @@ -1134,13 +1155,19 @@ export interface HafasClient { * @param location location * @param options options for search */ - nearby: (location: Location, options: NearByOptions | undefined) => Promise>; + nearby: ( + location: Location, + options: NearByOptions | undefined, + ) => Promise>; /** * Retrieves stations reachable within a certain time from a location * @param address location * @param options options for search */ - reachableFrom?: (address: Location, options: ReachableFromOptions | undefined) => Promise; + reachableFrom?: ( + address: Location, + options: ReachableFromOptions | undefined, + ) => Promise; /** * Retrieves all vehicles currently in an area. * @param box area @@ -1152,7 +1179,10 @@ export interface HafasClient { * @param lineNameOrFahrtNr string * @param options options for search */ - tripsByName?: (lineNameOrFahrtNr: string, options: TripsByNameOptions | undefined) => Promise; + tripsByName?: ( + lineNameOrFahrtNr: string, + options: TripsByNameOptions | undefined, + ) => Promise; /** * Fetches all remarks known to the HAFAS endpoint * @param opt RemarksOptions diff --git a/types/hafas-client/p/avv/index.d.ts b/types/hafas-client/p/avv/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/avv/index.d.ts +++ b/types/hafas-client/p/avv/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/bart/index.d.ts b/types/hafas-client/p/bart/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/bart/index.d.ts +++ b/types/hafas-client/p/bart/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/bls/index.d.ts b/types/hafas-client/p/bls/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/bls/index.d.ts +++ b/types/hafas-client/p/bls/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/bvg/index.d.ts b/types/hafas-client/p/bvg/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/bvg/index.d.ts +++ b/types/hafas-client/p/bvg/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/cfl/index.d.ts b/types/hafas-client/p/cfl/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/cfl/index.d.ts +++ b/types/hafas-client/p/cfl/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/cmta/index.d.ts b/types/hafas-client/p/cmta/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/cmta/index.d.ts +++ b/types/hafas-client/p/cmta/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/dart/index.d.ts b/types/hafas-client/p/dart/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/dart/index.d.ts +++ b/types/hafas-client/p/dart/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/db-busradar-nrw/index.d.ts b/types/hafas-client/p/db-busradar-nrw/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/db-busradar-nrw/index.d.ts +++ b/types/hafas-client/p/db-busradar-nrw/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/db/index.d.ts b/types/hafas-client/p/db/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/db/index.d.ts +++ b/types/hafas-client/p/db/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/hvv/index.d.ts b/types/hafas-client/p/hvv/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/hvv/index.d.ts +++ b/types/hafas-client/p/hvv/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/insa/index.d.ts b/types/hafas-client/p/insa/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/insa/index.d.ts +++ b/types/hafas-client/p/insa/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/invg/index.d.ts b/types/hafas-client/p/invg/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/invg/index.d.ts +++ b/types/hafas-client/p/invg/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/irish-rail/index.d.ts b/types/hafas-client/p/irish-rail/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/irish-rail/index.d.ts +++ b/types/hafas-client/p/irish-rail/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/ivb/index.d.ts b/types/hafas-client/p/ivb/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/ivb/index.d.ts +++ b/types/hafas-client/p/ivb/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/kvb/index.d.ts b/types/hafas-client/p/kvb/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/kvb/index.d.ts +++ b/types/hafas-client/p/kvb/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/mobil-nrw/index.d.ts b/types/hafas-client/p/mobil-nrw/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/mobil-nrw/index.d.ts +++ b/types/hafas-client/p/mobil-nrw/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/mobiliteit-lu/index.d.ts b/types/hafas-client/p/mobiliteit-lu/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/mobiliteit-lu/index.d.ts +++ b/types/hafas-client/p/mobiliteit-lu/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/nahsh/index.d.ts b/types/hafas-client/p/nahsh/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/nahsh/index.d.ts +++ b/types/hafas-client/p/nahsh/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/nvv/index.d.ts b/types/hafas-client/p/nvv/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/nvv/index.d.ts +++ b/types/hafas-client/p/nvv/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/oebb/index.d.ts b/types/hafas-client/p/oebb/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/oebb/index.d.ts +++ b/types/hafas-client/p/oebb/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/ooevv/index.d.ts b/types/hafas-client/p/ooevv/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/ooevv/index.d.ts +++ b/types/hafas-client/p/ooevv/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/pkp/index.d.ts b/types/hafas-client/p/pkp/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/pkp/index.d.ts +++ b/types/hafas-client/p/pkp/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/rejseplanen/index.d.ts b/types/hafas-client/p/rejseplanen/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/rejseplanen/index.d.ts +++ b/types/hafas-client/p/rejseplanen/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/rmv/index.d.ts b/types/hafas-client/p/rmv/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/rmv/index.d.ts +++ b/types/hafas-client/p/rmv/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/rsag/index.d.ts b/types/hafas-client/p/rsag/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/rsag/index.d.ts +++ b/types/hafas-client/p/rsag/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/saarfahrplan/index.d.ts b/types/hafas-client/p/saarfahrplan/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/saarfahrplan/index.d.ts +++ b/types/hafas-client/p/saarfahrplan/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/salzburg/index.d.ts b/types/hafas-client/p/salzburg/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/salzburg/index.d.ts +++ b/types/hafas-client/p/salzburg/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/sbahn-muenchen/index.d.ts b/types/hafas-client/p/sbahn-muenchen/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/sbahn-muenchen/index.d.ts +++ b/types/hafas-client/p/sbahn-muenchen/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/sncb/index.d.ts b/types/hafas-client/p/sncb/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/sncb/index.d.ts +++ b/types/hafas-client/p/sncb/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/stv/index.d.ts b/types/hafas-client/p/stv/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/stv/index.d.ts +++ b/types/hafas-client/p/stv/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/svv/index.d.ts b/types/hafas-client/p/svv/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/svv/index.d.ts +++ b/types/hafas-client/p/svv/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/tpg/index.d.ts b/types/hafas-client/p/tpg/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/tpg/index.d.ts +++ b/types/hafas-client/p/tpg/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/vbb/index.d.ts b/types/hafas-client/p/vbb/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/vbb/index.d.ts +++ b/types/hafas-client/p/vbb/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/vbn/index.d.ts b/types/hafas-client/p/vbn/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/vbn/index.d.ts +++ b/types/hafas-client/p/vbn/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/vkg/index.d.ts b/types/hafas-client/p/vkg/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/vkg/index.d.ts +++ b/types/hafas-client/p/vkg/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/vmt/index.d.ts b/types/hafas-client/p/vmt/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/vmt/index.d.ts +++ b/types/hafas-client/p/vmt/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/vor/index.d.ts b/types/hafas-client/p/vor/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/vor/index.d.ts +++ b/types/hafas-client/p/vor/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/vos/index.d.ts b/types/hafas-client/p/vos/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/vos/index.d.ts +++ b/types/hafas-client/p/vos/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/vrn/index.d.ts b/types/hafas-client/p/vrn/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/vrn/index.d.ts +++ b/types/hafas-client/p/vrn/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/vsn/index.d.ts b/types/hafas-client/p/vsn/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/vsn/index.d.ts +++ b/types/hafas-client/p/vsn/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/vvt/index.d.ts b/types/hafas-client/p/vvt/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/vvt/index.d.ts +++ b/types/hafas-client/p/vvt/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/vvv/index.d.ts b/types/hafas-client/p/vvv/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/vvv/index.d.ts +++ b/types/hafas-client/p/vvv/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/hafas-client/p/zvv/index.d.ts b/types/hafas-client/p/zvv/index.d.ts index 4e09d025df2ddf..764c7b87f526cb 100644 --- a/types/hafas-client/p/zvv/index.d.ts +++ b/types/hafas-client/p/zvv/index.d.ts @@ -1,3 +1,3 @@ -import { Profile } from '../../index'; +import { Profile } from "../../index"; export const profile: Profile; diff --git a/types/halfmoon/halfmoon-tests.ts b/types/halfmoon/halfmoon-tests.ts index 38c245ebe72356..da400f2fa86c19 100644 --- a/types/halfmoon/halfmoon-tests.ts +++ b/types/halfmoon/halfmoon-tests.ts @@ -1,16 +1,16 @@ -import halfmoon = require('halfmoon'); +import halfmoon = require("halfmoon"); halfmoon.pageWrapper; // $ExpectType Element halfmoon.stickyAlerts; // $ExpectType Element halfmoon.darkModeOn; // $ExpectType "yes" | "no" -halfmoon.createCookie('darkModeOn', 'yes'); // $ExpectType void -halfmoon.createCookie('darkModeOn', 'yes', 10); // $ExpectType void +halfmoon.createCookie("darkModeOn", "yes"); // $ExpectType void +halfmoon.createCookie("darkModeOn", "yes", 10); // $ExpectType void -halfmoon.readCookie('darkModeOn'); // $ExpectType string | null +halfmoon.readCookie("darkModeOn"); // $ExpectType string | null -halfmoon.eraseCookie('darkModeOn'); // $ExpectType void +halfmoon.eraseCookie("darkModeOn"); // $ExpectType void halfmoon.toggleDarkMode(); // $ExpectType void @@ -18,18 +18,18 @@ halfmoon.toggleSidebar(); // $ExpectType void halfmoon.deactivateAllDropdownToggles(); // $ExpectType void -halfmoon.toggleModal('modal'); // $ExpectType void +halfmoon.toggleModal("modal"); // $ExpectType void halfmoon.makeId(16); // $ExpectType string -halfmoon.toastAlert('alert'); // $ExpectType void -halfmoon.toastAlert('alert', 1000); // $ExpectType void +halfmoon.toastAlert("alert"); // $ExpectType void +halfmoon.toastAlert("alert", 1000); // $ExpectType void const stickyAlert = { - content: '', - title: '', - alertType: '', - fillType: '', + content: "", + title: "", + alertType: "", + fillType: "", hasDismissButton: true, timeShown: 1000, }; diff --git a/types/halfmoon/index.d.ts b/types/halfmoon/index.d.ts index 5b74358773e3f1..e357b22d349995 100644 --- a/types/halfmoon/index.d.ts +++ b/types/halfmoon/index.d.ts @@ -7,7 +7,7 @@ export const pageWrapper: Element; export const stickyAlerts: Element; /** The value of the `darkModeOn` cookie. */ -export let darkModeOn: 'yes' | 'no'; +export let darkModeOn: "yes" | "no"; /** * Create a cookie. diff --git a/types/halogen/index.d.ts b/types/halogen/index.d.ts index 8f0b36e3620780..d21ab33cffb809 100644 --- a/types/halogen/index.d.ts +++ b/types/halogen/index.d.ts @@ -6,29 +6,40 @@ import * as react from "react"; -export type VerticalAlign = "baseline" | "length" | "sub" | "super" | "top" | "text-top" | "middle" | "bottom" | "text-bottom" | "initial" | "inherit"; +export type VerticalAlign = + | "baseline" + | "length" + | "sub" + | "super" + | "top" + | "text-top" + | "middle" + | "bottom" + | "text-bottom" + | "initial" + | "inherit"; export interface HalogenCommonProps { - loading?: boolean | undefined; - color?: string | undefined; - id?: string | undefined; - className?: string | undefined; - verticalAlign?: VerticalAlign | undefined; + loading?: boolean | undefined; + color?: string | undefined; + id?: string | undefined; + className?: string | undefined; + verticalAlign?: VerticalAlign | undefined; } export interface SizeLoaderProps extends HalogenCommonProps { - size?: string | undefined; + size?: string | undefined; } export interface MarginLoaderProps extends HalogenCommonProps { - margin?: T | undefined; - size?: T | undefined; + margin?: T | undefined; + size?: T | undefined; } export interface RadiusLoaderProps extends MarginLoaderProps { - height?: string | undefined; - width?: string | undefined; - radius?: string | undefined; + height?: string | undefined; + width?: string | undefined; + radius?: string | undefined; } /** diff --git a/types/halogen/test/clip-loader.tsx b/types/halogen/test/clip-loader.tsx index ee03bf5ba2f5be..2ae00a47a193d7 100644 --- a/types/halogen/test/clip-loader.tsx +++ b/types/halogen/test/clip-loader.tsx @@ -1,18 +1,23 @@ -import * as React from "react"; import * as Halogen from "halogen"; +import * as React from "react"; class HalogenTests_ClipLoader_withNoProps extends React.Component { - render() { - return ( - - ); - } + render() { + return ; + } } class HalogenTests_ClipLoader_withAllProps extends React.Component { - render() { - return ( - - ); - } + render() { + return ( + + ); + } } diff --git a/types/halogen/test/fade-loader.tsx b/types/halogen/test/fade-loader.tsx index c401b988e0c58e..99c4fef03475b2 100644 --- a/types/halogen/test/fade-loader.tsx +++ b/types/halogen/test/fade-loader.tsx @@ -1,19 +1,27 @@ -import * as React from "react"; import * as Halogen from "halogen"; +import * as React from "react"; class HalogenTests_FadeLoader_withNoProps extends React.Component { - render() { - return ( - - ); - } + render() { + return ; + } } class HalogenTests_FadeLoader_withAllProps extends React.Component { - render() { - return ( - - ); - } + render() { + return ( + + ); + } } diff --git a/types/halogen/test/pacman-loader.tsx b/types/halogen/test/pacman-loader.tsx index 8f8e41ae84cda5..6809b0bf86a22c 100644 --- a/types/halogen/test/pacman-loader.tsx +++ b/types/halogen/test/pacman-loader.tsx @@ -1,18 +1,24 @@ -import * as React from "react"; import * as Halogen from "halogen"; +import * as React from "react"; class HalogenTests_PacmanLoader_withNoProps extends React.Component { - render() { - return ( - - ); - } + render() { + return ; + } } class HalogenTests_PacmanLoader_withAllProps extends React.Component { - render() { - return ( - - ); - } + render() { + return ( + + ); + } } diff --git a/types/halogen/test/rotate-loader.tsx b/types/halogen/test/rotate-loader.tsx index 4f75733999e2cc..7b2d148d3b5198 100644 --- a/types/halogen/test/rotate-loader.tsx +++ b/types/halogen/test/rotate-loader.tsx @@ -1,18 +1,24 @@ -import * as React from "react"; import * as Halogen from "halogen"; +import * as React from "react"; class HalogenTests_RotateLoader_withNoProps extends React.Component { - render() { - return ( - - ); - } + render() { + return ; + } } class HalogenTests_RotateLoader_withAllProps extends React.Component { - render() { - return ( - - ); - } + render() { + return ( + + ); + } } diff --git a/types/halogenium/index.d.ts b/types/halogenium/index.d.ts index 6d9bfbf7f814ee..718a62019e057d 100644 --- a/types/halogenium/index.d.ts +++ b/types/halogenium/index.d.ts @@ -4,75 +4,75 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -import * as React from 'react'; +import * as React from "react"; export type VerticalAlign = - | 'baseline' - | 'length' - | 'sub' - | 'super' - | 'top' - | 'text-top' - | 'middle' - | 'bottom' - | 'text-bottom' - | 'initial' - | 'inherit'; + | "baseline" + | "length" + | "sub" + | "super" + | "top" + | "text-top" + | "middle" + | "bottom" + | "text-bottom" + | "initial" + | "inherit"; export interface HalogenCommonProps { - loading?: boolean | undefined; - color?: string | undefined; - id?: string | undefined; - className?: string | undefined; - verticalAlign?: VerticalAlign | undefined; + loading?: boolean | undefined; + color?: string | undefined; + id?: string | undefined; + className?: string | undefined; + verticalAlign?: VerticalAlign | undefined; } export interface SizeLoaderProps extends HalogenCommonProps { - size?: number | string | undefined; + size?: number | string | undefined; } export interface MarginLoaderProps extends HalogenCommonProps { - margin?: number | string | undefined; - size?: number | string | undefined; + margin?: number | string | undefined; + size?: number | string | undefined; } export interface RadiusLoaderProps extends MarginLoaderProps { - height?: number | string | undefined; - width?: number | string | undefined; - radius?: number | string | undefined; + height?: number | string | undefined; + width?: number | string | undefined; + radius?: number | string | undefined; } /** * React components */ -export class PulseLoader extends React.Component { } +export class PulseLoader extends React.Component {} -export class RotateLoader extends React.Component { } +export class RotateLoader extends React.Component {} -export class BeatLoader extends React.Component { } +export class BeatLoader extends React.Component {} -export class RiseLoader extends React.Component { } +export class RiseLoader extends React.Component {} -export class SyncLoader extends React.Component { } +export class SyncLoader extends React.Component {} -export class GridLoader extends React.Component { } +export class GridLoader extends React.Component {} -export class ClipLoader extends React.Component { } +export class ClipLoader extends React.Component {} -export class SquareLoader extends React.Component { } +export class SquareLoader extends React.Component {} -export class DotLoader extends React.Component { } +export class DotLoader extends React.Component {} -export class PacmanLoader extends React.Component { } +export class PacmanLoader extends React.Component {} -export class MoonLoader extends React.Component { } +export class MoonLoader extends React.Component {} -export class RingLoader extends React.Component { } +export class RingLoader extends React.Component {} -export class BounceLoader extends React.Component { } +export class BounceLoader extends React.Component {} -export class SkewLoader extends React.Component { } +export class SkewLoader extends React.Component {} -export class FadeLoader extends React.Component { } +export class FadeLoader extends React.Component {} -export class ScaleLoader extends React.Component { } +export class ScaleLoader extends React.Component {} diff --git a/types/halogenium/test/clip-loader.tsx b/types/halogenium/test/clip-loader.tsx index d7d3bc8de58db7..9613366f2d3b99 100644 --- a/types/halogenium/test/clip-loader.tsx +++ b/types/halogenium/test/clip-loader.tsx @@ -1,18 +1,23 @@ -import * as React from "react"; import * as Halogenium from "halogenium"; +import * as React from "react"; class HalogenTests_ClipLoader_withNoProps extends React.Component { - render() { - return ( - - ); - } + render() { + return ; + } } class HalogenTests_ClipLoader_withAllProps extends React.Component { - render() { - return ( - - ); - } + render() { + return ( + + ); + } } diff --git a/types/halogenium/test/fade-loader.tsx b/types/halogenium/test/fade-loader.tsx index d81cb6a86a9d85..e74683e681506d 100644 --- a/types/halogenium/test/fade-loader.tsx +++ b/types/halogenium/test/fade-loader.tsx @@ -1,19 +1,27 @@ -import * as React from "react"; import * as Halogenium from "halogenium"; +import * as React from "react"; class HalogenTests_FadeLoader_withNoProps extends React.Component { - render() { - return ( - - ); - } + render() { + return ; + } } class HalogenTests_FadeLoader_withAllProps extends React.Component { - render() { - return ( - - ); - } + render() { + return ( + + ); + } } diff --git a/types/halogenium/test/pacman-loader.tsx b/types/halogenium/test/pacman-loader.tsx index 334766d7adeac2..21d8f1742b99f1 100644 --- a/types/halogenium/test/pacman-loader.tsx +++ b/types/halogenium/test/pacman-loader.tsx @@ -1,18 +1,24 @@ -import * as React from "react"; import * as Halogenium from "halogenium"; +import * as React from "react"; class HalogenTests_PacmanLoader_withNoProps extends React.Component { - render() { - return ( - - ); - } + render() { + return ; + } } class HalogenTests_PacmanLoader_withAllProps extends React.Component { - render() { - return ( - - ); - } + render() { + return ( + + ); + } } diff --git a/types/halogenium/test/rotate-loader.tsx b/types/halogenium/test/rotate-loader.tsx index 5d53a68ccf30d2..c8f00060734372 100644 --- a/types/halogenium/test/rotate-loader.tsx +++ b/types/halogenium/test/rotate-loader.tsx @@ -1,18 +1,24 @@ -import * as React from "react"; import * as Halogenium from "halogenium"; +import * as React from "react"; class HalogenTests_RotateLoader_withNoProps extends React.Component { - render() { - return ( - - ); - } + render() { + return ; + } } class HalogenTests_RotateLoader_withAllProps extends React.Component { - render() { - return ( - - ); - } + render() { + return ( + + ); + } } diff --git a/types/hammerjs/hammerjs-tests.ts b/types/hammerjs/hammerjs-tests.ts index 4ac95b746f508e..6efc2f37acb28c 100644 --- a/types/hammerjs/hammerjs-tests.ts +++ b/types/hammerjs/hammerjs-tests.ts @@ -1,200 +1,173 @@ // Tests based on examples at http://hammerjs.github.io/examples/ -(() => -{ - var myElement = document.getElementById( 'myElement' ); - - // create a simple instance - // by default, it only adds horizontal recognizers - var mc = new Hammer( myElement ); - - // listen to events... - mc.on( "panleft panright tap press", function ( ev ) - { - console.log(ev.maxPointers - 2); - console.log(Math.floor(ev.overallVelocity)); - console.log(ev.timeStamp + Date.now()); - } ); +(() => { + var myElement = document.getElementById("myElement"); + + // create a simple instance + // by default, it only adds horizontal recognizers + var mc = new Hammer(myElement); + + // listen to events... + mc.on("panleft panright tap press", function(ev) { + console.log(ev.maxPointers - 2); + console.log(Math.floor(ev.overallVelocity)); + console.log(ev.timeStamp + Date.now()); + }); })(); +(() => { + var myElement = document.getElementById("myElement"); -(() => -{ - var myElement = document.getElementById( 'myElement' ); + // create a simple instance + // by default, it only adds horizontal recognizers + var mc = new Hammer(myElement); - // create a simple instance - // by default, it only adds horizontal recognizers - var mc = new Hammer( myElement ); - - // listen to events... - mc.on( "panleft panright tap press", function ( ev ) - { - myElement.textContent = ev.type + " gesture detected."; - } ); + // listen to events... + mc.on("panleft panright tap press", function(ev) { + myElement.textContent = ev.type + " gesture detected."; + }); })(); - -(() => -{ - var myElement = document.getElementById( 'myElement' ); - - // create a simple instance - // by default, it only adds horizontal recognizers - var mc = new Hammer( myElement ); - - // let the pan gesture support all directions. - // this will block the vertical scrolling on a touch-device while on the element - mc.get( 'pan' ).set( {direction: Hammer.DIRECTION_ALL} ); - - // listen to events... - mc.on( "panleft panright panup pandown tap press", function ( ev:HammerInput ) - { - type EventType = - | HammerStatic["INPUT_START"] - | HammerStatic["INPUT_MOVE"] - | HammerStatic["INPUT_END"] - | HammerStatic["INPUT_CANCEL"]; - const eventType: EventType = ev.eventType; - myElement.textContent = ev.type + " gesture detected."; - } ); +(() => { + var myElement = document.getElementById("myElement"); + + // create a simple instance + // by default, it only adds horizontal recognizers + var mc = new Hammer(myElement); + + // let the pan gesture support all directions. + // this will block the vertical scrolling on a touch-device while on the element + mc.get("pan").set({ direction: Hammer.DIRECTION_ALL }); + + // listen to events... + mc.on("panleft panright panup pandown tap press", function(ev: HammerInput) { + type EventType = + | HammerStatic["INPUT_START"] + | HammerStatic["INPUT_MOVE"] + | HammerStatic["INPUT_END"] + | HammerStatic["INPUT_CANCEL"]; + const eventType: EventType = ev.eventType; + myElement.textContent = ev.type + " gesture detected."; + }); })(); +(() => { + var myElement = document.getElementById("myElement"); -(() => -{ - var myElement = document.getElementById( 'myElement' ); - - var mc = new Hammer.Manager( myElement ); - - // create a pinch and rotate recognizer - // these require 2 pointers - var pinch = new Hammer.Pinch(); - var rotate = new Hammer.Rotate(); + var mc = new Hammer.Manager(myElement); - // we want to detect both the same time - pinch.recognizeWith( rotate ); + // create a pinch and rotate recognizer + // these require 2 pointers + var pinch = new Hammer.Pinch(); + var rotate = new Hammer.Rotate(); - // add to the Manager - mc.add( [pinch, rotate] ); + // we want to detect both the same time + pinch.recognizeWith(rotate); + // add to the Manager + mc.add([pinch, rotate]); - mc.on( "pinch rotate", function ( ev:HammerInput ) - { - myElement.textContent += ev.type + " "; - } ); + mc.on("pinch rotate", function(ev: HammerInput) { + myElement.textContent += ev.type + " "; + }); })(); +(() => { + var myElement = document.getElementById("myElement"); -(() => -{ - var myElement = document.getElementById( 'myElement' ); + // We create a manager object, which is the same as Hammer(), but without the presetted recognizers. + var mc = new Hammer.Manager(myElement); - // We create a manager object, which is the same as Hammer(), but without the presetted recognizers. - var mc = new Hammer.Manager( myElement ); + // Default, tap recognizer + mc.add(new Hammer.Tap()); - // Default, tap recognizer - mc.add( new Hammer.Tap() ); + // Tap recognizer with minimal 4 taps + mc.add(new Hammer.Tap({ event: "quadrupletap", taps: 4 })); - // Tap recognizer with minimal 4 taps - mc.add( new Hammer.Tap( {event: 'quadrupletap', taps: 4} ) ); + // we want to recognize this simulatenous, so a quadrupletap will be detected even while a tap has been recognized. + // the tap event will be emitted on every tap + mc.get("quadrupletap").recognizeWith("tap"); - // we want to recognize this simulatenous, so a quadrupletap will be detected even while a tap has been recognized. - // the tap event will be emitted on every tap - mc.get( 'quadrupletap' ).recognizeWith( 'tap' ); - - - mc.on( "tap quadrupletap", function ( ev ) - { - myElement.textContent += ev.type + " "; - } ); + mc.on("tap quadrupletap", function(ev) { + myElement.textContent += ev.type + " "; + }); })(); +(() => { + var myElement = document.getElementById("myElement"); -(() => -{ - var myElement = document.getElementById( 'myElement' ); - - // We create a manager object, which is the same as Hammer(), but without the presetted recognizers. - var mc = new Hammer.Manager( myElement ); - + // We create a manager object, which is the same as Hammer(), but without the presetted recognizers. + var mc = new Hammer.Manager(myElement); - // Tap recognizer with minimal 2 taps - mc.add( new Hammer.Tap( {event: 'doubletap', taps: 2} ) ); - // Single tap recognizer - mc.add( new Hammer.Tap( {event: 'singletap'} ) ); + // Tap recognizer with minimal 2 taps + mc.add(new Hammer.Tap({ event: "doubletap", taps: 2 })); + // Single tap recognizer + mc.add(new Hammer.Tap({ event: "singletap" })); + // we want to recognize this simulatenous, so a quadrupletap will be detected even while a tap has been recognized. + mc.get("doubletap").recognizeWith("singletap"); + // we only want to trigger a tap, when we don't have detected a doubletap + mc.get("singletap").requireFailure("doubletap"); - // we want to recognize this simulatenous, so a quadrupletap will be detected even while a tap has been recognized. - mc.get( 'doubletap' ).recognizeWith( 'singletap' ); - // we only want to trigger a tap, when we don't have detected a doubletap - mc.get( 'singletap' ).requireFailure( 'doubletap' ); - - - mc.on( "singletap doubletap", function ( ev ) - { - myElement.textContent += ev.type + " "; - } ); + mc.on("singletap doubletap", function(ev) { + myElement.textContent += ev.type + " "; + }); })(); - -(() => -{ - var myElement = document.getElementById( 'myElement' ); - - // We create a manager object using custom options - var options: HammerOptions = { - recognizers: [ - [Hammer.Tap, { event: 'doubletap', taps: 2 }], - [Hammer.Tap, { event: 'singletap' }], - ], - inputClass: Hammer.TouchInput, - }; - var mc = new Hammer.Manager( myElement, options ); - - // we want to recognize this simulatenous, so a quadrupletap will be detected even while a tap has been recognized. - mc.get( 'doubletap' ).recognizeWith( 'singletap' ); - // we only want to trigger a tap, when we don't have detected a doubletap - mc.get( 'singletap' ).requireFailure( 'doubletap' ); - - - mc.on( "singletap doubletap", function ( ev ) - { - myElement.textContent += ev.type + " "; - } ); +(() => { + var myElement = document.getElementById("myElement"); + + // We create a manager object using custom options + var options: HammerOptions = { + recognizers: [ + [Hammer.Tap, { event: "doubletap", taps: 2 }], + [Hammer.Tap, { event: "singletap" }], + ], + inputClass: Hammer.TouchInput, + }; + var mc = new Hammer.Manager(myElement, options); + + // we want to recognize this simulatenous, so a quadrupletap will be detected even while a tap has been recognized. + mc.get("doubletap").recognizeWith("singletap"); + // we only want to trigger a tap, when we don't have detected a doubletap + mc.get("singletap").requireFailure("doubletap"); + + mc.on("singletap doubletap", function(ev) { + myElement.textContent += ev.type + " "; + }); })(); - -(()=>{ - var input = { - [Hammer.STATE_POSSIBLE]: 1 as 1, - [Hammer.STATE_BEGAN]: 2 as 2, - [Hammer.STATE_CHANGED]: 4 as 4, - [Hammer.STATE_ENDED]: 8 as 8, - [Hammer.STATE_CANCELLED]: 16 as 16, - [Hammer.STATE_FAILED]: 32 as 32, - } - input[Hammer.STATE_RECOGNIZED] = Hammer.STATE_ENDED as typeof Hammer.STATE_ENDED; - - var direction = { - [Hammer.INPUT_START]: 1 as 1, - [Hammer.INPUT_MOVE]: 2 as 2, - [Hammer.INPUT_END]: 4 as 4, - [Hammer.INPUT_CANCEL]: 8 as 8, - } - - var state = { - [Hammer.DIRECTION_NONE]: 1 as 1, - [Hammer.DIRECTION_LEFT]: 2 as 2, - [Hammer.DIRECTION_RIGHT]: 4 as 4, - [Hammer.DIRECTION_UP]: 8 as 8, - [Hammer.DIRECTION_DOWN]: 16 as 16, - [Hammer.DIRECTION_HORIZONTAL]: (Hammer.DIRECTION_LEFT | Hammer.DIRECTION_RIGHT) as 6, // TS infers this as a number, so we have to cast it ourselves - [Hammer.DIRECTION_VERTICAL]: (Hammer.DIRECTION_UP | Hammer.DIRECTION_DOWN) as 24, // bits aren't overlapping, so binary or is equal to addition - [Hammer.DIRECTION_ALL]: (Hammer.DIRECTION_HORIZONTAL | Hammer.DIRECTION_VERTICAL) as 30, - } - - type KeysSameAsValues = true; // typecheck: if all keys are equal to their value - type HammerInputLiteralsCheck = KeysSameAsValues - type HammerDirectionLiteralsCheck = KeysSameAsValues - type HammerStateLiteralsCheck = KeysSameAsValues +(() => { + var input = { + [Hammer.STATE_POSSIBLE]: 1 as 1, + [Hammer.STATE_BEGAN]: 2 as 2, + [Hammer.STATE_CHANGED]: 4 as 4, + [Hammer.STATE_ENDED]: 8 as 8, + [Hammer.STATE_CANCELLED]: 16 as 16, + [Hammer.STATE_FAILED]: 32 as 32, + }; + input[Hammer.STATE_RECOGNIZED] = Hammer.STATE_ENDED as typeof Hammer.STATE_ENDED; + + var direction = { + [Hammer.INPUT_START]: 1 as 1, + [Hammer.INPUT_MOVE]: 2 as 2, + [Hammer.INPUT_END]: 4 as 4, + [Hammer.INPUT_CANCEL]: 8 as 8, + }; + + var state = { + [Hammer.DIRECTION_NONE]: 1 as 1, + [Hammer.DIRECTION_LEFT]: 2 as 2, + [Hammer.DIRECTION_RIGHT]: 4 as 4, + [Hammer.DIRECTION_UP]: 8 as 8, + [Hammer.DIRECTION_DOWN]: 16 as 16, + [Hammer.DIRECTION_HORIZONTAL]: (Hammer.DIRECTION_LEFT | Hammer.DIRECTION_RIGHT) as 6, // TS infers this as a number, so we have to cast it ourselves + [Hammer.DIRECTION_VERTICAL]: (Hammer.DIRECTION_UP | Hammer.DIRECTION_DOWN) as 24, // bits aren't overlapping, so binary or is equal to addition + [Hammer.DIRECTION_ALL]: (Hammer.DIRECTION_HORIZONTAL | Hammer.DIRECTION_VERTICAL) as 30, + }; + + type KeysSameAsValues = true; // typecheck: if all keys are equal to their value + type HammerInputLiteralsCheck = KeysSameAsValues; + type HammerDirectionLiteralsCheck = KeysSameAsValues; + type HammerStateLiteralsCheck = KeysSameAsValues; })(); diff --git a/types/hammerjs/index.d.ts b/types/hammerjs/index.d.ts index c7a270f7efbdcf..8b1bb160d85d26 100644 --- a/types/hammerjs/index.d.ts +++ b/types/hammerjs/index.d.ts @@ -3,373 +3,345 @@ // Definitions by: Han Lin Yap // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare var Hammer:HammerStatic; +declare var Hammer: HammerStatic; declare module "hammerjs" { export = Hammer; } -interface HammerStatic -{ - new( element:HTMLElement | SVGElement, options?:HammerOptions ): HammerManager; - - defaults:HammerDefaults; - - VERSION: number; - - INPUT_START: 1; - INPUT_MOVE: 2; - INPUT_END: 4; - INPUT_CANCEL: 8; - - STATE_POSSIBLE: 1; - STATE_BEGAN: 2; - STATE_CHANGED: 4; - STATE_ENDED: 8; - STATE_RECOGNIZED: 8; // same as STATE_ENDED - STATE_CANCELLED: 16; - STATE_FAILED: 32; - - DIRECTION_NONE: 1; - DIRECTION_LEFT: 2; - DIRECTION_RIGHT: 4; - DIRECTION_UP: 8; - DIRECTION_DOWN: 16; - DIRECTION_HORIZONTAL: 6; // DIRECTION_LEFT | DIRECTION_RIGHT - DIRECTION_VERTICAL: 24; // DIRECTION_UP | DIRECTION_DOWN - DIRECTION_ALL: 30; // DIRECTION_HORIZONTAL | DIRECTION_VERTICAL - - Manager: HammerManagerConstructor; - Input: HammerInput; - TouchAction: TouchAction; - - TouchInput: TouchInput; - MouseInput: MouseInput; - PointerEventInput: PointerEventInput; - TouchMouseInput: TouchMouseInput; - SingleTouchInput: SingleTouchInput; - - Recognizer: RecognizerStatic; - AttrRecognizer: AttrRecognizerStatic; - Tap: TapRecognizerStatic; - Pan: PanRecognizerStatic; - Swipe: SwipeRecognizerStatic; - Pinch: PinchRecognizerStatic; - Rotate: RotateRecognizerStatic; - Press: PressRecognizerStatic; - - on( target:EventTarget, types:string, handler:Function ):void; - off( target:EventTarget, types:string, handler:Function ):void; - each( obj:any, iterator:Function, context:any ): void; - merge( dest:any, src:any ): any; - extend( dest:any, src:any, merge:boolean ): any; - inherit( child:Function, base:Function, properties:any ):any; - bindFn( fn:Function, context:any ):Function; - prefixed( obj:any, property:string ):string; +interface HammerStatic { + new(element: HTMLElement | SVGElement, options?: HammerOptions): HammerManager; + + defaults: HammerDefaults; + + VERSION: number; + + INPUT_START: 1; + INPUT_MOVE: 2; + INPUT_END: 4; + INPUT_CANCEL: 8; + + STATE_POSSIBLE: 1; + STATE_BEGAN: 2; + STATE_CHANGED: 4; + STATE_ENDED: 8; + STATE_RECOGNIZED: 8; // same as STATE_ENDED + STATE_CANCELLED: 16; + STATE_FAILED: 32; + + DIRECTION_NONE: 1; + DIRECTION_LEFT: 2; + DIRECTION_RIGHT: 4; + DIRECTION_UP: 8; + DIRECTION_DOWN: 16; + DIRECTION_HORIZONTAL: 6; // DIRECTION_LEFT | DIRECTION_RIGHT + DIRECTION_VERTICAL: 24; // DIRECTION_UP | DIRECTION_DOWN + DIRECTION_ALL: 30; // DIRECTION_HORIZONTAL | DIRECTION_VERTICAL + + Manager: HammerManagerConstructor; + Input: HammerInput; + TouchAction: TouchAction; + + TouchInput: TouchInput; + MouseInput: MouseInput; + PointerEventInput: PointerEventInput; + TouchMouseInput: TouchMouseInput; + SingleTouchInput: SingleTouchInput; + + Recognizer: RecognizerStatic; + AttrRecognizer: AttrRecognizerStatic; + Tap: TapRecognizerStatic; + Pan: PanRecognizerStatic; + Swipe: SwipeRecognizerStatic; + Pinch: PinchRecognizerStatic; + Rotate: RotateRecognizerStatic; + Press: PressRecognizerStatic; + + on(target: EventTarget, types: string, handler: Function): void; + off(target: EventTarget, types: string, handler: Function): void; + each(obj: any, iterator: Function, context: any): void; + merge(dest: any, src: any): any; + extend(dest: any, src: any, merge: boolean): any; + inherit(child: Function, base: Function, properties: any): any; + bindFn(fn: Function, context: any): Function; + prefixed(obj: any, property: string): string; } type RecognizerTuple = - [RecognizerStatic] - | [RecognizerStatic, RecognizerOptions] - | [RecognizerStatic, RecognizerOptions, string | string[]] - | [RecognizerStatic, RecognizerOptions, string | string[], (string | Recognizer) | (string | Recognizer)[]]; - -interface HammerDefaults extends HammerOptions -{ - domEvents:boolean; - enable:boolean; - preset:RecognizerTuple[]; - touchAction:string; - cssProps:CssProps; - - inputClass:HammerInput; - inputTarget:EventTarget; -} - -interface CssProps -{ - contentZooming:string; - tapHighlightColor:string; - touchCallout:string; - touchSelect:string; - userDrag:string; - userSelect:string; -} - -interface HammerOptions -{ - cssProps?:CssProps | undefined; - domEvents?:boolean | undefined; - enable?:boolean | ((manager: HammerManager) => boolean) | undefined; - preset?:RecognizerTuple[] | undefined; - touchAction?:string | undefined; - recognizers?:RecognizerTuple[] | undefined; - - inputClass?:HammerInput | undefined; - inputTarget?:EventTarget | undefined; + | [RecognizerStatic] + | [RecognizerStatic, RecognizerOptions] + | [RecognizerStatic, RecognizerOptions, string | string[]] + | [RecognizerStatic, RecognizerOptions, string | string[], (string | Recognizer) | (string | Recognizer)[]]; + +interface HammerDefaults extends HammerOptions { + domEvents: boolean; + enable: boolean; + preset: RecognizerTuple[]; + touchAction: string; + cssProps: CssProps; + + inputClass: HammerInput; + inputTarget: EventTarget; +} + +interface CssProps { + contentZooming: string; + tapHighlightColor: string; + touchCallout: string; + touchSelect: string; + userDrag: string; + userSelect: string; +} + +interface HammerOptions { + cssProps?: CssProps | undefined; + domEvents?: boolean | undefined; + enable?: boolean | ((manager: HammerManager) => boolean) | undefined; + preset?: RecognizerTuple[] | undefined; + touchAction?: string | undefined; + recognizers?: RecognizerTuple[] | undefined; + + inputClass?: HammerInput | undefined; + inputTarget?: EventTarget | undefined; } interface HammerManagerConstructor { - new( element:EventTarget, options?:HammerOptions ):HammerManager; + new(element: EventTarget, options?: HammerOptions): HammerManager; } interface HammerListener { - (event:HammerInput): void + (event: HammerInput): void; } -interface HammerManager -{ - add( recogniser:Recognizer ):Recognizer; - add( recogniser:Recognizer ):HammerManager; - add( recogniser:Recognizer[] ):Recognizer; - add( recogniser:Recognizer[] ):HammerManager; - destroy():void; - emit( event:string, data:any ):void; - get( recogniser:Recognizer ):Recognizer; - get( recogniser:string ):Recognizer; - off( events:string, handler?:HammerListener ):void; - on( events:string, handler:HammerListener ):void; - recognize( inputData:any ):void; - remove( recogniser:Recognizer ):HammerManager; - remove( recogniser:string ):HammerManager; - set( options:HammerOptions ):HammerManager; - stop( force:boolean ):void; +interface HammerManager { + add(recogniser: Recognizer): Recognizer; + add(recogniser: Recognizer): HammerManager; + add(recogniser: Recognizer[]): Recognizer; + add(recogniser: Recognizer[]): HammerManager; + destroy(): void; + emit(event: string, data: any): void; + get(recogniser: Recognizer): Recognizer; + get(recogniser: string): Recognizer; + off(events: string, handler?: HammerListener): void; + on(events: string, handler: HammerListener): void; + recognize(inputData: any): void; + remove(recogniser: Recognizer): HammerManager; + remove(recogniser: string): HammerManager; + set(options: HammerOptions): HammerManager; + stop(force: boolean): void; } -declare class HammerInput -{ - constructor( manager:HammerManager, callback:Function ); +declare class HammerInput { + constructor(manager: HammerManager, callback: Function); - destroy():void; - handler():void; - init():void; + destroy(): void; + handler(): void; + init(): void; - /** Name of the event. Like panstart. */ - type:string; + /** Name of the event. Like panstart. */ + type: string; - /** Movement of the X axis. */ - deltaX:number; + /** Movement of the X axis. */ + deltaX: number; - /** Movement of the Y axis. */ - deltaY:number; + /** Movement of the Y axis. */ + deltaY: number; - /** Total time in ms since the first input. */ - deltaTime:number; + /** Total time in ms since the first input. */ + deltaTime: number; - /** Distance moved. */ - distance:number; + /** Distance moved. */ + distance: number; - /** Angle moved. */ - angle:number; + /** Angle moved. */ + angle: number; - /** Velocity on the X axis, in px/ms. */ - velocityX:number; + /** Velocity on the X axis, in px/ms. */ + velocityX: number; - /** Velocity on the Y axis, in px/ms */ - velocityY:number; + /** Velocity on the Y axis, in px/ms */ + velocityY: number; - /** Highest velocityX/Y value. */ - velocity:number; + /** Highest velocityX/Y value. */ + velocity: number; - overallVelocity:number; + overallVelocity: number; - overallVelocityX:number; + overallVelocityX: number; - overallVelocityY:number; + overallVelocityY: number; - /** Direction moved. Matches the DIRECTION constants. */ - direction:number; + /** Direction moved. Matches the DIRECTION constants. */ + direction: number; - /** Direction moved from it's starting point. Matches the DIRECTION constants. */ - offsetDirection:number; + /** Direction moved from it's starting point. Matches the DIRECTION constants. */ + offsetDirection: number; - /** Scaling that has been done when multi-touch. 1 on a single touch. */ - scale:number; + /** Scaling that has been done when multi-touch. 1 on a single touch. */ + scale: number; - /** Rotation that has been done when multi-touch. 0 on a single touch. */ - rotation:number; + /** Rotation that has been done when multi-touch. 0 on a single touch. */ + rotation: number; - /** Center position for multi-touch, or just the single pointer. */ - center:HammerPoint; + /** Center position for multi-touch, or just the single pointer. */ + center: HammerPoint; - /** Source event object, type TouchEvent, MouseEvent or PointerEvent. */ - srcEvent:TouchEvent | MouseEvent | PointerEvent; + /** Source event object, type TouchEvent, MouseEvent or PointerEvent. */ + srcEvent: TouchEvent | MouseEvent | PointerEvent; - /** Target that received the event. */ - target:HTMLElement; + /** Target that received the event. */ + target: HTMLElement; - /** Primary pointer type, could be touch, mouse, pen or kinect. */ - pointerType:string; + /** Primary pointer type, could be touch, mouse, pen or kinect. */ + pointerType: string; - /** Event type, matches the INPUT constants. */ - eventType: HammerStatic['INPUT_START'] | - HammerStatic['INPUT_MOVE'] | - HammerStatic['INPUT_END'] | - HammerStatic['INPUT_CANCEL']; + /** Event type, matches the INPUT constants. */ + eventType: + | HammerStatic["INPUT_START"] + | HammerStatic["INPUT_MOVE"] + | HammerStatic["INPUT_END"] + | HammerStatic["INPUT_CANCEL"]; - /** true when the first input. */ - isFirst:boolean; + /** true when the first input. */ + isFirst: boolean; - /** true when the final (last) input. */ - isFinal:boolean; + /** true when the final (last) input. */ + isFinal: boolean; - /** Array with all pointers, including the ended pointers (touchend, mouseup). */ - pointers:any[]; + /** Array with all pointers, including the ended pointers (touchend, mouseup). */ + pointers: any[]; - /** Array with all new/moved/lost pointers. */ - changedPointers:any[]; + /** Array with all new/moved/lost pointers. */ + changedPointers: any[]; - /** Maximum number of pointers detected in the gesture */ - maxPointers:number; + /** Maximum number of pointers detected in the gesture */ + maxPointers: number; - /** Timestamp of a gesture */ - timeStamp:number; + /** Timestamp of a gesture */ + timeStamp: number; - /** Reference to the srcEvent.preventDefault() method. Only for experts! */ - preventDefault:Function; + /** Reference to the srcEvent.preventDefault() method. Only for experts! */ + preventDefault: Function; } -declare class MouseInput extends HammerInput -{ - constructor( manager:HammerManager, callback:Function ); +declare class MouseInput extends HammerInput { + constructor(manager: HammerManager, callback: Function); } -declare class PointerEventInput extends HammerInput -{ - constructor( manager:HammerManager, callback:Function ); +declare class PointerEventInput extends HammerInput { + constructor(manager: HammerManager, callback: Function); } -declare class SingleTouchInput extends HammerInput -{ - constructor( manager:HammerManager, callback:Function ); +declare class SingleTouchInput extends HammerInput { + constructor(manager: HammerManager, callback: Function); } -declare class TouchInput extends HammerInput -{ - constructor( manager:HammerManager, callback:Function ); +declare class TouchInput extends HammerInput { + constructor(manager: HammerManager, callback: Function); } -declare class TouchMouseInput extends HammerInput -{ - constructor( manager:HammerManager, callback:Function ); +declare class TouchMouseInput extends HammerInput { + constructor(manager: HammerManager, callback: Function); } interface RecognizerOptions { - direction?: number | undefined; - enable?: boolean | ((recognizer: Recognizer, inputData: HammerInput) => boolean) | undefined; - event?: string | undefined; - interval?: number | undefined; - pointers?: number | undefined; - posThreshold?: number | undefined; - taps?: number | undefined - threshold?: number | undefined; - time?: number | undefined; - velocity?: number | undefined; + direction?: number | undefined; + enable?: boolean | ((recognizer: Recognizer, inputData: HammerInput) => boolean) | undefined; + event?: string | undefined; + interval?: number | undefined; + pointers?: number | undefined; + posThreshold?: number | undefined; + taps?: number | undefined; + threshold?: number | undefined; + time?: number | undefined; + velocity?: number | undefined; } -interface RecognizerStatic -{ - new( options?:RecognizerOptions ):Recognizer; +interface RecognizerStatic { + new(options?: RecognizerOptions): Recognizer; } -interface Recognizer -{ - defaults:any; +interface Recognizer { + defaults: any; - canEmit():boolean; - canRecognizeWith( otherRecognizer:Recognizer ):boolean; - dropRecognizeWith( otherRecognizer:Recognizer | Recognizer[] | string):Recognizer; - dropRequireFailure( otherRecognizer:Recognizer | Recognizer[] | string):Recognizer; - emit( input:HammerInput ):void; - getTouchAction():any[]; - hasRequireFailures():boolean; - process( inputData:HammerInput ):string; - recognize( inputData:HammerInput ):void; - recognizeWith( otherRecognizer:Recognizer | Recognizer[] | string):Recognizer; - requireFailure( otherRecognizer:Recognizer | Recognizer[] | string):Recognizer; - reset():void; - set( options?:RecognizerOptions ):Recognizer; - tryEmit( input:HammerInput ):void; + canEmit(): boolean; + canRecognizeWith(otherRecognizer: Recognizer): boolean; + dropRecognizeWith(otherRecognizer: Recognizer | Recognizer[] | string): Recognizer; + dropRequireFailure(otherRecognizer: Recognizer | Recognizer[] | string): Recognizer; + emit(input: HammerInput): void; + getTouchAction(): any[]; + hasRequireFailures(): boolean; + process(inputData: HammerInput): string; + recognize(inputData: HammerInput): void; + recognizeWith(otherRecognizer: Recognizer | Recognizer[] | string): Recognizer; + requireFailure(otherRecognizer: Recognizer | Recognizer[] | string): Recognizer; + reset(): void; + set(options?: RecognizerOptions): Recognizer; + tryEmit(input: HammerInput): void; } -interface AttrRecognizerStatic -{ - attrTest( input:HammerInput ):boolean; - process( input:HammerInput ):any; +interface AttrRecognizerStatic { + attrTest(input: HammerInput): boolean; + process(input: HammerInput): any; } -interface AttrRecognizer extends Recognizer -{ - new( options?:RecognizerOptions ):AttrRecognizer; +interface AttrRecognizer extends Recognizer { + new(options?: RecognizerOptions): AttrRecognizer; } -interface PanRecognizerStatic -{ - new( options?:RecognizerOptions ):PanRecognizer; +interface PanRecognizerStatic { + new(options?: RecognizerOptions): PanRecognizer; } -interface PanRecognizer extends AttrRecognizer -{ +interface PanRecognizer extends AttrRecognizer { } -interface PinchRecognizerStatic -{ - new( options?:RecognizerOptions ):PinchRecognizer; +interface PinchRecognizerStatic { + new(options?: RecognizerOptions): PinchRecognizer; } -interface PinchRecognizer extends AttrRecognizer -{ +interface PinchRecognizer extends AttrRecognizer { } -interface PressRecognizerStatic -{ - new( options?:RecognizerOptions ):PressRecognizer; +interface PressRecognizerStatic { + new(options?: RecognizerOptions): PressRecognizer; } -interface PressRecognizer extends AttrRecognizer -{ +interface PressRecognizer extends AttrRecognizer { } -interface RotateRecognizerStatic -{ - new( options?:RecognizerOptions ):RotateRecognizer; +interface RotateRecognizerStatic { + new(options?: RecognizerOptions): RotateRecognizer; } -interface RotateRecognizer extends AttrRecognizer -{ +interface RotateRecognizer extends AttrRecognizer { } -interface SwipeRecognizerStatic -{ - new( options?:RecognizerOptions ):SwipeRecognizer; +interface SwipeRecognizerStatic { + new(options?: RecognizerOptions): SwipeRecognizer; } -interface SwipeRecognizer extends AttrRecognizer -{ +interface SwipeRecognizer extends AttrRecognizer { } -interface TapRecognizerStatic -{ - new( options?:RecognizerOptions ):TapRecognizer; +interface TapRecognizerStatic { + new(options?: RecognizerOptions): TapRecognizer; } -interface TapRecognizer extends AttrRecognizer -{ +interface TapRecognizer extends AttrRecognizer { } -declare class TouchAction -{ - constructor( manager:HammerManager, value:string ); +declare class TouchAction { + constructor(manager: HammerManager, value: string); - compute():string; - preventDefaults( input:HammerInput ):void; - preventSrc( srcEvent:any ):void; - set( value:string ):void; - update():void; + compute(): string; + preventDefaults(input: HammerInput): void; + preventSrc(srcEvent: any): void; + set(value: string): void; + update(): void; } -interface HammerPoint -{ - x: number; - y: number; +interface HammerPoint { + x: number; + y: number; } diff --git a/types/hammerjs/v1/hammerjs-tests.ts b/types/hammerjs/v1/hammerjs-tests.ts index 1be76931cec6b6..273f2f7416164b 100644 --- a/types/hammerjs/v1/hammerjs-tests.ts +++ b/types/hammerjs/v1/hammerjs-tests.ts @@ -7,20 +7,20 @@ if (!Hammer.HAS_TOUCHEVENTS && !Hammer.HAS_POINTEREVENTS) { // instance method check var el = document.getElementById("container"); -Hammer(el).on("doubletap", function () { - alert('you doubletapped me!'); +Hammer(el).on("doubletap", function() { + alert("you doubletapped me!"); }); var hammertime = Hammer(el, { drag: false, - transform: false -}).off("tap", function (event:HammerEvent) { - alert('hello!'); + transform: false, +}).off("tap", function(event: HammerEvent) { + alert("hello!"); }); hammertime.enable(false); -hammertime.on("touch drag transform", function (ev: HammerEvent) { +hammertime.on("touch drag transform", function(ev: HammerEvent) { if (!ev.gesture) { return; } @@ -32,15 +32,15 @@ hammertime.on("touch drag transform", function (ev: HammerEvent) { // jQuery check $("#element") - .hammer({ - // Options - }) - .on("tap", function (ev) { - console.log(ev); - }); + .hammer({ + // Options + }) + .on("tap", function(ev) { + console.log(ev); + }); $("#container").hammer({ preventDefault: false, - dragBlockVertical: false -}).on("hold tap doubletap transformstart transform transformend dragstart drag dragend release swipe", function (ev) { + dragBlockVertical: false, +}).on("hold tap doubletap transformstart transform transformend dragstart drag dragend release swipe", function(ev) { }); diff --git a/types/hammerjs/v1/index.d.ts b/types/hammerjs/v1/index.d.ts index 8c32c25490c843..df9eee173f02ca 100644 --- a/types/hammerjs/v1/index.d.ts +++ b/types/hammerjs/v1/index.d.ts @@ -4,7 +4,6 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 - /// declare var Hammer: HammerStatic; @@ -128,7 +127,6 @@ interface HammerEvent { stopPropagation(): void; preventDefault(): void; - } declare enum HammerPointerType { diff --git a/types/handbrake-js/handbrake-js-tests.ts b/types/handbrake-js/handbrake-js-tests.ts index 3d46564213d84f..e075045daeb870 100644 --- a/types/handbrake-js/handbrake-js-tests.ts +++ b/types/handbrake-js/handbrake-js-tests.ts @@ -1,7 +1,7 @@ -import * as hb from 'handbrake-js'; +import * as hb from "handbrake-js"; const options: hb.HandbrakeOptions = { - version: true + version: true, }; hb.exec(options, (err, stdout, stderr) => { @@ -20,14 +20,14 @@ hb.run(options).then(result => { }); hb.spawn({ - input: 'something.avi', - output: 'something.mp4', - preset: 'Normal', - rotate: '1' -}).on('progress', (progress) => { + input: "something.avi", + output: "something.mp4", + preset: "Normal", + rotate: "1", +}).on("progress", (progress) => { console.log(progress.percentComplete); -}).on('error', (err) => { +}).on("error", (err) => { console.error(err); -}).on('end', () => { - console.log('Process ended'); +}).on("end", () => { + console.log("Process ended"); }); diff --git a/types/handbrake-js/index.d.ts b/types/handbrake-js/index.d.ts index 09b06efdad8ca3..8c4cbd099312de 100644 --- a/types/handbrake-js/index.d.ts +++ b/types/handbrake-js/index.d.ts @@ -5,187 +5,187 @@ /// -import { EventEmitter } from 'events'; +import { EventEmitter } from "events"; export interface HandbrakeOptions { // General - 'help'?: boolean | undefined; - 'h'?: boolean | undefined; // Alias for 'help' - 'version'?: boolean | undefined; - 'verbose'?: boolean | undefined; - 'v'?: boolean | undefined; // Alias for 'verbose' - 'preset'?: string | undefined; - 'Z'?: string | undefined; // Alias for 'preset' - 'preset-list'?: boolean | undefined; - 'z'?: boolean | undefined; // Alias for 'preset-list' - 'preset-import-file'?: string | undefined; - 'no-dvdnav'?: boolean | undefined; - 'no-opencl'?: boolean | undefined; + "help"?: boolean | undefined; + "h"?: boolean | undefined; // Alias for 'help' + "version"?: boolean | undefined; + "verbose"?: boolean | undefined; + "v"?: boolean | undefined; // Alias for 'verbose' + "preset"?: string | undefined; + "Z"?: string | undefined; // Alias for 'preset' + "preset-list"?: boolean | undefined; + "z"?: boolean | undefined; // Alias for 'preset-list' + "preset-import-file"?: string | undefined; + "no-dvdnav"?: boolean | undefined; + "no-opencl"?: boolean | undefined; // Source - 'input'?: string | undefined; - 'i'?: string | undefined; // Alias for 'input' - 'title'?: number | undefined; - 't'?: number | undefined; // Alias for 'title' - 'min-duration'?: number | undefined; - 'scan'?: boolean | undefined; - 'main-feature'?: boolean | undefined; - 'chapters'?: string | undefined; - 'c'?: string | undefined; // Alias for 'chapters' - 'angle'?: number | undefined; - 'previews'?: string | undefined; - 'start-at-preview'?: string | undefined; - 'start-at'?: string | undefined; - 'stop-at'?: string | undefined; + "input"?: string | undefined; + "i"?: string | undefined; // Alias for 'input' + "title"?: number | undefined; + "t"?: number | undefined; // Alias for 'title' + "min-duration"?: number | undefined; + "scan"?: boolean | undefined; + "main-feature"?: boolean | undefined; + "chapters"?: string | undefined; + "c"?: string | undefined; // Alias for 'chapters' + "angle"?: number | undefined; + "previews"?: string | undefined; + "start-at-preview"?: string | undefined; + "start-at"?: string | undefined; + "stop-at"?: string | undefined; // Destination - 'output'?: string | undefined; - 'o'?: string | undefined; // Alias for 'output' - 'format'?: string | undefined; - 'f'?: string | undefined; // Alias for 'format' - 'markers'?: boolean | undefined; - 'm'?: boolean | undefined; // Alias for 'markers' - 'no-markers'?: boolean | undefined; - 'optimize'?: boolean | undefined; - 'O'?: boolean | undefined; // Alias for 'optimize' - 'ipod-atom'?: boolean | undefined; - 'I'?: boolean | undefined; // Alias for 'ipod-atom' - 'no-ipod-atom'?: boolean | undefined; - 'use-opencl'?: boolean | undefined; - 'P'?: boolean | undefined; // Alias for 'use-opencl' + "output"?: string | undefined; + "o"?: string | undefined; // Alias for 'output' + "format"?: string | undefined; + "f"?: string | undefined; // Alias for 'format' + "markers"?: boolean | undefined; + "m"?: boolean | undefined; // Alias for 'markers' + "no-markers"?: boolean | undefined; + "optimize"?: boolean | undefined; + "O"?: boolean | undefined; // Alias for 'optimize' + "ipod-atom"?: boolean | undefined; + "I"?: boolean | undefined; // Alias for 'ipod-atom' + "no-ipod-atom"?: boolean | undefined; + "use-opencl"?: boolean | undefined; + "P"?: boolean | undefined; // Alias for 'use-opencl' // Video - 'encoder'?: string | undefined; - 'e'?: string | undefined; // Alias for 'encoder' - 'encoder-preset'?: string | undefined; - 'encoder-preset-list'?: string | undefined; - 'encoder-tune'?: string | undefined; - 'encoder-tune-list'?: string | undefined; - 'encopts'?: string | undefined; - 'x'?: string | undefined; // Alias for 'encopts' - 'encoder-profile'?: string | undefined; - 'encoder-profile-list'?: string | undefined; - 'encoder-level'?: string | undefined; - 'encoder-level-list'?: string | undefined; - 'quality'?: number | undefined; - 'q'?: number | undefined; // Alias for 'quality' - 'vb'?: number | undefined; - 'b'?: number | undefined; // Alias for 'vb' - 'two-pass'?: boolean | undefined; - 'no-two-pass'?: boolean | undefined; - 'turbo'?: boolean | undefined; - 'T'?: boolean | undefined; // Alias for 'turbo' - 'no-turbo'?: boolean | undefined; - 'rate'?: number | undefined; - 'r'?: number | undefined; // Alias for 'rate' - 'vfr'?: boolean | undefined; - 'cfr'?: boolean | undefined; - 'pfr'?: boolean | undefined; + "encoder"?: string | undefined; + "e"?: string | undefined; // Alias for 'encoder' + "encoder-preset"?: string | undefined; + "encoder-preset-list"?: string | undefined; + "encoder-tune"?: string | undefined; + "encoder-tune-list"?: string | undefined; + "encopts"?: string | undefined; + "x"?: string | undefined; // Alias for 'encopts' + "encoder-profile"?: string | undefined; + "encoder-profile-list"?: string | undefined; + "encoder-level"?: string | undefined; + "encoder-level-list"?: string | undefined; + "quality"?: number | undefined; + "q"?: number | undefined; // Alias for 'quality' + "vb"?: number | undefined; + "b"?: number | undefined; // Alias for 'vb' + "two-pass"?: boolean | undefined; + "no-two-pass"?: boolean | undefined; + "turbo"?: boolean | undefined; + "T"?: boolean | undefined; // Alias for 'turbo' + "no-turbo"?: boolean | undefined; + "rate"?: number | undefined; + "r"?: number | undefined; // Alias for 'rate' + "vfr"?: boolean | undefined; + "cfr"?: boolean | undefined; + "pfr"?: boolean | undefined; // Audio - 'audio-lang-list'?: string | undefined; - 'all-audio'?: boolean | undefined; - 'first-audio'?: boolean | undefined; - 'audio'?: string | undefined; - 'a'?: string | undefined; // Alias for 'audio' - 'aencoder'?: string | undefined; - 'E'?: string | undefined; // Alias for 'aencoder' - 'audio-copy-mask'?: string | undefined; - 'audio-fallback'?: string | undefined; - 'ab'?: string | undefined; - 'B'?: string | undefined; // Alias for 'ab' - 'aq'?: string | undefined; - 'Q'?: string | undefined; // Alias for 'aq' - 'ac'?: string | undefined; - 'C'?: string | undefined; // Alias for 'ac' - 'mixdown'?: string | undefined; - 'normalize-mix'?: string | undefined; - 'arate'?: string | undefined; - 'R'?: string | undefined; // Alias for 'arate' - 'drc'?: number | undefined; - 'D'?: number | undefined; // Alias for 'drc' - 'gain'?: number | undefined; - 'adither'?: string | undefined; - 'aname'?: string | undefined; - 'A'?: string | undefined; // Alias for 'aname' + "audio-lang-list"?: string | undefined; + "all-audio"?: boolean | undefined; + "first-audio"?: boolean | undefined; + "audio"?: string | undefined; + "a"?: string | undefined; // Alias for 'audio' + "aencoder"?: string | undefined; + "E"?: string | undefined; // Alias for 'aencoder' + "audio-copy-mask"?: string | undefined; + "audio-fallback"?: string | undefined; + "ab"?: string | undefined; + "B"?: string | undefined; // Alias for 'ab' + "aq"?: string | undefined; + "Q"?: string | undefined; // Alias for 'aq' + "ac"?: string | undefined; + "C"?: string | undefined; // Alias for 'ac' + "mixdown"?: string | undefined; + "normalize-mix"?: string | undefined; + "arate"?: string | undefined; + "R"?: string | undefined; // Alias for 'arate' + "drc"?: number | undefined; + "D"?: number | undefined; // Alias for 'drc' + "gain"?: number | undefined; + "adither"?: string | undefined; + "aname"?: string | undefined; + "A"?: string | undefined; // Alias for 'aname' // Picture - 'width'?: number | undefined; - 'w'?: number | undefined; // Alias for 'width' - 'height'?: number | undefined; - 'l'?: number | undefined; // Alias for 'height' - 'crop'?: string | undefined; - 'loose-crop'?: boolean | undefined; - 'no-loose-crop'?: boolean | undefined; - 'maxHeight'?: number | undefined; - 'Y'?: number | undefined; // Alias for 'maxHeight' - 'maxWidth'?: number | undefined; - 'X'?: number | undefined; // Alias for 'maxWidth' - 'non-anamorphic'?: boolean | undefined; - 'auto-anamorphic'?: boolean | undefined; - 'loose-anamorphic'?: boolean | undefined; - 'custom-anamorphic'?: boolean | undefined; - 'display-width'?: number | undefined; - 'keep-display-aspect'?: boolean | undefined; - 'pixel-aspect'?: string | undefined; - 'itu-par'?: boolean | undefined; - 'modulus'?: number | undefined; - 'color-matrix'?: string | undefined; - 'M'?: string | undefined; // Alias for 'color-matrix' + "width"?: number | undefined; + "w"?: number | undefined; // Alias for 'width' + "height"?: number | undefined; + "l"?: number | undefined; // Alias for 'height' + "crop"?: string | undefined; + "loose-crop"?: boolean | undefined; + "no-loose-crop"?: boolean | undefined; + "maxHeight"?: number | undefined; + "Y"?: number | undefined; // Alias for 'maxHeight' + "maxWidth"?: number | undefined; + "X"?: number | undefined; // Alias for 'maxWidth' + "non-anamorphic"?: boolean | undefined; + "auto-anamorphic"?: boolean | undefined; + "loose-anamorphic"?: boolean | undefined; + "custom-anamorphic"?: boolean | undefined; + "display-width"?: number | undefined; + "keep-display-aspect"?: boolean | undefined; + "pixel-aspect"?: string | undefined; + "itu-par"?: boolean | undefined; + "modulus"?: number | undefined; + "color-matrix"?: string | undefined; + "M"?: string | undefined; // Alias for 'color-matrix' // Filters - 'comb-detect'?: string | undefined; - 'no-comb-detect'?: boolean | undefined; - 'deinterlace'?: string | undefined; - 'd'?: string | undefined; // Alias for 'deinterlace' - 'no-deinterlace'?: boolean | undefined; - 'decomb'?: string | undefined; - 'no-decomb'?: boolean | undefined; - 'detelecine'?: string | undefined; - 'no-detelecine'?: boolean | undefined; - 'hqdn3d'?: string | undefined; - 'no-hqdn3d'?: boolean | undefined; - 'denoise'?: string | undefined; - 'nlmeans'?: string | undefined; - 'no-nlmeans'?: boolean | undefined; - 'nlmeans-tune'?: string | undefined; - 'deblock'?: string | undefined; - 'no-deblock'?: boolean | undefined; - 'rotate'?: string | undefined; - 'pad'?: string | undefined; - 'grayscale'?: boolean | undefined; - 'g'?: boolean | undefined; // Alias for 'grayscale' - 'no-grayscale'?: boolean | undefined; + "comb-detect"?: string | undefined; + "no-comb-detect"?: boolean | undefined; + "deinterlace"?: string | undefined; + "d"?: string | undefined; // Alias for 'deinterlace' + "no-deinterlace"?: boolean | undefined; + "decomb"?: string | undefined; + "no-decomb"?: boolean | undefined; + "detelecine"?: string | undefined; + "no-detelecine"?: boolean | undefined; + "hqdn3d"?: string | undefined; + "no-hqdn3d"?: boolean | undefined; + "denoise"?: string | undefined; + "nlmeans"?: string | undefined; + "no-nlmeans"?: boolean | undefined; + "nlmeans-tune"?: string | undefined; + "deblock"?: string | undefined; + "no-deblock"?: boolean | undefined; + "rotate"?: string | undefined; + "pad"?: string | undefined; + "grayscale"?: boolean | undefined; + "g"?: boolean | undefined; // Alias for 'grayscale' + "no-grayscale"?: boolean | undefined; // Subtitle - 'subtitle-lang-list'?: string | undefined; - 'all-subtitles'?: boolean | undefined; - 'first-subtitles'?: boolean | undefined; - 'subtitle'?: string | undefined; - 's'?: string | undefined; // Alias for 'subtitle' - 'subtitle-forced'?: number | undefined; - 'F'?: number | undefined; // Alias for 'subtitle-forced' - 'subtitle-burned'?: number | undefined; - 'subtitle-default'?: number | undefined; - 'native-language'?: string | undefined; - 'N'?: string | undefined; // Alias for 'native-language' - 'native-dub'?: boolean | undefined; - 'srt-file'?: string | undefined; - 'srt-codeset'?: string | undefined; - 'srt-offset'?: string | undefined; - 'srt-lang'?: string | undefined; - 'srt-default'?: number | undefined; - 'srt-burn'?: number | undefined; + "subtitle-lang-list"?: string | undefined; + "all-subtitles"?: boolean | undefined; + "first-subtitles"?: boolean | undefined; + "subtitle"?: string | undefined; + "s"?: string | undefined; // Alias for 'subtitle' + "subtitle-forced"?: number | undefined; + "F"?: number | undefined; // Alias for 'subtitle-forced' + "subtitle-burned"?: number | undefined; + "subtitle-default"?: number | undefined; + "native-language"?: string | undefined; + "N"?: string | undefined; // Alias for 'native-language' + "native-dub"?: boolean | undefined; + "srt-file"?: string | undefined; + "srt-codeset"?: string | undefined; + "srt-offset"?: string | undefined; + "srt-lang"?: string | undefined; + "srt-default"?: number | undefined; + "srt-burn"?: number | undefined; [key: string]: unknown; } export enum HandbrakeErrors { - VALIDATION = 'ValidationError', - INVALID_INPUT = 'InvalidInput', - INVALID_PRESET = 'InvalidPreset', - OTHER = 'Other', - NOT_FOUND = 'HandbrakeCLINotFound' + VALIDATION = "ValidationError", + INVALID_INPUT = "InvalidInput", + INVALID_PRESET = "InvalidPreset", + OTHER = "Other", + NOT_FOUND = "HandbrakeCLINotFound", } export interface HandbrakeProgress { @@ -195,7 +195,7 @@ export interface HandbrakeProgress { readonly fps: number; readonly avgFps: number; readonly eta: string; - readonly task: 'Encoding' | 'Muxing'; + readonly task: "Encoding" | "Muxing"; } export interface Handbrake extends EventEmitter { @@ -205,12 +205,12 @@ export interface Handbrake extends EventEmitter { cancel(): void; - on(event: 'start' | 'begin' | 'end' | 'complete' | 'cancelled', cb: () => void): this; - on(event: 'progress', cb: (progress: HandbrakeProgress) => void): this; - on(event: 'output', cb: (output: string) => void): this; - on(event: 'error', cb: (error: Error) => void): this; + on(event: "start" | "begin" | "end" | "complete" | "cancelled", cb: () => void): this; + on(event: "progress", cb: (progress: HandbrakeProgress) => void): this; + on(event: "output", cb: (output: string) => void): this; + on(event: "error", cb: (error: Error) => void): this; } export function exec(options: HandbrakeOptions, cb?: (err: Error | null, stdout: string, stderr: string) => void): void; -export function run(options: HandbrakeOptions): Promise<{ stdout: string, stderr: string }>; +export function run(options: HandbrakeOptions): Promise<{ stdout: string; stderr: string }>; export function spawn(options: HandbrakeOptions): Handbrake; diff --git a/types/handlebars-helpers/handlebars-helpers-tests.ts b/types/handlebars-helpers/handlebars-helpers-tests.ts index c03ac56fd419eb..d4db9809227c23 100644 --- a/types/handlebars-helpers/handlebars-helpers-tests.ts +++ b/types/handlebars-helpers/handlebars-helpers-tests.ts @@ -1,11 +1,11 @@ -import * as Handlebars from 'handlebars'; -import * as helpers from 'handlebars-helpers'; +import * as Handlebars from "handlebars"; +import * as helpers from "handlebars-helpers"; const handlebars = Handlebars.create(); helpers(); -helpers('helper'); -helpers(['helper']); -helpers({handlebars}); -helpers('helper', {handlebars}); -helpers(['helper'], {handlebars}); +helpers("helper"); +helpers(["helper"]); +helpers({ handlebars }); +helpers("helper", { handlebars }); +helpers(["helper"], { handlebars }); diff --git a/types/handlebars-helpers/index.d.ts b/types/handlebars-helpers/index.d.ts index c05870f219a379..79e651b1ddc53e 100644 --- a/types/handlebars-helpers/index.d.ts +++ b/types/handlebars-helpers/index.d.ts @@ -4,9 +4,12 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -import * as Handlebars from 'handlebars'; +import * as Handlebars from "handlebars"; -declare function helpers(groups?: helpers.Options | string | string[], options?: helpers.Options): { [name: string]: Handlebars.HelperDelegate }; +declare function helpers( + groups?: helpers.Options | string | string[], + options?: helpers.Options, +): { [name: string]: Handlebars.HelperDelegate }; interface Utils { /** diff --git a/types/handlebars-webpack-plugin/handlebars-webpack-plugin-tests.ts b/types/handlebars-webpack-plugin/handlebars-webpack-plugin-tests.ts index f9dfcfa30cd838..caade09fd5ec7b 100644 --- a/types/handlebars-webpack-plugin/handlebars-webpack-plugin-tests.ts +++ b/types/handlebars-webpack-plugin/handlebars-webpack-plugin-tests.ts @@ -1,6 +1,6 @@ -import path = require('path'); -import HandlebarsPlugin = require('handlebars-webpack-plugin'); -import HtmlWebpackPlugin = require('html-webpack-plugin'); +import path = require("path"); +import HandlebarsPlugin = require("handlebars-webpack-plugin"); +import HtmlWebpackPlugin = require("html-webpack-plugin"); module.exports = { plugins: [ @@ -8,40 +8,40 @@ module.exports = { new HandlebarsPlugin({}), new HandlebarsPlugin({ htmlWebpackPlugin: { - title: 'hey', + title: "hey", }, }), new HandlebarsPlugin({ htmlWebpackPlugin: { - title: 'hey', + title: "hey", HtmlWebpackPlugin, }, }), new HandlebarsPlugin({ - entry: path.join(process.cwd(), 'app', 'src', '*.hbs'), - output: path.join(process.cwd(), 'build', '[name].html'), - data: require('package.json'), - partials: [path.join(process.cwd(), 'app', 'src', 'components', '*', '*.hbs')], + entry: path.join(process.cwd(), "app", "src", "*.hbs"), + output: path.join(process.cwd(), "build", "[name].html"), + data: require("package.json"), + partials: [path.join(process.cwd(), "app", "src", "components", "*", "*.hbs")], helpers: { hi: (arg1, arg2, options) => {}, hey: (arg1, arg2, options) => {}, }, getTargetFilepath: (filepath, outputTemplate, rootFolder) => { - const fileName = path.basename(filepath).replace(path.extname(filepath), ''); - return outputTemplate.replace('[name]', fileName); + const fileName = path.basename(filepath).replace(path.extname(filepath), ""); + return outputTemplate.replace("[name]", fileName); }, getPartialId: filePath => { return filePath.match(/\/([^/]+\/[^/]+)\.[^.]+$/)?.pop(); }, }), new HandlebarsPlugin({ - entry: path.join(process.cwd(), 'app', 'src', '*.hbs'), - output: path.join(process.cwd(), 'build', '[name].html'), - data: path.join(__dirname, 'app/data/project.json'), - partials: [path.join(process.cwd(), 'app', 'src', 'components', '*', '*.hbs')], + entry: path.join(process.cwd(), "app", "src", "*.hbs"), + output: path.join(process.cwd(), "build", "[name].html"), + data: path.join(__dirname, "app/data/project.json"), + partials: [path.join(process.cwd(), "app", "src", "components", "*", "*.hbs")], helpers: { is: (arg1, arg2, options) => {}, - projectHelpers: path.join(process.cwd(), 'app', 'helpers', '*.helper.js'), + projectHelpers: path.join(process.cwd(), "app", "helpers", "*.helper.js"), }, onBeforeSetup: Handlebars => {}, onBeforeAddPartials: (Handlebars, partialsMap) => {}, diff --git a/types/handlebars-webpack-plugin/index.d.ts b/types/handlebars-webpack-plugin/index.d.ts index 4216b0b4690827..ede802d344c027 100644 --- a/types/handlebars-webpack-plugin/index.d.ts +++ b/types/handlebars-webpack-plugin/index.d.ts @@ -5,11 +5,11 @@ // TypeScript Version: 3.7 // Minimum TypeScript Version: 3.7 -import { Compiler, WebpackPluginInstance } from 'webpack'; -import { HelperDeclareSpec } from 'handlebars'; -import { Options } from 'html-webpack-plugin'; +import { HelperDeclareSpec } from "handlebars"; +import { Options } from "html-webpack-plugin"; +import { Compiler, WebpackPluginInstance } from "webpack"; -import HtmlWebpackPlugin = require('html-webpack-plugin'); +import HtmlWebpackPlugin = require("html-webpack-plugin"); declare class HandlebarsWebpackPlugin implements WebpackPluginInstance { constructor(options?: HandlebarsWebpackPlugin.PluginOptions); @@ -68,7 +68,9 @@ declare namespace HandlebarsWebpackPlugin { /** * Modify the default output path of each entry-template */ - getTargetFilepath?: ((filepath: string, outputTemplate: string, rootFolder: string) => string | undefined) | undefined; + getTargetFilepath?: + | ((filepath: string, outputTemplate: string, rootFolder: string) => string | undefined) + | undefined; /** * Modify the hbs partial-id created for a loaded partial diff --git a/types/hapi-auth-basic/hapi-auth-basic-tests.ts b/types/hapi-auth-basic/hapi-auth-basic-tests.ts index 63ce81675a59bc..1d8edfa9ae1e0e 100644 --- a/types/hapi-auth-basic/hapi-auth-basic-tests.ts +++ b/types/hapi-auth-basic/hapi-auth-basic-tests.ts @@ -1,8 +1,8 @@ // from https://github.com/hapijs/hapi-auth-basic#hapi-auth-basic -import Bcrypt = require('bcrypt'); -import Basic = require('hapi-auth-basic'); -import { Server } from 'hapi'; +import Bcrypt = require("bcrypt"); +import Basic = require("hapi-auth-basic"); +import { Server } from "hapi"; const server = new Server(); @@ -13,31 +13,29 @@ interface User { id: string; } -const users: {[index: string]: User} = { +const users: { [index: string]: User } = { john: { - username: 'john', - password: '$2a$10$iqJSHD.BGr0E2IxQwYgJmeP3NvhPrXAeLSaGCj6IR/XU5QtjVu5Tm', // 'secret' - name: 'John Doe', - id: '2133d32a' - } + username: "john", + password: "$2a$10$iqJSHD.BGr0E2IxQwYgJmeP3NvhPrXAeLSaGCj6IR/XU5QtjVu5Tm", // 'secret' + name: "John Doe", + id: "2133d32a", + }, }; const validate: Basic.Validate = async (request, username, password, h) => { - const user = users[username]; if (!user) { return { isValid: false, credentials: null }; } - let isValid = await Bcrypt.compare(password, user.password) + let isValid = await Bcrypt.compare(password, user.password); return { isValid, credentials: { id: user.id, name: user.name } }; }; server.register(Basic).then(() => { + server.auth.strategy("simple", "basic", { validate }); + server.auth.default("simple"); - server.auth.strategy('simple', 'basic', { validate }); - server.auth.default('simple'); - - server.route({ method: 'GET', path: '/', options: { auth: 'simple' } }); + server.route({ method: "GET", path: "/", options: { auth: "simple" } }); }); diff --git a/types/hapi-auth-basic/index.d.ts b/types/hapi-auth-basic/index.d.ts index 567dcd3f8f3810..01aaf5859c0980 100644 --- a/types/hapi-auth-basic/index.d.ts +++ b/types/hapi-auth-basic/index.d.ts @@ -5,20 +5,25 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -import { Plugin, Request, ResponseToolkit } from 'hapi'; +import { Plugin, Request, ResponseToolkit } from "hapi"; declare namespace Basic { interface ValidateCustomResponse { - response: any, + response: any; } interface ValidateResponse { - isValid: boolean, - credentials?: any, + isValid: boolean; + credentials?: any; } interface Validate { - (request: Request, username: string, password: string, h: ResponseToolkit): Promise; + ( + request: Request, + username: string, + password: string, + h: ResponseToolkit, + ): Promise; } } diff --git a/types/hapi-auth-bearer-token/hapi-auth-bearer-token-tests.ts b/types/hapi-auth-bearer-token/hapi-auth-bearer-token-tests.ts index 040fb6e0119287..7db25c8fa148ee 100644 --- a/types/hapi-auth-bearer-token/hapi-auth-bearer-token-tests.ts +++ b/types/hapi-auth-bearer-token/hapi-auth-bearer-token-tests.ts @@ -1,35 +1,35 @@ // from https://github.com/johnbrett/hapi-auth-bearer-token -import { Server } from '@hapi/hapi'; -import * as AuthBearer from 'hapi-auth-bearer-token'; +import { Server } from "@hapi/hapi"; +import * as AuthBearer from "hapi-auth-bearer-token"; const server = new Server({ port: 8080 }); const start = async () => { await server.register(AuthBearer); - server.auth.strategy('simple', 'bearer-access-token', { - allowQueryToken: true, // optional, false by default + server.auth.strategy("simple", "bearer-access-token", { + allowQueryToken: true, // optional, false by default validate: (async (request, token, h) => { // here is where you validate your token // comparing with token from your database for example - const isValid = token === '1234'; + const isValid = token === "1234"; const credentials = { token }; - const artifacts = { test: 'info' }; + const artifacts = { test: "info" }; return { isValid, credentials, artifacts }; - }) as AuthBearer.Validate + }) as AuthBearer.Validate, }); - server.auth.default('simple'); + server.auth.default("simple"); server.route({ - method: 'GET', - path: '/', + method: "GET", + path: "/", handler: async (request, h) => { - return { info: 'success!' }; - } + return { info: "success!" }; + }, }); await server.start(); diff --git a/types/hapi-auth-bearer-token/index.d.ts b/types/hapi-auth-bearer-token/index.d.ts index 71d72d0f8bc94e..366efa39f0c604 100644 --- a/types/hapi-auth-bearer-token/index.d.ts +++ b/types/hapi-auth-bearer-token/index.d.ts @@ -2,38 +2,33 @@ // Project: https://github.com/johnbrett/hapi-auth-bearer-token // Definitions by: Rodrigo Saboya // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 +// Minimum TypeScript Version: 4.9 -import { - Request, - Plugin, - ResponseToolkit, - AuthenticationData, - } from '@hapi/hapi'; +import { AuthenticationData, Plugin, Request, ResponseToolkit } from "@hapi/hapi"; - type ValidateReturn = AuthenticationData & { isValid: boolean }; +type ValidateReturn = AuthenticationData & { isValid: boolean }; - declare module '@hapi/hapi' { +declare module "@hapi/hapi" { interface ServerAuth { - strategy(name: string, scheme: 'bearer-access-token', options: BearerToken.SchemaOptions): void; + strategy(name: string, scheme: "bearer-access-token", options: BearerToken.SchemaOptions): void; } - } +} - declare namespace BearerToken { +declare namespace BearerToken { interface SchemaOptions { - validate: Validate; - accessTokenName?: string | undefined; - allowQueryToken?: boolean | undefined; - allowCookieToken?: boolean | undefined; - allowMultipleHeaders?: boolean | undefined; - allowChaining?: boolean | undefined; - tokenType?: string | undefined; - unauthorized?: ((message: string | null, scheme: string) => any) | undefined; + validate: Validate; + accessTokenName?: string | undefined; + allowQueryToken?: boolean | undefined; + allowCookieToken?: boolean | undefined; + allowMultipleHeaders?: boolean | undefined; + allowChaining?: boolean | undefined; + tokenType?: string | undefined; + unauthorized?: ((message: string | null, scheme: string) => any) | undefined; } type Validate = (request: Request, token: string, h: ResponseToolkit) => Promise | ValidateReturn; - } +} - declare var BearerToken: Plugin<{}>; +declare var BearerToken: Plugin<{}>; - export = BearerToken; +export = BearerToken; diff --git a/types/hapi-auth-cookie/hapi-auth-cookie-tests.ts b/types/hapi-auth-cookie/hapi-auth-cookie-tests.ts index 4df23a695548d3..4fe911d373b605 100644 --- a/types/hapi-auth-cookie/hapi-auth-cookie-tests.ts +++ b/types/hapi-auth-cookie/hapi-auth-cookie-tests.ts @@ -1,5 +1,5 @@ -import * as hapi from 'hapi'; -import * as auth from 'hapi-auth-cookie'; +import * as hapi from "hapi"; +import * as auth from "hapi-auth-cookie"; const server = new hapi.Server({ port: 8000 }); @@ -10,26 +10,30 @@ server.register({ const options: auth.Options = { cookie: { clearInvalid: true, - name: 'session', - domain: '.typescript.org', - password: 'abcdef', - isSecure: true, - ttl: 259200000, + name: "session", + domain: ".typescript.org", + password: "abcdef", + isSecure: true, + ttl: 259200000, }, - keepAlive: true, - redirectTo: '/login', - appendNext: false, + keepAlive: true, + redirectTo: "/login", + appendNext: false, validateFunc: async () => { return { valid: true }; }, }; -server.auth.strategy('session', 'cookie', options); +server.auth.strategy("session", "cookie", options); -server.route({ method: 'get', path: '/', handler: async (request) => { - request.cookieAuth.set('key', 'value'); - request.cookieAuth.set({ user: request.params.user }); - request.cookieAuth.clear(); - request.cookieAuth.clear('key'); - request.cookieAuth.ttl(1000); -}}); +server.route({ + method: "get", + path: "/", + handler: async (request) => { + request.cookieAuth.set("key", "value"); + request.cookieAuth.set({ user: request.params.user }); + request.cookieAuth.clear(); + request.cookieAuth.clear("key"); + request.cookieAuth.ttl(1000); + }, +}); diff --git a/types/hapi-auth-cookie/index.d.ts b/types/hapi-auth-cookie/index.d.ts index 94babd8ddb96f4..5bf8d9e39d6667 100644 --- a/types/hapi-auth-cookie/index.d.ts +++ b/types/hapi-auth-cookie/index.d.ts @@ -3,17 +3,17 @@ // Definitions by: Silas Rech // Simon Schick // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 +// Minimum TypeScript Version: 4.9 -import { Request, ResponseObject, Plugin, ResponseToolkit, AuthCredentials, ServerStateCookieOptions } from 'hapi'; +import { AuthCredentials, Plugin, Request, ResponseObject, ResponseToolkit, ServerStateCookieOptions } from "hapi"; -declare module 'hapi' { +declare module "hapi" { interface ServerAuth { - strategy(name: string, scheme: 'cookie', options?: hapiAuthCookie.Options): void; + strategy(name: string, scheme: "cookie", options?: hapiAuthCookie.Options): void; } interface PluginSpecificConfiguration { - 'hapi-auth-cookie'?: { + "hapi-auth-cookie"?: { redirectTo?: boolean | undefined; } | undefined; } @@ -29,7 +29,10 @@ declare module 'hapi' { } declare namespace hapiAuthCookie { - interface ValidateResponse { valid: boolean; credentials?: AuthCredentials | undefined; } + interface ValidateResponse { + valid: boolean; + credentials?: AuthCredentials | undefined; + } type ValidateFunction = (request?: Request, session?: object) => Promise; type RedirectToFunction = (request?: Request) => string; diff --git a/types/hapi-decorators/hapi-decorators-tests.ts b/types/hapi-decorators/hapi-decorators-tests.ts index 2a6f2df5b334c2..ee53f8b70da581 100644 --- a/types/hapi-decorators/hapi-decorators-tests.ts +++ b/types/hapi-decorators/hapi-decorators-tests.ts @@ -1,36 +1,36 @@ -import * as hapi from 'hapi'; -import { controller, get, post, put, cache, config, route, validate, Controller } from 'hapi-decorators'; +import * as hapi from "hapi"; +import { cache, config, Controller, controller, get, post, put, route, validate } from "hapi-decorators"; -@controller('/test') +@controller("/test") class TestController implements Controller { baseUrl: string; routes: () => hapi.RouteConfiguration[]; - @get('/') + @get("/") @config({ - auth: false + auth: false, }) @cache({ - expiresIn: 42000 + expiresIn: 42000, }) @validate({ - payload: false + payload: false, }) getHandler(request: hapi.Request, reply: hapi.ReplyNoContinue) { reply({ success: true }); } - @post('/') + @post("/") postHandler(request: hapi.Request, reply: hapi.ReplyNoContinue) { reply({ success: true }); } - @put('/{id}') + @put("/{id}") putHandler(request: hapi.Request, reply: hapi.ReplyNoContinue) { reply({ success: true }); } - @route('delete', '/{id}') + @route("delete", "/{id}") deleteHandler(request: hapi.Request, reply: hapi.ReplyNoContinue) { reply({ success: true }); } @@ -40,9 +40,8 @@ const server = new hapi.Server(); server.route(new TestController().routes()); -@controller('/test') +@controller("/test") class SimpleTestController implements Controller { - foo: string; constructor(foo: string) { @@ -53,4 +52,4 @@ class SimpleTestController implements Controller { routes: () => hapi.RouteConfiguration[]; } -server.route(new SimpleTestController('bar').routes()); +server.route(new SimpleTestController("bar").routes()); diff --git a/types/hapi-decorators/index.d.ts b/types/hapi-decorators/index.d.ts index 0f0e2866865faa..fa3f7169281a6f 100644 --- a/types/hapi-decorators/index.d.ts +++ b/types/hapi-decorators/index.d.ts @@ -2,12 +2,12 @@ // Project: https://github.com/knownasilya/hapi-decorators // Definitions by: Ken Howard // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 +// Minimum TypeScript Version: 4.9 -import * as hapi from 'hapi'; -import * as Joi from 'joi'; +import * as hapi from "hapi"; +import * as Joi from "joi"; interface ControllerStatic { - new (...args: any[]): Controller; + new(...args: any[]): Controller; } export interface Controller { baseUrl: string; @@ -30,9 +30,13 @@ export const put: IRouteConfig; // export const delete: IRouteConfig; export const patch: IRouteConfig; export const all: IRouteConfig; -export function config(config: hapi.RouteAdditionalConfigurationOptions): (target: any, key: any, descriptor: any) => any; +export function config( + config: hapi.RouteAdditionalConfigurationOptions, +): (target: any, key: any, descriptor: any) => any; -export function validate(config: hapi.RouteValidationConfigurationObject): (target: any, key: any, descriptor: any) => any; +export function validate( + config: hapi.RouteValidationConfigurationObject, +): (target: any, key: any, descriptor: any) => any; interface ICacheConfig { privacy?: string | undefined; expiresIn?: number | undefined; diff --git a/types/hapi-server-session/hapi-server-session-tests.ts b/types/hapi-server-session/hapi-server-session-tests.ts index 0a9a3fd787e94c..a2f753b3e37bc6 100644 --- a/types/hapi-server-session/hapi-server-session-tests.ts +++ b/types/hapi-server-session/hapi-server-session-tests.ts @@ -1,20 +1,20 @@ -import hapiServerSessionPlugin from 'hapi-server-session'; -import { Server } from '@hapi/hapi'; +import { Server } from "@hapi/hapi"; +import hapiServerSessionPlugin from "hapi-server-session"; const server = new Server(); server.register({ plugin: hapiServerSessionPlugin, options: { - algorithm: 'md5', - cache: { segment: 'test' }, + algorithm: "md5", + cache: { segment: "test" }, cookie: { ttl: null }, expiresIn: 86400, - key: 'test', - name: 'test', + key: "test", + name: "test", size: 32, - vhost: ['test'], + vhost: ["test"], }, }); -server.route({ path: '/', method: 'GET', handler: (request, _h) => request.session }); +server.route({ path: "/", method: "GET", handler: (request, _h) => request.session }); diff --git a/types/hapi-server-session/index.d.ts b/types/hapi-server-session/index.d.ts index f301093e97694d..63fdd2c1225841 100644 --- a/types/hapi-server-session/index.d.ts +++ b/types/hapi-server-session/index.d.ts @@ -2,11 +2,12 @@ // Project: https://github.com/btmorex/hapi-server-session // Definitions by: Avery Fay // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// Minimum TypeScript Version: 4.9 -import { BinaryLike } from 'crypto'; -import { CachePolicyOptions, Plugin, ServerStateCookieOptions } from '@hapi/hapi'; +import { CachePolicyOptions, Plugin, ServerStateCookieOptions } from "@hapi/hapi"; +import { BinaryLike } from "crypto"; -declare module '@hapi/hapi' { +declare module "@hapi/hapi" { interface Request { session: any; } diff --git a/types/hapi/index.d.ts b/types/hapi/index.d.ts index 94d850e80735b7..cfa08a601a5ce7 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -19,19 +19,27 @@ /// -import * as Boom from 'boom'; -import * as http from 'http'; -import * as https from 'https'; -import * as Shot from 'shot'; -import * as stream from 'stream'; -import * as url from 'url'; -import * as zlib from 'zlib'; - -import { MimosOptions } from 'mimos'; -import { SealOptions, SealOptionsSub } from 'iron'; -import { ValidationOptions, SchemaMap, Schema } from 'joi'; -import Podium = require('podium'); -import { PolicyOptionVariants, EnginePrototypeOrObject, PolicyOptions, EnginePrototype, Policy, ClientApi, ClientOptions } from 'catbox'; +import * as Boom from "boom"; +import * as http from "http"; +import * as https from "https"; +import * as Shot from "shot"; +import * as stream from "stream"; +import * as url from "url"; +import * as zlib from "zlib"; + +import { SealOptions, SealOptionsSub } from "iron"; +import { Schema, SchemaMap, ValidationOptions } from "joi"; +import { MimosOptions } from "mimos"; +import Podium = require("podium"); +import { + ClientApi, + ClientOptions, + EnginePrototype, + EnginePrototypeOrObject, + Policy, + PolicyOptions, + PolicyOptionVariants, +} from "catbox"; /* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -238,7 +246,7 @@ export interface RequestAuth { * 'disconnect' - emitted when a request errors or aborts unexpectedly. * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestevents) */ -export type RequestEventType = 'peek' | 'finish' | 'disconnect'; +export type RequestEventType = "peek" | "finish" | "disconnect"; /** * Access: read only and the public podium interface. @@ -257,9 +265,9 @@ export interface RequestEvents extends Podium { * * 'disconnect' - emitted when a request errors or aborts unexpectedly. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestevents) */ - on(criteria: 'peek', listener: PeekListener): void; + on(criteria: "peek", listener: PeekListener): void; - on(criteria: 'finish' | 'disconnect', listener: (data: undefined) => void): void; + on(criteria: "finish" | "disconnect", listener: (data: undefined) => void): void; /** * Access: read only and the public podium interface. @@ -269,9 +277,9 @@ export interface RequestEvents extends Podium { * * 'disconnect' - emitted when a request errors or aborts unexpectedly. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestevents) */ - once(criteria: 'peek', listener: PeekListener): void; + once(criteria: "peek", listener: PeekListener): void; - once(criteria: 'finish' | 'disconnect', listener: (data: undefined) => void): void; + once(criteria: "finish" | "disconnect", listener: (data: undefined) => void): void; } /** @@ -568,7 +576,15 @@ export interface Request extends Podium { * @return ResponseObject * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestgenerateresponsesource-options) */ - generateResponse(source: string | object | null, options?: { variety?: string | undefined; prepare?: ((response: ResponseObject) => Promise) | undefined; marshal?: ((response: ResponseObject) => Promise) | undefined; close?: ((response: ResponseObject) => void) | undefined; }): ResponseObject; + generateResponse( + source: string | object | null, + options?: { + variety?: string | undefined; + prepare?: ((response: ResponseObject) => Promise) | undefined; + marshal?: ((response: ResponseObject) => Promise) | undefined; + close?: ((response: ResponseObject) => void) | undefined; + }, + ): ResponseObject; /** * Logs request-specific events. When called, the server emits a 'request' event which can be used by other listeners or plugins. The arguments are: @@ -625,17 +641,17 @@ export interface ResponseEvents extends Podium { * 'peek' - emitted for each chunk of data written back to the client connection. The event method signature is function(chunk, encoding). * 'finish' - emitted when the response finished writing but before the client response connection is ended. The event method signature is function (). */ - on(criteria: 'peek', listener: PeekListener): void; + on(criteria: "peek", listener: PeekListener): void; - on(criteria: 'finish', listener: (data: undefined) => void): void; + on(criteria: "finish", listener: (data: undefined) => void): void; /** * 'peek' - emitted for each chunk of data written back to the client connection. The event method signature is function(chunk, encoding). * 'finish' - emitted when the response finished writing but before the client response connection is ended. The event method signature is function (). */ - once(criteria: 'peek', listener: PeekListener): void; + once(criteria: "peek", listener: PeekListener): void; - once(criteria: 'finish', listener: (data: undefined) => void): void; + once(criteria: "finish", listener: (data: undefined) => void): void; } /** @@ -719,7 +735,7 @@ export interface ResponseObject extends Podium { * * 'stream' - a Stream. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsevariety) */ - readonly variety: 'plain' | 'buffer' | 'stream'; + readonly variety: "plain" | "buffer" | "stream"; /** * Sets the HTTP 'Content-Length' header (to avoid chunked transfer encoding) where: @@ -775,7 +791,7 @@ export interface ResponseObject extends Podium { * @return Return value: the current response object. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseencodingencoding) */ - encoding(encoding: 'ascii' | 'utf8' | 'utf16le' | 'ucs2' | 'base64' | 'latin1' | 'binary' | 'hex'): ResponseObject; + encoding(encoding: "ascii" | "utf8" | "utf16le" | "ucs2" | "base64" | "latin1" | "binary" | "hex"): ResponseObject; /** * Sets the representation entity tag where: @@ -787,7 +803,7 @@ export interface ResponseObject extends Podium { * @return Return value: the current response object. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseetagtag-options) */ - etag(tag: string, options?: {weak: boolean, vary: boolean}): ResponseObject; + etag(tag: string, options?: { weak: boolean; vary: boolean }): ResponseObject; /** * Sets an HTTP header where: @@ -959,7 +975,6 @@ export interface ResponseSettings { /** * See more about Lifecycle * https://github.com/hapijs/hapi/blob/master/API.md#request-lifecycle - * */ export type ResponseValue = string | object; @@ -1044,7 +1059,9 @@ export interface ResponseToolkit { * it should be used as the return value (but may be customize using the response methods). * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-hentityoptions) */ - entity(options?: {etag?: string | undefined, modified?: string | undefined, vary?: boolean | undefined}): ResponseObject | undefined; + entity( + options?: { etag?: string | undefined; modified?: string | undefined; vary?: boolean | undefined }, + ): ResponseObject | undefined; /** * Redirects the client to the specified uri. Same as calling h.response().redirect(uri). @@ -1110,7 +1127,7 @@ export interface ResponseToolkit { export type RouteOptionsAccessScope = false | string | string[]; -export type RouteOptionsAccessEntity = 'any' | 'user' | 'app'; +export type RouteOptionsAccessEntity = "any" | "user" | "app"; export interface RouteOptionsAccessScopeObject { scope: RouteOptionsAccessScope; @@ -1121,7 +1138,7 @@ export interface RouteOptionsAccessEntityObject { } export type RouteOptionsAccessObject = - RouteOptionsAccessScopeObject + | RouteOptionsAccessScopeObject | RouteOptionsAccessEntityObject | (RouteOptionsAccessScopeObject & RouteOptionsAccessEntityObject); @@ -1166,7 +1183,7 @@ export interface RouteOptionsAccess { * * 'try' - similar to 'optional', any request credentials are attempted authentication, but if the credentials are invalid, the request proceeds regardless of the authentication error. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthmode) */ - mode?: 'required' | 'optional' | 'try' | undefined; + mode?: "required" | "optional" | "try" | undefined; /** * Default value: false, unless the scheme requires payload authentication. @@ -1177,7 +1194,7 @@ export interface RouteOptionsAccess { * * 'optional' - payload authentication performed only when the client includes payload authentication information (e.g. hash attribute in Hawk). * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthpayload) */ - payload?: false | 'required' | 'optional' | undefined; + payload?: false | "required" | "optional" | undefined; /** * Default value: the default strategy set via server.auth.default(). @@ -1205,21 +1222,23 @@ export interface RouteOptionsAccess { * * otherwise - a string with the value of the 'Cache-Control' header when caching is disabled. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionscache) */ -export type RouteOptionsCache = { - privacy?: 'default' | 'public' | 'private' | undefined; - statuses?: number[] | undefined; - otherwise?: string | undefined; -} & ( - { - expiresIn?: number | undefined; - expiresAt?: undefined; - } | { - expiresIn?: undefined; - expiresAt?: string | undefined; -} | { - expiresIn?: undefined; - expiresAt?: undefined; -} +export type RouteOptionsCache = + & { + privacy?: "default" | "public" | "private" | undefined; + statuses?: number[] | undefined; + otherwise?: string | undefined; + } + & ( + { + expiresIn?: number | undefined; + expiresAt?: undefined; + } | { + expiresIn?: undefined; + expiresAt?: string | undefined; + } | { + expiresIn?: undefined; + expiresAt?: undefined; + } ); /** @@ -1244,7 +1263,7 @@ export interface RouteOptionsCors { * character, or a single '*' origin string. If set to 'ignore', any incoming Origin header is ignored (present or not) and the 'Access-Control-Allow-Origin' header is set to '*'. Defaults to any * origin ['*']. */ - origin?: string[] | '*' | 'ignore' | undefined; + origin?: string[] | "*" | "ignore" | undefined; /** * number of seconds the browser should cache the CORS response ('Access-Control-Max-Age'). The greater the value, the longer it will take before the browser checks for changes in policy. * Defaults to 86400 (one day). @@ -1285,7 +1304,7 @@ export interface RouteOptionsCors { * which files are used (e.g. using the request.app object), and listening to the server 'response' event to perform cleanup. For context [See * docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadoutput) */ -export type PayloadOutput = 'data' | 'stream' | 'file'; +export type PayloadOutput = "data" | "stream" | "file"; /** * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadcompression) @@ -1352,7 +1371,7 @@ export interface RouteOptionsPayload { * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadmultipart) */ multipart?: false | { - output: PayloadOutput | 'annotated'; + output: PayloadOutput | "annotated"; } | undefined; /** @@ -1387,7 +1406,7 @@ export interface RouteOptionsPayload { * * 'gunzip' - the raw payload is returned unmodified after any known content encoding is decoded. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadparse) */ - parse?: boolean | 'gunzip' | undefined; + parse?: boolean | "gunzip" | undefined; /** * Default value: to 10000 (10 seconds). @@ -1447,7 +1466,7 @@ export type ValidationObject = SchemaMap; * * * options - options. */ export type RouteOptionsResponseSchema = - boolean + | boolean | ValidationObject | Schema | ((value: object | Buffer | string, options: ValidationOptions) => Promise); @@ -1538,8 +1557,16 @@ export interface RouteOptionsResponse { /** * @see https://www.w3.org/TR/referrer-policy/ */ -export type ReferrerPolicy = '' | 'no-referrer' | 'no-referrer-when-downgrade' | 'unsafe-url' | - 'same-origin' | 'origin' | 'strict-origin' | 'origin-when-cross-origin' | 'strict-origin-when-cross-origin'; +export type ReferrerPolicy = + | "" + | "no-referrer" + | "no-referrer-when-downgrade" + | "unsafe-url" + | "same-origin" + | "origin" + | "strict-origin" + | "origin-when-cross-origin" + | "strict-origin-when-cross-origin"; /** * Default value: false (security headers disabled). @@ -1590,11 +1617,11 @@ export interface RouteOptionsSecureObject { /** * controls the 'X-Frame-Options' header */ - xframe?: true | 'deny' | 'sameorigin' | { + xframe?: true | "deny" | "sameorigin" | { /** * an object for specifying the 'allow-from' rule, */ - rule: 'deny' | 'sameorigin' | 'allow-from'; + rule: "deny" | "sameorigin" | "allow-from"; /** * when rule is 'allow-from' this is used to form the rest of the header, otherwise this field is ignored. If rule is 'allow-from' but source is unset, the rule will be automatically changed * to 'sameorigin'. @@ -1805,9 +1832,11 @@ export interface RouteOptions { * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsext) * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#request-lifecycle) */ - ext?: { - [key in RouteRequestExtType]?: RouteExtObject | RouteExtObject[]; - } | undefined; + ext?: + | { + [key in RouteRequestExtType]?: RouteExtObject | RouteExtObject[]; + } + | undefined; /** * Default value: { relativeTo: '.' }. @@ -2270,7 +2299,7 @@ export interface ServerEventCriteria { * * * tags - a tag string or array of tag strings. * * * all - if true, all tags must be present for the event update to match the subscription. Defaults to false (at least one matching tag). */ - filter?: string | string[] | {tags: string | string[], all?: boolean | undefined} | undefined; + filter?: string | string[] | { tags: string | string[]; all?: boolean | undefined } | undefined; /** * if true, and the data object passed to server.event.emit() is an array, the listener method is called with each array element passed as a separate argument. This should only be used * when the emitted data structure is known and predictable. Defaults to the event registration option (which defaults to false). @@ -2289,7 +2318,7 @@ export interface LogEvent { /** an array of tags identifying the event (e.g. ['error', 'http']) */ tags: string[]; /** set to 'internal' for internally generated events, otherwise 'app' for events generated by server.log() */ - channel: 'internal' | 'app'; + channel: "internal" | "app"; /** the request identifier. */ request: string; /** event-specific information. Available when event data was provided and is not an error. Errors are passed via error. */ @@ -2304,7 +2333,7 @@ export interface RequestEvent { /** an array of tags identifying the event (e.g. ['error', 'http']) */ tags: string[]; /** set to 'internal' for internally generated events, otherwise 'app' for events generated by server.log() */ - channel: 'internal' | 'app' | 'error'; + channel: "internal" | "app" | "error"; /** event-specific information. Available when event data was provided and is not an error. Errors are passed via error. */ data: object; /** the error object related to the event if applicable. Cannot appear together with data */ @@ -2362,17 +2391,17 @@ export interface ServerEvents extends Podium { * See ['start' event](https://github.com/hapijs/hapi/blob/master/API.md#-start-event) * See ['stop' event](https://github.com/hapijs/hapi/blob/master/API.md#-stop-event) */ - on(criteria: 'log' | ServerEventCriteria<'log'>, listener: LogEventHandler): void; + on(criteria: "log" | ServerEventCriteria<"log">, listener: LogEventHandler): void; - on(criteria: 'request' | ServerEventCriteria<'request'>, listener: RequestEventHandler): void; + on(criteria: "request" | ServerEventCriteria<"request">, listener: RequestEventHandler): void; - on(criteria: 'response' | ServerEventCriteria<'response'>, listener: ResponseEventHandler): void; + on(criteria: "response" | ServerEventCriteria<"response">, listener: ResponseEventHandler): void; - on(criteria: 'route' | ServerEventCriteria<'route'>, listener: RouteEventHandler): void; + on(criteria: "route" | ServerEventCriteria<"route">, listener: RouteEventHandler): void; - on(criteria: 'start' | ServerEventCriteria<'start'>, listener: StartEventHandler): void; + on(criteria: "start" | ServerEventCriteria<"start">, listener: StartEventHandler): void; - on(criteria: 'stop' | ServerEventCriteria<'stop'>, listener: StopEventHandler): void; + on(criteria: "stop" | ServerEventCriteria<"stop">, listener: StopEventHandler): void; /** * Same as calling [server.events.on()](https://github.com/hapijs/hapi/blob/master/API.md#server.events.on()) with the count option set to 1. @@ -2384,17 +2413,17 @@ export interface ServerEvents extends Podium { * @return Return value: none. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventsoncecriteria-listener) */ - once(criteria: 'log' | ServerEventCriteria<'log'>, listener: LogEventHandler): void; + once(criteria: "log" | ServerEventCriteria<"log">, listener: LogEventHandler): void; - once(criteria: 'request' | ServerEventCriteria<'request'>, listener: RequestEventHandler): void; + once(criteria: "request" | ServerEventCriteria<"request">, listener: RequestEventHandler): void; - once(criteria: 'response' | ServerEventCriteria<'response'>, listener: ResponseEventHandler): void; + once(criteria: "response" | ServerEventCriteria<"response">, listener: ResponseEventHandler): void; - once(criteria: 'route' | ServerEventCriteria<'route'>, listener: RouteEventHandler): void; + once(criteria: "route" | ServerEventCriteria<"route">, listener: RouteEventHandler): void; - once(criteria: 'start' | ServerEventCriteria<'start'>, listener: StartEventHandler): void; + once(criteria: "start" | ServerEventCriteria<"start">, listener: StartEventHandler): void; - once(criteria: 'stop' | ServerEventCriteria<'stop'>, listener: StopEventHandler): void; + once(criteria: "stop" | ServerEventCriteria<"stop">, listener: StopEventHandler): void; /** * Same as calling server.events.on() with the count option set to 1. @@ -2435,17 +2464,18 @@ export interface ServerEvents extends Podium { * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevents) * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#request-lifecycle) */ -export type ServerExtType = 'onPreStart' | 'onPostStart' | 'onPreStop' | 'onPostStop'; -export type RouteRequestExtType = 'onPreAuth' - | 'onCredentials' - | 'onPostAuth' - | 'onPreHandler' - | 'onPostHandler' - | 'onPreResponse'; +export type ServerExtType = "onPreStart" | "onPostStart" | "onPreStop" | "onPostStop"; +export type RouteRequestExtType = + | "onPreAuth" + | "onCredentials" + | "onPostAuth" + | "onPreHandler" + | "onPostHandler" + | "onPreResponse"; export type ServerRequestExtType = - RouteRequestExtType - | 'onRequest'; + | RouteRequestExtType + | "onRequest"; /** * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevents) @@ -2571,7 +2601,7 @@ export interface ServerExtOptions { * if set to 'plugin' when adding a request extension points the extension is only added to routes defined by the current plugin. Not allowed when configuring route-level extensions, or when * adding server extensions. Defaults to 'server' which applies to any route added to the server the extension is added to. */ - sandbox?: 'server' | 'plugin' | undefined; + sandbox?: "server" | "plugin" | undefined; } /** @@ -2618,7 +2648,7 @@ export interface ServerInfo { * * 'https' - HTTPS. * * 'socket' - UNIX domain socket or Windows named pipe. */ - protocol: 'http' | 'https' | 'socket'; + protocol: "http" | "https" | "socket"; /** * a string representing the connection (e.g. 'http://example.com:8080' or 'socket:/unix/domain/socket/path'). Contains @@ -3004,12 +3034,12 @@ export interface ServerOptions { // TODO I am not sure if I need to use all the server.state() definition (like the default value) OR only the options below. The v16 use "any" here. // state?: ServerStateCookieOptions; state?: { - strictHeader?: boolean | undefined, - ignoreErrors?: boolean | undefined, - isSecure?: boolean | undefined, - isHttpOnly?: boolean | undefined, - isSameSite?: false | 'Strict' | 'Lax' | undefined, - encoding?: 'none' | 'base64' | 'base64json' | 'form' | 'iron' | undefined + strictHeader?: boolean | undefined; + ignoreErrors?: boolean | undefined; + isSecure?: boolean | undefined; + isHttpOnly?: boolean | undefined; + isSameSite?: false | "Strict" | "Lax" | undefined; + encoding?: "none" | "base64" | "base64json" | "form" | "iron" | undefined; } | undefined; /** @@ -3056,7 +3086,7 @@ export interface ServerRealm { prefix: string; /** the route virtual host settings used by any calls to server.route() from the server. */ vhost: string; - } + }; }; /** the realm of the parent server object, or null for the root server. */ parent: ServerRealm | null; @@ -3131,14 +3161,18 @@ export interface ServerRegisterPluginObject extends ServerRegisterOptions { options?: T | undefined; } -export interface ServerRegisterPluginObjectArray extends Array - | ServerRegisterPluginObject - | ServerRegisterPluginObject - | ServerRegisterPluginObject - | ServerRegisterPluginObject - | ServerRegisterPluginObject - | ServerRegisterPluginObject - | undefined> { +export interface ServerRegisterPluginObjectArray extends + Array< + | ServerRegisterPluginObject + | ServerRegisterPluginObject + | ServerRegisterPluginObject + | ServerRegisterPluginObject + | ServerRegisterPluginObject + | ServerRegisterPluginObject + | ServerRegisterPluginObject + | undefined + > +{ 0: ServerRegisterPluginObject; 1?: ServerRegisterPluginObject | undefined; 2?: ServerRegisterPluginObject | undefined; @@ -3222,7 +3256,7 @@ export interface ServerStateCookieOptions { * * 'Strict' - sets the value to 'Strict' (this is the default value). * * 'Lax' - sets the value to 'Lax'. */ - isSameSite?: false | 'Strict' | 'Lax' | undefined; + isSameSite?: false | "Strict" | "Lax" | undefined; /** the path scope. Defaults to null (no path). */ path?: string | null | undefined; /** the domain scope. Defaults to null (no domain). */ @@ -3243,7 +3277,7 @@ export interface ServerStateCookieOptions { * * 'form' - object value is encoded using the x-www-form-urlencoded method. * * 'iron' - Encrypts and sign the value using iron. */ - encoding?: 'none' | 'base64' | 'base64json' | 'form' | 'iron' | undefined; + encoding?: "none" | "base64" | "base64json" | "form" | "iron" | undefined; /** * an object used to calculate an HMAC for cookie integrity validation. This does not provide privacy, only a mean * to verify that the cookie value was generated by the server. Redundant when 'iron' encoding is used. Options are: @@ -3404,15 +3438,15 @@ export class Server { /** * decorations on the request object. */ - request: string[], + request: string[]; /** * decorations on the response toolkit. */ - toolkit: string[], + toolkit: string[]; /** * decorations on the server object. */ - server: string[] + server: string[]; }; /** @@ -3491,7 +3525,7 @@ export class Server { /** * Max concurrent requests. */ - concurrent: number + concurrent: number; /** * V8 heap usage. */ @@ -3567,7 +3601,7 @@ export class Server { * * 'socket' - UNIX domain socket or Windows named pipe. * * 'tcp' - an HTTP listener. */ - readonly type: 'socket' | 'tcp'; + readonly type: "socket" | "tcp"; /** * The hapi module version number. @@ -3597,7 +3631,7 @@ export class Server { * @return Return value: none. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverdecoderencoding-decoder) */ - decoder(encoding: string, decoder: ((options: PayloadCompressionDecoderSettings) => zlib.Gunzip)): void; + decoder(encoding: string, decoder: (options: PayloadCompressionDecoderSettings) => zlib.Gunzip): void; /** * Extends various framework interfaces with custom methods where: @@ -3615,14 +3649,54 @@ export class Server { * @return void; * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverdecoratetype-property-method-options) */ - decorate(type: 'handler', property: DecorateName, method: HandlerDecorationMethod, options?: {apply?: boolean | undefined, extend?: boolean | undefined}): void; - decorate(type: 'request', property: DecorateName, method: (existing: ((...args: any[]) => any)) => (request: Request) => DecorationMethod, options: {apply: true, extend: true}): void; - decorate(type: 'request', property: DecorateName, method: (request: Request) => DecorationMethod, options: {apply: true, extend?: boolean | undefined}): void; - decorate(type: 'request', property: DecorateName, method: DecorationMethod, options?: {apply?: boolean | undefined, extend?: boolean | undefined}): void; - decorate(type: 'toolkit', property: DecorateName, method: (existing: ((...args: any[]) => any)) => DecorationMethod, options: {apply?: boolean | undefined, extend: true}): void; - decorate(type: 'toolkit', property: DecorateName, method: DecorationMethod, options?: {apply?: boolean | undefined, extend?: boolean | undefined}): void; - decorate(type: 'server', property: DecorateName, method: (existing: ((...args: any[]) => any)) => DecorationMethod, options: {apply?: boolean | undefined, extend: true}): void; - decorate(type: 'server', property: DecorateName, method: DecorationMethod, options?: {apply?: boolean | undefined, extend?: boolean | undefined}): void; + decorate( + type: "handler", + property: DecorateName, + method: HandlerDecorationMethod, + options?: { apply?: boolean | undefined; extend?: boolean | undefined }, + ): void; + decorate( + type: "request", + property: DecorateName, + method: (existing: (...args: any[]) => any) => (request: Request) => DecorationMethod, + options: { apply: true; extend: true }, + ): void; + decorate( + type: "request", + property: DecorateName, + method: (request: Request) => DecorationMethod, + options: { apply: true; extend?: boolean | undefined }, + ): void; + decorate( + type: "request", + property: DecorateName, + method: DecorationMethod, + options?: { apply?: boolean | undefined; extend?: boolean | undefined }, + ): void; + decorate( + type: "toolkit", + property: DecorateName, + method: (existing: (...args: any[]) => any) => DecorationMethod, + options: { apply?: boolean | undefined; extend: true }, + ): void; + decorate( + type: "toolkit", + property: DecorateName, + method: DecorationMethod, + options?: { apply?: boolean | undefined; extend?: boolean | undefined }, + ): void; + decorate( + type: "server", + property: DecorateName, + method: (existing: (...args: any[]) => any) => DecorationMethod, + options: { apply?: boolean | undefined; extend: true }, + ): void; + decorate( + type: "server", + property: DecorateName, + method: DecorationMethod, + options?: { apply?: boolean | undefined; extend?: boolean | undefined }, + ): void; /** * Used within a plugin to declare a required dependency on other plugins where: @@ -3636,7 +3710,7 @@ export class Server { * The method does not provide version dependency which should be implemented using npm peer dependencies. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverdependencydependencies-after) */ - dependency(dependencies: Dependencies, after?: ((server: Server) => Promise)): void; + dependency(dependencies: Dependencies, after?: (server: Server) => Promise): void; /** * Registers a custom content encoding compressor to extend the built-in support for 'gzip' and 'deflate' where: @@ -3646,7 +3720,7 @@ export class Server { * @return Return value: none. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverencoderencoding-encoder) */ - encoder(encoding: string, encoder: ((options: RouteCompressionEncoderSettings) => zlib.Gzip)): void; + encoder(encoding: string, encoder: (options: RouteCompressionEncoderSettings) => zlib.Gzip): void; /** * Used within a plugin to expose a property via server.plugins[name] where: @@ -3690,7 +3764,13 @@ export class Server { * @return void * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevents) */ - ext(events: ServerExtEventsObject | ServerExtEventsObject[] | ServerExtEventsRequestObject | ServerExtEventsRequestObject[]): void; + ext( + events: + | ServerExtEventsObject + | ServerExtEventsObject[] + | ServerExtEventsRequestObject + | ServerExtEventsRequestObject[], + ): void; /** * Registers a single extension event using the same properties as used in server.ext(events), but passed as arguments. @@ -3843,10 +3923,13 @@ export class Server { * @return Return value: none. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverregisterplugins-options) */ - /* eslint-disable-next-line @definitelytyped/no-unnecessary-generics */ + /* eslint-disable-next-line @definitelytyped/no-unnecessary-generics */ register(plugin: ServerRegisterPluginObject, options?: ServerRegisterOptions): Promise; /* eslint-disable-next-line @definitelytyped/no-unnecessary-generics */ - register(plugins: ServerRegisterPluginObjectArray, options?: ServerRegisterOptions): Promise; + register( + plugins: ServerRegisterPluginObjectArray, + options?: ServerRegisterOptions, + ): Promise; register(plugins: Array>, options?: ServerRegisterOptions): Promise; /* tslint:disable-next-line:unified-signatures */ register(plugins: Plugin | Array>, options?: ServerRegisterOptions): Promise; @@ -3890,7 +3973,10 @@ export class Server { * @return void * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverrulesprocessor-options) */ - rules(processor: (rules: object, info: {method: string, path: string, vhost?: string | undefined}) => object, options?: {validate: object}): void; // TODO needs implementation + rules( + processor: (rules: object, info: { method: string; path: string; vhost?: string | undefined }) => object, + options?: { validate: object }, + ): void; // TODO needs implementation /** * Starts the server by listening for incoming requests on the configured port (unless the connection was configured with autoListen set to false). @@ -3920,7 +4006,7 @@ export class Server { * @return Return value: none. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverstopoptions) */ - stop(options?: {timeout: number}): Promise; + stop(options?: { timeout: number }): Promise; /** * Returns a copy of the routing table where: @@ -3947,7 +4033,7 @@ export class Server { /** * User-extensible type for application specific state. */ - /* tslint:disable-next-line:no-empty-interface */ +/* tslint:disable-next-line:no-empty-interface */ export interface ApplicationState { } @@ -4007,13 +4093,13 @@ export namespace Lifecycle { */ type ReturnValue = ReturnValueTypes | (Promise); type ReturnValueTypes = - (null | string | number | boolean) | - (Buffer) | - (Error | Boom) | - (stream.Stream) | - (object | object[]) | - symbol | - ResponseToolkit; + | (null | string | number | boolean) + | (Buffer) + | (Error | Boom) + | (stream.Stream) + | (object | object[]) + | symbol + | ResponseToolkit; /** * Various configuration options allows defining how errors are handled. For example, when invalid payload is received or malformed cookie, instead of returning an error, the framework can be @@ -4027,7 +4113,7 @@ export namespace Lifecycle { * * * err - the error object. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-failaction-configuration) */ - type FailAction = 'error' | 'log' | 'ignore' | Method; + type FailAction = "error" | "log" | "ignore" | Method; } export namespace Util { @@ -4035,14 +4121,14 @@ export namespace Util { [key: string]: T; } - type HTTP_METHODS_PARTIAL_LOWERCASE = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'options'; + type HTTP_METHODS_PARTIAL_LOWERCASE = "get" | "post" | "put" | "patch" | "delete" | "options"; type HTTP_METHODS_PARTIAL = - 'GET' - | 'POST' - | 'PUT' - | 'PATCH' - | 'DELETE' - | 'OPTIONS' + | "GET" + | "POST" + | "PUT" + | "PATCH" + | "DELETE" + | "OPTIONS" | HTTP_METHODS_PARTIAL_LOWERCASE; - type HTTP_METHODS = 'HEAD' | 'head' | HTTP_METHODS_PARTIAL; + type HTTP_METHODS = "HEAD" | "head" | HTTP_METHODS_PARTIAL; } diff --git a/types/hapi/test/request/auth.ts b/types/hapi/test/request/auth.ts index cb6c04ad289e9c..a0bbbf76ab1acd 100644 --- a/types/hapi/test/request/auth.ts +++ b/types/hapi/test/request/auth.ts @@ -1,6 +1,6 @@ -import { Request } from 'hapi'; +import { Request } from "hapi"; -declare module 'hapi' { +declare module "hapi" { interface UserCredentials { a: number; } diff --git a/types/hapi/test/request/catch-all.ts b/types/hapi/test/request/catch-all.ts index 3ee4e74c4236f7..4ee25740224452 100644 --- a/types/hapi/test/request/catch-all.ts +++ b/types/hapi/test/request/catch-all.ts @@ -6,9 +6,13 @@ const options: ServerOptions = { }; const server = new Server(options); -server.route({ method: '*', path: '/{p*}', handler(request, h) { - return h.response('The page was not found').code(404); -}}); +server.route({ + method: "*", + path: "/{p*}", + handler(request, h) { + return h.response("The page was not found").code(404); + }, +}); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/test/request/event-types.ts b/types/hapi/test/request/event-types.ts index 4d4f3f01ca3556..a30fcb32b5b9dd 100644 --- a/types/hapi/test/request/event-types.ts +++ b/types/hapi/test/request/event-types.ts @@ -1,57 +1,57 @@ // https://github.com/hapijs/hapi/blob/master/API.md#-servereventevents // https://github.com/hapijs/hapi/blob/master/API.md#-requestevents +import * as Crypto from "crypto"; import { Lifecycle, Request, Server, ServerOptions, ServerRoute } from "hapi"; -import * as Crypto from 'crypto'; const options: ServerOptions = { port: 8000, }; const serverRoute: ServerRoute = { - path: '/', - method: 'GET', + path: "/", + method: "GET", handler(request) { - return 'ok: ' + request.path; - } + return "ok: " + request.path; + }, }; const onRequest: Lifecycle.Method = (request, h) => { /* * Server events */ - request.server.events.on('request', (request: Request, event: any, tags: any) => { + request.server.events.on("request", (request: Request, event: any, tags: any) => { console.log(request.paramsArray); console.log(event); console.log(tags); }); - request.server.events.on('response', (request: Request) => { - console.log('Response sent for request: ' + request.path); + request.server.events.on("response", (request: Request) => { + console.log("Response sent for request: " + request.path); }); - request.server.events.on('start', () => { - console.log('Server started'); + request.server.events.on("start", () => { + console.log("Server started"); }); - request.server.events.once('stop', () => { - console.log('Server stoped'); + request.server.events.once("stop", () => { + console.log("Server stoped"); }); /* * Request events */ - const hash = Crypto.createHash('sha1'); + const hash = Crypto.createHash("sha1"); request.events.on("peek", (chunk) => { hash.update(chunk); }); request.events.once("finish", () => { - console.log(hash.digest('hex')); + console.log(hash.digest("hex")); }); request.events.once("disconnect", () => { - console.error('request aborted'); + console.error("request aborted"); }); return h.continue; @@ -59,9 +59,9 @@ const onRequest: Lifecycle.Method = (request, h) => { const server = new Server(options); server.route(serverRoute); -server.ext('onRequest', onRequest, { - before: 'test', +server.ext("onRequest", onRequest, { + before: "test", }); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/test/request/get-log.ts b/types/hapi/test/request/get-log.ts index 3ba2658136655d..33d3a82875e7d3 100644 --- a/types/hapi/test/request/get-log.ts +++ b/types/hapi/test/request/get-log.ts @@ -6,22 +6,22 @@ const options: ServerOptions = { }; const handlerFn: Lifecycle.Method = (request, h) => { - request.log(['test', 'error'], 'Test event'); - return 'path: ' + request.path; + request.log(["test", "error"], "Test event"); + return "path: " + request.path; }; const serverRoute: ServerRoute = { - path: '/', - method: 'GET', - handler: handlerFn + path: "/", + method: "GET", + handler: handlerFn, }; const server = new Server(options); server.route(serverRoute); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); -server.events.on('request', (request: Request, event: any, tags: any) => { +server.events.on("request", (request: Request, event: any, tags: any) => { console.log(tags); if (tags.error) { console.log(event); diff --git a/types/hapi/test/request/methods.ts b/types/hapi/test/request/methods.ts index 22b58aac7f4e5a..acf4d8d2b291a0 100644 --- a/types/hapi/test/request/methods.ts +++ b/types/hapi/test/request/methods.ts @@ -1,4 +1,4 @@ -import { Request } from 'hapi'; +import { Request } from "hapi"; declare const req: Request; const act: boolean = req.active(); diff --git a/types/hapi/test/request/parameters.ts b/types/hapi/test/request/parameters.ts index 3f19a02d45852f..e9447521eb9159 100644 --- a/types/hapi/test/request/parameters.ts +++ b/types/hapi/test/request/parameters.ts @@ -9,24 +9,24 @@ const options: ServerOptions = { // http://localhost:8000/album-name/song-optional const getAlbum: Lifecycle.Method = (request, h) => { console.log(request.params); - return 'ok: ' + request.path; + return "ok: " + request.path; }; const serverRoute1: ServerRoute = { - path: '/{album}/{song?}', - method: 'GET', - handler: getAlbum + path: "/{album}/{song?}", + method: "GET", + handler: getAlbum, }; // Example 2 // http://localhost:8000/person/rafael/fijalkowski const getPerson: Lifecycle.Method = (request, h) => { - const nameParts = request.params.name.split('/'); + const nameParts = request.params.name.split("/"); return { first: nameParts[0], last: nameParts[1] }; }; const serverRoute2: ServerRoute = { - path: '/person/{name*2}', - method: 'GET', - handler: getPerson + path: "/person/{name*2}", + method: "GET", + handler: getPerson, }; const server = new Server(options); @@ -34,4 +34,4 @@ server.route(serverRoute1); server.route(serverRoute2); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/test/request/query.ts b/types/hapi/test/request/query.ts index 26a886aa5f6294..361d3d48c7cdbb 100644 --- a/types/hapi/test/request/query.ts +++ b/types/hapi/test/request/query.ts @@ -15,12 +15,12 @@ const handlerFn: Lifecycle.Method = (request, h) => { }; const serverRoute: ServerRoute = { - path: '/', - method: 'GET', - handler: handlerFn + path: "/", + method: "GET", + handler: handlerFn, }; const server = new Server(options); server.route(serverRoute); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/test/response/continue.ts b/types/hapi/test/response/continue.ts index 15a0f5e35b3201..24594467555c41 100644 --- a/types/hapi/test/response/continue.ts +++ b/types/hapi/test/response/continue.ts @@ -6,20 +6,20 @@ const options: ServerOptions = { }; const serverRoute: ServerRoute = { - path: '/test', - method: 'GET', + path: "/test", + method: "GET", handler(request, h) { - return 'ok: ' + request.path; - } + return "ok: " + request.path; + }, }; const server = new Server(options); server.route(serverRoute); server.ext("onRequest", (request, h) => { - request.setUrl('/test'); + request.setUrl("/test"); return h.continue; }); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/test/response/error.ts b/types/hapi/test/response/error.ts index 513f5fbbe59968..e3c5876c94b928 100644 --- a/types/hapi/test/response/error.ts +++ b/types/hapi/test/response/error.ts @@ -1,6 +1,6 @@ // https://github.com/hapijs/hapi/blob/master/API.md#errors -import { Request, ResponseToolkit, Server, ServerOptions, ServerRoute } from "hapi"; import * as Boom from "boom"; +import { Request, ResponseToolkit, Server, ServerOptions, ServerRoute } from "hapi"; const options: ServerOptions = { port: 8000, @@ -8,18 +8,18 @@ const options: ServerOptions = { const serverRoutes: ServerRoute[] = [ { - path: '/badRequest', - method: 'GET', + path: "/badRequest", + method: "GET", handler(request, h) { - throw Boom.badRequest('Unsupported parameter'); - } + throw Boom.badRequest("Unsupported parameter"); + }, }, { - path: '/internal', - method: 'GET', + path: "/internal", + method: "GET", handler(request, h) { - throw new Error('unexpect error'); - } + throw new Error("unexpect error"); + }, }, ]; @@ -27,4 +27,4 @@ const server = new Server(options); server.route(serverRoutes); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/test/response/redirect.ts b/types/hapi/test/response/redirect.ts index dc1b904ce3e10f..8ff432db799e5e 100644 --- a/types/hapi/test/response/redirect.ts +++ b/types/hapi/test/response/redirect.ts @@ -6,15 +6,15 @@ const options: ServerOptions = { }; const serverRoute: ServerRoute = { - path: '/', - method: 'GET', + path: "/", + method: "GET", handler(request, h) { - return h.redirect('http://example.com'); - } + return h.redirect("http://example.com"); + }, }; const server = new Server(options); server.route(serverRoute); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/test/response/response-events.ts b/types/hapi/test/response/response-events.ts index c78611cd2afff6..7283a488a4d9b7 100644 --- a/types/hapi/test/response/response-events.ts +++ b/types/hapi/test/response/response-events.ts @@ -1,18 +1,18 @@ // https://github.com/hapijs/hapi/blob/master/API.md#-responseevents -import { Lifecycle, Request, ResponseObject, ResponseToolkit, Server, ServerOptions, ServerRoute } from "hapi"; import * as Crypto from "crypto"; +import { Lifecycle, Request, ResponseObject, ResponseToolkit, Server, ServerOptions, ServerRoute } from "hapi"; const preResponse: Lifecycle.Method = (request, h) => { // In onPreResponse, the response object will be defined. const response = request.response; - const hash = Crypto.createHash('sha1'); - response.events.on('peek', (chunk, encoding) => { + const hash = Crypto.createHash("sha1"); + response.events.on("peek", (chunk, encoding) => { hash.update(chunk); }); - response.events.once('finish', () => { - console.log(hash.digest('hex')); + response.events.once("finish", () => { + console.log(hash.digest("hex")); }); return h.continue; @@ -22,7 +22,7 @@ const server = new Server({ port: 8000, }); -server.ext('onPreResponse', preResponse); +server.ext("onPreResponse", preResponse); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/test/response/response.ts b/types/hapi/test/response/response.ts index 368b6fa80bb3b3..f3fd9bb0a621b5 100644 --- a/types/hapi/test/response/response.ts +++ b/types/hapi/test/response/response.ts @@ -8,24 +8,24 @@ const options: ServerOptions = { const serverRoutes: ServerRoute[] = [ // Detailed notation { - path: '/test1', - method: 'GET', + path: "/test1", + method: "GET", handler(request, h) { - const response = h.response('success'); - response.type('text/plain'); - response.header('X-Custom', 'some-value'); + const response = h.response("success"); + response.type("text/plain"); + response.header("X-Custom", "some-value"); return response; - } + }, }, // Chained notation { - path: '/test2', - method: 'GET', + path: "/test2", + method: "GET", handler(request, h) { - return h.response('success') - .type('text/plain') - .header('X-Custom', 'some-value'); - } + return h.response("success") + .type("text/plain") + .header("X-Custom", "some-value"); + }, }, ]; @@ -33,4 +33,4 @@ const server = new Server(options); server.route(serverRoutes); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/test/route/adding-routes.ts b/types/hapi/test/route/adding-routes.ts index ac4c8958429531..31cff36267b0f0 100644 --- a/types/hapi/test/route/adding-routes.ts +++ b/types/hapi/test/route/adding-routes.ts @@ -6,27 +6,27 @@ const options: ServerOptions = { }; const serverRoute: ServerRoute = { - path: '/', - method: 'GET', + path: "/", + method: "GET", handler(request, h) { - return 'ok: ' + request.path; - } + return "ok: " + request.path; + }, }; const serverRoutes: ServerRoute[] = [ { - path: '/test1', - method: 'GET', + path: "/test1", + method: "GET", handler(request, h) { - return 'ok: ' + request.path; - } + return "ok: " + request.path; + }, }, { - path: '/test2', - method: 'GET', + path: "/test2", + method: "GET", handler(request, h) { - return 'ok: ' + request.path; - } + return "ok: " + request.path; + }, }, ]; @@ -35,4 +35,4 @@ server.route(serverRoute); server.route(serverRoutes); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/test/route/config.ts b/types/hapi/test/route/config.ts index 8cebaec2699e62..a1d3fb11dd4f79 100644 --- a/types/hapi/test/route/config.ts +++ b/types/hapi/test/route/config.ts @@ -6,33 +6,33 @@ const options: ServerOptions = { // different methods const routeConfig: ServerRoute = { - path: '/signin', - method: 'PUT', - vhost: 'site.coms', + path: "/signin", + method: "PUT", + vhost: "site.coms", }; const routeConfigTest1: ServerRoute = { - path: '/signin', - method: '*' + path: "/signin", + method: "*", }; const routeConfigTest2: ServerRoute = { - path: '/signin', - method: ['OPTIONS', '*'] + path: "/signin", + method: ["OPTIONS", "*"], }; // different handlers const routeConfigTest3: ServerRoute = { - path: '/signin', - method: 'PUT', - handler(request, h) { - return 'ok'; - } + path: "/signin", + method: "PUT", + handler(request, h) { + return "ok"; + }, }; const routeConfigTest4: ServerRoute = { - path: '/signin', - method: 'PUT', - handler(request, h) { - return 'ok'; - } + path: "/signin", + method: "PUT", + handler(request, h) { + return "ok"; + }, }; const server = new Server(options); @@ -42,11 +42,11 @@ server.route(routeConfig); const user: RouteOptions = { cache: { expiresIn: 5000 }, handler(request, h) { - return { name: 'John' }; - } + return { name: "John" }; + }, }; -server.route({method: 'GET', path: '/user', options: user }); +server.route({ method: "GET", path: "/user", options: user }); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/test/route/ext.ts b/types/hapi/test/route/ext.ts index b8dff446992339..4e0ffc3cf802bb 100644 --- a/types/hapi/test/route/ext.ts +++ b/types/hapi/test/route/ext.ts @@ -3,7 +3,7 @@ import { Server } from "hapi"; const server = new Server(); server.route({ - method: 'get', + method: "get", path: "/test", options: { ext: { @@ -17,6 +17,6 @@ server.route({ return h.continue; }, }], - } - } + }, + }, }); diff --git a/types/hapi/test/route/handler.ts b/types/hapi/test/route/handler.ts index 6fced100789760..4f04fdc4fe57c1 100644 --- a/types/hapi/test/route/handler.ts +++ b/types/hapi/test/route/handler.ts @@ -1,7 +1,7 @@ import { Lifecycle, Request, ResponseToolkit } from "hapi"; const handler: Lifecycle.Method = (request, h) => { - return 'success'; + return "success"; }; const strictHandler: Lifecycle.Method = (request, h) => { diff --git a/types/hapi/test/route/route-options-pre.ts b/types/hapi/test/route/route-options-pre.ts index 897f4a8ef5965e..12771d535f4b27 100644 --- a/types/hapi/test/route/route-options-pre.ts +++ b/types/hapi/test/route/route-options-pre.ts @@ -6,11 +6,11 @@ const server = new Server({ }); const pre1: Lifecycle.Method = (request, h) => { - return 'Hello'; + return "Hello"; }; const pre2: Lifecycle.Method = (request, h) => { - return 'World'; + return "World"; }; const pre3: Lifecycle.Method = (request, h) => { @@ -18,25 +18,25 @@ const pre3: Lifecycle.Method = (request, h) => { }; server.route({ - method: 'GET', - path: '/', + method: "GET", + path: "/", options: { pre: [ [ // m1 and m2 executed in parallel - { method: pre1, assign: 'm1' }, - { method: pre2, assign: 'm2' } + { method: pre1, assign: "m1" }, + { method: pre2, assign: "m2" }, ], - { method: pre3, assign: 'm3' }, + { method: pre3, assign: "m3" }, ], handler(request, h) { - return request.pre.m3 + '!\n'; - } - } + return request.pre.m3 + "!\n"; + }, + }, }); server.start(); -server.events.on('start', () => { - console.log('Server started at: ' + server.info.uri); +server.events.on("start", () => { + console.log("Server started at: " + server.info.uri); }); diff --git a/types/hapi/test/route/route-options.ts b/types/hapi/test/route/route-options.ts index 5f718a9c68b535..c45a02cc41bf05 100644 --- a/types/hapi/test/route/route-options.ts +++ b/types/hapi/test/route/route-options.ts @@ -8,66 +8,66 @@ import { RouteOptionsCors, RouteOptionsPayload, RouteOptionsResponse, + RouteOptionsSecureObject, RouteOptionsValidate, Server, - RouteOptionsSecureObject } from "hapi"; const routeOptionsAccess: RouteOptionsAccess = { access: [ { - scope: false + scope: false, }, { - entity: 'user' - } + entity: "user", + }, ], scope: false, - entity: 'user', - mode: 'optional', - payload: 'optional', - strategies: ['', ''], - strategy: '' + entity: "user", + mode: "optional", + payload: "optional", + strategies: ["", ""], + strategy: "", }; const corsOption: RouteOptionsCors = { - origin: 'ignore', + origin: "ignore", maxAge: 5000, - headers: ['test', 'test', 'test'], - additionalHeaders: ['test', 'test', 'test'], - exposedHeaders: ['test', 'test', 'test'], - additionalExposedHeaders: ['test', 'test', 'test'], - credentials: false + headers: ["test", "test", "test"], + additionalHeaders: ["test", "test", "test"], + exposedHeaders: ["test", "test", "test"], + additionalExposedHeaders: ["test", "test", "test"], + credentials: false, }; const payloadOptions: RouteOptionsPayload = { - allow: 'string', + allow: "string", compression: { test1: { - test: 2 - } + test: 2, + }, }, - defaultContentType: 'application/json', + defaultContentType: "application/json", failAction(request, h) { - return 'ok: ' + request.path; + return "ok: " + request.path; }, maxBytes: 1048576, multipart: { - output: 'annotated' + output: "annotated", }, - output: 'stream', - override: '', - parse: 'gunzip', + output: "stream", + override: "", + parse: "gunzip", timeout: 5000, - uploads: 'dir/' + uploads: "dir/", }; const pre1: Lifecycle.Method = (request, h) => { - return 'Hello'; + return "Hello"; }; const pre2: Lifecycle.Method = (request, h) => { - return 'World'; + return "World"; }; const pre3: Lifecycle.Method = (request, h) => { @@ -77,7 +77,7 @@ const pre3: Lifecycle.Method = (request, h) => { const routeOptionsResponse: RouteOptionsResponse = { emptyStatusCode: 200, failAction(request, h) { - return 'ok: ' + request.path; + return "ok: " + request.path; }, modify: false, options: undefined, @@ -93,7 +93,7 @@ const routeOptionsResponse: RouteOptionsResponse = { }; const routeOptionSecure: RouteOptionsSecureObject = { - referrer: 'origin', + referrer: "origin", noSniff: true, xframe: "deny", hsts: { @@ -108,7 +108,7 @@ const routeOptionSecure: RouteOptionsSecureObject = { const routeOptionsValidate: RouteOptionsValidate = { errorFields: {}, failAction(request, h) { - return 'ok: ' + request.path; + return "ok: " + request.path; }, headers: false, options: {}, @@ -117,7 +117,7 @@ const routeOptionsValidate: RouteOptionsValidate = { query: true, }; -declare module 'hapi' { +declare module "hapi" { interface RouteOptionsApp { one: number; two: string; @@ -127,33 +127,33 @@ declare module 'hapi' { const routeOptions: RouteOptions = { app: { one: 1, - two: "2" + two: "2", }, auth: routeOptionsAccess, bind: null, cache: { - privacy: 'default', + privacy: "default", statuses: [200], - otherwise: 'no-cache' + otherwise: "no-cache", }, compression: { test1: { - test: 2 - } + test: 2, + }, }, cors: corsOption, - description: 'description here', + description: "description here", ext: undefined, - files: { relativeTo: '.' }, + files: { relativeTo: "." }, handler(request, h) { - return 'ok: ' + request.path; + return "ok: " + request.path; }, - id: 'test', + id: "test", isInternal: false, json: undefined, - jsonp: 'callback', + jsonp: "callback", log: { collect: false }, - notes: ['test', 'test', 'test'], + notes: ["test", "test", "test"], payload: payloadOptions, plugins: { plugin1: {}, @@ -162,33 +162,33 @@ const routeOptions: RouteOptions = { pre: [ [ // m1 and m2 executed in parallel - { method: pre1, assign: 'm1' }, - { method: pre2, assign: 'm2' } + { method: pre1, assign: "m1" }, + { method: pre2, assign: "m2" }, ], - { method: pre3, assign: 'm3' }, + { method: pre3, assign: "m3" }, ], response: routeOptionsResponse, security: false, state: { parse: true, failAction(request, h) { - return 'ok: ' + request.path; + return "ok: " + request.path; }, }, - tags: ['test', 'test', 'test'], + tags: ["test", "test", "test"], timeout: { server: 10000, - socket: false + socket: false, }, - validate: routeOptionsValidate + validate: routeOptionsValidate, }; const server = new Server({ port: 8000, - routes: routeOptions + routes: routeOptions, }); server.start(); -server.events.on('start', () => { - console.log('Server started at: ' + server.info.uri); +server.events.on("start", () => { + console.log("Server started at: " + server.info.uri); }); diff --git a/types/hapi/test/route/validation.ts b/types/hapi/test/route/validation.ts index 79b8effbb1f620..fc468fa8b57098 100644 --- a/types/hapi/test/route/validation.ts +++ b/types/hapi/test/route/validation.ts @@ -12,40 +12,40 @@ const routeOptions: RouteOptions = { id: Joi.string().uuid().required(), name: Joi.object({ firstName: Joi.string().required(), - lastName: Joi.string().allow(null) + lastName: Joi.string().allow(null), }), - firstName: Joi.ref("name.firstName") + firstName: Joi.ref("name.firstName"), }, params: { name: Joi.string().min(3).max(10), - nameRef: Joi.ref("name") + nameRef: Joi.ref("name"), }, state: { - woop: Joi.string().allow('doop'), + woop: Joi.string().allow("doop"), }, }, response: { schema: Joi.object({ a: Joi.string(), b: Joi.object({ - c: Joi.number() + c: Joi.number(), }), - d: Joi.ref("b.c") - }) - } + d: Joi.ref("b.c"), + }), + }, }; const serverRoute: ServerRoute = { - path: '/', - method: 'GET', + path: "/", + method: "GET", handler(request, h) { - return 'ok: ' + request.path; + return "ok: " + request.path; }, - options: routeOptions + options: routeOptions, }; const server = new Server(options); server.route(serverRoute); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/test/server/server-app.ts b/types/hapi/test/server/server-app.ts index 42c2b5dec4140a..187a446efa8d6a 100644 --- a/types/hapi/test/server/server-app.ts +++ b/types/hapi/test/server/server-app.ts @@ -13,17 +13,17 @@ declare module "hapi" { } const server = new Server(options); -server.app.key = 'value2'; +server.app.key = "value2"; const serverRoute: ServerRoute = { - path: '/', - method: 'GET', + path: "/", + method: "GET", handler(request, h) { - return 'key: ' + request.server.app.key; - } + return "key: " + request.server.app.key; + }, }; server.route(serverRoute); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/test/server/server-auth-api.ts b/types/hapi/test/server/server-auth-api.ts index 4508c641c90b03..80a5237bf4e958 100644 --- a/types/hapi/test/server/server-auth-api.ts +++ b/types/hapi/test/server/server-auth-api.ts @@ -1,11 +1,8 @@ // https://github.com/hapijs/hapi/blob/master/API.md#-serverauthapi -import { - Server, - ServerAuthScheme, -} from "hapi"; import * as Boom from "boom"; +import { Server, ServerAuthScheme } from "hapi"; -declare module 'hapi' { +declare module "hapi" { interface ServerAuthSchemeObjectApi { settings: { x: number; @@ -17,24 +14,24 @@ const scheme: ServerAuthScheme = (server, options) => { return { api: { settings: { - x: 5 - } + x: 5, + }, }, authenticate(request, h) { const authorization = request.headers.authorization; if (!authorization) { - throw Boom.unauthorized(null, 'Custom'); + throw Boom.unauthorized(null, "Custom"); } return h.authenticated({ credentials: { user: { a: 1 } } }); - } + }, }; }; const server = new Server({ port: 8000, }); -server.auth.scheme('custom', scheme); -server.auth.strategy('default', 'custom'); +server.auth.scheme("custom", scheme); +server.auth.strategy("default", "custom"); server.start(); -console.log(server.auth.api.default.settings.x); // 5 +console.log(server.auth.api.default.settings.x); // 5 diff --git a/types/hapi/test/server/server-auth-default.ts b/types/hapi/test/server/server-auth-default.ts index 0a2da56efc15c8..675b559eaf1b7a 100644 --- a/types/hapi/test/server/server-auth-default.ts +++ b/types/hapi/test/server/server-auth-default.ts @@ -1,9 +1,9 @@ // https://github.com/hapijs/hapi/blob/master/API.md#-serverauthdefaultoptions // https://github.com/hapijs/hapi/blob/master/API.md#-serverauthschemename-scheme -import { Request, ResponseToolkit, Server, ServerAuthScheme, ServerAuthSchemeOptions } from "hapi"; import * as Boom from "boom"; +import { Request, ResponseToolkit, Server, ServerAuthScheme, ServerAuthSchemeOptions } from "hapi"; -declare module 'hapi' { +declare module "hapi" { interface UserCredentials { a: number; } @@ -19,23 +19,23 @@ const scheme: ServerAuthScheme = (server, options) => { const req = request.raw.req; const authorization = req.headers.authorization; if (!authorization) { - throw Boom.unauthorized(null, 'Custom'); + throw Boom.unauthorized(null, "Custom"); } - return h.authenticated({ credentials: { user: { a: 1 }, scope: ['test'] } }); - } + return h.authenticated({ credentials: { user: { a: 1 }, scope: ["test"] } }); + }, }; }; -server.auth.scheme('custom', scheme); -server.auth.strategy('default', 'custom'); -server.auth.default('default'); +server.auth.scheme("custom", scheme); +server.auth.strategy("default", "custom"); +server.auth.default("default"); server.route({ - method: 'GET', - path: '/', + method: "GET", + path: "/", handler(request, h) { - return request.auth.credentials.user || 'not authed'; - } + return request.auth.credentials.user || "not authed"; + }, }); server.start(); diff --git a/types/hapi/test/server/server-auth-test.ts b/types/hapi/test/server/server-auth-test.ts index 839ad6d310a12c..7226b1b26ab53f 100644 --- a/types/hapi/test/server/server-auth-test.ts +++ b/types/hapi/test/server/server-auth-test.ts @@ -1,9 +1,9 @@ // https://github.com/hapijs/hapi/blob/master/API.md#-await-serverauthteststrategy-request // https://github.com/hapijs/hapi/blob/master/API.md#-serverauthschemename-scheme -import { Request, ResponseToolkit, Server, ServerAuthScheme, ServerAuthSchemeOptions } from "hapi"; import * as Boom from "boom"; +import { Request, ResponseToolkit, Server, ServerAuthScheme, ServerAuthSchemeOptions } from "hapi"; -declare module 'hapi' { +declare module "hapi" { interface AuthCredentials { name?: string | undefined; } @@ -19,27 +19,27 @@ const scheme: ServerAuthScheme = (server, options) => { const req = request.raw.req; const authorization = req.headers.authorization; if (!authorization) { - throw Boom.unauthorized(null, 'Custom'); + throw Boom.unauthorized(null, "Custom"); } - return h.authenticated({ credentials: { name: 'john', } }); - } + return h.authenticated({ credentials: { name: "john" } }); + }, }; }; -server.auth.scheme('custom', scheme); -server.auth.strategy('default', 'custom'); +server.auth.scheme("custom", scheme); +server.auth.strategy("default", "custom"); server.route({ - method: 'GET', - path: '/', + method: "GET", + path: "/", handler: async (request: Request, h: ResponseToolkit) => { try { - const { credentials } = await request.server.auth.test('default', request); + const { credentials } = await request.server.auth.test("default", request); return { status: true, user: credentials.name }; } catch (err) { return { status: false }; } - } + }, }); server.start(); diff --git a/types/hapi/test/server/server-auth-verify.ts b/types/hapi/test/server/server-auth-verify.ts index ec788fcb596f36..b276171b10ae75 100644 --- a/types/hapi/test/server/server-auth-verify.ts +++ b/types/hapi/test/server/server-auth-verify.ts @@ -1,26 +1,26 @@ -import { Request, Server, RequestAuth } from "hapi"; import * as Boom from "boom"; +import { Request, RequestAuth, Server } from "hapi"; const server = new Server({ port: 8000, }); -server.auth.scheme('custom', () => ({ +server.auth.scheme("custom", () => ({ authenticate() { - throw Boom.unauthorized(null, 'hurr'); + throw Boom.unauthorized(null, "hurr"); }, async verify(_auth: RequestAuth) { - throw Boom.unauthorized(null, 'durr'); - } + throw Boom.unauthorized(null, "durr"); + }, })); -server.auth.strategy('default', 'custom'); +server.auth.strategy("default", "custom"); server.route({ - method: 'GET', - path: '/', + method: "GET", + path: "/", async handler(request: Request) { request.server.auth.verify(request); - } + }, }); server.start(); diff --git a/types/hapi/test/server/server-bind.ts b/types/hapi/test/server/server-bind.ts index 1fbd37c4c2f53e..bc0333a5dc487a 100644 --- a/types/hapi/test/server/server-bind.ts +++ b/types/hapi/test/server/server-bind.ts @@ -5,23 +5,23 @@ const server = new Server({ port: 8000, }); const handler: Lifecycle.Method = (request, h) => { - return h.context.message; // Or h.context.message + return h.context.message; // Or h.context.message }; const plugin: Plugin = { - name: 'example', + name: "example", register: async (server, options) => { const bind = { - message: 'hello' + message: "hello", }; server.bind(bind); - server.route({ method: 'GET', path: '/', handler }); - } + server.route({ method: "GET", path: "/", handler }); + }, }; server.start(); server.register(plugin); -server.events.on('start', () => { - console.log('Server started at: ' + server.info.uri); +server.events.on("start", () => { + console.log("Server started at: " + server.info.uri); }); diff --git a/types/hapi/test/server/server-cache-provision.ts b/types/hapi/test/server/server-cache-provision.ts index 8c28ca48de17a2..70a1975eb20802 100644 --- a/types/hapi/test/server/server-cache-provision.ts +++ b/types/hapi/test/server/server-cache-provision.ts @@ -1,19 +1,19 @@ // https://github.com/hapijs/hapi/blob/master/API.md#-await-servercacheprovisionoptions -import { Server } from "hapi"; import * as catbox from "catbox"; +import { Server } from "hapi"; const server = new Server({ port: 8000, }); server.initialize(); -server.cache.provision({engine: require('catbox-memory'), name: 'countries' }); +server.cache.provision({ engine: require("catbox-memory"), name: "countries" }); -const cache = server.cache({segment: 'countries', cache: 'countries', expiresIn: 60 * 60 * 1000 }); -cache.set('norway', 'oslo', 10 * 1000).then(() => {}); -const value = cache.get('norway').then(() => {}); +const cache = server.cache({ segment: "countries", cache: "countries", expiresIn: 60 * 60 * 1000 }); +cache.set("norway", "oslo", 10 * 1000).then(() => {}); +const value = cache.get("norway").then(() => {}); server.start(); -server.events.on('start', () => { - console.log('Server started at: ' + server.info.uri); +server.events.on("start", () => { + console.log("Server started at: " + server.info.uri); }); diff --git a/types/hapi/test/server/server-cache.ts b/types/hapi/test/server/server-cache.ts index 0872b287df1711..4ff1263c94cb7e 100644 --- a/types/hapi/test/server/server-cache.ts +++ b/types/hapi/test/server/server-cache.ts @@ -1,23 +1,23 @@ // https://github.com/hapijs/hapi/blob/master/API.md#-servercacheoptions -import { Server, ServerOptionsCache } from "hapi"; import * as catbox from "catbox"; +import { Server, ServerOptionsCache } from "hapi"; const server = new Server({ port: 8000, }); const catboxOptions: ServerOptionsCache = { - segment: 'countries', - expiresIn: 60 * 60 * 1000 + segment: "countries", + expiresIn: 60 * 60 * 1000, }; const cache = server.cache(catboxOptions); -cache.set('norway', 'oslo', 10 * 1000).then(() => {}); +cache.set("norway", "oslo", 10 * 1000).then(() => {}); -const value = cache.get('norway').then(() => {}); +const value = cache.get("norway").then(() => {}); console.log("Value: " + value); server.start(); -server.events.on('start', () => { - console.log('Server started at: ' + server.info.uri); +server.events.on("start", () => { + console.log("Server started at: " + server.info.uri); }); diff --git a/types/hapi/test/server/server-decoder.ts b/types/hapi/test/server/server-decoder.ts index 965745ee7c10e7..236750b109bb8a 100644 --- a/types/hapi/test/server/server-decoder.ts +++ b/types/hapi/test/server/server-decoder.ts @@ -3,6 +3,6 @@ import { Server } from "hapi"; import * as Zlib from "zlib"; const server = new Server({ port: 80, routes: { payload: { compression: { special: { chunkSize: 16 * 1024 } } } } }); -server.decoder('special', (options) => Zlib.createGunzip(options)); +server.decoder("special", (options) => Zlib.createGunzip(options)); server.start(); diff --git a/types/hapi/test/server/server-decorations.ts b/types/hapi/test/server/server-decorations.ts index fadab524220390..86ac077f90325b 100644 --- a/types/hapi/test/server/server-decorations.ts +++ b/types/hapi/test/server/server-decorations.ts @@ -1,7 +1,7 @@ // https://github.com/hapijs/hapi/blob/master/API.md#-serverdecoratetype-property-method-options import { Request, ResponseToolkit, Server } from "hapi"; -declare module 'hapi' { +declare module "hapi" { interface HandlerDecorations { test?: { test: number; @@ -16,25 +16,25 @@ const server = new Server({ }); server.start(); -server.decorate('toolkit', 'success', function() { - return this.response({ status: 'ok' }); +server.decorate("toolkit", "success", function() { + return this.response({ status: "ok" }); }); -server.decorate('handler', 'test', (route, options) => (req, h) => 123); +server.decorate("handler", "test", (route, options) => (req, h) => 123); server.route({ - method: 'GET', - path: '/', + method: "GET", + path: "/", handler: { test: { test: 123, - } - } + }, + }, }); console.log(server.decorations.toolkit); // Test decorators with additional arguments -declare module 'hapi' { +declare module "hapi" { interface Server { withParams(x: number, y: string): string; } @@ -48,28 +48,28 @@ function decorateServerWithParams(this: Server, x: number, y: string) { return `${x} ${y}`; } -server.decorate('server', 'withParams', decorateServerWithParams); +server.decorate("server", "withParams", decorateServerWithParams); server.withParams(1, "one"); function decorateToolkitWithParams(this: ResponseToolkit, x: number, y: string) { return `${x} ${y}`; } -server.decorate('toolkit', 'withParams', decorateToolkitWithParams); +server.decorate("toolkit", "withParams", decorateToolkitWithParams); -server.decorate('toolkit', Symbol('hi'), decorateToolkitWithParams); +server.decorate("toolkit", Symbol("hi"), decorateToolkitWithParams); server.route({ - method: 'GET', - path: '/toolkitWithParams', + method: "GET", + path: "/toolkitWithParams", handler: (r, h) => { return h.withParams(1, "one"); - } + }, }); // Test request + apply option types -declare module 'hapi' { +declare module "hapi" { interface Request { withApply(x: string, y: number): string; } @@ -81,19 +81,19 @@ function decorateRequestWithApply(request: Request) { }; } -server.decorate('request', 'withApply', decorateRequestWithApply, {apply: true}); +server.decorate("request", "withApply", decorateRequestWithApply, { apply: true }); server.route({ - method: 'GET', - path: '/requestWithApply', + method: "GET", + path: "/requestWithApply", handler: (r, h) => { return r.withApply("one", 1); - } + }, }); // Test extend option type -declare module 'hapi' { +declare module "hapi" { interface Server { withExtend(x: string, y: number): string; } @@ -106,5 +106,5 @@ const decorateServerWithExtend = (existing: () => void) => { }; }; -server.decorate('server', 'withExtend', decorateServerWithExtend, {extend: true}); +server.decorate("server", "withExtend", decorateServerWithExtend, { extend: true }); server.withExtend("one", 1); diff --git a/types/hapi/test/server/server-encoder.ts b/types/hapi/test/server/server-encoder.ts index dd9f12f4dbb45a..b942093097edc0 100644 --- a/types/hapi/test/server/server-encoder.ts +++ b/types/hapi/test/server/server-encoder.ts @@ -3,6 +3,6 @@ import { Server } from "hapi"; import * as Zlib from "zlib"; const server = new Server({ port: 80, routes: { payload: { compression: { special: { chunkSize: 16 * 1024 } } } } }); -server.encoder('special', (options) => Zlib.createGzip(options)); +server.encoder("special", (options) => Zlib.createGzip(options)); server.start(); diff --git a/types/hapi/test/server/server-events-once.ts b/types/hapi/test/server/server-events-once.ts index a4903ee6dc95bb..e7f8f47978fdd0 100644 --- a/types/hapi/test/server/server-events-once.ts +++ b/types/hapi/test/server/server-events-once.ts @@ -2,17 +2,17 @@ import { Request, ResponseToolkit, Server, ServerRoute } from "hapi"; const serverRoute: ServerRoute = { - path: '/', - method: 'GET', + path: "/", + method: "GET", handler(request, h) { - return 'oks: ' + request.path; - } + return "oks: " + request.path; + }, }; -declare module 'hapi' { +declare module "hapi" { interface ServerEvents { - once(event: 'test1', listener: (update: string) => void): this; - once(event: 'test2', listener: (...updates: string[]) => void): this; + once(event: "test1", listener: (update: string) => void): this; + once(event: "test2", listener: (...updates: string[]) => void): this; } } @@ -20,12 +20,16 @@ const server = new Server({ port: 8000, }); server.route(serverRoute); -server.event('test1'); -server.event('test2'); -server.events.once('test1', update => { console.log(update); }); -server.events.once('test2', (...args) => { console.log(args); }); -server.events.emit('test1', 'hello-1'); -server.events.emit('test2', 'hello-2'); // Ignored +server.event("test1"); +server.event("test2"); +server.events.once("test1", update => { + console.log(update); +}); +server.events.once("test2", (...args) => { + console.log(args); +}); +server.events.emit("test1", "hello-1"); +server.events.emit("test2", "hello-2"); // Ignored server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/test/server/server-events.ts b/types/hapi/test/server/server-events.ts index 4e6d8103f15065..4091cdac4ba4a4 100644 --- a/types/hapi/test/server/server-events.ts +++ b/types/hapi/test/server/server-events.ts @@ -1,11 +1,11 @@ // https://github.com/hapijs/hapi/blob/master/API.md#-servereventevents import { Server, ServerEvents } from "hapi"; -import Podium = require('podium'); -import 'hapi/definitions/server/server'; +import Podium = require("podium"); +import "hapi/definitions/server/server"; -declare module 'hapi' { +declare module "hapi" { interface ServerEvents { - on(event: 'test', listener: (update: string) => void): this; + on(event: "test", listener: (update: string) => void): this; } } @@ -13,12 +13,12 @@ const server = new Server({ port: 8000, }); -server.events.on('route', route => { +server.events.on("route", route => { console.log(route.path, route.vhost, route.realm, route.method, route.settings, route.fingerprint); }); -server.event('test'); -server.events.on('test', (update: any) => console.log(update)); -server.events.emit('test', 'hello'); +server.event("test"); +server.events.on("test", (update: any) => console.log(update)); +server.events.emit("test", "hello"); server.start(); diff --git a/types/hapi/test/server/server-expose.ts b/types/hapi/test/server/server-expose.ts index 74b7c127da3382..5247f35b4de7a2 100644 --- a/types/hapi/test/server/server-expose.ts +++ b/types/hapi/test/server/server-expose.ts @@ -1,7 +1,7 @@ // https://github.com/hapijs/hapi/blob/master/API.md#-serverplugins import { Plugin, Server, ServerRegisterOptions } from "hapi"; -declare module 'hapi' { +declare module "hapi" { interface PluginProperties { example1: { util(): void; @@ -13,17 +13,17 @@ declare module 'hapi' { } const plugin1: Plugin = { - name: 'example1', + name: "example1", async register(server: Server, options: ServerRegisterOptions) { - server.expose('util', () => console.log('something')); - } + server.expose("util", () => console.log("something")); + }, }; const plugin2: Plugin = { - name: 'example2', + name: "example2", async register(server: Server, options: ServerRegisterOptions) { - server.expose('util', () => console.log('something')); - } + server.expose("util", () => console.log("something")); + }, }; const server = new Server({ diff --git a/types/hapi/test/server/server-info.ts b/types/hapi/test/server/server-info.ts index 58045b19dadc7e..73c4e36244a198 100644 --- a/types/hapi/test/server/server-info.ts +++ b/types/hapi/test/server/server-info.ts @@ -7,4 +7,4 @@ const server = new Server({ server.start(); console.log(server.info); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/test/server/server-inject.ts b/types/hapi/test/server/server-inject.ts index 4a309d5563596b..fc41b798d7cb5c 100644 --- a/types/hapi/test/server/server-inject.ts +++ b/types/hapi/test/server/server-inject.ts @@ -6,19 +6,19 @@ const server = new Server({ }); const serverRoute: ServerRoute = { - path: '/', - method: 'GET', + path: "/", + method: "GET", handler(request, h) { - return 'Success!'; - } + return "Success!"; + }, }; server.route(serverRoute); server.start(); -server.inject('/').then(res => console.log(res.result)); +server.inject("/").then(res => console.log(res.result)); -declare module 'hapi' { +declare module "hapi" { interface ApplicationState { injectState?: number | undefined; } @@ -26,7 +26,7 @@ declare module 'hapi' { server.inject({ auth: { - strategy: 'test', + strategy: "test", credentials: { user: { a: 1, @@ -35,6 +35,6 @@ server.inject({ }, url: "test", app: { - injectState: 1 - } + injectState: 1, + }, }); diff --git a/types/hapi/test/server/server-load.ts b/types/hapi/test/server/server-load.ts index 8ac89fa0069452..38308fa70b84a1 100644 --- a/types/hapi/test/server/server-load.ts +++ b/types/hapi/test/server/server-load.ts @@ -6,7 +6,7 @@ const server = new Server({ load: { sampleInterval: 1000, concurrent: 123, - } + }, }); server.start(); diff --git a/types/hapi/test/server/server-lookup.ts b/types/hapi/test/server/server-lookup.ts index 2bbaf5713bea0e..59fb99f601f16d 100644 --- a/types/hapi/test/server/server-lookup.ts +++ b/types/hapi/test/server/server-lookup.ts @@ -6,15 +6,15 @@ const server = new Server({ }); server.route({ - path: '/', - method: 'GET', + path: "/", + method: "GET", options: { - id: 'root', - handler: () => 'ok' - } + id: "root", + handler: () => "ok", + }, }); -const route: RequestRoute | null = server.lookup('root'); +const route: RequestRoute | null = server.lookup("root"); console.log(route); server.start(); diff --git a/types/hapi/test/server/server-match.ts b/types/hapi/test/server/server-match.ts index d2ab8faa7968ed..4e285cb86811b4 100644 --- a/types/hapi/test/server/server-match.ts +++ b/types/hapi/test/server/server-match.ts @@ -6,15 +6,15 @@ const server = new Server({ }); server.route({ - path: '/', - method: 'GET', + path: "/", + method: "GET", options: { - id: 'root', - handler: () => 'ok' - } + id: "root", + handler: () => "ok", + }, }); -const route: RequestRoute | null = server.match('get', '/'); +const route: RequestRoute | null = server.match("get", "/"); if (route !== null) { console.log(route.path); diff --git a/types/hapi/test/server/server-method.ts b/types/hapi/test/server/server-method.ts index 39c3fdb9d77833..8b110d5b1ce6f9 100644 --- a/types/hapi/test/server/server-method.ts +++ b/types/hapi/test/server/server-method.ts @@ -11,15 +11,15 @@ const add = (a: any, b: any): number => { }; const methodObject: ServerMethodConfigurationObject = { - name: 'sum', + name: "sum", method: add, options: { cache: { expiresIn: 2000, - generateTimeout: 100 + generateTimeout: 100, }, - generateKey: (a: string | undefined) => a === undefined ? null : a - } + generateKey: (a: string | undefined) => a === undefined ? null : a, + }, }; server.method(methodObject); diff --git a/types/hapi/test/server/server-methods.ts b/types/hapi/test/server/server-methods.ts index f9a2d08e6c952b..1e719156eba971 100644 --- a/types/hapi/test/server/server-methods.ts +++ b/types/hapi/test/server/server-methods.ts @@ -6,6 +6,6 @@ const server = new Server({ }); server.start(); -server.method('add', (a, b) => (a + b)); -const result = server.methods.add(1, 2); // 3 +server.method("add", (a, b) => (a + b)); +const result = server.methods.add(1, 2); // 3 console.log(result); diff --git a/types/hapi/test/server/server-mime.ts b/types/hapi/test/server/server-mime.ts index d5a76da9fa63e7..168c541fc482d0 100644 --- a/types/hapi/test/server/server-mime.ts +++ b/types/hapi/test/server/server-mime.ts @@ -5,18 +5,18 @@ const options: ServerOptions = { port: 8000, mime: { override: { - 'node/module': { - source: 'apache', + "node/module": { + source: "apache", compressible: false, - extensions: ['node', 'module', 'npm'], - type: 'node/module' - } - } - } + extensions: ["node", "module", "npm"], + type: "node/module", + }, + }, + }, }; const server = new Server(options); -console.log(server.mime.path('code.js').type); // 'application/javascript' -console.log(server.mime.path('file.npm').type); // 'node/module' +console.log(server.mime.path("code.js").type); // 'application/javascript' +console.log(server.mime.path("file.npm").type); // 'node/module' server.start(); diff --git a/types/hapi/test/server/server-options.ts b/types/hapi/test/server/server-options.ts index b3111b42c8a2e6..be46edead91c02 100644 --- a/types/hapi/test/server/server-options.ts +++ b/types/hapi/test/server/server-options.ts @@ -4,20 +4,20 @@ import { MimosOptions, MimosOptionsValue } from "mimos"; const mimeOptions: MimosOptions = { override: { - 'node/module': { - source: 'iana', + "node/module": { + source: "iana", compressible: true, - extensions: ['node', 'modsule', 'npm'], - type: 'node/module' + extensions: ["node", "modsule", "npm"], + type: "node/module", }, - 'application/javascript': { - source: 'iana', - charset: 'UTF-8', + "application/javascript": { + source: "iana", + charset: "UTF-8", compressible: true, - extensions: ['js', 'javascript'], - type: 'text/javascript' + extensions: ["js", "javascript"], + type: "text/javascript", }, - 'text/html': { + "text/html": { predicate: (mime: MimosOptionsValue) => { if (1 === 1) { // mime.foo = 'test'; @@ -25,36 +25,36 @@ const mimeOptions: MimosOptions = { // mime.foo = 'bar'; } return mime; - } - } - } + }, + }, + }, }; const plugin: Plugin = { - name: 'example', + name: "example", register: async (server: Server, options: ServerRegisterOptions) => { - server.expose('key', 'value'); - server.plugins.example.other = 'other'; - console.log(server.plugins.example.key); // 'value' - console.log(server.plugins.example.other); // 'other' - } + server.expose("key", "value"); + server.plugins.example.other = "other"; + console.log(server.plugins.example.key); // 'value' + console.log(server.plugins.example.other); // 'other' + }, }; const routeOptions: RouteOptions = { compression: { test: { - some: 'option' - } + some: "option", + }, }, files: { - relativeTo: __dirname + relativeTo: __dirname, }, cors: { - origin: ['http://test.example.com', 'http://www.example.com', 'http://*.a.com'] + origin: ["http://test.example.com", "http://www.example.com", "http://*.a.com"], }, }; -declare module 'hapi' { +declare module "hapi" { interface ServerOptionsApp { key1?: string | undefined; key2?: string | undefined; @@ -63,28 +63,28 @@ declare module 'hapi' { } const options: ServerOptions = { - address: '0.0.0.0', + address: "0.0.0.0", app: { - key1: 'value1', - key2: 'value2', - any_thing: 'any_value', + key1: "value1", + key2: "value2", + any_thing: "any_value", }, autoListen: true, cache: { - engine: require('catbox-memory'), - name: 'test', + engine: require("catbox-memory"), + name: "test", shared: true, - partition: 'hapi-cache', - any_thing_1: 'any_thing_1', - any_thing_2: 'any_thing_2' + partition: "hapi-cache", + any_thing_1: "any_thing_1", + any_thing_2: "any_thing_2", }, compression: { - minBytes: 1024 + minBytes: 1024, }, debug: { - request: ['implementation'] + request: ["implementation"], }, - host: 'localhost', + host: "localhost", listener: undefined, load: { sampleInterval: 0 }, mime: mimeOptions, @@ -92,7 +92,7 @@ const options: ServerOptions = { port: 8000, router: { isCaseSensitive: true, - stripTrailingSlash: false + stripTrailingSlash: false, }, routes: routeOptions, state: { @@ -100,15 +100,15 @@ const options: ServerOptions = { ignoreErrors: false, isSecure: true, isHttpOnly: true, - isSameSite: 'Strict', - encoding: 'none' + isSameSite: "Strict", + encoding: "none", }, - tls: true + tls: true, }; const server = new Server(options); server.start(); -server.events.on('start', () => { - console.log('Server started at: ' + server.info.uri); +server.events.on("start", () => { + console.log("Server started at: " + server.info.uri); }); diff --git a/types/hapi/test/server/server-path.ts b/types/hapi/test/server/server-path.ts index 63efae5f8dde43..ae2160398571b3 100644 --- a/types/hapi/test/server/server-path.ts +++ b/types/hapi/test/server/server-path.ts @@ -6,32 +6,32 @@ const server = new Server({ }); // Definition for INERT -declare module 'hapi' { +declare module "hapi" { interface HandlerDecorations { file?: string | undefined; } } const serverRouteOption: ServerRoute = { - path: '/file', - method: 'GET', + path: "/file", + method: "GET", handler: { - file: './test.html' - } + file: "./test.html", + }, }; const plugin: Plugin = { - name: 'example', + name: "example", register: async (server: Server, options: ServerRegisterOptions) => { // Assuming the Inert plugin was registered previously - server.path(__dirname + '../static'); + server.path(__dirname + "../static"); server.route(serverRouteOption); - } + }, }; server.start(); server.register(plugin); -server.events.on('start', () => { - console.log('Server started at: ' + server.info.uri); +server.events.on("start", () => { + console.log("Server started at: " + server.info.uri); }); diff --git a/types/hapi/test/server/server-plugins.ts b/types/hapi/test/server/server-plugins.ts index e54ebfb6b39367..4ea749c0faf2e2 100644 --- a/types/hapi/test/server/server-plugins.ts +++ b/types/hapi/test/server/server-plugins.ts @@ -17,7 +17,7 @@ interface Plugin4 { four: 4; } -declare module 'hapi' { +declare module "hapi" { interface PluginProperties { example: { other: string; @@ -27,37 +27,37 @@ declare module 'hapi' { } const plugin1: Plugin = { - name: 'plugin1', + name: "plugin1", register: async (server: Server, options: Plugin1) => { - server.expose('key', 'value'); - server.plugins.example.other = 'other'; - console.log(server.plugins.example.key); // 'value' - console.log(server.plugins.example.other); // 'other' + server.expose("key", "value"); + server.plugins.example.other = "other"; + console.log(server.plugins.example.key); // 'value' + console.log(server.plugins.example.other); // 'other' }, }; const plugin2: Plugin = { - name: 'plugin2', + name: "plugin2", register: async (server: Server, options: Plugin2) => {}, dependencies: { - plugin1: '*', + plugin1: "*", }, requirements: { - node: '>=8', - hapi: '>=1337', + node: ">=8", + hapi: ">=1337", }, }; const plugin3: Plugin = { - name: 'plugin3', + name: "plugin3", register: async (server: Server, options: Plugin3) => {}, - dependencies: ['plugin2'], + dependencies: ["plugin2"], }; const plugin4: Plugin = { - name: 'plugin4', + name: "plugin4", register: (server: Server, options: Plugin4) => {}, - dependencies: 'plugin3', + dependencies: "plugin3", }; const server = new Server({ @@ -69,48 +69,48 @@ server.register(plugin1); server.register({ plugin: plugin1, - options: {one: 1} + options: { one: 1 }, }); server.register([ { plugin: plugin2, - options: {two: 2} + options: { two: 2 }, }, { plugin: plugin3, - options: {three: 3} + options: { three: 3 }, }, { plugin: plugin1, - options: {one: 1} + options: { one: 1 }, }, { plugin: plugin2, - options: {two: 2} + options: { two: 2 }, }, { plugin: plugin3, - options: {three: 3} + options: { three: 3 }, }, { plugin: plugin1, - options: {one: 1} + options: { one: 1 }, }, { plugin: plugin2, - options: {two: 2} + options: { two: 2 }, }, { plugin: plugin3, - options: {three: 3} + options: { three: 3 }, }, { plugin: plugin1, - options: {one: 1} + options: { one: 1 }, }, { plugin: plugin4, - options: {four: 4} - } + options: { four: 4 }, + }, ]); diff --git a/types/hapi/test/server/server-settings.ts b/types/hapi/test/server/server-settings.ts index fe77f618236aec..baee9bc6e17a6e 100644 --- a/types/hapi/test/server/server-settings.ts +++ b/types/hapi/test/server/server-settings.ts @@ -1,7 +1,7 @@ // https://github.com/hapijs/hapi/blob/master/API.md#-serversettings import { Server } from "hapi"; -declare module 'hapi' { +declare module "hapi" { interface ServerOptionsApp { key?: string | undefined; } @@ -10,9 +10,9 @@ declare module 'hapi' { const server = new Server({ port: 8000, app: { - key: 'value' - } + key: "value", + }, }); server.start(); -console.log(server.settings.app); // { key: 'value' } +console.log(server.settings.app); // { key: 'value' } diff --git a/types/hapi/test/server/server-start.ts b/types/hapi/test/server/server-start.ts index f41349e88cb5d9..6067a40c140347 100644 --- a/types/hapi/test/server/server-start.ts +++ b/types/hapi/test/server/server-start.ts @@ -6,6 +6,6 @@ const server = new Server({ }); server.start(); -server.events.on('start', () => { - console.log('Server started at: ' + server.info.uri); +server.events.on("start", () => { + console.log("Server started at: " + server.info.uri); }); diff --git a/types/hapi/test/server/server-state.ts b/types/hapi/test/server/server-state.ts index ba4ffe344c5601..d78ecf9e69f33c 100644 --- a/types/hapi/test/server/server-state.ts +++ b/types/hapi/test/server/server-state.ts @@ -6,12 +6,12 @@ const options: ServerOptions = { }; const serverRoute: ServerRoute = { - path: '/say-hello', - method: 'GET', + path: "/say-hello", + method: "GET", handler(_request, h) { - h.state('test', { test: true }); - return h.response('Hello').state('data', { firstVisit: false }); - } + h.state("test", { test: true }); + return h.response("Hello").state("data", { firstVisit: false }); + }, }; const server = new Server(options); @@ -21,8 +21,8 @@ const stateOption: ServerStateCookieOptions = { ttl: 24 * 60 * 60 * 1000, // One day isSecure: false, isHttpOnly: false, - encoding: 'base64json', + encoding: "base64json", }; -server.state('data', stateOption); +server.state("data", stateOption); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/test/server/server-stop.ts b/types/hapi/test/server/server-stop.ts index 7922fa944ef040..7fab70d26ffe15 100644 --- a/types/hapi/test/server/server-stop.ts +++ b/types/hapi/test/server/server-stop.ts @@ -6,11 +6,11 @@ const server = new Server({ }); server.start(); -server.events.on('start', () => { - console.log('Server started at: ' + server.info.uri); +server.events.on("start", () => { + console.log("Server started at: " + server.info.uri); }); -server.events.on('stop', () => { - console.log('Server stoped.'); +server.events.on("stop", () => { + console.log("Server stoped."); }); setTimeout(() => { server.stop({ timeout: 10 * 1000 }); diff --git a/types/hapi/test/server/server-table.ts b/types/hapi/test/server/server-table.ts index 79726118b51fcc..410d245f6818fa 100644 --- a/types/hapi/test/server/server-table.ts +++ b/types/hapi/test/server/server-table.ts @@ -6,14 +6,14 @@ const options: ServerOptions = { }; const server = new Server(options); -server.app.key = 'value2'; +server.app.key = "value2"; server.route({ - path: '/', - method: 'GET', + path: "/", + method: "GET", handler(request, h) { return h.response("Hello World"); - } + }, }); server.start(); @@ -26,4 +26,4 @@ console.log(table[0].realm); console.log(table[0].settings); console.log(table[0].fingerprint); console.log(table[0].auth); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/test/server/server-version.ts b/types/hapi/test/server/server-version.ts index b8e59497fc00ab..a712232a7f50a3 100644 --- a/types/hapi/test/server/server-version.ts +++ b/types/hapi/test/server/server-version.ts @@ -6,4 +6,4 @@ const server = new Server({ }); server.start(); -console.log(server.version); // 17.x.x +console.log(server.version); // 17.x.x diff --git a/types/hapi/v12/hapi-tests.ts b/types/hapi/v12/hapi-tests.ts index 287a071d388dd2..9f9dc83a9802c5 100644 --- a/types/hapi/v12/hapi-tests.ts +++ b/types/hapi/v12/hapi-tests.ts @@ -1,54 +1,53 @@ // Copied directly from 918608a5e007d925f4f60a275881057f07c12619 which seems to // be the last author to work on v12.0 - -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; // Create a server with a host and port var server = new Hapi.Server(); server.connection({ host: "localhost", - port: 8000 + port: 8000, }); // Add plugins var plugin: any = { - register: function (plugin: Object, options: Object, next: Function) { + register: function(plugin: Object, options: Object, next: Function) { next(); - } + }, }; plugin.register.attributes = { name: "test", - version: "1.0.0" + version: "1.0.0", }; // optional options parameter -server.register({}, function (err) {}); +server.register({}, function(err) {}); // optional options.routes.vhost parameter -server.register({}, { select: 'api', routes: { prefix: '/prefix' } }, function (err) {}); +server.register({}, { select: "api", routes: { prefix: "/prefix" } }, function(err) {}); -//server.pack.register(plugin, (err: Object) => { +// server.pack.register(plugin, (err: Object) => { // if (err) { throw err; } -//}); +// }); -//server.pack.register([plugin], (err: Object) => { +// server.pack.register([plugin], (err: Object) => { // if (err) { throw err; } -//}); +// }); // Add server method -var add = function (a: number, b: number, next: (err: any, result?: any, ttl?: number) => void) { +var add = function(a: number, b: number, next: (err: any, result?: any, ttl?: number) => void) { next(null, a + b); }; -server.method("sum", add);//, { cache: { expiresIn: 2000 } }); +server.method("sum", add); // , { cache: { expiresIn: 2000 } }); server.methods["sum"](4, 5, (err: any, result: any) => { console.log(result); }); -var addArray = function (array: Array, next: (err: any, result?: any, ttl?: number) => void) { +var addArray = function(array: Array, next: (err: any, result?: any, ttl?: number) => void) { var sum: number = 0; array.forEach((item: number) => { sum += item; @@ -57,10 +56,10 @@ var addArray = function (array: Array, next: (err: any, result?: any, tt }; server.method("sumObj", addArray, { - //cache: { expiresIn: 2000 }, + // cache: { expiresIn: 2000 }, generateKey: (array: Array) => { - return array.join(','); - } + return array.join(","); + }, }); server.methods["sumObj"]([5, 6], (err: any, result: any) => { @@ -69,45 +68,44 @@ server.methods["sumObj"]([5, 6], (err: any, result: any) => { // Add the route server.route({ - method: 'GET', - path: '/hello', - handler: function (request: Hapi.Request, reply: Function) { - reply('hello world'); - } + method: "GET", + path: "/hello", + handler: function(request: Hapi.Request, reply: Function) { + reply("hello world"); + }, }); server.route([{ - method: 'GET', - path: '/hello2', - handler: function (request: Hapi.Request, reply: Function) { - reply('hello world2'); - } + method: "GET", + path: "/hello2", + handler: function(request: Hapi.Request, reply: Function) { + reply("hello world2"); + }, }]); // config.validate parameters should be optional server.route([{ - method: 'GET', - path: '/hello2', + method: "GET", + path: "/hello2", handler: function(request: Hapi.Request, reply: Function) { - reply('hello world2'); + reply("hello world2"); }, config: { - validate: { - } - } + validate: {}, + }, }]); // Should be able to chain reply options server.route([{ - method: 'GET', - path: '/chained-notation', + method: "GET", + path: "/chained-notation", handler: function(request: Hapi.Request, reply: Hapi.IReply) { - reply('chained-notation') + reply("chained-notation") .bytes(16) .code(200) - .type('text/plain') - .header('X-Custom', 'some-value'); - } + .type("text/plain") + .header("X-Custom", "some-value"); + }, }]); // Start the server diff --git a/types/hapi/v12/index.d.ts b/types/hapi/v12/index.d.ts index 35d5dcd1fe247d..5f6bbfa11fcd66 100644 --- a/types/hapi/v12/index.d.ts +++ b/types/hapi/v12/index.d.ts @@ -7,7 +7,6 @@ // Copied directly from 918608a5e007d925f4f60a275881057f07c12619 which seems to // be the last author to work on v12.0 - /// // eslint-disable-next-line @definitelytyped/no-declare-current-package @@ -21,18 +20,24 @@ declare module "hapi" { } interface IThenable { - then(onFulfilled?: (value: R) => U | IThenable, onRejected?: (error: any) => U | IThenable): IThenable; + then( + onFulfilled?: (value: R) => U | IThenable, + onRejected?: (error: any) => U | IThenable, + ): IThenable; then(onFulfilled?: (value: R) => U | IThenable, onRejected?: (error: any) => void): IThenable; } interface IPromise extends IThenable { - then(onFulfilled?: (value: R) => U | IThenable, onRejected?: (error: any) => U | IThenable): IPromise; + then( + onFulfilled?: (value: R) => U | IThenable, + onRejected?: (error: any) => U | IThenable, + ): IPromise; then(onFulfilled?: (value: R) => U | IThenable, onRejected?: (error: any) => void): IPromise; catch(onRejected?: (error: any) => U | IThenable): IPromise; } /** Boom Module for errors. https://github.com/hapijs/boom - * boom provides a set of utilities for returning HTTP errors. Each utility returns a Boom error response object (instance of Error) which includes the following properties: */ + * boom provides a set of utilities for returning HTTP errors. Each utility returns a Boom error response object (instance of Error) which includes the following properties: */ export interface IBoom extends Error { /** if true, indicates this is a Boom object instance. */ isBoom: boolean; @@ -58,7 +63,6 @@ declare module "hapi" { }; /** reformat()rebuilds error.output using the other object properties. */ reformat(): void; - } /** cache functionality via the "CatBox" module. */ @@ -93,8 +97,11 @@ declare module "hapi" { /** - a string or string array of labels used to server.select() specific connections matching the specified labels.Defaults to an empty array [](no labels).*/ labels?: string | string[] | undefined; /** - used to create an HTTPS connection.The tls object is passed unchanged as options to the node.js HTTPS server as described in the node.js HTTPS documentation.Set to true when passing a listener object that has been configured to use TLS directly. */ - tls?: boolean | { key?: string | undefined; cert?: string | undefined; pfx?: string | undefined; } | Object | undefined; - + tls?: + | boolean + | { key?: string | undefined; cert?: string | undefined; pfx?: string | undefined } + | Object + | undefined; } export interface IConnectionConfigurationServerDefaults { @@ -162,19 +169,25 @@ declare module "hapi" { minimal?: boolean | undefined; /** plugin-specific configuration which can later be accessed via server.settings.plugins. plugins is an object where each key is a plugin name and the value is the configuration. Note the difference between server.settings.plugins which is used to store static configuration values and server.plugins which is meant for storing run-time state. Defaults to {}.*/ plugins?: IDictionary | undefined; - } export interface IServerViewCompile { (template: string, options: any): void; - (template: string, options: any, callback: (err: any, compiled: (context: any, options: any, callback: (err: any, rendered: boolean) => void) => void) => void): void; + ( + template: string, + options: any, + callback: ( + err: any, + compiled: (context: any, options: any, callback: (err: any, rendered: boolean) => void) => void, + ) => void, + ): void; } export interface IServerViewsAdditionalOptions { /** path - the root file path used to resolve and load the templates identified when calling reply.view().Defaults to current working directory.*/ path?: string | undefined; - /**partialsPath - the root file path where partials are located.Partials are small segments of template code that can be nested and reused throughout other templates.Defaults to no partials support (empty path). - */ + /** partialsPath - the root file path where partials are located.Partials are small segments of template code that can be nested and reused throughout other templates.Defaults to no partials support (empty path). + */ partialsPath?: string | undefined; /**helpersPath - the directory path where helpers are located.Helpers are functions used within templates to perform transformations and other data manipulations using the template context or other inputs.Each '.js' file in the helpers directory is loaded and the file name is used as the helper name.The files must export a single method with the signature function(context) and return a string.Sub - folders are not supported and are ignored.Defaults to no helpers support (empty path).Note that jade does not support loading helpers this way.*/ helpersPath?: string | undefined; @@ -208,11 +221,18 @@ declare module "hapi" { } export interface IServerViewsEnginesOptions extends IServerViewsAdditionalOptions { - /**- the npm module used for rendering the templates.The module object must contain: "module", the rendering function. The required function signature depends on the compileMode settings. - * If the compileMode is 'sync', the signature is compile(template, options), the return value is a function with signature function(context, options), and the method is allowed to throw errors.If the compileMode is 'async', the signature is compile(template, options, callback) where callback has the signature function(err, compiled) where compiled is a function with signature function(context, options, callback) and callback has the signature function(err, rendered).*/ + /** - the npm module used for rendering the templates.The module object must contain: "module", the rendering function. The required function signature depends on the compileMode settings. + * If the compileMode is 'sync', the signature is compile(template, options), the return value is a function with signature function(context, options), and the method is allowed to throw errors.If the compileMode is 'async', the signature is compile(template, options, callback) where callback has the signature function(err, compiled) where compiled is a function with signature function(context, options, callback) and callback has the signature function(err, rendered). */ module: { compile?(template: any, options: any): (context: any, options: any) => void; - compile?(template: any, options: any, callback: (err: any, compiled: (context: any, options: any, callback: (err: any, rendered: any) => void) => void) => void): void; + compile?( + template: any, + options: any, + callback: ( + err: any, + compiled: (context: any, options: any, callback: (err: any, rendered: any) => void) => void, + ) => void, + ): void; }; } @@ -243,16 +263,17 @@ declare module "hapi" { FLOW CONTROL: When calling reply(), the framework waits until process.nextTick() to continue processing the request and transmit the response. This enables making changes to the returned response object before the response is sent. This means the framework will resume as soon as the handler method exits. To suspend this behavior, the returned response object supports the following methods: hold(), send() */ export interface IReply { - (err: Error, + ( + err: Error, result?: string | number | boolean | Buffer | stream.Stream | IPromise | T, /** Note that when used to return both an error and credentials in the authentication methods, reply() must be called with three arguments function(err, null, data) where data is the additional authentication information. */ - credentialData?: any + credentialData?: any, ): IBoom; /** Note that if result is a Stream with a statusCode property, that status code will be used as the default response code. */ (result: string | number | boolean | Buffer | stream.Stream | IPromise | T): Response; /** Returns control back to the framework without setting a response. If called in the handler, the response defaults to an empty payload with status code 200. - * The data argument is only used for passing back authentication data and is ignored elsewhere. */ + * The data argument is only used for passing back authentication data and is ignored elsewhere. */ continue(credentialData?: any): void; /** Transmits a file from the file system. The 'Content-Type' header defaults to the matching mime type based on filename extension. The response flow control rules do not apply. */ @@ -270,7 +291,8 @@ declare module "hapi" { mode?: boolean | string | undefined; /** if true, looks for the same filename with the '.gz' suffix for a pre-compressed version of the file to serve if the request supports content encoding. Defaults to false. */ lookupCompressed: boolean; - }): void; + }, + ): void; /** Concludes the handler activity by returning control over to the router with a templatized view response. the response flow control rules apply. */ @@ -280,7 +302,8 @@ declare module "hapi" { /** optional object used by the template to render context-specific result. Defaults to no context {}. */ context?: {}, /** optional object used to override the server's views manager configuration for this response. Cannot override isCached, partialsPath, or helpersPath which are only loaded at initialization. */ - options?: any): Response; + options?: any, + ): Response; /** Concludes the handler activity by returning control over to the router and informing the router that a response has already been sent back directly via request.raw.res and that no further response action is needed The response flow control rules do not apply. */ close(options?: { @@ -290,8 +313,10 @@ declare module "hapi" { /** Proxies the request to an upstream endpoint. the response flow control rules do not apply. */ - proxy(/** an object including the same keys and restrictions defined by the route proxy handler options. */ - options: IProxyHandlerConfig): void; + proxy( + /** an object including the same keys and restrictions defined by the route proxy handler options. */ + options: IProxyHandlerConfig, + ): void; /** Redirects the client to the specified uri. Same as calling reply().redirect(uri). The response flow control rules apply. */ redirect(uri: string): ResponseRedirect; @@ -304,9 +329,8 @@ declare module "hapi" { (request: Request): T; } - export interface IFailAction { - (source: string, error: any, next: () => void): void + (source: string, error: any, next: () => void): void; } /** generates a reverse proxy handler */ export interface IProxyHandlerConfig { @@ -340,16 +364,23 @@ declare module "hapi" { err - internal error condition. uri - the absolute proxy URI. headers - optional object where each key is an HTTP request header and the value is the header content.*/ - mapUri?: ((request: Request, callback: (err: any, uri: string, headers?: { [key: string]: string }) => void) => void) | undefined; + mapUri?: + | (( + request: Request, + callback: (err: any, uri: string, headers?: { [key: string]: string }) => void, + ) => void) + | undefined; /** a custom function for processing the response from the upstream service before sending to the client. Useful for custom error handling of responses from the proxied endpoint or other payload manipulation. Function signature is function(err, res, request, reply, settings, ttl) where: - err - internal or upstream error returned from attempting to contact the upstream proxy. - res - the node response object received from the upstream service. res is a readable stream (use the wreck module read method to easily convert it to a Buffer or string). - request - is the incoming request object. - reply - the reply interface function. - settings - the proxy handler configuration. - ttl - the upstream TTL in milliseconds if proxy.ttl it set to 'upstream' and the upstream response included a valid 'Cache-Control' header with 'max-age'.*/ - onResponse?: (( - err: any, - res: http.ServerResponse, - req: Request, - reply: IReply, - settings: IProxyHandlerConfig, - ttl: number - ) => void) | undefined; + onResponse?: + | (( + err: any, + res: http.ServerResponse, + req: Request, + reply: IReply, + settings: IProxyHandlerConfig, + ttl: number, + ) => void) + | undefined; /** if set to 'upstream', applies the upstream response caching policy to the response using the response.ttl() method (or passed as an argument to the onResponse method if provided).*/ ttl?: number | undefined; /** - a node http(s) agent to be used for connections to upstream server. see https://nodejs.org/api/http.html#http_class_http_agent */ @@ -359,17 +390,17 @@ declare module "hapi" { } /** TODO: fill in joi definition */ export interface IJoi { - } /** a validation function using the signature function(value, options, next) */ export interface IValidationFunction { - - (/** the object containing the path parameters. */ + ( + /** the object containing the path parameters. */ value: any, /** the server validation options. */ options: any, /** the callback function called when validation is completed. */ - next: (err: any, value: any) => void): void; + next: (err: any, value: any) => void, + ): void; } /** a custom error handler function with the signature 'function(request, reply, source, error)` */ export interface IRouteFailFunction { @@ -382,7 +413,8 @@ declare module "hapi" { /** the source of the invalid field (e.g. 'path', 'query', 'payload'). */ source: string, /** the error object prepared for the client response (including the validation function error under error.data). */ - error: any): void; + error: any, + ): void; } /** Each route can be customize to change the default behavior of the request lifecycle using the following options: */ @@ -392,8 +424,7 @@ declare module "hapi" { /** authentication configuration.Value can be: false to disable authentication if a default strategy is set. a string with the name of an authentication strategy registered with server.auth.strategy(). an object */ - auth?: boolean | string | - { + auth?: boolean | string | { /** the authentication mode.Defaults to 'required' if a server authentication strategy is configured, otherwise defaults to no authentication.Available values: 'required'authentication is required. 'optional'authentication is optional (must be valid if present). @@ -414,9 +445,9 @@ declare module "hapi" { appthe authentication must be on behalf of an application. */ entity?: string | undefined; /** - * an object or array of objects specifying the route access rules. Each rule is evaluated against an incoming - * request and access is granted if at least one rule matches. Each rule object must include at least one of: - */ + * an object or array of objects specifying the route access rules. Each rule is evaluated against an incoming + * request and access is granted if at least one rule matches. Each rule object must include at least one of: + */ access?: IRouteAdditionalConfigurationAuthAccess | IRouteAdditionalConfigurationAuthAccess[] | undefined; } | undefined; /** an object passed back to the provided handler (via this) when called. */ @@ -461,7 +492,8 @@ declare module "hapi" { override?: boolean | undefined; } | undefined; /** defines the behavior for serving static resources using the built-in route handlers for files and directories: */ - files?: {/** determines the folder relative paths are resolved against when using the file and directory handlers. */ + files?: { + /** determines the folder relative paths are resolved against when using the file and directory handlers. */ relativeTo: string; } | undefined; @@ -530,7 +562,7 @@ declare module "hapi" { next(err) - the callback function called when validation is completed. */ schema?: boolean | any | undefined; /** HTTP status- codespecific validation rules.The status key is set to an object where each key is a 3 digit HTTP status code and the value has the same definition as schema.If a response status code is not present in the status object, the schema definition is used, expect for errors which are not validated by default. */ - status?: { [statusCode: number] : boolean | any } | undefined; + status?: { [statusCode: number]: boolean | any } | undefined; /** the percent of responses validated (0100).Set to 0 to disable all validation.Defaults to 100 (all responses). */ sample?: number | undefined; /** defines what to do when a response fails validation.Options are: @@ -590,7 +622,6 @@ declare module "hapi" { */ headers?: boolean | IJoi | IValidationFunction | undefined; - /** validation rules for incoming request path parameters, after matching the path against the route and extracting any parameters then stored in request.params.Values allowed: trueany path parameters allowed (no validation performed).This is the default. falseno path variables allowed. @@ -642,38 +673,38 @@ declare module "hapi" { } | undefined; /** ONLY WHEN ADDING NEW ROUTES (not when setting defaults). - *route description used for generating documentation (string). - */ + * route description used for generating documentation (string). + */ description?: string | undefined; /** ONLY WHEN ADDING NEW ROUTES (not when setting defaults). - *route notes used for generating documentation (string or array of strings). - */ + * route notes used for generating documentation (string or array of strings). + */ notes?: string | string[] | undefined; /** ONLY WHEN ADDING NEW ROUTES (not when setting defaults). - *route tags used for generating documentation (array of strings). - */ - tags?: string[] | undefined + * route tags used for generating documentation (array of strings). + */ + tags?: string[] | undefined; } /** - * specifying the route access rules. Each rule is evaluated against an incoming request and access is granted if at least one rule matches - */ + * specifying the route access rules. Each rule is evaluated against an incoming request and access is granted if at least one rule matches + */ export interface IRouteAdditionalConfigurationAuthAccess { /** - * the application scope required to access the route. Value can be a scope string or an array of scope strings. - * The authenticated credentials object scope property must contain at least one of the scopes defined to access the route. - * If a scope string begins with a + character, that scope is required. If a scope string begins with a ! character, - * that scope is forbidden. For example, the scope ['!a', '+b', 'c', 'd'] means the incoming request credentials' - * scope must not include 'a', must include 'b', and must include on of 'c' or 'd'. You may also access properties - * on the request object (query and params} to populate a dynamic scope by using {} characters around the property name, - * such as 'user-{params.id}'. Defaults to false (no scope requirements). - */ + * the application scope required to access the route. Value can be a scope string or an array of scope strings. + * The authenticated credentials object scope property must contain at least one of the scopes defined to access the route. + * If a scope string begins with a + character, that scope is required. If a scope string begins with a ! character, + * that scope is forbidden. For example, the scope ['!a', '+b', 'c', 'd'] means the incoming request credentials' + * scope must not include 'a', must include 'b', and must include on of 'c' or 'd'. You may also access properties + * on the request object (query and params} to populate a dynamic scope by using {} characters around the property name, + * such as 'user-{params.id}'. Defaults to false (no scope requirements). + */ scope?: string | Array | boolean | undefined; /** the required authenticated entity type. If set, must match the entity value of the authentication credentials. Available values: - * any - the authentication can be on behalf of a user or application. This is the default value. - * user - the authentication must be on behalf of a user which is identified by the presence of a user attribute in the credentials object returned by the authentication strategy. - * app - the authentication must be on behalf of an application which is identified by the lack of presence of a user attribute in the credentials object returned by the authentication strategy. - */ + * any - the authentication can be on behalf of a user or application. This is the default value. + * user - the authentication must be on behalf of a user which is identified by the presence of a user attribute in the credentials object returned by the authentication strategy. + * app - the authentication must be on behalf of an application which is identified by the lack of presence of a user attribute in the credentials object returned by the authentication strategy. + */ entity?: string | undefined; } @@ -697,7 +728,6 @@ declare module "hapi" { /** the route virtual host settings used by any calls to server.route() from the server. */ vhost: string; }; - }; /** the active plugin name (empty string if at the server root). */ plugin: string; @@ -709,19 +739,20 @@ declare module "hapi" { relativeTo: any; }; bind: any; - } + }; } /** server.state(name, [options]) http://hapijs.com/api#serverstatename-options HTTP state management uses client cookies to persist a state across multiple requests. Registers a cookie definitions where:*/ export interface IServerState { -/** - the cookie name string. */name: string; - -/** - are the optional cookie settings: */options: { -/** - time - to - live in milliseconds.Defaults to null (session time- life - cookies are deleted when the browser is closed).*/ttl: number; -/** - sets the 'Secure' flag.Defaults to false.*/isSecure: boolean; -/** - sets the 'HttpOnly' flag.Defaults to false.*/isHttpOnly: boolean -/** - the path scope.Defaults to null (no path).*/path: any; -/** - the domain scope.Defaults to null (no domain). */domain: any; + /** - the cookie name string. */ name: string; + + /** - are the optional cookie settings: */ options: { + /** - time - to - live in milliseconds.Defaults to null (session time- life - cookies are deleted when the browser is closed).*/ ttl: + number; + /** - sets the 'Secure' flag.Defaults to false.*/ isSecure: boolean; + /** - sets the 'HttpOnly' flag.Defaults to false.*/ isHttpOnly: boolean; + /** - the path scope.Defaults to null (no path).*/ path: any; + /** - the domain scope.Defaults to null (no domain). */ domain: any; /** if present and the cookie was not received from the client or explicitly set by the route handler, the cookie is automatically added to the response with the provided value. The value can be a function with signature function(request, next) where: request - the request object. next - the continuation function using the function(err, value) signature.*/ @@ -733,16 +764,19 @@ declare module "hapi" { 'form' - object value is encoded using the x-www-form-urlencoded method. 'iron' - Encrypts and sign the value using iron.*/ encoding: string; -/** - an object used to calculate an HMAC for cookie integrity validation.This does not provide privacy, only a mean to verify that the cookie value was generated by the server.Redundant when 'iron' encoding is used.Options are:*/sign: { -/** - algorithm options.Defaults to require('iron').defaults.integrity.*/integrity: any; -/** - password used for HMAC key generation.*/password: string; - }; -/** - password used for 'iron' encoding.*/password: string; -/** - options for 'iron' encoding.Defaults to require('iron').defaults.*/iron: any; -/** - if false, errors are ignored and treated as missing cookies.*/ignoreErrors: boolean; -/** - if true, automatically instruct the client to remove invalid cookies.Defaults to false.*/clearInvalid: boolean; -/** - if false, allows any cookie value including values in violation of RFC 6265. Defaults to true.*/strictHeader: boolean; -/** - overrides the default proxy localStatePassThrough setting.*/passThrough: any; + /** - an object used to calculate an HMAC for cookie integrity validation.This does not provide privacy, only a mean to verify that the cookie value was generated by the server.Redundant when 'iron' encoding is used.Options are:*/ sign: + { + /** - algorithm options.Defaults to require('iron').defaults.integrity.*/ integrity: any; + /** - password used for HMAC key generation.*/ password: string; + }; + /** - password used for 'iron' encoding.*/ password: string; + /** - options for 'iron' encoding.Defaults to require('iron').defaults.*/ iron: any; + /** - if false, errors are ignored and treated as missing cookies.*/ ignoreErrors: boolean; + /** - if true, automatically instruct the client to remove invalid cookies.Defaults to false.*/ clearInvalid: + boolean; + /** - if false, allows any cookie value including values in violation of RFC 6265. Defaults to true.*/ strictHeader: + boolean; + /** - overrides the default proxy localStatePassThrough setting.*/ passThrough: any; }; } @@ -798,7 +832,7 @@ declare module "hapi" { params: any; query: any; pre: any; - } + }; } | undefined; config?: { handler: any; @@ -860,7 +894,7 @@ declare module "hapi" { /** - (required) the absolute path used to match incoming requests (must begin with '/'). Incoming requests are compared to the configured paths based on the connection router configuration option.The path can include named parameters enclosed in {} which will be matched against literal values in the request as described in Path parameters.*/ path: string; /** - (required) the HTTP method.Typically one of 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', or 'OPTIONS'.Any HTTP method is allowed, except for 'HEAD'.Use '*' to match against any HTTP method (only when an exact match was not found, and any match with a specific method will be given a higher priority over a wildcard match). - * Can be assigned an array of methods which has the same result as adding the same route with different methods manually.*/ + * Can be assigned an array of methods which has the same result as adding the same route with different methods manually. */ method: string | string[]; /** - an optional domain string or an array of domain strings for limiting the route to only requests with a matching host header field.Matching is done against the hostname part of the header only (excluding the port).Defaults to all hosts.*/ vhost?: string | undefined; @@ -871,8 +905,6 @@ declare module "hapi" { } /** Route public interface When route information is returned or made available as a property. http://hapijs.com/api#route-public-interface */ export interface IRoute { - - /** the route HTTP method. */ method: string; /** the route path. */ @@ -935,43 +967,42 @@ declare module "hapi" { options?: { /** if true, requires payload validation as part of the scheme and forbids routes from disabling payload auth validation. Defaults to false.*/ payload: boolean; - } | undefined + } | undefined; } - - export interface IServerInject { - (options: string | { - /** the request HTTP method (e.g. 'POST'). Defaults to 'GET'.*/ - method: string; - /** the request URL. If the URI includes an authority (e.g. 'example.com:8080'), it is used to automatically set an HTTP 'Host' header, unless one was specified in headers.*/ - url: string; - /** an object with optional request headers where each key is the header name and the value is the header content. Defaults to no additions to the default Shot headers.*/ - headers?: IDictionary | undefined; - /** n optional string, buffer or object containing the request payload. In case of an object it will be converted to a string for you. Defaults to no payload. Note that payload processing defaults to 'application/json' if no 'Content-Type' header provided.*/ - payload?: string | {} | Buffer | undefined; - /** an optional credentials object containing authentication information. The credentials are used to bypass the default authentication strategies, and are validated directly as if they were received via an authentication scheme. Defaults to no credentials.*/ - credentials?: any; - /** an optional artifacts object containing authentication artifact information. The artifacts are used to bypass the default authentication strategies, and are validated directly as if they were received via an authentication scheme. Ignored if set without credentials. Defaults to no artifacts.*/ - artifacts?: any; - /** sets the initial value of request.app*/ - app?: any; - /** sets the initial value of request.plugins*/ - plugins?: any; - /** allows access to routes with config.isInternal set to true. Defaults to false.*/ - allowInternals?: boolean | undefined; - /** sets the remote address for the incoming connection.*/ - remoteAddress?: boolean | undefined; - /**object with options used to simulate client request stream conditions for testing: + ( + options: string | { + /** the request HTTP method (e.g. 'POST'). Defaults to 'GET'.*/ + method: string; + /** the request URL. If the URI includes an authority (e.g. 'example.com:8080'), it is used to automatically set an HTTP 'Host' header, unless one was specified in headers.*/ + url: string; + /** an object with optional request headers where each key is the header name and the value is the header content. Defaults to no additions to the default Shot headers.*/ + headers?: IDictionary | undefined; + /** n optional string, buffer or object containing the request payload. In case of an object it will be converted to a string for you. Defaults to no payload. Note that payload processing defaults to 'application/json' if no 'Content-Type' header provided.*/ + payload?: string | {} | Buffer | undefined; + /** an optional credentials object containing authentication information. The credentials are used to bypass the default authentication strategies, and are validated directly as if they were received via an authentication scheme. Defaults to no credentials.*/ + credentials?: any; + /** an optional artifacts object containing authentication artifact information. The artifacts are used to bypass the default authentication strategies, and are validated directly as if they were received via an authentication scheme. Ignored if set without credentials. Defaults to no artifacts.*/ + artifacts?: any; + /** sets the initial value of request.app*/ + app?: any; + /** sets the initial value of request.plugins*/ + plugins?: any; + /** allows access to routes with config.isInternal set to true. Defaults to false.*/ + allowInternals?: boolean | undefined; + /** sets the remote address for the incoming connection.*/ + remoteAddress?: boolean | undefined; + /**object with options used to simulate client request stream conditions for testing: error - if true, emits an 'error' event after payload transmission (if any). Defaults to false. close - if true, emits a 'close' event after payload transmission (if any). Defaults to false. end - if false, does not end the stream. Defaults to true.*/ - simulate?: { - error: boolean; - close: boolean; - end: boolean; - } | undefined; - }, + simulate?: { + error: boolean; + close: boolean; + end: boolean; + } | undefined; + }, callback: ( /**the response object where: statusCode - the HTTP status code. @@ -983,12 +1014,19 @@ declare module "hapi" { res - the simulated node response object. result - the raw handler response (e.g. when not a stream or a view) before it is serialized for transmission. If not available, the value is set to payload. Useful for inspection and reuse of the internal objects returned (instead of parsing the response string). request - the request object.*/ - res: { statusCode: number; headers: IDictionary; payload: string; rawPayload: Buffer; raw: { req: http.ClientRequest; res: http.ServerResponse }; result: string; request: Request }) => void + res: { + statusCode: number; + headers: IDictionary; + payload: string; + rawPayload: Buffer; + raw: { req: http.ClientRequest; res: http.ServerResponse }; + result: string; + request: Request; + }, + ) => void, ): void; - } - /** host - optional host to filter routes matching a specific virtual host. Defaults to all virtual hosts. The return value is an array where each item is an object containing: info - the connection.info the connection the table was generated for. @@ -1027,7 +1065,7 @@ declare module "hapi" { /** - an object used to calculate an HMAC for cookie integrity validation.This does not provide privacy, only a mean to verify that the cookie value was generated by the server.Redundant when 'iron' encoding is used.Options are: integrity - algorithm options.Defaults to require('iron').defaults.integrity. password - password used for HMAC key generation. */ - sign?: { integrity: any; password: string; } | undefined + sign?: { integrity: any; password: string } | undefined; password?: string | undefined; iron?: any; ignoreErrors?: boolean | undefined; @@ -1048,13 +1086,12 @@ declare module "hapi" { the callback option is set to false. the method must returns a value (result, Error, or a promise) or throw an Error.*/ export interface IServerMethod { - //(): void; - //(next: (err: any, result: any, ttl: number) => void): void; - //(arg1: any): void; - //(arg1: any, arg2: any, next: (err: any, result: any, ttl: number) => void): void; - //(arg1: any, arg2: any): void; + // (): void; + // (next: (err: any, result: any, ttl: number) => void): void; + // (arg1: any): void; + // (arg1: any, arg2: any, next: (err: any, result: any, ttl: number) => void): void; + // (arg1: any, arg2: any): void; (...args: any[]): void; - } /** options - optional configuration: bind - a context object passed back to the method function (via this) when called. Defaults to active context (set via server.bind() when the method is registered. @@ -1118,7 +1155,7 @@ declare module "hapi" { /** the authentication error is failed and mode set to 'try'.*/ error: any; /** an object used by the ['cookie' authentication scheme] https://github.com/hapijs/hapi-auth-cookie */ - session: any + session: any; }; /** the connection used by this request*/ connection: ServerConnection; @@ -1281,7 +1318,8 @@ declare module "hapi" { /** an optional message string or object with the application data being logged.*/ data?: string, /** an optional timestamp expressed in milliseconds. Defaults to Date.now() (now).*/ - timestamp?: number): void; + timestamp?: number, + ): void; /** request.getLog([tags], [internal]) Always available. @@ -1297,7 +1335,8 @@ declare module "hapi" { /** is a single tag string or array of tag strings. If no tags specified, returns all events.*/ tags?: string, /** filters the events to only those with a matching event.internal value. If true, only internal logs are included. If false, only user event are included. Defaults to all events (undefined).*/ - internal?: boolean): string[]; + internal?: boolean, + ): string[]; /** request.tail([name]) @@ -1336,7 +1375,8 @@ declare module "hapi" { });*/ tail( /** an optional tail name used for logging purposes.*/ - name?: string): Function; + name?: string, + ): Function; } /** Response events @@ -1403,7 +1443,7 @@ declare module "hapi" { stringify: any; ttl: number; varyEtag: boolean; - } + }; /** sets the HTTP 'Content-Length' header (to avoid chunked transfer encoding) where: length - the header value. Must match the actual payload size.*/ @@ -1417,7 +1457,6 @@ declare module "hapi" { /** sets the HTTP status code to Created (201) and the HTTP 'Location' header where: uri - an absolute or relative URI used as the 'Location' header value.*/ created(uri: string): Response; - /** encoding(encoding) - sets the string encoding scheme used to serial data into the HTTP payload where: encoding - the encoding property value (see node Buffer encoding).*/ encoding(encoding: string): Response; @@ -1427,7 +1466,8 @@ declare module "hapi" { weak - if true, the tag will be prefixed with the 'W/' weak signifier. Weak tags will fail to match identical tags for the purpose of determining 304 response status. Defaults to false. vary - if true and content encoding is set or applied to the response (e.g 'gzip' or 'deflate'), the encoding name will be automatically added to the tag at transmission time (separated by a '-' character). Ignored when weak is true. Defaults to true.*/ etag(tag: string, options: { - weak: boolean; vary: boolean; + weak: boolean; + vary: boolean; }): Response; /**header(name, value, options) - sets an HTTP header where: @@ -1527,7 +1567,13 @@ Notes: 1. Default value. 2. Proposed code, not supported by all clients. */ */ export class ServerConnection extends Events.EventEmitter { domain: any; - _events: { route: Function, domain: Function, _events: Function, _eventsCount: Function, _maxListeners: Function }; + _events: { + route: Function; + domain: Function; + _events: Function; + _eventsCount: Function; + _maxListeners: Function; + }; _eventsCount: number; settings: IServerConnectionOptions; server: Server; @@ -1542,9 +1588,11 @@ Notes: 1. Default value. 2. Proposed code, not supported by all clients. */ _requestCounter: { value: number; min: number; max: number }; _load: any; states: { - settings: any; cookies: any; names: any[] + settings: any; + cookies: any; + names: any[]; }; - auth: { connection: ServerConnection; _schemes: any; _strategies: any; settings: any; }; + auth: { connection: ServerConnection; _schemes: any; _strategies: any; settings: any }; _router: any; MSPluginsCollection: any; applicationCache: any; @@ -1567,7 +1615,6 @@ Notes: 1. Default value. 2. Proposed code, not supported by all clients. */ Note that the server object should not be used to emit application events as its internal implementation is designed to fan events out to the various plugin selections and not for application events. MORE EVENTS HERE: http://hapijs.com/api#server-events*/ export class Server extends Events.EventEmitter { - constructor(options?: IServerOptions); /** Provides a safe place to store server-specific run-time application data without potential conflicts with the framework internals. The data can be accessed whenever the server is accessible. Initialized with an empty object. var Hapi = require('hapi'); @@ -1743,7 +1790,8 @@ Notes: 1. Default value. 2. Proposed code, not supported by all clients. */ scheme - the method implementing the scheme with signature function(server, options) where: server - a reference to the server object the scheme is added to. options - optional scheme settings used to instantiate a strategy.*/ - scheme(name: string, + scheme( + name: string, /** When the scheme authenticate() method implementation calls reply() with an error condition, the specifics of the error affect whether additional authentication strategies will be attempted if configured for the route. If the err returned by the reply() method includes a message, no additional strategies will be attempted. If the err does not include a message but does include a scheme name (e.g. Boom.unauthorized(null, 'Custom')), additional strategies will be attempted in order of preference. n the scheme payload() method returns an error with a message, it means payload validation failed due to bad payload. If the error has no message but includes a scheme name (e.g. Boom.unauthorized(null, 'Custom')), authentication may still be successful if the route auth.payload configuration is set to 'optional'. server = new Hapi.Server(); @@ -1761,7 +1809,8 @@ Notes: 1. Default value. 2. Proposed code, not supported by all clients. */ }; }; */ - scheme: (server: Server, options: any) => IServerAuthScheme): void; + scheme: (server: Server, options: any) => IServerAuthScheme, + ): void; /** server.auth.strategy(name, scheme, [mode], [options]) Registers an authentication strategy where: @@ -1828,7 +1877,6 @@ Notes: 1. Default value. 2. Proposed code, not supported by all clients. */ };*/ bind(context: any): void; - /** server.cache(options) Provisions a cache segment within the server cache facility where: options - catbox policy configuration where: @@ -1904,7 +1952,6 @@ Notes: 1. Default value. 2. Proposed code, not supported by all clients. */ };*/ dependency(dependencies: string | string[], after?: (server: Server, next: (err: any) => void) => void): void; - /** server.expose(key, value) Used within a plugin to expose a property via server.plugins[name] where: key - the key assigned (server.plugins[name][key]). @@ -1949,7 +1996,11 @@ Notes: 1. Default value. 2. Proposed code, not supported by all clients. */ server.route({ method: 'GET', path: '/test', handler: handler }); server.start(); // All requests will get routed to '/test'*/ - ext(event: string, method: (request: Request, reply: IReply, bind?: any) => void, options?: { before: string | string[]; after: string | string[]; bind?: any }): void; + ext( + event: string, + method: (request: Request, reply: IReply, bind?: any) => void, + options?: { before: string | string[]; after: string | string[]; bind?: any }, + ): void; /** server.handler(name, method) Registers a new handler type to be used in routes where: @@ -1989,7 +2040,10 @@ Notes: 1. Default value. 2. Proposed code, not supported by all clients. */ } }; server.handler('test', handler);*/ - handler(name: string, method: (route: IRoute, options: THandlerConfig) => ISessionHandler): void; + handler( + name: string, + method: (route: IRoute, options: THandlerConfig) => ISessionHandler, + ): void; /** When the server contains exactly one connection, injects a request into the sole connection simulating an incoming HTTP request without making an actual socket connection. Injection is useful for testing purposes as well as for invoking routing logic internally without the overhead or limitations of the network stack. Utilizes the [shot module | https://github.com/hapijs/shot ] for performing injections, with some additional options and response properties @@ -2059,9 +2113,6 @@ Notes: 1. Default value. 2. Proposed code, not supported by all clients. */ When the server contains more than one connection, each server.connections array member provides its own connection.match() method.*/ match(method: string, path: string, host?: string): IRoute; - - - /** server.method(name, method, [options]) Registers a server method. Server methods are functions registered with the server and used throughout the application as a common utility. Their advantage is in the ability to configure them to use the built-in cache and share across multiple request handlers without having to create a common module. Methods are registered via server.method(name, method, [options]) @@ -2105,8 +2156,8 @@ Notes: 1. Default value. 2. Proposed code, not supported by all clients. */ /** a unique method name used to invoke the method via server.methods[name]. When configured with caching enabled, server.methods[name].cache.drop(arg1, arg2, ..., argn, callback) can be used to clear the cache for a given key. Supports using nested names such as utils.users.get which will automatically create the missing path under server.methods and can be accessed for the previous example via server.methods.utils.users.get.*/ name: string, method: IServerMethod, - options?: IServerMethodOptions): void; - + options?: IServerMethodOptions, + ): void; /**server.method(methods) Registers a server method function as described in server.method() using a configuration object where: @@ -2126,11 +2177,19 @@ Notes: 1. Default value. 2. Proposed code, not supported by all clients. */ } } });*/ - method(methods: { - name: string; method: IServerMethod; options?: IServerMethodOptions | undefined - } | Array<{ - name: string; method: IServerMethod; options?: IServerMethodOptions | undefined - }>): void; + method( + methods: + | { + name: string; + method: IServerMethod; + options?: IServerMethodOptions | undefined; + } + | Array<{ + name: string; + method: IServerMethod; + options?: IServerMethodOptions | undefined; + }>, + ): void; /**server.path(relativeTo) Sets the path prefix used to locate static resources (files and view templates) when relative paths are used where: relativeTo - the path prefix added to any relative file path starting with '.'. @@ -2168,10 +2227,10 @@ Notes: 1. Default value. 2. Proposed code, not supported by all clients. */ register(plugins: any | any[], options: { select: string | string[]; routes: { - prefix: string; vhost?: string | string[] | undefined + prefix: string; + vhost?: string | string[] | undefined; }; - } - , callback: (err: any) => void): void; + }, callback: (err: any) => void): void; register(plugins: any | any[], callback: (err: any) => void): void; @@ -2198,7 +2257,12 @@ Notes: 1. Default value. 2. Proposed code, not supported by all clients. */ server.render('hello', context, function (err, rendered, config) { console.log(rendered); });*/ - render(template: string, context: any, options: any, callback: (err: any, rendered: any, config: any) => void): void; + render( + template: string, + context: any, + options: any, + callback: (err: any, rendered: any, config: any) => void, + ): void; /** server.route(options) Adds a connection route where: options - a route configuration object or an array of configuration objects. @@ -2327,6 +2391,5 @@ Notes: 1. Default value. 2. Proposed code, not supported by all clients. */ }); When server.views() is called within a plugin, the views manager is only available to plugins methods.*/ views(options: IServerViewsConfiguration): void; - } } diff --git a/types/hapi/v15/hapi-tests.ts b/types/hapi/v15/hapi-tests.ts index 0ce42141827c63..f8b15aadd969a9 100644 --- a/types/hapi/v15/hapi-tests.ts +++ b/types/hapi/v15/hapi-tests.ts @@ -4,19 +4,19 @@ import Hapi = require("hapi"); const server = new Hapi.Server(); server.connection({ host: "localhost", - port: 8000 + port: 8000, }); // Add plugins const plugin: any = { register(plugin: Object, options: Object, next: Function) { next(); - } + }, }; plugin.register.attributes = { name: "test", - version: "1.0.0" + version: "1.0.0", }; // optional options parameter @@ -25,12 +25,12 @@ server.register({}, err => {}); server.register({}).then((res: any) => { console.log(res); }); -server.register({}, {select: "api", routes: {prefix: "/prefix"}}).then((res: any) => { +server.register({}, { select: "api", routes: { prefix: "/prefix" } }).then((res: any) => { console.log(res); }); // optional options.routes.vhost parameter -server.register({}, {select: "api", routes: {prefix: "/prefix"}}, err => {}); +server.register({}, { select: "api", routes: { prefix: "/prefix" } }, err => {}); // server.pack.register(plugin, (err: Object) => { // if (err) { throw err; } @@ -62,8 +62,8 @@ function addArray(array: number[], next: (err: any, result?: any, ttl?: number) server.method("sumObj", addArray, { cache: { expiresIn: 2000 }, generateKey(array: number[]) { - return array.join(','); - } + return array.join(","); + }, }); server.methods["sumObj"]([5, 6], (err: any, result: any) => { @@ -72,28 +72,28 @@ server.methods["sumObj"]([5, 6], (err: any, result: any) => { // Add the route server.route({ - method: 'GET', - path: '/hello', + method: "GET", + path: "/hello", handler(request: Hapi.Request, reply: Function) { - request.log('info', { route: '/hello' }, Date.now()); - reply('hello world'); - } + request.log("info", { route: "/hello" }, Date.now()); + reply("hello world"); + }, }); server.route([{ - method: 'GET', - path: '/hello2', + method: "GET", + path: "/hello2", handler(request: Hapi.Request, reply: Function) { - reply('hello world2'); - } + reply("hello world2"); + }, }]); server.route([{ - method: 'GET', - path: '/hello3', + method: "GET", + path: "/hello3", handler(request: Hapi.Request, reply: Hapi.IReply) { - reply('hello world2'); - } + reply("hello world2"); + }, }]); interface IHello { @@ -101,48 +101,48 @@ interface IHello { } server.route([{ - method: 'GET', - path: '/hello4', + method: "GET", + path: "/hello4", handler(request: Hapi.Request, reply: Hapi.IStrictReply) { - reply({ msg: 'hello world' }); - } + reply({ msg: "hello world" }); + }, }]); // Implict handler server.route({ - method: 'GET', - path: '/hello6', + method: "GET", + path: "/hello6", handler(request: Hapi.Request, reply: Hapi.IReply) { - request.log('info', { route: '/hello' }, Date.now()); - reply('hello world'); - } + request.log("info", { route: "/hello" }, Date.now()); + reply("hello world"); + }, }); // config.validate parameters should be optional server.route([{ - method: 'GET', - path: '/hello2', + method: "GET", + path: "/hello2", handler(request: Hapi.Request, reply: Function) { - reply('hello world2'); + reply("hello world2"); }, config: { - validate: {} - } + validate: {}, + }, }]); // Should be able to chain reply options server.route([{ - method: 'GET', - path: '/chained-notation', + method: "GET", + path: "/chained-notation", handler(request: Hapi.Request, reply: Hapi.IReply) { - reply.state('cookie_key', 'cookie_value'); - reply('chained-notation') + reply.state("cookie_key", "cookie_value"); + reply("chained-notation") .bytes(16) .code(200) - .type('text/plain') - .unstate('cookie_to_remove') - .header('X-Custom', 'some-value'); - } + .type("text/plain") + .unstate("cookie_to_remove") + .header("X-Custom", "some-value"); + }, }]); // Start the server @@ -151,21 +151,21 @@ server.start(); // server startup may now return a promise server.start() .then(() => { - console.log('Started!'); + console.log("Started!"); }); // inject a request into connection server.inject({ - method: 'GET', - url: '/hello' + method: "GET", + url: "/hello", }).then(response => { console.log(response.statusCode); }); // the same but this time using callback server.inject({ - method: 'GET', - url: '/hello' + method: "GET", + url: "/hello", }, response => { console.log(response.statusCode); }); @@ -173,7 +173,7 @@ server.inject({ // tests for server initialization server.initialize() .then(() => { - console.log('Initialized!'); + console.log("Initialized!"); }); // and the same but with callback @@ -186,14 +186,14 @@ server.initialize(err => { // server stopping may now return a promise server.stop() .then(() => { - console.log('Stopped!'); + console.log("Stopped!"); }); // decorate can take an optional options argument -server.decorate('hello', 'world', () => { +server.decorate("hello", "world", () => { }, { - apply: true + apply: true, }); -server.decorate('hello2', 'world2', () => { +server.decorate("hello2", "world2", () => { }); diff --git a/types/hapi/v15/index.d.ts b/types/hapi/v15/index.d.ts index f498df8fb16071..f91ee37ba47830 100644 --- a/types/hapi/v15/index.d.ts +++ b/types/hapi/v15/index.d.ts @@ -114,7 +114,11 @@ export interface IServerConnectionOptions extends IConnectionConfigurationServer /** - a string or string array of labels used to server.select() specific connections matching the specified labels.Defaults to an empty array [](no labels).*/ labels?: string | string[] | undefined; /** - used to create an HTTPS connection.The tls object is passed unchanged as options to the node.js HTTPS server as described in the node.js HTTPS documentation.Set to true when passing a listener object that has been configured to use TLS directly. */ - tls?: boolean | { key?: string | undefined; cert?: string | undefined; pfx?: string | undefined; } | Object | undefined; + tls?: + | boolean + | { key?: string | undefined; cert?: string | undefined; pfx?: string | undefined } + | Object + | undefined; } export interface IConnectionConfigurationServerDefaults { @@ -188,13 +192,20 @@ export interface IServerOptions { export interface IServerViewCompile { (template: string, options: any): void; - (template: string, options: any, callback: (err: any, compiled: (context: any, options: any, callback: (err: any, rendered: boolean) => void) => void) => void): void; + ( + template: string, + options: any, + callback: ( + err: any, + compiled: (context: any, options: any, callback: (err: any, rendered: boolean) => void) => void, + ) => void, + ): void; } export interface IServerViewsAdditionalOptions { /** path - the root file path used to resolve and load the templates identified when calling reply.view().Defaults to current working directory.*/ path?: string | undefined; - /**partialsPath - the root file path where partials are located.Partials are small segments of template code that can be nested and reused throughout other templates.Defaults to no partials support (empty path). + /** partialsPath - the root file path where partials are located.Partials are small segments of template code that can be nested and reused throughout other templates.Defaults to no partials support (empty path). */ partialsPath?: string | undefined; /**helpersPath - the directory path where helpers are located.Helpers are functions used within templates to perform transformations and other data manipulations using the template context or other inputs.Each '.js' file in the helpers directory is loaded and the file name is used as the helper name.The files must export a single method with the signature function(context) and return a string.Sub - folders are not supported and are ignored.Defaults to no helpers support (empty path).Note that jade does not support loading helpers this way.*/ @@ -229,11 +240,18 @@ export interface IServerViewsAdditionalOptions { } export interface IServerViewsEnginesOptions extends IServerViewsAdditionalOptions { - /**- the npm module used for rendering the templates.The module object must contain: "module", the rendering function. The required function signature depends on the compileMode settings. - * If the compileMode is 'sync', the signature is compile(template, options), the return value is a function with signature function(context, options), and the method is allowed to throw errors.If the compileMode is 'async', the signature is compile(template, options, callback) where callback has the signature function(err, compiled) where compiled is a function with signature function(context, options, callback) and callback has the signature function(err, rendered).*/ + /** - the npm module used for rendering the templates.The module object must contain: "module", the rendering function. The required function signature depends on the compileMode settings. + * If the compileMode is 'sync', the signature is compile(template, options), the return value is a function with signature function(context, options), and the method is allowed to throw errors.If the compileMode is 'async', the signature is compile(template, options, callback) where callback has the signature function(err, compiled) where compiled is a function with signature function(context, options, callback) and callback has the signature function(err, rendered). */ module: { compile?(template: any, options: any): (context: any, options: any) => void; - compile?(template: any, options: any, callback: (err: any, compiled: (context: any, options: any, callback: (err: any, rendered: any) => void) => void) => void): void; + compile?( + template: any, + options: any, + callback: ( + err: any, + compiled: (context: any, options: any, callback: (err: any, rendered: any) => void) => void, + ) => void, + ): void; }; } @@ -263,7 +281,8 @@ export interface IReplyMethods { continue(credentialData?: any): void; /** Transmits a file from the file system. The 'Content-Type' header defaults to the matching mime type based on filename extension. The response flow control rules do not apply. */ - file(/** the file path. */ + file( + /** the file path. */ path: string, /** optional settings: */ options?: { @@ -276,15 +295,18 @@ export interface IReplyMethods { mode?: boolean | string | undefined; /** if true, looks for the same filename with the '.gz' suffix for a pre-compressed version of the file to serve if the request supports content encoding. Defaults to false. */ lookupCompressed: boolean; - }): void; + }, + ): void; /** Concludes the handler activity by returning control over to the router with a templatized view response. the response flow control rules apply. */ - view(/** the template filename and path, relative to the templates path configured via the server views manager. */ + view( + /** the template filename and path, relative to the templates path configured via the server views manager. */ template: string, /** optional object used by the template to render context-specific result. Defaults to no context {}. */ context?: {}, /** optional object used to override the server's views manager configuration for this response. Cannot override isCached, partialsPath, or helpersPath which are only loaded at initialization. */ - options?: any): Response; + options?: any, + ): Response; /** Sets a header on the response */ header(name: string, value: string, options?: IHeaderOptions): Response; @@ -297,8 +319,10 @@ export interface IReplyMethods { /** Proxies the request to an upstream endpoint. the response flow control rules do not apply. */ - proxy(/** an object including the same keys and restrictions defined by the route proxy handler options. */ - options: IProxyHandlerConfig): void; + proxy( + /** an object including the same keys and restrictions defined by the route proxy handler options. */ + options: IProxyHandlerConfig, + ): void; /** Redirects the client to the specified uri. Same as calling reply().redirect(uri). * The response flow control rules apply. */ redirect(uri: string): ResponseRedirect; @@ -324,7 +348,8 @@ export interface IReply extends IReplyMethods { err: Error, result?: string | number | boolean | Buffer | stream.Stream | Promise | T, /** Note that when used to return both an error and credentials in the authentication methods, reply() must be called with three arguments function(err, null, data) where data is the additional authentication information. */ - credentialData?: any): IBoom; + credentialData?: any, + ): IBoom; /** Note that if result is a Stream with a statusCode property, that status code will be used as the default response code. */ (result: string | number | boolean | Buffer | stream.Stream | Promise | T): Response; } @@ -336,10 +361,12 @@ export interface IReply extends IReplyMethods { FLOW CONTROL: When calling reply(), the framework waits until process.nextTick() to continue processing the request and transmit the response. This enables making changes to the returned response object before the response is sent. This means the framework will resume as soon as the handler method exits. To suspend this behavior, the returned response object supports the following methods: hold(), send() */ export interface IStrictReply extends IReplyMethods { - (err: Error, + ( + err: Error, result?: Promise | T, /** Note that when used to return both an error and credentials in the authentication methods, reply() must be called with three arguments function(err, null, data) where data is the additional authentication information. */ - credentialData?: any): IBoom; + credentialData?: any, + ): IBoom; /** Note that if result is a Stream with a statusCode property, that status code will be used as the default response code. */ (result: Promise | T): Response; } @@ -399,7 +426,8 @@ export interface IProxyHandlerConfig { req: Request, reply: IReply, settings: IProxyHandlerConfig, - ttl: number): void; + ttl: number, + ): void; /** if set to 'upstream', applies the upstream response caching policy to the response using the response.ttl() method (or passed as an argument to the onResponse method if provided).*/ ttl?: number | undefined; /** - a node http(s) agent to be used for connections to upstream server. see https://nodejs.org/api/http.html#http_class_http_agent */ @@ -408,7 +436,7 @@ export interface IProxyHandlerConfig { maxSockets?: boolean | number | undefined; } /** TODO: fill in joi definition */ -export interface IJoi { } +export interface IJoi {} /** a validation function using the signature function(value, options, next) */ export interface IValidationFunction { @@ -418,19 +446,22 @@ export interface IValidationFunction { /** the server validation options. */ options: any, /** the callback function called when validation is completed. */ - next: (err: any, value: any) => void): void; + next: (err: any, value: any) => void, + ): void; } /** a custom error handler function with the signature 'function(request, reply, source, error)` */ export interface IRouteFailFunction { /** a custom error handler function with the signature 'function(request, reply, source, error)` */ - (/** - the [request object]. */ + ( + /** - the [request object]. */ request: Request, /** the continuation reply interface. */ reply: IReply, /** the source of the invalid field (e.g. 'path', 'query', 'payload'). */ source: string, /** the error object prepared for the client response (including the validation function error under error.data). */ - error: any): void; + error: any, + ): void; } /** Each route can be customize to change the default behavior of the request lifecycle using the following options: */ @@ -440,8 +471,7 @@ export interface IRouteAdditionalConfigurationOptions { /** authentication configuration.Value can be: false to disable authentication if a default strategy is set. a string with the name of an authentication strategy registered with server.auth.strategy(). an object */ - auth?: boolean | string | - { + auth?: boolean | string | { /** the authentication mode.Defaults to 'required' if a server authentication strategy is configured, otherwise defaults to no authentication.Available values: 'required'authentication is required. 'optional'authentication is optional (must be valid if present). @@ -499,7 +529,8 @@ export interface IRouteAdditionalConfigurationOptions { override?: boolean | undefined; } | undefined; /** defines the behavior for serving static resources using the built-in route handlers for files and directories: */ - files?: {/** determines the folder relative paths are resolved against when using the file and directory handlers. */ + files?: { + /** determines the folder relative paths are resolved against when using the file and directory handlers. */ relativeTo: string; } | undefined; @@ -679,20 +710,20 @@ export interface IRouteAdditionalConfigurationOptions { } | undefined; /** ONLY WHEN ADDING NEW ROUTES (not when setting defaults). - *route description used for generating documentation (string). + * route description used for generating documentation (string). */ description?: string | undefined; /** ONLY WHEN ADDING NEW ROUTES (not when setting defaults). - *route notes used for generating documentation (string or array of strings). + * route notes used for generating documentation (string or array of strings). */ notes?: string | string[] | undefined; /** ONLY WHEN ADDING NEW ROUTES (not when setting defaults). - *route tags used for generating documentation (array of strings). + * route tags used for generating documentation (array of strings). */ tags?: string[] | undefined; /** Enable logging of routes - */ + */ log?: boolean | undefined; } @@ -718,23 +749,25 @@ export interface IRouteAdditionalConfigurationAuthAccess { entity?: string | undefined; } -export type IRouteAdditionalConfigurationCache = { - /** determines the privacy flag included in clientside caching using the 'Cache-Control' header. Values are: +export type IRouteAdditionalConfigurationCache = + & { + /** determines the privacy flag included in clientside caching using the 'Cache-Control' header. Values are: 'Default': no privacy flag.This is the default setting. 'public': mark the response as suitable for public caching. 'private': mark the response as suitable only for private caching. */ - privacy?: 'default' | 'public' | 'private' | undefined; - /** an array of HTTP response status codes (e.g. 200) which are allowed to include a valid caching directive. Defaults to [200]. */ - statuses?: number[] | undefined; - /** a string with the value of the 'Cache-Control' header when caching is disabled. Defaults to 'no-cache'. */ - otherwise?: string | undefined; -} & ({ - /** relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */ - expiresIn: number; -} | { - /** time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. */ - expiresAt: string; -} | {}); + privacy?: "default" | "public" | "private" | undefined; + /** an array of HTTP response status codes (e.g. 200) which are allowed to include a valid caching directive. Defaults to [200]. */ + statuses?: number[] | undefined; + /** a string with the value of the 'Cache-Control' header when caching is disabled. Defaults to 'no-cache'. */ + otherwise?: string | undefined; + } + & ({ + /** relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */ + expiresIn: number; + } | { + /** time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. */ + expiresAt: string; + } | {}); /** server.realm http://hapijs.com/api#serverrealm The realm object contains server-wide or plugin-specific state that can be shared across various methods. For example, when calling server.bind(), @@ -782,7 +815,7 @@ export interface IServerState { /** - sets the 'Secure' flag.Defaults to false.*/ isSecure: boolean; /** - sets the 'HttpOnly' flag.Defaults to false.*/ - isHttpOnly: boolean + isHttpOnly: boolean; /** - the path scope.Defaults to null (no path).*/ path: any; /** - the domain scope.Defaults to null (no domain). */ @@ -872,7 +905,7 @@ export interface IRouteHandlerConfig { params: any; query: any; pre: any; - } + }; } | undefined; config?: { handler: any; @@ -934,7 +967,7 @@ export interface IRouteConfiguration { /** - (required) the absolute path used to match incoming requests (must begin with '/'). Incoming requests are compared to the configured paths based on the connection router configuration option.The path can include named parameters enclosed in {} which will be matched against literal values in the request as described in Path parameters.*/ path: string; /** - (required) the HTTP method.Typically one of 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', or 'OPTIONS'.Any HTTP method is allowed, except for 'HEAD'.Use '*' to match against any HTTP method (only when an exact match was not found, and any match with a specific method will be given a higher priority over a wildcard match). - * Can be assigned an array of methods which has the same result as adding the same route with different methods manually.*/ + * Can be assigned an array of methods which has the same result as adding the same route with different methods manually. */ method: string | string[]; /** - an optional domain string or an array of domain strings for limiting the route to only requests with a matching host header field.Matching is done against the hostname part of the header only (excluding the port).Defaults to all hosts.*/ vhost?: string | undefined; @@ -1030,7 +1063,7 @@ export interface IServerInjectResponse { rawPayload: Buffer; raw: { req: http.IncomingMessage; - res: http.ServerResponse + res: http.ServerResponse; }; result: any; request: Request; @@ -1111,7 +1144,7 @@ export interface ICookieSettings { /** - an object used to calculate an HMAC for cookie integrity validation.This does not provide privacy, only a mean to verify that the cookie value was generated by the server.Redundant when 'iron' encoding is used.Options are: integrity - algorithm options.Defaults to require('iron').defaults.integrity. password - password used for HMAC key generation. */ - sign?: { integrity: any; password: string; } | undefined; + sign?: { integrity: any; password: string } | undefined; password?: string | undefined; iron?: any; ignoreErrors?: boolean | undefined; @@ -1215,7 +1248,8 @@ export class Request extends Events.EventEmitter { acceptEncoding: string; /** if CORS is enabled for the route, contains the following: */ cors: { - isOriginMatch: boolean; /** true if the request 'Origin' header matches the configured CORS restrictions. Set to false if no 'Origin' header is found or if it does not match. Note that this is only available after the 'onRequest' extension point as CORS is configured per-route and no routing decisions are made at that point in the request lifecycle. */ + isOriginMatch: + boolean; /** true if the request 'Origin' header matches the configured CORS restrictions. Set to false if no 'Origin' header is found or if it does not match. Note that this is only available after the 'onRequest' extension point as CORS is configured per-route and no routing decisions are made at that point in the request lifecycle. */ }; /** content of the HTTP 'Host' header (e.g. 'example.com:8080'). */ host: string; @@ -1361,12 +1395,14 @@ export class Request extends Events.EventEmitter { return reply(); }; */ - log(/** a string or an array of strings (e.g. ['error', 'database', 'read']) used to identify the event. Tags are used instead of log levels and provide a much more expressive mechanism for describing and filtering events.*/ + log( + /** a string or an array of strings (e.g. ['error', 'database', 'read']) used to identify the event. Tags are used instead of log levels and provide a much more expressive mechanism for describing and filtering events.*/ tags: string | string[], /** an optional message string or object with the application data being logged.*/ data?: any, /** an optional timestamp expressed in milliseconds. Defaults to Date.now() (now).*/ - timestamp?: number): void; + timestamp?: number, + ): void; /** request.getLog([tags], [internal]) @@ -1379,10 +1415,12 @@ export class Request extends Events.EventEmitter { request.getLog(['error'], true); request.getLog(false);*/ - getLog(/** is a single tag string or array of tag strings. If no tags specified, returns all events.*/ + getLog( + /** is a single tag string or array of tag strings. If no tags specified, returns all events.*/ tags?: string, /** filters the events to only those with a matching event.internal value. If true, only internal logs are included. If false, only user event are included. Defaults to all events (undefined).*/ - internal?: boolean): string[]; + internal?: boolean, + ): string[]; /** request.tail([name]) @@ -1419,8 +1457,10 @@ export class Request extends Events.EventEmitter { console.log('Request completed including db activity'); });*/ - tail(/** an optional tail name used for logging purposes.*/ - name?: string): Function; + tail( + /** an optional tail name used for logging purposes.*/ + name?: string, + ): Function; } /** Response events @@ -1512,7 +1552,8 @@ export class Response extends Events.EventEmitter { weak - if true, the tag will be prefixed with the 'W/' weak signifier. Weak tags will fail to match identical tags for the purpose of determining 304 response status. Defaults to false. vary - if true and content encoding is set or applied to the response (e.g 'gzip' or 'deflate'), the encoding name will be automatically added to the tag at transmission time (separated by a '-' character). Ignored when weak is true. Defaults to true.*/ etag(tag: string, options: { - weak: boolean; vary: boolean; + weak: boolean; + vary: boolean; }): Response; /**header(name, value, options) - sets an HTTP header where: @@ -1621,7 +1662,7 @@ export interface IServerConnectionInfo { */ export class ServerConnection extends Events.EventEmitter { domain: any; - _events: { route: Function, domain: Function, _events: Function, _eventsCount: Function, _maxListeners: Function }; + _events: { route: Function; domain: Function; _events: Function; _eventsCount: Function; _maxListeners: Function }; _eventsCount: number; settings: IServerConnectionOptions; server: Server; @@ -1636,9 +1677,11 @@ export class ServerConnection extends Events.EventEmitter { _requestCounter: { value: number; min: number; max: number }; _load: any; states: { - settings: any; cookies: any; names: any[] + settings: any; + cookies: any; + names: any[]; }; - auth: { connection: ServerConnection; _schemes: any; _strategies: any; settings: any; api: any; }; + auth: { connection: ServerConnection; _schemes: any; _strategies: any; settings: any; api: any }; _router: any; MSPluginsCollection: any; applicationCache: any; @@ -1646,7 +1689,14 @@ export class ServerConnection extends Events.EventEmitter { info: IServerConnectionInfo; } -export type RequestExtPoints = "onRequest" | "onPreResponse" | "onPreAuth" | "onPostAuth" | "onPreHandler" | "onPostHandler" | "onPreResponse"; +export type RequestExtPoints = + | "onRequest" + | "onPreResponse" + | "onPreAuth" + | "onPostAuth" + | "onPreHandler" + | "onPostHandler" + | "onPreResponse"; export type ServerExtPoints = "onPreStart" | "onPostStart" | "onPreStop" | "onPostStop"; /** Server http://hapijs.com/api#server @@ -1844,7 +1894,7 @@ export class Server extends Events.EventEmitter { */ api: { [index: string]: any; - } + }; /** server.auth.default(options) Sets a default strategy which is applied to every route where: options - a string with the default strategy name or an object with a specified strategy or strategies using the same format as the route auth handler options. @@ -1891,7 +1941,8 @@ export class Server extends Events.EventEmitter { * }; * }; */ - scheme: (server: Server, options: any) => IServerAuthScheme): void; + scheme: (server: Server, options: any) => IServerAuthScheme, + ): void; /** * server.auth.strategy(name, scheme, [mode], [options]) @@ -2085,9 +2136,21 @@ export class Server extends Events.EventEmitter { server.route({ method: 'GET', path: '/test', handler: handler }); server.start(); // All requests will get routed to '/test'*/ - ext(event: RequestExtPoints, method: (request: Request, reply: IReply, bind?: any) => void, options?: { before: string | string[]; after: string | string[]; bind?: any }): void; - ext(event: RequestExtPoints, method: (request: Request, reply: IStrictReply, bind?: any) => void, options?: { before: string | string[]; after: string | string[]; bind?: any }): void; - ext(event: ServerExtPoints, method: (server: Server, next: (err?: any) => void, bind?: any) => void, options?: { before: string | string[]; after: string | string[]; bind?: any }): void; + ext( + event: RequestExtPoints, + method: (request: Request, reply: IReply, bind?: any) => void, + options?: { before: string | string[]; after: string | string[]; bind?: any }, + ): void; + ext( + event: RequestExtPoints, + method: (request: Request, reply: IStrictReply, bind?: any) => void, + options?: { before: string | string[]; after: string | string[]; bind?: any }, + ): void; + ext( + event: ServerExtPoints, + method: (server: Server, next: (err?: any) => void, bind?: any) => void, + options?: { before: string | string[]; after: string | string[]; bind?: any }, + ): void; /** server.handler(name, method) Registers a new handler type to be used in routes where: @@ -2258,10 +2321,12 @@ export class Server extends Events.EventEmitter { server.methods.sumSync(4, 5, function (err, result) { console.log(result); }); */ - method(/** a unique method name used to invoke the method via server.methods[name]. When configured with caching enabled, server.methods[name].cache.drop(arg1, arg2, ..., argn, callback) can be used to clear the cache for a given key. Supports using nested names such as utils.users.get which will automatically create the missing path under server.methods and can be accessed for the previous example via server.methods.utils.users.get.*/ + method( + /** a unique method name used to invoke the method via server.methods[name]. When configured with caching enabled, server.methods[name].cache.drop(arg1, arg2, ..., argn, callback) can be used to clear the cache for a given key. Supports using nested names such as utils.users.get which will automatically create the missing path under server.methods and can be accessed for the previous example via server.methods.utils.users.get.*/ name: string, method: IServerMethod, - options?: IServerMethodOptions): void; + options?: IServerMethodOptions, + ): void; /**server.method(methods) Registers a server method function as described in server.method() using a configuration object where: @@ -2281,11 +2346,19 @@ export class Server extends Events.EventEmitter { } } });*/ - method(methods: { - name: string; method: IServerMethod; options?: IServerMethodOptions | undefined - } | Array<{ - name: string; method: IServerMethod; options?: IServerMethodOptions | undefined - }>): void; + method( + methods: + | { + name: string; + method: IServerMethod; + options?: IServerMethodOptions | undefined; + } + | Array<{ + name: string; + method: IServerMethod; + options?: IServerMethodOptions | undefined; + }>, + ): void; /**server.path(relativeTo) Sets the path prefix used to locate static resources (files and view templates) when relative paths are used where: @@ -2321,18 +2394,22 @@ export class Server extends Events.EventEmitter { options: { select?: string | string[] | undefined; routes: { - prefix: string; vhost?: string | string[] | undefined + prefix: string; + vhost?: string | string[] | undefined; }; }, - callback: (err: any) => void): void; + callback: (err: any) => void, + ): void; register( plugins: any | any[], options: { select?: string | string[] | undefined; routes: { - prefix: string; vhost?: string | string[] | undefined + prefix: string; + vhost?: string | string[] | undefined; }; - }): Promise; + }, + ): Promise; register(plugins: any | any[], callback: (err: any) => void): void; register(plugins: any | any[]): Promise; @@ -2360,7 +2437,12 @@ export class Server extends Events.EventEmitter { server.render('hello', context, function (err, rendered, config) { console.log(rendered); });*/ - render(template: string, context: any, options: any, callback: (err: any, rendered: any, config: any) => void): void; + render( + template: string, + context: any, + options: any, + callback: (err: any, rendered: any, config: any) => void, + ): void; /** server.route(options) Adds a connection route where: diff --git a/types/hapi/v16/index.d.ts b/types/hapi/v16/index.d.ts index 5e967bffe76a8e..9fc467676acebd 100644 --- a/types/hapi/v16/index.d.ts +++ b/types/hapi/v16/index.d.ts @@ -32,19 +32,15 @@ import url = require("url"); import zlib = require("zlib"); import domain = require("domain"); -import * as Boom from 'boom'; -import { - ValidationOptions as JoiValidationOptions, - SchemaMap as JoiSchemaMap, - Schema as JoiSchema, -} from 'joi'; +import * as Boom from "boom"; +import { Schema as JoiSchema, SchemaMap as JoiSchemaMap, ValidationOptions as JoiValidationOptions } from "joi"; // TODO check JoiValidationObject is correct for "a Joi validation object" type JoiValidationObject = JoiSchema | JoiSchemaMap | (JoiSchema | JoiSchemaMap)[]; -import * as Catbox from 'catbox'; -import { MimosOptions } from 'mimos'; -import Podium = require('podium'); -import * as Shot from 'shot'; +import * as Catbox from "catbox"; +import { MimosOptions } from "mimos"; +import Podium = require("podium"); +import * as Shot from "shot"; export interface Dictionary { [key: string]: T; @@ -109,7 +105,7 @@ export class Server extends Podium { * Provides access to the server MIME database used for setting content-type information. The object must not be modified directly but only through the mime server setting. * [See docs](https://hapijs.com/api/16.1.1#servermime) */ - readonly mime: {path(path: string): {type: string}}; + readonly mime: { path(path: string): { type: string } }; /** * An object containing the values exposed by each plugin registered where each key is a plugin name and the values are the exposed properties by each plugin using server.expose(). Plugins may set the value of the server.plugins[name] object directly or via the server.expose() method. * [See docs](https://hapijs.com/api/16.1.1#serverplugins) @@ -183,7 +179,7 @@ export class Server extends Podium { * @param encoding the decoder name string. * @param decoder a function using the signature function(options) where options are the encoding specific options configured in the route payload.compression configuration option, and the return value is an object compatible with the output of node's zlib.createGunzip(). */ - decoder(encoding: string, decoder: ((options: CompressionDecoderSettings) => zlib.Gunzip)): void; + decoder(encoding: string, decoder: (options: CompressionDecoderSettings) => zlib.Gunzip): void; /** * Extends various framework interfaces with custom methods * Note that decorations apply to the entire server and all its connections regardless of current selection. @@ -205,9 +201,9 @@ export class Server extends Podium { * @param options if the type is 'request', supports the following optional settings: * * apply - if true, the method function is invoked using the signature function(request) where request is the current request object and the returned value is assigned as the decoration. */ - decorate(type: 'request' | 'reply' | 'server', property: string, method: Function): void; - decorate(type: 'request', property: string, method: Function, options?: {apply: false}): void; - decorate(type: 'request', property: string, method: (request: Request) => Function, options: {apply: true}): void; + decorate(type: "request" | "reply" | "server", property: string, method: Function): void; + decorate(type: "request", property: string, method: Function, options?: { apply: false }): void; + decorate(type: "request", property: string, method: (request: Request) => Function, options: { apply: true }): void; /** * The server.decorate('server', ...) method can modify this prototype/interface. * Have disabled these typings as there is a better alternative, see example in: tests/server/decorate.ts @@ -234,14 +230,18 @@ export class Server extends Podium { * @param data the value emitted to the subscribers. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. If no listeners match the event, the data function is not invoked. * @param callback an optional callback method invoked when all subscribers have been notified using the signature function(). The callback is called only after all the listeners have been notified, including any event updates emitted earlier (the order of event updates are guaranteed to be in the order they were emitted). */ - emit(criteria: string | {name: string, channel?: string | undefined, tags?: string | string[] | undefined}, data: any, callback?: () => void): void; + emit( + criteria: string | { name: string; channel?: string | undefined; tags?: string | string[] | undefined }, + data: any, + callback?: () => void, + ): void; /** * Registers a custom content encoding compressor to extend the built-in support for 'gzip' and 'deflate' * [See docs](https://hapijs.com/api/16.1.1#serverencoderencoding-encoder) * @param encoding the encoder name string. * @param encoder a function using the signature function(options) where options are the encoding specific options configured in the route compression configuration option, and the return value is an object compatible with the output of node's zlib.createGzip(). */ - encoder(encoding: string, encoder: ((options: CompressionEncoderSettings) => zlib.Gzip)): void; + encoder(encoding: string, encoder: (options: CompressionEncoderSettings) => zlib.Gzip): void; /** * Register custom application events * [See docs](https://hapijs.com/api/16.1.1#servereventevents) @@ -310,7 +310,7 @@ export class Server extends Podium { * @param callback the callback function with signature function(res) */ inject(options: string | InjectedRequestOptions, callback: (res: InjectedResponseObject) => void): void; - inject(options: string | InjectedRequestOptions, ): Promise; + inject(options: string | InjectedRequestOptions): Promise; /** * Logs server events that cannot be associated with a specific request. When called the server emits a 'log' event which can be used by other listeners or plugins to record the information or output to the console. * [See docs](https://hapijs.com/api/16.1.1#serverlogtags-data-timestamp) @@ -360,12 +360,12 @@ export class Server extends Podium { * If 'stop' - emitted when the server is stopped using server.stop(). * @param listener */ - on(criteria: 'start' | 'stop' | string | ServerEventCriteria, listener: Function): void; + on(criteria: "start" | "stop" | string | ServerEventCriteria, listener: Function): void; /** * The 'log' event includes the event object and a tags object (where each tag is a key with the value true) * [See docs](https://hapijs.com/api/16.1.1#server-events) */ - on(criteria: 'log', listener: (event: ServerEventObject, tags: Podium.Tags) => void): void; + on(criteria: "log", listener: (event: ServerEventObject, tags: Podium.Tags) => void): void; /** * The 'request' and 'request-internal' events include the request object, the event object, and a tags object (where each tag is a key with the value true) * [See docs](https://hapijs.com/api/16.1.1#server-events) @@ -373,25 +373,31 @@ export class Server extends Podium { * interference when using code like: `server.on('request', (request, event, tags) => {...}` * Same for 'response' | 'tail'. */ - on(criteria: 'request', listener: (request: Request, event: ServerEventObject, tags: Podium.Tags) => void): void; - on(criteria: 'request-internal', listener: (request: Request, event: ServerEventObject, tags: Podium.Tags) => void): void; + on(criteria: "request", listener: (request: Request, event: ServerEventObject, tags: Podium.Tags) => void): void; + on( + criteria: "request-internal", + listener: (request: Request, event: ServerEventObject, tags: Podium.Tags) => void, + ): void; /** * The 'request-error' event includes the request object and the causing error err object * [See docs](https://hapijs.com/api/16.1.1#server-events) */ - on(criteria: 'request-error', listener: (request: Request, err: Error) => void): void; + on(criteria: "request-error", listener: (request: Request, err: Error) => void): void; /** * The 'response' and 'tail' events include the request object * [See docs](https://hapijs.com/api/16.1.1#server-events) * See 'request' and 'request-internal' */ - on(criteria: 'response', listener: (request: Request) => void): void; - on(criteria: 'tail', listener: (request: Request) => void): void; + on(criteria: "response", listener: (request: Request) => void): void; + on(criteria: "tail", listener: (request: Request) => void): void; /** * The 'route' event includes the route public interface, the connection, and the server object used to add the route (e.g. the result of a plugin select operation) * [See docs](https://hapijs.com/api/16.1.1#server-events) */ - on(criteria: 'route', listener: (route: RoutePublicInterface, connection: ServerConnection, server: Server) => void): void; + on( + criteria: "route", + listener: (route: RoutePublicInterface, connection: ServerConnection, server: Server) => void, + ): void; /** * Same as calling server.on() with the count option set to 1. * TODO type this to copy the server.on specific types for 'route', 'tail', etc. @@ -422,14 +428,38 @@ export class Server extends Podium { * register(Plugin, {}, (err) => {// do more stuff}) or * register(Plugin, (err: Error) => {// do more stuff}) */ - register(plugins: Array<(PluginFunction | PluginRegistrationObject)>, callback: (err: Error | null) => void): void; - register(plugins: Array<(PluginFunction | PluginRegistrationObject)>): Promise; - register(plugins: PluginFunction | PluginRegistrationObject, callback: (err: Error | null) => void): void; - register(plugins: PluginFunction | PluginRegistrationObject): Promise; - register(plugins: Array<(PluginFunction | PluginRegistrationObject)>, options: PluginRegistrationOptions, callback: (err: Error | null) => void): void; - register(plugins: Array<(PluginFunction | PluginRegistrationObject)>, options: PluginRegistrationOptions): Promise; - register(plugins: PluginFunction | PluginRegistrationObject, options: PluginRegistrationOptions, callback: (err: Error | null) => void): void; - register(plugins: PluginFunction | PluginRegistrationObject, options: PluginRegistrationOptions): Promise; + register( + plugins: Array<(PluginFunction | PluginRegistrationObject)>, + callback: (err: Error | null) => void, + ): void; + register( + plugins: Array<(PluginFunction | PluginRegistrationObject)>, + ): Promise; + register( + plugins: PluginFunction | PluginRegistrationObject, + callback: (err: Error | null) => void, + ): void; + register( + plugins: PluginFunction | PluginRegistrationObject, + ): Promise; + register( + plugins: Array<(PluginFunction | PluginRegistrationObject)>, + options: PluginRegistrationOptions, + callback: (err: Error | null) => void, + ): void; + register( + plugins: Array<(PluginFunction | PluginRegistrationObject)>, + options: PluginRegistrationOptions, + ): Promise; + register( + plugins: PluginFunction | PluginRegistrationObject, + options: PluginRegistrationOptions, + callback: (err: Error | null) => void, + ): void; + register( + plugins: PluginFunction | PluginRegistrationObject, + options: PluginRegistrationOptions, + ): Promise; /** * Adds a connection route * [See docs](https://hapijs.com/api/16.1.1#serverrouteoptions) @@ -471,8 +501,8 @@ export class Server extends Podium { * @param callback optional callback method which is called once all the connections have ended and it is safe to exit the process with signature function(err) where: * * err - any termination error condition. */ - stop(options: {timeout: number} | null, callback: (err?: Error) => void): void; - stop(options?: {timeout: number}): Promise; + stop(options: { timeout: number } | null, callback: (err?: Error) => void): void; + stop(options?: { timeout: number }): Promise; /** * Returns a copy of the routing table * Note that if the server has not been started and multiple connections use port 0, the table items will override each other and will produce an incomplete result. @@ -499,7 +529,11 @@ export interface ServerOptions { * * a CatboxServerOptionsCacheConfiguration configuration object * * an array of the above object for configuring multiple cache instances, each with a unique name. When an array of objects is provided, multiple cache connections are established and each array item (except one) must include a name. */ - cache?: Catbox.EnginePrototype | CatboxServerOptionsCacheConfiguration | CatboxServerOptionsCacheConfiguration[] | undefined; + cache?: + | Catbox.EnginePrototype + | CatboxServerOptionsCacheConfiguration + | CatboxServerOptionsCacheConfiguration[] + | undefined; /** sets the default connections configuration which can be overridden by each connection */ connections?: ConnectionConfigurationServerDefaults | undefined; /** determines which logged events are sent to the console (this should only be used for development and does not affect which events are actually logged internally and recorded). Set to false to disable all console logging, or to an object with: */ @@ -561,7 +595,7 @@ export interface ServerEventCriteria { * * tags - a tag string or array of tag strings. * * all - if true, all tags must be present for the event update to match the subscription. Defaults to false (at least one matching tag). */ - filter?: string | string[] | {tags: string | string[], all?: boolean | undefined} | undefined; + filter?: string | string[] | { tags: string | string[]; all?: boolean | undefined } | undefined; /** if true, and the data object passed to server.emit() is an array, the listener method is called with each array element passed as a separate argument. This should only be used when the emitted data structure is known and predictable. Defaults to the event registration option (which defaults to false). */ spread?: boolean | undefined; /** if true and the criteria object passed to server.emit() includes tags, the tags are mapped to an object (where each tag string is the key and the value is true) which is appended to the arguments list at the end (but before the callback argument if block is set). Defaults to the event registration option (which defaults to false). */ @@ -804,7 +838,7 @@ export interface AuthOptions { * * 'optional' - authentication is optional (must be valid if present). * * 'try' - same as 'optional' but allows for invalid authentication. */ - mode?: 'required' | 'optional' | 'try' | undefined; + mode?: "required" | "optional" | "try" | undefined; /** a string array of strategy names in order they should be attempted. If only one strategy is used, strategy can be used instead with the single string value. Defaults to the default authentication strategy which is available only when a single strategy is configured. */ strategies?: string[] | undefined; strategy?: string | undefined; @@ -814,13 +848,13 @@ export interface AuthOptions { * * 'required' - payload authentication required. This is the default value when the scheme sets options.payload to true. * * 'optional' - payload authentication performed only when the client includes payload authentication information (e.g. hash attribute in Hawk). */ - payload?: false | 'required' | 'optional' | undefined; + payload?: false | "required" | "optional" | undefined; /** specifying the route access rules. */ access?: RouteAuthAccessConfiguationObject | RouteAuthAccessConfiguationObject[] | undefined; /** (undocumented) Convenience way of setting access.scope, will over write all values in `access` */ scope?: false | string | string[] | undefined; /** (undocumented) Convenience way of setting access.entity, will over write all values in `access` */ - entity?: 'any' | 'user' | 'app' | undefined; + entity?: "any" | "user" | "app" | undefined; } /** @@ -836,47 +870,49 @@ export interface RouteAuthAccessConfiguationObject { * * user - the authentication must be on behalf of a user which is identified by the presence of a user attribute in the credentials object returned by the authentication strategy. * * app - the authentication must be on behalf of an application which is identified by the lack of presence of a user attribute in the credentials object returned by the authentication strategy. */ - entity?: 'any' | 'user' | 'app' | undefined; + entity?: "any" | "user" | "app" | undefined; } /** * For context see RouteAdditionalConfigurationOptions > cache */ -export type RouteCacheOptions = { - /** - * determines the privacy flag included in client-side caching using the 'Cache-Control' header. Values are: - * * 'default' - no privacy flag. This is the default setting. - * * 'public' - mark the response as suitable for public caching. - * * 'private' - mark the response as suitable only for private caching. - */ - privacy?: 'default' | 'public' | 'private' | undefined; - /** an array of HTTP response status codes (e.g. 200) which are allowed to include a valid caching directive. Defaults to [200]. */ - statuses?: number[] | undefined; - /** a string with the value of the 'Cache-Control' header when caching is disabled. Defaults to 'no-cache'. */ - otherwise?: string | undefined; -} & ({ - /** relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */ - expiresIn?: number | undefined; - /** time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. */ - expiresAt?: undefined; -} | { - /** relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */ - expiresIn?: undefined; - /** time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. */ - expiresAt?: string | undefined; -} | { - /** relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */ - expiresIn?: undefined; - /** time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. */ - expiresAt?: undefined; -}); +export type RouteCacheOptions = + & { + /** + * determines the privacy flag included in client-side caching using the 'Cache-Control' header. Values are: + * * 'default' - no privacy flag. This is the default setting. + * * 'public' - mark the response as suitable for public caching. + * * 'private' - mark the response as suitable only for private caching. + */ + privacy?: "default" | "public" | "private" | undefined; + /** an array of HTTP response status codes (e.g. 200) which are allowed to include a valid caching directive. Defaults to [200]. */ + statuses?: number[] | undefined; + /** a string with the value of the 'Cache-Control' header when caching is disabled. Defaults to 'no-cache'. */ + otherwise?: string | undefined; + } + & ({ + /** relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */ + expiresIn?: number | undefined; + /** time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. */ + expiresAt?: undefined; + } | { + /** relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */ + expiresIn?: undefined; + /** time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. */ + expiresAt?: string | undefined; + } | { + /** relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */ + expiresIn?: undefined; + /** time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. */ + expiresAt?: undefined; + }); /** * For context see RouteAdditionalConfigurationOptions > cors */ export interface CorsConfigurationObject { /** a strings array of allowed origin servers ('Access-Control-Allow-Origin'). The array can contain any combination of fully qualified origins along with origin strings containing a wildcard '*' character, or a single '*' origin string. Defaults to any origin ['*']. */ - origin?: string[] | '*' | undefined; + origin?: string[] | "*" | undefined; /** number of seconds the browser should cache the CORS response ('Access-Control-Max-Age'). The greater the value, the longer it will take before the browser checks for changes in policy. Defaults to 86400 (one day). */ maxAge?: number | undefined; /** a strings array of allowed headers ('Access-Control-Allow-Headers'). Defaults to ['Accept', 'Authorization', 'Content-Type', 'If-None-Match'] */ @@ -917,7 +953,7 @@ export interface ServerRequestExtConfigurationObject { /** * a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is see ServerExtFunction or see ServerExtRequestHandler */ - method: ServerExtRequestHandler | ServerExtRequestHandler[] + method: ServerExtRequestHandler | ServerExtRequestHandler[]; options?: ServerExtOptions | undefined; } @@ -957,7 +993,7 @@ export interface ServerExtOptions { /** bind - a context object passed back to the provided method (via this) when called. Ignored if the method is an arrow function. */ bind: any; /** sandbox - if set to 'plugin' when adding a request extension points the extension is only added to routes defined by the current plugin. Not allowed when configuring route-level extensions, or when adding server extensions. Defaults to 'connection' which applies to any route added to the connection the extension is added to. */ - sandbox?: 'connection' | 'plugin' | undefined; + sandbox?: "connection" | "plugin" | undefined; } /** @@ -967,14 +1003,20 @@ export interface ServerExtOptions { * * 'onPreStop' - called before the connection listeners are stopped. * * 'onPostStop' - called after the connection listeners are stopped. */ -export type ServerStartExtPoints = 'onPreStart' | 'onPostStart' | 'onPreStop' | 'onPostStop'; +export type ServerStartExtPoints = "onPreStart" | "onPostStart" | "onPreStop" | "onPostStop"; /** * [See docs](https://hapijs.com/api/16.1.1#request-lifecycle) * * The available extension points include the request extension points as well as the following server extension points: */ -export type ServerRequestExtPointsBase = 'onPreResponse' | 'onPreAuth' | 'onPostAuth' | 'onPreHandler' | 'onPostHandler' | 'onPreResponse'; +export type ServerRequestExtPointsBase = + | "onPreResponse" + | "onPreAuth" + | "onPostAuth" + | "onPreHandler" + | "onPostHandler" + | "onPreResponse"; -export type ServerRequestExtPoints = ServerRequestExtPointsBase | 'onRequest'; +export type ServerRequestExtPoints = ServerRequestExtPointsBase | "onRequest"; /** * Server extension function registered an one of the server extension points @@ -1007,7 +1049,7 @@ export interface RoutePayloadConfigurationObject { * * 'text/*' * * 'multipart/form-data' */ - parse?: 'gunzip' | boolean | undefined; + parse?: "gunzip" | boolean | undefined; /** * overrides payload processing for multipart requests. Value can be one of: * * false - disables multipart processing. @@ -1019,7 +1061,7 @@ export interface RoutePayloadConfigurationObject { * * payload - the processed part payload. */ multipart?: false | { - output: PayLoadOutputOption | 'annotated'; + output: PayLoadOutputOption | "annotated"; } | undefined; /** a string or an array of strings with the allowed mime types for the endpoint. Defaults to any of the supported mime types listed above. Note that allowing other mime types not listed will not enable them to be parsed, and that if parsing mode is 'parse', the request will result in an error response. */ allow?: string | string[] | undefined; @@ -1037,14 +1079,14 @@ export interface RoutePayloadConfigurationObject { * * 'log' - report the error but continue processing the request. * * 'ignore' - take no action and continue processing the request. */ - failAction?: 'error' | 'log' | 'ignore' | undefined; + failAction?: "error" | "log" | "ignore" | undefined; /** the default 'Content-Type' HTTP header value is not present. Defaults to 'application/json'. */ defaultContentType?: string | undefined; /** an object where each key is a content-encoding name and each value is an object with the desired decoder settings. Note that encoder settings are set in the root option compression. */ compression?: Dictionary | undefined; } -export type PayLoadOutputOption = 'data' | 'stream' | 'file'; +export type PayLoadOutputOption = "data" | "stream" | "file"; /** * events must be one of: @@ -1098,13 +1140,16 @@ export interface RouteConfiguration { /** the absolute path used to match incoming requests (must begin with '/'). Incoming requests are compared to the configured paths based on the connection router configuration option. The path can include named parameters enclosed in {} which will be matched against literal values in the request as described in Path parameters. */ path: string; /** the HTTP method. Typically one of 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', or 'OPTIONS'. Any HTTP method is allowed, except for 'HEAD'. Use '*' to match against any HTTP method (only when an exact match was not found, and any match with a specific method will be given a higher priority over a wildcard match). Can be assigned an array of methods which has the same result as adding the same route with different methods manually. */ - method: HTTP_METHODS_PARTIAL | '*' | (HTTP_METHODS_PARTIAL | '*')[]; + method: HTTP_METHODS_PARTIAL | "*" | (HTTP_METHODS_PARTIAL | "*")[]; /** an optional domain string or an array of domain strings for limiting the route to only requests with a matching host header field. Matching is done against the hostname part of the header only (excluding the port). Defaults to all hosts. */ vhost?: string | undefined; /** the function called to generate the response after successful authentication and validation. The handler function is described in Route handler. If set to a string, the value is parsed the same way a prerequisite server method string shortcut is processed. Alternatively, handler can be assigned an object with a single key using the name of a registered handler type and value with the options passed to the registered handler. */ handler?: string | RouteHandler | RouteHandlerPlugins | undefined; /** additional route options. The config value can be an object or a function that returns an object using the signature function(server) where server is the server the route is being added to and this is bound to the current realm's bind option. */ - config?: RouteAdditionalConfigurationOptions | ((server: Server) => RouteAdditionalConfigurationOptions) | undefined; + config?: + | RouteAdditionalConfigurationOptions + | ((server: Server) => RouteAdditionalConfigurationOptions) + | undefined; } /** @@ -1148,10 +1193,12 @@ export interface RouteAdditionalConfigurationOptions { /** if true, the route cannot be accessed through the HTTP connection but only through the server.inject() interface with the allowInternals option set to true. Used for internal routes that should not be accessible to the outside world. Defaults to false. */ isInternal?: boolean | undefined; /** optional arguments passed to JSON.stringify() when converting an object or error response to a string payload. Supports the following: */ - json?: Json.StringifyArguments & { - /** string suffix added after conversion to JSON string. Defaults to no suffix. */ - suffix?: string | undefined; - } | undefined; + json?: + | Json.StringifyArguments & { + /** string suffix added after conversion to JSON string. Defaults to no suffix. */ + suffix?: string | undefined; + } + | undefined; /** enables JSONP support by setting the value to the query parameter name containing the function name used to wrap the response payload. For example, if the value is 'callback', a request comes in with 'callback=me', and the JSON response is '{ "a":"b" }', the payload will be 'me({ "a":"b" });'. Does not work with stream responses. Headers content-type and x-content-type-options are set to text/javascript and nosniff respectively, and will override those headers even if explicitly set by response.type() */ jsonp?: string | undefined; /** if true, request level logging is enabled (accessible via request.getLog()). */ @@ -1179,7 +1226,7 @@ export interface RouteAdditionalConfigurationOptions { * * 'log' - report the error but continue processing the request. * * 'ignore' - take no action. */ - failAction: 'error' | 'log' | 'ignore'; + failAction: "error" | "log" | "ignore"; } | undefined; /** request input validation rules for various request components. When using a Joi validation object, the values of the other inputs (i.e. headers, query, params, payload, and auth) are made available under the validation context (accessible in rules as Joi.ref('$query.key')). Note that validation is performed in order (i.e. headers, params, query, payload) and if type casting is used (converting a string to number), the value of inputs not yet validated will reflect the raw, unvalidated and unmodified values. If the validation rules for headers, params, query, and payload are defined at both the routes defaults level and an individual route, the individual route settings override the routes defaults (the rules are not merged). The validate object supports: */ validate?: RouteValidationConfigurationObject | undefined; @@ -1324,7 +1371,7 @@ export interface RoutePrerequisiteObjects { * * 'log' - logs the error but continues processing the request. If assign is used, the error will be assigned. * * 'ignore' - takes no special action. If assign is used, the error will be assigned. */ - failAction?: 'error' | 'log' | 'ignore' | undefined; + failAction?: "error" | "log" | "ignore" | undefined; } /** @@ -1343,7 +1390,11 @@ export interface RouteResponseConfigurationObject void) | undefined; + failAction?: + | "error" + | "log" + | ((request: Request, reply: ReplyWithContinue, source: string, error: Boom.BoomError) => void) + | undefined; /** if true, applies the validation rule changes to the response payload. Defaults to false. */ modify?: boolean | undefined; /** @@ -1375,7 +1426,10 @@ export interface RouteResponseConfigurationObject response > status */ -export type RouteResponseConfigurationScheme = boolean | JoiValidationObject | ValidationFunctionForRouteResponse; +export type RouteResponseConfigurationScheme = + | boolean + | JoiValidationObject + | ValidationFunctionForRouteResponse; /** * see RouteResponseConfigurationScheme @@ -1414,7 +1468,7 @@ export interface RouteResponseValidationContext { /** the credential object received during the authentication process. The presence of an object does not mean successful authentication. */ credentials: AuthenticatedCredentials; }; - } + }; } /** @@ -1431,9 +1485,9 @@ export interface RouteSecurityConfigurationObject { preload?: boolean | undefined; } | undefined; /** controls the 'X-Frame-Options' header. When set to true the header will be set to DENY, you may also specify a string value of 'deny' or 'sameorigin'. Defaults to true. To use the 'allow-from' rule, you must set this to an object with the following fields: */ - xframe?: true | 'deny' | 'sameorigin' | { + xframe?: true | "deny" | "sameorigin" | { /** may also be 'deny' or 'sameorigin' but set directly as a string for xframe */ - rule: 'allow-from'; + rule: "allow-from"; /** when rule is 'allow-from' this is used to form the rest of the header, otherwise this field is ignored. If rule is 'allow-from' but source is unset, the rule will be automatically changed to 'sameorigin'. */ source: string; } | undefined; @@ -1487,7 +1541,7 @@ export interface RouteValidationConfigurationObject void): void; - inject(options: string | InjectedRequestOptions, ): Promise; + inject(options: string | InjectedRequestOptions): Promise; /** Mentioned but not documented under server.connections [See docs](https://hapijs.com/api/16.1.1#serverconnections) */ table(host?: string): Route[]; /** Described in server.table [See docs](https://hapijs.com/api/16.1.1#serverlookupid) */ @@ -1668,7 +1722,7 @@ export interface ServerConnectionInfo { /** the active IP address the connection was bound to after starting. Set to undefined until the server has been started or when using a non TCP port (e.g. UNIX domain socket). */ address: undefined | string; /** the protocol used. 'socket' when UNIX domain socket or Windows named pipe. */ - protocol: 'http' | 'https' | 'socket'; + protocol: "http" | "https" | "socket"; /** a string representing the connection (e.g. 'http://example.com:8080' or 'socket:/unix/domain/socket/path'). Contains the uri setting if provided, otherwise constructed from the available settings. If no port is available or set to 0, the uri will not include a port component. */ uri: string; } @@ -1692,12 +1746,12 @@ export interface ServerRealm { prefix: string; /** the route virtual host settings used by any calls to server.route() from the server. */ vhost: string; - } + }; }; /** the active plugin name (empty string if at the server root). */ plugin: string; /** the plugin options object passed at registration. */ - pluginOptions: any; // OptionsPassedToPlugin; + pluginOptions: any; // OptionsPassedToPlugin; /** plugin-specific state to be shared only among activities sharing the same active state. plugins is an object where each key is a plugin name and the value is the plugin state. */ plugins: PluginsStates; /** settings overrides (from RouteAdditionalConfigurationOptions) */ @@ -1728,7 +1782,7 @@ export interface ServerRegisteredPlugin { * options used to register the plugin. * TODO update with outcome of: https://github.com/hapijs/hapi/pull/3479 */ - options: any; // OptionsPassedToPlugin; + options: any; // OptionsPassedToPlugin; /** plugin registration attributes. */ attributes: PluginAttributes; } @@ -1767,7 +1821,7 @@ export interface ServerAuth { * @param options scheme options based on the scheme requirements. */ strategy(name: string, scheme: string, options?: any): void; - strategy(name: string, scheme: string, mode: boolean | 'required' | 'optional' | 'try', options?: any): void; + strategy(name: string, scheme: string, mode: boolean | "required" | "optional" | "try", options?: any): void; /** * Tests a request against an authentication strategy * Note that the test() method does not take into account the route authentication configuration. It also does not perform payload authentication. It is limited to the basic strategy authentication execution. It does not include verifying scope, entity, or other route properties. @@ -1778,7 +1832,11 @@ export interface ServerAuth { * * err - the error if authentication failed. * * credentials - the authentication credentials object if authentication was successful. */ - test(strategy: string, request: Request, next: (err: Error | null, credentials: AuthenticatedCredentials) => void): void; + test( + strategy: string, + request: Request, + next: (err: Error | null, credentials: AuthenticatedCredentials) => void, + ): void; } export type Strategy = any; @@ -1985,7 +2043,10 @@ export class Request extends Podium { * @param source the object to set as the source of the reply interface. TODO, submit a PR to clarify this doc, from the source code it's clear that "the object to set" refers to something of type `ReplyValue` i.e. that can be null, string, number, object, Stream, Promise, or Buffer. * @param options options for the method, optional. Not documented yet, perhaps not very important. */ - generateResponse(source?: ReplyValue, options?: {marshal?: any; prepare?: any; close?: any; variety?: any}): Response; + generateResponse( + source?: ReplyValue, + options?: { marshal?: any; prepare?: any; close?: any; variety?: any }, + ): Response; /** * request.log(tags, [data, [timestamp]]) * Always available. @@ -2018,7 +2079,7 @@ export class Request extends Podium { * [See docs](https://hapijs.com/api/16.1.1#requesttailname) * @param name an optional tail name used for logging purposes. */ - tail(name?: string): (() => void); + tail(name?: string): () => void; /** * The server.decorate('request', ...) method can modify this prototype/interface. * Have disabled these typings as there is a better alternative, see example in: tests/server/decorate.ts @@ -2040,9 +2101,16 @@ export interface RequestAuthenticationInformation { error: Error; } -export type HTTP_METHODS_PARTIAL_lowercase = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'options'; -export type HTTP_METHODS_PARTIAL = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | HTTP_METHODS_PARTIAL_lowercase; -export type HTTP_METHODS = 'HEAD' | 'head' | HTTP_METHODS_PARTIAL; +export type HTTP_METHODS_PARTIAL_lowercase = "get" | "post" | "put" | "patch" | "delete" | "options"; +export type HTTP_METHODS_PARTIAL = + | "GET" + | "POST" + | "PUT" + | "PATCH" + | "DELETE" + | "OPTIONS" + | HTTP_METHODS_PARTIAL_lowercase; +export type HTTP_METHODS = "HEAD" | "head" | HTTP_METHODS_PARTIAL; /** * Request events @@ -2052,7 +2120,7 @@ export type HTTP_METHODS = 'HEAD' | 'head' | HTTP_METHODS_PARTIAL; * * 'disconnect' - emitted when a request errors or aborts unexpectedly. * [See docs](https://hapijs.com/api/16.1.1#request-events) */ -export type RequestEventTypes = 'peek' | 'finish' | 'disconnect'; +export type RequestEventTypes = "peek" | "finish" | "disconnect"; /* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2189,7 +2257,9 @@ export interface Base_Reply { * * modified - the Last-Modified header value. Required if etag is not present. Defaults to no header. * * vary - same as the response.etag() option. Defaults to true. */ - entity(options: {etag?: string | undefined, modified?: string | undefined, vary?: boolean | undefined}): Response | null; + entity( + options: { etag?: string | undefined; modified?: string | undefined; vary?: boolean | undefined }, + ): Response | null; /** * reply.close([options]) * Concludes the handler activity by returning control over to the router and informing the router that a response has already been sent back directly via request.raw.res and that no further response action is needed. Supports the following optional options: @@ -2198,7 +2268,7 @@ export interface Base_Reply { * @param options options object: * * end - if false, the router will not call request.raw.res.end()) to ensure the response was ended. Defaults to true. */ - close(options?: {end?: boolean | undefined}): void; + close(options?: { end?: boolean | undefined }): void; /** * reply.redirect(uri) * Redirects the client to the specified uri. Same as calling reply().redirect(uri). @@ -2328,9 +2398,7 @@ export interface ReplyNoContinue extends Base_Reply {} // Since an request can only have one response regardless if it is an error or success, the reply() method can only result in a single response value. This means that passing both an err and result will only use the err. There is no requirement for either err or result to be (or not) an Error object. The framework will simply use the first argument if present, otherwise the second. The method supports two arguments to be compatible with the common callback pattern of error first. // FLOW CONTROL: // When calling reply(), the framework waits until process.nextTick() to continue processing the request and transmit the response. This enables making changes to the returned response object before the response is sent. This means the framework will resume as soon as the handler method exits. To suspend this behavior, the returned response object supports the following methods: hold(), send() -/** - * - */ +/** */ // export interface Reply { // extends ReplyMethods { // (err: Error, // result?: string | number | boolean | Buffer | stream.Stream | Promise | T, @@ -2388,7 +2456,7 @@ export interface Response extends Podium { * * 'stream' - a Stream. * * 'promise' - a Promise object. */ - variety: 'plain' | 'buffer' | 'stream' | 'promise'; + variety: "plain" | "buffer" | "stream" | "promise"; /** application-specific state. Provides a safe place to store application data without potential conflicts with the framework. Should not be used by plugins which should use plugins[name]. */ app: any; /** plugin-specific state. Provides a place to store and pass request-level plugin data. The plugins is an object where each key is a plugin name and the value is the state. */ @@ -2462,7 +2530,7 @@ export interface Response extends Podium { * * 'binary' - Alias for 'latin1'. * * 'hex' - Encode each byte as two hexadecimal characters. */ - encoding(encoding: 'ascii' | 'utf8' | 'utf16le' | 'ucs2' | 'base64' | 'latin1' | 'binary' | 'hex'): Response; + encoding(encoding: "ascii" | "utf8" | "utf16le" | "ucs2" | "base64" | "latin1" | "binary" | "hex"): Response; /** * sets the representation entity tag * @param tag the entity tag string without the double-quote. @@ -2470,7 +2538,7 @@ export interface Response extends Podium { * * weak - if true, the tag will be prefixed with the 'W/' weak signifier. Weak tags will fail to match identical tags for the purpose of determining 304 response status. Defaults to false. * * vary - if true and content encoding is set or applied to the response (e.g 'gzip' or 'deflate'), the encoding name will be automatically added to the tag at transmission time (separated by a '-' character). Ignored when weak is true. Defaults to true. */ - etag(tag: string, options?: {weak: boolean, vary: boolean}): Response; + etag(tag: string, options?: { weak: boolean; vary: boolean }): Response; /** * sets an HTTP header * @param name the header name. @@ -2642,7 +2710,7 @@ export interface PluginAttributes { /** optional string or array of string indicating a plugin dependency. Same as setting dependencies via server.dependency(). */ dependencies?: string | string[] | undefined; /** if false, does not allow the plugin to call server APIs that modify the connections such as adding a route or configuring state. This flag allows the plugin to be registered before connections are added and to pass dependency requirements. When set to 'conditional', the mode is based on the presence of selected connections (if the server has connections, it is the same as true, but if no connections are available, it is the same as false). Defaults to true. */ - connections?: boolean | 'conditional' | undefined; + connections?: boolean | "conditional" | undefined; /** if true, will only register the plugin once per connection (or once per server for a connectionless plugin). If set, overrides the once option passed to server.register(). Defaults to undefined (registration will be based on the server.register() option once). */ once?: boolean | undefined; } @@ -2678,7 +2746,7 @@ export interface PluginRegistrationObject extends PluginR */ export interface PluginRegistrationOptions { once?: boolean | undefined; - routes?: {prefix?: string | undefined, vhost?: string | string[] | undefined} | undefined; + routes?: { prefix?: string | undefined; vhost?: string | string[] | undefined } | undefined; select?: string | string[] | undefined; } diff --git a/types/hapi/v16/test/connection/table.ts b/types/hapi/v16/test/connection/table.ts index 24eaa28ddcee1c..b9aeb47c5fe4d9 100644 --- a/types/hapi/v16/test/connection/table.ts +++ b/types/hapi/v16/test/connection/table.ts @@ -1,10 +1,15 @@ - // From https://hapijs.com/api/16.1.1#servertablehost -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); -server.connection({ port: 80, host: 'example.com' }); -server.route({ method: 'GET', path: '/example', handler: function (request, reply) { return reply(); } }); +server.connection({ port: 80, host: "example.com" }); +server.route({ + method: "GET", + path: "/example", + handler: function(request, reply) { + return reply(); + }, +}); const connection = server.connections[0]; const table = connection.table(); @@ -19,4 +24,4 @@ const table = connection.table(); ] */ -table.map(({method, path, settings: {description}}) => { }); +table.map(({ method, path, settings: { description } }) => {}); diff --git a/types/hapi/v16/test/continuation/errors.ts b/types/hapi/v16/test/continuation/errors.ts index 2f9fedaaf53448..20bbecdad0a84d 100644 --- a/types/hapi/v16/test/continuation/errors.ts +++ b/types/hapi/v16/test/continuation/errors.ts @@ -1,6 +1,5 @@ - -import * as Hapi from 'hapi'; -import * as Boom from 'boom'; +import * as Boom from "boom"; +import * as Hapi from "hapi"; // Assignment of a typical function to ContinuationValueFunction is possible const handleError: Hapi.ContinuationValueFunction = (err?: Boom.BoomError | null, value?: any) => { @@ -13,10 +12,10 @@ const handleError: Hapi.ContinuationValueFunction = (err?: Boom.BoomError | null // Discriminated union type works: switch (customError.data.customType) { - case 'Custom1': + case "Custom1": customError.data.custom1; break; - case 'Custom2': + case "Custom2": customError.data.custom2; break; } @@ -26,7 +25,11 @@ const handleError: Hapi.ContinuationValueFunction = (err?: Boom.BoomError | null handleError(Boom.badData()); // Accepts an error with custom data -const errorWithData = Boom.badImplementation('', { custom1: 'test', customType: 'Custom1' as 'Custom1', isCustom: true as true }); +const errorWithData = Boom.badImplementation("", { + custom1: "test", + customType: "Custom1" as "Custom1", + isCustom: true as true, +}); handleError(errorWithData); // Accepts an error with a more explicit type @@ -45,12 +48,12 @@ interface CustomDataBase { } interface CustomData1 extends CustomDataBase { - customType: 'Custom1'; + customType: "Custom1"; custom1: string; } interface CustomData2 extends CustomDataBase { - customType: 'Custom2'; + customType: "Custom2"; custom2: string; } diff --git a/types/hapi/v16/test/getting-started/01-creating-a-server.ts b/types/hapi/v16/test/getting-started/01-creating-a-server.ts index 819ab5108e51c2..8ba561eccd143e 100644 --- a/types/hapi/v16/test/getting-started/01-creating-a-server.ts +++ b/types/hapi/v16/test/getting-started/01-creating-a-server.ts @@ -1,14 +1,13 @@ // From https://hapijs.com/tutorials/getting-started#creating-a-server -'use strict'; +"use strict"; -import Hapi = require('hapi'); +import Hapi = require("hapi"); const server = new Hapi.Server(); -server.connection({ port: 3000, host: 'localhost' }); +server.connection({ port: 3000, host: "localhost" }); server.start((err) => { - if (err) { throw err; } diff --git a/types/hapi/v16/test/getting-started/02-adding-routes.ts b/types/hapi/v16/test/getting-started/02-adding-routes.ts index db4805366c569b..2ea6d1b35a7cb2 100644 --- a/types/hapi/v16/test/getting-started/02-adding-routes.ts +++ b/types/hapi/v16/test/getting-started/02-adding-routes.ts @@ -1,30 +1,29 @@ // from https://hapijs.com/tutorials/getting-started#adding-routes -'use strict'; +"use strict"; -import Hapi = require('hapi'); +import Hapi = require("hapi"); const server = new Hapi.Server(); -server.connection({ port: 3000, host: 'localhost' }); +server.connection({ port: 3000, host: "localhost" }); server.route({ - method: 'GET', - path: '/', - handler: function (request, reply) { - reply('Hello, world!'); - } + method: "GET", + path: "/", + handler: function(request, reply) { + reply("Hello, world!"); + }, }); server.route({ - method: 'GET', - path: '/{name}', - handler: function (request, reply) { - reply('Hello, ' + encodeURIComponent(request.params.name) + '!'); - } + method: "GET", + path: "/{name}", + handler: function(request, reply) { + reply("Hello, " + encodeURIComponent(request.params.name) + "!"); + }, }); server.start((err) => { - if (err) { throw err; } diff --git a/types/hapi/v16/test/getting-started/04-using-plugins.ts b/types/hapi/v16/test/getting-started/04-using-plugins.ts index 28d1a1b576fe94..8e5ad399a7d559 100644 --- a/types/hapi/v16/test/getting-started/04-using-plugins.ts +++ b/types/hapi/v16/test/getting-started/04-using-plugins.ts @@ -1,27 +1,27 @@ // from https://hapijs.com/tutorials/getting-started#using-plugins -'use strict'; +"use strict"; -import Hapi = require('hapi'); -const Good = require('good'); +import Hapi = require("hapi"); +const Good = require("good"); const server = new Hapi.Server(); -server.connection({ port: 3000, host: 'localhost' }); +server.connection({ port: 3000, host: "localhost" }); server.route({ - method: 'GET', - path: '/', - handler: function (request, reply) { - reply('Hello, world!'); - } + method: "GET", + path: "/", + handler: function(request, reply) { + reply("Hello, world!"); + }, }); server.route({ - method: 'GET', - path: '/{name}', - handler: function (request, reply) { - reply('Hello, ' + encodeURIComponent(request.params.name) + '!'); - } + method: "GET", + path: "/{name}", + handler: function(request, reply) { + reply("Hello, " + encodeURIComponent(request.params.name) + "!"); + }, }); server.register({ @@ -29,28 +29,26 @@ server.register({ options: { reporters: { console: [{ - module: 'good-squeeze', - name: 'Squeeze', + module: "good-squeeze", + name: "Squeeze", args: [{ - response: '*', - log: '*' - }] + response: "*", + log: "*", + }], }, { - module: 'good-console' - }, 'stdout'] - } - } + module: "good-console", + }, "stdout"], + }, + }, }, (err) => { - if (err) { throw err; // something bad happened loading the plugin } server.start((err) => { - if (err) { throw err; } - server.log('info', 'Server running at: ' + server.info!.uri); + server.log("info", "Server running at: " + server.info!.uri); }); }); diff --git a/types/hapi/v16/test/path/catch-all.ts b/types/hapi/v16/test/path/catch-all.ts index c9002392b1d0b3..889913c050e6ca 100644 --- a/types/hapi/v16/test/path/catch-all.ts +++ b/types/hapi/v16/test/path/catch-all.ts @@ -1,15 +1,13 @@ - // From https://hapijs.com/api/16.1.1#catch-all-route -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.connection({ port: 80 }); server.route({ - method: '*', - path: '/{p*}', - handler: function (request, reply) { - - return reply('The page was not found').code(404); - } + method: "*", + path: "/{p*}", + handler: function(request, reply) { + return reply("The page was not found").code(404); + }, }); diff --git a/types/hapi/v16/test/path/parameters.ts b/types/hapi/v16/test/path/parameters.ts index 62bbfcc638adc8..3e5668b1571830 100644 --- a/types/hapi/v16/test/path/parameters.ts +++ b/types/hapi/v16/test/path/parameters.ts @@ -1,33 +1,32 @@ - // From https://hapijs.com/api/16.1.1#path-parameters -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.connection({ port: 80 }); -const getAlbum: Hapi.RouteHandler = function (request, reply) { - - return reply('You asked for ' + - (request.params.song ? request.params.song + ' from ' : '') + - request.params.album); +const getAlbum: Hapi.RouteHandler = function(request, reply) { + return reply( + "You asked for " + + (request.params.song ? request.params.song + " from " : "") + + request.params.album, + ); }; server.route({ - path: '/{album}/{song?}', - method: 'GET', - handler: getAlbum + path: "/{album}/{song?}", + method: "GET", + handler: getAlbum, }); // Example 2 -const getPerson: Hapi.RouteHandler = function (request, reply) { - - const nameParts = request.params.name.split('/'); +const getPerson: Hapi.RouteHandler = function(request, reply) { + const nameParts = request.params.name.split("/"); return reply({ first: nameParts[0], last: nameParts[1] }); }; server.route({ - path: '/person/{name*2}', // Matches '/person/john/doe' - method: 'GET', - handler: getPerson + path: "/person/{name*2}", // Matches '/person/john/doe' + method: "GET", + handler: getPerson, }); diff --git a/types/hapi/v16/test/plugins/options.ts b/types/hapi/v16/test/plugins/options.ts index cd192f19960b67..622a64eea0f064 100644 --- a/types/hapi/v16/test/plugins/options.ts +++ b/types/hapi/v16/test/plugins/options.ts @@ -1,7 +1,6 @@ - // From https://hapijs.com/api/16.1.1#serverinfo -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; // added in addition to code from docs interface PluginOptions { @@ -10,27 +9,25 @@ interface PluginOptions { // modified from docs var registerFunction: Hapi.PluginFunction = function(server, options, next) { - server.route({ - method: 'GET', - path: '/test', - handler: function (request, reply) { - + method: "GET", + path: "/test", + handler: function(request, reply) { // modified from docs return reply(`ok ${options.quantity}`); - } + }, }); return next(); }; var attributes: Hapi.PluginAttributes = { - name: 'test', - version: '1.0.0' + name: "test", + version: "1.0.0", }; var attributes: Hapi.PluginAttributes = { - pkg: {} // require('./package.json'), + pkg: {}, // require('./package.json'), }; registerFunction.attributes = attributes; diff --git a/types/hapi/v16/test/reply/continue.ts b/types/hapi/v16/test/reply/continue.ts index de6994fbd04200..8f05e2cfeb30fc 100644 --- a/types/hapi/v16/test/reply/continue.ts +++ b/types/hapi/v16/test/reply/continue.ts @@ -1,15 +1,13 @@ - // From https://hapijs.com/api/16.1.1#replycontinueresult -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.connection({ port: 80 }); -const onRequest: Hapi.ServerExtRequestHandler = function (request, reply) { - +const onRequest: Hapi.ServerExtRequestHandler = function(request, reply) { // Change all requests to '/test' - request.setUrl('/test'); + request.setUrl("/test"); return reply.continue(); }; -server.ext('onRequest', onRequest); +server.ext("onRequest", onRequest); diff --git a/types/hapi/v16/test/reply/entity.ts b/types/hapi/v16/test/reply/entity.ts index cfcce6de25dbc7..24d2012e91e63c 100644 --- a/types/hapi/v16/test/reply/entity.ts +++ b/types/hapi/v16/test/reply/entity.ts @@ -1,24 +1,22 @@ - // From https://hapijs.com/api/16.1.1#replyentityoptions -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.connection({ port: 80 }); server.route({ - method: 'GET', - path: '/', + method: "GET", + path: "/", config: { cache: { expiresIn: 5000 }, - handler: function (request, reply) { - - const response = reply.entity({ etag: 'abc' }); + handler: function(request, reply) { + const response = reply.entity({ etag: "abc" }); if (response) { - response.header('X', 'y'); + response.header("X", "y"); return; } - return reply('ok'); - } - } + return reply("ok"); + }, + }, }); diff --git a/types/hapi/v16/test/reply/redirect.ts b/types/hapi/v16/test/reply/redirect.ts index 5baf892ac1a5d6..a59b37e7487ac5 100644 --- a/types/hapi/v16/test/reply/redirect.ts +++ b/types/hapi/v16/test/reply/redirect.ts @@ -1,8 +1,6 @@ - // From https://hapijs.com/api/16.1.1#replyredirecturi -import * as Hapi from 'hapi'; -const handler: Hapi.RouteHandler = function (request, reply) { - - return reply.redirect('http://example.com'); +import * as Hapi from "hapi"; +const handler: Hapi.RouteHandler = function(request, reply) { + return reply.redirect("http://example.com"); }; diff --git a/types/hapi/v16/test/reply/reply.ts b/types/hapi/v16/test/reply/reply.ts index ab62c53bc63c90..52b43ca41207c0 100644 --- a/types/hapi/v16/test/reply/reply.ts +++ b/types/hapi/v16/test/reply/reply.ts @@ -1,22 +1,19 @@ - // From https://hapijs.com/api/16.1.1#replyerr-result -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; // verbose notation -const handler: Hapi.RouteHandler = function (request, reply) { - - const response = reply('success'); - response.type('text/plain'); - response.header('X-Custom', 'some-value'); +const handler: Hapi.RouteHandler = function(request, reply) { + const response = reply("success"); + response.type("text/plain"); + response.header("X-Custom", "some-value"); }; // Chained notation -const handler2: Hapi.RouteHandler = function (request, reply) { - - return reply('success') - .type('text/plain') - .header('X-Custom', 'some-value'); +const handler2: Hapi.RouteHandler = function(request, reply) { + return reply("success") + .type("text/plain") + .header("X-Custom", "some-value"); }; diff --git a/types/hapi/v16/test/reply/state_cookie.ts b/types/hapi/v16/test/reply/state_cookie.ts index bf9421931125d7..26b4a379fa7ece 100644 --- a/types/hapi/v16/test/reply/state_cookie.ts +++ b/types/hapi/v16/test/reply/state_cookie.ts @@ -1,33 +1,30 @@ - // from https://hapijs.com/tutorials/cookies?lang=en_US -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.connection({ port: 80 }); -server.state('data', { +server.state("data", { ttl: null, isSecure: true, isHttpOnly: true, - encoding: 'base64json', + encoding: "base64json", clearInvalid: false, // remove invalid cookies - strictHeader: true // don't allow violations of RFC 6265 + strictHeader: true, // don't allow violations of RFC 6265 }); server.route({ - method: 'GET', - path: '/say-hello', - config: { - state: { - parse: true, // parse and store in request.state - failAction: 'error' // may also be 'ignore' or 'log' - } - }, - handler: function(request, reply) { - // TODO test this - reply('Hello').state('data', { firstVisit: false }); - } -}) - - + method: "GET", + path: "/say-hello", + config: { + state: { + parse: true, // parse and store in request.state + failAction: "error", // may also be 'ignore' or 'log' + }, + }, + handler: function(request, reply) { + // TODO test this + reply("Hello").state("data", { firstVisit: false }); + }, +}); diff --git a/types/hapi/v16/test/request/event-types.ts b/types/hapi/v16/test/request/event-types.ts index 0946f0a0ed12d8..492e42bd272082 100644 --- a/types/hapi/v16/test/request/event-types.ts +++ b/types/hapi/v16/test/request/event-types.ts @@ -1,30 +1,25 @@ - // From https://hapijs.com/api/16.1.1#requestsetmethodmethod -import * as Hapi from 'hapi'; -const Crypto = require('crypto'); +import * as Hapi from "hapi"; +const Crypto = require("crypto"); const server = new Hapi.Server(); server.connection({ port: 80 }); -const onRequest: Hapi.ServerExtRequestHandler = function (request, reply) { - - const hash = Crypto.createHash('sha1'); - request.on('peek', (chunk) => { - +const onRequest: Hapi.ServerExtRequestHandler = function(request, reply) { + const hash = Crypto.createHash("sha1"); + request.on("peek", (chunk) => { hash.update(chunk); }); - request.once('finish', () => { - - console.log(hash.digest('hex')); + request.once("finish", () => { + console.log(hash.digest("hex")); }); - request.once('disconnect', () => { - - console.error('request aborted'); + request.once("disconnect", () => { + console.error("request aborted"); }); return reply.continue(); }; -server.ext('onRequest', onRequest); +server.ext("onRequest", onRequest); diff --git a/types/hapi/v16/test/request/generate-response.ts b/types/hapi/v16/test/request/generate-response.ts index c30c3a7be59c7a..1662c7ea2ba70c 100644 --- a/types/hapi/v16/test/request/generate-response.ts +++ b/types/hapi/v16/test/request/generate-response.ts @@ -1,17 +1,14 @@ - // From https://hapijs.com/api/16.1.1#requestgenerateresponsesource-options -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; // Added in addition to code from docs function promiseMethod() { return Promise.resolve(true); } -const handler: Hapi.ServerExtRequestHandler = function (request, reply) { - +const handler: Hapi.ServerExtRequestHandler = function(request, reply) { const result = promiseMethod().then((thing: boolean) => { - if (!thing) { return request.generateResponse().code(214); } diff --git a/types/hapi/v16/test/request/get-log.ts b/types/hapi/v16/test/request/get-log.ts index b241202525eb1a..445622602c0296 100644 --- a/types/hapi/v16/test/request/get-log.ts +++ b/types/hapi/v16/test/request/get-log.ts @@ -1,12 +1,11 @@ - // From https://hapijs.com/api/16.1.1#requestgetlogtags-internal -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; declare const request: Hapi.Request; request.getLog(); -request.getLog('error'); -request.getLog(['error', 'auth']); -request.getLog(['error'], true); +request.getLog("error"); +request.getLog(["error", "auth"]); +request.getLog(["error"], true); request.getLog(false); diff --git a/types/hapi/v16/test/request/log.ts b/types/hapi/v16/test/request/log.ts index 1c2da1f3b075b2..24edcabdd5e070 100644 --- a/types/hapi/v16/test/request/log.ts +++ b/types/hapi/v16/test/request/log.ts @@ -1,19 +1,16 @@ - // From https://hapijs.com/api/16.1.1#requestlogtags-data-timestamp -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.connection({ port: 80, routes: { log: true, security: false } }); -server.on('request', (request, event, tags) => { - +server.on("request", (request, event, tags) => { if (tags.error) { console.log(event); } }); -const handler: Hapi.RouteHandler = function (request, reply) { - - request.log(['test', 'error'], 'Test event'); +const handler: Hapi.RouteHandler = function(request, reply) { + request.log(["test", "error"], "Test event"); return reply(); }; diff --git a/types/hapi/v16/test/request/query.ts b/types/hapi/v16/test/request/query.ts index c6507c2da0b6c2..b41ff00948e092 100644 --- a/types/hapi/v16/test/request/query.ts +++ b/types/hapi/v16/test/request/query.ts @@ -1,13 +1,12 @@ // Added test in addition to docs, for request.query -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; interface GetThingQuery { name: string; } -const handler: Hapi.RouteHandler = function (request, reply) { - +const handler: Hapi.RouteHandler = function(request, reply) { const query = request.query as GetThingQuery; return reply(`You asked for ${query.name}`); diff --git a/types/hapi/v16/test/request/set-method.ts b/types/hapi/v16/test/request/set-method.ts index 7269e6255f3530..81d70a4bc3420d 100644 --- a/types/hapi/v16/test/request/set-method.ts +++ b/types/hapi/v16/test/request/set-method.ts @@ -1,15 +1,13 @@ - // From https://hapijs.com/api/16.1.1#requestsetmethodmethod -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.connection({ port: 80 }); -const onRequest: Hapi.ServerExtRequestHandler = function (request, reply) { - +const onRequest: Hapi.ServerExtRequestHandler = function(request, reply) { // Change all requests to 'GET' - request.setMethod('GET'); + request.setMethod("GET"); return reply.continue(); }; -server.ext('onRequest', onRequest); +server.ext("onRequest", onRequest); diff --git a/types/hapi/v16/test/request/set-url.ts b/types/hapi/v16/test/request/set-url.ts index 56f4b470961625..c8099ea544c72b 100644 --- a/types/hapi/v16/test/request/set-url.ts +++ b/types/hapi/v16/test/request/set-url.ts @@ -1,25 +1,22 @@ - // From https://hapijs.com/api/16.1.1#requestseturlurl-striptrailingslash -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.connection({ port: 80 }); -var onRequest: Hapi.ServerExtRequestHandler = function (request, reply) { - +var onRequest: Hapi.ServerExtRequestHandler = function(request, reply) { // Change all requests to '/test' - request.setUrl('/test'); + request.setUrl("/test"); return reply.continue(); }; -server.ext('onRequest', onRequest); +server.ext("onRequest", onRequest); // Example 2 -import * as Url from 'url'; - -onRequest = function (request, reply) { +import * as Url from "url"; +onRequest = function(request, reply) { const uri = request.raw.req.url; const parsed = Url.parse(uri!, false); request.setUrl(parsed); @@ -27,4 +24,4 @@ onRequest = function (request, reply) { return reply.continue(); }; -server.ext('onRequest', onRequest); +server.ext("onRequest", onRequest); diff --git a/types/hapi/v16/test/request/tail.ts b/types/hapi/v16/test/request/tail.ts index 9c68ccb8f2a880..0e25a8a4230214 100644 --- a/types/hapi/v16/test/request/tail.ts +++ b/types/hapi/v16/test/request/tail.ts @@ -1,26 +1,22 @@ - // From https://hapijs.com/api/16.1.1#requestsetmethodmethod -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.connection({ port: 80 }); -const get: Hapi.RouteHandler = function (request, reply) { - - const dbTail = request.tail('write to database'); +const get: Hapi.RouteHandler = function(request, reply) { + const dbTail = request.tail("write to database"); var db: any; - db.save('key', 'value', () => { - + db.save("key", "value", () => { dbTail(); }); - return reply('Success!'); + return reply("Success!"); }; -server.route({ method: 'GET', path: '/', handler: get }); - -server.on('tail', (request) => { +server.route({ method: "GET", path: "/", handler: get }); - console.log('Request completed including db activity'); +server.on("tail", (request) => { + console.log("Request completed including db activity"); }); diff --git a/types/hapi/v16/test/response/error-representation.ts b/types/hapi/v16/test/response/error-representation.ts index 27b90330dda913..d8049e878069b4 100644 --- a/types/hapi/v16/test/response/error-representation.ts +++ b/types/hapi/v16/test/response/error-representation.ts @@ -1,12 +1,10 @@ - // From https://hapijs.com/api/16.1.1#error-transformation -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.connection({ port: 80 }); -const preResponse: Hapi.ServerExtRequestHandler = function (request, reply) { - +const preResponse: Hapi.ServerExtRequestHandler = function(request, reply) { const response = request.response!; if (!response.isBoom) { return reply.continue(); @@ -14,10 +12,10 @@ const preResponse: Hapi.ServerExtRequestHandler = function (request, reply) { // Replace error with friendly HTML - const error = response; - const ctx = { - message: (error.output!.statusCode === 404 ? 'page not found' : 'something went wrong') - }; + const error = response; + const ctx = { + message: (error.output!.statusCode === 404 ? "page not found" : "something went wrong"), + }; }; -server.ext('onPreResponse', preResponse); +server.ext("onPreResponse", preResponse); diff --git a/types/hapi/v16/test/response/error.ts b/types/hapi/v16/test/response/error.ts index 79c020586f39d8..4ae4b8c005d163 100644 --- a/types/hapi/v16/test/response/error.ts +++ b/types/hapi/v16/test/response/error.ts @@ -1,25 +1,22 @@ - // From https://hapijs.com/api/16.1.1#error-response -import * as Hapi from 'hapi'; -import * as Boom from 'boom'; +import * as Boom from "boom"; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.route({ - method: 'GET', - path: '/badRequest', - handler: function (request, reply) { - - return reply(Boom.badRequest('Unsupported parameter')); - } + method: "GET", + path: "/badRequest", + handler: function(request, reply) { + return reply(Boom.badRequest("Unsupported parameter")); + }, }); server.route({ - method: 'GET', - path: '/internal', - handler: function (request, reply) { - - return reply(new Error('unexpect error')); - } + method: "GET", + path: "/internal", + handler: function(request, reply) { + return reply(new Error("unexpect error")); + }, }); diff --git a/types/hapi/v16/test/response/events.ts b/types/hapi/v16/test/response/events.ts index 2d1658087b8f30..adbfc97367d1be 100644 --- a/types/hapi/v16/test/response/events.ts +++ b/types/hapi/v16/test/response/events.ts @@ -1,30 +1,26 @@ - // From https://hapijs.com/api/16.1.1#response-events -import * as Hapi from 'hapi'; -const Crypto = require('crypto'); +import * as Hapi from "hapi"; +const Crypto = require("crypto"); const server = new Hapi.Server(); server.connection({ port: 80 }); -const preResponse: Hapi.ServerExtRequestHandler = function (request, reply) { - +const preResponse: Hapi.ServerExtRequestHandler = function(request, reply) { const response = request.response!; if (response.isBoom) { return reply(); } - const hash = Crypto.createHash('sha1'); - response.on('peek', (chunk) => { - + const hash = Crypto.createHash("sha1"); + response.on("peek", (chunk) => { hash.update(chunk); }); - response.once('finish', () => { - - console.log(hash.digest('hex')); + response.once("finish", () => { + console.log(hash.digest("hex")); }); return reply.continue(); }; -server.ext('onPreResponse', preResponse); +server.ext("onPreResponse", preResponse); diff --git a/types/hapi/v16/test/response/flow-control.ts b/types/hapi/v16/test/response/flow-control.ts index bc18a36aff4f1a..a1b44fd51cb707 100644 --- a/types/hapi/v16/test/response/flow-control.ts +++ b/types/hapi/v16/test/response/flow-control.ts @@ -1,14 +1,11 @@ - // From https://hapijs.com/api/16.1.1#flow-control -import * as Hapi from 'hapi'; - -const handler = function (request: Hapi.Request, reply: Hapi.ReplyWithContinue) { +import * as Hapi from "hapi"; - const response = reply('success').hold(); +const handler = function(request: Hapi.Request, reply: Hapi.ReplyWithContinue) { + const response = reply("success").hold(); setTimeout(() => { - response.send(); }, 1000); }; diff --git a/types/hapi/v16/test/route/additional-options.ts b/types/hapi/v16/test/route/additional-options.ts index 49466873e672ca..f1978b09e59c44 100644 --- a/types/hapi/v16/test/route/additional-options.ts +++ b/types/hapi/v16/test/route/additional-options.ts @@ -1,6 +1,6 @@ -'use strict'; +"use strict"; -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; var authConfig: Hapi.RouteAdditionalConfigurationOptions = { app: {}, @@ -9,54 +9,54 @@ var authConfig: Hapi.RouteAdditionalConfigurationOptions = { var extConfigSingle: Hapi.RouteAdditionalConfigurationOptions = { ext: { - type: 'onPreAuth', - method: function (request, reply) { - reply('ok'); - } as Hapi.ServerExtRequestHandler - } -} + type: "onPreAuth", + method: function(request, reply) { + reply("ok"); + } as Hapi.ServerExtRequestHandler, + }, +}; var extConfigMulti: Hapi.RouteAdditionalConfigurationOptions = { ext: [{ - type: 'onPreAuth', - method: function (request, reply) { - reply('ok'); - } as Hapi.ServerExtRequestHandler + type: "onPreAuth", + method: function(request, reply) { + reply("ok"); + } as Hapi.ServerExtRequestHandler, }, { - type: 'onPostAuth', - method: function (request, reply) { - reply('ok'); - } as Hapi.ServerExtRequestHandler + type: "onPostAuth", + method: function(request, reply) { + reply("ok"); + } as Hapi.ServerExtRequestHandler, }, { - type: 'onPostStart', - method: function (server, next) { + type: "onPostStart", + method: function(server, next) { next(); - } as Hapi.ServerExtFunction - }] -} + } as Hapi.ServerExtFunction, + }], +}; // Handler in config const user: Hapi.RouteAdditionalConfigurationOptions = { cache: { expiresIn: 5000, statuses: [200, 201] }, - handler: function (request, reply) { - return reply({ name: 'John' }); - } + handler: function(request, reply) { + return reply({ name: "John" }); + }, }; // Add in addition to examples in docs var cache: Hapi.RouteCacheOptions = { - privacy: 'default', + privacy: "default", expiresIn: 5000, }; cache = { - privacy: 'default', - expiresAt: '22:44', + privacy: "default", + expiresAt: "22:44", }; cache = { - privacy: 'default', + privacy: "default", }; /* should error (as does!) @@ -67,15 +67,15 @@ var cache: Hapi.RouteCacheOptions = { */ var payloadOptions: Hapi.RoutePayloadConfigurationObject = { - allow: 'multipart/form-data', + allow: "multipart/form-data", maxBytes: 123, - output: 'file', - timeout: 1000 + output: "file", + timeout: 1000, }; var payloadOptions: Hapi.RoutePayloadConfigurationObject = { - allow: 'multipart/form-data', + allow: "multipart/form-data", maxBytes: 123, - output: 'file', - timeout: false + output: "file", + timeout: false, }; diff --git a/types/hapi/v16/test/route/auth.ts b/types/hapi/v16/test/route/auth.ts index e5239322daf27d..e96256b5ae1242 100644 --- a/types/hapi/v16/test/route/auth.ts +++ b/types/hapi/v16/test/route/auth.ts @@ -1,25 +1,25 @@ -'use strict'; +"use strict"; -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; var routeMoreConfig: Hapi.RouteAdditionalConfigurationOptions = { auth: false, -} +}; routeMoreConfig = { - auth: 'some_strategy', -} + auth: "some_strategy", +}; routeMoreConfig = { auth: { - mode: 'required', - strategies: ['strat1', 'strat2'], - strategy: 'should not be given when strategies given', + mode: "required", + strategies: ["strat1", "strat2"], + strategy: "should not be given when strategies given", payload: false, access: { scope: false, - entity: 'any', + entity: "any", }, // Will over write values in access scope: false, - entity: 'any', - } -} + entity: "any", + }, +}; diff --git a/types/hapi/v16/test/route/config.ts b/types/hapi/v16/test/route/config.ts index 16457395f8b69d..d5d6086c68c31d 100644 --- a/types/hapi/v16/test/route/config.ts +++ b/types/hapi/v16/test/route/config.ts @@ -1,34 +1,34 @@ -'use strict'; +"use strict"; -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; // different methods var routeConfig: Hapi.RouteConfiguration = { - path: '/signin', - method: 'PUT', - vhost: 'site.coms', + path: "/signin", + method: "PUT", + vhost: "site.coms", }; var routeConfig: Hapi.RouteConfiguration = { - path: '/signin', - method: '*' + path: "/signin", + method: "*", }; var routeConfig: Hapi.RouteConfiguration = { - path: '/signin', - method: ['OPTIONS', '*'] + path: "/signin", + method: ["OPTIONS", "*"], }; // different handlers var routeConfig: Hapi.RouteConfiguration = { - path: '/signin', - method: 'PUT', - handler: 'some registered handler' + path: "/signin", + method: "PUT", + handler: "some registered handler", }; var routeConfig: Hapi.RouteConfiguration = { - path: '/signin', - method: 'PUT', - handler: function (request, reply) { - return reply('ok'); - } + path: "/signin", + method: "PUT", + handler: function(request, reply) { + return reply("ok"); + }, }; const server = new Hapi.Server(); @@ -37,10 +37,9 @@ server.route(routeConfig); // Handler in config const user: Hapi.RouteAdditionalConfigurationOptions = { cache: { expiresIn: 5000 }, - handler: function (request, reply) { - - return reply({ name: 'John' }); - } + handler: function(request, reply) { + return reply({ name: "John" }); + }, }; -server.route({method: 'GET', path: '/user', config: user }); +server.route({ method: "GET", path: "/user", config: user }); diff --git a/types/hapi/v16/test/route/handler.ts b/types/hapi/v16/test/route/handler.ts index c66d17018e1bf2..20231e9393d54d 100644 --- a/types/hapi/v16/test/route/handler.ts +++ b/types/hapi/v16/test/route/handler.ts @@ -1,10 +1,10 @@ -'use strict'; +"use strict"; -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; var handler: Hapi.RouteHandler = function(request, reply) { - reply('success'); -} + reply("success"); +}; var strictHandler: Hapi.RouteHandler = function(request, reply) { reply(123); -} +}; diff --git a/types/hapi/v16/test/route/plugins.ts b/types/hapi/v16/test/route/plugins.ts index e6c30914731e8e..7d80977e015418 100644 --- a/types/hapi/v16/test/route/plugins.ts +++ b/types/hapi/v16/test/route/plugins.ts @@ -1,14 +1,14 @@ // Added in addition to code from https://hapijs.com/api/16.1.1#route-options > plugins -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; // In the plugin code -declare module 'hapi' { +declare module "hapi" { interface PluginSpecificConfiguration { coolPlugin: { optionA: string; optionB?: boolean | undefined; - } + }; } } @@ -17,22 +17,22 @@ const pluginsServerConfig: Hapi.ServerOptions = { plugins: { coolPlugin: { optionA: "test", - } - } + }, + }, }; const pluginsConnectionConfig: Hapi.ConnectionConfigurationServerDefaults = { plugins: { coolPlugin: { optionA: "test", - } - } + }, + }, }; const pluginsRouteConfig: Hapi.RouteAdditionalConfigurationOptions = { plugins: { coolPlugin: { optionA: "test", - } - } + }, + }, }; diff --git a/types/hapi/v16/test/route/prerequisites.ts b/types/hapi/v16/test/route/prerequisites.ts index c4ca7650faa00e..ea5fad0e505f39 100644 --- a/types/hapi/v16/test/route/prerequisites.ts +++ b/types/hapi/v16/test/route/prerequisites.ts @@ -1,42 +1,39 @@ - // From https://hapijs.com/api/16.1.1#route-prerequisites -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.connection({ port: 80 }); -const pre1: Hapi.RoutePrerequisiteRequestHandler = function (request, reply) { - - return reply('Hello'); +const pre1: Hapi.RoutePrerequisiteRequestHandler = function(request, reply) { + return reply("Hello"); }; -const pre2: Hapi.RoutePrerequisiteRequestHandler = function (request, reply) { - - return reply('World'); +const pre2: Hapi.RoutePrerequisiteRequestHandler = function(request, reply) { + return reply("World"); }; -const pre3: Hapi.RoutePrerequisiteRequestHandler = function (request, reply) { +const pre3: Hapi.RoutePrerequisiteRequestHandler = function(request, reply) { const pre = request.pre as Pre1; - return reply(pre.m1 + ' ' + pre.m2); + return reply(pre.m1 + " " + pre.m2); }; server.route({ - method: 'GET', - path: '/', + method: "GET", + path: "/", config: { pre: [ [ // m1 and m2 executed in parallel - { method: pre1, assign: 'm1' }, - { method: pre2, assign: 'm2' } + { method: pre1, assign: "m1" }, + { method: pre2, assign: "m2" }, ], - { method: pre3, assign: 'm3' }, + { method: pre3, assign: "m3" }, ], - handler: function (request, reply) { + handler: function(request, reply) { const pre = request.pre as Pre2; - return reply(pre.m3 + '\n'); - } - } + return reply(pre.m3 + "\n"); + }, + }, }); interface Pre1 { m1: string; diff --git a/types/hapi/v16/test/route/public-interface.ts b/types/hapi/v16/test/route/public-interface.ts index 32d76124265030..14f08678d7df2b 100644 --- a/types/hapi/v16/test/route/public-interface.ts +++ b/types/hapi/v16/test/route/public-interface.ts @@ -1,15 +1,15 @@ -'use strict'; +"use strict"; -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; var route = {} as Hapi.RoutePublicInterface; var a: string = route.method; var a: string = route.path; -if (typeof(route.vhost) == 'string') { - var a: string = route.vhost; +if (typeof (route.vhost) == "string") { + var a: string = route.vhost; } else { - var b: string[] = route.vhost!; + var b: string[] = route.vhost!; } var c: Hapi.ServerRealm = route.realm; var d: Hapi.RouteAdditionalConfigurationOptions = route.settings; diff --git a/types/hapi/v16/test/route/validate.ts b/types/hapi/v16/test/route/validate.ts index be8a4280fc72e7..a8023dfc8380ed 100644 --- a/types/hapi/v16/test/route/validate.ts +++ b/types/hapi/v16/test/route/validate.ts @@ -1,8 +1,7 @@ - // Added from: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/16065#issuecomment-302216131 -import * as Hapi from 'hapi'; -import * as Joi from 'joi'; +import * as Hapi from "hapi"; +import * as Joi from "joi"; const validate: Hapi.RouteValidationConfigurationObject = { headers: true, @@ -29,7 +28,11 @@ interface CustomValidationOptions extends Joi.ValidationOptions { myOption: number; } -const inputValidationFunction: Hapi.ValidationFunctionForRouteInput = (value, options, next) => { +const inputValidationFunction: Hapi.ValidationFunctionForRouteInput = ( + value, + options, + next, +) => { options.myOption; // check custom options options.context.auth.artifacts; // check context next(null, value); // check with value @@ -42,11 +45,15 @@ const validateWithFunctions: Hapi.RouteValidationConfigurationObject = (value, options, next) => { +const responseValidationFunction: Hapi.ValidationFunctionForRouteResponse = ( + value, + options, + next, +) => { options.myOption; // check custom options options.context.auth.isAuthenticated; // check context next(null, value); // check with value @@ -58,7 +65,7 @@ config = { response: { schema: responseValidationFunction, options: { - myOption: 18 - } - } as Hapi.RouteResponseConfigurationObject + myOption: 18, + }, + } as Hapi.RouteResponseConfigurationObject, }; diff --git a/types/hapi/v16/test/server/app.ts b/types/hapi/v16/test/server/app.ts index dac8921c2066d0..a3d2de5cc6b7b8 100644 --- a/types/hapi/v16/test/server/app.ts +++ b/types/hapi/v16/test/server/app.ts @@ -1,11 +1,9 @@ - // From https://hapijs.com/api/16.1.1#serverapp -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; var server = new Hapi.Server(); -server.app.key = 'value'; - -const handler: Hapi.RouteHandler = function (request, reply) { +server.app.key = "value"; +const handler: Hapi.RouteHandler = function(request, reply) { return reply(request.server.app.key); }; diff --git a/types/hapi/v16/test/server/auth.ts b/types/hapi/v16/test/server/auth.ts index 3f28732d42555a..042472c6e9c970 100644 --- a/types/hapi/v16/test/server/auth.ts +++ b/types/hapi/v16/test/server/auth.ts @@ -1,101 +1,92 @@ - // From https://hapijs.com/api/16.1.1#serverauthapi -import * as Hapi from 'hapi'; -import * as Boom from 'boom'; +import * as Boom from "boom"; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.connection({ port: 80 }); -var scheme: Hapi.ServerAuthScheme = function (server, options) { - +var scheme: Hapi.ServerAuthScheme = function(server, options) { return { api: { settings: { - x: 5 - } + x: 5, + }, }, - authenticate: function (request, reply) { - + authenticate: function(request, reply) { const req = request.raw.req; const authorization = req.headers.authorization; if (!authorization) { - return reply(Boom.unauthorized(null, 'Custom')); + return reply(Boom.unauthorized(null, "Custom")); } - return reply.continue({ credentials: { user: 'john' } }); - } + return reply.continue({ credentials: { user: "john" } }); + }, }; }; -server.auth.scheme('custom', scheme); -server.auth.strategy('default', 'custom'); +server.auth.scheme("custom", scheme); +server.auth.strategy("default", "custom"); -console.log(server.auth.api.default.settings.x); // 5 +console.log(server.auth.api.default.settings.x); // 5 // Default -server.auth.default('default'); +server.auth.default("default"); server.route({ - method: 'GET', - path: '/', - handler: function (request, reply) { - + method: "GET", + path: "/", + handler: function(request, reply) { return reply(request.auth.credentials.user); - } + }, }); // scheme -scheme = function (server, options) { - +scheme = function(server, options) { return { - authenticate: function (request, reply) { - + authenticate: function(request, reply) { const req = request.raw.req; const authorization = req.headers.authorization; if (!authorization) { - return reply(Boom.unauthorized(null, 'Custom')); + return reply(Boom.unauthorized(null, "Custom")); } - return reply.continue({ credentials: { user: 'john' } }); - } + return reply.continue({ credentials: { user: "john" } }); + }, }; }; -server.auth.scheme('custom', scheme); +server.auth.scheme("custom", scheme); // strategy -server.auth.scheme('custom', scheme); -server.auth.strategy('default', 'custom'); +server.auth.scheme("custom", scheme); +server.auth.strategy("default", "custom"); server.route({ - method: 'GET', - path: '/', + method: "GET", + path: "/", config: { - auth: 'default', - handler: function (request, reply) { - + auth: "default", + handler: function(request, reply) { return reply(request.auth.credentials.user); - } - } + }, + }, }); // test server.route({ - method: 'GET', - path: '/', - handler: function (request, reply) { - - request.server.auth.test('default', request, (err, credentials) => { - + method: "GET", + path: "/", + handler: function(request, reply) { + request.server.auth.test("default", request, (err, credentials) => { if (err) { return reply({ status: false }); } return reply({ status: true, user: (credentials as any).name }); }); - } + }, }); diff --git a/types/hapi/v16/test/server/bind.ts b/types/hapi/v16/test/server/bind.ts index 2741e16c82cc08..9553ee6a9fbc7c 100644 --- a/types/hapi/v16/test/server/bind.ts +++ b/types/hapi/v16/test/server/bind.ts @@ -1,24 +1,21 @@ - // From https://hapijs.com/api/16.1.1#serverbindcontext -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; interface HandlerThis { message: string; } -const handler: Hapi.RouteHandler = function (this: HandlerThis, request, reply) { - +const handler: Hapi.RouteHandler = function(this: HandlerThis, request, reply) { return reply(this.message); }; -var register: Hapi.PluginFunction<{}> = function (server, options, next) { - +var register: Hapi.PluginFunction<{}> = function(server, options, next) { const bind: HandlerThis = { - message: 'hello' + message: "hello", }; server.bind(bind); - server.route({ method: 'GET', path: '/', handler: handler }); + server.route({ method: "GET", path: "/", handler: handler }); return next(); }; diff --git a/types/hapi/v16/test/server/cache.ts b/types/hapi/v16/test/server/cache.ts index 4cb9eaa4b76c40..0d41a30eec35a1 100644 --- a/types/hapi/v16/test/server/cache.ts +++ b/types/hapi/v16/test/server/cache.ts @@ -1,15 +1,12 @@ - // From https://hapijs.com/api/16.1.1#servercacheoptions -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.connection({ port: 80 }); -const cache = server.cache({ segment: 'countries', expiresIn: 60 * 60 * 1000 }); -cache.set('norway', { capital: 'oslo' }, null, (err) => { - - cache.get('norway', (err, value, cached, log) => { - +const cache = server.cache({ segment: "countries", expiresIn: 60 * 60 * 1000 }); +cache.set("norway", { capital: "oslo" }, null, (err) => { + cache.get("norway", (err, value, cached, log) => { // value === { capital: 'oslo' }; }); }); @@ -18,14 +15,10 @@ cache.set('norway', { capital: 'oslo' }, null, (err) => { // From https://hapijs.com/api/16.1.1#servercacheprovisionoptions-callback server.initialize((err) => { - - server.cache.provision({ engine: require('catbox-memory'), name: 'countries' }, (err) => { - - const cache = server.cache({ cache: 'countries', expiresIn: 60 * 60 * 1000 }); - cache.set('norway', { capital: 'oslo' }, null, (err) => { - - cache.get('norway', (err, value, cached, log) => { - + server.cache.provision({ engine: require("catbox-memory"), name: "countries" }, (err) => { + const cache = server.cache({ cache: "countries", expiresIn: 60 * 60 * 1000 }); + cache.set("norway", { capital: "oslo" }, null, (err) => { + cache.get("norway", (err, value, cached, log) => { // value === { capital: 'oslo' }; }); }); diff --git a/types/hapi/v16/test/server/connection-options.ts b/types/hapi/v16/test/server/connection-options.ts index 3a526307db5bf1..f541fb4a163c4b 100644 --- a/types/hapi/v16/test/server/connection-options.ts +++ b/types/hapi/v16/test/server/connection-options.ts @@ -1,11 +1,10 @@ - // From https://hapijs.com/api/16.1.1#serverconnectionoptions -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); -const web = server.connection({ port: 8000, host: 'example.com', labels: ['web'] }); -const admin = server.connection({ port: 8001, host: 'example.com', labels: ['admin'] }); +const web = server.connection({ port: 8000, host: "example.com", labels: ["web"] }); +const admin = server.connection({ port: 8001, host: "example.com", labels: ["admin"] }); server.connections.length === 2; web.connections.length === 1; @@ -13,8 +12,7 @@ admin.connections.length === 1; // example 2 -var registerFunction: Hapi.PluginFunction<{}> = function (srv, options, next) { - +var registerFunction: Hapi.PluginFunction<{}> = function(srv, options, next) { // Use the 'srv' argument to add a new connection const server = srv.connection(); @@ -22,18 +20,17 @@ var registerFunction: Hapi.PluginFunction<{}> = function (srv, options, next) { // Use the 'server' return value to manage the new connection server.route({ - path: '/', - method: 'GET', - handler: function (request, reply) { - - return reply('hello'); - } + path: "/", + method: "GET", + handler: function(request, reply) { + return reply("hello"); + }, }); return next(); }; registerFunction.attributes = { - name: 'example', - connections: false + name: "example", + connections: false, }; diff --git a/types/hapi/v16/test/server/connections.ts b/types/hapi/v16/test/server/connections.ts index fb2f9f303e2430..aed0d455074218 100644 --- a/types/hapi/v16/test/server/connections.ts +++ b/types/hapi/v16/test/server/connections.ts @@ -1,13 +1,12 @@ - // From https://hapijs.com/api/16.1.1#serverconnections -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; var server = new Hapi.Server(); -server.connection({ port: 80, labels: 'a' }); -server.connection({ port: 8080, labels: 'b' }); +server.connection({ port: 80, labels: "a" }); +server.connection({ port: 8080, labels: "b" }); // server.connections.length === 2 -const a = server.select('a'); +const a = server.select("a"); // a.connections.length === 1 diff --git a/types/hapi/v16/test/server/decoder.ts b/types/hapi/v16/test/server/decoder.ts index edd52485eace45..32c4d30fc5537f 100644 --- a/types/hapi/v16/test/server/decoder.ts +++ b/types/hapi/v16/test/server/decoder.ts @@ -1,9 +1,8 @@ - // From https://hapijs.com/api/16.1.1#serverdecoderencoding-decoder -import * as Hapi from 'hapi'; -import * as Zlib from 'zlib'; +import * as Hapi from "hapi"; +import * as Zlib from "zlib"; const server = new Hapi.Server(); server.connection({ port: 80, routes: { payload: { compression: { special: { chunkSize: 16 * 1024 } } } } }); -server.decoder('special', (options) => Zlib.createGunzip(options)); +server.decoder("special", (options) => Zlib.createGunzip(options)); diff --git a/types/hapi/v16/test/server/decorate.ts b/types/hapi/v16/test/server/decorate.ts index 540e29c95181e6..275787d98bf520 100644 --- a/types/hapi/v16/test/server/decorate.ts +++ b/types/hapi/v16/test/server/decorate.ts @@ -1,65 +1,62 @@ - // From https://hapijs.com/api/16.1.1#serverdecoratetype-property-method-options -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.connection({ port: 80 }); -const success = function (this: Hapi.ReplyNoContinue) { - - return this.response({ status: 'ok' }); +const success = function(this: Hapi.ReplyNoContinue) { + return this.response({ status: "ok" }); }; -server.decorate('reply', 'success', success); +server.decorate("reply", "success", success); -declare module 'hapi' { +declare module "hapi" { interface Base_Reply { success: () => Response; } } server.route({ - method: 'GET', - path: '/', - handler: function (request, reply) { - + method: "GET", + path: "/", + handler: function(request, reply) { return reply.success(); - } + }, }); // custom typing code for decorating request -server.decorate('request', 'some_request_method', (request) => { +server.decorate("request", "some_request_method", (request) => { return function() { // Do some sort of processing; return request.id; - } -}, {apply: true}); + }; +}, { apply: true }); -declare module 'hapi' { +declare module "hapi" { interface Request { some_request_method(): void; } } server.route({ - method: 'GET', - path: '/', - handler: function (request, reply) { + method: "GET", + path: "/", + handler: function(request, reply) { request.some_request_method(); return reply(); - } + }, }); // custom typing code for decorating server -server.decorate('server', 'some_server_method', (server: Hapi.Server) => { - return function(arg1: number){ +server.decorate("server", "some_server_method", (server: Hapi.Server) => { + return function(arg1: number) { return "some text"; - } + }; }); -declare module 'hapi' { +declare module "hapi" { interface Server { some_server_method(arg1: number): string; } diff --git a/types/hapi/v16/test/server/dependency.ts b/types/hapi/v16/test/server/dependency.ts index 1d63397cf26548..730f49876ac62e 100644 --- a/types/hapi/v16/test/server/dependency.ts +++ b/types/hapi/v16/test/server/dependency.ts @@ -1,24 +1,21 @@ - // From https://hapijs.com/api/16.1.1#serverdependencydependencies-after -import * as Hapi from 'hapi'; - -const after: Hapi.AfterDependencyLoadCallback = function (server, next) { +import * as Hapi from "hapi"; +const after: Hapi.AfterDependencyLoadCallback = function(server, next) { // Additional plugin registration logic return next(); }; -var registerFunction: Hapi.PluginFunction<{}> = function (server, options, next) { - - server.dependency('yar', after); +var registerFunction: Hapi.PluginFunction<{}> = function(server, options, next) { + server.dependency("yar", after); return next(); }; // Example 2, via attributes registerFunction.attributes = { - name: 'test', - version: '1.0.0', - dependencies: 'yar' + name: "test", + version: "1.0.0", + dependencies: "yar", }; diff --git a/types/hapi/v16/test/server/emit.ts b/types/hapi/v16/test/server/emit.ts index d248f7d4ab7331..d4aeed14aaac8a 100644 --- a/types/hapi/v16/test/server/emit.ts +++ b/types/hapi/v16/test/server/emit.ts @@ -1,12 +1,11 @@ - // From https://hapijs.com/api/16.1.1#serveremitcriteria-data-callback -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.connection({ port: 80 }); -server.event('test'); -server.on('test', (update: Update) => console.log(update)); +server.event("test"); +server.on("test", (update: Update) => console.log(update)); type Update = string; -var toSend: Update = 'hello'; -server.emit('test', toSend); +var toSend: Update = "hello"; +server.emit("test", toSend); diff --git a/types/hapi/v16/test/server/encoder.ts b/types/hapi/v16/test/server/encoder.ts index f35102b776d258..14d8e4e5274132 100644 --- a/types/hapi/v16/test/server/encoder.ts +++ b/types/hapi/v16/test/server/encoder.ts @@ -1,9 +1,8 @@ - // From https://hapijs.com/api/16.1.1#serverencoderencoding-encoder -import * as Hapi from 'hapi'; -import * as Zlib from 'zlib'; +import * as Hapi from "hapi"; +import * as Zlib from "zlib"; const server = new Hapi.Server(); server.connection({ port: 80, routes: { compression: { special: { chunkSize: 16 * 1024 } } } }); -server.encoder('special', (options) => Zlib.createGzip(options)); +server.encoder("special", (options) => Zlib.createGzip(options)); diff --git a/types/hapi/v16/test/server/event.ts b/types/hapi/v16/test/server/event.ts index f0c2215f1274c7..17f6c5cc322671 100644 --- a/types/hapi/v16/test/server/event.ts +++ b/types/hapi/v16/test/server/event.ts @@ -1,12 +1,11 @@ - // From https://hapijs.com/api/16.1.1#servereventevents -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.connection({ port: 80 }); -server.event('test'); -server.on('test', (update: Update) => console.log(update)); +server.event("test"); +server.on("test", (update: Update) => console.log(update)); type Update = string; -var toSend: Update = 'hello'; -server.emit('test', toSend); +var toSend: Update = "hello"; +server.emit("test", toSend); diff --git a/types/hapi/v16/test/server/expose.ts b/types/hapi/v16/test/server/expose.ts index effbc1ae49e852..6c437d2c670aee 100644 --- a/types/hapi/v16/test/server/expose.ts +++ b/types/hapi/v16/test/server/expose.ts @@ -1,17 +1,20 @@ - // From https://hapijs.com/api/16.1.1#serverexposekey-value -import * as Hapi from 'hapi'; -var register: Hapi.PluginFunction<{}> = function (server, options, next) { - - server.expose('util', function () { console.log('something'); }); +import * as Hapi from "hapi"; +var register: Hapi.PluginFunction<{}> = function(server, options, next) { + server.expose("util", function() { + console.log("something"); + }); return next(); }; // example of `expose()` merging object -register = function (server, options, next) { - - server.expose({ util: function () { console.log('something'); } }); +register = function(server, options, next) { + server.expose({ + util: function() { + console.log("something"); + }, + }); return next(); }; diff --git a/types/hapi/v16/test/server/ext.ts b/types/hapi/v16/test/server/ext.ts index 500ac1d4af4153..f89813725d4a9f 100644 --- a/types/hapi/v16/test/server/ext.ts +++ b/types/hapi/v16/test/server/ext.ts @@ -1,46 +1,40 @@ - // From https://hapijs.com/api/16.1.1#serverextevents -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.connection({ port: 80 }); server.ext({ - type: 'onRequest', - method: function (request, reply) { - + type: "onRequest", + method: function(request, reply) { // Change all requests to '/test' - request.setUrl('/test'); + request.setUrl("/test"); return reply.continue(); - } + }, }); -var handler: Hapi.RouteHandler = function (request, reply) { - - return reply({ status: 'ok' }); +var handler: Hapi.RouteHandler = function(request, reply) { + return reply({ status: "ok" }); }; -server.route({ method: 'GET', path: '/test', handler: handler }); -server.start((err) => { }); +server.route({ method: "GET", path: "/test", handler: handler }); +server.start((err) => {}); // All requests will get routed to '/test' - // Example 2 -server.ext('onRequest', function (request, reply) { - +server.ext("onRequest", function(request, reply) { // Change all requests to '/test' - request.setUrl('/test'); + request.setUrl("/test"); return reply.continue(); }); -handler = function (request, reply) { - - return reply({ status: 'ok' }); +handler = function(request, reply) { + return reply({ status: "ok" }); }; -server.route({ method: 'GET', path: '/test', handler: handler }); -server.start((err) => { }); +server.route({ method: "GET", path: "/test", handler: handler }); +server.start((err) => {}); // All requests will get routed to '/test' diff --git a/types/hapi/v16/test/server/handler.ts b/types/hapi/v16/test/server/handler.ts index 957e2c33b890e3..05954f0b385261 100644 --- a/types/hapi/v16/test/server/handler.ts +++ b/types/hapi/v16/test/server/handler.ts @@ -1,55 +1,50 @@ - // From https://hapijs.com/api/16.1.1#serverhandlername-method -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); -server.connection({ host: 'localhost', port: 8000 }); +server.connection({ host: "localhost", port: 8000 }); // Defines new handler for routes on this server -var handler: Hapi.MakeRouteHandler = function (route, options) { - - return function (request, reply) { - - return reply('new handler: ' + options.msg); - } +var handler: Hapi.MakeRouteHandler = function(route, options) { + return function(request, reply) { + return reply("new handler: " + options.msg); + }; }; -server.handler('test', handler); +server.handler("test", handler); interface TestPluginConfig { msg: string; } -declare module 'hapi' { +declare module "hapi" { interface RouteHandlerPlugins { test?: TestPluginConfig | undefined; } } server.route({ - method: 'GET', - path: '/', - handler: { test: { msg: 'test' } } + method: "GET", + path: "/", + handler: { test: { msg: "test" } }, }); -server.start(function (err) { }); +server.start(function(err) {}); // example 2 -handler = function (route, options: TestPluginConfig) { - - return function (request, reply) { - - return reply('new handler: ' + options.msg); - } +handler = function(route, options: TestPluginConfig) { + return function(request, reply) { + return reply("new handler: " + options.msg); + }; }; // Change the default payload processing for this handler handler.defaults = { payload: { - output: 'stream', - parse: false - } + output: "stream", + parse: false, + }, }; -server.handler('test', handler); +server.handler("test", handler); diff --git a/types/hapi/v16/test/server/info.ts b/types/hapi/v16/test/server/info.ts index eaf1b397479dc3..14e2cf87026eea 100644 --- a/types/hapi/v16/test/server/info.ts +++ b/types/hapi/v16/test/server/info.ts @@ -1,13 +1,12 @@ - // From https://hapijs.com/api/16.1.1#serverinfo -import assert = require('assert'); -import * as Hapi from 'hapi'; +import assert = require("assert"); +import * as Hapi from "hapi"; const server = new Hapi.Server(); var options: Hapi.ServerConnectionOptions = { port: 80 }; server.connection(options); -if(server.info) assert(server.info.port === 80); +if (server.info) assert(server.info.port === 80); options = { port: 8080 }; server.connection(options); diff --git a/types/hapi/v16/test/server/initialize.ts b/types/hapi/v16/test/server/initialize.ts index a8c13c2e953879..cf5ca333ef41c6 100644 --- a/types/hapi/v16/test/server/initialize.ts +++ b/types/hapi/v16/test/server/initialize.ts @@ -1,12 +1,10 @@ - // From https://hapijs.com/api/16.1.1#serverinitializecallback -import * as Hapi from 'hapi'; -import * as Hoek from 'hoek'; +import * as Hapi from "hapi"; +import * as Hoek from "hoek"; const server = new Hapi.Server(); server.connection({ port: 80 }); server.initialize((err) => { - Hoek.assert(!err, err); }); diff --git a/types/hapi/v16/test/server/inject.ts b/types/hapi/v16/test/server/inject.ts index 7010faa3dc0f58..5633903ddb05ce 100644 --- a/types/hapi/v16/test/server/inject.ts +++ b/types/hapi/v16/test/server/inject.ts @@ -1,19 +1,17 @@ - // From https://hapijs.com/api/16.1.1#serverinjectoptions-callback -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.connection({ port: 80 }); -const handler: Hapi.RouteHandler = function (request, reply) { - - return reply('Success!'); +const handler: Hapi.RouteHandler = function(request, reply) { + return reply("Success!"); }; -server.route({ method: 'GET', path: '/', handler: handler }); +server.route({ method: "GET", path: "/", handler: handler }); -server.inject('/', (res) => { +server.inject("/", (res) => { const num: number = res.statusCode; - const result = res.result as {aField: string}; + const result = res.result as { aField: string }; console.log(res.result); }); diff --git a/types/hapi/v16/test/server/load.ts b/types/hapi/v16/test/server/load.ts index ee204c864f4b08..c5095c58576b72 100644 --- a/types/hapi/v16/test/server/load.ts +++ b/types/hapi/v16/test/server/load.ts @@ -1,7 +1,6 @@ - // From https://hapijs.com/api/16.1.1#serverload -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server({ load: { sampleInterval: 1000 } }); var d: number = server.load.rss; diff --git a/types/hapi/v16/test/server/log.ts b/types/hapi/v16/test/server/log.ts index 4507358d60d906..fea6eb90353d8a 100644 --- a/types/hapi/v16/test/server/log.ts +++ b/types/hapi/v16/test/server/log.ts @@ -1,15 +1,13 @@ - // From https://hapijs.com/api/16.1.1#serverlogtags-data-timestamp -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.connection({ port: 80 }); -server.on('log', (event, tags) => { - +server.on("log", (event, tags) => { if (tags.error) { console.log(event); } }); -server.log(['test', 'error'], 'Test event'); +server.log(["test", "error"], "Test event"); diff --git a/types/hapi/v16/test/server/lookup.ts b/types/hapi/v16/test/server/lookup.ts index 89ce852700a635..6643cb8c36bf6b 100644 --- a/types/hapi/v16/test/server/lookup.ts +++ b/types/hapi/v16/test/server/lookup.ts @@ -1,19 +1,17 @@ - // From https://hapijs.com/api/16.1.1#serverlookupid -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.connection(); server.route({ - method: 'GET', - path: '/', + method: "GET", + path: "/", config: { - handler: function (request, reply) { - + handler: function(request, reply) { return reply(); }, - id: 'root' - } + id: "root", + }, }); -const route = server.lookup('root'); +const route = server.lookup("root"); diff --git a/types/hapi/v16/test/server/match.ts b/types/hapi/v16/test/server/match.ts index f322a314944b6e..ec5bd48d23d712 100644 --- a/types/hapi/v16/test/server/match.ts +++ b/types/hapi/v16/test/server/match.ts @@ -1,19 +1,17 @@ - // From https://hapijs.com/api/16.1.1#servermatchmethod-path-host -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.connection(); server.route({ - method: 'GET', - path: '/', + method: "GET", + path: "/", config: { - handler: function (request, reply) { - + handler: function(request, reply) { return reply(); }, - id: 'root' - } + id: "root", + }, }); -const route = server.match('get', '/'); +const route = server.match("get", "/"); diff --git a/types/hapi/v16/test/server/method.ts b/types/hapi/v16/test/server/method.ts index e1cc2ce4872f2e..b686ce863de0a1 100644 --- a/types/hapi/v16/test/server/method.ts +++ b/types/hapi/v16/test/server/method.ts @@ -1,63 +1,54 @@ - // From https://hapijs.com/api/16.1.1#servermethodname-method-options -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.connection({ port: 80 }); // Simple arguments -const add = function (a: number, b: number, next: Hapi.ServerMethodNext) { - +const add = function(a: number, b: number, next: Hapi.ServerMethodNext) { return next(null, a + b); }; -server.method('sum', add, { cache: { expiresIn: 2000, generateTimeout: 100 } }); +server.method("sum", add, { cache: { expiresIn: 2000, generateTimeout: 100 } }); var next: Hapi.ServerMethodNext = (err, result) => { - console.log(result); }; server.methods.sum(4, 5, next); // Object argument -const addArray = function (array: number[], next: Hapi.ServerMethodNext) { - +const addArray = function(array: number[], next: Hapi.ServerMethodNext) { let sum = 0; array.forEach((item) => { - sum += item; }); return next(null, sum); }; -server.method('sumObj', addArray, { +server.method("sumObj", addArray, { cache: { expiresIn: 2000, generateTimeout: 100 }, - generateKey: function (array) { - - return array.join(','); - } + generateKey: function(array) { + return array.join(","); + }, }); var next: Hapi.ServerMethodNext = (err, result) => { - console.log(result); }; server.methods.sumObj([5, 6], next); // Synchronous method with cache -const addSync = function (a: number, b: number) { - +const addSync = function(a: number, b: number) { return a + b; }; -server.method('sumSync', addSync, { cache: { expiresIn: 2000, generateTimeout: 100 }, callback: false }); +server.method("sumSync", addSync, { cache: { expiresIn: 2000, generateTimeout: 100 }, callback: false }); var next: Hapi.ServerMethodNext = (err, result) => { - console.log(result); }; server.methods.sumSync(4, 5, next); @@ -65,32 +56,32 @@ server.methods.sumSync(4, 5, next); // server.method(methods) var config = { - name: 'sum', + name: "sum", method: add, options: { cache: { expiresIn: 2000, - generateTimeout: 100 - } - } + generateTimeout: 100, + }, + }, }; server.method(config); server.method([config]); // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18283 -const syncX1 = function (arg1: string) { +const syncX1 = function(arg1: string) { return Promise.resolve("some value" + arg1); -} +}; type SyncX1 = typeof syncX1; -const asyncX1 = function (callback: Hapi.ServerMethodNext) { +const asyncX1 = function(callback: Hapi.ServerMethodNext) { callback(null, "result"); -} +}; type AsyncX1 = typeof asyncX1; server.method("MethodSyncX1", syncX1); server.method("MethodAsyncX1", asyncX1); (server.methods.MethodSyncX1 as SyncX1)("argument1") as Promise; -const cb: Hapi.ServerMethodNext = (err, result, ttl) => {} +const cb: Hapi.ServerMethodNext = (err, result, ttl) => {}; (server.methods.MethodAsyncX1 as AsyncX1)(cb) as void; diff --git a/types/hapi/v16/test/server/methods.ts b/types/hapi/v16/test/server/methods.ts index 1e2060c3e887f5..df57f82b871ca5 100644 --- a/types/hapi/v16/test/server/methods.ts +++ b/types/hapi/v16/test/server/methods.ts @@ -1,17 +1,14 @@ - // From https://hapijs.com/api/16.1.1#servermethods -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); -const add = function (a: number, b: number, next: (err: Error | null, result: number) => void) { - +const add = function(a: number, b: number, next: (err: Error | null, result: number) => void) { return next(null, a + b); }; -server.method('add', add); +server.method("add", add); server.methods.add(1, 2, (err: Error | null, result: number) => { - // result === 3 }); diff --git a/types/hapi/v16/test/server/mime.ts b/types/hapi/v16/test/server/mime.ts index 356a663579d087..9b1b63559efbd7 100644 --- a/types/hapi/v16/test/server/mime.ts +++ b/types/hapi/v16/test/server/mime.ts @@ -1,21 +1,20 @@ - // From https://hapijs.com/api/16.1.1#servermime -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const options: Hapi.ServerOptions = { mime: { override: { - 'node/module': { - source: 'apache', + "node/module": { + source: "apache", compressible: false, - extensions: ['node', 'module', 'npm'], - type: 'node/module' - } - } - } + extensions: ["node", "module", "npm"], + type: "node/module", + }, + }, + }, }; const server = new Hapi.Server(options); -server.mime.path('code.js').type === 'application/javascript'; -server.mime.path('file.npm').type === 'node/module'; +server.mime.path("code.js").type === "application/javascript"; +server.mime.path("file.npm").type === "node/module"; diff --git a/types/hapi/v16/test/server/new.ts b/types/hapi/v16/test/server/new.ts index eb5ffc51b0a24d..32f0150d87940f 100644 --- a/types/hapi/v16/test/server/new.ts +++ b/types/hapi/v16/test/server/new.ts @@ -1,57 +1,57 @@ -'use strict'; +"use strict"; -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; new Hapi.Server(); new Hapi.Server({ - app: {some: 'values'}, - cache: require('catbox-redis'), + app: { some: "values" }, + cache: require("catbox-redis"), }); const server = new Hapi.Server({ - cache: require('catbox-redis'), + cache: require("catbox-redis"), load: { - sampleInterval: 1000 - } + sampleInterval: 1000, + }, }); // Specific cache configuration options new Hapi.Server({ cache: { - engine: require('catbox-redis'), - // name: 'optionally omitted when only a single cache used', - } + engine: require("catbox-redis"), + // name: 'optionally omitted when only a single cache used', + }, }); new Hapi.Server({ cache: [{ - engine: require('catbox-redis'), - name: 'unique 1', - }, - { - engine: require('catbox-redis'), - name: 'unique 2', + engine: require("catbox-redis"), + name: "unique 1", + }, { + engine: require("catbox-redis"), + name: "unique 2", shared: true, - otherOptions: 'will be passed to the catbox strategy', - }] + otherOptions: "will be passed to the catbox strategy", + }], }); new Hapi.Server({ - cache: [{ - engine: require('catbox-redis'), - }, - // Does not correctly error but will be caught by hapi at runtime - { - engine: require('catbox-redis'), - }] + cache: [ + { + engine: require("catbox-redis"), + }, // Does not correctly error but will be caught by hapi at runtime + { + engine: require("catbox-redis"), + }, + ], }); -//+ Code added in addition to docs -declare module 'hapi' { +// + Code added in addition to docs +declare module "hapi" { interface PluginSpecificConfiguration { // Set this to non optional if plugin config is non optional - 'some-plugin-name'?: {options: string;} | undefined; + "some-plugin-name"?: { options: string } | undefined; } } -//- Code added in addition to docs +// - Code added in addition to docs new Hapi.Server({ connections: { @@ -63,13 +63,13 @@ new Hapi.Server({ maxEventLoopDelay: 10, }, plugins: { - 'some-plugin-name': {options: 'here'}, - coolPlugin: {optionA: ""}, + "some-plugin-name": { options: "here" }, + coolPlugin: { optionA: "" }, }, router: { isCaseSensitive: false, stripTrailingSlash: true, }, - routes: {} - } -}) + routes: {}, + }, +}); diff --git a/types/hapi/v16/test/server/on.ts b/types/hapi/v16/test/server/on.ts index 08802fda96fbd8..0e8a1570e24db0 100644 --- a/types/hapi/v16/test/server/on.ts +++ b/types/hapi/v16/test/server/on.ts @@ -1,43 +1,37 @@ - // From https://hapijs.com/api/16.1.1#serveroncriteria-listener // From https://hapijs.com/api/16.1.1#server-events -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.connection({ port: 80 }); -server.event('test'); -server.on('test', (update: Update) => console.log(update)); +server.event("test"); +server.on("test", (update: Update) => console.log(update)); type Update = string; -var toSend: Update = 'hello'; -server.emit('test', toSend); - -server.on('log', (event, tags) => { +var toSend: Update = "hello"; +server.emit("test", toSend); +server.on("log", (event, tags) => { if (tags.error) { - console.log('Server error: ' + (event.data || 'unspecified')); + console.log("Server error: " + (event.data || "unspecified")); } }); -server.on('request', (request, event, tags) => { - +server.on("request", (request, event, tags) => { if (tags.received) { - console.log('New request: ' + request.id); + console.log("New request: " + request.id); } }); -server.on('request-error', (request, err) => { - - console.log('Error response (500) sent for request: ' + request.id + ' because: ' + err.message); +server.on("request-error", (request, err) => { + console.log("Error response (500) sent for request: " + request.id + " because: " + err.message); }); -server.on('response', (request) => { - - console.log('Response sent for request: ' + request.id); +server.on("response", (request) => { + console.log("Response sent for request: " + request.id); }); -server.on('route', (route, connection, server) => { - - console.log('New route added: ' + route.path); +server.on("route", (route, connection, server) => { + console.log("New route added: " + route.path); }); diff --git a/types/hapi/v16/test/server/once.ts b/types/hapi/v16/test/server/once.ts index 55fdb08ec23593..e1ea52c51a1acb 100644 --- a/types/hapi/v16/test/server/once.ts +++ b/types/hapi/v16/test/server/once.ts @@ -1,14 +1,13 @@ - // From https://hapijs.com/api/16.1.1#serveroncecriteria-listener -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.connection({ port: 80 }); -server.event('test'); -server.once('test', (update: Update) => console.log(update)); +server.event("test"); +server.once("test", (update: Update) => console.log(update)); type Update = string; -var toSend: Update = 'hello'; -server.emit('test', toSend); -server.emit('test', toSend); // Ignored +var toSend: Update = "hello"; +server.emit("test", toSend); +server.emit("test", toSend); // Ignored diff --git a/types/hapi/v16/test/server/path.ts b/types/hapi/v16/test/server/path.ts index 2f76e42cf57539..931e930278a29f 100644 --- a/types/hapi/v16/test/server/path.ts +++ b/types/hapi/v16/test/server/path.ts @@ -1,13 +1,11 @@ - // From https://hapijs.com/api/16.1.1#serverpathrelativeto -import * as Hapi from 'hapi'; - -var register: Hapi.PluginFunction<{}> = function (server, options, next) { +import * as Hapi from "hapi"; +var register: Hapi.PluginFunction<{}> = function(server, options, next) { // Assuming the Inert plugin was registered previously - server.path(__dirname + '../static'); - server.route({ path: '/file', method: 'GET', handler() {} }); + server.path(__dirname + "../static"); + server.route({ path: "/file", method: "GET", handler() {} }); next(); }; diff --git a/types/hapi/v16/test/server/plugins.ts b/types/hapi/v16/test/server/plugins.ts index 2ce13ffb2f9b35..ef850f1ab3cc16 100644 --- a/types/hapi/v16/test/server/plugins.ts +++ b/types/hapi/v16/test/server/plugins.ts @@ -1,15 +1,13 @@ - // From https://hapijs.com/api/16.1.1#serverplugins -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; var registerFunction: Hapi.PluginFunction<{}> = function(server, options, next) { - - server.expose('key', 'value'); - server.plugins.example.key === 'value'; + server.expose("key", "value"); + server.plugins.example.key === "value"; return next(); }; registerFunction.attributes = { - name: 'example' + name: "example", }; diff --git a/types/hapi/v16/test/server/realm.ts b/types/hapi/v16/test/server/realm.ts index 31f764b7ef5420..164df6ad04edab 100644 --- a/types/hapi/v16/test/server/realm.ts +++ b/types/hapi/v16/test/server/realm.ts @@ -1,10 +1,8 @@ - // From https://hapijs.com/api/16.1.1#serverrealm -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; var registerFunction: Hapi.PluginFunction<{}> = function(server, options, next) { - console.log(server.realm.modifiers.route.prefix); return next(); }; diff --git a/types/hapi/v16/test/server/register.ts b/types/hapi/v16/test/server/register.ts index c04e0b16bcbdf9..6be5d099c56a09 100644 --- a/types/hapi/v16/test/server/register.ts +++ b/types/hapi/v16/test/server/register.ts @@ -1,18 +1,16 @@ - // From https://hapijs.com/api/16.1.1#serverregisterplugins-options-callback -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.register({ - register: require('plugin_name'), + register: require("plugin_name"), options: { - message: 'hello' - } + message: "hello", + }, }, (err) => { - if (err) { - console.log('Failed loading plugin'); + console.log("Failed loading plugin"); } }); diff --git a/types/hapi/v16/test/server/route.ts b/types/hapi/v16/test/server/route.ts index 0402fd3e898d5c..15915ca2232062 100644 --- a/types/hapi/v16/test/server/route.ts +++ b/types/hapi/v16/test/server/route.ts @@ -1,12 +1,29 @@ - // From https://hapijs.com/api/16.1.1#serverrouteoptions -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.connection({ port: 80 }); -server.route({ method: 'GET', path: '/', handler: function (request, reply) { return reply('ok'); } }); +server.route({ + method: "GET", + path: "/", + handler: function(request, reply) { + return reply("ok"); + }, +}); server.route([ - { method: 'GET', path: '/1', handler: function (request, reply) { return reply('ok'); } }, - { method: 'GET', path: '/2', handler: function (request, reply) { return reply('ok'); } } + { + method: "GET", + path: "/1", + handler: function(request, reply) { + return reply("ok"); + }, + }, + { + method: "GET", + path: "/2", + handler: function(request, reply) { + return reply("ok"); + }, + }, ]); diff --git a/types/hapi/v16/test/server/select.ts b/types/hapi/v16/test/server/select.ts index 8a25f45abd4bef..8c6beb7d251521 100644 --- a/types/hapi/v16/test/server/select.ts +++ b/types/hapi/v16/test/server/select.ts @@ -1,11 +1,10 @@ - // From https://hapijs.com/api/16.1.1#serverselectlabels -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); -server.connection({ port: 80, labels: ['a', 'b'] }); -server.connection({ port: 8080, labels: ['a', 'c'] }); -server.connection({ port: 8081, labels: ['b', 'c'] }); +server.connection({ port: 80, labels: ["a", "b"] }); +server.connection({ port: 8080, labels: ["a", "c"] }); +server.connection({ port: 8081, labels: ["b", "c"] }); -const a = server.select('a'); // 80, 8080 -const ac = a.select('c'); // 8080 +const a = server.select("a"); // 80, 8080 +const ac = a.select("c"); // 8080 diff --git a/types/hapi/v16/test/server/settings.ts b/types/hapi/v16/test/server/settings.ts index 7f716693121b4f..92be5fb074bfe3 100644 --- a/types/hapi/v16/test/server/settings.ts +++ b/types/hapi/v16/test/server/settings.ts @@ -1,11 +1,10 @@ - // From https://hapijs.com/api/16.1.1#serversettings -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server({ app: { - key: 'value' - } + key: "value", + }, }); -server.settings.app.key === 'value'; +server.settings.app.key === "value"; diff --git a/types/hapi/v16/test/server/start.ts b/types/hapi/v16/test/server/start.ts index a15bb797404b82..d0cb0ffe4bb135 100644 --- a/types/hapi/v16/test/server/start.ts +++ b/types/hapi/v16/test/server/start.ts @@ -1,13 +1,11 @@ - // From https://hapijs.com/api/16.1.1#serverstartcallback -import * as Hapi from 'hapi'; -import * as Hoek from 'hoek'; +import * as Hapi from "hapi"; +import * as Hoek from "hoek"; const server = new Hapi.Server(); server.connection({ port: 80 }); server.start((err) => { - Hoek.assert(!err, err!); - console.log('Server started at: ' + server.info!.uri); + console.log("Server started at: " + server.info!.uri); }); diff --git a/types/hapi/v16/test/server/state.ts b/types/hapi/v16/test/server/state.ts index 2035343a17fa2c..25b67f2f9d88f5 100644 --- a/types/hapi/v16/test/server/state.ts +++ b/types/hapi/v16/test/server/state.ts @@ -1,37 +1,34 @@ - // From https://hapijs.com/api/16.1.1#serverstatename-options -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.connection({ port: 80 }); // Set cookie definition -server.state('session', { - ttl: 24 * 60 * 60 * 1000, // One day +server.state("session", { + ttl: 24 * 60 * 60 * 1000, // One day isSecure: true, - path: '/', - encoding: 'base64json' + path: "/", + encoding: "base64json", }); // Set state in route handler -const handler: Hapi.RouteHandler = function (request, reply) { - +const handler: Hapi.RouteHandler = function(request, reply) { let session = request.state.session; if (!session) { - session = { user: 'joe' }; + session = { user: "joe" }; } session.last = Date.now(); - return reply('Success').state('session', session); + return reply("Success").state("session", session); }; // Example 2 -server.on('request-internal', (request, event, tags) => { - +server.on("request-internal", (request, event, tags) => { if (tags.error && tags.state) { console.error(event); } diff --git a/types/hapi/v16/test/server/stop.ts b/types/hapi/v16/test/server/stop.ts index ddfd07aa8f244a..7e0656315343be 100644 --- a/types/hapi/v16/test/server/stop.ts +++ b/types/hapi/v16/test/server/stop.ts @@ -1,11 +1,9 @@ - // From https://hapijs.com/api/16.1.1#serverstopoptions-callback -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); server.connection({ port: 80 }); server.stop({ timeout: 60 * 1000 }, (err) => { - - console.log('Server stopped'); + console.log("Server stopped"); }); diff --git a/types/hapi/v16/test/server/table.ts b/types/hapi/v16/test/server/table.ts index abe0707c769654..a84a2311c941e8 100644 --- a/types/hapi/v16/test/server/table.ts +++ b/types/hapi/v16/test/server/table.ts @@ -1,9 +1,14 @@ - // From https://hapijs.com/api/16.1.1#servertablehost -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); -server.connection({ port: 80, host: 'example.com' }); -server.route({ method: 'GET', path: '/example', handler: function (request, reply) { return reply(); } }); +server.connection({ port: 80, host: "example.com" }); +server.route({ + method: "GET", + path: "/example", + handler: function(request, reply) { + return reply(); + }, +}); const table = server.table(); diff --git a/types/hapi/v16/test/server/version.ts b/types/hapi/v16/test/server/version.ts index 064e87e3cd006f..10c4bef561e4ec 100644 --- a/types/hapi/v16/test/server/version.ts +++ b/types/hapi/v16/test/server/version.ts @@ -1,6 +1,5 @@ - // From http://hapijs.com/api#serversettings -import * as Hapi from 'hapi'; +import * as Hapi from "hapi"; const server = new Hapi.Server(); -server.version === '8.0.0' +server.version === "8.0.0"; diff --git a/types/hapi/v17/index.d.ts b/types/hapi/v17/index.d.ts index fc394249bae9a4..a4e99a7f87e998 100644 --- a/types/hapi/v17/index.d.ts +++ b/types/hapi/v17/index.d.ts @@ -19,19 +19,19 @@ /// -import * as Boom from 'boom'; -import * as http from 'http'; -import * as https from 'https'; -import * as Shot from 'shot'; -import * as stream from 'stream'; -import * as url from 'url'; -import * as zlib from 'zlib'; - -import { MimosOptions } from 'mimos'; -import { SealOptions, SealOptionsSub } from 'iron'; -import { ValidationOptions, SchemaMap, Schema } from 'joi'; -import Podium = require('podium'); -import { PolicyOptionVariants, EnginePrototypeOrObject, PolicyOptions, EnginePrototype, Policy } from 'catbox'; +import * as Boom from "boom"; +import * as http from "http"; +import * as https from "https"; +import * as Shot from "shot"; +import * as stream from "stream"; +import * as url from "url"; +import * as zlib from "zlib"; + +import { SealOptions, SealOptionsSub } from "iron"; +import { Schema, SchemaMap, ValidationOptions } from "joi"; +import { MimosOptions } from "mimos"; +import Podium = require("podium"); +import { EnginePrototype, EnginePrototypeOrObject, Policy, PolicyOptions, PolicyOptionVariants } from "catbox"; /* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -238,7 +238,7 @@ export interface RequestAuth { * 'disconnect' - emitted when a request errors or aborts unexpectedly. * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestevents) */ -export type RequestEventType = 'peek' | 'finish' | 'disconnect'; +export type RequestEventType = "peek" | "finish" | "disconnect"; /** * Access: read only and the public podium interface. @@ -257,9 +257,9 @@ export interface RequestEvents extends Podium { * * 'disconnect' - emitted when a request errors or aborts unexpectedly. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestevents) */ - on(criteria: 'peek', listener: PeekListener): void; + on(criteria: "peek", listener: PeekListener): void; - on(criteria: 'finish' | 'disconnect', listener: (data: undefined) => void): void; + on(criteria: "finish" | "disconnect", listener: (data: undefined) => void): void; /** * Access: read only and the public podium interface. @@ -269,9 +269,9 @@ export interface RequestEvents extends Podium { * * 'disconnect' - emitted when a request errors or aborts unexpectedly. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestevents) */ - once(criteria: 'peek', listener: PeekListener): void; + once(criteria: "peek", listener: PeekListener): void; - once(criteria: 'finish' | 'disconnect', listener: (data: undefined) => void): void; + once(criteria: "finish" | "disconnect", listener: (data: undefined) => void): void; } /** @@ -566,7 +566,15 @@ export interface Request extends Podium { * @return ResponseObject * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestgenerateresponsesource-options) */ - generateResponse(source: string | object | null, options?: { variety?: string | undefined; prepare?: ((response: ResponseObject) => Promise) | undefined; marshal?: ((response: ResponseObject) => Promise) | undefined; close?: ((response: ResponseObject) => void) | undefined; }): ResponseObject; + generateResponse( + source: string | object | null, + options?: { + variety?: string | undefined; + prepare?: ((response: ResponseObject) => Promise) | undefined; + marshal?: ((response: ResponseObject) => Promise) | undefined; + close?: ((response: ResponseObject) => void) | undefined; + }, + ): ResponseObject; /** * Logs request-specific events. When called, the server emits a 'request' event which can be used by other listeners or plugins. The arguments are: @@ -623,17 +631,17 @@ export interface ResponseEvents extends Podium { * 'peek' - emitted for each chunk of data written back to the client connection. The event method signature is function(chunk, encoding). * 'finish' - emitted when the response finished writing but before the client response connection is ended. The event method signature is function (). */ - on(criteria: 'peek', listener: PeekListener): void; + on(criteria: "peek", listener: PeekListener): void; - on(criteria: 'finish', listener: (data: undefined) => void): void; + on(criteria: "finish", listener: (data: undefined) => void): void; /** * 'peek' - emitted for each chunk of data written back to the client connection. The event method signature is function(chunk, encoding). * 'finish' - emitted when the response finished writing but before the client response connection is ended. The event method signature is function (). */ - once(criteria: 'peek', listener: PeekListener): void; + once(criteria: "peek", listener: PeekListener): void; - once(criteria: 'finish', listener: (data: undefined) => void): void; + once(criteria: "finish", listener: (data: undefined) => void): void; } /** @@ -717,7 +725,7 @@ export interface ResponseObject extends Podium { * * 'stream' - a Stream. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsevariety) */ - readonly variety: 'plain' | 'buffer' | 'stream'; + readonly variety: "plain" | "buffer" | "stream"; /** * Sets the HTTP 'Content-Length' header (to avoid chunked transfer encoding) where: @@ -773,7 +781,7 @@ export interface ResponseObject extends Podium { * @return Return value: the current response object. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseencodingencoding) */ - encoding(encoding: 'ascii' | 'utf8' | 'utf16le' | 'ucs2' | 'base64' | 'latin1' | 'binary' | 'hex'): ResponseObject; + encoding(encoding: "ascii" | "utf8" | "utf16le" | "ucs2" | "base64" | "latin1" | "binary" | "hex"): ResponseObject; /** * Sets the representation entity tag where: @@ -785,7 +793,7 @@ export interface ResponseObject extends Podium { * @return Return value: the current response object. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseetagtag-options) */ - etag(tag: string, options?: {weak: boolean, vary: boolean}): ResponseObject; + etag(tag: string, options?: { weak: boolean; vary: boolean }): ResponseObject; /** * Sets an HTTP header where: @@ -957,7 +965,6 @@ export interface ResponseSettings { /** * See more about Lifecycle * https://github.com/hapijs/hapi/blob/master/API.md#request-lifecycle - * */ export type ResponseValue = string | object; @@ -1042,7 +1049,9 @@ export interface ResponseToolkit { * it should be used as the return value (but may be customize using the response methods). * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-hentityoptions) */ - entity(options?: {etag?: string | undefined, modified?: string | undefined, vary?: boolean | undefined}): ResponseObject | undefined; + entity( + options?: { etag?: string | undefined; modified?: string | undefined; vary?: boolean | undefined }, + ): ResponseObject | undefined; /** * Redirects the client to the specified uri. Same as calling h.response().redirect(uri). @@ -1108,7 +1117,7 @@ export interface ResponseToolkit { export type RouteOptionsAccessScope = false | string | string[]; -export type RouteOptionsAccessEntity = 'any' | 'user' | 'app'; +export type RouteOptionsAccessEntity = "any" | "user" | "app"; export interface RouteOptionsAccessScopeObject { scope: RouteOptionsAccessScope; @@ -1119,7 +1128,7 @@ export interface RouteOptionsAccessEntityObject { } export type RouteOptionsAccessObject = - RouteOptionsAccessScopeObject + | RouteOptionsAccessScopeObject | RouteOptionsAccessEntityObject | (RouteOptionsAccessScopeObject & RouteOptionsAccessEntityObject); @@ -1164,7 +1173,7 @@ export interface RouteOptionsAccess { * * 'try' - similar to 'optional', any request credentials are attempted authentication, but if the credentials are invalid, the request proceeds regardless of the authentication error. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthmode) */ - mode?: 'required' | 'optional' | 'try' | undefined; + mode?: "required" | "optional" | "try" | undefined; /** * Default value: false, unless the scheme requires payload authentication. @@ -1175,7 +1184,7 @@ export interface RouteOptionsAccess { * * 'optional' - payload authentication performed only when the client includes payload authentication information (e.g. hash attribute in Hawk). * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthpayload) */ - payload?: false | 'required' | 'optional' | undefined; + payload?: false | "required" | "optional" | undefined; /** * Default value: the default strategy set via server.auth.default(). @@ -1203,21 +1212,23 @@ export interface RouteOptionsAccess { * * otherwise - a string with the value of the 'Cache-Control' header when caching is disabled. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionscache) */ -export type RouteOptionsCache = { - privacy?: 'default' | 'public' | 'private' | undefined; - statuses?: number[] | undefined; - otherwise?: string | undefined; -} & ( - { - expiresIn?: number | undefined; - expiresAt?: undefined; - } | { - expiresIn?: undefined; - expiresAt?: string | undefined; -} | { - expiresIn?: undefined; - expiresAt?: undefined; -} +export type RouteOptionsCache = + & { + privacy?: "default" | "public" | "private" | undefined; + statuses?: number[] | undefined; + otherwise?: string | undefined; + } + & ( + { + expiresIn?: number | undefined; + expiresAt?: undefined; + } | { + expiresIn?: undefined; + expiresAt?: string | undefined; + } | { + expiresIn?: undefined; + expiresAt?: undefined; + } ); /** @@ -1242,7 +1253,7 @@ export interface RouteOptionsCors { * character, or a single '*' origin string. If set to 'ignore', any incoming Origin header is ignored (present or not) and the 'Access-Control-Allow-Origin' header is set to '*'. Defaults to any * origin ['*']. */ - origin?: string[] | '*' | 'ignore' | undefined; + origin?: string[] | "*" | "ignore" | undefined; /** * number of seconds the browser should cache the CORS response ('Access-Control-Max-Age'). The greater the value, the longer it will take before the browser checks for changes in policy. * Defaults to 86400 (one day). @@ -1283,7 +1294,7 @@ export interface RouteOptionsCors { * which files are used (e.g. using the request.app object), and listening to the server 'response' event to perform cleanup. For context [See * docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadoutput) */ -export type PayloadOutput = 'data' | 'stream' | 'file'; +export type PayloadOutput = "data" | "stream" | "file"; /** * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadcompression) @@ -1350,7 +1361,7 @@ export interface RouteOptionsPayload { * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadmultipart) */ multipart?: false | { - output: PayloadOutput | 'annotated'; + output: PayloadOutput | "annotated"; } | undefined; /** @@ -1385,7 +1396,7 @@ export interface RouteOptionsPayload { * * 'gunzip' - the raw payload is returned unmodified after any known content encoding is decoded. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadparse) */ - parse?: boolean | 'gunzip' | undefined; + parse?: boolean | "gunzip" | undefined; /** * Default value: to 10000 (10 seconds). @@ -1438,7 +1449,7 @@ export interface RouteOptionsPreObject { export type ValidationObject = SchemaMap; export type RouteOptionsResponseSchema = - boolean + | boolean | ValidationObject | Schema | ((value: object | Buffer | string, options: ValidationOptions) => Promise); @@ -1519,8 +1530,16 @@ export interface RouteOptionsResponse { /** * @see https://www.w3.org/TR/referrer-policy/ */ -export type ReferrerPolicy = '' | 'no-referrer' | 'no-referrer-when-downgrade' | 'unsafe-url' | - 'same-origin' | 'origin' | 'strict-origin' | 'origin-when-cross-origin' | 'strict-origin-when-cross-origin'; +export type ReferrerPolicy = + | "" + | "no-referrer" + | "no-referrer-when-downgrade" + | "unsafe-url" + | "same-origin" + | "origin" + | "strict-origin" + | "origin-when-cross-origin" + | "strict-origin-when-cross-origin"; /** * Default value: false (security headers disabled). @@ -1571,11 +1590,11 @@ export interface RouteOptionsSecureObject { /** * controls the 'X-Frame-Options' header */ - xframe?: true | 'deny' | 'sameorigin' | { + xframe?: true | "deny" | "sameorigin" | { /** * an object for specifying the 'allow-from' rule, */ - rule: 'deny' | 'sameorigin' | 'allow-from'; + rule: "deny" | "sameorigin" | "allow-from"; /** * when rule is 'allow-from' this is used to form the rest of the header, otherwise this field is ignored. If rule is 'allow-from' but source is unset, the rule will be automatically changed * to 'sameorigin'. @@ -1794,9 +1813,11 @@ export interface RouteOptions { * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsext) * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#request-lifecycle) */ - ext?: { - [key in RouteRequestExtType]?: RouteExtObject | RouteExtObject[]; - } | undefined; + ext?: + | { + [key in RouteRequestExtType]?: RouteExtObject | RouteExtObject[]; + } + | undefined; /** * Default value: { relativeTo: '.' }. @@ -2259,7 +2280,7 @@ export interface ServerEventCriteria { * * * tags - a tag string or array of tag strings. * * * all - if true, all tags must be present for the event update to match the subscription. Defaults to false (at least one matching tag). */ - filter?: string | string[] | {tags: string | string[], all?: boolean | undefined} | undefined; + filter?: string | string[] | { tags: string | string[]; all?: boolean | undefined } | undefined; /** * if true, and the data object passed to server.event.emit() is an array, the listener method is called with each array element passed as a separate argument. This should only be used * when the emitted data structure is known and predictable. Defaults to the event registration option (which defaults to false). @@ -2278,7 +2299,7 @@ export interface LogEvent { /** an array of tags identifying the event (e.g. ['error', 'http']) */ tags: string[]; /** set to 'internal' for internally generated events, otherwise 'app' for events generated by server.log() */ - channel: 'internal' | 'app'; + channel: "internal" | "app"; /** the request identifier. */ request: string; /** event-specific information. Available when event data was provided and is not an error. Errors are passed via error. */ @@ -2293,7 +2314,7 @@ export interface RequestEvent { /** an array of tags identifying the event (e.g. ['error', 'http']) */ tags: string[]; /** set to 'internal' for internally generated events, otherwise 'app' for events generated by server.log() */ - channel: 'internal' | 'app' | 'error'; + channel: "internal" | "app" | "error"; /** event-specific information. Available when event data was provided and is not an error. Errors are passed via error. */ data: object; /** the error object related to the event if applicable. Cannot appear together with data */ @@ -2351,17 +2372,17 @@ export interface ServerEvents extends Podium { * See ['start' event](https://github.com/hapijs/hapi/blob/master/API.md#-start-event) * See ['stop' event](https://github.com/hapijs/hapi/blob/master/API.md#-stop-event) */ - on(criteria: 'log' | ServerEventCriteria<'log'>, listener: LogEventHandler): void; + on(criteria: "log" | ServerEventCriteria<"log">, listener: LogEventHandler): void; - on(criteria: 'request' | ServerEventCriteria<'request'>, listener: RequestEventHandler): void; + on(criteria: "request" | ServerEventCriteria<"request">, listener: RequestEventHandler): void; - on(criteria: 'response' | ServerEventCriteria<'response'>, listener: ResponseEventHandler): void; + on(criteria: "response" | ServerEventCriteria<"response">, listener: ResponseEventHandler): void; - on(criteria: 'route' | ServerEventCriteria<'route'>, listener: RouteEventHandler): void; + on(criteria: "route" | ServerEventCriteria<"route">, listener: RouteEventHandler): void; - on(criteria: 'start' | ServerEventCriteria<'start'>, listener: StartEventHandler): void; + on(criteria: "start" | ServerEventCriteria<"start">, listener: StartEventHandler): void; - on(criteria: 'stop' | ServerEventCriteria<'stop'>, listener: StopEventHandler): void; + on(criteria: "stop" | ServerEventCriteria<"stop">, listener: StopEventHandler): void; /** * Same as calling [server.events.on()](https://github.com/hapijs/hapi/blob/master/API.md#server.events.on()) with the count option set to 1. @@ -2373,17 +2394,17 @@ export interface ServerEvents extends Podium { * @return Return value: none. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventsoncecriteria-listener) */ - once(criteria: 'log' | ServerEventCriteria<'log'>, listener: LogEventHandler): void; + once(criteria: "log" | ServerEventCriteria<"log">, listener: LogEventHandler): void; - once(criteria: 'request' | ServerEventCriteria<'request'>, listener: RequestEventHandler): void; + once(criteria: "request" | ServerEventCriteria<"request">, listener: RequestEventHandler): void; - once(criteria: 'response' | ServerEventCriteria<'response'>, listener: ResponseEventHandler): void; + once(criteria: "response" | ServerEventCriteria<"response">, listener: ResponseEventHandler): void; - once(criteria: 'route' | ServerEventCriteria<'route'>, listener: RouteEventHandler): void; + once(criteria: "route" | ServerEventCriteria<"route">, listener: RouteEventHandler): void; - once(criteria: 'start' | ServerEventCriteria<'start'>, listener: StartEventHandler): void; + once(criteria: "start" | ServerEventCriteria<"start">, listener: StartEventHandler): void; - once(criteria: 'stop' | ServerEventCriteria<'stop'>, listener: StopEventHandler): void; + once(criteria: "stop" | ServerEventCriteria<"stop">, listener: StopEventHandler): void; /** * Same as calling server.events.on() with the count option set to 1. @@ -2424,17 +2445,18 @@ export interface ServerEvents extends Podium { * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevents) * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#request-lifecycle) */ -export type ServerExtType = 'onPreStart' | 'onPostStart' | 'onPreStop' | 'onPostStop'; -export type RouteRequestExtType = 'onPreAuth' - | 'onCredentials' - | 'onPostAuth' - | 'onPreHandler' - | 'onPostHandler' - | 'onPreResponse'; +export type ServerExtType = "onPreStart" | "onPostStart" | "onPreStop" | "onPostStop"; +export type RouteRequestExtType = + | "onPreAuth" + | "onCredentials" + | "onPostAuth" + | "onPreHandler" + | "onPostHandler" + | "onPreResponse"; export type ServerRequestExtType = - RouteRequestExtType - | 'onRequest'; + | RouteRequestExtType + | "onRequest"; /** * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevents) @@ -2560,7 +2582,7 @@ export interface ServerExtOptions { * if set to 'plugin' when adding a request extension points the extension is only added to routes defined by the current plugin. Not allowed when configuring route-level extensions, or when * adding server extensions. Defaults to 'server' which applies to any route added to the server the extension is added to. */ - sandbox?: 'server' | 'plugin' | undefined; + sandbox?: "server" | "plugin" | undefined; } /** @@ -2607,7 +2629,7 @@ export interface ServerInfo { * * 'https' - HTTPS. * * 'socket' - UNIX domain socket or Windows named pipe. */ - protocol: 'http' | 'https' | 'socket'; + protocol: "http" | "https" | "socket"; /** * a string representing the connection (e.g. 'http://example.com:8080' or 'socket:/unix/domain/socket/path'). Contains @@ -2974,12 +2996,12 @@ export interface ServerOptions { // TODO I am not sure if I need to use all the server.state() definition (like the default value) OR only the options below. The v16 use "any" here. // state?: ServerStateCookieOptions; state?: { - strictHeader?: boolean | undefined, - ignoreErrors?: boolean | undefined, - isSecure?: boolean | undefined, - isHttpOnly?: boolean | undefined, - isSameSite?: false | 'Strict' | 'Lax' | undefined, - encoding?: 'none' | 'base64' | 'base64json' | 'form' | 'iron' | undefined + strictHeader?: boolean | undefined; + ignoreErrors?: boolean | undefined; + isSecure?: boolean | undefined; + isHttpOnly?: boolean | undefined; + isSameSite?: false | "Strict" | "Lax" | undefined; + encoding?: "none" | "base64" | "base64json" | "form" | "iron" | undefined; } | undefined; /** @@ -3015,7 +3037,7 @@ export interface ServerRealm { prefix: string; /** the route virtual host settings used by any calls to server.route() from the server. */ vhost: string; - } + }; }; /** the realm of the parent server object, or null for the root server. */ parent: ServerRealm | null; @@ -3090,14 +3112,18 @@ export interface ServerRegisterPluginObject extends ServerRegisterOptions { options?: T | undefined; } -export interface ServerRegisterPluginObjectArray extends Array - | ServerRegisterPluginObject - | ServerRegisterPluginObject - | ServerRegisterPluginObject - | ServerRegisterPluginObject - | ServerRegisterPluginObject - | ServerRegisterPluginObject - | undefined> { +export interface ServerRegisterPluginObjectArray extends + Array< + | ServerRegisterPluginObject + | ServerRegisterPluginObject + | ServerRegisterPluginObject + | ServerRegisterPluginObject + | ServerRegisterPluginObject + | ServerRegisterPluginObject + | ServerRegisterPluginObject + | undefined + > +{ 0: ServerRegisterPluginObject; 1?: ServerRegisterPluginObject | undefined; 2?: ServerRegisterPluginObject | undefined; @@ -3181,7 +3207,7 @@ export interface ServerStateCookieOptions { * * 'Strict' - sets the value to 'Strict' (this is the default value). * * 'Lax' - sets the value to 'Lax'. */ - isSameSite?: false | 'Strict' | 'Lax' | undefined; + isSameSite?: false | "Strict" | "Lax" | undefined; /** the path scope. Defaults to null (no path). */ path?: string | null | undefined; /** the domain scope. Defaults to null (no domain). */ @@ -3202,7 +3228,7 @@ export interface ServerStateCookieOptions { * * 'form' - object value is encoded using the x-www-form-urlencoded method. * * 'iron' - Encrypts and sign the value using iron. */ - encoding?: 'none' | 'base64' | 'base64json' | 'form' | 'iron' | undefined; + encoding?: "none" | "base64" | "base64json" | "form" | "iron" | undefined; /** * an object used to calculate an HMAC for cookie integrity validation. This does not provide privacy, only a mean * to verify that the cookie value was generated by the server. Redundant when 'iron' encoding is used. Options are: @@ -3363,15 +3389,15 @@ export class Server { /** * decorations on the request object. */ - request: string[], + request: string[]; /** * decorations on the response toolkit. */ - toolkit: string[], + toolkit: string[]; /** * decorations on the server object. */ - server: string[] + server: string[]; }; /** @@ -3450,7 +3476,7 @@ export class Server { /** * Max concurrent requests. */ - concurrent: number + concurrent: number; /** * V8 heap usage. */ @@ -3526,7 +3552,7 @@ export class Server { * * 'socket' - UNIX domain socket or Windows named pipe. * * 'tcp' - an HTTP listener. */ - readonly type: 'socket' | 'tcp'; + readonly type: "socket" | "tcp"; /** * The hapi module version number. @@ -3556,7 +3582,7 @@ export class Server { * @return Return value: none. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverdecoderencoding-decoder) */ - decoder(encoding: string, decoder: ((options: PayloadCompressionDecoderSettings) => zlib.Gunzip)): void; + decoder(encoding: string, decoder: (options: PayloadCompressionDecoderSettings) => zlib.Gunzip): void; /** * Extends various framework interfaces with custom methods where: @@ -3574,14 +3600,54 @@ export class Server { * @return void; * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverdecoratetype-property-method-options) */ - decorate(type: 'handler', property: DecorateName, method: HandlerDecorationMethod, options?: {apply?: boolean | undefined, extend?: boolean | undefined}): void; - decorate(type: 'request', property: DecorateName, method: (existing: ((...args: any[]) => any)) => (request: Request) => DecorationMethod, options: {apply: true, extend: true}): void; - decorate(type: 'request', property: DecorateName, method: (request: Request) => DecorationMethod, options: {apply: true, extend?: boolean | undefined}): void; - decorate(type: 'request', property: DecorateName, method: DecorationMethod, options?: {apply?: boolean | undefined, extend?: boolean | undefined}): void; - decorate(type: 'toolkit', property: DecorateName, method: (existing: ((...args: any[]) => any)) => DecorationMethod, options: {apply?: boolean | undefined, extend: true}): void; - decorate(type: 'toolkit', property: DecorateName, method: DecorationMethod, options?: {apply?: boolean | undefined, extend?: boolean | undefined}): void; - decorate(type: 'server', property: DecorateName, method: (existing: ((...args: any[]) => any)) => DecorationMethod, options: {apply?: boolean | undefined, extend: true}): void; - decorate(type: 'server', property: DecorateName, method: DecorationMethod, options?: {apply?: boolean | undefined, extend?: boolean | undefined}): void; + decorate( + type: "handler", + property: DecorateName, + method: HandlerDecorationMethod, + options?: { apply?: boolean | undefined; extend?: boolean | undefined }, + ): void; + decorate( + type: "request", + property: DecorateName, + method: (existing: (...args: any[]) => any) => (request: Request) => DecorationMethod, + options: { apply: true; extend: true }, + ): void; + decorate( + type: "request", + property: DecorateName, + method: (request: Request) => DecorationMethod, + options: { apply: true; extend?: boolean | undefined }, + ): void; + decorate( + type: "request", + property: DecorateName, + method: DecorationMethod, + options?: { apply?: boolean | undefined; extend?: boolean | undefined }, + ): void; + decorate( + type: "toolkit", + property: DecorateName, + method: (existing: (...args: any[]) => any) => DecorationMethod, + options: { apply?: boolean | undefined; extend: true }, + ): void; + decorate( + type: "toolkit", + property: DecorateName, + method: DecorationMethod, + options?: { apply?: boolean | undefined; extend?: boolean | undefined }, + ): void; + decorate( + type: "server", + property: DecorateName, + method: (existing: (...args: any[]) => any) => DecorationMethod, + options: { apply?: boolean | undefined; extend: true }, + ): void; + decorate( + type: "server", + property: DecorateName, + method: DecorationMethod, + options?: { apply?: boolean | undefined; extend?: boolean | undefined }, + ): void; /** * Used within a plugin to declare a required dependency on other plugins where: @@ -3595,7 +3661,7 @@ export class Server { * The method does not provide version dependency which should be implemented using npm peer dependencies. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverdependencydependencies-after) */ - dependency(dependencies: Dependencies, after?: ((server: Server) => Promise)): void; + dependency(dependencies: Dependencies, after?: (server: Server) => Promise): void; /** * Registers a custom content encoding compressor to extend the built-in support for 'gzip' and 'deflate' where: @@ -3605,7 +3671,7 @@ export class Server { * @return Return value: none. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverencoderencoding-encoder) */ - encoder(encoding: string, encoder: ((options: RouteCompressionEncoderSettings) => zlib.Gzip)): void; + encoder(encoding: string, encoder: (options: RouteCompressionEncoderSettings) => zlib.Gzip): void; /** * Used within a plugin to expose a property via server.plugins[name] where: @@ -3649,7 +3715,13 @@ export class Server { * @return void * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevents) */ - ext(events: ServerExtEventsObject | ServerExtEventsObject[] | ServerExtEventsRequestObject | ServerExtEventsRequestObject[]): void; + ext( + events: + | ServerExtEventsObject + | ServerExtEventsObject[] + | ServerExtEventsRequestObject + | ServerExtEventsRequestObject[], + ): void; /** * Registers a single extension event using the same properties as used in server.ext(events), but passed as arguments. @@ -3802,10 +3874,13 @@ export class Server { * @return Return value: none. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverregisterplugins-options) */ - /* eslint-disable-next-line @definitelytyped/no-unnecessary-generics */ + /* eslint-disable-next-line @definitelytyped/no-unnecessary-generics */ register(plugin: ServerRegisterPluginObject, options?: ServerRegisterOptions): Promise; /* eslint-disable-next-line @definitelytyped/no-unnecessary-generics */ - register(plugins: ServerRegisterPluginObjectArray, options?: ServerRegisterOptions): Promise; + register( + plugins: ServerRegisterPluginObjectArray, + options?: ServerRegisterOptions, + ): Promise; register(plugins: Array>, options?: ServerRegisterOptions): Promise; /* tslint:disable-next-line:unified-signatures */ register(plugins: Plugin | Array>, options?: ServerRegisterOptions): Promise; @@ -3849,7 +3924,10 @@ export class Server { * @return void * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverrulesprocessor-options) */ - rules(processor: (rules: object, info: {method: string, path: string, vhost?: string | undefined}) => object, options?: {validate: object}): void; // TODO needs implementation + rules( + processor: (rules: object, info: { method: string; path: string; vhost?: string | undefined }) => object, + options?: { validate: object }, + ): void; // TODO needs implementation /** * Starts the server by listening for incoming requests on the configured port (unless the connection was configured with autoListen set to false). @@ -3879,7 +3957,7 @@ export class Server { * @return Return value: none. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverstopoptions) */ - stop(options?: {timeout: number}): Promise; + stop(options?: { timeout: number }): Promise; /** * Returns a copy of the routing table where: @@ -3906,7 +3984,7 @@ export class Server { /** * User-extensible type for application specific state. */ - /* tslint:disable-next-line:no-empty-interface */ +/* tslint:disable-next-line:no-empty-interface */ export interface ApplicationState { } @@ -3966,13 +4044,13 @@ export namespace Lifecycle { */ type ReturnValue = ReturnValueTypes | (Promise); type ReturnValueTypes = - (null | string | number | boolean) | - (Buffer) | - (Error | Boom) | - (stream.Stream) | - (object | object[]) | - symbol | - ResponseToolkit; + | (null | string | number | boolean) + | (Buffer) + | (Error | Boom) + | (stream.Stream) + | (object | object[]) + | symbol + | ResponseToolkit; /** * Various configuration options allows defining how errors are handled. For example, when invalid payload is received or malformed cookie, instead of returning an error, the framework can be @@ -3986,7 +4064,7 @@ export namespace Lifecycle { * * * err - the error object. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-failaction-configuration) */ - type FailAction = 'error' | 'log' | 'ignore' | Method; + type FailAction = "error" | "log" | "ignore" | Method; } export namespace Util { @@ -3994,14 +4072,14 @@ export namespace Util { [key: string]: T; } - type HTTP_METHODS_PARTIAL_LOWERCASE = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'options'; + type HTTP_METHODS_PARTIAL_LOWERCASE = "get" | "post" | "put" | "patch" | "delete" | "options"; type HTTP_METHODS_PARTIAL = - 'GET' - | 'POST' - | 'PUT' - | 'PATCH' - | 'DELETE' - | 'OPTIONS' + | "GET" + | "POST" + | "PUT" + | "PATCH" + | "DELETE" + | "OPTIONS" | HTTP_METHODS_PARTIAL_LOWERCASE; - type HTTP_METHODS = 'HEAD' | 'head' | HTTP_METHODS_PARTIAL; + type HTTP_METHODS = "HEAD" | "head" | HTTP_METHODS_PARTIAL; } diff --git a/types/hapi/v17/test/request/auth.ts b/types/hapi/v17/test/request/auth.ts index cb6c04ad289e9c..a0bbbf76ab1acd 100644 --- a/types/hapi/v17/test/request/auth.ts +++ b/types/hapi/v17/test/request/auth.ts @@ -1,6 +1,6 @@ -import { Request } from 'hapi'; +import { Request } from "hapi"; -declare module 'hapi' { +declare module "hapi" { interface UserCredentials { a: number; } diff --git a/types/hapi/v17/test/request/catch-all.ts b/types/hapi/v17/test/request/catch-all.ts index 3ee4e74c4236f7..4ee25740224452 100644 --- a/types/hapi/v17/test/request/catch-all.ts +++ b/types/hapi/v17/test/request/catch-all.ts @@ -6,9 +6,13 @@ const options: ServerOptions = { }; const server = new Server(options); -server.route({ method: '*', path: '/{p*}', handler(request, h) { - return h.response('The page was not found').code(404); -}}); +server.route({ + method: "*", + path: "/{p*}", + handler(request, h) { + return h.response("The page was not found").code(404); + }, +}); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/v17/test/request/event-types.ts b/types/hapi/v17/test/request/event-types.ts index 4d4f3f01ca3556..a30fcb32b5b9dd 100644 --- a/types/hapi/v17/test/request/event-types.ts +++ b/types/hapi/v17/test/request/event-types.ts @@ -1,57 +1,57 @@ // https://github.com/hapijs/hapi/blob/master/API.md#-servereventevents // https://github.com/hapijs/hapi/blob/master/API.md#-requestevents +import * as Crypto from "crypto"; import { Lifecycle, Request, Server, ServerOptions, ServerRoute } from "hapi"; -import * as Crypto from 'crypto'; const options: ServerOptions = { port: 8000, }; const serverRoute: ServerRoute = { - path: '/', - method: 'GET', + path: "/", + method: "GET", handler(request) { - return 'ok: ' + request.path; - } + return "ok: " + request.path; + }, }; const onRequest: Lifecycle.Method = (request, h) => { /* * Server events */ - request.server.events.on('request', (request: Request, event: any, tags: any) => { + request.server.events.on("request", (request: Request, event: any, tags: any) => { console.log(request.paramsArray); console.log(event); console.log(tags); }); - request.server.events.on('response', (request: Request) => { - console.log('Response sent for request: ' + request.path); + request.server.events.on("response", (request: Request) => { + console.log("Response sent for request: " + request.path); }); - request.server.events.on('start', () => { - console.log('Server started'); + request.server.events.on("start", () => { + console.log("Server started"); }); - request.server.events.once('stop', () => { - console.log('Server stoped'); + request.server.events.once("stop", () => { + console.log("Server stoped"); }); /* * Request events */ - const hash = Crypto.createHash('sha1'); + const hash = Crypto.createHash("sha1"); request.events.on("peek", (chunk) => { hash.update(chunk); }); request.events.once("finish", () => { - console.log(hash.digest('hex')); + console.log(hash.digest("hex")); }); request.events.once("disconnect", () => { - console.error('request aborted'); + console.error("request aborted"); }); return h.continue; @@ -59,9 +59,9 @@ const onRequest: Lifecycle.Method = (request, h) => { const server = new Server(options); server.route(serverRoute); -server.ext('onRequest', onRequest, { - before: 'test', +server.ext("onRequest", onRequest, { + before: "test", }); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/v17/test/request/get-log.ts b/types/hapi/v17/test/request/get-log.ts index 3ba2658136655d..33d3a82875e7d3 100644 --- a/types/hapi/v17/test/request/get-log.ts +++ b/types/hapi/v17/test/request/get-log.ts @@ -6,22 +6,22 @@ const options: ServerOptions = { }; const handlerFn: Lifecycle.Method = (request, h) => { - request.log(['test', 'error'], 'Test event'); - return 'path: ' + request.path; + request.log(["test", "error"], "Test event"); + return "path: " + request.path; }; const serverRoute: ServerRoute = { - path: '/', - method: 'GET', - handler: handlerFn + path: "/", + method: "GET", + handler: handlerFn, }; const server = new Server(options); server.route(serverRoute); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); -server.events.on('request', (request: Request, event: any, tags: any) => { +server.events.on("request", (request: Request, event: any, tags: any) => { console.log(tags); if (tags.error) { console.log(event); diff --git a/types/hapi/v17/test/request/methods.ts b/types/hapi/v17/test/request/methods.ts index 22b58aac7f4e5a..acf4d8d2b291a0 100644 --- a/types/hapi/v17/test/request/methods.ts +++ b/types/hapi/v17/test/request/methods.ts @@ -1,4 +1,4 @@ -import { Request } from 'hapi'; +import { Request } from "hapi"; declare const req: Request; const act: boolean = req.active(); diff --git a/types/hapi/v17/test/request/parameters.ts b/types/hapi/v17/test/request/parameters.ts index 3f19a02d45852f..e9447521eb9159 100644 --- a/types/hapi/v17/test/request/parameters.ts +++ b/types/hapi/v17/test/request/parameters.ts @@ -9,24 +9,24 @@ const options: ServerOptions = { // http://localhost:8000/album-name/song-optional const getAlbum: Lifecycle.Method = (request, h) => { console.log(request.params); - return 'ok: ' + request.path; + return "ok: " + request.path; }; const serverRoute1: ServerRoute = { - path: '/{album}/{song?}', - method: 'GET', - handler: getAlbum + path: "/{album}/{song?}", + method: "GET", + handler: getAlbum, }; // Example 2 // http://localhost:8000/person/rafael/fijalkowski const getPerson: Lifecycle.Method = (request, h) => { - const nameParts = request.params.name.split('/'); + const nameParts = request.params.name.split("/"); return { first: nameParts[0], last: nameParts[1] }; }; const serverRoute2: ServerRoute = { - path: '/person/{name*2}', - method: 'GET', - handler: getPerson + path: "/person/{name*2}", + method: "GET", + handler: getPerson, }; const server = new Server(options); @@ -34,4 +34,4 @@ server.route(serverRoute1); server.route(serverRoute2); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/v17/test/request/query.ts b/types/hapi/v17/test/request/query.ts index 090ab3ae8df6eb..3a411be6027b41 100644 --- a/types/hapi/v17/test/request/query.ts +++ b/types/hapi/v17/test/request/query.ts @@ -15,12 +15,12 @@ const handlerFn: Lifecycle.Method = (request, h) => { }; const serverRoute: ServerRoute = { - path: '/', - method: 'GET', - handler: handlerFn + path: "/", + method: "GET", + handler: handlerFn, }; const server = new Server(options); server.route(serverRoute); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/v17/test/response/continue.ts b/types/hapi/v17/test/response/continue.ts index 15a0f5e35b3201..24594467555c41 100644 --- a/types/hapi/v17/test/response/continue.ts +++ b/types/hapi/v17/test/response/continue.ts @@ -6,20 +6,20 @@ const options: ServerOptions = { }; const serverRoute: ServerRoute = { - path: '/test', - method: 'GET', + path: "/test", + method: "GET", handler(request, h) { - return 'ok: ' + request.path; - } + return "ok: " + request.path; + }, }; const server = new Server(options); server.route(serverRoute); server.ext("onRequest", (request, h) => { - request.setUrl('/test'); + request.setUrl("/test"); return h.continue; }); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/v17/test/response/error.ts b/types/hapi/v17/test/response/error.ts index 513f5fbbe59968..e3c5876c94b928 100644 --- a/types/hapi/v17/test/response/error.ts +++ b/types/hapi/v17/test/response/error.ts @@ -1,6 +1,6 @@ // https://github.com/hapijs/hapi/blob/master/API.md#errors -import { Request, ResponseToolkit, Server, ServerOptions, ServerRoute } from "hapi"; import * as Boom from "boom"; +import { Request, ResponseToolkit, Server, ServerOptions, ServerRoute } from "hapi"; const options: ServerOptions = { port: 8000, @@ -8,18 +8,18 @@ const options: ServerOptions = { const serverRoutes: ServerRoute[] = [ { - path: '/badRequest', - method: 'GET', + path: "/badRequest", + method: "GET", handler(request, h) { - throw Boom.badRequest('Unsupported parameter'); - } + throw Boom.badRequest("Unsupported parameter"); + }, }, { - path: '/internal', - method: 'GET', + path: "/internal", + method: "GET", handler(request, h) { - throw new Error('unexpect error'); - } + throw new Error("unexpect error"); + }, }, ]; @@ -27,4 +27,4 @@ const server = new Server(options); server.route(serverRoutes); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/v17/test/response/redirect.ts b/types/hapi/v17/test/response/redirect.ts index dc1b904ce3e10f..8ff432db799e5e 100644 --- a/types/hapi/v17/test/response/redirect.ts +++ b/types/hapi/v17/test/response/redirect.ts @@ -6,15 +6,15 @@ const options: ServerOptions = { }; const serverRoute: ServerRoute = { - path: '/', - method: 'GET', + path: "/", + method: "GET", handler(request, h) { - return h.redirect('http://example.com'); - } + return h.redirect("http://example.com"); + }, }; const server = new Server(options); server.route(serverRoute); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/v17/test/response/response-events.ts b/types/hapi/v17/test/response/response-events.ts index ec1b070b18edd0..fe2938593330db 100644 --- a/types/hapi/v17/test/response/response-events.ts +++ b/types/hapi/v17/test/response/response-events.ts @@ -1,18 +1,18 @@ // https://github.com/hapijs/hapi/blob/master/API.md#-responseevents -import { Lifecycle, Request, ResponseObject, ResponseToolkit, Server, ServerOptions, ServerRoute } from "hapi"; import * as Crypto from "crypto"; +import { Lifecycle, Request, ResponseObject, ResponseToolkit, Server, ServerOptions, ServerRoute } from "hapi"; const preResponse: Lifecycle.Method = (request, h) => { // In onPreResponse, the response object will be defined. const response = request.response!; - const hash = Crypto.createHash('sha1'); - response.events.on('peek', (chunk, encoding) => { + const hash = Crypto.createHash("sha1"); + response.events.on("peek", (chunk, encoding) => { hash.update(chunk); }); - response.events.once('finish', () => { - console.log(hash.digest('hex')); + response.events.once("finish", () => { + console.log(hash.digest("hex")); }); return h.continue; @@ -22,7 +22,7 @@ const server = new Server({ port: 8000, }); -server.ext('onPreResponse', preResponse); +server.ext("onPreResponse", preResponse); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/v17/test/response/response.ts b/types/hapi/v17/test/response/response.ts index 368b6fa80bb3b3..f3fd9bb0a621b5 100644 --- a/types/hapi/v17/test/response/response.ts +++ b/types/hapi/v17/test/response/response.ts @@ -8,24 +8,24 @@ const options: ServerOptions = { const serverRoutes: ServerRoute[] = [ // Detailed notation { - path: '/test1', - method: 'GET', + path: "/test1", + method: "GET", handler(request, h) { - const response = h.response('success'); - response.type('text/plain'); - response.header('X-Custom', 'some-value'); + const response = h.response("success"); + response.type("text/plain"); + response.header("X-Custom", "some-value"); return response; - } + }, }, // Chained notation { - path: '/test2', - method: 'GET', + path: "/test2", + method: "GET", handler(request, h) { - return h.response('success') - .type('text/plain') - .header('X-Custom', 'some-value'); - } + return h.response("success") + .type("text/plain") + .header("X-Custom", "some-value"); + }, }, ]; @@ -33,4 +33,4 @@ const server = new Server(options); server.route(serverRoutes); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/v17/test/route/adding-routes.ts b/types/hapi/v17/test/route/adding-routes.ts index ac4c8958429531..31cff36267b0f0 100644 --- a/types/hapi/v17/test/route/adding-routes.ts +++ b/types/hapi/v17/test/route/adding-routes.ts @@ -6,27 +6,27 @@ const options: ServerOptions = { }; const serverRoute: ServerRoute = { - path: '/', - method: 'GET', + path: "/", + method: "GET", handler(request, h) { - return 'ok: ' + request.path; - } + return "ok: " + request.path; + }, }; const serverRoutes: ServerRoute[] = [ { - path: '/test1', - method: 'GET', + path: "/test1", + method: "GET", handler(request, h) { - return 'ok: ' + request.path; - } + return "ok: " + request.path; + }, }, { - path: '/test2', - method: 'GET', + path: "/test2", + method: "GET", handler(request, h) { - return 'ok: ' + request.path; - } + return "ok: " + request.path; + }, }, ]; @@ -35,4 +35,4 @@ server.route(serverRoute); server.route(serverRoutes); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/v17/test/route/config.ts b/types/hapi/v17/test/route/config.ts index 8cebaec2699e62..a1d3fb11dd4f79 100644 --- a/types/hapi/v17/test/route/config.ts +++ b/types/hapi/v17/test/route/config.ts @@ -6,33 +6,33 @@ const options: ServerOptions = { // different methods const routeConfig: ServerRoute = { - path: '/signin', - method: 'PUT', - vhost: 'site.coms', + path: "/signin", + method: "PUT", + vhost: "site.coms", }; const routeConfigTest1: ServerRoute = { - path: '/signin', - method: '*' + path: "/signin", + method: "*", }; const routeConfigTest2: ServerRoute = { - path: '/signin', - method: ['OPTIONS', '*'] + path: "/signin", + method: ["OPTIONS", "*"], }; // different handlers const routeConfigTest3: ServerRoute = { - path: '/signin', - method: 'PUT', - handler(request, h) { - return 'ok'; - } + path: "/signin", + method: "PUT", + handler(request, h) { + return "ok"; + }, }; const routeConfigTest4: ServerRoute = { - path: '/signin', - method: 'PUT', - handler(request, h) { - return 'ok'; - } + path: "/signin", + method: "PUT", + handler(request, h) { + return "ok"; + }, }; const server = new Server(options); @@ -42,11 +42,11 @@ server.route(routeConfig); const user: RouteOptions = { cache: { expiresIn: 5000 }, handler(request, h) { - return { name: 'John' }; - } + return { name: "John" }; + }, }; -server.route({method: 'GET', path: '/user', options: user }); +server.route({ method: "GET", path: "/user", options: user }); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/v17/test/route/ext.ts b/types/hapi/v17/test/route/ext.ts index b8dff446992339..4e0ffc3cf802bb 100644 --- a/types/hapi/v17/test/route/ext.ts +++ b/types/hapi/v17/test/route/ext.ts @@ -3,7 +3,7 @@ import { Server } from "hapi"; const server = new Server(); server.route({ - method: 'get', + method: "get", path: "/test", options: { ext: { @@ -17,6 +17,6 @@ server.route({ return h.continue; }, }], - } - } + }, + }, }); diff --git a/types/hapi/v17/test/route/handler.ts b/types/hapi/v17/test/route/handler.ts index 6fced100789760..4f04fdc4fe57c1 100644 --- a/types/hapi/v17/test/route/handler.ts +++ b/types/hapi/v17/test/route/handler.ts @@ -1,7 +1,7 @@ import { Lifecycle, Request, ResponseToolkit } from "hapi"; const handler: Lifecycle.Method = (request, h) => { - return 'success'; + return "success"; }; const strictHandler: Lifecycle.Method = (request, h) => { diff --git a/types/hapi/v17/test/route/route-options-pre.ts b/types/hapi/v17/test/route/route-options-pre.ts index 897f4a8ef5965e..12771d535f4b27 100644 --- a/types/hapi/v17/test/route/route-options-pre.ts +++ b/types/hapi/v17/test/route/route-options-pre.ts @@ -6,11 +6,11 @@ const server = new Server({ }); const pre1: Lifecycle.Method = (request, h) => { - return 'Hello'; + return "Hello"; }; const pre2: Lifecycle.Method = (request, h) => { - return 'World'; + return "World"; }; const pre3: Lifecycle.Method = (request, h) => { @@ -18,25 +18,25 @@ const pre3: Lifecycle.Method = (request, h) => { }; server.route({ - method: 'GET', - path: '/', + method: "GET", + path: "/", options: { pre: [ [ // m1 and m2 executed in parallel - { method: pre1, assign: 'm1' }, - { method: pre2, assign: 'm2' } + { method: pre1, assign: "m1" }, + { method: pre2, assign: "m2" }, ], - { method: pre3, assign: 'm3' }, + { method: pre3, assign: "m3" }, ], handler(request, h) { - return request.pre.m3 + '!\n'; - } - } + return request.pre.m3 + "!\n"; + }, + }, }); server.start(); -server.events.on('start', () => { - console.log('Server started at: ' + server.info.uri); +server.events.on("start", () => { + console.log("Server started at: " + server.info.uri); }); diff --git a/types/hapi/v17/test/route/route-options.ts b/types/hapi/v17/test/route/route-options.ts index 438ef77d6243b0..52387cca361ca7 100644 --- a/types/hapi/v17/test/route/route-options.ts +++ b/types/hapi/v17/test/route/route-options.ts @@ -8,66 +8,66 @@ import { RouteOptionsCors, RouteOptionsPayload, RouteOptionsResponse, + RouteOptionsSecureObject, RouteOptionsValidate, Server, - RouteOptionsSecureObject } from "hapi"; const routeOptionsAccess: RouteOptionsAccess = { access: [ { - scope: false + scope: false, }, { - entity: 'user' - } + entity: "user", + }, ], scope: false, - entity: 'user', - mode: 'optional', - payload: 'optional', - strategies: ['', ''], - strategy: '' + entity: "user", + mode: "optional", + payload: "optional", + strategies: ["", ""], + strategy: "", }; const corsOption: RouteOptionsCors = { - origin: 'ignore', + origin: "ignore", maxAge: 5000, - headers: ['test', 'test', 'test'], - additionalHeaders: ['test', 'test', 'test'], - exposedHeaders: ['test', 'test', 'test'], - additionalExposedHeaders: ['test', 'test', 'test'], - credentials: false + headers: ["test", "test", "test"], + additionalHeaders: ["test", "test", "test"], + exposedHeaders: ["test", "test", "test"], + additionalExposedHeaders: ["test", "test", "test"], + credentials: false, }; const payloadOptions: RouteOptionsPayload = { - allow: 'string', + allow: "string", compression: { test1: { - test: 2 - } + test: 2, + }, }, - defaultContentType: 'application/json', + defaultContentType: "application/json", failAction(request, h) { - return 'ok: ' + request.path; + return "ok: " + request.path; }, maxBytes: 1048576, multipart: { - output: 'annotated' + output: "annotated", }, - output: 'stream', - override: '', - parse: 'gunzip', + output: "stream", + override: "", + parse: "gunzip", timeout: 5000, - uploads: 'dir/' + uploads: "dir/", }; const pre1: Lifecycle.Method = (request, h) => { - return 'Hello'; + return "Hello"; }; const pre2: Lifecycle.Method = (request, h) => { - return 'World'; + return "World"; }; const pre3: Lifecycle.Method = (request, h) => { @@ -77,7 +77,7 @@ const pre3: Lifecycle.Method = (request, h) => { const routeOptionsResponse: RouteOptionsResponse = { emptyStatusCode: 200, failAction(request, h) { - return 'ok: ' + request.path; + return "ok: " + request.path; }, modify: false, options: undefined, @@ -92,7 +92,7 @@ const routeOptionsResponse: RouteOptionsResponse = { }; const routeOptionSecure: RouteOptionsSecureObject = { - referrer: 'origin', + referrer: "origin", noSniff: true, xframe: "deny", hsts: { @@ -107,7 +107,7 @@ const routeOptionSecure: RouteOptionsSecureObject = { const routeOptionsValidate: RouteOptionsValidate = { errorFields: {}, failAction(request, h) { - return 'ok: ' + request.path; + return "ok: " + request.path; }, headers: false, options: {}, @@ -116,7 +116,7 @@ const routeOptionsValidate: RouteOptionsValidate = { query: true, }; -declare module 'hapi' { +declare module "hapi" { interface RouteOptionsApp { one: number; two: string; @@ -126,33 +126,33 @@ declare module 'hapi' { const routeOptions: RouteOptions = { app: { one: 1, - two: "2" + two: "2", }, auth: routeOptionsAccess, bind: null, cache: { - privacy: 'default', + privacy: "default", statuses: [200], - otherwise: 'no-cache' + otherwise: "no-cache", }, compression: { test1: { - test: 2 - } + test: 2, + }, }, cors: corsOption, - description: 'description here', + description: "description here", ext: undefined, - files: { relativeTo: '.' }, + files: { relativeTo: "." }, handler(request, h) { - return 'ok: ' + request.path; + return "ok: " + request.path; }, - id: 'test', + id: "test", isInternal: false, json: undefined, - jsonp: 'callback', + jsonp: "callback", log: { collect: false }, - notes: ['test', 'test', 'test'], + notes: ["test", "test", "test"], payload: payloadOptions, plugins: { plugin1: {}, @@ -161,33 +161,33 @@ const routeOptions: RouteOptions = { pre: [ [ // m1 and m2 executed in parallel - { method: pre1, assign: 'm1' }, - { method: pre2, assign: 'm2' } + { method: pre1, assign: "m1" }, + { method: pre2, assign: "m2" }, ], - { method: pre3, assign: 'm3' }, + { method: pre3, assign: "m3" }, ], response: routeOptionsResponse, security: false, state: { parse: true, failAction(request, h) { - return 'ok: ' + request.path; + return "ok: " + request.path; }, }, - tags: ['test', 'test', 'test'], + tags: ["test", "test", "test"], timeout: { server: 10000, - socket: false + socket: false, }, - validate: routeOptionsValidate + validate: routeOptionsValidate, }; const server = new Server({ port: 8000, - routes: routeOptions + routes: routeOptions, }); server.start(); -server.events.on('start', () => { - console.log('Server started at: ' + server.info.uri); +server.events.on("start", () => { + console.log("Server started at: " + server.info.uri); }); diff --git a/types/hapi/v17/test/route/validation.ts b/types/hapi/v17/test/route/validation.ts index 2151371c5fd266..b243f3ca22f33c 100644 --- a/types/hapi/v17/test/route/validation.ts +++ b/types/hapi/v17/test/route/validation.ts @@ -12,37 +12,37 @@ const routeOptions: RouteOptions = { id: Joi.string().uuid().required(), name: Joi.object({ firstName: Joi.string().required(), - lastName: Joi.string().allow(null) + lastName: Joi.string().allow(null), }), - firstName: Joi.ref("name.firstName") + firstName: Joi.ref("name.firstName"), }, params: { name: Joi.string().min(3).max(10), - nameRef: Joi.ref("name") - } + nameRef: Joi.ref("name"), + }, }, response: { schema: Joi.object({ a: Joi.string(), b: Joi.object({ - c: Joi.number() + c: Joi.number(), }), - d: Joi.ref("b.c") - }) - } + d: Joi.ref("b.c"), + }), + }, }; const serverRoute: ServerRoute = { - path: '/', - method: 'GET', + path: "/", + method: "GET", handler(request, h) { - return 'ok: ' + request.path; + return "ok: " + request.path; }, - options: routeOptions + options: routeOptions, }; const server = new Server(options); server.route(serverRoute); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/v17/test/server/server-app.ts b/types/hapi/v17/test/server/server-app.ts index 42c2b5dec4140a..187a446efa8d6a 100644 --- a/types/hapi/v17/test/server/server-app.ts +++ b/types/hapi/v17/test/server/server-app.ts @@ -13,17 +13,17 @@ declare module "hapi" { } const server = new Server(options); -server.app.key = 'value2'; +server.app.key = "value2"; const serverRoute: ServerRoute = { - path: '/', - method: 'GET', + path: "/", + method: "GET", handler(request, h) { - return 'key: ' + request.server.app.key; - } + return "key: " + request.server.app.key; + }, }; server.route(serverRoute); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/v17/test/server/server-auth-api.ts b/types/hapi/v17/test/server/server-auth-api.ts index 4508c641c90b03..80a5237bf4e958 100644 --- a/types/hapi/v17/test/server/server-auth-api.ts +++ b/types/hapi/v17/test/server/server-auth-api.ts @@ -1,11 +1,8 @@ // https://github.com/hapijs/hapi/blob/master/API.md#-serverauthapi -import { - Server, - ServerAuthScheme, -} from "hapi"; import * as Boom from "boom"; +import { Server, ServerAuthScheme } from "hapi"; -declare module 'hapi' { +declare module "hapi" { interface ServerAuthSchemeObjectApi { settings: { x: number; @@ -17,24 +14,24 @@ const scheme: ServerAuthScheme = (server, options) => { return { api: { settings: { - x: 5 - } + x: 5, + }, }, authenticate(request, h) { const authorization = request.headers.authorization; if (!authorization) { - throw Boom.unauthorized(null, 'Custom'); + throw Boom.unauthorized(null, "Custom"); } return h.authenticated({ credentials: { user: { a: 1 } } }); - } + }, }; }; const server = new Server({ port: 8000, }); -server.auth.scheme('custom', scheme); -server.auth.strategy('default', 'custom'); +server.auth.scheme("custom", scheme); +server.auth.strategy("default", "custom"); server.start(); -console.log(server.auth.api.default.settings.x); // 5 +console.log(server.auth.api.default.settings.x); // 5 diff --git a/types/hapi/v17/test/server/server-auth-default.ts b/types/hapi/v17/test/server/server-auth-default.ts index 0a2da56efc15c8..675b559eaf1b7a 100644 --- a/types/hapi/v17/test/server/server-auth-default.ts +++ b/types/hapi/v17/test/server/server-auth-default.ts @@ -1,9 +1,9 @@ // https://github.com/hapijs/hapi/blob/master/API.md#-serverauthdefaultoptions // https://github.com/hapijs/hapi/blob/master/API.md#-serverauthschemename-scheme -import { Request, ResponseToolkit, Server, ServerAuthScheme, ServerAuthSchemeOptions } from "hapi"; import * as Boom from "boom"; +import { Request, ResponseToolkit, Server, ServerAuthScheme, ServerAuthSchemeOptions } from "hapi"; -declare module 'hapi' { +declare module "hapi" { interface UserCredentials { a: number; } @@ -19,23 +19,23 @@ const scheme: ServerAuthScheme = (server, options) => { const req = request.raw.req; const authorization = req.headers.authorization; if (!authorization) { - throw Boom.unauthorized(null, 'Custom'); + throw Boom.unauthorized(null, "Custom"); } - return h.authenticated({ credentials: { user: { a: 1 }, scope: ['test'] } }); - } + return h.authenticated({ credentials: { user: { a: 1 }, scope: ["test"] } }); + }, }; }; -server.auth.scheme('custom', scheme); -server.auth.strategy('default', 'custom'); -server.auth.default('default'); +server.auth.scheme("custom", scheme); +server.auth.strategy("default", "custom"); +server.auth.default("default"); server.route({ - method: 'GET', - path: '/', + method: "GET", + path: "/", handler(request, h) { - return request.auth.credentials.user || 'not authed'; - } + return request.auth.credentials.user || "not authed"; + }, }); server.start(); diff --git a/types/hapi/v17/test/server/server-auth-test.ts b/types/hapi/v17/test/server/server-auth-test.ts index 8e4b3d24b791f1..0eac9153338561 100644 --- a/types/hapi/v17/test/server/server-auth-test.ts +++ b/types/hapi/v17/test/server/server-auth-test.ts @@ -1,9 +1,9 @@ // https://github.com/hapijs/hapi/blob/master/API.md#-await-serverauthteststrategy-request // https://github.com/hapijs/hapi/blob/master/API.md#-serverauthschemename-scheme -import { Request, ResponseToolkit, Server, ServerAuthScheme, ServerAuthSchemeOptions } from "hapi"; import * as Boom from "boom"; +import { Request, ResponseToolkit, Server, ServerAuthScheme, ServerAuthSchemeOptions } from "hapi"; -declare module 'hapi' { +declare module "hapi" { interface AuthCredentials { name?: string | undefined; } @@ -19,27 +19,27 @@ const scheme: ServerAuthScheme = (server, options) => { const req = request.raw.req; const authorization = req.headers.authorization; if (!authorization) { - throw Boom.unauthorized(null, 'Custom'); + throw Boom.unauthorized(null, "Custom"); } - return h.authenticated({ credentials: { name: 'john', } }); - } + return h.authenticated({ credentials: { name: "john" } }); + }, }; }; -server.auth.scheme('custom', scheme); -server.auth.strategy('default', 'custom'); +server.auth.scheme("custom", scheme); +server.auth.strategy("default", "custom"); server.route({ - method: 'GET', - path: '/', + method: "GET", + path: "/", handler: async (request: Request, h: ResponseToolkit) => { try { - const credentials = await request.server.auth.test('default', request); + const credentials = await request.server.auth.test("default", request); return { status: true, user: credentials.name }; } catch (err) { return { status: false }; } - } + }, }); server.start(); diff --git a/types/hapi/v17/test/server/server-auth-verify.ts b/types/hapi/v17/test/server/server-auth-verify.ts index ec788fcb596f36..b276171b10ae75 100644 --- a/types/hapi/v17/test/server/server-auth-verify.ts +++ b/types/hapi/v17/test/server/server-auth-verify.ts @@ -1,26 +1,26 @@ -import { Request, Server, RequestAuth } from "hapi"; import * as Boom from "boom"; +import { Request, RequestAuth, Server } from "hapi"; const server = new Server({ port: 8000, }); -server.auth.scheme('custom', () => ({ +server.auth.scheme("custom", () => ({ authenticate() { - throw Boom.unauthorized(null, 'hurr'); + throw Boom.unauthorized(null, "hurr"); }, async verify(_auth: RequestAuth) { - throw Boom.unauthorized(null, 'durr'); - } + throw Boom.unauthorized(null, "durr"); + }, })); -server.auth.strategy('default', 'custom'); +server.auth.strategy("default", "custom"); server.route({ - method: 'GET', - path: '/', + method: "GET", + path: "/", async handler(request: Request) { request.server.auth.verify(request); - } + }, }); server.start(); diff --git a/types/hapi/v17/test/server/server-bind.ts b/types/hapi/v17/test/server/server-bind.ts index 1fbd37c4c2f53e..bc0333a5dc487a 100644 --- a/types/hapi/v17/test/server/server-bind.ts +++ b/types/hapi/v17/test/server/server-bind.ts @@ -5,23 +5,23 @@ const server = new Server({ port: 8000, }); const handler: Lifecycle.Method = (request, h) => { - return h.context.message; // Or h.context.message + return h.context.message; // Or h.context.message }; const plugin: Plugin = { - name: 'example', + name: "example", register: async (server, options) => { const bind = { - message: 'hello' + message: "hello", }; server.bind(bind); - server.route({ method: 'GET', path: '/', handler }); - } + server.route({ method: "GET", path: "/", handler }); + }, }; server.start(); server.register(plugin); -server.events.on('start', () => { - console.log('Server started at: ' + server.info.uri); +server.events.on("start", () => { + console.log("Server started at: " + server.info.uri); }); diff --git a/types/hapi/v17/test/server/server-cache-provision.ts b/types/hapi/v17/test/server/server-cache-provision.ts index 8c28ca48de17a2..70a1975eb20802 100644 --- a/types/hapi/v17/test/server/server-cache-provision.ts +++ b/types/hapi/v17/test/server/server-cache-provision.ts @@ -1,19 +1,19 @@ // https://github.com/hapijs/hapi/blob/master/API.md#-await-servercacheprovisionoptions -import { Server } from "hapi"; import * as catbox from "catbox"; +import { Server } from "hapi"; const server = new Server({ port: 8000, }); server.initialize(); -server.cache.provision({engine: require('catbox-memory'), name: 'countries' }); +server.cache.provision({ engine: require("catbox-memory"), name: "countries" }); -const cache = server.cache({segment: 'countries', cache: 'countries', expiresIn: 60 * 60 * 1000 }); -cache.set('norway', 'oslo', 10 * 1000).then(() => {}); -const value = cache.get('norway').then(() => {}); +const cache = server.cache({ segment: "countries", cache: "countries", expiresIn: 60 * 60 * 1000 }); +cache.set("norway", "oslo", 10 * 1000).then(() => {}); +const value = cache.get("norway").then(() => {}); server.start(); -server.events.on('start', () => { - console.log('Server started at: ' + server.info.uri); +server.events.on("start", () => { + console.log("Server started at: " + server.info.uri); }); diff --git a/types/hapi/v17/test/server/server-cache.ts b/types/hapi/v17/test/server/server-cache.ts index 0872b287df1711..4ff1263c94cb7e 100644 --- a/types/hapi/v17/test/server/server-cache.ts +++ b/types/hapi/v17/test/server/server-cache.ts @@ -1,23 +1,23 @@ // https://github.com/hapijs/hapi/blob/master/API.md#-servercacheoptions -import { Server, ServerOptionsCache } from "hapi"; import * as catbox from "catbox"; +import { Server, ServerOptionsCache } from "hapi"; const server = new Server({ port: 8000, }); const catboxOptions: ServerOptionsCache = { - segment: 'countries', - expiresIn: 60 * 60 * 1000 + segment: "countries", + expiresIn: 60 * 60 * 1000, }; const cache = server.cache(catboxOptions); -cache.set('norway', 'oslo', 10 * 1000).then(() => {}); +cache.set("norway", "oslo", 10 * 1000).then(() => {}); -const value = cache.get('norway').then(() => {}); +const value = cache.get("norway").then(() => {}); console.log("Value: " + value); server.start(); -server.events.on('start', () => { - console.log('Server started at: ' + server.info.uri); +server.events.on("start", () => { + console.log("Server started at: " + server.info.uri); }); diff --git a/types/hapi/v17/test/server/server-decoder.ts b/types/hapi/v17/test/server/server-decoder.ts index 965745ee7c10e7..236750b109bb8a 100644 --- a/types/hapi/v17/test/server/server-decoder.ts +++ b/types/hapi/v17/test/server/server-decoder.ts @@ -3,6 +3,6 @@ import { Server } from "hapi"; import * as Zlib from "zlib"; const server = new Server({ port: 80, routes: { payload: { compression: { special: { chunkSize: 16 * 1024 } } } } }); -server.decoder('special', (options) => Zlib.createGunzip(options)); +server.decoder("special", (options) => Zlib.createGunzip(options)); server.start(); diff --git a/types/hapi/v17/test/server/server-decorations.ts b/types/hapi/v17/test/server/server-decorations.ts index fadab524220390..86ac077f90325b 100644 --- a/types/hapi/v17/test/server/server-decorations.ts +++ b/types/hapi/v17/test/server/server-decorations.ts @@ -1,7 +1,7 @@ // https://github.com/hapijs/hapi/blob/master/API.md#-serverdecoratetype-property-method-options import { Request, ResponseToolkit, Server } from "hapi"; -declare module 'hapi' { +declare module "hapi" { interface HandlerDecorations { test?: { test: number; @@ -16,25 +16,25 @@ const server = new Server({ }); server.start(); -server.decorate('toolkit', 'success', function() { - return this.response({ status: 'ok' }); +server.decorate("toolkit", "success", function() { + return this.response({ status: "ok" }); }); -server.decorate('handler', 'test', (route, options) => (req, h) => 123); +server.decorate("handler", "test", (route, options) => (req, h) => 123); server.route({ - method: 'GET', - path: '/', + method: "GET", + path: "/", handler: { test: { test: 123, - } - } + }, + }, }); console.log(server.decorations.toolkit); // Test decorators with additional arguments -declare module 'hapi' { +declare module "hapi" { interface Server { withParams(x: number, y: string): string; } @@ -48,28 +48,28 @@ function decorateServerWithParams(this: Server, x: number, y: string) { return `${x} ${y}`; } -server.decorate('server', 'withParams', decorateServerWithParams); +server.decorate("server", "withParams", decorateServerWithParams); server.withParams(1, "one"); function decorateToolkitWithParams(this: ResponseToolkit, x: number, y: string) { return `${x} ${y}`; } -server.decorate('toolkit', 'withParams', decorateToolkitWithParams); +server.decorate("toolkit", "withParams", decorateToolkitWithParams); -server.decorate('toolkit', Symbol('hi'), decorateToolkitWithParams); +server.decorate("toolkit", Symbol("hi"), decorateToolkitWithParams); server.route({ - method: 'GET', - path: '/toolkitWithParams', + method: "GET", + path: "/toolkitWithParams", handler: (r, h) => { return h.withParams(1, "one"); - } + }, }); // Test request + apply option types -declare module 'hapi' { +declare module "hapi" { interface Request { withApply(x: string, y: number): string; } @@ -81,19 +81,19 @@ function decorateRequestWithApply(request: Request) { }; } -server.decorate('request', 'withApply', decorateRequestWithApply, {apply: true}); +server.decorate("request", "withApply", decorateRequestWithApply, { apply: true }); server.route({ - method: 'GET', - path: '/requestWithApply', + method: "GET", + path: "/requestWithApply", handler: (r, h) => { return r.withApply("one", 1); - } + }, }); // Test extend option type -declare module 'hapi' { +declare module "hapi" { interface Server { withExtend(x: string, y: number): string; } @@ -106,5 +106,5 @@ const decorateServerWithExtend = (existing: () => void) => { }; }; -server.decorate('server', 'withExtend', decorateServerWithExtend, {extend: true}); +server.decorate("server", "withExtend", decorateServerWithExtend, { extend: true }); server.withExtend("one", 1); diff --git a/types/hapi/v17/test/server/server-encoder.ts b/types/hapi/v17/test/server/server-encoder.ts index dd9f12f4dbb45a..b942093097edc0 100644 --- a/types/hapi/v17/test/server/server-encoder.ts +++ b/types/hapi/v17/test/server/server-encoder.ts @@ -3,6 +3,6 @@ import { Server } from "hapi"; import * as Zlib from "zlib"; const server = new Server({ port: 80, routes: { payload: { compression: { special: { chunkSize: 16 * 1024 } } } } }); -server.encoder('special', (options) => Zlib.createGzip(options)); +server.encoder("special", (options) => Zlib.createGzip(options)); server.start(); diff --git a/types/hapi/v17/test/server/server-events-once.ts b/types/hapi/v17/test/server/server-events-once.ts index a4903ee6dc95bb..e7f8f47978fdd0 100644 --- a/types/hapi/v17/test/server/server-events-once.ts +++ b/types/hapi/v17/test/server/server-events-once.ts @@ -2,17 +2,17 @@ import { Request, ResponseToolkit, Server, ServerRoute } from "hapi"; const serverRoute: ServerRoute = { - path: '/', - method: 'GET', + path: "/", + method: "GET", handler(request, h) { - return 'oks: ' + request.path; - } + return "oks: " + request.path; + }, }; -declare module 'hapi' { +declare module "hapi" { interface ServerEvents { - once(event: 'test1', listener: (update: string) => void): this; - once(event: 'test2', listener: (...updates: string[]) => void): this; + once(event: "test1", listener: (update: string) => void): this; + once(event: "test2", listener: (...updates: string[]) => void): this; } } @@ -20,12 +20,16 @@ const server = new Server({ port: 8000, }); server.route(serverRoute); -server.event('test1'); -server.event('test2'); -server.events.once('test1', update => { console.log(update); }); -server.events.once('test2', (...args) => { console.log(args); }); -server.events.emit('test1', 'hello-1'); -server.events.emit('test2', 'hello-2'); // Ignored +server.event("test1"); +server.event("test2"); +server.events.once("test1", update => { + console.log(update); +}); +server.events.once("test2", (...args) => { + console.log(args); +}); +server.events.emit("test1", "hello-1"); +server.events.emit("test2", "hello-2"); // Ignored server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/v17/test/server/server-events.ts b/types/hapi/v17/test/server/server-events.ts index 4e6d8103f15065..4091cdac4ba4a4 100644 --- a/types/hapi/v17/test/server/server-events.ts +++ b/types/hapi/v17/test/server/server-events.ts @@ -1,11 +1,11 @@ // https://github.com/hapijs/hapi/blob/master/API.md#-servereventevents import { Server, ServerEvents } from "hapi"; -import Podium = require('podium'); -import 'hapi/definitions/server/server'; +import Podium = require("podium"); +import "hapi/definitions/server/server"; -declare module 'hapi' { +declare module "hapi" { interface ServerEvents { - on(event: 'test', listener: (update: string) => void): this; + on(event: "test", listener: (update: string) => void): this; } } @@ -13,12 +13,12 @@ const server = new Server({ port: 8000, }); -server.events.on('route', route => { +server.events.on("route", route => { console.log(route.path, route.vhost, route.realm, route.method, route.settings, route.fingerprint); }); -server.event('test'); -server.events.on('test', (update: any) => console.log(update)); -server.events.emit('test', 'hello'); +server.event("test"); +server.events.on("test", (update: any) => console.log(update)); +server.events.emit("test", "hello"); server.start(); diff --git a/types/hapi/v17/test/server/server-expose.ts b/types/hapi/v17/test/server/server-expose.ts index 74b7c127da3382..5247f35b4de7a2 100644 --- a/types/hapi/v17/test/server/server-expose.ts +++ b/types/hapi/v17/test/server/server-expose.ts @@ -1,7 +1,7 @@ // https://github.com/hapijs/hapi/blob/master/API.md#-serverplugins import { Plugin, Server, ServerRegisterOptions } from "hapi"; -declare module 'hapi' { +declare module "hapi" { interface PluginProperties { example1: { util(): void; @@ -13,17 +13,17 @@ declare module 'hapi' { } const plugin1: Plugin = { - name: 'example1', + name: "example1", async register(server: Server, options: ServerRegisterOptions) { - server.expose('util', () => console.log('something')); - } + server.expose("util", () => console.log("something")); + }, }; const plugin2: Plugin = { - name: 'example2', + name: "example2", async register(server: Server, options: ServerRegisterOptions) { - server.expose('util', () => console.log('something')); - } + server.expose("util", () => console.log("something")); + }, }; const server = new Server({ diff --git a/types/hapi/v17/test/server/server-info.ts b/types/hapi/v17/test/server/server-info.ts index 58045b19dadc7e..73c4e36244a198 100644 --- a/types/hapi/v17/test/server/server-info.ts +++ b/types/hapi/v17/test/server/server-info.ts @@ -7,4 +7,4 @@ const server = new Server({ server.start(); console.log(server.info); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/v17/test/server/server-inject.ts b/types/hapi/v17/test/server/server-inject.ts index cf49f040327c97..aa71cf244d5b20 100644 --- a/types/hapi/v17/test/server/server-inject.ts +++ b/types/hapi/v17/test/server/server-inject.ts @@ -6,19 +6,19 @@ const server = new Server({ }); const serverRoute: ServerRoute = { - path: '/', - method: 'GET', + path: "/", + method: "GET", handler(request, h) { - return 'Success!'; - } + return "Success!"; + }, }; server.route(serverRoute); server.start(); -server.inject('/').then(res => console.log(res.result)); +server.inject("/").then(res => console.log(res.result)); -declare module 'hapi' { +declare module "hapi" { interface ApplicationState { injectState?: number | undefined; } @@ -27,6 +27,6 @@ declare module 'hapi' { server.inject({ url: "test", app: { - injectState: 1 - } + injectState: 1, + }, }); diff --git a/types/hapi/v17/test/server/server-load.ts b/types/hapi/v17/test/server/server-load.ts index 8ac89fa0069452..38308fa70b84a1 100644 --- a/types/hapi/v17/test/server/server-load.ts +++ b/types/hapi/v17/test/server/server-load.ts @@ -6,7 +6,7 @@ const server = new Server({ load: { sampleInterval: 1000, concurrent: 123, - } + }, }); server.start(); diff --git a/types/hapi/v17/test/server/server-lookup.ts b/types/hapi/v17/test/server/server-lookup.ts index 2bbaf5713bea0e..59fb99f601f16d 100644 --- a/types/hapi/v17/test/server/server-lookup.ts +++ b/types/hapi/v17/test/server/server-lookup.ts @@ -6,15 +6,15 @@ const server = new Server({ }); server.route({ - path: '/', - method: 'GET', + path: "/", + method: "GET", options: { - id: 'root', - handler: () => 'ok' - } + id: "root", + handler: () => "ok", + }, }); -const route: RequestRoute | null = server.lookup('root'); +const route: RequestRoute | null = server.lookup("root"); console.log(route); server.start(); diff --git a/types/hapi/v17/test/server/server-match.ts b/types/hapi/v17/test/server/server-match.ts index d2ab8faa7968ed..4e285cb86811b4 100644 --- a/types/hapi/v17/test/server/server-match.ts +++ b/types/hapi/v17/test/server/server-match.ts @@ -6,15 +6,15 @@ const server = new Server({ }); server.route({ - path: '/', - method: 'GET', + path: "/", + method: "GET", options: { - id: 'root', - handler: () => 'ok' - } + id: "root", + handler: () => "ok", + }, }); -const route: RequestRoute | null = server.match('get', '/'); +const route: RequestRoute | null = server.match("get", "/"); if (route !== null) { console.log(route.path); diff --git a/types/hapi/v17/test/server/server-method.ts b/types/hapi/v17/test/server/server-method.ts index 39c3fdb9d77833..8b110d5b1ce6f9 100644 --- a/types/hapi/v17/test/server/server-method.ts +++ b/types/hapi/v17/test/server/server-method.ts @@ -11,15 +11,15 @@ const add = (a: any, b: any): number => { }; const methodObject: ServerMethodConfigurationObject = { - name: 'sum', + name: "sum", method: add, options: { cache: { expiresIn: 2000, - generateTimeout: 100 + generateTimeout: 100, }, - generateKey: (a: string | undefined) => a === undefined ? null : a - } + generateKey: (a: string | undefined) => a === undefined ? null : a, + }, }; server.method(methodObject); diff --git a/types/hapi/v17/test/server/server-methods.ts b/types/hapi/v17/test/server/server-methods.ts index f9a2d08e6c952b..1e719156eba971 100644 --- a/types/hapi/v17/test/server/server-methods.ts +++ b/types/hapi/v17/test/server/server-methods.ts @@ -6,6 +6,6 @@ const server = new Server({ }); server.start(); -server.method('add', (a, b) => (a + b)); -const result = server.methods.add(1, 2); // 3 +server.method("add", (a, b) => (a + b)); +const result = server.methods.add(1, 2); // 3 console.log(result); diff --git a/types/hapi/v17/test/server/server-mime.ts b/types/hapi/v17/test/server/server-mime.ts index d5a76da9fa63e7..168c541fc482d0 100644 --- a/types/hapi/v17/test/server/server-mime.ts +++ b/types/hapi/v17/test/server/server-mime.ts @@ -5,18 +5,18 @@ const options: ServerOptions = { port: 8000, mime: { override: { - 'node/module': { - source: 'apache', + "node/module": { + source: "apache", compressible: false, - extensions: ['node', 'module', 'npm'], - type: 'node/module' - } - } - } + extensions: ["node", "module", "npm"], + type: "node/module", + }, + }, + }, }; const server = new Server(options); -console.log(server.mime.path('code.js').type); // 'application/javascript' -console.log(server.mime.path('file.npm').type); // 'node/module' +console.log(server.mime.path("code.js").type); // 'application/javascript' +console.log(server.mime.path("file.npm").type); // 'node/module' server.start(); diff --git a/types/hapi/v17/test/server/server-options.ts b/types/hapi/v17/test/server/server-options.ts index b3111b42c8a2e6..be46edead91c02 100644 --- a/types/hapi/v17/test/server/server-options.ts +++ b/types/hapi/v17/test/server/server-options.ts @@ -4,20 +4,20 @@ import { MimosOptions, MimosOptionsValue } from "mimos"; const mimeOptions: MimosOptions = { override: { - 'node/module': { - source: 'iana', + "node/module": { + source: "iana", compressible: true, - extensions: ['node', 'modsule', 'npm'], - type: 'node/module' + extensions: ["node", "modsule", "npm"], + type: "node/module", }, - 'application/javascript': { - source: 'iana', - charset: 'UTF-8', + "application/javascript": { + source: "iana", + charset: "UTF-8", compressible: true, - extensions: ['js', 'javascript'], - type: 'text/javascript' + extensions: ["js", "javascript"], + type: "text/javascript", }, - 'text/html': { + "text/html": { predicate: (mime: MimosOptionsValue) => { if (1 === 1) { // mime.foo = 'test'; @@ -25,36 +25,36 @@ const mimeOptions: MimosOptions = { // mime.foo = 'bar'; } return mime; - } - } - } + }, + }, + }, }; const plugin: Plugin = { - name: 'example', + name: "example", register: async (server: Server, options: ServerRegisterOptions) => { - server.expose('key', 'value'); - server.plugins.example.other = 'other'; - console.log(server.plugins.example.key); // 'value' - console.log(server.plugins.example.other); // 'other' - } + server.expose("key", "value"); + server.plugins.example.other = "other"; + console.log(server.plugins.example.key); // 'value' + console.log(server.plugins.example.other); // 'other' + }, }; const routeOptions: RouteOptions = { compression: { test: { - some: 'option' - } + some: "option", + }, }, files: { - relativeTo: __dirname + relativeTo: __dirname, }, cors: { - origin: ['http://test.example.com', 'http://www.example.com', 'http://*.a.com'] + origin: ["http://test.example.com", "http://www.example.com", "http://*.a.com"], }, }; -declare module 'hapi' { +declare module "hapi" { interface ServerOptionsApp { key1?: string | undefined; key2?: string | undefined; @@ -63,28 +63,28 @@ declare module 'hapi' { } const options: ServerOptions = { - address: '0.0.0.0', + address: "0.0.0.0", app: { - key1: 'value1', - key2: 'value2', - any_thing: 'any_value', + key1: "value1", + key2: "value2", + any_thing: "any_value", }, autoListen: true, cache: { - engine: require('catbox-memory'), - name: 'test', + engine: require("catbox-memory"), + name: "test", shared: true, - partition: 'hapi-cache', - any_thing_1: 'any_thing_1', - any_thing_2: 'any_thing_2' + partition: "hapi-cache", + any_thing_1: "any_thing_1", + any_thing_2: "any_thing_2", }, compression: { - minBytes: 1024 + minBytes: 1024, }, debug: { - request: ['implementation'] + request: ["implementation"], }, - host: 'localhost', + host: "localhost", listener: undefined, load: { sampleInterval: 0 }, mime: mimeOptions, @@ -92,7 +92,7 @@ const options: ServerOptions = { port: 8000, router: { isCaseSensitive: true, - stripTrailingSlash: false + stripTrailingSlash: false, }, routes: routeOptions, state: { @@ -100,15 +100,15 @@ const options: ServerOptions = { ignoreErrors: false, isSecure: true, isHttpOnly: true, - isSameSite: 'Strict', - encoding: 'none' + isSameSite: "Strict", + encoding: "none", }, - tls: true + tls: true, }; const server = new Server(options); server.start(); -server.events.on('start', () => { - console.log('Server started at: ' + server.info.uri); +server.events.on("start", () => { + console.log("Server started at: " + server.info.uri); }); diff --git a/types/hapi/v17/test/server/server-path.ts b/types/hapi/v17/test/server/server-path.ts index 63efae5f8dde43..ae2160398571b3 100644 --- a/types/hapi/v17/test/server/server-path.ts +++ b/types/hapi/v17/test/server/server-path.ts @@ -6,32 +6,32 @@ const server = new Server({ }); // Definition for INERT -declare module 'hapi' { +declare module "hapi" { interface HandlerDecorations { file?: string | undefined; } } const serverRouteOption: ServerRoute = { - path: '/file', - method: 'GET', + path: "/file", + method: "GET", handler: { - file: './test.html' - } + file: "./test.html", + }, }; const plugin: Plugin = { - name: 'example', + name: "example", register: async (server: Server, options: ServerRegisterOptions) => { // Assuming the Inert plugin was registered previously - server.path(__dirname + '../static'); + server.path(__dirname + "../static"); server.route(serverRouteOption); - } + }, }; server.start(); server.register(plugin); -server.events.on('start', () => { - console.log('Server started at: ' + server.info.uri); +server.events.on("start", () => { + console.log("Server started at: " + server.info.uri); }); diff --git a/types/hapi/v17/test/server/server-plugins.ts b/types/hapi/v17/test/server/server-plugins.ts index e54ebfb6b39367..4ea749c0faf2e2 100644 --- a/types/hapi/v17/test/server/server-plugins.ts +++ b/types/hapi/v17/test/server/server-plugins.ts @@ -17,7 +17,7 @@ interface Plugin4 { four: 4; } -declare module 'hapi' { +declare module "hapi" { interface PluginProperties { example: { other: string; @@ -27,37 +27,37 @@ declare module 'hapi' { } const plugin1: Plugin = { - name: 'plugin1', + name: "plugin1", register: async (server: Server, options: Plugin1) => { - server.expose('key', 'value'); - server.plugins.example.other = 'other'; - console.log(server.plugins.example.key); // 'value' - console.log(server.plugins.example.other); // 'other' + server.expose("key", "value"); + server.plugins.example.other = "other"; + console.log(server.plugins.example.key); // 'value' + console.log(server.plugins.example.other); // 'other' }, }; const plugin2: Plugin = { - name: 'plugin2', + name: "plugin2", register: async (server: Server, options: Plugin2) => {}, dependencies: { - plugin1: '*', + plugin1: "*", }, requirements: { - node: '>=8', - hapi: '>=1337', + node: ">=8", + hapi: ">=1337", }, }; const plugin3: Plugin = { - name: 'plugin3', + name: "plugin3", register: async (server: Server, options: Plugin3) => {}, - dependencies: ['plugin2'], + dependencies: ["plugin2"], }; const plugin4: Plugin = { - name: 'plugin4', + name: "plugin4", register: (server: Server, options: Plugin4) => {}, - dependencies: 'plugin3', + dependencies: "plugin3", }; const server = new Server({ @@ -69,48 +69,48 @@ server.register(plugin1); server.register({ plugin: plugin1, - options: {one: 1} + options: { one: 1 }, }); server.register([ { plugin: plugin2, - options: {two: 2} + options: { two: 2 }, }, { plugin: plugin3, - options: {three: 3} + options: { three: 3 }, }, { plugin: plugin1, - options: {one: 1} + options: { one: 1 }, }, { plugin: plugin2, - options: {two: 2} + options: { two: 2 }, }, { plugin: plugin3, - options: {three: 3} + options: { three: 3 }, }, { plugin: plugin1, - options: {one: 1} + options: { one: 1 }, }, { plugin: plugin2, - options: {two: 2} + options: { two: 2 }, }, { plugin: plugin3, - options: {three: 3} + options: { three: 3 }, }, { plugin: plugin1, - options: {one: 1} + options: { one: 1 }, }, { plugin: plugin4, - options: {four: 4} - } + options: { four: 4 }, + }, ]); diff --git a/types/hapi/v17/test/server/server-settings.ts b/types/hapi/v17/test/server/server-settings.ts index fe77f618236aec..baee9bc6e17a6e 100644 --- a/types/hapi/v17/test/server/server-settings.ts +++ b/types/hapi/v17/test/server/server-settings.ts @@ -1,7 +1,7 @@ // https://github.com/hapijs/hapi/blob/master/API.md#-serversettings import { Server } from "hapi"; -declare module 'hapi' { +declare module "hapi" { interface ServerOptionsApp { key?: string | undefined; } @@ -10,9 +10,9 @@ declare module 'hapi' { const server = new Server({ port: 8000, app: { - key: 'value' - } + key: "value", + }, }); server.start(); -console.log(server.settings.app); // { key: 'value' } +console.log(server.settings.app); // { key: 'value' } diff --git a/types/hapi/v17/test/server/server-start.ts b/types/hapi/v17/test/server/server-start.ts index f41349e88cb5d9..6067a40c140347 100644 --- a/types/hapi/v17/test/server/server-start.ts +++ b/types/hapi/v17/test/server/server-start.ts @@ -6,6 +6,6 @@ const server = new Server({ }); server.start(); -server.events.on('start', () => { - console.log('Server started at: ' + server.info.uri); +server.events.on("start", () => { + console.log("Server started at: " + server.info.uri); }); diff --git a/types/hapi/v17/test/server/server-state.ts b/types/hapi/v17/test/server/server-state.ts index ba4ffe344c5601..d78ecf9e69f33c 100644 --- a/types/hapi/v17/test/server/server-state.ts +++ b/types/hapi/v17/test/server/server-state.ts @@ -6,12 +6,12 @@ const options: ServerOptions = { }; const serverRoute: ServerRoute = { - path: '/say-hello', - method: 'GET', + path: "/say-hello", + method: "GET", handler(_request, h) { - h.state('test', { test: true }); - return h.response('Hello').state('data', { firstVisit: false }); - } + h.state("test", { test: true }); + return h.response("Hello").state("data", { firstVisit: false }); + }, }; const server = new Server(options); @@ -21,8 +21,8 @@ const stateOption: ServerStateCookieOptions = { ttl: 24 * 60 * 60 * 1000, // One day isSecure: false, isHttpOnly: false, - encoding: 'base64json', + encoding: "base64json", }; -server.state('data', stateOption); +server.state("data", stateOption); server.start(); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/v17/test/server/server-stop.ts b/types/hapi/v17/test/server/server-stop.ts index 7922fa944ef040..7fab70d26ffe15 100644 --- a/types/hapi/v17/test/server/server-stop.ts +++ b/types/hapi/v17/test/server/server-stop.ts @@ -6,11 +6,11 @@ const server = new Server({ }); server.start(); -server.events.on('start', () => { - console.log('Server started at: ' + server.info.uri); +server.events.on("start", () => { + console.log("Server started at: " + server.info.uri); }); -server.events.on('stop', () => { - console.log('Server stoped.'); +server.events.on("stop", () => { + console.log("Server stoped."); }); setTimeout(() => { server.stop({ timeout: 10 * 1000 }); diff --git a/types/hapi/v17/test/server/server-table.ts b/types/hapi/v17/test/server/server-table.ts index 79726118b51fcc..410d245f6818fa 100644 --- a/types/hapi/v17/test/server/server-table.ts +++ b/types/hapi/v17/test/server/server-table.ts @@ -6,14 +6,14 @@ const options: ServerOptions = { }; const server = new Server(options); -server.app.key = 'value2'; +server.app.key = "value2"; server.route({ - path: '/', - method: 'GET', + path: "/", + method: "GET", handler(request, h) { return h.response("Hello World"); - } + }, }); server.start(); @@ -26,4 +26,4 @@ console.log(table[0].realm); console.log(table[0].settings); console.log(table[0].fingerprint); console.log(table[0].auth); -console.log('Server started at: ' + server.info.uri); +console.log("Server started at: " + server.info.uri); diff --git a/types/hapi/v17/test/server/server-version.ts b/types/hapi/v17/test/server/server-version.ts index b8e59497fc00ab..a712232a7f50a3 100644 --- a/types/hapi/v17/test/server/server-version.ts +++ b/types/hapi/v17/test/server/server-version.ts @@ -6,4 +6,4 @@ const server = new Server({ }); server.start(); -console.log(server.version); // 17.x.x +console.log(server.version); // 17.x.x diff --git a/types/hapi/v8/hapi-tests.ts b/types/hapi/v8/hapi-tests.ts index 7819001423cbb2..ebd5f6f7999be3 100644 --- a/types/hapi/v8/hapi-tests.ts +++ b/types/hapi/v8/hapi-tests.ts @@ -1,5 +1,3 @@ - - import Hapi = require("hapi"); // Create a server with a host and port @@ -11,44 +9,44 @@ server.connection({ // Add plugins var plugin: any = { - register: function (plugin: Object, options: Object, next: Function) { + register: function(plugin: Object, options: Object, next: Function) { next(); - } + }, }; plugin.register.attributes = { name: "test", - version: "1.0.0" + version: "1.0.0", }; // optional options parameter -server.register({}, function (err) { +server.register({}, function(err) { }); // optional options.routes.vhost parameter -server.register({}, {select: 'api', routes: {prefix: '/prefix'}}, function (err) { +server.register({}, { select: "api", routes: { prefix: "/prefix" } }, function(err) { }); -//server.pack.register(plugin, (err: Object) => { +// server.pack.register(plugin, (err: Object) => { // if (err) { throw err; } -//}); +// }); -//server.pack.register([plugin], (err: Object) => { +// server.pack.register([plugin], (err: Object) => { // if (err) { throw err; } -//}); +// }); // Add server method -var add = function (a: number, b: number, next: (err: any, result?: any, ttl?: number) => void) { +var add = function(a: number, b: number, next: (err: any, result?: any, ttl?: number) => void) { next(null, a + b); }; -server.method("sum", add);//, { cache: { expiresIn: 2000 } }); +server.method("sum", add); // , { cache: { expiresIn: 2000 } }); server.methods["sum"](4, 5, (err: any, result: any) => { console.log(result); }); -var addArray = function (array: Array, next: (err: any, result?: any, ttl?: number) => void) { +var addArray = function(array: Array, next: (err: any, result?: any, ttl?: number) => void) { var sum: number = 0; array.forEach((item: number) => { sum += item; @@ -57,10 +55,10 @@ var addArray = function (array: Array, next: (err: any, result?: any, tt }; server.method("sumObj", addArray, { - //cache: { expiresIn: 2000 }, + // cache: { expiresIn: 2000 }, generateKey: (array: Array) => { - return array.join(','); - } + return array.join(","); + }, }); server.methods["sumObj"]([5, 6], (err: any, result: any) => { @@ -69,59 +67,59 @@ server.methods["sumObj"]([5, 6], (err: any, result: any) => { // Add the route server.route({ - method: 'GET', - path: '/hello', - handler: function (request: Hapi.Request, reply: Function) { - reply('hello world'); - } + method: "GET", + path: "/hello", + handler: function(request: Hapi.Request, reply: Function) { + reply("hello world"); + }, }); server.route([{ - method: 'GET', - path: '/hello2', - handler: function (request: Hapi.Request, reply: Function) { - reply('hello world2'); - } + method: "GET", + path: "/hello2", + handler: function(request: Hapi.Request, reply: Function) { + reply("hello world2"); + }, }]); // config.validate parameters should be optional server.route([{ - method: 'GET', - path: '/hello2', - handler: function (request: Hapi.Request, reply: Function) { - reply('hello world2'); + method: "GET", + path: "/hello2", + handler: function(request: Hapi.Request, reply: Function) { + reply("hello world2"); }, config: { - validate: {} - } + validate: {}, + }, }]); server.route([{ - method: 'GET', - path: '/hello3', - handler: function (request: Hapi.Request, reply: Function) { + method: "GET", + path: "/hello3", + handler: function(request: Hapi.Request, reply: Function) { reply().code(201); - } + }, }]); server.route([{ - method: 'GET', - path: '/hello4', - handler: function (request: Hapi.Request, reply: Hapi.IReply) { - reply('hello world2'); - } + method: "GET", + path: "/hello4", + handler: function(request: Hapi.Request, reply: Hapi.IReply) { + reply("hello world2"); + }, }]); interface IHello { - msg: string + msg: string; } server.route([{ - method: 'GET', - path: '/hello5', - handler: function (request: Hapi.Request, reply: Hapi.IStrictReply) { - reply({ msg: 'hello world' }) - } + method: "GET", + path: "/hello5", + handler: function(request: Hapi.Request, reply: Hapi.IStrictReply) { + reply({ msg: "hello world" }); + }, }]); // Start the server diff --git a/types/hapi/v8/index.d.ts b/types/hapi/v8/index.d.ts index d52ccfdc8578eb..d34317ed95bb18 100644 --- a/types/hapi/v8/index.d.ts +++ b/types/hapi/v8/index.d.ts @@ -3,11 +3,10 @@ // Definitions by: Jason Swearingen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -//This is a total rewrite of Hakubo's original hapi.d.ts, as it was out of date/incomplete. +// This is a total rewrite of Hakubo's original hapi.d.ts, as it was out of date/incomplete. /// - import http = require("http"); import stream = require("stream"); import Events = require("events"); @@ -17,7 +16,7 @@ interface IDictionary { } /** Boom Module for errors. https://github.com/hapijs/boom -* boom provides a set of utilities for returning HTTP errors. Each utility returns a Boom error response object (instance of Error) which includes the following properties: */ + * boom provides a set of utilities for returning HTTP errors. Each utility returns a Boom error response object (instance of Error) which includes the following properties: */ export interface IBoom extends Error { /** if true, indicates this is a Boom object instance. */ isBoom: boolean; @@ -43,7 +42,6 @@ export interface IBoom extends Error { }; /** reformat()rebuilds error.output using the other object properties. */ reformat(): void; - } /** cache functionality via the "CatBox" module. */ @@ -79,7 +77,6 @@ export interface ISeverConnectionOptions extends IConnectionConfigurationServerD labels?: string | string[] | undefined; /** - used to create an HTTPS connection.The tls object is passed unchanged as options to the node.js HTTPS server as described in the node.js HTTPS documentation.Set to true when passing a listener object that has been configured to use TLS directly. */ tls?: boolean | undefined; - } export interface IConnectionConfigurationServerDefaults { @@ -147,19 +144,25 @@ export interface IServerOptions { minimal?: boolean | undefined; /** plugin-specific configuration which can later be accessed via server.settings.plugins. plugins is an object where each key is a plugin name and the value is the configuration. Note the difference between server.settings.plugins which is used to store static configuration values and server.plugins which is meant for storing run-time state. Defaults to {}.*/ plugins?: IDictionary | undefined; - } export interface IServerViewCompile { (template: string, options: any): void; - (template: string, options: any, callback: (err: any, compiled: (context: any, options: any, callback: (err: any, rendered: boolean) => void) => void) => void): void; + ( + template: string, + options: any, + callback: ( + err: any, + compiled: (context: any, options: any, callback: (err: any, rendered: boolean) => void) => void, + ) => void, + ): void; } export interface IServerViewsAdditionalOptions { /** path - the root file path used to resolve and load the templates identified when calling reply.view().Defaults to current working directory.*/ path?: string | undefined; - /**partialsPath - the root file path where partials are located.Partials are small segments of template code that can be nested and reused throughout other templates.Defaults to no partials support (empty path). - */ + /** partialsPath - the root file path where partials are located.Partials are small segments of template code that can be nested and reused throughout other templates.Defaults to no partials support (empty path). + */ partialsPath?: string | undefined; /**helpersPath - the directory path where helpers are located.Helpers are functions used within templates to perform transformations and other data manipulations using the template context or other inputs.Each '.js' file in the helpers directory is loaded and the file name is used as the helper name.The files must export a single method with the signature function(context) and return a string.Sub - folders are not supported and are ignored.Defaults to no helpers support (empty path).Note that jade does not support loading helpers this way.*/ helpersPath?: string | undefined; @@ -193,11 +196,18 @@ export interface IServerViewsAdditionalOptions { } export interface IServerViewsEnginesOptions extends IServerViewsAdditionalOptions { - /**- the npm module used for rendering the templates.The module object must contain: "module", the rendering function. The required function signature depends on the compileMode settings. - * If the compileMode is 'sync', the signature is compile(template, options), the return value is a function with signature function(context, options), and the method is allowed to throw errors.If the compileMode is 'async', the signature is compile(template, options, callback) where callback has the signature function(err, compiled) where compiled is a function with signature function(context, options, callback) and callback has the signature function(err, rendered).*/ + /** - the npm module used for rendering the templates.The module object must contain: "module", the rendering function. The required function signature depends on the compileMode settings. + * If the compileMode is 'sync', the signature is compile(template, options), the return value is a function with signature function(context, options), and the method is allowed to throw errors.If the compileMode is 'async', the signature is compile(template, options, callback) where callback has the signature function(err, compiled) where compiled is a function with signature function(context, options, callback) and callback has the signature function(err, rendered). */ module: { compile?(template: any, options: any): (context: any, options: any) => void; - compile?(template: any, options: any, callback: (err: any, compiled: (context: any, options: any, callback: (err: any, rendered: any) => void) => void) => void): void; + compile?( + template: any, + options: any, + callback: ( + err: any, + compiled: (context: any, options: any, callback: (err: any, rendered: any) => void) => void, + ) => void, + ): void; }; } @@ -222,7 +232,7 @@ export interface IServerViewsConfiguration extends IServerViewsAdditionalOptions } interface IReplyMethods { /** Returns control back to the framework without setting a response. If called in the handler, the response defaults to an empty payload with status code 200. - * The data argument is only used for passing back authentication data and is ignored elsewhere. */ + * The data argument is only used for passing back authentication data and is ignored elsewhere. */ continue(credentialData?: any): void; /** Transmits a file from the file system. The 'Content-Type' header defaults to the matching mime type based on filename extension. The response flow control rules do not apply. */ @@ -240,7 +250,8 @@ interface IReplyMethods { mode?: boolean | string | undefined; /** if true, looks for the same filename with the '.gz' suffix for a pre-compressed version of the file to serve if the request supports content encoding. Defaults to false. */ lookupCompressed: boolean; - }): void; + }, + ): void; /** Concludes the handler activity by returning control over to the router with a templatized view response. the response flow control rules apply. */ @@ -250,7 +261,8 @@ interface IReplyMethods { /** optional object used by the template to render context-specific result. Defaults to no context {}. */ context?: {}, /** optional object used to override the server's views manager configuration for this response. Cannot override isCached, partialsPath, or helpersPath which are only loaded at initialization. */ - options?: any): Response; + options?: any, + ): Response; /** Concludes the handler activity by returning control over to the router and informing the router that a response has already been sent back directly via request.raw.res and that no further response action is needed The response flow control rules do not apply. */ close(options?: { @@ -260,8 +272,10 @@ interface IReplyMethods { /** Proxies the request to an upstream endpoint. the response flow control rules do not apply. */ - proxy(/** an object including the same keys and restrictions defined by the route proxy handler options. */ - options: IProxyHandlerConfig): void; + proxy( + /** an object including the same keys and restrictions defined by the route proxy handler options. */ + options: IProxyHandlerConfig, + ): void; /** Redirects the client to the specified uri. Same as calling reply().redirect(uri). The response flow control rules apply. */ redirect(uri: string): Response; @@ -274,10 +288,11 @@ Since an request can only have one response regardless if it is an error or succ FLOW CONTROL: When calling reply(), the framework waits until process.nextTick() to continue processing the request and transmit the response. This enables making changes to the returned response object before the response is sent. This means the framework will resume as soon as the handler method exits. To suspend this behavior, the returned response object supports the following methods: hold(), send() */ export interface IReply extends IReplyMethods { - (err: Error, + ( + err: Error, result?: string | number | boolean | Buffer | stream.Stream | Promise | T, /** Note that when used to return both an error and credentials in the authentication methods, reply() must be called with three arguments function(err, null, data) where data is the additional authentication information. */ - credentialData?: any + credentialData?: any, ): IBoom; /** Note that if result is a Stream with a statusCode property, that status code will be used as the default response code. */ (result?: string | number | boolean | Buffer | stream.Stream | Promise | T): Response; @@ -290,10 +305,12 @@ export interface IReply extends IReplyMethods { FLOW CONTROL: When calling reply(), the framework waits until process.nextTick() to continue processing the request and transmit the response. This enables making changes to the returned response object before the response is sent. This means the framework will resume as soon as the handler method exits. To suspend this behavior, the returned response object supports the following methods: hold(), send() */ export interface IStrictReply extends IReplyMethods { - (err: Error, + ( + err: Error, result?: Promise | T, /** Note that when used to return both an error and credentials in the authentication methods, reply() must be called with three arguments function(err, null, data) where data is the additional authentication information. */ - credentialData?: any): IBoom; + credentialData?: any, + ): IBoom; /** Note that if result is a Stream with a statusCode property, that status code will be used as the default response code. */ (result: Promise | T): Response; } @@ -304,14 +321,14 @@ export interface ISessionHandler { export interface IStrictSessionHandler { (request: Request, reply: IStrictReply): void; - } +} - export interface IRequestHandler { +export interface IRequestHandler { (request: Request): T; } export interface IFailAction { - (source: string, error: any, next: () => void): void + (source: string, error: any, next: () => void): void; } /** generates a reverse proxy handler */ export interface IProxyHandlerConfig { @@ -345,16 +362,20 @@ export interface IProxyHandlerConfig { err - internal error condition. uri - the absolute proxy URI. headers - optional object where each key is an HTTP request header and the value is the header content.*/ - mapUri?: ((request: Request, callback: (err: any, uri: string, headers?: { [key: string]: string }) => void) => void) | undefined; + mapUri?: + | ((request: Request, callback: (err: any, uri: string, headers?: { [key: string]: string }) => void) => void) + | undefined; /** a custom function for processing the response from the upstream service before sending to the client. Useful for custom error handling of responses from the proxied endpoint or other payload manipulation. Function signature is function(err, res, request, reply, settings, ttl) where: - err - internal or upstream error returned from attempting to contact the upstream proxy. - res - the node response object received from the upstream service. res is a readable stream (use the wreck module read method to easily convert it to a Buffer or string). - request - is the incoming request object. - reply - the reply interface function. - settings - the proxy handler configuration. - ttl - the upstream TTL in milliseconds if proxy.ttl it set to 'upstream' and the upstream response included a valid 'Cache-Control' header with 'max-age'.*/ - onResponse?: (( - err: any, - res: http.ServerResponse, - req: Request, - reply: () => void, - settings: IProxyHandlerConfig, - ttl: number - ) => void) | undefined; + onResponse?: + | (( + err: any, + res: http.ServerResponse, + req: Request, + reply: () => void, + settings: IProxyHandlerConfig, + ttl: number, + ) => void) + | undefined; /** if set to 'upstream', applies the upstream response caching policy to the response using the response.ttl() method (or passed as an argument to the onResponse method if provided).*/ ttl?: number | undefined; /** - a node http(s) agent to be used for connections to upstream server. see https://nodejs.org/api/http.html#http_class_http_agent */ @@ -364,17 +385,17 @@ export interface IProxyHandlerConfig { } /** TODO: fill in joi definition */ export interface IJoi { - } /** a validation function using the signature function(value, options, next) */ export interface IValidationFunction { - - (/** the object containing the path parameters. */ + ( + /** the object containing the path parameters. */ value: any, /** the server validation options. */ options: any, /** the callback function called when validation is completed. */ - next: (err: any, value: any) => void): void; + next: (err: any, value: any) => void, + ): void; } /** a custom error handler function with the signature 'function(request, reply, source, error)` */ export interface IRouteFailFunction { @@ -387,7 +408,8 @@ export interface IRouteFailFunction { /** the source of the invalid field (e.g. 'path', 'query', 'payload'). */ source: string, /** the error object prepared for the client response (including the validation function error under error.data). */ - error: any): void; + error: any, + ): void; } /** Each route can be customize to change the default behavior of the request lifecycle using the following options: */ @@ -397,8 +419,7 @@ export interface IRouteAdditionalConfigurationOptions { /** authentication configuration.Value can be: false to disable authentication if a default strategy is set. a string with the name of an authentication strategy registered with server.auth.strategy(). an object */ - auth?: boolean | string | - { + auth?: boolean | string | { /** the authentication mode.Defaults to 'required' if a server authentication strategy is configured, otherwise defaults to no authentication.Available values: 'required'authentication is required. 'optional'authentication is optional (must be valid if present). @@ -462,12 +483,13 @@ export interface IRouteAdditionalConfigurationOptions { override?: boolean | undefined; } | undefined; /** defines the behavior for serving static resources using the built-in route handlers for files and directories: */ - files?: {/** determines the folder relative paths are resolved against when using the file and directory handlers. */ + files?: { + /** determines the folder relative paths are resolved against when using the file and directory handlers. */ relativeTo: string; } | undefined; /** an alternative location for the route handler option. */ - handler?: ISessionHandler | IStrictSessionHandler | string | IRouteHandlerConfig | undefined; + handler?: ISessionHandler | IStrictSessionHandler | string | IRouteHandlerConfig | undefined; /** an optional unique identifier used to look up the route using server.lookup(). */ id?: number | undefined; /** optional arguments passed to JSON.stringify() when converting an object or error response to a string payload.Supports the following: */ @@ -585,7 +607,6 @@ export interface IRouteAdditionalConfigurationOptions { */ headers?: boolean | IJoi | IValidationFunction | undefined; - /** validation rules for incoming request path parameters, after matching the path against the route and extracting any parameters then stored in request.params.Values allowed: trueany path parameters allowed (no validation performed).This is the default. falseno path variables allowed. @@ -637,17 +658,17 @@ export interface IRouteAdditionalConfigurationOptions { } | undefined; /** ONLY WHEN ADDING NEW ROUTES (not when setting defaults). - *route description used for generating documentation (string). - */ + * route description used for generating documentation (string). + */ description?: string | undefined; /** ONLY WHEN ADDING NEW ROUTES (not when setting defaults). - *route notes used for generating documentation (string or array of strings). - */ + * route notes used for generating documentation (string or array of strings). + */ notes?: string | string[] | undefined; /** ONLY WHEN ADDING NEW ROUTES (not when setting defaults). - *route tags used for generating documentation (array of strings). - */ - tags?: string[] | undefined + * route tags used for generating documentation (array of strings). + */ + tags?: string[] | undefined; } /** server.realm http://hapijs.com/api#serverrealm The realm object contains server-wide or plugin-specific state that can be shared across various methods. For example, when calling server.bind(), @@ -669,7 +690,6 @@ export interface IServerRealm { /** the route virtual host settings used by any calls to server.route() from the server. */ vhost: string; }; - }; /** the active plugin name (empty string if at the server root). */ plugin: string; @@ -681,19 +701,20 @@ export interface IServerRealm { relativeTo: any; }; bind: any; - } + }; } /** server.state(name, [options]) http://hapijs.com/api#serverstatename-options HTTP state management uses client cookies to persist a state across multiple requests. Registers a cookie definitions where:*/ export interface IServerState { -/** - the cookie name string. */name: string; - -/** - are the optional cookie settings: */options: { -/** - time - to - live in milliseconds.Defaults to null (session time- life - cookies are deleted when the browser is closed).*/ttl: number; -/** - sets the 'Secure' flag.Defaults to false.*/isSecure: boolean; -/** - sets the 'HttpOnly' flag.Defaults to false.*/isHttpOnly: boolean -/** - the path scope.Defaults to null (no path).*/path: any; -/** - the domain scope.Defaults to null (no domain). */domain: any; + /** - the cookie name string. */ name: string; + + /** - are the optional cookie settings: */ options: { + /** - time - to - live in milliseconds.Defaults to null (session time- life - cookies are deleted when the browser is closed).*/ ttl: + number; + /** - sets the 'Secure' flag.Defaults to false.*/ isSecure: boolean; + /** - sets the 'HttpOnly' flag.Defaults to false.*/ isHttpOnly: boolean; + /** - the path scope.Defaults to null (no path).*/ path: any; + /** - the domain scope.Defaults to null (no domain). */ domain: any; /** if present and the cookie was not received from the client or explicitly set by the route handler, the cookie is automatically added to the response with the provided value. The value can be a function with signature function(request, next) where: request - the request object. next - the continuation function using the function(err, value) signature.*/ @@ -705,16 +726,19 @@ export interface IServerState { 'form' - object value is encoded using the x-www-form-urlencoded method. 'iron' - Encrypts and sign the value using iron.*/ encoding: string; -/** - an object used to calculate an HMAC for cookie integrity validation.This does not provide privacy, only a mean to verify that the cookie value was generated by the server.Redundant when 'iron' encoding is used.Options are:*/sign: { -/** - algorithm options.Defaults to require('iron').defaults.integrity.*/integrity: any; -/** - password used for HMAC key generation.*/password: string; - }; -/** - password used for 'iron' encoding.*/password: string; -/** - options for 'iron' encoding.Defaults to require('iron').defaults.*/iron: any; -/** - if false, errors are ignored and treated as missing cookies.*/ignoreErrors: boolean; -/** - if true, automatically instruct the client to remove invalid cookies.Defaults to false.*/clearInvalid: boolean; -/** - if false, allows any cookie value including values in violation of RFC 6265. Defaults to true.*/strictHeader: boolean; -/** - overrides the default proxy localStatePassThrough setting.*/passThrough: any; + /** - an object used to calculate an HMAC for cookie integrity validation.This does not provide privacy, only a mean to verify that the cookie value was generated by the server.Redundant when 'iron' encoding is used.Options are:*/ sign: + { + /** - algorithm options.Defaults to require('iron').defaults.integrity.*/ integrity: any; + /** - password used for HMAC key generation.*/ password: string; + }; + /** - password used for 'iron' encoding.*/ password: string; + /** - options for 'iron' encoding.Defaults to require('iron').defaults.*/ iron: any; + /** - if false, errors are ignored and treated as missing cookies.*/ ignoreErrors: boolean; + /** - if true, automatically instruct the client to remove invalid cookies.Defaults to false.*/ clearInvalid: + boolean; + /** - if false, allows any cookie value including values in violation of RFC 6265. Defaults to true.*/ strictHeader: + boolean; + /** - overrides the default proxy localStatePassThrough setting.*/ passThrough: any; }; } @@ -770,7 +794,7 @@ export interface IRouteHandlerConfig { params: any; query: any; pre: any; - } + }; } | undefined; config?: { handler: any; @@ -832,19 +856,17 @@ export interface IRouteConfiguration { /** - (required) the absolute path used to match incoming requests (must begin with '/'). Incoming requests are compared to the configured paths based on the connection router configuration option.The path can include named parameters enclosed in {} which will be matched against literal values in the request as described in Path parameters.*/ path: string; /** - (required) the HTTP method.Typically one of 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', or 'OPTIONS'.Any HTTP method is allowed, except for 'HEAD'.Use '*' to match against any HTTP method (only when an exact match was not found, and any match with a specific method will be given a higher priority over a wildcard match). - * Can be assigned an array of methods which has the same result as adding the same route with different methods manually.*/ + * Can be assigned an array of methods which has the same result as adding the same route with different methods manually. */ method: string | string[]; /** - an optional domain string or an array of domain strings for limiting the route to only requests with a matching host header field.Matching is done against the hostname part of the header only (excluding the port).Defaults to all hosts.*/ vhost?: string | undefined; /** - (required) the function called to generate the response after successful authentication and validation.The handler function is described in Route handler.If set to a string, the value is parsed the same way a prerequisite server method string shortcut is processed.Alternatively, handler can be assigned an object with a single key using the name of a registered handler type and value with the options passed to the registered handler.*/ - handler: ISessionHandler | IStrictSessionHandler | string | IRouteHandlerConfig; + handler: ISessionHandler | IStrictSessionHandler | string | IRouteHandlerConfig; /** - additional route options.*/ config?: IRouteAdditionalConfigurationOptions | undefined; } /** Route public interface When route information is returned or made available as a property. http://hapijs.com/api#route-public-interface */ export interface IRoute { - - /** the route HTTP method. */ method: string; /** the route path. */ @@ -910,33 +932,32 @@ export interface IServerAuthScheme { options?: { /** if true, requires payload validation as part of the scheme and forbids routes from disabling payload auth validation. Defaults to false.*/ payload: boolean; - } | undefined + } | undefined; } - - export interface IServerInject { - (options: { - /** the request HTTP method (e.g. 'POST'). Defaults to 'GET'.*/ - method: string; - /** the request URL. If the URI includes an authority (e.g. 'example.com:8080'), it is used to automatically set an HTTP 'Host' header, unless one was specified in headers.*/ - url: string; - /** an object with optional request headers where each key is the header name and the value is the header content. Defaults to no additions to the default Shot headers.*/ - headers: IDictionary; - /**- an optional string or buffer containing the request payload (object must be manually converted to a string first). Defaults to no payload. Note that payload processing defaults to 'application/json' if no 'Content-Type' header provided.*/ - payload: string | Buffer; - /**an optional credentials object containing authentication information. The credentials are used to bypass the default authentication strategies, and are validated directly as if they were received via an authentication scheme. Defaults to no credentials.*/ - credentials: any; - /**object with options used to simulate client request stream conditions for testing: + ( + options: { + /** the request HTTP method (e.g. 'POST'). Defaults to 'GET'.*/ + method: string; + /** the request URL. If the URI includes an authority (e.g. 'example.com:8080'), it is used to automatically set an HTTP 'Host' header, unless one was specified in headers.*/ + url: string; + /** an object with optional request headers where each key is the header name and the value is the header content. Defaults to no additions to the default Shot headers.*/ + headers: IDictionary; + /**- an optional string or buffer containing the request payload (object must be manually converted to a string first). Defaults to no payload. Note that payload processing defaults to 'application/json' if no 'Content-Type' header provided.*/ + payload: string | Buffer; + /**an optional credentials object containing authentication information. The credentials are used to bypass the default authentication strategies, and are validated directly as if they were received via an authentication scheme. Defaults to no credentials.*/ + credentials: any; + /**object with options used to simulate client request stream conditions for testing: error - if true, emits an 'error' event after payload transmission (if any). Defaults to false. close - if true, emits a 'close' event after payload transmission (if any). Defaults to false. end - if false, does not end the stream. Defaults to true.*/ - simulate: { - error: boolean; - close: boolean; - end: boolean; - }; - }, + simulate: { + error: boolean; + close: boolean; + end: boolean; + }; + }, callback: ( /**the response object where: statusCode - the HTTP status code. @@ -948,12 +969,19 @@ export interface IServerInject { res - the simulated node response object. result - the raw handler response (e.g. when not a stream or a view) before it is serialized for transmission. If not available, the value is set to payload. Useful for inspection and reuse of the internal objects returned (instead of parsing the response string). request - the request object.*/ - res: { statusCode: number; headers: IDictionary; payload: string; rawPayload: Buffer; raw: { req: http.ClientRequest; res: http.ServerResponse }; result: string; request: Request }) => void + res: { + statusCode: number; + headers: IDictionary; + payload: string; + rawPayload: Buffer; + raw: { req: http.ClientRequest; res: http.ServerResponse }; + result: string; + request: Request; + }, + ) => void, ): void; - } - /** host - optional host to filter routes matching a specific virtual host. Defaults to all virtual hosts. The return value is an array where each item is an object containing: info - the connection.info the connection the table was generated for. @@ -992,7 +1020,7 @@ export interface ICookieSettings { /** - an object used to calculate an HMAC for cookie integrity validation.This does not provide privacy, only a mean to verify that the cookie value was generated by the server.Redundant when 'iron' encoding is used.Options are: integrity - algorithm options.Defaults to require('iron').defaults.integrity. password - password used for HMAC key generation. */ - sign?: { integrity: any; password: string; } | undefined + sign?: { integrity: any; password: string } | undefined; password?: string | undefined; iron?: any; ignoreErrors?: boolean | undefined; @@ -1013,13 +1041,12 @@ arg1, arg2, etc. - the method function arguments. the callback option is set to false. the method must returns a value (result, Error, or a promise) or throw an Error.*/ export interface IServerMethod { - //(): void; - //(next: (err: any, result: any, ttl: number) => void): void; - //(arg1: any): void; - //(arg1: any, arg2: any, next: (err: any, result: any, ttl: number) => void): void; - //(arg1: any, arg2: any): void; + // (): void; + // (next: (err: any, result: any, ttl: number) => void): void; + // (arg1: any): void; + // (arg1: any, arg2: any, next: (err: any, result: any, ttl: number) => void): void; + // (arg1: any, arg2: any): void; (...args: any[]): void; - } /** options - optional configuration: bind - a context object passed back to the method function (via this) when called. Defaults to active context (set via server.bind() when the method is registered. @@ -1083,7 +1110,7 @@ export declare class Request extends Events.EventEmitter { /** the authentication error is failed and mode set to 'try'.*/ error: any; /** an object used by the ['cookie' authentication scheme] https://github.com/hapijs/hapi-auth-cookie */ - session: any + session: any; }; /** the node domain object used to protect against exceptions thrown in extensions, handlers and route prerequisites. Can be used to manually bind callback functions otherwise bound to other domains.*/ domain: any; @@ -1244,7 +1271,8 @@ export declare class Request extends Events.EventEmitter { /** an optional message string or object with the application data being logged.*/ data?: any, /** an optional timestamp expressed in milliseconds. Defaults to Date.now() (now).*/ - timestamp?: number): void; + timestamp?: number, + ): void; /** request.getLog([tags], [internal]) Always available. @@ -1260,7 +1288,8 @@ export declare class Request extends Events.EventEmitter { /** is a single tag string or array of tag strings. If no tags specified, returns all events.*/ tags?: string, /** filters the events to only those with a matching event.internal value. If true, only internal logs are included. If false, only user event are included. Defaults to all events (undefined).*/ - internal?: boolean): string[]; + internal?: boolean, + ): string[]; /** request.tail([name]) @@ -1299,7 +1328,8 @@ export declare class Request extends Events.EventEmitter { });*/ tail( /** an optional tail name used for logging purposes.*/ - name?: string): Function; + name?: string, + ): Function; } /** Response events @@ -1365,7 +1395,7 @@ export declare class Response extends Events.EventEmitter { stringify: any; ttl: number; varyEtag: boolean; - } + }; /** sets the HTTP 'Content-Length' header (to avoid chunked transfer encoding) where: length - the header value. Must match the actual payload size.*/ @@ -1379,7 +1409,6 @@ export declare class Response extends Events.EventEmitter { /** sets the HTTP status code to Created (201) and the HTTP 'Location' header where: uri - an absolute or relative URI used as the 'Location' header value.*/ created(uri: string): void; - /** encoding(encoding) - sets the string encoding scheme used to serial data into the HTTP payload where: encoding - the encoding property value (see node Buffer encoding).*/ encoding(encoding: string): void; @@ -1389,7 +1418,8 @@ export declare class Response extends Events.EventEmitter { weak - if true, the tag will be prefixed with the 'W/' weak signifier. Weak tags will fail to match identical tags for the purpose of determining 304 response status. Defaults to false. vary - if true and content encoding is set or applied to the response (e.g 'gzip' or 'deflate'), the encoding name will be automatically added to the tag at transmission time (separated by a '-' character). Ignored when weak is true. Defaults to true.*/ etag(tag: string, options: { - weak: boolean; vary: boolean; + weak: boolean; + vary: boolean; }): void; /**header(name, value, options) - sets an HTTP header where: @@ -1425,11 +1455,8 @@ export declare class Response extends Events.EventEmitter { value - the cookie value. If no encoding is defined, must be a string. options - optional configuration. If the state was previously registered with the server using server.state(), the specified keys in options override those same keys in the server definition (but not others).*/ state(name: string, value: string, options?: any): void; - } - - /** Server http://hapijs.com/api#server rver object is the main application container. The server manages all incoming connections along with all the facilities provided by the framework. A server can contain more than one connection (e.g. listen to port 80 and 8080). Server events @@ -1445,7 +1472,6 @@ The server object inherits from Events.EventEmitter and emits the following even Note that the server object should not be used to emit application events as its internal implementation is designed to fan events out to the various plugin selections and not for application events. MORE EVENTS HERE: http://hapijs.com/api#server-events*/ export declare class Server extends Events.EventEmitter { - constructor(options?: IServerOptions); /** Provides a safe place to store server-specific run-time application data without potential conflicts with the framework internals. The data can be accessed whenever the server is accessible. Initialized with an empty object. var Hapi = require('hapi'); @@ -1646,7 +1672,8 @@ export declare class Server extends Events.EventEmitter { scheme - the method implementing the scheme with signature function(server, options) where: server - a reference to the server object the scheme is added to. options - optional scheme settings used to instantiate a strategy.*/ - scheme(name: string, + scheme( + name: string, /** When the scheme authenticate() method implementation calls reply() with an error condition, the specifics of the error affect whether additional authentication strategies will be attempted if configured for the route. If the err returned by the reply() method includes a message, no additional strategies will be attempted. If the err does not include a message but does include a scheme name (e.g. Boom.unauthorized(null, 'Custom')), additional strategies will be attempted in order of preference. n the scheme payload() method returns an error with a message, it means payload validation failed due to bad payload. If the error has no message but includes a scheme name (e.g. Boom.unauthorized(null, 'Custom')), authentication may still be successful if the route auth.payload configuration is set to 'optional'. server = new Hapi.Server(); @@ -1664,7 +1691,8 @@ export declare class Server extends Events.EventEmitter { }; }; */ - scheme: (server: Server, options: any) => IServerAuthScheme): void; + scheme: (server: Server, options: any) => IServerAuthScheme, + ): void; /** server.auth.strategy(name, scheme, [mode], [options]) Registers an authentication strategy where: @@ -1731,7 +1759,6 @@ export declare class Server extends Events.EventEmitter { };*/ bind(context: any): void; - /** server.cache(options) Provisions a cache segment within the server cache facility where: options - catbox policy configuration where: @@ -1807,7 +1834,6 @@ export declare class Server extends Events.EventEmitter { };*/ dependency(dependencies: string | string[], after?: (server: Server, next: (err: any) => void) => void): void; - /** server.expose(key, value) Used within a plugin to expose a property via server.plugins[name] where: key - the key assigned (server.plugins[name][key]). @@ -1852,8 +1878,16 @@ export declare class Server extends Events.EventEmitter { server.route({ method: 'GET', path: '/test', handler: handler }); server.start(); // All requests will get routed to '/test'*/ - ext(event: string, method: (request: Request, reply: IReply, bind?: any) => void, options?: { before: string | string[]; after: string | string[]; bind?: any }): void; - ext(event: string, method: (request: Request, reply: IStrictReply, bind?: any) => void, options?: { before: string | string[]; after: string | string[]; bind?: any }): void; + ext( + event: string, + method: (request: Request, reply: IReply, bind?: any) => void, + options?: { before: string | string[]; after: string | string[]; bind?: any }, + ): void; + ext( + event: string, + method: (request: Request, reply: IStrictReply, bind?: any) => void, + options?: { before: string | string[]; after: string | string[]; bind?: any }, + ): void; /** server.handler(name, method) Registers a new handler type to be used in routes where: @@ -1963,9 +1997,6 @@ export declare class Server extends Events.EventEmitter { When the server contains more than one connection, each server.connections array member provides its own connection.match() method.*/ match(method: string, path: string, host?: string): IRoute; - - - /** server.method(name, method, [options]) Registers a server method. Server methods are functions registered with the server and used throughout the application as a common utility. Their advantage is in the ability to configure them to use the built-in cache and share across multiple request handlers without having to create a common module. Methods are registered via server.method(name, method, [options]) @@ -2009,8 +2040,8 @@ export declare class Server extends Events.EventEmitter { /** a unique method name used to invoke the method via server.methods[name]. When configured with caching enabled, server.methods[name].cache.drop(arg1, arg2, ..., argn, callback) can be used to clear the cache for a given key. Supports using nested names such as utils.users.get which will automatically create the missing path under server.methods and can be accessed for the previous example via server.methods.utils.users.get.*/ name: string, method: IServerMethod, - options?: IServerMethodOptions): void; - + options?: IServerMethodOptions, + ): void; /**server.method(methods) Registers a server method function as described in server.method() using a configuration object where: @@ -2030,11 +2061,19 @@ export declare class Server extends Events.EventEmitter { } } });*/ - method(methods: { - name: string; method: IServerMethod; options?: IServerMethodOptions | undefined - } | Array<{ - name: string; method: IServerMethod; options?: IServerMethodOptions | undefined - }>): void; + method( + methods: + | { + name: string; + method: IServerMethod; + options?: IServerMethodOptions | undefined; + } + | Array<{ + name: string; + method: IServerMethod; + options?: IServerMethodOptions | undefined; + }>, + ): void; /**server.path(relativeTo) Sets the path prefix used to locate static resources (files and view templates) when relative paths are used where: relativeTo - the path prefix added to any relative file path starting with '.'. @@ -2072,10 +2111,10 @@ export declare class Server extends Events.EventEmitter { register(plugins: any | any[], options: { select: string | string[]; routes: { - prefix: string; vhost?: string | string[] | undefined + prefix: string; + vhost?: string | string[] | undefined; }; - } - , callback: (err: any) => void): void; + }, callback: (err: any) => void): void; register(plugins: any | any[], callback: (err: any) => void): void; @@ -2102,7 +2141,12 @@ export declare class Server extends Events.EventEmitter { server.render('hello', context, function (err, rendered, config) { console.log(rendered); });*/ - render(template: string, context: any, options: any, callback: (err: any, rendered: any, config: any) => void): void; + render( + template: string, + context: any, + options: any, + callback: (err: any, rendered: any, config: any) => void, + ): void; /** server.route(options) Adds a connection route where: options - a route configuration object or an array of configuration objects. @@ -2231,5 +2275,4 @@ export declare class Server extends Events.EventEmitter { }); When server.views() is called within a plugin, the views manager is only available to plugins methods.*/ views(options: IServerViewsConfiguration): void; - } diff --git a/types/hapi__b64/hapi__b64-tests.ts b/types/hapi__b64/hapi__b64-tests.ts index 699fc2c65da4b6..75d38e4951eb98 100644 --- a/types/hapi__b64/hapi__b64-tests.ts +++ b/types/hapi__b64/hapi__b64-tests.ts @@ -1,17 +1,17 @@ -import * as B64 from '@hapi/b64'; -import * as fs from 'fs'; +import * as B64 from "@hapi/b64"; +import * as fs from "fs"; -const stream = fs.createReadStream('package.json'); +const stream = fs.createReadStream("package.json"); const encoder = new B64.Encoder(); const decoder = new B64.Decoder(); stream.pipe(encoder).pipe(process.stdout); stream.pipe(decoder).pipe(process.stdout); -B64.decode(Buffer.from('aHR0cHM6Ly9naXRodWIuY29t')); // $ExpectType Buffer -B64.encode(Buffer.from('https://github.com')); // $ExpectType Buffer +B64.decode(Buffer.from("aHR0cHM6Ly9naXRodWIuY29t")); // $ExpectType Buffer +B64.encode(Buffer.from("https://github.com")); // $ExpectType Buffer -B64.base64urlDecode('aHR0cHM6Ly9naXRodWIuY29t'); // $ExpectType string -B64.base64urlDecode('aHR0cHM6Ly9naXRodWIuY29t', 'ascii'); // $ExpectType string -B64.base64urlDecode('aHR0cHM6Ly9naXRodWIuY29t', 'buffer'); // $ExpectType Buffer -B64.base64urlEncode('https://github.com'); // $ExpectType string +B64.base64urlDecode("aHR0cHM6Ly9naXRodWIuY29t"); // $ExpectType string +B64.base64urlDecode("aHR0cHM6Ly9naXRodWIuY29t", "ascii"); // $ExpectType string +B64.base64urlDecode("aHR0cHM6Ly9naXRodWIuY29t", "buffer"); // $ExpectType Buffer +B64.base64urlEncode("https://github.com"); // $ExpectType string diff --git a/types/hapi__b64/index.d.ts b/types/hapi__b64/index.d.ts index 8a4a0fd6963dce..bde33c6a96b58f 100644 --- a/types/hapi__b64/index.d.ts +++ b/types/hapi__b64/index.d.ts @@ -5,7 +5,7 @@ /// -import * as stream from 'stream'; +import * as stream from "stream"; export class Decoder extends stream.Transform {} export class Encoder extends stream.Transform {} @@ -16,4 +16,4 @@ export function encode(buffer: Buffer): Buffer; export function base64urlEncode(value: string | Buffer, encoding?: BufferEncoding): string; export function base64urlDecode(value: string, encoding?: BufferEncoding): string; -export function base64urlDecode(value: string, encoding: 'buffer'): Buffer; +export function base64urlDecode(value: string, encoding: "buffer"): Buffer; diff --git a/types/hapi__basic/hapi__basic-tests.ts b/types/hapi__basic/hapi__basic-tests.ts index 81a6fe45790e68..a17fcda11ac368 100644 --- a/types/hapi__basic/hapi__basic-tests.ts +++ b/types/hapi__basic/hapi__basic-tests.ts @@ -1,8 +1,8 @@ // from https://github.com/hapijs/hapi-auth-basic#hapi-auth-basic -import Bcrypt = require('bcrypt'); -import Basic = require('@hapi/basic'); -import { Server } from '@hapi/hapi'; +import Bcrypt = require("bcrypt"); +import Basic = require("@hapi/basic"); +import { Server } from "@hapi/hapi"; const server = new Server(); @@ -13,31 +13,29 @@ interface User { id: string; } -const users: {[index: string]: User} = { +const users: { [index: string]: User } = { john: { - username: 'john', - password: '$2a$10$iqJSHD.BGr0E2IxQwYgJmeP3NvhPrXAeLSaGCj6IR/XU5QtjVu5Tm', // 'secret' - name: 'John Doe', - id: '2133d32a' - } + username: "john", + password: "$2a$10$iqJSHD.BGr0E2IxQwYgJmeP3NvhPrXAeLSaGCj6IR/XU5QtjVu5Tm", // 'secret' + name: "John Doe", + id: "2133d32a", + }, }; const validate: Basic.Validate = async (request, username, password, h) => { - const user = users[username]; if (!user) { return { isValid: false, credentials: null }; } - let isValid = await Bcrypt.compare(password, user.password) + let isValid = await Bcrypt.compare(password, user.password); return { isValid, credentials: { id: user.id, name: user.name } }; }; server.register(Basic).then(() => { + server.auth.strategy("simple", "basic", { validate }); + server.auth.default("simple"); - server.auth.strategy('simple', 'basic', { validate }); - server.auth.default('simple'); - - server.route({ method: 'GET', path: '/', options: { auth: 'simple' } }); + server.route({ method: "GET", path: "/", options: { auth: "simple" } }); }); diff --git a/types/hapi__basic/index.d.ts b/types/hapi__basic/index.d.ts index a7543d39a1a028..e27e5e579f6558 100644 --- a/types/hapi__basic/index.d.ts +++ b/types/hapi__basic/index.d.ts @@ -6,20 +6,25 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -import { Plugin, Request, ResponseToolkit } from '@hapi/hapi'; +import { Plugin, Request, ResponseToolkit } from "@hapi/hapi"; declare namespace Basic { interface ValidateCustomResponse { - response: any, + response: any; } interface ValidateResponse { - isValid: boolean, - credentials?: any, + isValid: boolean; + credentials?: any; } interface Validate { - (request: Request, username: string, password: string, h: ResponseToolkit): Promise; + ( + request: Request, + username: string, + password: string, + h: ResponseToolkit, + ): Promise; } } diff --git a/types/hapi__bell/hapi__bell-tests.ts b/types/hapi__bell/hapi__bell-tests.ts index 5990f67b90d006..8536e950142ddb 100644 --- a/types/hapi__bell/hapi__bell-tests.ts +++ b/types/hapi__bell/hapi__bell-tests.ts @@ -1,5 +1,5 @@ -import { Server } from '@hapi/hapi'; -import * as bell from '@hapi/bell'; +import * as bell from "@hapi/bell"; +import { Server } from "@hapi/hapi"; async function run() { const server = new Server({ port: 8000 }); @@ -8,141 +8,131 @@ async function run() { bell.simulate(async () => ({})); bell.simulate(() => ({})); - server.auth.strategy('arcgisonline', 'bell', { - provider: 'twitter', - password: 'some cookie password', - location: 'http://example.com/oauth', - clientId: '', - clientSecret: '', + server.auth.strategy("arcgisonline", "bell", { + provider: "twitter", + password: "some cookie password", + location: "http://example.com/oauth", + clientId: "", + clientSecret: "", scope(request) { - const scopes = ['public_profile', 'email']; + const scopes = ["public_profile", "email"]; if (request.query.wantsSharePermission) { - scopes.push('publish_actions'); + scopes.push("publish_actions"); } return scopes; - } + }, }); const providers: bell.BellOptions[] = [{ - provider: 'discord', - password: 'cookie_encryption_password_secure', + provider: "discord", + password: "cookie_encryption_password_secure", isSecure: false, - clientId: '', - clientSecret: '', - location: () => '', - }, - { - provider: 'facebook', - password: 'cookie_encryption_password_secure', + clientId: "", + clientSecret: "", + location: () => "", + }, { + provider: "facebook", + password: "cookie_encryption_password_secure", isSecure: false, - clientId: '', - clientSecret: '', - location: server.info.uri - }, - { - provider: 'google', - password: 'cookie_encryption_password_secure', + clientId: "", + clientSecret: "", + location: server.info.uri, + }, { + provider: "google", + password: "cookie_encryption_password_secure", isSecure: false, - clientId: '', - clientSecret: '', - location: server.info.uri - }, - { - provider: 'linkedin', - password: 'cookie_encryption_password_secure', + clientId: "", + clientSecret: "", + location: server.info.uri, + }, { + provider: "linkedin", + password: "cookie_encryption_password_secure", isSecure: false, - clientId: '', - clientSecret: '', + clientId: "", + clientSecret: "", providerParams: { - redirect_uri: server.info.uri + '/bell/door' - } - }, - { - provider: 'meetup', - password: 'cookie_encryption_password_secure', + redirect_uri: server.info.uri + "/bell/door", + }, + }, { + provider: "meetup", + password: "cookie_encryption_password_secure", isSecure: false, - clientId: '', - clientSecret: '', - scope: ['basic', 'ageless', 'group_edit', 'reporting'], - }, - { - provider: 'nest', - password: 'cookie_encryption_password_secure', + clientId: "", + clientSecret: "", + scope: ["basic", "ageless", "group_edit", "reporting"], + }, { + provider: "nest", + password: "cookie_encryption_password_secure", isSecure: false, - clientId: '', - clientSecret: '' - }, - { - provider: 'okta', - config: { uri: 'https://your-organization.okta.com' }, - password: 'cookie_encryption_password_secure', + clientId: "", + clientSecret: "", + }, { + provider: "okta", + config: { uri: "https://your-organization.okta.com" }, + password: "cookie_encryption_password_secure", isSecure: false, - location: 'http://127.0.0.1:8000', - clientId: '', - clientSecret: '' - }, - { - provider: 'slack', - password: 'cookie_encryption_password_secure', + location: "http://127.0.0.1:8000", + clientId: "", + clientSecret: "", + }, { + provider: "slack", + password: "cookie_encryption_password_secure", isSecure: false, - clientId: '', - clientSecret: '' - }, - { - provider: 'twitch', - password: 'cookie_encryption_password_secure', + clientId: "", + clientSecret: "", + }, { + provider: "twitch", + password: "cookie_encryption_password_secure", isSecure: false, - clientId: '', - clientSecret: '', - scope: ['user_read', 'channel_read'] - }, - { + clientId: "", + clientSecret: "", + scope: ["user_read", "channel_read"], + }, { provider: { - auth: 'http://test.com/auth', - token: 'http://test.com/auth', - name: 'custom', - protocol: 'oauth', - temporary: 'wat', + auth: "http://test.com/auth", + token: "http://test.com/auth", + name: "custom", + protocol: "oauth", + temporary: "wat", async profile(credentials, params, get) { console.log(credentials.provider); console.log(credentials.query); console.log(credentials.secret); console.log(this.clientId); - credentials.profile = await get('http://test.com/profile', { - a: 'test', + credentials.profile = await get("http://test.com/profile", { + a: "test", }); }, }, - password: 'cookie_encryption_password_secure', + password: "cookie_encryption_password_secure", isSecure: false, - clientId: '', - clientSecret: '', - location: () => '', - }, - { + clientId: "", + clientSecret: "", + location: () => "", + }, { provider: { - auth: 'http://test.com/auth', - token: 'http://test.com/auth', - name: 'custom', - protocol: 'oauth2', - scope: ['a', 's', 'd', 'f'], - scopeSeparator: '~~~', - pkce: 'S256', + auth: "http://test.com/auth", + token: "http://test.com/auth", + name: "custom", + protocol: "oauth2", + scope: ["a", "s", "d", "f"], + scopeSeparator: "~~~", + pkce: "S256", async profile(credentials, params, get) { console.log(credentials.provider); console.log(credentials.query); console.log(credentials.token); console.log(credentials.refreshToken); console.log(this.clientId); - credentials.profile = await get('http://test.com/profile', { - a: 'test', + credentials.profile = await get("http://test.com/profile", { + a: "test", }); }, }, - password: 'cookie_encryption_password_secure', + password: "cookie_encryption_password_secure", isSecure: false, - clientId: '', - clientSecret: '', - location: () => '', + clientId: "", + clientSecret: "", + location: () => "", }]; } diff --git a/types/hapi__bell/index.d.ts b/types/hapi__bell/index.d.ts index 168641512ca370..afcb0a73d530a6 100644 --- a/types/hapi__bell/index.d.ts +++ b/types/hapi__bell/index.d.ts @@ -5,177 +5,180 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.1 -import { Request, Plugin, AuthCredentials } from '@hapi/hapi'; +import { AuthCredentials, Plugin, Request } from "@hapi/hapi"; -declare module '@hapi/hapi' { - interface ServerAuth { - strategy(name: string, scheme: 'bell', options: BellOptions): void; - } +declare module "@hapi/hapi" { + interface ServerAuth { + strategy(name: string, scheme: "bell", options: BellOptions): void; + } } export interface StringLikeMap { [key: string]: string | number; } export type Provider = - 'arcgisonline' | - 'auth0' | - 'azure' | - 'bitbucket' | - 'cognito' | - 'digitalocean' | - 'discord' | - 'dropbox' | - 'facebook' | - 'fitbit' | - 'foursquare' | - 'github' | - 'gitlab' | - 'google' | - 'googleplus' | - 'instagram' | - 'linkedin' | - 'live' | - 'medium' | - 'meetup' | - 'mixer' | - 'nest' | - 'okta' | - 'phabricator' | - 'pingfed' | - 'pinterest' | - 'reddit' | - 'salesforce' | - 'slack' | - 'spotify' | - 'stripe' | - 'trakt' | - 'tumblr' | - 'twitch' | - 'twitter' | - 'vk' | - 'wordpress' | - 'yahoo'; + | "arcgisonline" + | "auth0" + | "azure" + | "bitbucket" + | "cognito" + | "digitalocean" + | "discord" + | "dropbox" + | "facebook" + | "fitbit" + | "foursquare" + | "github" + | "gitlab" + | "google" + | "googleplus" + | "instagram" + | "linkedin" + | "live" + | "medium" + | "meetup" + | "mixer" + | "nest" + | "okta" + | "phabricator" + | "pingfed" + | "pinterest" + | "reddit" + | "salesforce" + | "slack" + | "spotify" + | "stripe" + | "trakt" + | "tumblr" + | "twitch" + | "twitter" + | "vk" + | "wordpress" + | "yahoo"; export type RequestPassThrough = (request: Request) => PromiseLike | AuthCredentials; export interface OptionalOptions { - /** - * the name of the cookie used to manage the temporary state. - * Defaults to 'bell-provider' where 'provider' is the provider name (or 'custom' for custom providers). - * For example, the Twitter cookie name defaults to 'bell-twitter'. - */ - cookie?: string | undefined; - /** - * sets the cookie secure flag. - * Defaults to true. - */ - isSecure?: boolean | undefined; - /** - * sets the cookie HTTP only flag. - * Defaults to true. - */ - isHttpOnly?: boolean | undefined; - /** - * cookie time-to-live in milliseconds. - * Defaults to null (session time-life - cookies are deleted when the browser is closed). - */ - ttl?: number | undefined; - /** - * the domain scope. - * Defaults to null (no domain). - */ - domain?: string | undefined; - /** - * provider-specific query parameters for the authentication endpoint. - * It may be passed either as an object to merge into the query string, - * or a function which takes the client's request and returns an object. - * Each provider supports its own set of parameters which customize the user's login experience. - * For example: - * * Facebook supports `display` ('page', 'popup', or 'touch'), `auth_type`, `auth_nonce`. - * * Google supports `access_type`, `approval_prompt`, `prompt`, `login_hint`, `user_id`, `hd`. - * * Twitter supports `force_login`, `screen_name`. - * * Linkedin supports `fields`. - */ - providerParams?: StringLikeMap | ((request: Request) => StringLikeMap) | undefined; - /** - * allows passing query parameters from a bell protected endpoint to the auth request. - * It will merge the query params you pass along with the providerParams and any other predefined ones. - * Be aware that this will override predefined query parameters! - * Default to false. - */ - allowRuntimeProviderParams?: StringLikeMap | boolean | undefined; - /** - * Each built-in vendor comes with the required scope for basic profile information. - * Use scope to specify a different scope as required by your application. - * It may be passed either as an object to merge into the query string, - * or a function which takes the client's request and returns an object. - * Consult the provider for their specific supported scopes. - */ - scope?: string[] | ((request: Request) => string[]) | undefined; - /** - * skips obtaining a user profile from the provider. - * Useful if you need specific scopes, - * but not the user profile. - * Defaults to false. - */ - skipProfile?: boolean | undefined; - /** - * a configuration object used to customize the provider settings. - * The built-in 'twitter' provider accepts the `extendedProfile` & `getMethod` options. - * option which allows disabling the extra profile request when the provider - * returns the user information in the callback (defaults to true). - * The built-in 'github' and 'phabricator' providers accept the uri - * option which allows pointing to a private enterprise installation (e.g. 'https://vpn.example.com'). - * See Providers documentation for more information. - */ - config?: { extendedProfile?: boolean | undefined; getMethod?: string | undefined } | { uri?: string | undefined } | undefined; - /** - * an object of key-value pairs that specify additional - * URL query parameters to send with the profile request to the provider. - * The built-in facebook provider, - * for example, could have fields specified to determine the fields returned from the user's graph, - * which would then be available to you in the auth.credentials.profile.raw object. - */ - profileParams?: StringLikeMap | undefined; - /** - * allows passing additional OAuth state from initial request. - * This must be a function returning a string, - * which will be appended to the bell internal state parameter for OAuth code flow. - */ - runtimeStateCallback?(req: Request): string; + /** + * the name of the cookie used to manage the temporary state. + * Defaults to 'bell-provider' where 'provider' is the provider name (or 'custom' for custom providers). + * For example, the Twitter cookie name defaults to 'bell-twitter'. + */ + cookie?: string | undefined; + /** + * sets the cookie secure flag. + * Defaults to true. + */ + isSecure?: boolean | undefined; + /** + * sets the cookie HTTP only flag. + * Defaults to true. + */ + isHttpOnly?: boolean | undefined; + /** + * cookie time-to-live in milliseconds. + * Defaults to null (session time-life - cookies are deleted when the browser is closed). + */ + ttl?: number | undefined; + /** + * the domain scope. + * Defaults to null (no domain). + */ + domain?: string | undefined; + /** + * provider-specific query parameters for the authentication endpoint. + * It may be passed either as an object to merge into the query string, + * or a function which takes the client's request and returns an object. + * Each provider supports its own set of parameters which customize the user's login experience. + * For example: + * * Facebook supports `display` ('page', 'popup', or 'touch'), `auth_type`, `auth_nonce`. + * * Google supports `access_type`, `approval_prompt`, `prompt`, `login_hint`, `user_id`, `hd`. + * * Twitter supports `force_login`, `screen_name`. + * * Linkedin supports `fields`. + */ + providerParams?: StringLikeMap | ((request: Request) => StringLikeMap) | undefined; + /** + * allows passing query parameters from a bell protected endpoint to the auth request. + * It will merge the query params you pass along with the providerParams and any other predefined ones. + * Be aware that this will override predefined query parameters! + * Default to false. + */ + allowRuntimeProviderParams?: StringLikeMap | boolean | undefined; + /** + * Each built-in vendor comes with the required scope for basic profile information. + * Use scope to specify a different scope as required by your application. + * It may be passed either as an object to merge into the query string, + * or a function which takes the client's request and returns an object. + * Consult the provider for their specific supported scopes. + */ + scope?: string[] | ((request: Request) => string[]) | undefined; + /** + * skips obtaining a user profile from the provider. + * Useful if you need specific scopes, + * but not the user profile. + * Defaults to false. + */ + skipProfile?: boolean | undefined; + /** + * a configuration object used to customize the provider settings. + * The built-in 'twitter' provider accepts the `extendedProfile` & `getMethod` options. + * option which allows disabling the extra profile request when the provider + * returns the user information in the callback (defaults to true). + * The built-in 'github' and 'phabricator' providers accept the uri + * option which allows pointing to a private enterprise installation (e.g. 'https://vpn.example.com'). + * See Providers documentation for more information. + */ + config?: + | { extendedProfile?: boolean | undefined; getMethod?: string | undefined } + | { uri?: string | undefined } + | undefined; + /** + * an object of key-value pairs that specify additional + * URL query parameters to send with the profile request to the provider. + * The built-in facebook provider, + * for example, could have fields specified to determine the fields returned from the user's graph, + * which would then be available to you in the auth.credentials.profile.raw object. + */ + profileParams?: StringLikeMap | undefined; + /** + * allows passing additional OAuth state from initial request. + * This must be a function returning a string, + * which will be appended to the bell internal state parameter for OAuth code flow. + */ + runtimeStateCallback?(req: Request): string; - // THESE ARE IN THE *REQUIRED* section but are actually not... - /** - * A boolean indicating whether or not you want the redirect_uri to be forced to https. - * Useful if your hapi application runs as http, but is accessed through https. - */ - forceHttps?: boolean | undefined; - /** - * Set the base redirect_uri manually if it cannot be inferred properly from server settings. - * Useful to override port, protocol, and host if proxied or forwarded. - */ - location?: string | ((req: Request) => string) | undefined; + // THESE ARE IN THE *REQUIRED* section but are actually not... + /** + * A boolean indicating whether or not you want the redirect_uri to be forced to https. + * Useful if your hapi application runs as http, but is accessed through https. + */ + forceHttps?: boolean | undefined; + /** + * Set the base redirect_uri manually if it cannot be inferred properly from server settings. + * Useful to override port, protocol, and host if proxied or forwarded. + */ + location?: string | ((req: Request) => string) | undefined; } export interface RequiredProviderOptions { - /** - * the cookie encryption password. - * Used to encrypt the temporary state cookie used by the module in - * between the authorization protocol steps. - */ - password: string; - /** - * the OAuth client identifier (consumer key). - */ - clientId: string; - /** - * the OAuth client secret (consumer secret) - */ - clientSecret: string; + /** + * the cookie encryption password. + * Used to encrypt the temporary state cookie used by the module in + * between the authorization protocol steps. + */ + password: string; + /** + * the OAuth client identifier (consumer key). + */ + clientId: string; + /** + * the OAuth client secret (consumer secret) + */ + clientSecret: string; } export interface KnownProviderOptions extends RequiredProviderOptions, OptionalOptions { - provider: Provider; + provider: Provider; } /** @@ -185,45 +188,45 @@ export interface KnownProviderOptions extends RequiredProviderOptions, OptionalO export type AuthedRequest = (uri: string, params?: { [key: string]: string }) => Promise; export interface Credentials { - provider: Provider | 'custom'; - token: string; - query: StringLikeMap; - /** - * Varying data depending on provider. - */ - profile?: object | undefined; + provider: Provider | "custom"; + token: string; + query: StringLikeMap; + /** + * Varying data depending on provider. + */ + profile?: object | undefined; } export interface Credentials1 extends Credentials { - secret: string; + secret: string; } export interface Credentials2 extends Credentials { - refreshToken?: string | undefined; - expiresIn?: number | undefined; + refreshToken?: string | undefined; + expiresIn?: number | undefined; } export interface CustomProtocol { - /** - * The name of the protocol. - * @default custom - */ - name?: string | undefined; - /** - * the authorization endpoint URI. - */ - auth: string; - /** - * the access token endpoint URI. - */ - token: string; - /** - * a headers object with additional headers required by the provider - * (e.g. GitHub required the 'User-Agent' header which is set by default). - */ - headers?: { - [key: string]: string; - } | undefined; + /** + * The name of the protocol. + * @default custom + */ + name?: string | undefined; + /** + * the authorization endpoint URI. + */ + auth: string; + /** + * the access token endpoint URI. + */ + token: string; + /** + * a headers object with additional headers required by the provider + * (e.g. GitHub required the 'User-Agent' header which is set by default). + */ + headers?: { + [key: string]: string; + } | undefined; } /** @@ -233,61 +236,66 @@ export interface CustomProtocol { * @param params the parsed information received from the provider (e.g. token, secret, and other custom fields). * @param get an OAuth helper function to make authenticated requests using the credentials received. */ -export type ProfileGetter = (this: CustomProviderOptions, credentials: C, params: { [key: string]: string }, get: AuthedRequest) => Promise; +export type ProfileGetter = ( + this: CustomProviderOptions, + credentials: C, + params: { [key: string]: string }, + get: AuthedRequest, +) => Promise; export interface CustomProtocol1 extends CustomProtocol { - /** - * the authorization protocol used. - */ - protocol: 'oauth'; + /** + * the authorization protocol used. + */ + protocol: "oauth"; - /** - * the OAuth signature method. Must be one of: - * * 'HMAC-SHA1' - default - * * 'RSA-SHA1' - in that case, the clientSecret is your RSA private key - */ - signatureMethod?: 'HMAC-SHA1' | 'RSA-SHA1' | undefined; - /** - * the temporary credentials (request token) endpoint). - */ - temporary?: string | undefined; + /** + * the OAuth signature method. Must be one of: + * * 'HMAC-SHA1' - default + * * 'RSA-SHA1' - in that case, the clientSecret is your RSA private key + */ + signatureMethod?: "HMAC-SHA1" | "RSA-SHA1" | undefined; + /** + * the temporary credentials (request token) endpoint). + */ + temporary?: string | undefined; - profile: ProfileGetter; + profile: ProfileGetter; } -export type PkceSetting = 'plain' | 'S256'; +export type PkceSetting = "plain" | "S256"; export interface CustomProtocol2 extends CustomProtocol { - /** - * the authorization protocol used. - */ - protocol: 'oauth2'; - /** - * an array of scope strings. - */ - scope?: string[] | ((query: StringLikeMap) => string[]) | undefined; - /** - * boolean that determines if OAuth client id and client secret will be sent - * as parameters as opposed to an Authorization header. - * Defaults to false. - */ - useParamsAuth?: boolean | undefined; + /** + * the authorization protocol used. + */ + protocol: "oauth2"; + /** + * an array of scope strings. + */ + scope?: string[] | ((query: StringLikeMap) => string[]) | undefined; + /** + * boolean that determines if OAuth client id and client secret will be sent + * as parameters as opposed to an Authorization header. + * Defaults to false. + */ + useParamsAuth?: boolean | undefined; - /** - * If specified, uses proof key exchange. - */ - pkce?: PkceSetting | undefined; + /** + * If specified, uses proof key exchange. + */ + pkce?: PkceSetting | undefined; - /** - * the scope separator character. Only required when a provider has a broken OAuth 2.0 implementation. Defaults to space (Facebook and GitHub default to comma). - */ - scopeSeparator?: string | undefined; + /** + * the scope separator character. Only required when a provider has a broken OAuth 2.0 implementation. Defaults to space (Facebook and GitHub default to comma). + */ + scopeSeparator?: string | undefined; - profile: ProfileGetter; + profile: ProfileGetter; } export interface CustomProviderOptions extends RequiredProviderOptions, OptionalOptions { - provider: CustomProtocol1 | CustomProtocol2; + provider: CustomProtocol1 | CustomProtocol2; } export type BellOptions = CustomProviderOptions | KnownProviderOptions; diff --git a/types/hapi__call/hapi__call-tests.ts b/types/hapi__call/hapi__call-tests.ts index 2be886fd39728a..46305f66638216 100644 --- a/types/hapi__call/hapi__call-tests.ts +++ b/types/hapi__call/hapi__call-tests.ts @@ -1,15 +1,15 @@ -import { Route, Router } from '@hapi/call'; +import { Route, Router } from "@hapi/call"; const router = new Router<{ id: string }>({ isCaseSensitive: false }); -router.add({ method: 'get', path: '/user/{userId}'}, { id: 'get_user'}); +router.add({ method: "get", path: "/user/{userId}" }, { id: "get_user" }); -const route = router.route('get', '/'); +const route = router.route("get", "/"); if (!(route instanceof Error)) { console.log(route.route.id); console.log(route.params.userId); console.log(route.paramsArray[0]); } else { - throw route; + throw route; } diff --git a/types/hapi__call/index.d.ts b/types/hapi__call/index.d.ts index 40055152d6311f..c59c287d87592b 100644 --- a/types/hapi__call/index.d.ts +++ b/types/hapi__call/index.d.ts @@ -38,7 +38,7 @@ export interface Match { export type Route = Match | Error; export class Router { - constructor(routerOptions?: RouterOptions) + constructor(routerOptions?: RouterOptions); add(definition: RouteDefinition, route?: Handler): void; route(method: string, path: string): Route; } diff --git a/types/hapi__catbox-memcached/hapi__catbox-memcached-tests.ts b/types/hapi__catbox-memcached/hapi__catbox-memcached-tests.ts index 0bb717781f2e70..9843e3de7e21be 100644 --- a/types/hapi__catbox-memcached/hapi__catbox-memcached-tests.ts +++ b/types/hapi__catbox-memcached/hapi__catbox-memcached-tests.ts @@ -1,14 +1,14 @@ -import CatboxMemcached = require('@hapi/catbox-memcached'); -import { Server } from '@hapi/hapi'; +import CatboxMemcached = require("@hapi/catbox-memcached"); +import { Server } from "@hapi/hapi"; new CatboxMemcached(); const options: CatboxMemcached.Options = { - host: 'test', + host: "test", port: 0, timeout: 0, idle: 0, - partition: 'test', + partition: "test", }; new Server({ diff --git a/types/hapi__catbox-memcached/index.d.ts b/types/hapi__catbox-memcached/index.d.ts index a4e713ac023bd3..4db15dc362e509 100644 --- a/types/hapi__catbox-memcached/index.d.ts +++ b/types/hapi__catbox-memcached/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Avery Fay // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import { CacheKey, ClientApi, ClientOptions } from '@hapi/catbox'; +import { CacheKey, ClientApi, ClientOptions } from "@hapi/catbox"; declare namespace CatboxMemcached { interface Options extends ClientOptions { diff --git a/types/hapi__catbox-memory/hapi__catbox-memory-tests.ts b/types/hapi__catbox-memory/hapi__catbox-memory-tests.ts index 5308ca50f7b51b..b9a04a10d01580 100644 --- a/types/hapi__catbox-memory/hapi__catbox-memory-tests.ts +++ b/types/hapi__catbox-memory/hapi__catbox-memory-tests.ts @@ -1,5 +1,5 @@ -import { Engine as CatboxMemory } from '@hapi/catbox-memory'; -import { Client } from '@hapi/catbox'; +import { Client } from "@hapi/catbox"; +import { Engine as CatboxMemory } from "@hapi/catbox-memory"; const client = new CatboxMemory({ cloneBuffersOnGet: false, diff --git a/types/hapi__catbox-memory/index.d.ts b/types/hapi__catbox-memory/index.d.ts index 9001c3f87fa039..78d04fb022f3e6 100644 --- a/types/hapi__catbox-memory/index.d.ts +++ b/types/hapi__catbox-memory/index.d.ts @@ -5,7 +5,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -import { ClientApi, ClientOptions } from '@hapi/catbox'; +import { ClientApi, ClientOptions } from "@hapi/catbox"; interface Engine extends ClientApi {} diff --git a/types/hapi__catbox-redis/hapi__catbox-redis-tests.ts b/types/hapi__catbox-redis/hapi__catbox-redis-tests.ts index d5e6d9f7bc3db2..87ad2c0e48830b 100644 --- a/types/hapi__catbox-redis/hapi__catbox-redis-tests.ts +++ b/types/hapi__catbox-redis/hapi__catbox-redis-tests.ts @@ -1,17 +1,21 @@ -import * as CatbotRedis from '@hapi/catbox-redis'; +import * as CatbotRedis from "@hapi/catbox-redis"; const cache = new CatbotRedis({ - host: 'localhost', - partition: 'test', + host: "localhost", + partition: "test", port: 2018, }); cache.get({ - segment: 'test', - id: 'test', + segment: "test", + id: "test", }); -cache.set({ - segment: 'test', - id: 'test', -}, 'test', 123); +cache.set( + { + segment: "test", + id: "test", + }, + "test", + 123, +); diff --git a/types/hapi__catbox-redis/index.d.ts b/types/hapi__catbox-redis/index.d.ts index 3bdbd9b62f015b..60ef8357859f02 100644 --- a/types/hapi__catbox-redis/index.d.ts +++ b/types/hapi__catbox-redis/index.d.ts @@ -7,56 +7,58 @@ /* eslint-disable @definitelytyped/no-declare-current-package */ // tslint:disable-next-line:no-single-declare-module -declare module '@hapi/catbox-redis' { - import { Redis, Cluster } from 'ioredis'; - import { EnginePrototype, ClientOptions, Client } from '@hapi/catbox'; +declare module "@hapi/catbox-redis" { + import { Cluster, Redis } from "ioredis"; + import { Client, ClientOptions, EnginePrototype } from "@hapi/catbox"; namespace CatboxRedis { - interface CatboxRedisOptions extends ClientOptions { - /** - * Raw client. - */ - client?: Redis | Cluster | undefined; - /** - * the Redis server URL (if url is provided, host, port, and socket are ignored) - */ - url?: string | undefined; - /** - * the Redis server hostname. - * Defaults to '127.0.0.1'. - */ - host?: string | undefined; - /** - * the Redis server port or unix domain socket path. - * Defaults to 6379. - */ - port?: number | undefined; - /** - * the unix socket string to connect to (if socket is provided, host and port are ignored) - */ - socket?: string | undefined; - /** - * the Redis authentication password when required. - */ - password?: string | undefined; - /** - * the Redis database. - */ - database?: string | undefined; - /** - * an array of redis sentinel addresses to connect to. - */ - sentinels?: Array<{ - host: string; - }> | undefined; - /** - * the name of the sentinel master. - * (Only needed when sentinels is specified) - */ - sentinelName?: string | undefined; - } + interface CatboxRedisOptions extends ClientOptions { + /** + * Raw client. + */ + client?: Redis | Cluster | undefined; + /** + * the Redis server URL (if url is provided, host, port, and socket are ignored) + */ + url?: string | undefined; + /** + * the Redis server hostname. + * Defaults to '127.0.0.1'. + */ + host?: string | undefined; + /** + * the Redis server port or unix domain socket path. + * Defaults to 6379. + */ + port?: number | undefined; + /** + * the unix socket string to connect to (if socket is provided, host and port are ignored) + */ + socket?: string | undefined; + /** + * the Redis authentication password when required. + */ + password?: string | undefined; + /** + * the Redis database. + */ + database?: string | undefined; + /** + * an array of redis sentinel addresses to connect to. + */ + sentinels?: + | Array<{ + host: string; + }> + | undefined; + /** + * the name of the sentinel master. + * (Only needed when sentinels is specified) + */ + sentinelName?: string | undefined; + } } class CatboxRedis extends Client { - constructor(options: CatboxRedis.CatboxRedisOptions); + constructor(options: CatboxRedis.CatboxRedisOptions); } export = CatboxRedis; - } +} diff --git a/types/hapi__catbox/hapi__catbox-tests.ts b/types/hapi__catbox/hapi__catbox-tests.ts index 0ae66bb186422b..d8f9582416e7b6 100644 --- a/types/hapi__catbox/hapi__catbox-tests.ts +++ b/types/hapi__catbox/hapi__catbox-tests.ts @@ -1,22 +1,26 @@ -import { Client, Policy, EnginePrototypeOrObject, DecoratedResult, CachedObject } from "@hapi/catbox"; +import { CachedObject, Client, DecoratedResult, EnginePrototypeOrObject, Policy } from "@hapi/catbox"; const Memory: EnginePrototypeOrObject = { async start(): Promise {}, stop(): void {}, async get(): Promise> { return { - item: 'asd', + item: "asd", stored: 12, ttl: 123, }; }, async set(): Promise {}, async drop(): Promise {}, - isReady(): boolean { return true; }, - validateSegmentName(segment: string): null { return null; }, + isReady(): boolean { + return true; + }, + validateSegmentName(segment: string): null { + return null; + }, }; -const client = new Client(Memory, { partition: 'cache' }); +const client = new Client(Memory, { partition: "cache" }); client.start().then(() => {}); client.stop().then(() => {}); @@ -26,24 +30,32 @@ const client2 = new Client(Memory); client2.start().then(() => {}); client2.stop().then(() => {}); -const cache = new Policy({ - expiresIn: 5000, -}, client, 'cache'); +const cache = new Policy( + { + expiresIn: 5000, + }, + client, + "cache", +); -cache.set('foo', 'bar', 5000).then(() => {}); +cache.set("foo", "bar", 5000).then(() => {}); -cache.get('foo').then(() => {}); +cache.get("foo").then(() => {}); -cache.drop('foo').then(() => {}); +cache.drop("foo").then(() => {}); cache.isReady(); cache.stats(); -const decoratedCache = new Policy({ - getDecoratedValue: true, -}, client, 'cache2'); +const decoratedCache = new Policy( + { + getDecoratedValue: true, + }, + client, + "cache2", +); -decoratedCache.get('test').then((a: DecoratedResult) => { +decoratedCache.get("test").then((a: DecoratedResult) => { const res: string = a.value; }); diff --git a/types/hapi__content/hapi__content-tests.ts b/types/hapi__content/hapi__content-tests.ts index ed862f4c51b6cb..ab93782c010a6d 100644 --- a/types/hapi__content/hapi__content-tests.ts +++ b/types/hapi__content/hapi__content-tests.ts @@ -1,4 +1,4 @@ -import Content from '@hapi/content'; +import Content from "@hapi/content"; const parsedContentType = Content.type("application/json; charset=utf-8"); @@ -6,6 +6,6 @@ console.log(parsedContentType.mime); console.log(parsedContentType.charset); console.log(parsedContentType.boundary); -const parsedContentDisposition = Content.disposition('form-data; name="file"; filename=file.jpg'); +const parsedContentDisposition = Content.disposition("form-data; name=\"file\"; filename=file.jpg"); console.log(parsedContentDisposition.filename); console.log(parsedContentDisposition.name); diff --git a/types/hapi__content/index.d.ts b/types/hapi__content/index.d.ts index aaa0ddd1771539..0360eb5ee3d64c 100644 --- a/types/hapi__content/index.d.ts +++ b/types/hapi__content/index.d.ts @@ -6,16 +6,16 @@ /// export interface ContentType { - mime: string; - charset?: string; - boundary?: string; + mime: string; + charset?: string; + boundary?: string; } export function type(header: string | undefined): ContentType; export interface ContentDisposition { - name: string; - filename: string; + name: string; + filename: string; } export function disposition(header: string | undefined): ContentDisposition; diff --git a/types/hapi__cookie/hapi__cookie-tests.ts b/types/hapi__cookie/hapi__cookie-tests.ts index c12c8c5ce57562..e451ec354c9518 100644 --- a/types/hapi__cookie/hapi__cookie-tests.ts +++ b/types/hapi__cookie/hapi__cookie-tests.ts @@ -1,5 +1,5 @@ -import * as hapi from '@hapi/hapi'; -import * as auth from '@hapi/cookie'; +import * as auth from "@hapi/cookie"; +import * as hapi from "@hapi/hapi"; const server = new hapi.Server({ port: 8000, @@ -12,11 +12,11 @@ const server = new hapi.Server({ server.register(auth); -server.state('data', { +server.state("data", { ttl: null, isSecure: true, isHttpOnly: true, - encoding: 'base64json', + encoding: "base64json", clearInvalid: true, strictHeader: true, }); @@ -24,58 +24,58 @@ server.state('data', { const options: auth.Options = { cookie: { clearInvalid: true, - name: 'session', - domain: '.typescript.org', - password: 'abcdef', + name: "session", + domain: ".typescript.org", + password: "abcdef", isSecure: true, ttl: 259200000, }, keepAlive: true, - redirectTo: '/login', + redirectTo: "/login", appendNext: false, validate: async () => { return { isValid: true }; }, }; -server.auth.strategy('session', 'cookie', options); +server.auth.strategy("session", "cookie", options); server.route({ - method: 'get', - path: '/', + method: "get", + path: "/", handler: async (request, h) => { - request.cookieAuth.set('key', 'value'); + request.cookieAuth.set("key", "value"); request.cookieAuth.set({ user: request.params.user }); request.cookieAuth.clear(); - request.cookieAuth.clear('key'); + request.cookieAuth.clear("key"); request.cookieAuth.ttl(1000); - h.state('data', { firstVisit: false }); + h.state("data", { firstVisit: false }); - return h.response('Hello'); + return h.response("Hello"); }, }); server.route({ - method: 'get', - path: '/', + method: "get", + path: "/", handler: async (_, h) => { - return h.response('Hello').state('data', { firstVisit: false }); + return h.response("Hello").state("data", { firstVisit: false }); }, }); server.route({ - method: 'get', - path: '/', + method: "get", + path: "/", handler: async (_, h) => { - return h.response('Hello').state('data', 'test', { encoding: 'none' }); + return h.response("Hello").state("data", "test", { encoding: "none" }); }, }); server.route({ - method: 'get', - path: '/', + method: "get", + path: "/", handler: async (_, h) => { - return h.response('Bye').unstate('data'); + return h.response("Bye").unstate("data"); }, }); diff --git a/types/hapi__cookie/index.d.ts b/types/hapi__cookie/index.d.ts index 0e743096c1a9cf..7a5972d7cb36db 100644 --- a/types/hapi__cookie/index.d.ts +++ b/types/hapi__cookie/index.d.ts @@ -4,18 +4,18 @@ // Simon Schick // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import { Request, Plugin, AuthCredentials, ServerStateCookieOptions } from '@hapi/hapi'; +import { AuthCredentials, Plugin, Request, ServerStateCookieOptions } from "@hapi/hapi"; -declare module '@hapi/hapi' { +declare module "@hapi/hapi" { interface ServerAuth { - strategy(name: string, scheme: 'cookie', options?: hapiAuthCookie.Options): void; + strategy(name: string, scheme: "cookie", options?: hapiAuthCookie.Options): void; } interface PluginSpecificConfiguration { cookie?: | { - redirectTo?: boolean | undefined; - } + redirectTo?: boolean | undefined; + } | undefined; } diff --git a/types/hapi__crumb/hapi__crumb-tests.ts b/types/hapi__crumb/hapi__crumb-tests.ts index 0bdc00b4bf199f..142e00fe89f10e 100644 --- a/types/hapi__crumb/hapi__crumb-tests.ts +++ b/types/hapi__crumb/hapi__crumb-tests.ts @@ -1,42 +1,42 @@ -import * as hapi from '@hapi/hapi'; -import * as crumb from '@hapi/crumb'; +import * as crumb from "@hapi/crumb"; +import * as hapi from "@hapi/hapi"; const server = new hapi.Server({ port: 8000 }); server.register({ plugin: crumb, options: { - key: 'csrf-token', + key: "csrf-token", size: 50, autoGenerate: true, addToViewContext: true, cookieOptions: { - path: '/', + path: "/", }, - headerName: 'X-CSRF-Token', + headerName: "X-CSRF-Token", restful: true, skip: () => false, enforce: true, logUnauthorized: false, - } + }, }); server.route({ - method: 'get', - path: '/', + method: "get", + path: "/", handler: async (_, h) => { return h.continue; }, }); server.route({ - method: 'get', - path: '/custom', + method: "get", + path: "/custom", options: { plugins: { crumb: { - key: 'x-csrf-token', - source: 'query', + key: "x-csrf-token", + source: "query", restful: true, }, }, diff --git a/types/hapi__crumb/index.d.ts b/types/hapi__crumb/index.d.ts index ad886e4decd8ba..fa5baadc6b6dc7 100644 --- a/types/hapi__crumb/index.d.ts +++ b/types/hapi__crumb/index.d.ts @@ -5,9 +5,9 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -import { Request, Plugin, ResponseToolkit, ServerStateCookieOptions } from '@hapi/hapi'; +import { Plugin, Request, ResponseToolkit, ServerStateCookieOptions } from "@hapi/hapi"; -declare module '@hapi/hapi' { +declare module "@hapi/hapi" { interface PluginSpecificConfiguration { crumb?: boolean | { /** @@ -20,7 +20,7 @@ declare module '@hapi/hapi' { * * @default 'payload' */ - source?: 'payload' | 'query' | undefined; + source?: "payload" | "query" | undefined; /** * Override for the server's 'restful' setting diff --git a/types/hapi__glue/hapi__glue-tests.ts b/types/hapi__glue/hapi__glue-tests.ts index 63caa10855beb4..16336f88d66088 100644 --- a/types/hapi__glue/hapi__glue-tests.ts +++ b/types/hapi__glue/hapi__glue-tests.ts @@ -1,26 +1,26 @@ -import * as Glue from '@hapi/glue'; +import * as Glue from "@hapi/glue"; const manifest: Glue.Manifest = { - server: { - port: 3000 - }, - register: { - plugins: [ - "./test-plugin.js", - { - plugin: "./test.js", - routes: { - prefix: "test" - } - }, - { - plugin: { - name: 'test', - register: (server, options) => {} - } - } - ] - } + server: { + port: 3000, + }, + register: { + plugins: [ + "./test-plugin.js", + { + plugin: "./test.js", + routes: { + prefix: "test", + }, + }, + { + plugin: { + name: "test", + register: (server, options) => {}, + }, + }, + ], + }, }; Glue.compose(manifest); diff --git a/types/hapi__glue/index.d.ts b/types/hapi__glue/index.d.ts index 8f8739f8282d4f..0873bcdff1eeca 100644 --- a/types/hapi__glue/index.d.ts +++ b/types/hapi__glue/index.d.ts @@ -8,22 +8,22 @@ import { Plugin, Server, ServerOptions } from "@hapi/hapi"; export interface Options { - relativeTo: string; - preConnections?: ((Server: Server, next: (err: any) => void) => void) | undefined; - preRegister?: ((Server: Server, next: (err: any) => void) => void) | undefined; + relativeTo: string; + preConnections?: ((Server: Server, next: (err: any) => void) => void) | undefined; + preRegister?: ((Server: Server, next: (err: any) => void) => void) | undefined; } export interface PluginObject { - plugin: string | Plugin; - options?: any; - routes?: any; + plugin: string | Plugin; + options?: any; + routes?: any; } export interface Manifest { - server: ServerOptions; - register?: { - plugins: string[] | PluginObject[] | Array<(string|PluginObject)> - } | undefined; + server: ServerOptions; + register?: { + plugins: string[] | PluginObject[] | Array<(string | PluginObject)>; + } | undefined; } export function compose(manifest: Manifest, options?: Options): Promise; diff --git a/types/hapi__h2o2/hapi__h2o2-tests.ts b/types/hapi__h2o2/hapi__h2o2-tests.ts index 99f8bd3527884d..2b484f243d3a7b 100644 --- a/types/hapi__h2o2/hapi__h2o2-tests.ts +++ b/types/hapi__h2o2/hapi__h2o2-tests.ts @@ -1,6 +1,6 @@ -import wreck = require('@hapi/wreck'); -import h2o2 = require('@hapi/h2o2'); -import hapi = require('@hapi/hapi'); +import wreck = require("@hapi/wreck"); +import h2o2 = require("@hapi/h2o2"); +import hapi = require("@hapi/hapi"); h2o2.plugin; h2o2.plugin.requirements; @@ -11,80 +11,80 @@ async function main() { await server.register(h2o2); server.route({ - method: 'GET', - path: '/hproxyoptions', + method: "GET", + path: "/hproxyoptions", async handler(request, h) { // ResponseToolkit augmentation // https://github.com/hapijs/h2o2#hproxyoptions - return h.proxy({ host: 'example.com', port: 80, protocol: 'http' }); + return h.proxy({ host: "example.com", port: 80, protocol: "http" }); }, }); server.route({ - method: 'GET', - path: '/using-the-host-port-protocol-options', + method: "GET", + path: "/using-the-host-port-protocol-options", handler: { // HandlerDecorations augmentation // https://github.com/hapijs/h2o2#using-the-host-port-protocol-options proxy: { - host: '10.33.33.1', - port: '443', - protocol: 'https', + host: "10.33.33.1", + port: "443", + protocol: "https", }, }, }); server.route({ - method: 'GET', - path: '/using-the-uri-option', + method: "GET", + path: "/using-the-uri-option", handler: { // HandlerDecorations augmentation // https://github.com/hapijs/h2o2#using-the-uri-option proxy: { - uri: 'https://some.upstream.service.com/that/has?what=you&want=todo', + uri: "https://some.upstream.service.com/that/has?what=you&want=todo", }, }, }); server.route({ - method: 'GET', - path: '/custom-uri-template-values', + method: "GET", + path: "/custom-uri-template-values", handler: { // HandlerDecorations augmentation // https://github.com/hapijs/h2o2#custom-uri-template-values proxy: { - uri: '{protocol}://{host}:{port}/go/to/{path}', + uri: "{protocol}://{host}:{port}/go/to/{path}", }, }, }); server.route({ - method: 'GET', - path: '/custom-uri-template-values/{bar}', + method: "GET", + path: "/custom-uri-template-values/{bar}", handler: { // HandlerDecorations augmentation // https://github.com/hapijs/h2o2#custom-uri-template-values proxy: { - uri: 'https://some.upstream.service.com/some/path/to/{bar}', + uri: "https://some.upstream.service.com/some/path/to/{bar}", }, }, }); server.route({ - method: 'GET', - path: '/', + method: "GET", + path: "/", handler: { // HandlerDecorations augmentation // https://github.com/hapijs/h2o2#using-the-mapuri-and-onresponse-options proxy: { async mapUri(request) { return { - uri: 'https://some.upstream.service.com/', + uri: "https://some.upstream.service.com/", }; }, async onRequest(req) { - return req.request('GET', 'https://some.upstream.service.com/'); + return req.request("GET", "https://some.upstream.service.com/"); }, async onResponse(err, res, request, h, settings, ttl) { @@ -96,7 +96,7 @@ async function main() { for (const header in res.headers) { let value = res.headers[header]; if (value) { - if (typeof value === 'string') { + if (typeof value === "string") { value = [value]; } for (const v of value) { @@ -112,8 +112,8 @@ async function main() { }); server.route({ - method: 'GET', - path: '/', + method: "GET", + path: "/", handler: { proxy: { httpClient: { @@ -141,31 +141,31 @@ async function main() { */ const proxyOptions: h2o2.ProxyHandlerOptions = { - host: '10.33.33.1', - port: '443', - protocol: 'https', // errors correctly if misspelt + host: "10.33.33.1", + port: "443", + protocol: "https", // errors correctly if misspelt }; const badProtocolDemo: hapi.ServerRoute = { - method: 'GET', - path: '/', + method: "GET", + path: "/", handler: { proxy: { - host: '10.33.33.1', - port: '443', + host: "10.33.33.1", + port: "443", // port: null // detected as incompatible }, }, }; const replyViaToolkit: hapi.ServerRoute = { - method: 'GET', - path: '/', + method: "GET", + path: "/", async handler(req, h): Promise { return h.proxy({ - host: '10.33.33.1', - port: '443', - protocol: 'https', + host: "10.33.33.1", + port: "443", + protocol: "https", }); }, }; diff --git a/types/hapi__h2o2/index.d.ts b/types/hapi__h2o2/index.d.ts index 10a808c2d87985..b1c1b9358052ad 100644 --- a/types/hapi__h2o2/index.d.ts +++ b/types/hapi__h2o2/index.d.ts @@ -8,10 +8,10 @@ /// -import { Agent, IncomingMessage } from 'http'; -import { Boom } from '@hapi/boom'; -import Wreck = require('@hapi/wreck'); -import { Plugin, Request, ResponseToolkit, Lifecycle, RouteOptions, ResponseObject } from '@hapi/hapi'; +import { Boom } from "@hapi/boom"; +import { Agent, IncomingMessage } from "http"; +import Wreck = require("@hapi/wreck"); +import { Lifecycle, Plugin, Request, ResponseObject, ResponseToolkit, RouteOptions } from "@hapi/hapi"; declare namespace h2o2 { /** @@ -45,7 +45,7 @@ declare namespace h2o2 { /** * protocol to use when making the request to the proxied host: */ - protocol?: 'http' | 'https' | undefined; + protocol?: "http" | "https" | undefined; /** * absolute URI used instead of host, port, protocol, path, and query. * Cannot be used with host, port, protocol, or mapUri. @@ -151,21 +151,21 @@ declare namespace h2o2 { */ onResponse?: | (( - this: RouteOptions, - err: null | Boom, - res: IncomingMessage, - req: Request, - h: ResponseToolkit, - settings: ProxyHandlerOptions, - ttl: number, - ) => Lifecycle.ReturnValue) + this: RouteOptions, + err: null | Boom, + res: IncomingMessage, + req: Request, + h: ResponseToolkit, + settings: ProxyHandlerOptions, + ttl: number, + ) => Lifecycle.ReturnValue) | undefined; /** * if set to 'upstream', applies the upstream response caching policy to * the response using the response.ttl() method (or passed as an * argument to the onResponse method if provided). */ - ttl?: 'upstream' | undefined; + ttl?: "upstream" | undefined; /** * a node http(s) agent to be used for connections to upstream server. * @see {@link https://nodejs.org/api/http.html#http_class_http_agent} @@ -201,7 +201,7 @@ declare namespace h2o2 { } } -declare module '@hapi/hapi' { +declare module "@hapi/hapi" { interface HandlerDecorations { /** * Proxies the request to an upstream endpoint. diff --git a/types/hapi__hawk/hapi__hawk-tests.ts b/types/hapi__hawk/hapi__hawk-tests.ts index 59b22017d50bae..35bde1f49814de 100644 --- a/types/hapi__hawk/hapi__hawk-tests.ts +++ b/types/hapi__hawk/hapi__hawk-tests.ts @@ -1,12 +1,12 @@ -import * as Http from 'http'; -import * as Hawk from '@hapi/hawk'; -import * as request from 'request'; +import * as Hawk from "@hapi/hawk"; +import * as Http from "http"; +import * as request from "request"; const credentialsFunc = (): Hawk.server.Credentials => { const credentials: Hawk.server.Credentials = { - key: 'werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn', - algorithm: 'sha256', - user: 'Steve', + key: "werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn", + algorithm: "sha256", + user: "Steve", }; return credentials; @@ -17,29 +17,29 @@ Http.createServer(async (req, res) => { const payload = `Hello ${credentials.user} ${artifacts.ext}`; const status = 200; - const headers: Record = { 'Content-Type': 'text/plain' }; - const header = Hawk.server.header(credentials, artifacts, { payload, contentType: headers['Content-Type'] }); - headers['Server-Authorization'] = header; + const headers: Record = { "Content-Type": "text/plain" }; + const header = Hawk.server.header(credentials, artifacts, { payload, contentType: headers["Content-Type"] }); + headers["Server-Authorization"] = header; res.writeHead(status, headers); res.end(payload); }); const credentials: Hawk.client.Credentials = { - id: 'dh37fgj492je', - key: 'werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn', - algorithm: 'sha256', + id: "dh37fgj492je", + key: "werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn", + algorithm: "sha256", }; const requestOptions: request.OptionsWithUri = { - uri: 'http://example.com:8000/resource/1?b=1&a=2', - method: 'GET', + uri: "http://example.com:8000/resource/1?b=1&a=2", + method: "GET", headers: {}, }; -const header = Hawk.client.header('http://example.com:8000/resource/1?b=1&a=2', 'GET', { +const header = Hawk.client.header("http://example.com:8000/resource/1?b=1&a=2", "GET", { credentials, - ext: 'some-app-data', + ext: "some-app-data", }); requestOptions.headers!.Authorization = header; diff --git a/types/hapi__hawk/index.d.ts b/types/hapi__hawk/index.d.ts index 80ea4133c4ba5a..835d99874f9239 100755 --- a/types/hapi__hawk/index.d.ts +++ b/types/hapi__hawk/index.d.ts @@ -5,18 +5,18 @@ /// -import * as sntp from '@hapi/sntp'; -import * as server from './lib/server'; -import * as client from './lib/client'; -import * as crypto from './lib/crypto'; -import * as utils from './lib/utils'; -import * as plugin from './lib/plugin'; +import * as sntp from "@hapi/sntp"; +import * as client from "./lib/client"; +import * as crypto from "./lib/crypto"; +import * as plugin from "./lib/plugin"; +import * as server from "./lib/server"; +import * as utils from "./lib/utils"; export namespace uri { const authenticate: typeof server.authenticateBewit; const getBewit: typeof client.getBewit; } -export { sntp, server, client, crypto, utils, plugin }; +export { client, crypto, plugin, server, sntp, utils }; export as namespace hawk; diff --git a/types/hapi__hawk/lib/browser.d.ts b/types/hapi__hawk/lib/browser.d.ts index b397d5722d2f59..abbad8dca84fb2 100755 --- a/types/hapi__hawk/lib/browser.d.ts +++ b/types/hapi__hawk/lib/browser.d.ts @@ -1,6 +1,6 @@ -import CryptoJS = require('crypto-js'); -import * as Crypto from './crypto'; -import * as Client from './client'; +import CryptoJS = require("crypto-js"); +import * as Client from "./client"; +import * as Crypto from "./crypto"; declare namespace hawk { namespace client { diff --git a/types/hapi__hawk/lib/client.d.ts b/types/hapi__hawk/lib/client.d.ts index 25d6fe20bea477..8eede6ac269919 100755 --- a/types/hapi__hawk/lib/client.d.ts +++ b/types/hapi__hawk/lib/client.d.ts @@ -1,9 +1,9 @@ -import * as Crypto from './crypto'; -import * as http from 'http'; -import * as request from 'request'; +import * as http from "http"; +import * as request from "request"; +import * as Crypto from "./crypto"; export interface Credentials { - algorithm: 'sha1' | 'sha256'; + algorithm: "sha1" | "sha256"; id: string; key: string; } diff --git a/types/hapi__hawk/lib/crypto.d.ts b/types/hapi__hawk/lib/crypto.d.ts index 2612bae83e3f12..c2e7c27285c103 100755 --- a/types/hapi__hawk/lib/crypto.d.ts +++ b/types/hapi__hawk/lib/crypto.d.ts @@ -1,5 +1,5 @@ -import * as Crypto from 'crypto'; -import * as Client from './client'; +import * as Crypto from "crypto"; +import * as Client from "./client"; export interface Artifacts { app?: string | undefined; diff --git a/types/hapi__hawk/lib/plugin.d.ts b/types/hapi__hawk/lib/plugin.d.ts index 6a03460d1f120c..27be6a124d8977 100755 --- a/types/hapi__hawk/lib/plugin.d.ts +++ b/types/hapi__hawk/lib/plugin.d.ts @@ -1,4 +1,4 @@ -import * as Hapi from '@hapi/hapi'; +import * as Hapi from "@hapi/hapi"; export namespace plugin { const pkg: Record; diff --git a/types/hapi__hawk/lib/server.d.ts b/types/hapi__hawk/lib/server.d.ts index 663419fc6600e1..d8d67573e16edf 100755 --- a/types/hapi__hawk/lib/server.d.ts +++ b/types/hapi__hawk/lib/server.d.ts @@ -1,9 +1,9 @@ -import * as http from 'http'; -import * as request from 'request'; +import * as http from "http"; +import * as request from "request"; -import * as Crypto from './crypto'; -import * as Utils from './utils'; -import { Message } from './client'; +import { Message } from "./client"; +import * as Crypto from "./crypto"; +import * as Utils from "./utils"; export type CredentialsFunc = (id: string) => Promise | Credentials; export type NonceFunc = (key: string, nonce: string, ts: string) => Promise | void; @@ -52,7 +52,7 @@ export interface AuthenticateOptions { } export interface Credentials { - algorithm: 'sha1' | 'sha256'; + algorithm: "sha1" | "sha256"; key: string; user: string; } @@ -75,7 +75,7 @@ export interface HeaderOptions { export type AuthenticateBewitOptions = Pick< AuthenticateOptions, - 'hostHeaderName' | 'localtimeOffsetMsec' | 'host' | 'port' + "hostHeaderName" | "localtimeOffsetMsec" | "host" | "port" >; export interface Bewit { @@ -95,7 +95,7 @@ export interface AuthenticatedMessage { export type AuthenticateMessageOptions = Pick< AuthenticateOptions, - 'nonceFunc' | 'timestampSkewSec' | 'localtimeOffsetMsec' + "nonceFunc" | "timestampSkewSec" | "localtimeOffsetMsec" >; export function authenticate( diff --git a/types/hapi__hawk/lib/utils.d.ts b/types/hapi__hawk/lib/utils.d.ts index 36851858881133..d8bde033118b25 100755 --- a/types/hapi__hawk/lib/utils.d.ts +++ b/types/hapi__hawk/lib/utils.d.ts @@ -1,6 +1,6 @@ -import * as Boom from '@hapi/boom'; -import * as http from 'http'; -import * as https from 'https'; +import * as Boom from "@hapi/boom"; +import * as http from "http"; +import * as https from "https"; export interface Host { name: string; diff --git a/types/hapi__inert/hapi__inert-tests.ts b/types/hapi__inert/hapi__inert-tests.ts index 9ce8d8be958e4d..e5cf8d81799cd4 100644 --- a/types/hapi__inert/hapi__inert-tests.ts +++ b/types/hapi__inert/hapi__inert-tests.ts @@ -1,12 +1,12 @@ -import { Server, Lifecycle } from '@hapi/hapi'; -import * as path from 'path'; -import * as inert from '@hapi/inert'; +import { Lifecycle, Server } from "@hapi/hapi"; +import * as inert from "@hapi/inert"; +import * as path from "path"; const server = new Server({ port: 3000, routes: { files: { - relativeTo: path.join(__dirname, 'public'), + relativeTo: path.join(__dirname, "public"), }, }, }); @@ -15,11 +15,11 @@ const provision = async () => { await server.register(inert); server.route({ - method: 'GET', - path: '/{param*}', + method: "GET", + path: "/{param*}", handler: { directory: { - path: '.', + path: ".", redirectToSlash: true, index: true, }, @@ -27,72 +27,72 @@ const provision = async () => { }); server.route({ - method: 'GET', - path: '/{param*}', + method: "GET", + path: "/{param*}", handler(request, h) { - return h.file('awesome.png', { - confine: './images', + return h.file("awesome.png", { + confine: "./images", }); }, }); // https://github.com/hapijs/inert#serving-a-single-file server.route({ - method: 'GET', - path: '/{path*}', + method: "GET", + path: "/{path*}", handler: { - file: 'page.html', + file: "page.html", }, }); // https://github.com/hapijs/inert#customized-file-response server.route({ - method: 'GET', - path: '/file', + method: "GET", + path: "/file", handler(request, reply) { - let path = 'plain.txt'; - if (request.headers['x-magic'] === 'sekret') { - path = 'awesome.png'; + let path = "plain.txt"; + if (request.headers["x-magic"] === "sekret") { + path = "awesome.png"; } - return reply.file(path).vary('x-magic'); + return reply.file(path).vary("x-magic"); }, }); const handler: Lifecycle.Method = (request, h) => { const response = request.response; if (response instanceof Error && response.output.statusCode === 404) { - return h.file('404.html').code(404); + return h.file("404.html").code(404); } return h.continue; }; - server.ext('onPostHandler', handler); + server.ext("onPostHandler", handler); const file: inert.FileHandlerRouteObject = { - path: '', + path: "", confine: true, }; const directory: inert.DirectoryHandlerRouteObject = { - path: '', + path: "", listing: true, }; server.route({ - path: '', - method: 'GET', + path: "", + method: "GET", handler: { file, directory: { path() { if (Math.random() > 0.5) { - return ''; + return ""; } else if (Math.random() > 0) { - return ['']; + return [""]; } - return new Error(''); + return new Error(""); }, }, }, diff --git a/types/hapi__inert/index.d.ts b/types/hapi__inert/index.d.ts index 784a9f39507298..16ecfed5042a95 100644 --- a/types/hapi__inert/index.d.ts +++ b/types/hapi__inert/index.d.ts @@ -5,7 +5,7 @@ // Silas Rech // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import { Plugin, Request, ResponseObject } from '@hapi/hapi'; +import { Plugin, Request, ResponseObject } from "@hapi/hapi"; declare namespace inert { type RequestHandler = (request: Request) => T; @@ -26,7 +26,7 @@ declare namespace inert { * * 'attachment' * *'inline' */ - mode?: false | 'attachment' | 'inline' | undefined; + mode?: false | "attachment" | "inline" | undefined; /** * lookupCompressed - if true, looks for for a pre-compressed version of the file with the same filename with an extension, depending on the accepted encoding. Defaults to false. */ @@ -41,7 +41,7 @@ declare namespace inert { * * 'simple' - Hex encoded size and modification date, suitable when files are stored on a single server. * * false - Disable ETag computation. */ - etagMethod?: 'hash' | 'simple' | false | undefined; + etagMethod?: "hash" | "simple" | false | undefined; /** * start - offset in file to reading from, defaults to 0. */ @@ -99,7 +99,7 @@ declare namespace inert { * * 'simple' - Hex encoded size and modification date, suitable when files are stored on a single server. * * false - Disable ETag computation. */ - etagMethod?: 'hash' | 'simple' | false | undefined; + etagMethod?: "hash" | "simple" | false | undefined; /** * defaultExtension - optional string, appended to file requests if the requested file is not found. Defaults to no extension. */ @@ -122,7 +122,7 @@ declare const inert: { plugin: Plugin }; export = inert; -declare module '@hapi/hapi' { +declare module "@hapi/hapi" { interface HandlerDecorations { /** * The file handler @@ -149,11 +149,11 @@ declare module '@hapi/hapi' { directory?: inert.DirectoryHandlerRouteObject | undefined; files?: | { - /** - * Set the relative path - */ - relativeTo: string; - } + /** + * Set the relative path + */ + relativeTo: string; + } | undefined; } diff --git a/types/hapi__joi/hapi__joi-tests.ts b/types/hapi__joi/hapi__joi-tests.ts index 1f2f1f1246bd59..cdcfcd3d0417a0 100644 --- a/types/hapi__joi/hapi__joi-tests.ts +++ b/types/hapi__joi/hapi__joi-tests.ts @@ -1,11 +1,11 @@ -import Joi = require('@hapi/joi'); +import Joi = require("@hapi/joi"); // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- const x: any = null; declare const value: any; const num = 0; -const str = ''; +const str = ""; declare const bool: boolean; declare const exp: RegExp; declare const obj: object; @@ -34,7 +34,7 @@ let objSchema: Joi.ObjectSchema = Joi.object(); declare const schemaArr: Joi.Schema[]; -let ref: Joi.Reference = Joi.ref('test'); +let ref: Joi.Reference = Joi.ref("test"); let description: Joi.Description = {}; // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- @@ -49,22 +49,22 @@ validOpts = { stripUnknown: bool }; validOpts = { stripUnknown: { arrays: bool } }; validOpts = { stripUnknown: { objects: bool } }; validOpts = { stripUnknown: { arrays: bool, objects: bool } }; -validOpts = { presence: 'optional' || 'required' || 'forbidden' }; +validOpts = { presence: "optional" || "required" || "forbidden" }; validOpts = { context: obj }; validOpts = { noDefaults: bool }; validOpts = { abortEarly: true, messages: { - 'any.ref': str, - 'string.email': str + "any.ref": str, + "string.email": str, }, - dateFormat: 'iso' + dateFormat: "iso", }; // Test various permutations of string, `false`, or `undefined` for both parameters: -validOpts = { errors: { wrap: { label: str, array: str }}}; -validOpts = { errors: { wrap: { label: false, array: false }}}; -validOpts = { errors: { wrap: { label: str }}}; -validOpts = { errors: { wrap: { array: str }}}; +validOpts = { errors: { wrap: { label: str, array: str } } }; +validOpts = { errors: { wrap: { label: false, array: false } } }; +validOpts = { errors: { wrap: { label: str } } }; +validOpts = { errors: { wrap: { array: str } } }; // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- @@ -104,7 +104,7 @@ let ipOpts: Joi.IpOptions = {}; ipOpts = { version: str }; ipOpts = { version: strArr }; -ipOpts = { cidr: 'forbidden' }; +ipOpts = { cidr: "forbidden" }; // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- @@ -173,14 +173,14 @@ let validErrFunc: Joi.ValidationErrorFunction; validErrItem = { message: str, type: str, - path: [str] + path: [str], }; validErrItem = { message: str, type: str, path: [str], - context: obj + context: obj, }; validErrItem = { @@ -191,7 +191,7 @@ validErrItem = { }; validErrFunc = errs => errs[0]; -validErrFunc = errs => 'Some error'; +validErrFunc = errs => "Some error"; validErrFunc = errs => err; // error() can take function with ErrorReport argument @@ -200,7 +200,7 @@ validErrFunc = errors => { const code: string = errors[0].code; const messages = errors[0].prefs.messages; - const message: string = messages ? messages[code].rendered : 'Error'; + const message: string = messages ? messages[code].rendered : "Error"; const validationErr = new Error(); validationErr.message = `[${path}]: ${message}`; @@ -245,34 +245,34 @@ let schemaMap: Joi.SchemaMap = {}; schemaMap = { a: numSchema, - b: strSchema + b: strSchema, }; schemaMap = { a: numSchema, b: { b1: strSchema, - b2: anySchema - } + b2: anySchema, + }, }; schemaMap = { a: numSchema, b: [ { b1: strSchema }, - { b2: anySchema } + { b2: anySchema }, ], c: arrSchema, - d: schemaLike + d: schemaLike, }; schemaMap = { a: 1, b: { - b1: '1', - b2: 2 + b1: "1", + b2: 2, }, c: [ { c1: true }, - { c2: null } - ] + { c2: null }, + ], }; // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- @@ -356,12 +356,23 @@ arrSchema = arrSchema.sparse(bool); arrSchema = arrSchema.single(); arrSchema = arrSchema.single(bool); arrSchema = arrSchema.sort(); -arrSchema = arrSchema.sort({ order: 'descending' }); -arrSchema = arrSchema.sort({ by: 'n' }); +arrSchema = arrSchema.sort({ order: "descending" }); +arrSchema = arrSchema.sort({ by: "n" }); arrSchema = arrSchema.sort({ by: ref }); arrSchema = arrSchema.sort(); arrSchema = arrSchema.ordered(anySchema); -arrSchema = arrSchema.ordered(anySchema, numSchema, strSchema, arrSchema, boolSchema, binSchema, dateSchema, funcSchema, objSchema, schemaLike); +arrSchema = arrSchema.ordered( + anySchema, + numSchema, + strSchema, + arrSchema, + boolSchema, + binSchema, + dateSchema, + funcSchema, + objSchema, + schemaLike, +); arrSchema = arrSchema.ordered(schemaMap); arrSchema = arrSchema.ordered([schemaMap, schemaMap, schemaLike]); arrSchema = arrSchema.min(num); @@ -370,7 +381,7 @@ arrSchema = arrSchema.length(num); arrSchema = arrSchema.length(ref); arrSchema = arrSchema.unique(); arrSchema = arrSchema.unique((a, b) => a.test === b.test); -arrSchema = arrSchema.unique('customer.id'); +arrSchema = arrSchema.unique("customer.id"); arrSchema = arrSchema.items(numSchema); arrSchema = arrSchema.items(numSchema, strSchema, schemaLike); @@ -548,10 +559,10 @@ binSchema = binSchema.length(num); dateSchema = Joi.date(); -dateSchema = dateSchema.greater('now'); -dateSchema = dateSchema.less('now'); -dateSchema = dateSchema.min('now'); -dateSchema = dateSchema.max('now'); +dateSchema = dateSchema.greater("now"); +dateSchema = dateSchema.less("now"); +dateSchema = dateSchema.min("now"); +dateSchema = dateSchema.max("now"); dateSchema = dateSchema.greater(date); dateSchema = dateSchema.less(date); @@ -576,8 +587,8 @@ dateSchema = dateSchema.max(ref); dateSchema = dateSchema.iso(); dateSchema = dateSchema.timestamp(); -dateSchema = dateSchema.timestamp('javascript'); -dateSchema = dateSchema.timestamp('unix'); +dateSchema = dateSchema.timestamp("javascript"); +dateSchema = dateSchema.timestamp("unix"); { // common dateSchema = dateSchema.allow(x); @@ -720,25 +731,25 @@ objSchema = objSchema.pattern(exp, schemaLike); objSchema = objSchema.and(str); objSchema = objSchema.and(str, str); -objSchema = objSchema.and(str, str, { separator: ',' }); +objSchema = objSchema.and(str, str, { separator: "," }); objSchema = objSchema.nand(str); objSchema = objSchema.nand(str, str); -objSchema = objSchema.nand(str, str, { separator: ',' }); +objSchema = objSchema.nand(str, str, { separator: "," }); objSchema = objSchema.schema(); objSchema = objSchema.or(str); objSchema = objSchema.or(str, str); -objSchema = objSchema.or(str, str, { separator: ',' }); +objSchema = objSchema.or(str, str, { separator: "," }); objSchema = objSchema.oxor(str); objSchema = objSchema.oxor(str, str); -objSchema = objSchema.oxor(str, str, { separator: ',' }); +objSchema = objSchema.oxor(str, str, { separator: "," }); objSchema = objSchema.xor(str); objSchema = objSchema.xor(str, str); -objSchema = objSchema.xor(str, str, { separator: ',' }); +objSchema = objSchema.xor(str, str, { separator: "," }); objSchema = objSchema.with(str, str); objSchema = objSchema.with(str, strArr); @@ -849,14 +860,14 @@ strSchema = strSchema.uri(); strSchema = strSchema.uri(uriOpts); strSchema = strSchema.guid(); strSchema = strSchema.guid({ - version: ['uuidv1', 'uuidv2', 'uuidv3', 'uuidv4', 'uuidv5'] + version: ["uuidv1", "uuidv2", "uuidv3", "uuidv4", "uuidv5"], }); -strSchema = strSchema.guid({ version: 'uuidv4' }); +strSchema = strSchema.guid({ version: "uuidv4" }); strSchema = strSchema.uuid(); strSchema = strSchema.uuid({ - version: ['uuidv1', 'uuidv2', 'uuidv3', 'uuidv4', 'uuidv5'], + version: ["uuidv1", "uuidv2", "uuidv3", "uuidv4", "uuidv5"], }); -strSchema = strSchema.uuid({ version: 'uuidv4' }); +strSchema = strSchema.uuid({ version: "uuidv4" }); strSchema = strSchema.hex(); strSchema = strSchema.hex(hexOpts); strSchema = strSchema.hostname(); @@ -867,7 +878,7 @@ strSchema = strSchema.trim(); strSchema = strSchema.truncate(); strSchema = strSchema.truncate(false); strSchema = strSchema.normalize(); -strSchema = strSchema.normalize('NFKC'); +strSchema = strSchema.normalize("NFKC"); strSchema = strSchema.base64(); strSchema = strSchema.base64(base64Opts); strSchema = strSchema.dataUri(); @@ -927,23 +938,23 @@ Joi.checkPreferences(validOpts); let expr; -expr = Joi.expression('{{foo}}'); -expr = Joi.expression('{{foo}}', { adjust: (value) => value }); -expr = Joi.expression('{{foo}}', { ancestor: 3 }); -expr = Joi.expression('{{foo}}', { in: true }); -expr = Joi.expression('{{foo}}', { iterables: true }); -expr = Joi.expression('{{foo}}', { map: [['key', 'value']] }); -expr = Joi.expression('{{foo}}', { prefix: { local: '%' } }); -expr = Joi.expression('{{foo}}', { separator: '_' }); - -expr = Joi.x('{{foo}}'); -expr = Joi.x('{{foo}}', { adjust: (value) => value }); -expr = Joi.x('{{foo}}', { ancestor: 3 }); -expr = Joi.x('{{foo}}', { in: true }); -expr = Joi.x('{{foo}}', { iterables: true }); -expr = Joi.x('{{foo}}', { map: [['key', 'value']] }); -expr = Joi.x('{{foo}}', { prefix: { local: '%' } }); -expr = Joi.x('{{foo}}', { separator: '_' }); +expr = Joi.expression("{{foo}}"); +expr = Joi.expression("{{foo}}", { adjust: (value) => value }); +expr = Joi.expression("{{foo}}", { ancestor: 3 }); +expr = Joi.expression("{{foo}}", { in: true }); +expr = Joi.expression("{{foo}}", { iterables: true }); +expr = Joi.expression("{{foo}}", { map: [["key", "value"]] }); +expr = Joi.expression("{{foo}}", { prefix: { local: "%" } }); +expr = Joi.expression("{{foo}}", { separator: "_" }); + +expr = Joi.x("{{foo}}"); +expr = Joi.x("{{foo}}", { adjust: (value) => value }); +expr = Joi.x("{{foo}}", { ancestor: 3 }); +expr = Joi.x("{{foo}}", { in: true }); +expr = Joi.x("{{foo}}", { iterables: true }); +expr = Joi.x("{{foo}}", { map: [["key", "value"]] }); +expr = Joi.x("{{foo}}", { prefix: { local: "%" } }); +expr = Joi.x("{{foo}}", { separator: "_" }); // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- @@ -973,7 +984,7 @@ schema = Joi.link(str); { // validate tests { - let value = { username: 'example', password: 'example' }; + let value = { username: "example", password: "example" }; const schema = Joi.object().keys({ username: Joi.string().max(255).required(), password: Joi.string().pattern(/^[a-zA-Z0-9]{3,255}$/).required(), @@ -985,7 +996,7 @@ schema = Joi.link(str); result = schema.validate(value); if (result.error) { - throw Error('error should not be set'); + throw Error("error should not be set"); } result = schema.validate(value, validOpts); asyncResult = schema.validateAsync(value); @@ -993,13 +1004,15 @@ schema = Joi.link(str); asyncResult .then(val => JSON.stringify(val, null, 2)) - .then(val => { throw new Error('one error'); }) - .catch(e => { }); + .then(val => { + throw new Error("one error"); + }) + .catch(e => {}); - const falsyValue = { username: 'example' }; + const falsyValue = { username: "example" }; result = schema.validate(falsyValue); if (!result.error) { - throw Error('error should be set'); + throw Error("error should be set"); } } } @@ -1018,7 +1031,7 @@ Joi.assert(obj, schema, validOpts); Joi.assert(obj, schemaLike); { - let value = { username: 'example', password: 'example' }; + let value = { username: "example", password: "example" }; value = Joi.attempt(obj, schema); value = Joi.attempt(obj, schema, str); value = Joi.attempt(obj, schema, str, validOpts); @@ -1037,13 +1050,13 @@ Joi.isSchema(schema); description = schema.describe(); -const Joi2 = Joi.extend({ type: '', base: schema }); +const Joi2 = Joi.extend({ type: "", base: schema }); const Joi3 = Joi.extend({ - type: 'string', + type: "string", base: Joi.string(), messages: { - asd: 'must be exactly asd(f)' + asd: "must be exactly asd(f)", }, coerce(schema, value) { return { value }; @@ -1052,17 +1065,17 @@ const Joi3 = Joi.extend({ asd: { args: [ { - name: 'allowFalse', + name: "allowFalse", ref: true, assert: Joi.boolean(), - } + }, ], method(allowFalse: boolean) { return this.$_addRule({ - name: 'asd', + name: "asd", args: { allowFalse, - } + }, }); }, validate(value: boolean, helpers, params, options) { @@ -1070,23 +1083,23 @@ const Joi3 = Joi.extend({ return value; } - return helpers.error('asd', { v: value }, options); - } - } - } + return helpers.error("asd", { v: value }, options); + }, + }, + }, }); -const Joi4 = Joi.extend({ type: '', base: schema }, { type: '', base: schema }); +const Joi4 = Joi.extend({ type: "", base: schema }, { type: "", base: schema }); -const Joi5 = Joi.extend({ type: '', base: schema }, { type: '', base: schema }, { type: '', base: schema }); +const Joi5 = Joi.extend({ type: "", base: schema }, { type: "", base: schema }, { type: "", base: schema }); // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- const defaultsJoi = Joi.defaults((schema) => { switch (schema.type) { - case 'string': - return schema.allow(''); - case 'object': + case "string": + return schema.allow(""); + case "object": return (schema as Joi.ObjectSchema).min(1); default: return schema; @@ -1154,12 +1167,12 @@ ref = Joi.in(str, refOpts); schema = Joi.symbol(); schema = Joi.symbol().map(new Map()); schema = Joi.symbol().map({ - key: Symbol('asd'), + key: Symbol("asd"), }); // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- -const rule = Joi.string().case('upper').$_getRule('case'); +const rule = Joi.string().case("upper").$_getRule("case"); if (rule && rule.args) { const direction = rule.args.direction; } @@ -1185,7 +1198,7 @@ anyObject = anyObject.append({ }); anyObject = anyObject.keys({ - length: Joi.string() + length: Joi.string(), }); // test with keys @@ -1197,7 +1210,7 @@ Joi.object().keys({ }).append({ height: Joi.number(), }).keys({ - length: Joi.string() + length: Joi.string(), }); // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- diff --git a/types/hapi__joi/index.d.ts b/types/hapi__joi/index.d.ts index e7d584115d3b4f..0df58278595336 100644 --- a/types/hapi__joi/index.d.ts +++ b/types/hapi__joi/index.d.ts @@ -30,24 +30,24 @@ declare namespace Joi { type Types = - | 'any' - | 'alternatives' - | 'array' - | 'boolean' - | 'binary' - | 'date' - | 'function' - | 'link' - | 'number' - | 'object' - | 'string' - | 'symbol'; - - type BasicType = boolean|number|string|any[]|object|null; + | "any" + | "alternatives" + | "array" + | "boolean" + | "binary" + | "date" + | "function" + | "link" + | "number" + | "object" + | "string" + | "symbol"; + + type BasicType = boolean | number | string | any[] | object | null; type LanguageMessages = Record; - type PresenceMode = 'optional' | 'required' | 'forbidden'; + type PresenceMode = "optional" | "required" | "forbidden"; interface ErrorFormattingOptions { /** @@ -59,7 +59,7 @@ declare namespace Joi { /** * defines the value used to set the label context variable. */ - label?: 'path' | 'key' | false | undefined; + label?: "path" | "key" | false | undefined; /** * The preferred language code for error messages. * The value is matched against keys at the root of the messages object, and then the error code as a child key of that. @@ -93,14 +93,14 @@ declare namespace Joi { * * @default '"' */ - label?: string|false | undefined, + label?: string | false | undefined; /** * the characters used around array avlues. Defaults to `'[]'` * * @default '[]' */ - array?: string|false | undefined + array?: string | false | undefined; } | undefined; } @@ -138,7 +138,7 @@ declare namespace Joi { * * @default 'iso' */ - dateFormat?: 'date' | 'iso' | 'string' | 'time' | 'utc' | undefined; + dateFormat?: "date" | "iso" | "string" | "time" | "utc" | undefined; /** * when true, valid results and throw errors are decorated with a debug property which includes an array of the validation steps used to generate the returned result. * @@ -348,7 +348,7 @@ declare namespace Joi { cidr?: PresenceMode | undefined; } - type GuidVersions = 'uuidv1' | 'uuidv2' | 'uuidv3' | 'uuidv4' | 'uuidv5'; + type GuidVersions = "uuidv1" | "uuidv2" | "uuidv3" | "uuidv4" | "uuidv5"; interface GuidOptions { version: GuidVersions[] | GuidVersions; @@ -394,7 +394,7 @@ declare namespace Joi { paddingRequired?: boolean | undefined; } - interface Base64Options extends Pick { + interface Base64Options extends Pick { /** * if true, uses the URI-safe base64 format which replaces `+` with `-` and `\` with `_`. * @@ -624,7 +624,7 @@ declare namespace Joi { } interface ValidationError extends Error { - name: 'ValidationError'; + name: "ValidationError"; isJoi: boolean; @@ -863,7 +863,7 @@ declare namespace Joi { /** * Casts the validated value to the specified type. */ - cast(to: 'map' | 'number' | 'set' | 'string'): this; + cast(to: "map" | "number" | "set" | "string"): this; /** * Returns a new type that is the result of adding the rules of one type to another. @@ -891,7 +891,7 @@ declare namespace Joi { * Note that if value is an object, any changes to the object after `default()` is called will change the * reference and any future assignment. */ - default(value?: BasicType|Reference|((parent: any, helpers: CustomHelpers) => BasicType|Reference)): this; + default(value?: BasicType | Reference | ((parent: any, helpers: CustomHelpers) => BasicType | Reference)): this; /** * Returns a plain object representing the schema's rules and properties @@ -1287,7 +1287,7 @@ declare namespace Joi { /** * Requires the number to be negative or positive. */ - sign(sign: 'positive' | 'negative'): this; + sign(sign: "positive" | "negative"): this; /** * Allows the number to be outside of JavaScript's safety range (Number.MIN_SAFE_INTEGER & Number.MAX_SAFE_INTEGER). @@ -1309,7 +1309,7 @@ declare namespace Joi { /** * Sets the required string case. */ - case(direction: 'upper' | 'lower'): this; + case(direction: "upper" | "lower"): this; /** * Requires the number to be a credit card number (Using Lunh Algorithm). @@ -1396,7 +1396,7 @@ declare namespace Joi { * Requires the string value to be in a unicode normalized form. If the validation convert option is on (enabled by default), the string will be normalized. * @param [form='NFC'] - The unicode normalization form to use. Valid values: NFC [default], NFD, NFKC, NFKD */ - normalize(form?: 'NFC' | 'NFD' | 'NFKC' | 'NFKD'): this; + normalize(form?: "NFC" | "NFD" | "NFKC" | "NFKD"): this; /** * Defines a regular expression rule. @@ -1469,7 +1469,7 @@ declare namespace Joi { /** * @default 'ascending' */ - order?: 'ascending' | 'descending' | undefined; + order?: "ascending" | "descending" | undefined; by?: string | Reference | undefined; } @@ -1708,7 +1708,7 @@ declare namespace Joi { * allowing to explicitly ensure a date is either in the past or in the future. * It can also be a reference to another field. */ - greater(date: 'now' | Date | number | string | Reference): this; + greater(date: "now" | Date | number | string | Reference): this; /** * Requires the string value to be in valid ISO 8601 date format. @@ -1721,7 +1721,7 @@ declare namespace Joi { * allowing to explicitly ensure a date is either in the past or in the future. * It can also be a reference to another field. */ - less(date: 'now' | Date | number | string | Reference): this; + less(date: "now" | Date | number | string | Reference): this; /** * Specifies the oldest date allowed. @@ -1729,7 +1729,7 @@ declare namespace Joi { * allowing to explicitly ensure a date is either in the past or in the future. * It can also be a reference to another field. */ - min(date: 'now' | Date | number | string | Reference): this; + min(date: "now" | Date | number | string | Reference): this; /** * Specifies the latest date allowed. @@ -1737,13 +1737,13 @@ declare namespace Joi { * allowing to explicitly ensure a date is either in the past or in the future. * It can also be a reference to another field. */ - max(date: 'now' | Date | number | string | Reference): this; + max(date: "now" | Date | number | string | Reference): this; /** * Requires the value to be a timestamp interval from Unix Time. * @param type - the type of timestamp (allowed values are unix or javascript [default]) */ - timestamp(type?: 'javascript' | 'unix'): this; + timestamp(type?: "javascript" | "unix"): this; } interface FunctionSchema extends ObjectSchema { @@ -1782,7 +1782,7 @@ declare namespace Joi { * Requires the validated value to match a specific set of the provided alternative.try() schemas. * Cannot be combined with `alternatives.conditional()`. */ - match(mode: 'any' | 'all' | 'one'): this; + match(mode: "any" | "all" | "one"): this; /** * Adds an alternative schema type for attempting to match against the validated value. @@ -1804,7 +1804,7 @@ declare namespace Joi { ref(ref: string): this; } - interface Reference extends Exclude { + interface Reference extends Exclude { depth: number; type: string; key: string; @@ -1890,7 +1890,7 @@ declare namespace Joi { interface ExtensionTerm { init: any[] | null; register?: any; - manifest?: Record | undefined; + manifest?: Record | undefined; } interface Extension { @@ -1932,7 +1932,7 @@ declare namespace Joi { */ version: string; - ValidationError: new (message: string, details: any, original: any) => ValidationError; + ValidationError: new(message: string, details: any, original: any) => ValidationError; /** * Generates a schema object that matches any data type. diff --git a/types/hapi__jwt/hapi__jwt-tests.ts b/types/hapi__jwt/hapi__jwt-tests.ts index a729fb8c4a8f2e..6af1afc60f3d3f 100644 --- a/types/hapi__jwt/hapi__jwt-tests.ts +++ b/types/hapi__jwt/hapi__jwt-tests.ts @@ -1,5 +1,5 @@ -import * as Hapi from '@hapi/hapi'; -import * as Jwt from '@hapi/jwt'; +import * as Hapi from "@hapi/hapi"; +import * as Jwt from "@hapi/jwt"; // Plugin definitions @@ -7,11 +7,11 @@ const server = Hapi.server({ port: 8000 }); server.register(Jwt); -server.auth.strategy('my_jwt_stategy', 'jwt', { - keys: 'some_shared_secret', +server.auth.strategy("my_jwt_stategy", "jwt", { + keys: "some_shared_secret", verify: { - aud: 'urn:audience:test', - iss: 'urn:issuer:test', + aud: "urn:audience:test", + iss: "urn:issuer:test", sub: false, nbf: true, exp: true, @@ -26,20 +26,20 @@ server.auth.strategy('my_jwt_stategy', 'jwt', { }, }); -server.auth.default('my_jwt_stategy'); +server.auth.default("my_jwt_stategy"); // Token definitions const encodedToken = Jwt.token.generate( { - aud: 'urn:audience:test', - iss: 'urn:issuer:test', - user: 'some_user_name', - group: 'hapi_community', + aud: "urn:audience:test", + iss: "urn:issuer:test", + user: "some_user_name", + group: "hapi_community", }, { - key: 'some_shared_secret', - algorithm: 'HS512', + key: "some_shared_secret", + algorithm: "HS512", }, { ttlSec: 14400, // 4 hours @@ -48,24 +48,24 @@ const encodedToken = Jwt.token.generate( const token = Jwt.token.decode(encodedToken); -Jwt.token.verify(token, 'some_shared_secret'); +Jwt.token.verify(token, "some_shared_secret"); -Jwt.token.verifySignature(token, 'some_shared_secret'); +Jwt.token.verifySignature(token, "some_shared_secret"); Jwt.token.verifyPayload(token); Jwt.token.verifyTime(token); -Jwt.token.signature.generate(token.token, 'HS512', 'some_shared_secret'); +Jwt.token.signature.generate(token.token, "HS512", "some_shared_secret"); -Jwt.token.signature.verify(token.raw, 'HS512', 'some_shared_secret'); +Jwt.token.signature.verify(token.raw, "HS512", "some_shared_secret"); // Crypto definitions -Jwt.crypto.rsaPublicKeyToPEM('00:aa:18:ab:a4:3b:50:de:ef:38:59:8f:af:87:d2', '65537'); +Jwt.crypto.rsaPublicKeyToPEM("00:aa:18:ab:a4:3b:50:de:ef:38:59:8f:af:87:d2", "65537"); // Utils definitions Jwt.utils.toHex(2020); -Jwt.utils.b64stringify({ foo: 'bar' }); +Jwt.utils.b64stringify({ foo: "bar" }); diff --git a/types/hapi__jwt/index.d.ts b/types/hapi__jwt/index.d.ts index 30eec7274d9efa..7696c044103a77 100644 --- a/types/hapi__jwt/index.d.ts +++ b/types/hapi__jwt/index.d.ts @@ -4,9 +4,9 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 4.2 -import { Plugin, ResponseToolkit, Request, ResponseObject } from '@hapi/hapi'; +import { Plugin, Request, ResponseObject, ResponseToolkit } from "@hapi/hapi"; -declare module '@hapi/hapi' { +declare module "@hapi/hapi" { interface ServerAuth { /** * Function to define the server authentication strategy to be used. @@ -15,7 +15,7 @@ declare module '@hapi/hapi' { * @param scheme jwt for this plugin. * @param options jwt plugin options. */ - strategy(name: string, scheme: 'jwt', options?: hapiJwt.Options): void; + strategy(name: string, scheme: "jwt", options?: hapiJwt.Options): void; } } @@ -23,19 +23,19 @@ declare namespace hapiJwt { // Common definitions type SupportedAlgorithm = - | 'RS256' - | 'RS384' - | 'RS512' - | 'PS256' - | 'PS384' - | 'PS512' - | 'ES256' - | 'ES384' - | 'ES512' - | 'HS256' - | 'HS384' - | 'HS512'; - type NoAlgorithm = 'none'; + | "RS256" + | "RS384" + | "RS512" + | "PS256" + | "PS384" + | "PS512" + | "ES256" + | "ES384" + | "ES512" + | "HS256" + | "HS384" + | "HS512"; + type NoAlgorithm = "none"; interface StandardKey { /** @@ -85,7 +85,7 @@ declare namespace hapiJwt { /** * The token type. */ - typ?: 'JWT' | undefined; + typ?: "JWT" | undefined; }; /** * An object containing the payload. diff --git a/types/hapi__pez/hapi__pez-tests.ts b/types/hapi__pez/hapi__pez-tests.ts index edaf5c9305ff3e..3607537c16fe1b 100644 --- a/types/hapi__pez/hapi__pez-tests.ts +++ b/types/hapi__pez/hapi__pez-tests.ts @@ -1,18 +1,18 @@ import Content from "@hapi/content"; -import Pez from '@hapi/pez'; +import Pez from "@hapi/pez"; const contentType = Content.type("application/json; charset=utf-8"); -const minDispenser = new Pez.Dispenser({ boundary: 'AaB03x' }); +const minDispenser = new Pez.Dispenser({ boundary: "AaB03x" }); const maxBytesDispenser = new Pez.Dispenser({ - boundary: 'AaB03x', - maxBytes: 4096 - 1, - maxParts: 1, + boundary: "AaB03x", + maxBytes: 4096 - 1, + maxParts: 1, }); // Example with Node Stream Options type const nodeOptionDispenser = new Pez.Dispenser({ - boundary: 'AaB03x', - maxBytes: 50e6, - ...contentType, + boundary: "AaB03x", + maxBytes: 50e6, + ...contentType, }); diff --git a/types/hapi__pez/index.d.ts b/types/hapi__pez/index.d.ts index 4f2a463a2ff7cc..018e7821085820 100644 --- a/types/hapi__pez/index.d.ts +++ b/types/hapi__pez/index.d.ts @@ -4,14 +4,14 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -import * as stream from 'stream'; +import * as stream from "stream"; export interface PezOptions extends stream.WritableOptions { - boundary: string; - maxBytes?: number; - maxParts?: number; + boundary: string; + maxBytes?: number; + maxParts?: number; } export class Dispenser extends stream.Writable { - constructor(options?: PezOptions); + constructor(options?: PezOptions); } diff --git a/types/hapi__shot/hapi__shot-tests.ts b/types/hapi__shot/hapi__shot-tests.ts index ce8b828e53f464..417e3c71cab534 100644 --- a/types/hapi__shot/hapi__shot-tests.ts +++ b/types/hapi__shot/hapi__shot-tests.ts @@ -2,19 +2,21 @@ // Load modules -import { IncomingMessage, ServerResponse, createServer } from 'http'; -import { inject } from '@hapi/shot'; +import { inject } from "@hapi/shot"; +import { createServer, IncomingMessage, ServerResponse } from "http"; // Declare internals async function main() { const dispatch = (req: IncomingMessage, res: ServerResponse) => { - const reply = 'Hello World'; - res.writeHead(200, { 'Content-Type': 'text/plain', 'Content-Length': reply.length }); + const reply = "Hello World"; + res.writeHead(200, { "Content-Type": "text/plain", "Content-Length": reply.length }); res.end(reply); }; const server = createServer(dispatch); - console.log((await inject(dispatch, { method: 'get', url: '/', headers: { test: 'asd', test2: ['a', 'b'] } })).payload); + console.log( + (await inject(dispatch, { method: "get", url: "/", headers: { test: "asd", test2: ["a", "b"] } })).payload, + ); } diff --git a/types/hapi__shot/index.d.ts b/types/hapi__shot/index.d.ts index 97125286ea8b86..3a2e869b66ad25 100644 --- a/types/hapi__shot/index.d.ts +++ b/types/hapi__shot/index.d.ts @@ -104,5 +104,5 @@ export interface ResponseObject { /** the raw payload as a Buffer. */ rawPayload: Buffer; /** an object containing the response trailers. */ - trailers: {[index: string]: any}; + trailers: { [index: string]: any }; } diff --git a/types/hapi__sntp/hapi__sntp-tests.ts b/types/hapi__sntp/hapi__sntp-tests.ts index ccf5eebbec9fcd..aceae193960cd3 100644 --- a/types/hapi__sntp/hapi__sntp-tests.ts +++ b/types/hapi__sntp/hapi__sntp-tests.ts @@ -1,7 +1,7 @@ -import Sntp = require('@hapi/sntp'); +import Sntp = require("@hapi/sntp"); const options = { - host: 'abc', + host: "abc", port: 123, }; diff --git a/types/hapi__subtext/hapi__subtext-tests.ts b/types/hapi__subtext/hapi__subtext-tests.ts index 76e61ace56fb5e..fbb63310020ae9 100644 --- a/types/hapi__subtext/hapi__subtext-tests.ts +++ b/types/hapi__subtext/hapi__subtext-tests.ts @@ -1,15 +1,15 @@ -import { parse } from '@hapi/subtext'; -import { IncomingMessage } from 'http'; -import { Socket } from 'net'; +import { parse } from "@hapi/subtext"; +import { IncomingMessage } from "http"; +import { Socket } from "net"; const socket = new Socket(); const req = new IncomingMessage(socket); parse(req, null, { - output: "data", - parse: true, + output: "data", + parse: true, }) - .then(result => { - console.log(result.payload); - console.log(result.mime); - }); + .then(result => { + console.log(result.payload); + console.log(result.mime); + }); diff --git a/types/hapi__subtext/index.d.ts b/types/hapi__subtext/index.d.ts index efad7f39918579..c51f54b4e1bc37 100644 --- a/types/hapi__subtext/index.d.ts +++ b/types/hapi__subtext/index.d.ts @@ -5,49 +5,49 @@ /// -import { IncomingMessage } from 'http'; -import stream = require('stream'); -import { BrotliOptions, ZlibOptions } from 'zlib'; +import { IncomingMessage } from "http"; +import stream = require("stream"); +import { BrotliOptions, ZlibOptions } from "zlib"; export interface MultipartOptions { - output: "data" | "stream" | "file"; + output: "data" | "stream" | "file"; } export interface DecompressionOptions { - gzip?: ZlibOptions; - deflate?: ZlibOptions; - br?: BrotliOptions; - compress?: BrotliOptions; + gzip?: ZlibOptions; + deflate?: ZlibOptions; + br?: BrotliOptions; + compress?: BrotliOptions; } export interface ContentDecoders { - gzip?: (options: ZlibOptions | null) => stream.Transform; - deflate?: (options: ZlibOptions | null) => stream.Transform; - br?: (options: BrotliOptions | null) => stream.Transform; - compress?: (options: BrotliOptions | null) => stream.Transform; + gzip?: (options: ZlibOptions | null) => stream.Transform; + deflate?: (options: ZlibOptions | null) => stream.Transform; + br?: (options: BrotliOptions | null) => stream.Transform; + compress?: (options: BrotliOptions | null) => stream.Transform; } export interface Options { - parse: boolean; - output: "data" | "stream" | "file"; - maxBytes?: number; - override?: string; - defaultContentType?: string; - allow?: string[]; - timeout?: number; - querystring?: (str: string) => Partial>; - uploads?: string; - multipart?: boolean | MultipartOptions; - decoders?: ContentDecoders; - compression?: DecompressionOptions; + parse: boolean; + output: "data" | "stream" | "file"; + maxBytes?: number; + override?: string; + defaultContentType?: string; + allow?: string[]; + timeout?: number; + querystring?: (str: string) => Partial>; + uploads?: string; + multipart?: boolean | MultipartOptions; + decoders?: ContentDecoders; + compression?: DecompressionOptions; } export interface Result { - /** - * Will be `null` if no payload was present on request - */ - payload: unknown; - mime: string; + /** + * Will be `null` if no payload was present on request + */ + payload: unknown; + mime: string; } export function parse(req: IncomingMessage, tap: null | NodeJS.WritableStream, options: Options): Promise; diff --git a/types/hapi__vision/hapi__vision-tests.ts b/types/hapi__vision/hapi__vision-tests.ts index 4013beea55c8e2..39fc9652291ed3 100644 --- a/types/hapi__vision/hapi__vision-tests.ts +++ b/types/hapi__vision/hapi__vision-tests.ts @@ -1,11 +1,7 @@ -import { - Server, - Request, - ResponseToolkit, -} from '@hapi/hapi'; +import { Request, ResponseToolkit, Server } from "@hapi/hapi"; -import * as Vision from '@hapi/vision'; -import * as Handlebars from 'handlebars'; +import * as Vision from "@hapi/vision"; +import * as Handlebars from "handlebars"; const server = new Server({ port: 80, @@ -16,43 +12,43 @@ const provision = async () => { plugin: Vision, options: { engines: { hbs: Handlebars }, - path: __dirname + '/templates', - } + path: __dirname + "/templates", + }, }); server.views({ engines: { hbs: Handlebars }, - path: __dirname + '/templates', + path: __dirname + "/templates", }); const manager = server.getViewsManager(); - manager.registerHelper('test', () => 'test'); + manager.registerHelper("test", () => "test"); const context = { - title: 'Views Example', - message: 'Hello, World', + title: "Views Example", + message: "Hello, World", }; - console.log(await server.render('hello', context)); + console.log(await server.render("hello", context)); server.route({ - method: 'GET', - path: '/view', + method: "GET", + path: "/view", handler: async (request: Request, h: ResponseToolkit) => { - return request.render('test', { message: 'hello' }); + return request.render("test", { message: "hello" }); }, }); server.route({ - method: 'GET', - path: '/', + method: "GET", + path: "/", handler: { view: { - template: 'hello', + template: "hello", context: { - title: 'Views Example', - message: 'Hello, World', + title: "Views Example", + message: "Hello, World", }, }, }, @@ -60,20 +56,20 @@ const provision = async () => { const handler = (request: Request, h: ResponseToolkit) => { const context = { - title: 'Views Example', - message: 'Hello, World', + title: "Views Example", + message: "Hello, World", }; - return h.view('hello', context); + return h.view("hello", context); }; - server.route({ method: 'GET', path: '/', handler }); + server.route({ method: "GET", path: "/", handler }); server.route({ - method: 'GET', - path: '/temp1', + method: "GET", + path: "/temp1", handler: { view: { - template: 'temp1', + template: "temp1", options: { compileOptions: { noEscape: true, diff --git a/types/hapi__vision/index.d.ts b/types/hapi__vision/index.d.ts index d77ee4aa918a7c..b8e23691380144 100644 --- a/types/hapi__vision/index.d.ts +++ b/types/hapi__vision/index.d.ts @@ -4,13 +4,9 @@ // Alexander James Phillips // Silas Rech // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 +// Minimum TypeScript Version: 4.9 -import { - Plugin, - Request, - ResponseObject, -} from '@hapi/hapi'; +import { Plugin, Request, ResponseObject } from "@hapi/hapi"; declare namespace vision { interface EnginesConfiguration { @@ -18,7 +14,7 @@ declare namespace vision { * Required object where each key is a file extension (e.g. 'html', 'hbr'), mapped to the npm module used for rendering the templates. * Alternatively, the extension can be mapped to an object */ - engines: {[fileExtension: string]: NpmModule} | ServerViewsEnginesOptions; + engines: { [fileExtension: string]: NpmModule } | ServerViewsEnginesOptions; /** defines the default filename extension to append to template names when multiple engines are configured and no explicit extension is provided for a given template. No default value. */ defaultExtension?: string | undefined; } @@ -54,7 +50,6 @@ declare namespace vision { } /** - * * @see {@link https://github.com/hapijs/vision/blob/master/API.md#the-view-handler} > options for the list of attributes it can not have (isCached, partialsPath, helpersPath) */ interface ViewHandlerOrReplyOptions { @@ -90,7 +85,7 @@ declare namespace vision { /** the content type of the engine results. Defaults to 'text/html'. */ contentType?: string | undefined; /** specify whether the engine compile() method is 'sync' or 'async'. Defaults to 'sync'. */ - compileMode?: 'sync' | 'async' | undefined; + compileMode?: "sync" | "async" | undefined; /** * A global context used with all templates. * The global context option can be either an object or a function that takes the request as its only argument and returns a context object. @@ -126,12 +121,15 @@ declare namespace vision { * compiled is a function with signature function(context, options, callback) (the compiled async template) * and callback has the signature function(err, rendered). */ - type ServerViewCompileSync = (template: string, options: any) => (context: any, options: any) => void; + type ServerViewCompileSync = (template: string, options: any) => (context: any, options: any) => void; type ServerViewCompileAsync = (template: string, options: any, next: ServerViewCompileNext) => void; type ServerViewCompile = ServerViewCompileSync | ServerViewCompileAsync; - type ServerViewCompileNext = (err: Error | null, compiled: (context: any, options: any, callback: (err: null | Error, rendered: string | null) => void) => void) => void; + type ServerViewCompileNext = ( + err: Error | null, + compiled: (context: any, options: any, callback: (err: null | Error, rendered: string | null) => void) => void, + ) => void; /** * The npm module used for rendering the templates. The module object must contain the compile() function @@ -195,7 +193,7 @@ declare const vision: Plugin; export = vision; -declare module '@hapi/hapi' { +declare module "@hapi/hapi" { interface Server { /** * Initializes the server views manager @@ -216,7 +214,7 @@ declare module '@hapi/hapi' { } } -declare module '@hapi/hapi' { +declare module "@hapi/hapi" { interface Request { /** * request.render() works the same way as server.render() but is for use inside of request handlers. @@ -237,7 +235,7 @@ declare module '@hapi/hapi' { } } -declare module '@hapi/hapi' { +declare module "@hapi/hapi" { interface ResponseToolkit { /** * Concludes the handler activity by returning control over to the router with a templatized view response @@ -259,7 +257,7 @@ declare module '@hapi/hapi' { } } -declare module '@hapi/hapi' { +declare module "@hapi/hapi" { interface HandlerDecorations { /** * The view handler can be used with routes registered in the same realm as the view manager. diff --git a/types/hapi__yar/hapi__yar-tests.ts b/types/hapi__yar/hapi__yar-tests.ts index 7d606f557f11a8..c9e5a5352a7f57 100644 --- a/types/hapi__yar/hapi__yar-tests.ts +++ b/types/hapi__yar/hapi__yar-tests.ts @@ -1,5 +1,5 @@ -import { Server, Request } from '@hapi/hapi'; -import * as yar from '@hapi/yar'; +import { Request, Server } from "@hapi/hapi"; +import * as yar from "@hapi/yar"; async function boot() { const server = new Server(); @@ -7,25 +7,25 @@ async function boot() { plugin: yar, options: { cookieOptions: { - password: 'test', + password: "test", isSecure: true, }, cache: { - cache: 'test', + cache: "test", expiresIn: 123141243, - } + }, }, }); server.route({ - path: '/test', - method: 'get', + path: "/test", + method: "get", async handler(request: Request, h) { - const example = request.yar.get('example'); + const example = request.yar.get("example"); - request.yar.flash('info', 'Hello world.'); + request.yar.flash("info", "Hello world."); const all_flashes = request.yar.flash(); - const info_flashes = request.yar.flash('info'); + const info_flashes = request.yar.flash("info"); await request.yar.commit(h); @@ -33,7 +33,7 @@ async function boot() { id: request.yar.id, key: example.key, all_flashes, - info_flashes + info_flashes, }; }, }); diff --git a/types/hapi__yar/index.d.ts b/types/hapi__yar/index.d.ts index 6b2f0a75d5c980..65a01dbc7f7a39 100644 --- a/types/hapi__yar/index.d.ts +++ b/types/hapi__yar/index.d.ts @@ -3,11 +3,11 @@ // Definitions by: Simon Schick // Silas Rech // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 +// Minimum TypeScript Version: 4.9 // From https://github.com/hapijs/yar/blob/master/API.md -import { Server, ServerOptionsCache, Request, Plugin, CachePolicyOptions, ResponseToolkit } from '@hapi/hapi'; -import { PolicyOptions, Id } from '@hapi/catbox'; +import { Id, PolicyOptions } from "@hapi/catbox"; +import { CachePolicyOptions, Plugin, Request, ResponseToolkit, Server, ServerOptionsCache } from "@hapi/hapi"; declare namespace yar { interface YarOptions { /** @@ -78,7 +78,7 @@ declare namespace yar { * enables the same-site cookie parameter. * Default to 'Lax'. */ - isSameSite?: 'Lax' | 'Strict' | 'None' | false | undefined; + isSameSite?: "Lax" | "Strict" | "None" | false | undefined; /** * determines whether or not to transfer using TLS/SSL. * Defaults to true. @@ -170,7 +170,7 @@ declare namespace yar { declare const yar: Plugin; export = yar; -declare module '@hapi/hapi' { +declare module "@hapi/hapi" { interface Request { yar: yar.Yar; } diff --git a/types/hapipal__avocat/hapipal__avocat-tests.ts b/types/hapipal__avocat/hapipal__avocat-tests.ts index f44ddc6455f6f0..fe79452e21f459 100644 --- a/types/hapipal__avocat/hapipal__avocat-tests.ts +++ b/types/hapipal__avocat/hapipal__avocat-tests.ts @@ -1,5 +1,5 @@ -import * as Avocat from '@hapipal/avocat'; -import * as Boom from '@hapi/boom'; +import * as Boom from "@hapi/boom"; +import * as Avocat from "@hapipal/avocat"; const notFound: Boom.Boom = Avocat.rethrow(Boom.notFound(), { return: true }); notFound.message; diff --git a/types/hapipal__avocat/index.d.ts b/types/hapipal__avocat/index.d.ts index 10cb68cf499ed7..38882f77e1642d 100644 --- a/types/hapipal__avocat/index.d.ts +++ b/types/hapipal__avocat/index.d.ts @@ -2,9 +2,10 @@ // Project: https://github.com/hapipal/avocat#readme // Definitions by: Tim Costa // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// Minimum TypeScript Version: 4.9 -import { ResponseObject } from '@hapi/hapi'; -import { Boom } from '@hapi/boom'; +import { Boom } from "@hapi/boom"; +import { ResponseObject } from "@hapi/hapi"; export interface Options { return?: boolean | undefined; diff --git a/types/hapipal__schmervice/hapipal__schmervice-tests.ts b/types/hapipal__schmervice/hapipal__schmervice-tests.ts index 0d4b632af780b5..903be7a700586b 100644 --- a/types/hapipal__schmervice/hapipal__schmervice-tests.ts +++ b/types/hapipal__schmervice/hapipal__schmervice-tests.ts @@ -1,10 +1,10 @@ -import * as Schmervice from '@hapipal/schmervice'; -import * as Hapi from '@hapi/hapi'; +import * as Hapi from "@hapi/hapi"; +import * as Schmervice from "@hapipal/schmervice"; -import { OrganizationService as OrganizationServiceClass } from './test/organization_service'; -import { UserService as UserServiceClass } from './test/user_service'; +import { OrganizationService as OrganizationServiceClass } from "./test/organization_service"; +import { UserService as UserServiceClass } from "./test/user_service"; -declare module '@hapipal/schmervice' { +declare module "@hapipal/schmervice" { interface AuthServices { membersService: Service; adminService: Service; @@ -18,8 +18,8 @@ declare module '@hapipal/schmervice' { } interface SchmerviceDecorator { - (namespace: 'auth'): AuthServices; - (namespace: 'oath'): OathServices; + (namespace: "auth"): AuthServices; + (namespace: "oath"): OathServices; } } @@ -34,31 +34,31 @@ declare module '@hapipal/schmervice' { server.registerService(OrganizationServiceClass); server.registerService(UserServiceClass); server.registerService({ - name: 'TestServiceObject' + name: "TestServiceObject", }); server.registerService((server, options) => ({ - name: 'TestServiceFactory', + name: "TestServiceFactory", server, - options + options, })); server.registerService( - Schmervice.withName('TestServiceWithName', {}, (server, options) => ({ - someMethod: () => {} - })) + Schmervice.withName("TestServiceWithName", {}, (server, options) => ({ + someMethod: () => {}, + })), ); server.registerService({ - [Schmervice.name]: 'TestServiceWithSymbols', - [Schmervice.sandbox]: 'server', - someMethod: () => {} + [Schmervice.name]: "TestServiceWithSymbols", + [Schmervice.sandbox]: "server", + someMethod: () => {}, }); server.registerService([ class MyArrayServiceClass extends Schmervice.Service { someMethod() {} }, { - name: 'MyArrayServiceObject', - someOtherMethod: () => {} - } + name: "MyArrayServiceObject", + someOtherMethod: () => {}, + }, ]); await server.initialize(); @@ -68,7 +68,7 @@ declare module '@hapipal/schmervice' { // and the handling of merged known keys const { UserService, OrganizationService, TestServiceObject } = server.services(); - const user = { firstName: 'Johnny', lastName: 'Dough' }; + const user = { firstName: "Johnny", lastName: "Dough" }; TestServiceObject.bind(); @@ -76,17 +76,17 @@ declare module '@hapipal/schmervice' { UserService.caching({ getFullName: { - expiresIn: 1000 - } + expiresIn: 1000, + }, }); UserService.caching({ getFullName: { generateKey: (id) => id, cache: { - expiresIn: 1000 - } - } + expiresIn: 1000, + }, + }, }); await OrganizationService.addUser(user); @@ -96,12 +96,12 @@ declare module '@hapipal/schmervice' { const { adminService, manangerService, - membersService - } = server.services('auth'); + membersService, + } = server.services("auth"); const { crownCourtService, promissoryService, - witnessService - } = server.services('oath'); + witnessService, + } = server.services("oath"); })(); diff --git a/types/hapipal__schmervice/index.d.ts b/types/hapipal__schmervice/index.d.ts index e15ddd040ab4ab..6ae9f0883b30f6 100644 --- a/types/hapipal__schmervice/index.d.ts +++ b/types/hapipal__schmervice/index.d.ts @@ -3,18 +3,18 @@ // Definitions by: Tim Costa // Danilo Alonso // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// Minimum TypeScript Version: 3.6 +// Minimum TypeScript Version: 4.9 -import { Plugin, Server, ServerOptionsCache, ServerMethodOptions } from '@hapi/hapi'; +import { Plugin, Server, ServerMethodOptions, ServerOptionsCache } from "@hapi/hapi"; export const name: unique symbol; export const sandbox: unique symbol; export interface ServiceCachingOptions { - [methodNameToCache: string]: ServerOptionsCache | Exclude; + [methodNameToCache: string]: ServerOptionsCache | Exclude; } -export type ServiceSandbox = boolean | 'plugin' | 'server'; +export type ServiceSandbox = boolean | "plugin" | "server"; export interface ServiceRegistrationObject { caching?: ServiceCachingOptions | undefined; @@ -48,7 +48,7 @@ export class Service { teardown?(): void; } -export type RegisterServiceConfiguration = (typeof ServiceFactory | Service | Service[] | ServiceRegistrationObject); +export type RegisterServiceConfiguration = typeof ServiceFactory | Service | Service[] | ServiceRegistrationObject; export const plugin: Plugin<{}>; @@ -59,7 +59,11 @@ export interface WithNameOptions { // TS takes issue with this function signature (name, [options], serviceFactory) due to a required param // following an optional param. The best solution short of changing the library appears to be to just // make options a required parameter that people can set to {} -export function withName(name: string, options: WithNameOptions, serviceFactory: RegisterServiceConfiguration): RegisterServiceConfiguration; +export function withName( + name: string, + options: WithNameOptions, + serviceFactory: RegisterServiceConfiguration, +): RegisterServiceConfiguration; // allows service definitions to optionally "register" themselves as types that will be returned // by using typescript declaration merging with interfaces @@ -73,8 +77,6 @@ export interface RegisteredServices { * or services registered on the server using `server.services(true)`, * or services scoped to plugin namespace using `server.services('namespace')`. * - * - * * This interface can be overwritten to modify what you want your namespace * to actually return. For example: * @@ -98,14 +100,13 @@ export interface RegisteredServices { * (namespace: 'oath'): OathServices * } * } - * */ - export interface SchmerviceDecorator { +export interface SchmerviceDecorator { (all?: boolean | string): RegisteredServices; } // sets up types for the functions added via hapi decorations -declare module '@hapi/hapi' { +declare module "@hapi/hapi" { interface Server { registerService: (config: RegisterServiceConfiguration) => void; services: SchmerviceDecorator; diff --git a/types/hapipal__schmervice/test/organization_service.ts b/types/hapipal__schmervice/test/organization_service.ts index 9c52a1bfb20a65..3f5622bda4547c 100644 --- a/types/hapipal__schmervice/test/organization_service.ts +++ b/types/hapipal__schmervice/test/organization_service.ts @@ -1,5 +1,5 @@ -import * as Schmervice from '@hapipal/schmervice'; -import { User } from './user_service'; +import * as Schmervice from "@hapipal/schmervice"; +import { User } from "./user_service"; // doesnt use name or sandbox symbols export class OrganizationService extends Schmervice.Service { @@ -8,15 +8,15 @@ export class OrganizationService extends Schmervice.Service { } async initialize() { - console.log('OrganizationService initialize'); + console.log("OrganizationService initialize"); } async teardown() { - console.log('OrganizationService teardown'); + console.log("OrganizationService teardown"); } } -declare module '@hapipal/schmervice' { +declare module "@hapipal/schmervice" { interface RegisteredServices { OrganizationService: OrganizationService; } diff --git a/types/hapipal__schmervice/test/user_service.ts b/types/hapipal__schmervice/test/user_service.ts index 26e63db292c984..6756d7795826ed 100644 --- a/types/hapipal__schmervice/test/user_service.ts +++ b/types/hapipal__schmervice/test/user_service.ts @@ -1,4 +1,4 @@ -import * as Schmervice from '@hapipal/schmervice'; +import * as Schmervice from "@hapipal/schmervice"; export interface User { firstName: string; @@ -6,7 +6,7 @@ export interface User { } export class UserService extends Schmervice.Service { - static [Schmervice.name]: 'user_service'; + static [Schmervice.name]: "user_service"; static [Schmervice.sandbox]: true; getFullName(user: User): string { @@ -14,15 +14,15 @@ export class UserService extends Schmervice.Service { } async initialize() { - console.log('UserService initialize'); + console.log("UserService initialize"); } async teardown() { - console.log('UserService teardown'); + console.log("UserService teardown"); } } -declare module '@hapipal/schmervice' { +declare module "@hapipal/schmervice" { interface RegisteredServices { UserService: UserService; } diff --git a/types/hapipal__toys/hapipal__toys-tests.ts b/types/hapipal__toys/hapipal__toys-tests.ts index 6c39ca830bb6ce..b13187bcb35a14 100644 --- a/types/hapipal__toys/hapipal__toys-tests.ts +++ b/types/hapipal__toys/hapipal__toys-tests.ts @@ -1,8 +1,8 @@ -import { EventEmitter } from 'events'; -import { Stream } from 'stream'; -import * as Boom from '@hapi/boom'; -import * as Hapi from '@hapi/hapi'; -import * as Toys from '@hapipal/toys'; +import * as Boom from "@hapi/boom"; +import * as Hapi from "@hapi/hapi"; +import * as Toys from "@hapipal/toys"; +import { EventEmitter } from "events"; +import { Stream } from "stream"; (async () => { const server = new Hapi.Server({ port: 3000 }); @@ -11,40 +11,40 @@ import * as Toys from '@hapipal/toys'; await server.register(Toys.noop); // test Toys.auth.strategy - Toys.auth.strategy(server, 'simple-bearer', async (request, h) => { - const token = (request.headers.authorization || '').replace('Bearer ', ''); + Toys.auth.strategy(server, "simple-bearer", async (request, h) => { + const token = (request.headers.authorization || "").replace("Bearer ", ""); if (!token) { - throw Boom.unauthorized(null, 'Bearer'); + throw Boom.unauthorized(null, "Bearer"); } return h.authenticated({ credentials: { auth: true }, - artifacts: { token } + artifacts: { token }, }); }); // tests Toys.withRouteDefaults - const defaultToGet = Toys.withRouteDefaults({ method: 'get' }); + const defaultToGet = Toys.withRouteDefaults({ method: "get" }); server.route( defaultToGet([ // this route is depended on by Toys.options tests { - path: '/', - handler: () => 'I was gotten' + path: "/", + handler: () => "I was gotten", }, { - method: 'post', - path: '/', - handler: () => 'I was posted' - } - ]) + method: "post", + path: "/", + handler: () => "I was posted", + }, + ]), ); // tests Toys.pre server.route({ - method: 'get', - path: '/user/{id}', + method: "get", + path: "/user/{id}", options: { pre: Toys.pre([ { @@ -54,28 +54,28 @@ import * as Toys from '@hapipal/toys'; ]), handler: ({ pre }) => ({ ...pre.user, - }) - } + }), + }, }); // tests Toys.ext server.route({ - method: 'get', - path: '/', + method: "get", + path: "/", options: { handler: () => { return { ok: true }; }, ext: { onPostAuth: Toys.ext((request, h) => { - if (!request.headers['special-header']) { + if (!request.headers["special-header"]) { throw Boom.unauthorized(); } return h.continue; - }) - } - } + }), + }, + }, }); // tests Toys[EXT_TYPE] @@ -92,22 +92,22 @@ import * as Toys from '@hapipal/toys'; ]); // tests Toys.reacher - const simpleReacher = Toys.reacher('a.b.c'); + const simpleReacher = Toys.reacher("a.b.c"); const simpleReachedValue: number = simpleReacher({ a: { b: { - c: 1 - } - } + c: 1, + }, + }, }); - const reacherWithOptions = Toys.reacher(['a', 1], { - default: 'default', + const reacherWithOptions = Toys.reacher(["a", 1], { + default: "default", strict: true, }); const reacherWithOptionsValue: string = reacherWithOptions({ a: [ - 'test', + "test", ], }); const reacherWithOptionsDefault: string = reacherWithOptions(); @@ -115,35 +115,35 @@ import * as Toys from '@hapipal/toys'; // tests Toys.transformer // $ExpectType PerformTransform const transformAddress = Toys.transformer({ - street1: 'address.street_one', - street2: 'address.street_two', - city: 'address.city', - state: 'address.state.code', - country: 'address.country.code' + street1: "address.street_one", + street2: "address.street_two", + city: "address.city", + state: "address.state.code", + country: "address.country.code", }); // $ExpectType object transformAddress({ address: { - street_one: 'one', - street_two: 'two', - city: 'city', + street_one: "one", + street_two: "two", + city: "city", state: { - code: 'NY', + code: "NY", }, country: { - code: 'USA', + code: "USA", }, }, }); const emitter = new EventEmitter(); - emitter.emit('test', 'singleValue'); + emitter.emit("test", "singleValue"); // $ExpectType any - await Toys.event(emitter, 'test'); - emitter.emit('test', 'valueOne', 'valueTwo'); + await Toys.event(emitter, "test"); + emitter.emit("test", "valueOne", "valueTwo"); // $ExpectType any - await Toys.event(emitter, 'test', { + await Toys.event(emitter, "test", { multiple: true, error: false, }); @@ -173,22 +173,22 @@ import * as Toys from '@hapipal/toys'; // $ExpectType object Toys.options(server); const response = await server.inject({ - method: 'get', - url: '/', + method: "get", + url: "/", }); // $ExpectType object Toys.options(response.request); // tests Toys.header // $ExpectType void - Toys.header(response.request.response, 'x-my-header', 'has-this-value', { + Toys.header(response.request.response, "x-my-header", "has-this-value", { append: true, - separator: ':', + separator: ":", override: false, duplicate: true, }); // $ExpectType void - Toys.header(response.request.response, 'x-my-other-header', 'has-this-other-value'); + Toys.header(response.request.response, "x-my-other-header", "has-this-other-value"); // tests Toys.getHeaders // $ExpectType { [header: string]: string; } @@ -204,11 +204,11 @@ import * as Toys from '@hapipal/toys'; // tests Toys.state // $ExpectType object - Toys.state(response.request.route.realm, 'my-plugin'); + Toys.state(response.request.route.realm, "my-plugin"); // tests Toys.rootState // $ExpectType object - Toys.rootState(response.request.route.realm, 'my-plugin'); + Toys.rootState(response.request.route.realm, "my-plugin"); // tests Toys.forEachAncestorRealm // $ExpectType void @@ -216,11 +216,11 @@ import * as Toys from '@hapipal/toys'; // tests Toys.asyncStorage const multiplyBy = async (x: number) => { - return x * (Toys.asyncStorage('y') || 0); + return x * (Toys.asyncStorage("y") || 0); }; // $ExpectType number - await Toys.withAsyncStorage('y', 3, async () => { + await Toys.withAsyncStorage("y", 3, async () => { return multiplyBy(4); }); diff --git a/types/hapipal__toys/index.d.ts b/types/hapipal__toys/index.d.ts index c75105edcff112..b11041474a4eea 100644 --- a/types/hapipal__toys/index.d.ts +++ b/types/hapipal__toys/index.d.ts @@ -3,6 +3,7 @@ // Definitions by: Tim Costa // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +import { Boom } from "@hapi/boom"; import { Lifecycle, Plugin, @@ -18,11 +19,10 @@ import { ServerExtOptions, ServerRealm, ServerRoute, -} from '@hapi/hapi'; -import { Boom } from '@hapi/boom'; -import { EventEmitter } from 'events'; -import { Stream, FinishedOptions } from 'stream'; -import { AsyncLocalStorage } from 'async_hooks'; +} from "@hapi/hapi"; +import { AsyncLocalStorage } from "async_hooks"; +import { EventEmitter } from "events"; +import { FinishedOptions, Stream } from "stream"; export function ext(method: Lifecycle.Method, options?: ServerExtOptions): RouteExtObject; export function onRequest(method: Lifecycle.Method, options?: ServerExtOptions): ServerExtEventsObject; @@ -34,13 +34,15 @@ export function onPostHandler(method: Lifecycle.Method, options?: ServerExtOptio export function onPreResponse(method: Lifecycle.Method, options?: ServerExtOptions): ServerExtEventsObject; export function onPostResponse(method: Lifecycle.Method, options?: ServerExtOptions): ServerExtEventsObject; -export type AssignRouteDefaults = (routes: Partial | Array>) => ServerRoute | ServerRoute[]; +export type AssignRouteDefaults = ( + routes: Partial | Array>, +) => ServerRoute | ServerRoute[]; export function withRouteDefaults(defaults: Partial): AssignRouteDefaults; export interface ToysPreShorthand { [assignKey: string]: Lifecycle.Method; } -export type ToysPreArg = (ToysPreShorthand | Lifecycle.Method); +export type ToysPreArg = ToysPreShorthand | Lifecycle.Method; export function pre(options: ToysPreArg | ToysPreArg[]): RouteOptionsPreArray; export interface ReacherOptions { @@ -61,7 +63,12 @@ export function transformer(transform: Transformer, options?: ReacherOptions): P export const noop: Plugin; -export function header(response: ResponseObject | Boom, name: string, value: string, options?: ResponseObjectHeaderOptions): void; +export function header( + response: ResponseObject | Boom, + name: string, + value: string, + options?: ResponseObjectHeaderOptions, +): void; export function getHeaders(response: ResponseObject | Boom): { [header: string]: string }; export function code(response: ResponseObject | Boom, code: number): void; @@ -84,7 +91,7 @@ export interface StreamOptions { } export function stream(stream: Stream, options?: StreamOptions & FinishedOptions): Promise; -export type TypesWithRealmsAndOptions = (Server | Request | ResponseToolkit | ServerRealm | ServerRoute); +export type TypesWithRealmsAndOptions = Server | Request | ResponseToolkit | ServerRealm | ServerRoute; export function options(obj: TypesWithRealmsAndOptions): object; export function realm(obj: TypesWithRealmsAndOptions): object; diff --git a/types/happo-cypress/happo-cypress-tests.ts b/types/happo-cypress/happo-cypress-tests.ts index f5ab349e93dc96..361b9f833efbed 100644 --- a/types/happo-cypress/happo-cypress-tests.ts +++ b/types/happo-cypress/happo-cypress-tests.ts @@ -1,19 +1,19 @@ -import 'happo-cypress'; +import "happo-cypress"; // $ExpectType void -cy.get('foo').happoScreenshot(); +cy.get("foo").happoScreenshot(); // $ExpectType void -cy.get('foo').happoScreenshot({}); +cy.get("foo").happoScreenshot({}); // $ExpectType void -cy.get('foo').happoScreenshot({ - component: 'Header', - variant: 'dark', - targets: ['chrome-desktop'], +cy.get("foo").happoScreenshot({ + component: "Header", + variant: "dark", + targets: ["chrome-desktop"], responsiveInlinedCanvases: true, transformDOM: { - selector: 'iframe', + selector: "iframe", transform: element => element, }, includeAllElements: true, @@ -29,17 +29,17 @@ cy.happoHideDynamicElements({}); cy.happoHideDynamicElements({ matchers: [/liked by [0-9]+ people/], defaultMatchers: [/liked by [0-9]+ people/], - selectors: ['iframe'], - defaultSelectors: ['iframe'], + selectors: ["iframe"], + defaultSelectors: ["iframe"], replace: true, }); // $ExpectType void -cy.get('foo').happoScreenshot({ - component: 'Header', - targets: ['chrome-desktop', { - name: 'dynamic-target', - browser: 'chrome', - viewport: '100x100', +cy.get("foo").happoScreenshot({ + component: "Header", + targets: ["chrome-desktop", { + name: "dynamic-target", + browser: "chrome", + viewport: "100x100", }], }); diff --git a/types/happyguestmx__web-utilities/happyguestmx__web-utilities-tests.ts b/types/happyguestmx__web-utilities/happyguestmx__web-utilities-tests.ts index 93614918a4986b..bb17f66728bc36 100644 --- a/types/happyguestmx__web-utilities/happyguestmx__web-utilities-tests.ts +++ b/types/happyguestmx__web-utilities/happyguestmx__web-utilities-tests.ts @@ -1,4 +1,4 @@ -import { fsp, common } from '@happyguestmx/web-utilities'; +import { common, fsp } from "@happyguestmx/web-utilities"; new fsp.FSP([], [], true, true); common.isEmpty({}); diff --git a/types/happyguestmx__web-utilities/index.d.ts b/types/happyguestmx__web-utilities/index.d.ts index 63fd25bb613182..fee74d22faf6f8 100644 --- a/types/happyguestmx__web-utilities/index.d.ts +++ b/types/happyguestmx__web-utilities/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: HappyGuest // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import { APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda'; +import { APIGatewayProxyEvent, APIGatewayProxyResult } from "aws-lambda"; // shared export interface QueryOutput { Items: any[]; @@ -142,7 +142,7 @@ export interface FspPaginationOutput { export interface FspQuery { queryString: string; orderBy: string; - sortType: 'asc' | 'desc'; + sortType: "asc" | "desc"; size: number; page: number; } @@ -152,7 +152,7 @@ export interface FSP { data: any[]; filterColums: any[]; Filter: (term: string | string[]) => boolean; - Sort: (orderBy: string, sortType: 'asc' | 'desc') => any[]; + Sort: (orderBy: string, sortType: "asc" | "desc") => any[]; Pagin: (page: number, size: number) => FspPaginOutput; FSP: (query: FspQuery) => FspPaginationOutput; } @@ -162,19 +162,19 @@ export interface FSPConstructor { // ddbHelper export type ComparisonOperator = - | 'EQ' - | 'NE' - | 'IN' - | 'LE' - | 'LT' - | 'GE' - | 'GT' - | 'BETWEEN' - | 'NOT_NULL' - | 'NULL' - | 'CONTAINS' - | 'NOT_CONTAINS' - | 'BEGINS_WITH' + | "EQ" + | "NE" + | "IN" + | "LE" + | "LT" + | "GE" + | "GT" + | "BETWEEN" + | "NOT_NULL" + | "NULL" + | "CONTAINS" + | "NOT_CONTAINS" + | "BEGINS_WITH" | string; export interface QueryInput { TableName: string; @@ -195,10 +195,10 @@ export interface QueryInput { ComparisonOperator: ComparisonOperator; }; }; - ConditionalOperator?: 'AND' | 'OR' | string; + ConditionalOperator?: "AND" | "OR" | string; ScanIndexForward?: boolean; ExclusiveStartKey?: { [key: string]: any }; - ReturnConsumedCapacity?: 'INDEXES' | 'TOTAL' | 'NONE' | string; + ReturnConsumedCapacity?: "INDEXES" | "TOTAL" | "NONE" | string; ProjectionExpression?: string; FilterExpression?: string; KeyConditionExpression?: string; @@ -241,7 +241,7 @@ export interface ScanInput { export interface DdbHelper { recursiveQuery: ( params: QueryInput | ScanInput, - method: 'query' | 'scan', + method: "query" | "scan", xray?: boolean, ) => Promise; } @@ -307,5 +307,5 @@ export const paramsHandler: ParamsHandler; export const response: Response; export const fsp: { FSP: FSPConstructor }; export const ddbHelper: DdbHelper; -export class WithDataError extends Error { } +export class WithDataError extends Error {} export const userHandler: UserHandler; diff --git a/types/happypack/happypack-tests.ts b/types/happypack/happypack-tests.ts index 779a8cea3b0b8c..278cf23dad1489 100644 --- a/types/happypack/happypack-tests.ts +++ b/types/happypack/happypack-tests.ts @@ -1,7 +1,7 @@ -import * as happyPack from 'happypack'; +import * as happyPack from "happypack"; const ref: happyPack = new happyPack({ - id: '1', + id: "1", threads: 1, - loaders: ['ts-loader'] + loaders: ["ts-loader"], }); diff --git a/types/happypack/index.d.ts b/types/happypack/index.d.ts index 5abdf62969b27c..9ed7d03eb32bd2 100644 --- a/types/happypack/index.d.ts +++ b/types/happypack/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.7 -import { Plugin } from 'webpack'; +import { Plugin } from "webpack"; export = happypack; diff --git a/types/har-format/index.d.ts b/types/har-format/index.d.ts index 4c40ae23e5798a..4b69bcdf47744a 100644 --- a/types/har-format/index.d.ts +++ b/types/har-format/index.d.ts @@ -234,7 +234,7 @@ export interface Page { /** _non-standard_ */ _score_gzip?: number | null | undefined; /** _non-standard_ */ - '_score_keep-alive'?: number | null | undefined; + "_score_keep-alive"?: number | null | undefined; /** _non-standard_ */ _score_minify?: number | null | undefined; /** _non-standard_ */ @@ -404,7 +404,7 @@ export interface Entry { /** _non-standard_ */ _expires?: string | null | undefined; /** _non-standard_ */ - _fromCache?: 'memory' | 'disk' | null | undefined; + _fromCache?: "memory" | "disk" | null | undefined; /** _non-standard_ */ _full_url?: string | null | undefined; /** _non-standard_ */ @@ -471,29 +471,29 @@ export interface Entry { _request_id?: number | string | null | undefined; /** _non-standard_ */ _resourceType?: - | 'document' - | 'stylesheet' - | 'image' - | 'media' - | 'font' - | 'script' - | 'texttrack' - | 'xhr' - | 'fetch' - | 'prefetch' - | 'eventsource' - | 'websocket' - | 'webtransport' - | 'wasm' - | 'manifest' - | 'signed-exchange' - | 'ping' - | 'csp-violation-report' - | 'other' - | 'preflight' - | 'sm-script' - | 'sm-stylesheet' - | 'webbundle' + | "document" + | "stylesheet" + | "image" + | "media" + | "font" + | "script" + | "texttrack" + | "xhr" + | "fetch" + | "prefetch" + | "eventsource" + | "websocket" + | "webtransport" + | "wasm" + | "manifest" + | "signed-exchange" + | "ping" + | "csp-violation-report" + | "other" + | "preflight" + | "sm-script" + | "sm-stylesheet" + | "webbundle" | null | undefined; /** _non-standard_ */ @@ -513,7 +513,7 @@ export interface Entry { /** _non-standard_ */ _score_gzip?: number | string | null | undefined; /** _non-standard_ */ - '_score_keep-alive'?: number | string | null | undefined; + "_score_keep-alive"?: number | string | null | undefined; /** _non-standard_ */ _score_minify?: number | string | null | undefined; /** _non-standard_ */ @@ -551,11 +551,11 @@ export interface Entry { /** _non-standard_ */ _webSocketMessages?: | Array<{ - type: 'send' | 'receive'; - time: number; - opcode: number; - data: string; - }> + type: "send" | "receive"; + time: number; + opcode: number; + data: string; + }> | null | undefined; /** diff --git a/types/har-format/test/har-format-tests.ts b/types/har-format/test/har-format-tests.ts index e7f44971a535bf..ff550e05adfad2 100644 --- a/types/har-format/test/har-format-tests.ts +++ b/types/har-format/test/har-format-tests.ts @@ -1,8 +1,8 @@ -import * as harFormat from 'har-format'; +import * as harFormat from "har-format"; const testCreator: harFormat.Creator = { - name: 'WebInspector', - version: '537.36', + name: "WebInspector", + version: "537.36", }; const testPageTiming: harFormat.PageTiming = { @@ -11,23 +11,23 @@ const testPageTiming: harFormat.PageTiming = { }; const testPage: harFormat.Page = { - startedDateTime: '2017-02-11T09:36:22.868Z', - id: 'page_1', - title: 'https://github.com/', + startedDateTime: "2017-02-11T09:36:22.868Z", + id: "page_1", + title: "https://github.com/", pageTimings: testPageTiming, // TS >= v4.4 only - _iAmSomeCustomField: 'some value', + _iAmSomeCustomField: "some value", }; const testHeader: harFormat.Header = { - name: 'Accept', - value: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', + name: "Accept", + value: "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", }; const testRequest: harFormat.Request = { - method: 'GET', - url: 'https://github.com/', - httpVersion: 'HTTP/1.1', + method: "GET", + url: "https://github.com/", + httpVersion: "HTTP/1.1", headers: [testHeader], queryString: [], cookies: [], @@ -36,66 +36,66 @@ const testRequest: harFormat.Request = { }; const testHeaders: harFormat.Header = { - name: 'Content-Encoding', - value: 'gzip', + name: "Content-Encoding", + value: "gzip", }; const testCookie: harFormat.Cookie = { - name: 'logged_in', - value: 'no', - path: '/', - domain: '.github.com', - expires: '2037-02-11T09:36:23.000Z', + name: "logged_in", + value: "no", + path: "/", + domain: ".github.com", + expires: "2037-02-11T09:36:23.000Z", httpOnly: true, secure: true, }; const textPostData: harFormat.PostData = { - mimeType: 'text/plain', - text: 'some-text', + mimeType: "text/plain", + text: "some-text", }; const paramsPostData: harFormat.PostData = { - mimeType: 'multipart/form-data', + mimeType: "multipart/form-data", params: [ { - name: 'some-param', - value: 'val', + name: "some-param", + value: "val", }, ], }; // @ts-expect-error const missingPostData: harFormat.PostData = { - mimeType: 'text/plain', + mimeType: "text/plain", }; // @ts-expect-error const tooMuchPostData: harFormat.PostData = { - mimeType: 'multipart/form-data', + mimeType: "multipart/form-data", params: [ { - name: 'some-param', - value: 'val', + name: "some-param", + value: "val", }, ], - text: 'asd', + text: "asd", }; const testContent: harFormat.Content = { size: 26915, - mimeType: 'text/html', + mimeType: "text/html", compression: 18635, }; const testResponse: harFormat.Response = { status: 200, - statusText: 'OK', - httpVersion: 'HTTP/1.1', + statusText: "OK", + httpVersion: "HTTP/1.1", headers: [testHeaders], cookies: [testCookie], content: testContent, - redirectURL: '', + redirectURL: "", headersSize: 2084, bodySize: 8280, _transferSize: 10364, @@ -112,35 +112,35 @@ const testTimings: harFormat.Timings = { }; const testEntry: harFormat.Entry = { - startedDateTime: '2017-02-11T09:36:22.868Z', + startedDateTime: "2017-02-11T09:36:22.868Z", time: 816.8100000002596, request: testRequest, response: testResponse, cache: {}, timings: testTimings, - serverIPAddress: '192.30.253.113', - connection: '26487', - pageref: 'page_1', + serverIPAddress: "192.30.253.113", + connection: "26487", + pageref: "page_1", _gzip_total: null, - _resourceType: 'websocket', + _resourceType: "websocket", _server_rtt: null, _chunks: [{ ts: 1, bytes: 4 }], _webSocketMessages: [ { - type: 'send', + type: "send", time: 12.34, opcode: 1, - data: 'Ping!', + data: "Ping!", }, { - type: 'receive', + type: "receive", time: 56.78, opcode: 1, - data: 'Pong!', + data: "Pong!", }, ], // TS >= v4.4 only - _iAmSomeCustomField: 'some value', + _iAmSomeCustomField: "some value", }; // Examples from http://www.softwareishard.com/blog/har-12-spec/#cache @@ -156,7 +156,7 @@ const testCacheNotCached: harFormat.Cache = { }; const testLog: harFormat.Log = { - version: '1.2', + version: "1.2", creator: testCreator, pages: [testPage], entries: [testEntry], diff --git a/types/hard-source-webpack-plugin/hard-source-webpack-plugin-tests.ts b/types/hard-source-webpack-plugin/hard-source-webpack-plugin-tests.ts index 55c57297e583a4..e065b1709352db 100644 --- a/types/hard-source-webpack-plugin/hard-source-webpack-plugin-tests.ts +++ b/types/hard-source-webpack-plugin/hard-source-webpack-plugin-tests.ts @@ -1,19 +1,19 @@ -import * as HardSourceWebpackPlugin from 'hard-source-webpack-plugin'; -import { ForkOptions, ChildProcess } from 'child_process'; -import * as webpack from 'webpack'; +import { ChildProcess, ForkOptions } from "child_process"; +import * as HardSourceWebpackPlugin from "hard-source-webpack-plugin"; +import * as webpack from "webpack"; new HardSourceWebpackPlugin({ info: { - level: 'debug', - mode: 'test', - } + level: "debug", + mode: "test", + }, }); new HardSourceWebpackPlugin.ExcludeModulePlugin([ { test: /mini-css-extract-plugin[\\/]dist[\\/]loader/ }, { - test: 'mini-css-extract-plugin', - include: '/path/to/vendor' + test: "mini-css-extract-plugin", + include: "/path/to/vendor", }, ]); @@ -25,9 +25,11 @@ new HardSourceWebpackPlugin.SerializerCacachePlugin(); new HardSourceWebpackPlugin.SerializerJsonPlugin(); new HardSourceWebpackPlugin.ParallelModulePlugin({ - fork: ((forkFn: (modulePath: string, args?: ReadonlyArray, options?: ForkOptions) => ChildProcess, - compiler: webpack.Compiler, - webpackBin: string) => { + fork: (( + forkFn: (modulePath: string, args?: ReadonlyArray, options?: ForkOptions) => ChildProcess, + compiler: webpack.Compiler, + webpackBin: string, + ) => { }), numWorkers: () => 3, minModules: 10, diff --git a/types/hard-source-webpack-plugin/index.d.ts b/types/hard-source-webpack-plugin/index.d.ts index bc64d36df8aec0..3cd97e0d61ee8d 100644 --- a/types/hard-source-webpack-plugin/index.d.ts +++ b/types/hard-source-webpack-plugin/index.d.ts @@ -4,8 +4,8 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.7 -import * as webpack from 'webpack'; -import { ForkOptions, ChildProcess } from 'child_process'; +import { ChildProcess, ForkOptions } from "child_process"; +import * as webpack from "webpack"; declare class hard_source_webpack_plugin { constructor(options?: Options); @@ -21,8 +21,8 @@ interface Options { files: string[]; } | undefined; info?: { - mode: 'none' | 'test'; - level: 'debug' | 'log' | 'info' | 'warn' | 'error'; + mode: "none" | "test"; + level: "debug" | "log" | "info" | "warn" | "error"; } | undefined; cachePrune?: { maxAge: number; @@ -32,7 +32,7 @@ interface Options { declare namespace hard_source_webpack_plugin { class ExcludeModulePlugin { - constructor(options: ExcludeModulePlugin.Option | ExcludeModulePlugin.Option[]) + constructor(options: ExcludeModulePlugin.Option | ExcludeModulePlugin.Option[]); apply(compiler: webpack.Compiler): void; } @@ -71,7 +71,7 @@ declare namespace hard_source_webpack_plugin { } class ParallelModulePlugin { - constructor(options: ParallelModulePlugin.Options) + constructor(options: ParallelModulePlugin.Options); apply(compiler: webpack.Compiler): void; } diff --git a/types/hark/hark-tests.ts b/types/hark/hark-tests.ts index 4cb1351040cd78..e9db7e6c4a7009 100644 --- a/types/hark/hark-tests.ts +++ b/types/hark/hark-tests.ts @@ -1,4 +1,4 @@ -import hark = require('hark'); +import hark = require("hark"); navigator.mediaDevices.getUserMedia({ audio: true, video: true }).then( (stream) => { @@ -7,17 +7,17 @@ navigator.mediaDevices.getUserMedia({ audio: true, video: true }).then( interval: 50, history: 10, threshold: -50, - audioContext: new AudioContext() + audioContext: new AudioContext(), }; const h: hark.Harker = hark(stream, option); h.stop(); h.resume(); - h.on('speaking', () => { - console.log('speaking'); + h.on("speaking", () => { + console.log("speaking"); }); - h.on('stopped_speaking', () => { - console.log('stop speaking'); + h.on("stopped_speaking", () => { + console.log("stop speaking"); }); - } + }, ); diff --git a/types/hark/index.d.ts b/types/hark/index.d.ts index 1f8e5046790323..da452565a95d3d 100644 --- a/types/hark/index.d.ts +++ b/types/hark/index.d.ts @@ -28,8 +28,8 @@ declare namespace hark { stop(): void; speakingHistory: number[]; - on(event: 'speaking' | 'stopped_speaking', listener: () => void): void; - on(event: 'volume_change', listener: (currentVolume: number, threshold: number) => void): void; - on(event: 'state_change', listener: (state: AudioContextState) => void): void; + on(event: "speaking" | "stopped_speaking", listener: () => void): void; + on(event: "volume_change", listener: (currentVolume: number, threshold: number) => void): void; + on(event: "state_change", listener: (state: AudioContextState) => void): void; } } diff --git a/types/harmon/harmon-tests.ts b/types/harmon/harmon-tests.ts index 49e4ed6e5e9a14..e22ccb5435a5d0 100644 --- a/types/harmon/harmon-tests.ts +++ b/types/harmon/harmon-tests.ts @@ -1,8 +1,8 @@ -import * as harmonBinary from 'harmon'; +import * as harmonBinary from "harmon"; type Select = harmonBinary.Select; -const select1: Select = { func: () => {}, query: 'query1' }; -const select2: Select = { func: () => {}, query: 'query2' }; +const select1: Select = { func: () => {}, query: "query1" }; +const select2: Select = { func: () => {}, query: "query2" }; const selects = [select1, select2]; harmonBinary(selects, selects, true); diff --git a/types/harmon/index.d.ts b/types/harmon/index.d.ts index b384aa85e7eb94..b5160c37d6a520 100644 --- a/types/harmon/index.d.ts +++ b/types/harmon/index.d.ts @@ -3,7 +3,11 @@ // Definitions by: Eric Danowski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare function harmonBinary(reqSelectors?: harmonBinary.Select[], resSelectors?: harmonBinary.Select[], htmlOnly?: boolean): any; +declare function harmonBinary( + reqSelectors?: harmonBinary.Select[], + resSelectors?: harmonBinary.Select[], + htmlOnly?: boolean, +): any; declare namespace harmonBinary { interface Select { query: string; diff --git a/types/harmony-proxy/harmony-proxy-tests.ts b/types/harmony-proxy/harmony-proxy-tests.ts index 3eb2aed095c3ab..f42540388d5a0a 100644 --- a/types/harmony-proxy/harmony-proxy-tests.ts +++ b/types/harmony-proxy/harmony-proxy-tests.ts @@ -1,5 +1,3 @@ - - import * as Proxy from "harmony-proxy"; interface IKatana { @@ -18,10 +16,10 @@ let handler = { let result = target.apply(thisArg, argArray); console.log(`Finished: ${performance.now()}`); return result; - } + }, }; let katana = new Katana(); -let katanaProxy = new Proxy(katana, handler); +let katanaProxy = new Proxy(katana, handler); katanaProxy.use(); diff --git a/types/harmony-proxy/index.d.ts b/types/harmony-proxy/index.d.ts index 996b0201766424..090398f8ddbc1d 100644 --- a/types/harmony-proxy/index.d.ts +++ b/types/harmony-proxy/index.d.ts @@ -7,25 +7,25 @@ declare namespace harmonyProxy { type PropertyKey = string | number | symbol; interface ProxyHandler { - getPrototypeOf? (target: T): any; - setPrototypeOf? (target: T, v: any): boolean; - isExtensible? (target: T): boolean; - preventExtensions? (target: T): boolean; - getOwnPropertyDescriptor? (target: T, p: PropertyKey): PropertyDescriptor; - has? (target: T, p: PropertyKey): boolean; - get? (target: T, p: PropertyKey, receiver: any): any; - set? (target: T, p: PropertyKey, value: any, receiver: any): boolean; - deleteProperty? (target: T, p: PropertyKey): boolean; - defineProperty? (target: T, p: PropertyKey, attributes: PropertyDescriptor): boolean; - enumerate? (target: T): PropertyKey[]; - ownKeys? (target: T): PropertyKey[]; - apply? (target: T, thisArg: any, argArray?: any): any; - construct? (target: T, thisArg: any, argArray?: any): any; + getPrototypeOf?(target: T): any; + setPrototypeOf?(target: T, v: any): boolean; + isExtensible?(target: T): boolean; + preventExtensions?(target: T): boolean; + getOwnPropertyDescriptor?(target: T, p: PropertyKey): PropertyDescriptor; + has?(target: T, p: PropertyKey): boolean; + get?(target: T, p: PropertyKey, receiver: any): any; + set?(target: T, p: PropertyKey, value: any, receiver: any): boolean; + deleteProperty?(target: T, p: PropertyKey): boolean; + defineProperty?(target: T, p: PropertyKey, attributes: PropertyDescriptor): boolean; + enumerate?(target: T): PropertyKey[]; + ownKeys?(target: T): PropertyKey[]; + apply?(target: T, thisArg: any, argArray?: any): any; + construct?(target: T, thisArg: any, argArray?: any): any; } interface ProxyConstructor { - revocable(target: T, handler: ProxyHandler): { proxy: T; revoke: () => void; }; - new (target: T, handler: ProxyHandler): T + revocable(target: T, handler: ProxyHandler): { proxy: T; revoke: () => void }; + new(target: T, handler: ProxyHandler): T; } } diff --git a/types/has-bigints/has-bigints-tests.ts b/types/has-bigints/has-bigints-tests.ts index 43c9edc058316d..469dd156fbcd3a 100644 --- a/types/has-bigints/has-bigints-tests.ts +++ b/types/has-bigints/has-bigints-tests.ts @@ -1,3 +1,3 @@ -import hasBigInts = require('has-bigints'); +import hasBigInts = require("has-bigints"); hasBigInts(); // $ExpectType boolean diff --git a/types/has-package-exports/conditional.d.ts b/types/has-package-exports/conditional.d.ts index c3089c0f5c6c66..ef5fd972a6d43a 100644 --- a/types/has-package-exports/conditional.d.ts +++ b/types/has-package-exports/conditional.d.ts @@ -1,6 +1,6 @@ // This is necessary to disallow import of `has-package-exports/conditional.js`: // eslint-disable-next-line @definitelytyped/no-declare-current-package -declare module 'has-package-exports/conditional' { +declare module "has-package-exports/conditional" { /** * Whether the current environment supports conditional `exports` in `package.json`. * diff --git a/types/has-package-exports/has-package-exports-tests.ts b/types/has-package-exports/has-package-exports-tests.ts index 46d96562bbd9d2..f6a853835610cc 100644 --- a/types/has-package-exports/has-package-exports-tests.ts +++ b/types/has-package-exports/has-package-exports-tests.ts @@ -1,18 +1,18 @@ -import hasPackageExports = require('has-package-exports'); +import hasPackageExports = require("has-package-exports"); hasPackageExports; // $ExpectType boolean | null -import hasPackageExportsConditional = require('has-package-exports/conditional'); +import hasPackageExportsConditional = require("has-package-exports/conditional"); hasPackageExportsConditional; // $ExpectType boolean | null -import hasPackageExportsPattern = require('has-package-exports/pattern'); +import hasPackageExportsPattern = require("has-package-exports/pattern"); hasPackageExportsPattern; // $ExpectType boolean // These are invalid because of `package.json#exports`: // @ts-expect-error -import hasPackageExportsIllegal1 = require('has-package-exports/index'); +import hasPackageExportsIllegal1 = require("has-package-exports/index"); // @ts-expect-error -import hasPackageExportsIllegal2 = require('has-package-exports/index.js'); +import hasPackageExportsIllegal2 = require("has-package-exports/index.js"); // @ts-expect-error -import hasPackageExportsConditionalIllegal = require('has-package-exports/conditional.js'); +import hasPackageExportsConditionalIllegal = require("has-package-exports/conditional.js"); // @ts-expect-error -import hasPackageExportsPatternIllegal = require('has-package-exports/pattern.js'); +import hasPackageExportsPatternIllegal = require("has-package-exports/pattern.js"); diff --git a/types/has-package-exports/index.d.ts b/types/has-package-exports/index.d.ts index f85e3ea1322329..78ce563013cc3e 100644 --- a/types/has-package-exports/index.d.ts +++ b/types/has-package-exports/index.d.ts @@ -6,7 +6,7 @@ // This is necessary to disallow import of `has-package-exports/index` or `has-package-exports/index.js`: // eslint-disable-next-line @definitelytyped/no-declare-current-package -declare module 'has-package-exports' { +declare module "has-package-exports" { /** * Whether the current environment supports the `exports` field in `package.json`. * diff --git a/types/has-package-exports/pattern.d.ts b/types/has-package-exports/pattern.d.ts index 3e6475fa0ae6d6..9ad7d87ab2f00b 100644 --- a/types/has-package-exports/pattern.d.ts +++ b/types/has-package-exports/pattern.d.ts @@ -1,6 +1,6 @@ // This is necessary to disallow import of `has-package-exports/pattern.js`: // eslint-disable-next-line @definitelytyped/no-declare-current-package -declare module 'has-package-exports/pattern' { +declare module "has-package-exports/pattern" { /** * Whether the current environment supports pattern `exports` in `package.json`. */ diff --git a/types/has-package-self-reference/has-package-self-reference-tests.ts b/types/has-package-self-reference/has-package-self-reference-tests.ts index 5fac7424e4455f..0ecc12c35cb3a5 100644 --- a/types/has-package-self-reference/has-package-self-reference-tests.ts +++ b/types/has-package-self-reference/has-package-self-reference-tests.ts @@ -1,8 +1,8 @@ -import hasPackageSelfReference = require('has-package-self-reference'); +import hasPackageSelfReference = require("has-package-self-reference"); hasPackageSelfReference; // $ExpectType boolean | null // These are invalid because of `package.json#exports`: // @ts-expect-error -import hasPackageSelfReferenceIllegal1 = require('has-package-self-reference/index'); +import hasPackageSelfReferenceIllegal1 = require("has-package-self-reference/index"); // @ts-expect-error -import hasPackageSelfReferenceIllegal2 = require('has-package-self-reference/index.js'); +import hasPackageSelfReferenceIllegal2 = require("has-package-self-reference/index.js"); diff --git a/types/has-package-self-reference/index.d.ts b/types/has-package-self-reference/index.d.ts index e4befe30d439ae..b50886460eb666 100644 --- a/types/has-package-self-reference/index.d.ts +++ b/types/has-package-self-reference/index.d.ts @@ -6,7 +6,7 @@ // This is necessary to disallow import of `has-package-self-reference/index` or `has-package-self-reference/index.js`: // eslint-disable-next-line @definitelytyped/no-declare-current-package -declare module 'has-package-self-reference' { +declare module "has-package-self-reference" { /** * Whether the current environment supports self-reference for packages * with the `exports` field in `package.json`. diff --git a/types/has-symbols/has-symbols-tests.ts b/types/has-symbols/has-symbols-tests.ts index efda60537db565..af5bafb6cd459f 100644 --- a/types/has-symbols/has-symbols-tests.ts +++ b/types/has-symbols/has-symbols-tests.ts @@ -1,5 +1,5 @@ -import hasNativeSymbols = require('has-symbols'); -import hasSymbolSham = require('has-symbols/shams'); +import hasNativeSymbols = require("has-symbols"); +import hasSymbolSham = require("has-symbols/shams"); hasNativeSymbols(); // $ExpectType boolean hasSymbolSham(); // $ExpectType boolean diff --git a/types/has-values/has-values-tests.ts b/types/has-values/has-values-tests.ts index 5d1aa587c98db5..501265b3b354f7 100644 --- a/types/has-values/has-values-tests.ts +++ b/types/has-values/has-values-tests.ts @@ -1,20 +1,20 @@ import has = require("has-values"); function tests() { - has(['a']); // => true + has(["a"]); // => true has([[], []]); // => false has(true); // => true has(false); // => false has(new Error()); // => false - has(new Error('foo')); // => true + has(new Error("foo")); // => true has(new Map()); // => false - has(new Map([['foo', 'bar']])); // true + has(new Map([["foo", "bar"]])); // true has(null); // => true has(new Set()); // => false - has(new Set(['foo', 'bar'])); // => true + has(new Set(["foo", "bar"])); // => true } diff --git a/types/has/has-tests.ts b/types/has/has-tests.ts index d8872727d114cb..add2f065d9dbfb 100644 --- a/types/has/has-tests.ts +++ b/types/has/has-tests.ts @@ -1,19 +1,19 @@ -import hasOwnProperty = require('has'); +import hasOwnProperty = require("has"); // $ExpectType boolean -hasOwnProperty(Object.prototype, 'hasOwnProperty'); -hasOwnProperty({ prop: null }, 'hasOwnProperty'); -hasOwnProperty('foo', 'bar'); -hasOwnProperty(123, '456'); +hasOwnProperty(Object.prototype, "hasOwnProperty"); +hasOwnProperty({ prop: null }, "hasOwnProperty"); +hasOwnProperty("foo", "bar"); +hasOwnProperty(123, "456"); hasOwnProperty(Symbol.iterator, Symbol.toStringTag); declare const arrayLikeOrIterable: ArrayLike | Iterable; -if (hasOwnProperty(arrayLikeOrIterable, 'length')) { +if (hasOwnProperty(arrayLikeOrIterable, "length")) { arrayLikeOrIterable; // $ExpectType ArrayLike } // @ts-expect-error -hasOwnProperty(undefined, ''); +hasOwnProperty(undefined, ""); // @ts-expect-error -hasOwnProperty(null, ''); +hasOwnProperty(null, ""); diff --git a/types/hasbin/hasbin-tests.ts b/types/hasbin/hasbin-tests.ts index fbe412e5349f19..fb908491cca7b8 100644 --- a/types/hasbin/hasbin-tests.ts +++ b/types/hasbin/hasbin-tests.ts @@ -1,16 +1,16 @@ -import hasbin = require('hasbin'); +import hasbin = require("hasbin"); -hasbin('node', (result: boolean) => {}); -hasbin.async('node', (result: boolean) => {}); -hasbin.some(['node', 'ls'], (result: boolean) => {}); -hasbin.all(['node', 'ls'], (result: boolean) => {}); -hasbin.first(['node', 'ls'], (first: string | false) => {}); +hasbin("node", (result: boolean) => {}); +hasbin.async("node", (result: boolean) => {}); +hasbin.some(["node", "ls"], (result: boolean) => {}); +hasbin.all(["node", "ls"], (result: boolean) => {}); +hasbin.first(["node", "ls"], (first: string | false) => {}); -const first = hasbin.first.sync(['node', 'ls']); // $ExpectType string | false +const first = hasbin.first.sync(["node", "ls"]); // $ExpectType string | false if (first !== false) { const file: string = first; } -hasbin.sync('node'); // $ExpectType boolean -hasbin.some.sync(['node', 'ls']); // $ExpectType boolean -hasbin.all.sync(['node', 'ls']); // $ExpectType boolean +hasbin.sync("node"); // $ExpectType boolean +hasbin.some.sync(["node", "ls"]); // $ExpectType boolean +hasbin.all.sync(["node", "ls"]); // $ExpectType boolean diff --git a/types/hash-chain/hash-chain-tests.ts b/types/hash-chain/hash-chain-tests.ts index 0e555db7d12b6c..41c5973ad127e4 100644 --- a/types/hash-chain/hash-chain-tests.ts +++ b/types/hash-chain/hash-chain-tests.ts @@ -1,4 +1,4 @@ -import HashChain = require('hash-chain'); +import HashChain = require("hash-chain"); // test type exports type HC = HashChain; diff --git a/types/hash-file/hash-file-tests.ts b/types/hash-file/hash-file-tests.ts index f269dbb64bd762..4d1c45b7fe6359 100644 --- a/types/hash-file/hash-file-tests.ts +++ b/types/hash-file/hash-file-tests.ts @@ -1,7 +1,7 @@ -import hashFile = require('hash-file'); +import hashFile = require("hash-file"); -hashFile('tsconfig.json') +hashFile("tsconfig.json") .then((hash: string) => { }); -const hash = hashFile.sync('tsconfig.json'); +const hash = hashFile.sync("tsconfig.json"); diff --git a/types/hash-stream/hash-stream-tests.ts b/types/hash-stream/hash-stream-tests.ts index 4ff7bb3fa9ecbd..6cee45e76d7a41 100644 --- a/types/hash-stream/hash-stream-tests.ts +++ b/types/hash-stream/hash-stream-tests.ts @@ -1,15 +1,15 @@ -import getHash = require('hash-stream'); -import { createReadStream } from 'fs'; +import getHash = require("hash-stream"); +import { createReadStream } from "fs"; -getHash('image.png', 'sha256', (err, hash) => { +getHash("image.png", "sha256", (err, hash) => { err; // $ExpectType Error | null hash; // $ExpectType Buffer - const str = hash.toString('hex'); + const str = hash.toString("hex"); }); -getHash('image.png', 'sha256'); // $ExpectType Promise +getHash("image.png", "sha256"); // $ExpectType Promise -getHash(createReadStream('image.png'), 'sha256', (err, hash) => { +getHash(createReadStream("image.png"), "sha256", (err, hash) => { err; // $ExpectType any hash; // $ExpectType Buffer }); -getHash(createReadStream('image.png'), 'sha256'); // $ExpectType Promise +getHash(createReadStream("image.png"), "sha256"); // $ExpectType Promise diff --git a/types/hash-stream/index.d.ts b/types/hash-stream/index.d.ts index 92de86540fcbee..b65530b4fe08ec 100644 --- a/types/hash-stream/index.d.ts +++ b/types/hash-stream/index.d.ts @@ -4,9 +4,17 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -import * as stream from 'stream'; +import * as stream from "stream"; export = hashStream; -declare function hashStream(stream: stream.Readable, algorithm: string, callback?: (error: any, hash: Buffer) => void): Promise; -declare function hashStream(filename: string, algorithm: string, callback?: (error: Error | null, hash: Buffer) => void): Promise; +declare function hashStream( + stream: stream.Readable, + algorithm: string, + callback?: (error: any, hash: Buffer) => void, +): Promise; +declare function hashStream( + filename: string, + algorithm: string, + callback?: (error: Error | null, hash: Buffer) => void, +): Promise; diff --git a/types/hasher/hasher-tests.ts b/types/hasher/hasher-tests.ts index c8f463988fba79..212ae2b71e7037 100644 --- a/types/hasher/hasher-tests.ts +++ b/types/hasher/hasher-tests.ts @@ -1,16 +1,14 @@ - - -//handle hash changes +// handle hash changes function handleChanges(newHash: any, oldHash: any) { console.log(newHash); } -hasher.changed.add(handleChanges); //add hash change listener -hasher.initialized.add(handleChanges); //add initialized listener (to grab initial value in case it is already set) -hasher.init(); //initialize hasher (start listening for history changes) +hasher.changed.add(handleChanges); // add hash change listener +hasher.initialized.add(handleChanges); // add initialized listener (to grab initial value in case it is already set) +hasher.init(); // initialize hasher (start listening for history changes) -hasher.setHash('foo'); //change hash value (generates new history record) +hasher.setHash("foo"); // change hash value (generates new history record) -hasher.appendHash = '?test=true'; +hasher.appendHash = "?test=true"; -hasher.prependHash = '!'; //default value is "/" +hasher.prependHash = "!"; // default value is "/" diff --git a/types/hasher/index.d.ts b/types/hasher/index.d.ts index a52df1dfef9152..d5af3f11f925ec 100644 --- a/types/hasher/index.d.ts +++ b/types/hasher/index.d.ts @@ -6,12 +6,10 @@ /// -import * as signal from 'signals'; +import * as signal from "signals"; declare namespace HasherJs { - export interface HasherStatic { - // {string} hasher.appendHash // String that should always be added to the end of Hash value. appendHash: string; diff --git a/types/hashmap/hashmap-tests.ts b/types/hashmap/hashmap-tests.ts index d1e4b2744b26c6..6710168c4af72c 100644 --- a/types/hashmap/hashmap-tests.ts +++ b/types/hashmap/hashmap-tests.ts @@ -2,8 +2,8 @@ import HashMap = require("hashmap"); const emptyMap: HashMap = new HashMap(); const filledMap: HashMap = new HashMap("bar", 123, "bar2", 234); const filledMap2: HashMap = new HashMap([ - ["bar", 123], - ["bar2", 234], + ["bar", 123], + ["bar2", 234], ]); const copiedMap: HashMap = new HashMap(filledMap); diff --git a/types/hashmap/index.d.ts b/types/hashmap/index.d.ts index fe7efb0c4c88f8..049189a67a302a 100644 --- a/types/hashmap/index.d.ts +++ b/types/hashmap/index.d.ts @@ -21,7 +21,7 @@ declare class HashMap { * * @param keysAndValues key1, value1, key2, value2... */ - constructor(...keysAndValues: Array<(TKey|TValue)>); + constructor(...keysAndValues: Array<(TKey | TValue)>); /** * Return value from hashmap. @@ -46,7 +46,7 @@ declare class HashMap { * @param keysAndValues key1, value1, key2, value2... * @return Self. */ - multi(...keysAndValues: Array): HashMap; + multi(...keysAndValues: Array): HashMap; /** * Copy all key-value pairs from other to this instance. diff --git a/types/hashmap/v1/hashmap-tests.ts b/types/hashmap/v1/hashmap-tests.ts index e4dc5df0c69829..7f8ba7653b592d 100644 --- a/types/hashmap/v1/hashmap-tests.ts +++ b/types/hashmap/v1/hashmap-tests.ts @@ -1,22 +1,22 @@ -var map : HashMap = new HashMap(); +var map: HashMap = new HashMap(); map.set("foo", 123); -var value : number = map.get("foo"); +var value: number = map.get("foo"); map.has("foo"); map.remove("foo"); -var keys : string[] = map.keys(); +var keys: string[] = map.keys(); -var values : number[] = map.values(); +var values: number[] = map.values(); -var count : number = map.count(); +var count: number = map.count(); -map.forEach(function(value : number, key : string) : void { - console.log(key); - console.log(value); +map.forEach(function(value: number, key: string): void { + console.log(key); + console.log(value); }); map.clear(); diff --git a/types/hashmap/v1/index.d.ts b/types/hashmap/v1/index.d.ts index c4da6a9f47f951..793687e870f9a0 100644 --- a/types/hashmap/v1/index.d.ts +++ b/types/hashmap/v1/index.d.ts @@ -10,7 +10,7 @@ declare class HashMap { * @param key Key. * @return Value stored under given key. */ - get(key : KeyType) : ValueType; + get(key: KeyType): ValueType; /** * Store value in hashmap. @@ -18,7 +18,7 @@ declare class HashMap { * @param key Key. * @param value Value. */ - set(key : KeyType, value : ValueType) : void; + set(key: KeyType, value: ValueType): void; /** * Checks if given key exists in hashmap. @@ -26,46 +26,45 @@ declare class HashMap { * @param key Key. * @return Whether given key exists in hashmap. */ - has(key : KeyType) : boolean; + has(key: KeyType): boolean; /** * Removes given key from hashmap. * * @param key Key. */ - remove(key : KeyType) : void; + remove(key: KeyType): void; /** * Returns all contained keys. * * @return List of keys. */ - keys() : KeyType[]; + keys(): KeyType[]; /** * Returns all container values. * * @return List of values. */ - values() : ValueType[]; + values(): ValueType[]; /** * Returns size of hashmap (number of entries). * * @return Number of entries in hashmap. */ - count() : number; + count(): number; /** * Clears hashmap. */ - clear() : void; + clear(): void; /** * Iterates over hashmap. * * @param callback Function to be invoked for every hashmap entry. */ - forEach(callback : (value : ValueType, key : KeyType) => void) : void; + forEach(callback: (value: ValueType, key: KeyType) => void): void; } - diff --git a/types/hashring/hashring-tests.ts b/types/hashring/hashring-tests.ts index cbea3b5eaa605c..038c4875573333 100644 --- a/types/hashring/hashring-tests.ts +++ b/types/hashring/hashring-tests.ts @@ -1,16 +1,20 @@ import * as HashRing from "hashring"; -const ring = new HashRing([ - '127.0.0.1', - '127.0.0.2', - '127.0.0.3', - '127.0.0.4' -], 'md5', { - 'max cache size': 10000 -}); +const ring = new HashRing( + [ + "127.0.0.1", + "127.0.0.2", + "127.0.0.3", + "127.0.0.4", + ], + "md5", + { + "max cache size": 10000, + }, +); -ring.get('foo bar banana'); +ring.get("foo bar banana"); -ring.range('foo bar banana', 2); +ring.range("foo bar banana", 2); -ring.add('127.0.0.7').remove('127.0.0.1'); +ring.add("127.0.0.7").remove("127.0.0.1"); diff --git a/types/hashring/index.d.ts b/types/hashring/index.d.ts index edb6e1c0f2c8fe..b0b879d074aeb9 100644 --- a/types/hashring/index.d.ts +++ b/types/hashring/index.d.ts @@ -7,132 +7,133 @@ /// declare namespace HashRing { - interface HashRingOptions { + interface HashRingOptions { + /** + * The amount of virtual nodes per server, + * defaults to 40 as this generates 160 points per server + * as used by ketama hashing. + */ + "vnode count": number; + + /** + * The default port number which will removed from the server address + * to provide ketama compatibility. + */ + "default port": number; + + /** + * Allows you to force a compatibility mode of the HashRing. + * It default to ketama hash rings but if you are coming from + * a python world you might want compatibility with the hash_ring module. + * + * There's a small diff between + * `hash_ring` and `ketama` and that's the amount of replica's of a server. + * `Ketama` uses 4 and `hash_ring` uses 3. + * + * Set this to `hash_ring` if you want to use 3. + */ + "compatibility": "hash_ring" | "ketama"; + + /** + * The amount of replicas per server. + * Defaults to 4. + */ + "replicas": number; + + /** + * We use a simple LRU cache + * inside the module to speed up frequent key lookups, + * you can customize the amount of keys that need to be cached. + * + * It defaults to 5000. + */ + "max cache size": number; + } + interface ServerConfig { + vnodes: number; + weight: number; + } + type Servers = + | string + | ReadonlyArray + | Record>; +} + +declare class HashRing { + constructor( + servers: HashRing.Servers, + algorithm?: string | ((key: string) => string | Buffer), + options?: Partial, + ); + /** - * The amount of virtual nodes per server, - * defaults to 40 as this generates 160 points per server - * as used by ketama hashing. + * Generates the continuum of server a.k.a as the Hash Ring + * based on their weights and virtual nodes assigned. */ - "vnode count": number; + continuum(): this; /** - * The default port number which will removed from the server address - * to provide ketama compatibility. + * Find the correct node for which the key is closest to the point + * after what the given key hashes to. + * @param key Random key that needs to be searched in the hash ring + * @returns The matching server address */ - "default port": number; + get(key: string): string; /** - * Allows you to force a compatibility mode of the HashRing. - * It default to ketama hash rings but if you are coming from - * a python world you might want compatibility with the hash_ring module. - * - * There's a small diff between - * `hash_ring` and `ketama` and that's the amount of replica's of a server. - * `Ketama` uses 4 and `hash_ring` uses 3. - * - * Set this to `hash_ring` if you want to use 3. + * Returns a range of servers. Could be useful for replication. + * @param key Random key that needs to be searched in the hash ring + * @param size Amount items to be returned (maximum). + * Defaults to the amount of servers that are in the hashring. + * @param unique Don't return duplicate servers. Defaults to true. */ - "compatibility": "hash_ring" | "ketama"; + range(key: string, size?: number, unique?: boolean): string[]; /** - * The amount of replicas per server. - * Defaults to 4. + * Hotswap identical servers with each other. + * This doesn't require the cache to be completely nuked and + * the hash ring distribution to be re-calculated. + * @param from The server that needs to be replaced + * @param to The server that replaces the server */ - "replicas": number; + swap(from: string, to: string): this; /** - * We use a simple LRU cache - * inside the module to speed up frequent key lookups, - * you can customize the amount of keys that need to be cached. - * - * It defaults to 5000. + * Add a new server to ring without having to re-initialize the hashring. + * It accepts the same arguments as you can use in the constructor. + * @param servers Servers that need to be added to the ring. */ - "max cache size": number; - } - interface ServerConfig { - vnodes: number; - weight: number; - } - type Servers = string | - ReadonlyArray | - Record>; -} + add(servers: HashRing.Servers): this; -declare class HashRing { - constructor( - servers: HashRing.Servers, - algorithm?: string | ((key: string) => string | Buffer), - options?: Partial, - ); - - /** - * Generates the continuum of server a.k.a as the Hash Ring - * based on their weights and virtual nodes assigned. - */ - continuum(): this; - - /** - * Find the correct node for which the key is closest to the point - * after what the given key hashes to. - * @param key Random key that needs to be searched in the hash ring - * @returns The matching server address - */ - get(key: string): string; - - /** - * Returns a range of servers. Could be useful for replication. - * @param key Random key that needs to be searched in the hash ring - * @param size Amount items to be returned (maximum). - * Defaults to the amount of servers that are in the hashring. - * @param unique Don't return duplicate servers. Defaults to true. - */ - range(key: string, size?: number, unique?: boolean): string[]; - - /** - * Hotswap identical servers with each other. - * This doesn't require the cache to be completely nuked and - * the hash ring distribution to be re-calculated. - * @param from The server that needs to be replaced - * @param to The server that replaces the server - */ - swap(from: string, to: string): this; - - /** - * Add a new server to ring without having to re-initialize the hashring. - * It accepts the same arguments as you can use in the constructor. - * @param servers Servers that need to be added to the ring. - */ - add(servers: HashRing.Servers): this; - - /** - * Remove a server from the hash ring. - * @param server Server that need to be removed from the ring. - */ - remove(server: HashRing.Servers): this; - - /** - * Checks if a given server exists in the hash ring. - * @param server Server for whose existence we're checking. - * @returns Indication if we have that server. - */ - has(server: string): boolean; - - /** - * Reset the HashRing and clean up it's references. - */ - reset(): this; - - /** - * Resets the HashRing and closes the ring. - */ - end(): this; - - /** - * Returns the points per server. - * @param servers server Optional server to filter down. - * @returns server -> Array(points). - */ - points(servers: HashRing.Servers): Array>; + /** + * Remove a server from the hash ring. + * @param server Server that need to be removed from the ring. + */ + remove(server: HashRing.Servers): this; + + /** + * Checks if a given server exists in the hash ring. + * @param server Server for whose existence we're checking. + * @returns Indication if we have that server. + */ + has(server: string): boolean; + + /** + * Reset the HashRing and clean up it's references. + */ + reset(): this; + + /** + * Resets the HashRing and closes the ring. + */ + end(): this; + + /** + * Returns the points per server. + * @param servers server Optional server to filter down. + * @returns server -> Array(points). + */ + points(servers: HashRing.Servers): Array>; } export = HashRing; diff --git a/types/hashset/hashset-tests.ts b/types/hashset/hashset-tests.ts index 71c2e1eafadcb9..52ec42c17f5f5d 100644 --- a/types/hashset/hashset-tests.ts +++ b/types/hashset/hashset-tests.ts @@ -1,5 +1,3 @@ - - class Point { constructor(public x: number, public y: number) { } diff --git a/types/hashset/index.d.ts b/types/hashset/index.d.ts index 779223d4197353..ebef51d3ac2086 100644 --- a/types/hashset/index.d.ts +++ b/types/hashset/index.d.ts @@ -5,14 +5,14 @@ /// -interface IHashSet -{ +interface IHashSet { add(value: TValue): void; addAll(arr: TValue[]): void; contains(value: TValue): boolean; clear(): void; - isEmpty(): boolean; values(): TValue[]; + isEmpty(): boolean; + values(): TValue[]; remove(value: TValue): void; size(): number; @@ -26,9 +26,12 @@ interface IHashSet } interface IHashSetStatic { - new (): IHashSet; - new (options: IHashtableOptions): IHashSet; - new (hashCode?: (value: TValue) => any, equals?: (value1: TValue, value2: TValue) => boolean): IHashSet; + new(): IHashSet; + new(options: IHashtableOptions): IHashSet; + new( + hashCode?: (value: TValue) => any, + equals?: (value1: TValue, value2: TValue) => boolean, + ): IHashSet; } declare var HashSet: IHashSetStatic; diff --git a/types/hashtable/hashtable-tests.ts b/types/hashtable/hashtable-tests.ts index e7eb12c3241d89..d94c84229e9c64 100644 --- a/types/hashtable/hashtable-tests.ts +++ b/types/hashtable/hashtable-tests.ts @@ -1,5 +1,3 @@ - - class Point { constructor(public x: number, public y: number) { } diff --git a/types/hashtable/index.d.ts b/types/hashtable/index.d.ts index 7bbc4cdb834477..5bde1367c81fb4 100644 --- a/types/hashtable/index.d.ts +++ b/types/hashtable/index.d.ts @@ -3,10 +3,12 @@ // Definitions by: Sergey Gerasimov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -interface IHashtable -{ +interface IHashtable { put(key: TKey, value: TValue): TValue; - putAll(hashtable: IHashtable, conflictCallback?: (key: TKey, thisValue: TValue, value: TValue) => TValue): void; + putAll( + hashtable: IHashtable, + conflictCallback?: (key: TKey, thisValue: TValue, value: TValue) => TValue, + ): void; get(key: TKey): TValue; containsKey(key: TKey): boolean; @@ -36,9 +38,12 @@ interface IHashtableOptions { } interface IHashtableStatic { - new (): IHashtable; - new (options: IHashtableOptions): IHashtable; - new (hashCode?: (value: TValue) => any, equals?: (value1: TValue, value2: TValue) => boolean): IHashtable; + new(): IHashtable; + new(options: IHashtableOptions): IHashtable; + new( + hashCode?: (value: TValue) => any, + equals?: (value1: TValue, value2: TValue) => boolean, + ): IHashtable; } declare var Hashtable: IHashtableStatic; diff --git a/types/hast/hast-tests.ts b/types/hast/hast-tests.ts index 77bdcfa968db68..2af4b016397792 100644 --- a/types/hast/hast-tests.ts +++ b/types/hast/hast-tests.ts @@ -1,4 +1,4 @@ -import { Comment, Data, Doctype, Element, Literal, Node, Parent, Properties, Root, Text } from 'hast'; +import { Comment, Data, Doctype, Element, Literal, Node, Parent, Properties, Root, Text } from "hast"; const data: Data = {}; @@ -8,52 +8,52 @@ const position = { }; const literal: Literal = { - type: 'whatever', - value: 'value', + type: "whatever", + value: "value", position, data, }; const comment: Comment = { - type: 'comment', - value: 'value', + type: "comment", + value: "value", position, data, }; const text: Text = { - type: 'text', - value: 'value', + type: "text", + value: "value", position, data, }; const doctype: Doctype = { - type: 'doctype', + type: "doctype", position, data, }; const properties: Properties = { - propertyName1: 'propertyValue1', - propertyName2: ['propertyValue2', 'propertyValue3'], + propertyName1: "propertyValue1", + propertyName2: ["propertyValue2", "propertyValue3"], propertyName3: true, propertyName4: 47, - propertyName5: [4, '4'], + propertyName5: [4, "4"], propertyName6: null, propertyName7: undefined, }; const element: Element = { - type: 'element', - tagName: 'x', + type: "element", + tagName: "x", properties, - children: [{ type: 'element', tagName: 'y', properties: {}, children: [] }, comment, text], + children: [{ type: "element", tagName: "y", properties: {}, children: [] }, comment, text], }; const elementWithWrongChild: Element = { - type: 'element', - name: 'z', + type: "element", + name: "z", attributes: {}, children: [ // @ts-expect-error: doctypes are not valid in elements. @@ -62,14 +62,14 @@ const elementWithWrongChild: Element = { }; const parent: Parent = { - type: 'whatever', + type: "whatever", data, position, children: [element, doctype, comment, text], }; const root: Root = { - type: 'root', + type: "root", data, position, children: [element, doctype, comment, text], @@ -77,10 +77,10 @@ const root: Root = { // Test custom hast node registration. interface Custom extends Node { - type: 'custom'; + type: "custom"; } -declare module 'hast' { +declare module "hast" { interface RootContentMap { custom: Custom; } @@ -91,44 +91,44 @@ declare module 'hast' { } const rootOther: Root = { - type: 'root', + type: "root", data, position, - children: [{ type: 'custom' }], + children: [{ type: "custom" }], }; const elementOther: Element = { - type: 'element', - tagName: 'foo', - properties: { key: 'value' }, + type: "element", + tagName: "foo", + properties: { key: "value" }, data, position, - children: [{ type: 'custom' }], + children: [{ type: "custom" }], }; const rootAnother: Root = { - type: 'root', + type: "root", data, position, children: [ // @ts-expect-error: node not registered in `RootContentMap`. - { type: 'invalid' }, + { type: "invalid" }, ], }; const elementAnother: Element = { - type: 'element', - name: 'foo', + type: "element", + name: "foo", data, position, children: [ // @ts-expect-error: node not registered in `ElementContentMap`. - { type: 'invalid' }, + { type: "invalid" }, ], }; // Register a field on `Data`, which will be available on all nodes. -declare module 'hast' { +declare module "hast" { interface Data { someField?: string | undefined; } @@ -139,30 +139,30 @@ declare module 'hast' { } const textWithData: Text = { - type: 'text', - value: 'value', + type: "text", + value: "value", data: { - someField: 'a', + someField: "a", // @ts-expect-error: registered on comments, not on texts. someOtherField: 1, }, }; const textWithOtherData: Text = { - type: 'text', - value: 'value', + type: "text", + value: "value", data: { - someField: 'a', + someField: "a", // @ts-expect-error: not registered. someUnknownField: true, }, }; const commentWithData: Comment = { - type: 'comment', - value: 'value', + type: "comment", + value: "value", data: { - someField: 'a', + someField: "a", someOtherField: 1, // @ts-expect-error: not registered. someUnknownField: true, diff --git a/types/hast/index.d.ts b/types/hast/index.d.ts index e250a301765d07..b6beeb0fc892ca 100644 --- a/types/hast/index.d.ts +++ b/types/hast/index.d.ts @@ -6,7 +6,7 @@ // Remco Haszing // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import type { Data as UnistData, Literal as UnistLiteral, Node as UnistNode, Parent as UnistParent } from 'unist'; +import type { Data as UnistData, Literal as UnistLiteral, Node as UnistNode, Parent as UnistParent } from "unist"; // ## Interfaces @@ -176,7 +176,7 @@ export interface Comment extends Literal { /** * Node type of HTML comments in hast. */ - type: 'comment'; + type: "comment"; /** * Data associated with the comment. */ @@ -195,7 +195,7 @@ export interface Doctype extends UnistNode { /** * Node type of HTML document types in hast. */ - type: 'doctype'; + type: "doctype"; /** * Data associated with the doctype. */ @@ -214,7 +214,7 @@ export interface Element extends Parent { /** * Node type of elements. */ - type: 'element'; + type: "element"; /** * Tag name (such as `'body'`) of the element. */ @@ -254,7 +254,7 @@ export interface Root extends Parent { /** * Node type of hast root. */ - type: 'root'; + type: "root"; /** * Children of root. */ @@ -277,7 +277,7 @@ export interface Text extends Literal { /** * Node type of HTML character data (plain text) in hast. */ - type: 'text'; + type: "text"; /** * Data associated with the text. */ diff --git a/types/hast/v2/hast-tests.ts b/types/hast/v2/hast-tests.ts index 07343d0e1df716..0734a4772823c6 100644 --- a/types/hast/v2/hast-tests.ts +++ b/types/hast/v2/hast-tests.ts @@ -1,16 +1,16 @@ -import { Data, Point, Position } from 'unist'; -import { Parent, Properties, Literal, Root, Element, DocType, Comment, Text } from 'hast'; +import { Comment, DocType, Element, Literal, Parent, Properties, Root, Text } from "hast"; +import { Data, Point, Position } from "unist"; // Augmentations -declare module 'hast' { +declare module "hast" { interface RootContentMap { raw: Raw; } } interface Raw extends Literal { - type: 'raw'; + type: "raw"; } // Tests @@ -18,10 +18,10 @@ interface Raw extends Literal { declare var raw: Raw; const data: Data = { - string: 'string', + string: "string", number: 1, object: { - key: 'value', + key: "value", }, array: [], boolean: true, @@ -41,61 +41,61 @@ const position: Position = { }; const literal: Literal = { - type: 'text', + type: "text", data, position, - value: 'value', + value: "value", }; const comment: Comment = { - type: 'comment', + type: "comment", data, position, - value: 'value', + value: "value", }; const text: Text = { - type: 'text', + type: "text", data, position, - value: 'value', + value: "value", }; const docType: DocType = { - type: 'doctype', - name: 'name', + type: "doctype", + name: "name", }; const element: Element = getElement(); const parent: Parent = { - type: 'parent', + type: "parent", data, position, children: [getElement(), docType, comment, text], }; const root: Root = { - type: 'root', + type: "root", data, position, children: [getElement(), docType, comment, text, raw], }; const properties: Properties = { - propertyName1: 'propertyValue1', - propertyName2: ['propertyValue2', 'propertyValue3'], + propertyName1: "propertyValue1", + propertyName2: ["propertyValue2", "propertyValue3"], propertyName3: true, propertyName4: 47, - propertyName5: [4, '4'], + propertyName5: [4, "4"], propertyName6: null, propertyName7: undefined, }; function getElement(): Element { return { - type: 'element', - tagName: 'tagName', + type: "element", + tagName: "tagName", properties, content: root, children: [element, comment, text], diff --git a/types/hast/v2/index.d.ts b/types/hast/v2/index.d.ts index 71c4ee4c671c41..da40ec41646657 100644 --- a/types/hast/v2/index.d.ts +++ b/types/hast/v2/index.d.ts @@ -6,7 +6,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.0 -import { Parent as UnistParent, Literal as UnistLiteral, Node as UnistNode } from 'unist'; +import { Literal as UnistLiteral, Node as UnistNode, Parent as UnistParent } from "unist"; export { UnistNode as Node }; @@ -84,7 +84,7 @@ export interface Root extends Parent { /** * Represents this variant of a Node. */ - type: 'root'; + type: "root"; /** * List representing the children of a node. @@ -99,7 +99,7 @@ export interface Element extends Parent { /** * Represents this variant of a Node. */ - type: 'element'; + type: "element"; /** * Represents the element’s local name. @@ -136,7 +136,7 @@ export interface DocType extends UnistNode { /** * Represents this variant of a Node. */ - type: 'doctype'; + type: "doctype"; name: string; } @@ -148,7 +148,7 @@ export interface Comment extends Literal { /** * Represents this variant of a Literal. */ - type: 'comment'; + type: "comment"; } /** @@ -158,5 +158,5 @@ export interface Text extends Literal { /** * Represents this variant of a Literal. */ - type: 'text'; + type: "text"; } diff --git a/types/hasura/hasura-tests.ts b/types/hasura/hasura-tests.ts index 495da05f8c2680..51f548ddab2cea 100644 --- a/types/hasura/hasura-tests.ts +++ b/types/hasura/hasura-tests.ts @@ -25,14 +25,14 @@ const profileInput: hasura.HasuraInsertInput = { name: "foo", addresses: { data: [{ - street: "N/A" - }] - } + street: "N/A", + }], + }, }], on_conflict: { constraint: "profile_pkey", - update_columns: ["id"] - } + update_columns: ["id"], + }, }; const profileWhere: hasura.WhereBoolExp = { @@ -41,11 +41,11 @@ const profileWhere: hasura.WhereBoolExp = { }, _and: [{ quantity: { _eq: 10 }, - jsonColumn: {_eq: "{}"}, + jsonColumn: { _eq: "{}" }, addresses: { - city: {_eq: ""} - } - }] + city: { _eq: "" }, + }, + }], }; type ProfileOrderBy = hasura.OrderBy; @@ -54,28 +54,28 @@ type ProfileOrderByAggregate = hasura.OrderByAggregate; const profileOrderBy: ProfileOrderBy = { id: "desc", phone: { - code: "asc" + code: "asc", }, addresses: { - street: "desc" + street: "desc", }, addresses_agregate: { max: { - street: "asc" - } + street: "asc", + }, }, jsonColumn: "desc", - jsonbColumn: "asc" + jsonbColumn: "asc", }; const profileOrderByAgg: ProfileOrderByAggregate = { ...profileOrderBy, max: { - quantity: "asc" + quantity: "asc", }, avg: { - quantity: "desc" - } + quantity: "desc", + }, }; type ProfileQueryResponse = hasura.HasuraQueryResponse<"profiles", Partial>; @@ -86,10 +86,10 @@ const profileQueryResp: ProfileQueryResponse = { quantity: 10, addresses: [{ street: "N/A", - city: "New York" - }] - }] - } + city: "New York", + }], + }], + }, }; const profileInsertInput: hasura.HasuraInsertInput = { @@ -97,28 +97,28 @@ const profileInsertInput: hasura.HasuraInsertInput = { quantity: 0, addresses: { data: [{ - street: "" + street: "", }], on_conflict: { constraint: "", - update_columns: ["street"] - } - } - }] + update_columns: ["street"], + }, + }, + }], }; const profileUpdateInput: hasura.HasuraUpdateInput = { _set: { - name: "foo" + name: "foo", }, _inc: { - quantity: 10 + quantity: 10, }, where: { quantity: { - _gt: 10 - } - } + _gt: 10, + }, + }, }; type ProfileAggregateResponse = hasura.HasuraAggregateQueryResponse<"profiles_aggregate", Partial>; @@ -127,26 +127,26 @@ const profileAggregateResp: ProfileAggregateResponse = { profiles_aggregate: { aggregate: { min: { - quantity: 10 + quantity: 10, }, max: { - name: "" + name: "", }, sum: { - quantity: 10 + quantity: 10, }, avg: { - quantity: 0.1 - } + quantity: 0.1, + }, }, nodes: [{ name: "test", quantity: 10, addresses: [{ street: "N/A", - city: "New York" - }] - }] - } - } + city: "New York", + }], + }], + }, + }, }; diff --git a/types/hasura/index.d.ts b/types/hasura/index.d.ts index 907e0d0a3ef937..39c7adc06adbf0 100644 --- a/types/hasura/index.d.ts +++ b/types/hasura/index.d.ts @@ -3,11 +3,11 @@ // Definitions by: Toan Nguyen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export const XHasuraAdminSecret = 'x-hasura-admin-secret'; -export const XHasuraClientName = 'hasura-client-name'; -export const XHasuraRole = 'x-hasura-role'; -export const XHasuraUserID = 'x-hasura-user-id'; -export const HASURA_ROLE_ADMIN = 'admin'; +export const XHasuraAdminSecret = "x-hasura-admin-secret"; +export const XHasuraClientName = "hasura-client-name"; +export const XHasuraRole = "x-hasura-role"; +export const XHasuraUserID = "x-hasura-user-id"; +export const HASURA_ROLE_ADMIN = "admin"; export interface ColumnBoolExp { _eq?: T | undefined; @@ -42,136 +42,161 @@ type Equals = (() => T extends X ? 1 : 2) extends () => T extends Y type ScalarType = string | number | boolean | ScalarJSON | ScalarJSONB; type ObjectType = Record | Array>>; export type ScalarJSON = T & { - __type?: 'json' | undefined; + __type?: "json" | undefined; }; export type ScalarJSONB = T & { - __type?: 'jsonb' | undefined; + __type?: "jsonb" | undefined; }; -export type ScalarUUID = string & { __type?: 'uuid' | undefined }; -export type WhereBoolExp> = { - [key in keyof T]?: T[key] extends string - ? TextColumnBoolExp - : Equals> extends true - ? JSONColumnBoolExp - : Equals> extends true - ? JSONBColumnBoolExp - : T[key] extends ObjectType - ? WhereBoolExp - : T[key] extends ObjectType[] - ? WhereBoolExp - : ColumnBoolExp; -} & { - _and?: Array> | undefined; - _or?: Array> | undefined; - _not?: Array> | undefined; -}; -type ScalarOrderBy = 'asc' | 'desc' | 'asc_nulls_first' | 'asc_nulls_last' | 'desc_nulls_first' | 'desc_nulls_last'; +export type ScalarUUID = string & { __type?: "uuid" | undefined }; +export type WhereBoolExp> = + & { + [key in keyof T]?: T[key] extends string ? TextColumnBoolExp + : Equals> extends true ? JSONColumnBoolExp + : Equals> extends true ? JSONBColumnBoolExp + : T[key] extends ObjectType ? WhereBoolExp + : T[key] extends ObjectType[] ? WhereBoolExp + : ColumnBoolExp; + } + & { + _and?: Array> | undefined; + _or?: Array> | undefined; + _not?: Array> | undefined; + }; +type ScalarOrderBy = "asc" | "desc" | "asc_nulls_first" | "asc_nulls_last" | "desc_nulls_first" | "desc_nulls_last"; type NumberScalarKeys = { [key in keyof T]: T[key] extends number ? key : never; }[keyof T]; type ScalaKeys = { - [key in keyof T]: Equals> extends true - ? key - : Equals> extends true - ? key - : T[key] extends number | string | boolean - ? key + [key in keyof T]: Equals> extends true ? key + : Equals> extends true ? key + : T[key] extends number | string | boolean ? key : never; }[keyof T]; type MinMaxAggregateKeys = { - [key in keyof T]: Equals extends true - ? never - : T[key] extends number | string | boolean - ? key + [key in keyof T]: Equals extends true ? never + : T[key] extends number | string | boolean ? key : never; }[keyof T]; -export type OrderBy> = { - [key in keyof T]?: Equals> extends true - ? ScalarOrderBy - : Equals> extends true - ? ScalarOrderBy - : T[key] extends ObjectType - ? OrderBy - : T[key] extends ObjectType[] - ? OrderBy - : ScalarOrderBy; -} & { - [key: string]: any; -}; +export type OrderBy> = + & { + [key in keyof T]?: Equals> extends true ? ScalarOrderBy + : Equals> extends true ? ScalarOrderBy + : T[key] extends ObjectType ? OrderBy + : T[key] extends ObjectType[] ? OrderBy + : ScalarOrderBy; + } + & { + [key: string]: any; + }; interface BaseOrderByAggregate { count?: ScalarOrderBy | undefined; - max?: MinMaxAggregateKeys extends never - ? never - : { - [key in MinMaxAggregateKeys]?: ScalarOrderBy; - } | undefined; - min?: { - [key in MinMaxAggregateKeys]?: ScalarOrderBy; - } | undefined; + max?: MinMaxAggregateKeys extends never ? never + : + | { + [key in MinMaxAggregateKeys]?: ScalarOrderBy; + } + | undefined; + min?: + | { + [key in MinMaxAggregateKeys]?: ScalarOrderBy; + } + | undefined; } interface NumberOrderByAggregate { - avg?: { - [key in Keys]?: ScalarOrderBy; - } | undefined; - sum?: { - [key in Keys]?: ScalarOrderBy; - } | undefined; - stddev?: { - [key in Keys]?: ScalarOrderBy; - } | undefined; - stddev_pop?: { - [key in Keys]?: ScalarOrderBy; - } | undefined; - stddev_samp?: { - [key in Keys]?: ScalarOrderBy; - } | undefined; - var_pop?: { - [key in Keys]?: ScalarOrderBy; - } | undefined; - variance?: { - [key in Keys]?: ScalarOrderBy; - } | undefined; + avg?: + | { + [key in Keys]?: ScalarOrderBy; + } + | undefined; + sum?: + | { + [key in Keys]?: ScalarOrderBy; + } + | undefined; + stddev?: + | { + [key in Keys]?: ScalarOrderBy; + } + | undefined; + stddev_pop?: + | { + [key in Keys]?: ScalarOrderBy; + } + | undefined; + stddev_samp?: + | { + [key in Keys]?: ScalarOrderBy; + } + | undefined; + var_pop?: + | { + [key in Keys]?: ScalarOrderBy; + } + | undefined; + variance?: + | { + [key in Keys]?: ScalarOrderBy; + } + | undefined; } -export type OrderByAggregate> = (NumberScalarKeys extends never - ? BaseOrderByAggregate - : BaseOrderByAggregate & NumberOrderByAggregate>) & - OrderBy; +export type OrderByAggregate> = + & (NumberScalarKeys extends never ? BaseOrderByAggregate + : BaseOrderByAggregate & NumberOrderByAggregate>) + & OrderBy; export type Aggregate = T & { __aggregate?: never | undefined; }; interface BaseAggregateResult { count?: number | undefined; - max?: { - [key in MinMaxAggregateKeys]?: T[key]; - } | undefined; - min?: { - [key in MinMaxAggregateKeys]?: T[key]; - } | undefined; + max?: + | { + [key in MinMaxAggregateKeys]?: T[key]; + } + | undefined; + min?: + | { + [key in MinMaxAggregateKeys]?: T[key]; + } + | undefined; } interface NumberAggregateResult extends BaseAggregateResult { - avg?: { - [key in Keys]?: number; - } | undefined; - sum?: { - [key in Keys]?: number; - } | undefined; - stddev?: { - [key in Keys]?: number; - } | undefined; - stddev_pop?: { - [key in Keys]?: number; - } | undefined; - stddev_samp?: { - [key in Keys]?: number; - } | undefined; - var_pop?: { - [key in Keys]?: number; - } | undefined; - variance?: { - [key in Keys]?: number; - } | undefined; + avg?: + | { + [key in Keys]?: number; + } + | undefined; + sum?: + | { + [key in Keys]?: number; + } + | undefined; + stddev?: + | { + [key in Keys]?: number; + } + | undefined; + stddev_pop?: + | { + [key in Keys]?: number; + } + | undefined; + stddev_samp?: + | { + [key in Keys]?: number; + } + | undefined; + var_pop?: + | { + [key in Keys]?: number; + } + | undefined; + variance?: + | { + [key in Keys]?: number; + } + | undefined; } export type HasuraDataItem> = T & { @@ -185,8 +210,7 @@ export interface HasuraQueryResponse = NumberScalarKeys extends never - ? BaseAggregateResult +type AggregateResult = NumberScalarKeys extends never ? BaseAggregateResult : NumberAggregateResult>; export interface HasuraAggregateResult> { @@ -200,23 +224,18 @@ export interface HasuraAggregateQueryResponse> { data: { - [key in keyof T]: Equals> extends true - ? HasuraAggregateResult + [key in keyof T]: Equals> extends true ? HasuraAggregateResult : Array; }; } type HasuraInsertInputObject> = { - [key in keyof T]?: Equals> extends true - ? T[key] - : Equals> extends true - ? T[key] - : T[key] extends ObjectType - ? HasuraInsertInputSingle - : T[key] extends ObjectType[] - ? HasuraInsertInput + [key in keyof T]?: Equals> extends true ? T[key] + : Equals> extends true ? T[key] + : T[key] extends ObjectType ? HasuraInsertInputSingle + : T[key] extends ObjectType[] ? HasuraInsertInput : T[key]; }; -export type HasuraInsertOnConflict, OC extends string = 'on_conflict'> = { +export type HasuraInsertOnConflict, OC extends string = "on_conflict"> = { [oc in OC]?: { constraint: string; update_columns: Array; @@ -225,39 +244,42 @@ export type HasuraInsertOnConflict, OC extends str }; export type HasuraInsertInputSingle< T extends Record, - OKey extends string = 'objects', - OC extends string = 'on_conflict' -> = { - [ok in OKey]: HasuraInsertInputObject; -} & - HasuraInsertOnConflict; + OKey extends string = "objects", + OC extends string = "on_conflict", +> = + & { + [ok in OKey]: HasuraInsertInputObject; + } + & HasuraInsertOnConflict; export type HasuraInsertInput< T extends Record, - OKey extends string = 'objects', - ConflictKey extends string = 'on_conflict' -> = { - [ok in OKey]: Array>; -} & - HasuraInsertOnConflict; + OKey extends string = "objects", + ConflictKey extends string = "on_conflict", +> = + & { + [ok in OKey]: Array>; + } + & HasuraInsertOnConflict; export type HasuraUpdateInput< T extends Record, - WhereKey extends string = 'where', - SKey extends string = '_set', - IncKey extends string = '_inc' -> = { - [ok in WhereKey]: WhereBoolExp; -} & - { + WhereKey extends string = "where", + SKey extends string = "_set", + IncKey extends string = "_inc", +> = + & { + [ok in WhereKey]: WhereBoolExp; + } + & { [key in SKey]: { [k in ScalaKeys]?: T[k]; }; - } & - { + } + & { [key in IncKey]?: { [k in NumberScalarKeys]: T[k]; }; }; -export type HasuraDeleteInput, WhereKey extends string = 'where'> = { +export type HasuraDeleteInput, WhereKey extends string = "where"> = { [ok in WhereKey]: WhereBoolExp; }; export interface HasuraMutationResponse = never> { diff --git a/types/hat/hat-tests.ts b/types/hat/hat-tests.ts index 1ca7aa6415106b..fcbd47dc7e5182 100644 --- a/types/hat/hat-tests.ts +++ b/types/hat/hat-tests.ts @@ -1,11 +1,11 @@ -import hat = require('hat'); +import hat = require("hat"); const randomId = hat(); const rack = hat.rack(); rack(); -rack('car'); -const tractorId = rack('tractor'); +rack("car"); +const tractorId = rack("tractor"); rack.get(tractorId); -rack.set(randomId, 'bicycle'); +rack.set(randomId, "bicycle"); rack.hats; diff --git a/types/haversine/haversine-tests.ts b/types/haversine/haversine-tests.ts index 6dec8826acc75c..70ef844ce04c15 100644 --- a/types/haversine/haversine-tests.ts +++ b/types/haversine/haversine-tests.ts @@ -1,9 +1,9 @@ -import haversine = require('haversine'); -import { Feature, Point } from 'geojson'; +import haversine = require("haversine"); +import { Feature, Point } from "geojson"; const start: haversine.CoordinateLongitudeLatitude = { - longitude: 48.1548256, - latitude: 11.4017529 + longitude: 48.1548256, + latitude: 11.4017529, }; const end = { @@ -12,35 +12,35 @@ const end = { }; const options: haversine.Options = { - unit: 'km', - threshold: 1 + unit: "km", + threshold: 1, }; -haversine(start, end, options); // $ExpectType number -haversine(start, end, { unit: 'km', threshold: 1 }); // $ExpectType boolean +haversine(start, end, options); // $ExpectType number +haversine(start, end, { unit: "km", threshold: 1 }); // $ExpectType boolean // @ts-expect-error -haversine(start, end, {format: '[lat,lon]'}); +haversine(start, end, { format: "[lat,lon]" }); // @ts-expect-error -haversine(start, end, {format: '[lon,lat]'}); +haversine(start, end, { format: "[lon,lat]" }); // @ts-expect-error -haversine(start, end, {format: '{lat,lng}'}); +haversine(start, end, { format: "{lat,lng}" }); const startShort: haversine.CoordinateLonLat = { - lon: 48.1548256, - lat: 11.4017529 + lon: 48.1548256, + lat: 11.4017529, }; const endShort: haversine.CoordinateLonLat = { - lon: 52.5065133, - lat: 13.1445551 + lon: 52.5065133, + lat: 13.1445551, }; // @ts-expect-error haversine(startShort, endShort); -haversine(startShort, endShort, { format: '{lon,lat}' }); // $ExpectType number -haversine(startShort, endShort, { format: '{lon,lat}', threshold: 1 }); // $ExpectType boolean +haversine(startShort, endShort, { format: "{lon,lat}" }); // $ExpectType number +haversine(startShort, endShort, { format: "{lon,lat}", threshold: 1 }); // $ExpectType boolean const startLatLng = { lat: 11.4017529, @@ -53,51 +53,51 @@ const endLatLng = { }; const optionsLatLng: haversine.Options = { - format: '{lat,lng}', + format: "{lat,lng}", }; -haversine(startLatLng, endLatLng, optionsLatLng); // $ExpectType number +haversine(startLatLng, endLatLng, optionsLatLng); // $ExpectType number // not actually valid, but the type of optionsLatLng.format is widened to string -haversine(start, end, optionsLatLng); // $ExpectType number +haversine(start, end, optionsLatLng); // $ExpectType number // @ts-expect-error -haversine(start, end, { format: '{lat,lng}' }); +haversine(start, end, { format: "{lat,lng}" }); const startLatLon: haversine.LatLonTuple = [11.4017529, 48.1548256]; const endLatLon: haversine.LatLonTuple = [13.1445551, 52.5065133]; const optionsLatLon: haversine.Options = { - format: '[lat,lon]', + format: "[lat,lon]", }; haversine(startLatLon, endLatLon, optionsLatLon); const startGeoJSON = { - type: 'Feature', + type: "Feature", geometry: { - type: 'Point', + type: "Point", coordinates: startLatLon, }, }; // Ensure that types/haversine is compatible with types/geojson. const endGeoJSON: Feature = { - type: 'Feature', + type: "Feature", geometry: { - type: 'Point', + type: "Point", coordinates: endLatLon, }, properties: {}, }; const optionsGeoJSON: haversine.Options = { - format: 'geojson', + format: "geojson", }; -haversine(startGeoJSON, endGeoJSON, optionsGeoJSON); // $ExpectType number -haversine(startGeoJSON, endGeoJSON, { format: 'geojson', unit: 'nmi'}); // $ExpectType number -haversine(startGeoJSON, endGeoJSON, { format: 'geojson', unit: 'nmi', threshold: 2}); // $ExpectType boolean +haversine(startGeoJSON, endGeoJSON, optionsGeoJSON); // $ExpectType number +haversine(startGeoJSON, endGeoJSON, { format: "geojson", unit: "nmi" }); // $ExpectType number +haversine(startGeoJSON, endGeoJSON, { format: "geojson", unit: "nmi", threshold: 2 }); // $ExpectType boolean // @ts-expect-error -haversine(start, end, { format: 'geojson' }); +haversine(start, end, { format: "geojson" }); diff --git a/types/haversine/index.d.ts b/types/haversine/index.d.ts index ca3bbfb7fb73bc..64ea8c5fdae2d8 100644 --- a/types/haversine/index.d.ts +++ b/types/haversine/index.d.ts @@ -25,46 +25,41 @@ declare namespace haversine { interface GeoJSON { geometry: { - coordinates: number[]; // matches Point type in types/geojson. + coordinates: number[]; // matches Point type in types/geojson. }; } - type Coordinate = (CoordinateLongitudeLatitude | CoordinateLonLat | CoordinateLatLng | LatLonTuple | GeoJSON); + type Coordinate = CoordinateLongitudeLatitude | CoordinateLonLat | CoordinateLatLng | LatLonTuple | GeoJSON; interface Options { /** Unit of measurement applied to result. Default: "km". */ - unit?: 'km' | 'mile' | 'meter' | 'nmi' | undefined; + unit?: "km" | "mile" | "meter" | "nmi" | undefined; /** * If passed, will result in library returning boolean value of whether or not the start and end points are within that supplied threshold. */ threshold?: number | null | undefined; /** Format of coordinate arguments. */ - format?: '[lat,lon]' | '[lon,lat]' | '{lon,lat}' | '{lat,lng}' | 'geojson' | undefined; + format?: "[lat,lon]" | "[lon,lat]" | "{lon,lat}" | "{lat,lng}" | "geojson" | undefined; } // The input & output types of haversine() both depend on the Options object. - type ParamType = T extends undefined - ? CoordinateLongitudeLatitude - : T extends {format: '[lat,lon]' | '[lon,lat]'} - ? [number, number] - : T extends {format: '{lat,lon}'} - ? CoordinateLonLat - : T extends {format: '{lat,lng}'} - ? CoordinateLatLng - : T extends {format: 'geojson'} - ? GeoJSON + type ParamType = T extends undefined ? CoordinateLongitudeLatitude + : T extends { format: "[lat,lon]" | "[lon,lat]" } ? [number, number] + : T extends { format: "{lat,lon}" } ? CoordinateLonLat + : T extends { format: "{lat,lng}" } ? CoordinateLatLng + : T extends { format: "geojson" } ? GeoJSON : Coordinate; - type Return = T extends {threshold: number} ? boolean : number; + type Return = T extends { threshold: number } ? boolean : number; } /** * Determines the great-circle distance between two points on a sphere given their longitudes and latitudes */ -declare function haversine( +declare function haversine( start: haversine.ParamType, end: haversine.ParamType, options?: OptionsT, - ): haversine.Return; +): haversine.Return; export = haversine; diff --git a/types/hawk/hawk-tests.ts b/types/hawk/hawk-tests.ts index 45fc988546a0aa..3e89ab92cf2124 100644 --- a/types/hawk/hawk-tests.ts +++ b/types/hawk/hawk-tests.ts @@ -1,15 +1,15 @@ -import * as Http from 'http'; -import * as Hawk from 'hawk'; -import * as Request from 'request'; +import * as Hawk from "hawk"; +import * as Http from "http"; +import * as Request from "request"; { // Credentials lookup function const credentialsFunc: Hawk.server.CredentialsFunc = (id: string) => { const credentials: Hawk.server.Credentials = { - key: 'werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn', - algorithm: 'sha256', - user: 'Steve', + key: "werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn", + algorithm: "sha256", + user: "Steve", }; return credentials; @@ -20,7 +20,7 @@ import * as Request from 'request'; const handler = async (req: Http.IncomingMessage, res: Http.ServerResponse) => { let payload; let status; - const headers: Http.IncomingHttpHeaders = { 'Content-Type': 'text/plain' }; + const headers: Http.IncomingHttpHeaders = { "Content-Type": "text/plain" }; // Authenticate incoming request @@ -33,11 +33,11 @@ import * as Request from 'request'; const header = Hawk.server.header(credentials, artifacts, { payload, - contentType: headers['Content-Type'], + contentType: headers["Content-Type"], }); - headers['Server-Authorization'] = header; + headers["Server-Authorization"] = header; } catch (error) { - payload = 'Shoosh!'; + payload = "Shoosh!"; status = 401; } @@ -51,31 +51,31 @@ import * as Request from 'request'; // Start server - Http.createServer(handler).listen(8000, 'example.com'); + Http.createServer(handler).listen(8000, "example.com"); } { // Client credentials const credentials: Hawk.client.Credentials = { - id: 'dh37fgj492je', - key: 'werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn', - algorithm: 'sha256', + id: "dh37fgj492je", + key: "werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn", + algorithm: "sha256", }; // Request options const requestOptions: Request.RequiredUriUrl & Request.CoreOptions & { headers: Request.Headers } = { - uri: 'http://example.com:8000/resource/1?b=1&a=2', - method: 'GET', + uri: "http://example.com:8000/resource/1?b=1&a=2", + method: "GET", headers: {}, }; // Generate Authorization request header - const { header, artifacts } = Hawk.client.header('http://example.com:8000/resource/1?b=1&a=2', 'GET', { + const { header, artifacts } = Hawk.client.header("http://example.com:8000/resource/1?b=1&a=2", "GET", { credentials, - ext: 'some-app-data', + ext: "some-app-data", }); requestOptions.headers.Authorization = header; @@ -88,7 +88,7 @@ import * as Request from 'request'; // Output results - console.log(`${response.statusCode}: ${body}` + (isValid ? ' (valid)' : ' (invalid)')); + console.log(`${response.statusCode}: ${body}` + (isValid ? " (valid)" : " (invalid)")); }); } diff --git a/types/hawk/index.d.ts b/types/hawk/index.d.ts index 99e175548acb77..cd579ca3bc333c 100755 --- a/types/hawk/index.d.ts +++ b/types/hawk/index.d.ts @@ -5,16 +5,16 @@ /// -import * as server from './lib/server'; -import * as client from './lib/client'; -import * as crypto from './lib/crypto'; -import * as utils from './lib/utils'; +import * as client from "./lib/client"; +import * as crypto from "./lib/crypto"; +import * as server from "./lib/server"; +import * as utils from "./lib/utils"; export namespace uri { const authenticate: typeof server.authenticateBewit; const getBewit: typeof client.getBewit; } -export { server, client, crypto, utils }; +export { client, crypto, server, utils }; export as namespace hawk; diff --git a/types/hawk/lib/browser.d.ts b/types/hawk/lib/browser.d.ts index b397d5722d2f59..abbad8dca84fb2 100755 --- a/types/hawk/lib/browser.d.ts +++ b/types/hawk/lib/browser.d.ts @@ -1,6 +1,6 @@ -import CryptoJS = require('crypto-js'); -import * as Crypto from './crypto'; -import * as Client from './client'; +import CryptoJS = require("crypto-js"); +import * as Client from "./client"; +import * as Crypto from "./crypto"; declare namespace hawk { namespace client { diff --git a/types/hawk/lib/client.d.ts b/types/hawk/lib/client.d.ts index 25d6fe20bea477..8eede6ac269919 100755 --- a/types/hawk/lib/client.d.ts +++ b/types/hawk/lib/client.d.ts @@ -1,9 +1,9 @@ -import * as Crypto from './crypto'; -import * as http from 'http'; -import * as request from 'request'; +import * as http from "http"; +import * as request from "request"; +import * as Crypto from "./crypto"; export interface Credentials { - algorithm: 'sha1' | 'sha256'; + algorithm: "sha1" | "sha256"; id: string; key: string; } diff --git a/types/hawk/lib/crypto.d.ts b/types/hawk/lib/crypto.d.ts index 2612bae83e3f12..c2e7c27285c103 100755 --- a/types/hawk/lib/crypto.d.ts +++ b/types/hawk/lib/crypto.d.ts @@ -1,5 +1,5 @@ -import * as Crypto from 'crypto'; -import * as Client from './client'; +import * as Crypto from "crypto"; +import * as Client from "./client"; export interface Artifacts { app?: string | undefined; diff --git a/types/hawk/lib/server.d.ts b/types/hawk/lib/server.d.ts index 50611f9530c354..9fded06024b9cc 100755 --- a/types/hawk/lib/server.d.ts +++ b/types/hawk/lib/server.d.ts @@ -1,7 +1,7 @@ -import * as http from 'http'; +import * as http from "http"; -import * as Crypto from './crypto'; -import { Message } from './client'; +import { Message } from "./client"; +import * as Crypto from "./crypto"; export type CredentialsFunc = (id: string) => Promise | Credentials; export type NonceFunc = (key: string, nonce: string, ts: string) => Promise | void; @@ -50,7 +50,7 @@ export interface AuthenticateOptions { } export interface Credentials { - algorithm: 'sha1' | 'sha256'; + algorithm: "sha1" | "sha256"; key: string; user: string; } @@ -73,7 +73,7 @@ export interface HeaderOptions { export type AuthenticateBewitOptions = Pick< AuthenticateOptions, - 'hostHeaderName' | 'localtimeOffsetMsec' | 'host' | 'port' + "hostHeaderName" | "localtimeOffsetMsec" | "host" | "port" >; export interface Bewit { @@ -93,7 +93,7 @@ export interface AuthenticatedMessage { export type AuthenticateMessageOptions = Pick< AuthenticateOptions, - 'nonceFunc' | 'timestampSkewSec' | 'localtimeOffsetMsec' + "nonceFunc" | "timestampSkewSec" | "localtimeOffsetMsec" >; export function authenticate( diff --git a/types/hawk/lib/utils.d.ts b/types/hawk/lib/utils.d.ts index 7ff7a9023cd6e5..898d426116ceea 100755 --- a/types/hawk/lib/utils.d.ts +++ b/types/hawk/lib/utils.d.ts @@ -1,6 +1,6 @@ -import * as Boom from '@hapi/boom'; -import * as http from 'http'; -import * as https from 'https'; +import * as Boom from "@hapi/boom"; +import * as http from "http"; +import * as https from "https"; export interface Host { name: string; diff --git a/types/haxball-headless-browser/haxball-headless-browser-tests.ts b/types/haxball-headless-browser/haxball-headless-browser-tests.ts index d9ee2ff743b6c7..832d56a76d1f44 100644 --- a/types/haxball-headless-browser/haxball-headless-browser-tests.ts +++ b/types/haxball-headless-browser/haxball-headless-browser-tests.ts @@ -1,7 +1,7 @@ let room = HBInit({ roomName: "test room", playerName: "bot", - geo: {code: "DE", lat: 50, lon: 50} + geo: { code: "DE", lat: 50, lon: 50 }, }); room.onPlayerJoin = p => { diff --git a/types/haxball-headless-browser/index.d.ts b/types/haxball-headless-browser/index.d.ts index c4dbd801c3c8e8..28d8b562652f54 100644 --- a/types/haxball-headless-browser/index.d.ts +++ b/types/haxball-headless-browser/index.d.ts @@ -11,7 +11,7 @@ interface RoomConfigObject { password?: string; maxPlayers?: number; public?: boolean; - geo?: {"code": string, "lat": number, "lon": number}; + geo?: { "code": string; "lat": number; "lon": number }; token?: string; noPlayer?: boolean; } @@ -35,7 +35,7 @@ declare class RoomObject { getPlayer(playerId: number): PlayerObject; getPlayerList(): PlayerObject[]; getScores(): ScoresObject; - getBallPosition(): {"x": number, "y": number}; + getBallPosition(): { "x": number; "y": number }; startRecording(): void; stopRecording(): Uint8Array; setPassword(pass: string): void; @@ -76,7 +76,7 @@ declare class PlayerObject { name: string; team: TeamID; admin: boolean; - position: {"x": number, "y": number}; + position: { "x": number; "y": number }; auth: string; conn: string; } diff --git a/types/hbs/hbs-tests.ts b/types/hbs/hbs-tests.ts index c1d355daea3659..a958c0b93c0e46 100644 --- a/types/hbs/hbs-tests.ts +++ b/types/hbs/hbs-tests.ts @@ -1,22 +1,22 @@ -import express = require('express'); +import express = require("express"); const app = express(); -app.set('view engine', 'html'); +app.set("view engine", "html"); -import hbs = require('hbs'); +import hbs = require("hbs"); // The idiom for this is // app.engine('html', require('hbs').__express); // However this undermines the test since the return type of require() is any -app.engine('html', hbs.__express); +app.engine("html", hbs.__express); -hbs.registerHelper('helper_name', (testParm: number) => testParm++); -hbs.registerPartial('partial_name', 'partial value'); +hbs.registerHelper("helper_name", (testParm: number) => testParm++); +hbs.registerPartial("partial_name", "partial value"); -hbs.registerPartials(__dirname + '/views/partials'); +hbs.registerPartials(__dirname + "/views/partials"); -hbs.registerPartials(__dirname + '/views/partials', () => {}); +hbs.registerPartials(__dirname + "/views/partials", () => {}); hbs.localsAsTemplateData(app); @@ -25,5 +25,5 @@ const safeString = new hbs.handlebars.SafeString("string"); const instance1 = hbs.create(); const instance2 = hbs.create(); -app.engine('html', instance1.__express); -app.engine('hbs', instance2.__express); +app.engine("html", instance1.__express); +app.engine("hbs", instance2.__express); diff --git a/types/hbs/index.d.ts b/types/hbs/index.d.ts index 1b3a36c4bed4ae..b25c260dfda0b6 100644 --- a/types/hbs/index.d.ts +++ b/types/hbs/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -import handlebars = require('handlebars'); +import handlebars = require("handlebars"); type handlebarsModule = typeof handlebars; diff --git a/types/hcaptcha__react-hcaptcha/hcaptcha__react-hcaptcha-tests.tsx b/types/hcaptcha__react-hcaptcha/hcaptcha__react-hcaptcha-tests.tsx index ea999577090b13..6c091e67dfddce 100644 --- a/types/hcaptcha__react-hcaptcha/hcaptcha__react-hcaptcha-tests.tsx +++ b/types/hcaptcha__react-hcaptcha/hcaptcha__react-hcaptcha-tests.tsx @@ -1,5 +1,5 @@ -import * as React from 'react'; -import HCaptcha from '@hcaptcha/react-hcaptcha'; +import HCaptcha from "@hcaptcha/react-hcaptcha"; +import * as React from "react"; const Test: React.FC = () => { const captchaRef = React.createRef(); diff --git a/types/hcaptcha__react-hcaptcha/index.d.ts b/types/hcaptcha__react-hcaptcha/index.d.ts index 153ca953e1df06..ae66ce850073f0 100644 --- a/types/hcaptcha__react-hcaptcha/index.d.ts +++ b/types/hcaptcha__react-hcaptcha/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -import * as React from 'react'; +import * as React from "react"; interface HCaptchaState { isApiReady: boolean; @@ -19,8 +19,8 @@ interface HCaptchaProps { onVerify?: ((token: string) => any) | undefined; languageOverride?: string | undefined; sitekey: string; - size?: 'normal' | 'compact' | 'invisible' | undefined; - theme?: 'light' | 'dark' | undefined; + size?: "normal" | "compact" | "invisible" | undefined; + theme?: "light" | "dark" | undefined; tabIndex?: number | undefined; id?: string | undefined; reCaptchaCompat?: boolean | undefined; diff --git a/types/hcaptcha__vue-hcaptcha/hcaptcha__vue-hcaptcha-tests.ts b/types/hcaptcha__vue-hcaptcha/hcaptcha__vue-hcaptcha-tests.ts index 49a43996914960..5307171cdfded2 100644 --- a/types/hcaptcha__vue-hcaptcha/hcaptcha__vue-hcaptcha-tests.ts +++ b/types/hcaptcha__vue-hcaptcha/hcaptcha__vue-hcaptcha-tests.ts @@ -1,9 +1,9 @@ -import Vue from 'vue'; -import HCaptcha from '@hcaptcha/vue-hcaptcha'; +import HCaptcha from "@hcaptcha/vue-hcaptcha"; +import Vue from "vue"; new Vue({ - el: '#app', - components: { - hcaptcha: HCaptcha - } + el: "#app", + components: { + hcaptcha: HCaptcha, + }, }); diff --git a/types/hcaptcha__vue-hcaptcha/index.d.ts b/types/hcaptcha__vue-hcaptcha/index.d.ts index ffe6524daf7e2d..b2357223007570 100644 --- a/types/hcaptcha__vue-hcaptcha/index.d.ts +++ b/types/hcaptcha__vue-hcaptcha/index.d.ts @@ -4,28 +4,28 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.8 -import { VueConstructor } from 'vue'; +import { VueConstructor } from "vue"; export const h: HCaptcha; export default h; export interface HCaptchaProps { - sitekey: string; - theme?: string | undefined; - size?: string | undefined; - tabindex?: string | undefined; + sitekey: string; + theme?: string | undefined; + size?: string | undefined; + tabindex?: string | undefined; } export interface HCaptchaMethods { - onloadScript(): void; - onError(e: Error): void; - onVerify(response: string): void; - onExpired(): void; - execute(): void; - reset(): void; + onloadScript(): void; + onError(e: Error): void; + onVerify(response: string): void; + onExpired(): void; + execute(): void; + reset(): void; } export interface HCaptcha extends VueConstructor { - props: HCaptchaProps; - data: any; - methods: HCaptchaMethods; + props: HCaptchaProps; + data: any; + methods: HCaptchaMethods; } diff --git a/types/hdkey/hdkey-tests.ts b/types/hdkey/hdkey-tests.ts index 4f14a35af0f440..411ceafe9a3b15 100644 --- a/types/hdkey/hdkey-tests.ts +++ b/types/hdkey/hdkey-tests.ts @@ -1,16 +1,16 @@ -import HDKey = require('hdkey'); +import HDKey = require("hdkey"); const hdKey = new HDKey(); -hdKey.derive('m/1/42'); +hdKey.derive("m/1/42"); hdKey.privateKey; hdKey.publicKey; hdKey.publicExtendedKey; const priv = hdKey.privateExtendedKey; HDKey.fromExtendedKey(priv); -const sign = hdKey.sign(Buffer.from('hello world')); -hdKey.verify(Buffer.from('hello world'), sign); +const sign = hdKey.sign(Buffer.from("hello world")); +hdKey.verify(Buffer.from("hello world"), sign); hdKey.wipePrivateData(); hdKey.chainCode; hdKey.toJSON(); -HDKey.fromJSON({ xpriv: '', xpub: '' }); -HDKey.fromMasterSeed(Buffer.from('hello world')); -HDKey.fromMasterSeed(Buffer.from('hello world'), { private: 0x043587cf, public: 0x04358394 }); +HDKey.fromJSON({ xpriv: "", xpub: "" }); +HDKey.fromMasterSeed(Buffer.from("hello world")); +HDKey.fromMasterSeed(Buffer.from("hello world"), { private: 0x043587cf, public: 0x04358394 }); diff --git a/types/he/he-tests.ts b/types/he/he-tests.ts index 3fce7214c9caa4..3f06b8605c358b 100644 --- a/types/he/he-tests.ts +++ b/types/he/he-tests.ts @@ -1,72 +1,72 @@ -import he = require('he'); +import he = require("he"); function main() { var result: string; - result = he.encode('foo \xa9 bar \u2260 baz qux'); + result = he.encode("foo \xa9 bar \u2260 baz qux"); // 'foo © bar ≠ baz qux' - he.encode('foo \0 bar'); + he.encode("foo \0 bar"); // 'foo \0 bar' // Passing an `options` object to `encode`, to explicitly disallow named references: - he.encode('foo \xa9 bar \u2260 baz qux', { - 'useNamedReferences': false + he.encode("foo \xa9 bar \u2260 baz qux", { + "useNamedReferences": false, }); - he.encode('foo \xa9 bar \u2260 baz qux', { - 'encodeEverything': true + he.encode("foo \xa9 bar \u2260 baz qux", { + "encodeEverything": true, }); - he.encode('foo \xa9 bar \u2260 baz qux', { - 'encodeEverything': true, - 'useNamedReferences': true + he.encode("foo \xa9 bar \u2260 baz qux", { + "encodeEverything": true, + "useNamedReferences": true, }); - he.encode('\x01', { - 'strict': false + he.encode("\x01", { + "strict": false, }); // '' - he.encode('foo © and & ampersand', { - 'allowUnsafeSymbols': true + he.encode("foo © and & ampersand", { + "allowUnsafeSymbols": true, }); // Using the global default setting (defaults to `false`): - he.encode('foo © bar ≠ baz 𝌆 qux'); + he.encode("foo © bar ≠ baz 𝌆 qux"); // → 'foo © bar ≠ baz 𝌆 qux' // Passing an `options` object to `encode`, to explicitly disable decimal escapes: - he.encode('foo © bar ≠ baz 𝌆 qux', { - 'decimal': false + he.encode("foo © bar ≠ baz 𝌆 qux", { + "decimal": false, }); // → 'foo © bar ≠ baz 𝌆 qux' // Passing an `options` object to `encode`, to explicitly enable decimal escapes: - he.encode('foo © bar ≠ baz 𝌆 qux', { - 'decimal': true + he.encode("foo © bar ≠ baz 𝌆 qux", { + "decimal": true, }); // → 'foo © bar ≠ baz 𝌆 qux' // Passing an `options` object to `encode`, to explicitly allow named references and decimal escapes: - he.encode('foo © bar ≠ baz 𝌆 qux', { - 'useNamedReferences': true, - 'decimal': true + he.encode("foo © bar ≠ baz 𝌆 qux", { + "useNamedReferences": true, + "decimal": true, }); // Override the global default setting: he.encode.options.useNamedReferences = true; - he.decode('foo © bar ≠ baz 𝌆 qux'); + he.decode("foo © bar ≠ baz 𝌆 qux"); - he.decode('foo&bar', { - 'isAttributeValue': false + he.decode("foo&bar", { + "isAttributeValue": false, }); - he.decode('foo&bar', { - 'strict': false + he.decode("foo&bar", { + "strict": false, }); he.decode.options.isAttributeValue = true; - he.escape(''); + he.escape(""); } diff --git a/types/he/index.d.ts b/types/he/index.d.ts index 61166b3c46b732..a040105e260b45 100644 --- a/types/he/index.d.ts +++ b/types/he/index.d.ts @@ -12,11 +12,11 @@ export var version: string; export interface EncodeOptions { /** - * The default value for the useNamedReferences option is false. This - * means that encode() will not use any named character references - * (e.g. ©) in the output — hexadecimal escapes (e.g. ©) will - * be used instead. Set it to true to enable the use of named references. - */ + * The default value for the useNamedReferences option is false. This + * means that encode() will not use any named character references + * (e.g. ©) in the output — hexadecimal escapes (e.g. ©) will + * be used instead. Set it to true to enable the use of named references. + */ useNamedReferences?: boolean | undefined; /** @@ -32,13 +32,13 @@ export interface EncodeOptions { decimal?: boolean | undefined; /** - * The default value for the encodeEverything option is false. This means - * that encode() will not use any character references for printable ASCII - * symbols that don’t need escaping. Set it to true to encode every symbol - * in the input string. When set to true, this option takes precedence over - * allowUnsafeSymbols (i.e. setting the latter to true in such a case has - * no effect). - */ + * The default value for the encodeEverything option is false. This means + * that encode() will not use any character references for printable ASCII + * symbols that don’t need escaping. Set it to true to encode every symbol + * in the input string. When set to true, this option takes precedence over + * allowUnsafeSymbols (i.e. setting the latter to true in such a case has + * no effect). + */ encodeEverything?: boolean | undefined; /** @@ -51,28 +51,28 @@ export interface EncodeOptions { strict?: boolean | undefined; /** - * The default value for the allowUnsafeSymbols option is false. This means - * that characters that are unsafe for use in HTML content (&, <, >, ", ', - * and `) will be encoded. When set to true, only non-ASCII characters will - * be encoded. If the encodeEverything option is set to true, this option - * will be ignored. - */ + * The default value for the allowUnsafeSymbols option is false. This means + * that characters that are unsafe for use in HTML content (&, <, >, ", ', + * and `) will be encoded. When set to true, only non-ASCII characters will + * be encoded. If the encodeEverything option is set to true, this option + * will be ignored. + */ allowUnsafeSymbols?: boolean | undefined; } export interface Encode { /** - * Encode a string of text - * - * This function takes a string of text and encodes (by default) any symbols - * that aren’t printable ASCII symbols and &, <, >, ", ', and `, replacing - * them with character references. - * - * As long as the input string contains allowed code points only, the return - * value of this function is always valid HTML. Any (invalid) code points - * that cannot be represented using a character reference in the input are - * not encoded. - */ + * Encode a string of text + * + * This function takes a string of text and encodes (by default) any symbols + * that aren’t printable ASCII symbols and &, <, >, ", ', and `, replacing + * them with character references. + * + * As long as the input string contains allowed code points only, the return + * value of this function is always valid HTML. Any (invalid) code points + * that cannot be represented using a character reference in the input are + * not encoded. + */ (text: string, options?: EncodeOptions): string; options: EncodeOptions; diff --git a/types/headroom/headroom-tests.ts b/types/headroom/headroom-tests.ts index bce41880e2b286..f788cb29f8cc7e 100644 --- a/types/headroom/headroom-tests.ts +++ b/types/headroom/headroom-tests.ts @@ -1,13 +1,11 @@ +new Headroom(document.getElementById("siteHead")); +new Headroom(document.getElementsByClassName("siteHead")[0]); -new Headroom(document.getElementById('siteHead')); - -new Headroom(document.getElementsByClassName('siteHead')[0]); - -new Headroom(document.getElementsByClassName('siteHead')[0], { - tolerance: 34 +new Headroom(document.getElementsByClassName("siteHead")[0], { + tolerance: 34, }); -new Headroom(document.getElementsByClassName('siteHead')[0], { - offset: 500 +new Headroom(document.getElementsByClassName("siteHead")[0], { + offset: 500, }); diff --git a/types/heap/heap-tests.ts b/types/heap/heap-tests.ts index e7a4d000c8d7fb..a0ea22b57d14bb 100644 --- a/types/heap/heap-tests.ts +++ b/types/heap/heap-tests.ts @@ -1,7 +1,11 @@ import Heap = require("heap"); -var numberComparator = (a: number, b: number) => { return a.toString().length - b.toString().length; }; -var stringComparator = (a: string, b: string) => { return a.length - b.length; }; +var numberComparator = (a: number, b: number) => { + return a.toString().length - b.toString().length; +}; +var stringComparator = (a: string, b: string) => { + return a.length - b.length; +}; // Test constructor var numberHeap: Heap = new Heap(); diff --git a/types/heap/index.d.ts b/types/heap/index.d.ts index c11e10d1c03e3e..41f380d2a50af3 100644 --- a/types/heap/index.d.ts +++ b/types/heap/index.d.ts @@ -4,7 +4,6 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare class Heap { - // Constructor constructor(cmp?: (a: T, b: T) => number); @@ -54,8 +53,8 @@ declare class Heap { toArray(): T[]; // Return a clone of the heap. (note: the internal data is a shallow copy of the original one) - clone(): Heap - copy(): Heap + clone(): Heap; + copy(): Heap; // Static Methods @@ -83,7 +82,6 @@ declare class Heap { // Find the n smallest elements in a dataset. static nsmallest(array: T[], n: number, cmp?: (a: T, b: T) => number): T[]; - } export = Heap; diff --git a/types/heapdump/heapdump-tests.ts b/types/heapdump/heapdump-tests.ts index 80306b9d322b51..eb0b69bb373419 100644 --- a/types/heapdump/heapdump-tests.ts +++ b/types/heapdump/heapdump-tests.ts @@ -1,4 +1,4 @@ -import * as heapdump from 'heapdump'; +import * as heapdump from "heapdump"; let strValue = ""; let errValue = new Error(strValue); @@ -6,15 +6,15 @@ let nullValue = null; let undefinedValue; heapdump.writeSnapshot(strValue, (err, filename) => { - errValue = err as Error; - nullValue = err as null; - strValue = filename as string; - undefinedValue = filename as undefined; + errValue = err as Error; + nullValue = err as null; + strValue = filename as string; + undefinedValue = filename as undefined; }); heapdump.writeSnapshot((err, filename) => { - errValue = err as Error; - nullValue = err as null; - strValue = filename as string; - undefinedValue = filename as undefined; + errValue = err as Error; + nullValue = err as null; + strValue = filename as string; + undefinedValue = filename as undefined; }); diff --git a/types/heapdump/index.d.ts b/types/heapdump/index.d.ts index 1473ebb70a0b04..1351e449c15664 100644 --- a/types/heapdump/index.d.ts +++ b/types/heapdump/index.d.ts @@ -4,5 +4,8 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 -export function writeSnapshot(dumpFileName?: string, callback?: (err: Error | null, filename: string | undefined) => void): void; +export function writeSnapshot( + dumpFileName?: string, + callback?: (err: Error | null, filename: string | undefined) => void, +): void; export function writeSnapshot(callback: (err: Error | null, filename: string | undefined) => void): void; diff --git a/types/heatmap.js/heatmap.js-tests.ts b/types/heatmap.js/heatmap.js-tests.ts index 5dfbd910190015..0a4f86151bd8b9 100644 --- a/types/heatmap.js/heatmap.js-tests.ts +++ b/types/heatmap.js/heatmap.js-tests.ts @@ -10,21 +10,21 @@ declare const container: HTMLElement; { const config: h337.HeatmapConfiguration = { container, - xField: 'x', - yField: 'y', - valueField: 'value', + xField: "x", + yField: "y", + valueField: "value", }; } { // @ts-expect-error - const config: h337.HeatmapConfiguration = { container, valueField: 'foo' }; + const config: h337.HeatmapConfiguration = { container, valueField: "foo" }; } { - const config: h337.HeatmapConfiguration<'foo'> = { + const config: h337.HeatmapConfiguration<"foo"> = { container, - valueField: 'foo', + valueField: "foo", }; config; // $ExpectType HeatmapConfiguration<"foo", "x", "y"> } @@ -77,7 +77,7 @@ declare const container: HTMLElement; // @ts-expect-error heatmap.addData({ x: 1, value: 1 }); // @ts-expect-error - heatmap.addData({ x: 1, y: 1, }); + heatmap.addData({ x: 1, y: 1 }); } { @@ -107,14 +107,13 @@ declare const container: HTMLElement; // @ts-expect-error heatmap.addData({ xPos: 1, count: 1 }); // @ts-expect-error - heatmap.addData({ xPos: 1, yPos: 1, }); + heatmap.addData({ xPos: 1, yPos: 1 }); } // -- Heatmap#setData -- { - const validData: ReadonlyArray = - [{ x: 1, y: 2, value: 1 }]; + const validData: ReadonlyArray = [{ x: 1, y: 2, value: 1 }]; const heatmap = h337.create({ container }); // @ts-expect-error @@ -126,7 +125,7 @@ declare const container: HTMLElement; heatmap.setData({ min: 0, max: 1, - data: validData + data: validData, }); // @ts-expect-error @@ -134,8 +133,7 @@ declare const container: HTMLElement; } { - const validData: ReadonlyArray> = - [{ xPos: 1, yPos: 2, count: 1 }]; + const validData: ReadonlyArray> = [{ xPos: 1, yPos: 2, count: 1 }]; const heatmap = h337.create<"count", "xPos", "yPos">({ container }); // @ts-expect-error @@ -147,7 +145,7 @@ declare const container: HTMLElement; heatmap.setData({ min: 0, max: 1, - data: validData + data: validData, }); // @ts-expect-error @@ -185,7 +183,7 @@ declare const container: HTMLElement; container, valueField: "count", xField: "xPos", - yField: "yPos" + yField: "yPos", }); nextHeatmap; // $ExpectType Heatmap<"count", "xPos", "yPos"> @@ -234,46 +232,49 @@ declare const container: HTMLElement; { const baseLayer = L.tileLayer( - 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { - attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © CloudMade', - maxZoom: 18 - } + "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", + { + attribution: + "Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © CloudMade", + maxZoom: 18, + }, ); - const testData: h337.HeatmapData> = { + const testData: h337.HeatmapData> = { min: 1, max: 3, data: [ { lat: 24.6408, lng: 46.7728, - count: 3 - }, { + count: 3, + }, + { lat: 50.75, lng: -1.55, - count: 1 - } - ] + count: 1, + }, + ], }; - const config: h337.HeatmapOverlayConfiguration<'count'> = { + const config: h337.HeatmapOverlayConfiguration<"count"> = { radius: 2, maxOpacity: .8, scaleRadius: true, useLocalExtrema: true, - latField: 'lat', - lngField: 'lng', - valueField: 'count' + latField: "lat", + lngField: "lng", + valueField: "count", }; config; // $ExpectType HeatmapOverlayConfiguration<"count", "lat", "lng"> const heatmapLayer = new HeatmapOverlay(config); heatmapLayer; // $ExpectType HeatmapOverlay<"count", "lat", "lng"> - const map = new L.Map('map-canvas', { + const map = new L.Map("map-canvas", { center: new L.LatLng(25.6586, -80.3568), zoom: 4, - layers: [baseLayer, heatmapLayer] + layers: [baseLayer, heatmapLayer], }); // $ExpectType void diff --git a/types/heatmap.js/index.d.ts b/types/heatmap.js/index.d.ts index 6e431b627ac5a5..189d62d37c906a 100644 --- a/types/heatmap.js/index.d.ts +++ b/types/heatmap.js/index.d.ts @@ -43,11 +43,11 @@ export as namespace h337; * var heatmapInstance = h337.create(config); */ export function create< - V extends string = 'value', - X extends string = 'x', - Y extends string = 'y' + V extends string = "value", + X extends string = "x", + Y extends string = "y", >( - configObject: HeatmapConfiguration + configObject: HeatmapConfiguration, ): Heatmap; export function register(pluginKey: string, plugin: any): void; @@ -144,7 +144,7 @@ export class Heatmap { configure< Vn extends string = V, Xn extends string = X, - Yn extends string = Y + Yn extends string = Y, >(configObject: HeatmapConfiguration): Heatmap; /** @@ -159,7 +159,7 @@ export class Heatmap { * // get the value at x=10, y=10 * heatmapInstance.getValueAt({ x: 10, y: 10 }); // returns 100 */ - getValueAt(point: { x: number, y: number }): number; + getValueAt(point: { x: number; y: number }): number; /** * Returns a persistable and reimportable (with setData) JSON object. @@ -191,7 +191,7 @@ export class Heatmap { repaint(): this; } -export interface BaseHeatmapConfiguration { +export interface BaseHeatmapConfiguration { /** * A background color string in form of hexcode, color name, or rgb(a) */ @@ -264,9 +264,9 @@ export interface BaseHeatmapConfiguration { * Configuration object of a heatmap */ export interface HeatmapConfiguration< - V extends string = 'value', - X extends string = 'x', - Y extends string = 'y', + V extends string = "value", + X extends string = "x", + Y extends string = "y", > extends BaseHeatmapConfiguration { /** * A DOM node where the heatmap canvas should be appended (heatmap will adapt to @@ -288,9 +288,9 @@ export interface HeatmapConfiguration< } export interface HeatmapOverlayConfiguration< - V extends string = 'value', - TLat extends string = 'lat', - TLong extends string = 'lng', + V extends string = "value", + TLat extends string = "lat", + TLong extends string = "lng", > extends BaseHeatmapConfiguration { /** * The property name of your latitude coordinate in a datapoint @@ -311,9 +311,9 @@ export interface HeatmapOverlayConfiguration< * config object. */ export type DataPoint< - V extends string = 'value', - X extends string = 'x', - Y extends string = 'y', + V extends string = "value", + X extends string = "x", + Y extends string = "y", > = Record; /** @@ -358,7 +358,7 @@ declare global { class HeatmapOverlay< V extends string, TLat extends string, - TLng extends string + TLng extends string, > implements Leaflet.ILayer { /** * Initialization function diff --git a/types/heft-jest/mocked.d.ts b/types/heft-jest/mocked.d.ts index 12390d2a2a4bd5..e44c2921a8820a 100644 --- a/types/heft-jest/mocked.d.ts +++ b/types/heft-jest/mocked.d.ts @@ -31,29 +31,29 @@ declare namespace mocked { type MethodKeysOf = { [K in keyof T]: T[K] extends MockableFunction ? K : never }[keyof T]; type PropertyKeysOf = { [K in keyof T]: T[K] extends MockableFunction ? never : K }[keyof T]; type ArgumentsOf = T extends (...args: infer A) => any ? A : never; - type ConstructorArgumentsOf = T extends new (...args: infer A) => any ? A : never; + type ConstructorArgumentsOf = T extends new(...args: infer A) => any ? A : never; interface MockWithArgs extends jest.MockInstance, ArgumentsOf> { - new (...args: ConstructorArgumentsOf): T; + new(...args: ConstructorArgumentsOf): T; (...args: ArgumentsOf): ReturnType; } - type MaybeMockedConstructor = T extends new (...args: any[]) => infer R + type MaybeMockedConstructor = T extends new(...args: any[]) => infer R ? jest.MockInstance> : {}; type MockedFunction = MockWithArgs & { [K in keyof T]: T[K] }; type MockedFunctionDeep = MockWithArgs & MockedObjectDeep; - type MockedObject = MaybeMockedConstructor & - { [K in MethodKeysOf]: T[K] extends MockableFunction ? MockedFunction : T[K] } & - { [K in PropertyKeysOf]: T[K] }; - type MockedObjectDeep = MaybeMockedConstructor & - { [K in MethodKeysOf]: T[K] extends MockableFunction ? MockedFunctionDeep : T[K] } & - { [K in PropertyKeysOf]: MaybeMockedDeep }; + type MockedObject = + & MaybeMockedConstructor + & { [K in MethodKeysOf]: T[K] extends MockableFunction ? MockedFunction : T[K] } + & { [K in PropertyKeysOf]: T[K] }; + type MockedObjectDeep = + & MaybeMockedConstructor + & { [K in MethodKeysOf]: T[K] extends MockableFunction ? MockedFunctionDeep : T[K] } + & { [K in PropertyKeysOf]: MaybeMockedDeep }; - type MaybeMockedDeep = T extends MockableFunction - ? MockedFunctionDeep - : T extends object - ? MockedObjectDeep + type MaybeMockedDeep = T extends MockableFunction ? MockedFunctionDeep + : T extends object ? MockedObjectDeep : T; type MaybeMocked = T extends MockableFunction ? MockedFunction : T extends object ? MockedObject : T; diff --git a/types/heic-convert/heic-convert-tests.ts b/types/heic-convert/heic-convert-tests.ts index cb94165d2763e1..a8640397e2ca70 100644 --- a/types/heic-convert/heic-convert-tests.ts +++ b/types/heic-convert/heic-convert-tests.ts @@ -1,13 +1,13 @@ -import convert = require('heic-convert'); +import convert = require("heic-convert"); // $ExpectType Promise -convert({ buffer: new ArrayBuffer(10), format: 'PNG' }); +convert({ buffer: new ArrayBuffer(10), format: "PNG" }); // $ExpectType Promise -convert({ buffer: new ArrayBuffer(10), format: 'JPEG', quality: 0.4 }); +convert({ buffer: new ArrayBuffer(10), format: "JPEG", quality: 0.4 }); // $ExpectType Promise -convert.all({ buffer: new ArrayBuffer(10), format: 'PNG' }); +convert.all({ buffer: new ArrayBuffer(10), format: "PNG" }); // $ExpectType Promise -convert.all({ buffer: new ArrayBuffer(10), format: 'JPEG', quality: 0.4 }); +convert.all({ buffer: new ArrayBuffer(10), format: "JPEG", quality: 0.4 }); diff --git a/types/heic-convert/index.d.ts b/types/heic-convert/index.d.ts index 512ee456a71373..e43c9c414b8762 100644 --- a/types/heic-convert/index.d.ts +++ b/types/heic-convert/index.d.ts @@ -11,7 +11,7 @@ interface ConversionOptions { /** * output format */ - format: 'JPEG' | 'PNG'; + format: "JPEG" | "PNG"; /** * the JPEG compression quality, between 0 and 1 * @default 0.92 diff --git a/types/heic-decode/heic-decode-tests.ts b/types/heic-decode/heic-decode-tests.ts index cfb461bb0fbf1d..7f27b50dc5f608 100644 --- a/types/heic-decode/heic-decode-tests.ts +++ b/types/heic-decode/heic-decode-tests.ts @@ -1,4 +1,4 @@ -import decode = require('heic-decode'); +import decode = require("heic-decode"); const { all } = decode; // $ExpectType Promise diff --git a/types/hellojs/hellojs-tests.ts b/types/hellojs/hellojs-tests.ts index ffd52ca8ca6e7c..5d0bd495925092 100644 --- a/types/hellojs/hellojs-tests.ts +++ b/types/hellojs/hellojs-tests.ts @@ -1,38 +1,38 @@ hello.init({ serviceName: { - name: 'Test', + name: "Test", oauth: { version: 2, - auth: '', - grant: '', - response_type: 'id_token token', + auth: "", + grant: "", + response_type: "id_token token", }, refresh: true, - scope_delim: ' ', + scope_delim: " ", logout: () => { - const id_token = hello('networkName').getAuthResponse().id_token; - hello.utils.store('networkName', null); + const id_token = hello("networkName").getAuthResponse().id_token; + hello.utils.store("networkName", null); }, xhr: p => { const token = p.query.access_token; delete p.query.access_token; if (token) { p.headers = { - Authorization: 'Bearer ' + token, + Authorization: "Bearer " + token, }; } switch (p.method) { - case 'post': - case 'put': - if (typeof p.data === 'object') { + case "post": + case "put": + if (typeof p.data === "object") { try { p.data = JSON.stringify(p.data); - p.headers['content-type'] = 'application/json'; + p.headers["content-type"] = "application/json"; } catch (e) {} } break; - case 'patch': + case "patch": hello.utils.extend(p.query, p.data); p.data = null; break; @@ -47,51 +47,51 @@ hello.init({ // https://github.com/MrSwitch/hello.js/blob/v1.15.1/src/modules/joinme.js hello.init({ joinme: { - name: 'join.me', + name: "join.me", oauth: { version: 2, - auth: '', - grant: '', + auth: "", + grant: "", }, refresh: false, scope: { - basic: 'user_info', - user: 'user_info', - scheduler: 'scheduler', - start: 'start_meeting', - email: '', - friends: '', - share: '', - publish: '', - photos: '', - publish_files: '', - files: '', - videos: '', - offline_access: '', - }, - scope_delim: ' ', + basic: "user_info", + user: "user_info", + scheduler: "scheduler", + start: "start_meeting", + email: "", + friends: "", + share: "", + publish: "", + photos: "", + publish_files: "", + files: "", + videos: "", + offline_access: "", + }, + scope_delim: " ", login: p => { p.options.popup.width = 400; p.options.popup.height = 700; }, - base: 'https://api.join.me/v1/', + base: "https://api.join.me/v1/", get: { - me: 'user', - meetings: 'meetings', - 'meetings/info': 'meetings/@{id}', + me: "user", + meetings: "meetings", + "meetings/info": "meetings/@{id}", }, post: { - 'meetings/start/adhoc': (p, callback) => { - callback('meetings/start'); + "meetings/start/adhoc": (p, callback) => { + callback("meetings/start"); }, }, patch: { - 'meetings/update': (p, callback) => { - callback('meetings/' + p.data.meetingId); + "meetings/update": (p, callback) => { + callback("meetings/" + p.data.meetingId); }, }, del: { - 'meetings/delete': 'meetings/@{id}', + "meetings/delete": "meetings/@{id}", }, wrap: { me: (o, headers) => { @@ -100,8 +100,8 @@ hello.init({ } o.name = o.fullName; - o.first_name = o.name.split(' ')[0]; - o.last_name = o.name.split(' ')[1]; + o.first_name = o.name.split(" ")[0]; + o.last_name = o.name.split(" ")[1]; o.id = o.email; return o; @@ -113,18 +113,18 @@ hello.init({ xhr: (p, qs) => { const token = qs.access_token; delete qs.access_token; - p.headers.Authorization = 'Bearer ' + token; + p.headers.Authorization = "Bearer " + token; }, }, }); hello.init( { - facebook: '', + facebook: "", }, { - redirect_uri: 'hello.html', - display: 'page', + redirect_uri: "hello.html", + display: "page", }, ); @@ -132,84 +132,84 @@ hello.init( hello.init( { linkedin: { - id: '', + id: "", oauth: { version: 2, - response_type: 'code', - auth: 'https://www.linkedin.com/oauth/v2/authorization', - grant: 'https://www.linkedin.com/oauth/v2/accessToken', + response_type: "code", + auth: "https://www.linkedin.com/oauth/v2/authorization", + grant: "https://www.linkedin.com/oauth/v2/accessToken", }, scope: { - basic: 'r_liteprofile', - email: 'r_emailaddress', + basic: "r_liteprofile", + email: "r_emailaddress", }, - base: 'https://api.linkedin.com/v2/', + base: "https://api.linkedin.com/v2/", get: { - me: 'me?projection=(id,firstName,lastName,profilePicture(displayImage~:playableStreams))', - email: 'emailAddress?q=members&projection=(elements*(handle~))', + me: "me?projection=(id,firstName,lastName,profilePicture(displayImage~:playableStreams))", + email: "emailAddress?q=members&projection=(elements*(handle~))", }, }, - facebook: '', + facebook: "", }, { - redirect_uri: 'hello.html', - display: 'page', + redirect_uri: "hello.html", + display: "page", }, ); hello.init({ - facebook: '359288236870', - windows: '000000004403AD10', + facebook: "359288236870", + windows: "000000004403AD10", }); hello.init({ yahoo: { oauth: { version: 2, - auth: 'https://api.login.yahoo.com/oauth2/request_auth', - grant: 'https://api.login.yahoo.com/oauth2/get_token', + auth: "https://api.login.yahoo.com/oauth2/request_auth", + grant: "https://api.login.yahoo.com/oauth2/get_token", base64_state: true, }, - } + }, }); -hello('facebook').login(); +hello("facebook").login(); -hello('facebook').logout(); +hello("facebook").logout(); hello - .on('auth.login', auth => { - alert('log to ' + auth.network); + .on("auth.login", auth => { + alert("log to " + auth.network); }) - .on('auth.logout', auth => { - alert('unlog from ' + auth.network); + .on("auth.logout", auth => { + alert("unlog from " + auth.network); }); -hello.getAuthResponse('facebook'); +hello.getAuthResponse("facebook"); -hello.login('facebook', null, () => { - const req = hello.getAuthResponse('facebook'); +hello.login("facebook", null, () => { + const req = hello.getAuthResponse("facebook"); }); -hello.logout('facebook'); +hello.logout("facebook"); -hello('facebook') - .api('me') +hello("facebook") + .api("me") .then( json => { - alert('Your name is ' + json.name); + alert("Your name is " + json.name); }, () => { - alert('Whoops!'); + alert("Whoops!"); }, ); const sessionstart = () => { - alert('Session has started'); + alert("Session has started"); }; -hello.on('auth.login', sessionstart); +hello.on("auth.login", sessionstart); -hello.off('auth.login', sessionstart); +hello.off("auth.login", sessionstart); -hello('facebook').login({ scope: 'friends,photos,publish' }); +hello("facebook").login({ scope: "friends,photos,publish" }); diff --git a/types/hellojs/index.d.ts b/types/hellojs/index.d.ts index 1c1df2522195aa..0116bf67d906f8 100644 --- a/types/hellojs/index.d.ts +++ b/types/hellojs/index.d.ts @@ -14,7 +14,7 @@ declare const hello: hello.HelloJSStatic; declare namespace hello { interface HelloJSUtils { extend(r: object, ...a: any[]): any; - error(code: number, message: string): { code: number, message: string }; + error(code: number, message: string): { code: number; message: string }; qs(url: string, params?: object, formatFunction?: (param: any) => string): string; param(o: object, formatFunction?: (param: any) => string): string; param(s: string, formatFunction?: (param: string) => any): any; @@ -43,7 +43,14 @@ declare namespace hello { clone(obj: T): T; xhr(method: string, url: string, headers: object, data: any, callback: HelloJSResponseCallback): XMLHttpRequest; jsonp(url: string, callback: () => void, callbackID?: string, timeout?: number): void; - post(url: string, data: any, options: object, callback: HelloJSResponseCallback, callbackID?: string, timeout?: number): void; + post( + url: string, + data: any, + options: object, + callback: HelloJSResponseCallback, + callbackID?: string, + timeout?: number, + ): void; hasBinary(data: any): boolean; isBinary(data: any): boolean; toBlob(dataURI: string): Blob | string; @@ -54,7 +61,7 @@ declare namespace hello { type HelloJSResponseCallback = (r: any, headers: any) => void; type HelloJSTokenResponseType = - "code" + | "code" | "code id_token" | "code id_token token" | "code token" @@ -124,10 +131,14 @@ declare namespace hello { } interface HelloJSStatic extends HelloJSEvent { - init(serviceAppIdsOrDefs: { [id: string]: string | HelloJSServiceDef; }, options?: HelloJSLoginOptions): void; + init(serviceAppIdsOrDefs: { [id: string]: string | HelloJSServiceDef }, options?: HelloJSLoginOptions): void; login(callback: () => void): PromiseLike; login(options?: HelloJSLoginOptions, callback?: () => void): PromiseLike; - login(network?: string, options?: HelloJSLoginOptions, callback?: () => void): PromiseLike; + login( + network?: string, + options?: HelloJSLoginOptions, + callback?: () => void, + ): PromiseLike; logout(callback?: () => void): PromiseLike; logout(options?: HelloJSLogoutOptions, callback?: () => void): PromiseLike; logout(network?: string, options?: HelloJSLogoutOptions, callback?: () => void): PromiseLike; @@ -137,7 +148,14 @@ declare namespace hello { utils: HelloJSUtils; api(options: object): PromiseLike; api(path?: string, method?: string, data?: object, callback?: (json: any) => void): PromiseLike; - api(path?: string, query?: object, method?: string, data?: object, timeout?: number, callback?: (json: any) => void): PromiseLike; + api( + path?: string, + query?: object, + method?: string, + data?: object, + timeout?: number, + callback?: (json: any) => void, + ): PromiseLike; } interface HelloJSOAuthDef { @@ -162,7 +180,7 @@ declare namespace hello { id?: string | undefined; name?: string | undefined; oauth: HelloJSOAuth2Def | HelloJSOAuth1Def; - scope?: { [id: string]: string; } | undefined; + scope?: { [id: string]: string } | undefined; scope_delim?: string | undefined; refresh?: boolean | undefined; base?: string | undefined; @@ -172,7 +190,7 @@ declare namespace hello { del?: { [id: string]: string | HelloJSUrlMappingFunction } | undefined; put?: { [id: string]: string | HelloJSUrlMappingFunction } | undefined; patch?: { [id: string]: string | HelloJSUrlMappingFunction } | undefined; - wrap?: { [id: string]: (r: any, headers: any, p: any) => void; } | undefined; + wrap?: { [id: string]: (r: any, headers: any, p: any) => void } | undefined; xhr?(p: any, query: any): void; jsonp?: ((p: any, query: any) => void) | boolean | undefined; form?: ((p: any, query: any) => void) | boolean | undefined; diff --git a/types/hellosign-embedded/hellosign-embedded-tests.ts b/types/hellosign-embedded/hellosign-embedded-tests.ts index 6f78ac2d271cd2..7a271a8c790a2f 100644 --- a/types/hellosign-embedded/hellosign-embedded-tests.ts +++ b/types/hellosign-embedded/hellosign-embedded-tests.ts @@ -1,25 +1,25 @@ -import HelloSign from 'hellosign-embedded'; +import HelloSign from "hellosign-embedded"; // init - without params new HelloSign(); // init - with params -const client = new HelloSign({ clientId: 'init123' }); +const client = new HelloSign({ clientId: "init123" }); // open - only url -client.open('http://example.org'); +client.open("http://example.org"); // open - with options -client.open('http://example.org', { +client.open("http://example.org", { allowCancel: true, - container: document.getElementById('#hellosign-container'), + container: document.getElementById("#hellosign-container"), debug: true, hideHeader: true, - redirectTo: 'https://github.com/DefinitelyTyped/DefinitelyTyped', - locale: 'en_US', + redirectTo: "https://github.com/DefinitelyTyped/DefinitelyTyped", + locale: "en_US", skipDomainVerification: true, whiteLabeling: { - page_background_color: '#f7f8f9', + page_background_color: "#f7f8f9", }, }); @@ -28,7 +28,7 @@ client.close(); // on // event as string -client.on('error', data => { +client.on("error", data => { console.log(data.code); console.log(data.signatureId); }); @@ -39,7 +39,7 @@ client.on(HelloSign.events.DECLINE, data => { // once // event as string -client.once('ready', data => { +client.once("ready", data => { console.log(data.signatureId); }); // event as enum @@ -50,14 +50,14 @@ client.once(HelloSign.events.REASSIGN, data => { // off // only name as string -client.off('message'); +client.off("message"); // only name as enum client.off(HelloSign.events.CLOSE); // name and cb as enum const cb = () => {}; client.off(HelloSign.events.CLOSE, cb); -client.off('cancel'); +client.off("cancel"); // getters client.isOpen; diff --git a/types/hellosign-embedded/index.d.ts b/types/hellosign-embedded/index.d.ts index 6fdae38c44f206..52a799d1681e6f 100644 --- a/types/hellosign-embedded/index.d.ts +++ b/types/hellosign-embedded/index.d.ts @@ -7,60 +7,60 @@ export declare namespace HelloSign { interface ClassNames { - BASE: 'x-hellosign-embedded'; - BASE_IN_MODAL: 'x-hellosign-embedded--in-modal'; - IFRAME: 'x-hellosign-embedded__iframe'; - MODAL_CLOSE: 'x-hellosign-embedded__modal-close'; - MODAL_CLOSE_BTN: 'x-hellosign-embedded__modal-close-button'; - MODAL_CONTENT: 'x-hellosign-embedded__modal-content'; - MODAL_SCREEN: 'x-hellosign-embedded__modal-screen'; + BASE: "x-hellosign-embedded"; + BASE_IN_MODAL: "x-hellosign-embedded--in-modal"; + IFRAME: "x-hellosign-embedded__iframe"; + MODAL_CLOSE: "x-hellosign-embedded__modal-close"; + MODAL_CLOSE_BTN: "x-hellosign-embedded__modal-close-button"; + MODAL_CONTENT: "x-hellosign-embedded__modal-content"; + MODAL_SCREEN: "x-hellosign-embedded__modal-screen"; } interface Events { - ERROR: 'error'; - SEND: 'send'; - CANCEL: 'cancel'; - CLOSE: 'close'; - CREATE_TEMPLATE: 'createTemplate'; - DECLINE: 'decline'; - FINISH: 'finish'; - MESSAGE: 'message'; - OPEN: 'open'; - READY: 'ready'; - REASSIGN: 'reassign'; - SIGN: 'sign'; + ERROR: "error"; + SEND: "send"; + CANCEL: "cancel"; + CLOSE: "close"; + CREATE_TEMPLATE: "createTemplate"; + DECLINE: "decline"; + FINISH: "finish"; + MESSAGE: "message"; + OPEN: "open"; + READY: "ready"; + REASSIGN: "reassign"; + SIGN: "sign"; } interface Locales { - CS_CZ: 'cs_CZ'; - DA_DK: 'da_DK'; - DE_DE: 'de_DE'; - EN_US: 'en_US'; - ES_ES: 'es_ES'; - ES_MX: 'es_MX'; - FR_FR: 'fr_FR'; - IT_IT: 'it_IT'; - JA_JP: 'ja_JP'; - NL_NL: 'nl_NL'; - PL_PL: 'pl_PL'; - PT_BR: 'pt_BR'; - SV_SE: 'sv_SE'; - ZH_CN: 'zh_CN'; + CS_CZ: "cs_CZ"; + DA_DK: "da_DK"; + DE_DE: "de_DE"; + EN_US: "en_US"; + ES_ES: "es_ES"; + ES_MX: "es_MX"; + FR_FR: "fr_FR"; + IT_IT: "it_IT"; + JA_JP: "ja_JP"; + NL_NL: "nl_NL"; + PL_PL: "pl_PL"; + PT_BR: "pt_BR"; + SV_SE: "sv_SE"; + ZH_CN: "zh_CN"; } interface Messages { - APP_CONFIGURE: 'hellosign:configure'; - APP_ERROR: 'hellosign:error'; - APP_INITIALIZE: 'hellosign:initialize'; - APP_VERIFY_DOMAIN_REQUEST: 'hellosign:verifyDomainRequest'; - APP_VERIFY_DOMAIN_RESPONSE: 'hellosign:verifyDomainResponse'; - USER_CANCEL_REQUEST: 'hellosign:userCancelRequest'; - USER_CREATE_TEMPLATE: 'hellosign:userCreateTemplate'; - USER_DECLINE_REQUEST: 'hellosign:userDeclineRequest'; - USER_FINISH_REQUEST: 'hellosign:userFinishRequest'; - USER_REASSIGN_REQUEST: 'hellosign:userReassignRequest'; - USER_SEND_REQUEST: 'hellosign:userSendRequest'; - USER_SIGN_REQUEST: 'hellosign:userSignRequest'; + APP_CONFIGURE: "hellosign:configure"; + APP_ERROR: "hellosign:error"; + APP_INITIALIZE: "hellosign:initialize"; + APP_VERIFY_DOMAIN_REQUEST: "hellosign:verifyDomainRequest"; + APP_VERIFY_DOMAIN_RESPONSE: "hellosign:verifyDomainResponse"; + USER_CANCEL_REQUEST: "hellosign:userCancelRequest"; + USER_CREATE_TEMPLATE: "hellosign:userCreateTemplate"; + USER_DECLINE_REQUEST: "hellosign:userDeclineRequest"; + USER_FINISH_REQUEST: "hellosign:userFinishRequest"; + USER_REASSIGN_REQUEST: "hellosign:userReassignRequest"; + USER_SEND_REQUEST: "hellosign:userSendRequest"; + USER_SIGN_REQUEST: "hellosign:userSignRequest"; } export interface Options { @@ -169,32 +169,44 @@ export declare namespace HelloSign { close: () => void; - on(name: Events['CLOSE'] | Events['CANCEL'] | Events['FINISH'], cb: () => void): void; - on(name: Events['CREATE_TEMPLATE'], cb: (data: CreateTemplateEventPyload) => void): void; - on(name: Events['DECLINE'], cb: (data: DeclineEventPyload) => void): void; - on(name: Events['ERROR'], cb: (data: ErrorEventPyload) => void): void; - on(name: Events['MESSAGE'], cb: (data: MessageEventPayload) => void): void; - on(name: Events['OPEN'], cb: (data: OpenEventPayload) => void): void; - on(name: Events['READY'], cb: (data: ReadyEventPayload) => void): void; - on(name: Events['REASSIGN'], cb: (data: ReassignEventPayload) => void): void; - on(name: Events['SEND'], cb: (data: SendEventPayload) => void): void; - on(name: Events['SIGN'], cb: (data: SignEventPayload) => void): void; - - once(name: Events['CLOSE'] | Events['CANCEL'] | Events['FINISH'], cb: () => void): void; - once(name: Events['CREATE_TEMPLATE'], cb: (data: CreateTemplateEventPyload) => void): void; - once(name: Events['DECLINE'], cb: (data: DeclineEventPyload) => void): void; - once(name: Events['ERROR'], cb: (data: ErrorEventPyload) => void): void; - once(name: Events['MESSAGE'], cb: (data: MessageEventPayload) => void): void; - once(name: Events['OPEN'], cb: (data: OpenEventPayload) => void): void; - once(name: Events['READY'], cb: (data: ReadyEventPayload) => void): void; - once(name: Events['REASSIGN'], cb: (data: ReassignEventPayload) => void): void; - once(name: Events['SEND'], cb: (data: SendEventPayload) => void): void; - once(name: Events['SIGN'], cb: (data: SignEventPayload) => void): void; - - off(name: Events['CLOSE'] | Events['CANCEL'] | Events['CREATE_TEMPLATE'] | Events['DECLINE'] | - Events['ERROR'] | Events['FINISH'] | Events['MESSAGE'] | Events['OPEN'] | Events['READY'] | - Events['REASSIGN'] | Events['SEND'] | Events['SIGN'], - cb?: CB): void; + on(name: Events["CLOSE"] | Events["CANCEL"] | Events["FINISH"], cb: () => void): void; + on(name: Events["CREATE_TEMPLATE"], cb: (data: CreateTemplateEventPyload) => void): void; + on(name: Events["DECLINE"], cb: (data: DeclineEventPyload) => void): void; + on(name: Events["ERROR"], cb: (data: ErrorEventPyload) => void): void; + on(name: Events["MESSAGE"], cb: (data: MessageEventPayload) => void): void; + on(name: Events["OPEN"], cb: (data: OpenEventPayload) => void): void; + on(name: Events["READY"], cb: (data: ReadyEventPayload) => void): void; + on(name: Events["REASSIGN"], cb: (data: ReassignEventPayload) => void): void; + on(name: Events["SEND"], cb: (data: SendEventPayload) => void): void; + on(name: Events["SIGN"], cb: (data: SignEventPayload) => void): void; + + once(name: Events["CLOSE"] | Events["CANCEL"] | Events["FINISH"], cb: () => void): void; + once(name: Events["CREATE_TEMPLATE"], cb: (data: CreateTemplateEventPyload) => void): void; + once(name: Events["DECLINE"], cb: (data: DeclineEventPyload) => void): void; + once(name: Events["ERROR"], cb: (data: ErrorEventPyload) => void): void; + once(name: Events["MESSAGE"], cb: (data: MessageEventPayload) => void): void; + once(name: Events["OPEN"], cb: (data: OpenEventPayload) => void): void; + once(name: Events["READY"], cb: (data: ReadyEventPayload) => void): void; + once(name: Events["REASSIGN"], cb: (data: ReassignEventPayload) => void): void; + once(name: Events["SEND"], cb: (data: SendEventPayload) => void): void; + once(name: Events["SIGN"], cb: (data: SignEventPayload) => void): void; + + off( + name: + | Events["CLOSE"] + | Events["CANCEL"] + | Events["CREATE_TEMPLATE"] + | Events["DECLINE"] + | Events["ERROR"] + | Events["FINISH"] + | Events["MESSAGE"] + | Events["OPEN"] + | Events["READY"] + | Events["REASSIGN"] + | Events["SEND"] + | Events["SIGN"], + cb?: CB, + ): void; } } diff --git a/types/hellosign-sdk/hellosign-sdk-tests.ts b/types/hellosign-sdk/hellosign-sdk-tests.ts index f1996cfb4b2ccc..d942f2ed6d48f2 100644 --- a/types/hellosign-sdk/hellosign-sdk-tests.ts +++ b/types/hellosign-sdk/hellosign-sdk-tests.ts @@ -1,53 +1,53 @@ -import * as fs from 'fs'; -import { EventResponse, Signature } from 'hellosign-sdk'; -import HelloSign = require('hellosign-sdk'); +import * as fs from "fs"; +import { EventResponse, Signature } from "hellosign-sdk"; +import HelloSign = require("hellosign-sdk"); // $ExpectType HelloSign -new HelloSign({ key: 'test', client_id: 'client_id', client_secret: 'client_secret' }); +new HelloSign({ key: "test", client_id: "client_id", client_secret: "client_secret" }); // $ExpectType HelloSign -new HelloSign({ username: 'username', password: 'password' }); +new HelloSign({ username: "username", password: "password" }); -const hsClient = new HelloSign({ key: 'test' }); +const hsClient = new HelloSign({ key: "test" }); // $ExpectType void -hsClient.setApiKey('key'); +hsClient.setApiKey("key"); // $ExpectType void -hsClient.setClientId('client id'); +hsClient.setClientId("client id"); // $ExpectType void -hsClient.setClientSecret('client secret'); +hsClient.setClientSecret("client secret"); // $ExpectType void -hsClient.setHost('host', 'port', 'protocol'); +hsClient.setHost("host", "port", "protocol"); // $ExpectType void -hsClient.setOauthToken('oauth token'); +hsClient.setOauthToken("oauth token"); // $ExpectType void -hsClient.setPort('port'); +hsClient.setPort("port"); // $ExpectType void -hsClient.setProtocol('protocol'); +hsClient.setProtocol("protocol"); // $ExpectType void hsClient.setTimeout(999); // $ExpectType void -hsClient.setUserPassAuth('username', 'password'); +hsClient.setUserPassAuth("username", "password"); // $ExpectType void -hsClient._setApiField('dev', true); +hsClient._setApiField("dev", true); // $ExpectType any -hsClient.getApiField('dev'); +hsClient.getApiField("dev"); // $ExpectType boolean hsClient.isDev(); const baseResponse: HelloSign.BaseResponse = { - resHeaders: { accept: '*' }, + resHeaders: { accept: "*" }, statusCode: 200, - statusMessage: 'OK', + statusMessage: "OK", }; const listInfo: HelloSign.ListInfo = { @@ -62,10 +62,10 @@ const listInfo: HelloSign.ListInfo = { // Account module const accountResponse: HelloSign.AccountResponse = { account: { - callback_url: 'callback_url', - role_code: 'code', - account_id: 'account_id', - email_address: 'email_address', + callback_url: "callback_url", + role_code: "code", + account_id: "account_id", + email_address: "email_address", is_locked: true, is_paid_hs: true, is_paid_hf: false, @@ -82,81 +82,81 @@ const accountResponse: HelloSign.AccountResponse = { hsClient.account.get(); // $ExpectType Promise -hsClient.account.update({ callback_url: 'callback_url' }); +hsClient.account.update({ callback_url: "callback_url" }); // $ExpectType Promise -hsClient.account.create({ email_address: 'email_address' }); +hsClient.account.create({ email_address: "email_address" }); // $ExpectType Promise -hsClient.account.verify({ email_address: 'email_address' }); +hsClient.account.verify({ email_address: "email_address" }); // SignatureRequestModule const signatureRequestResponse: HelloSign.SignatureRequestResponse = { signature_request: { test_mode: 0, - signature_request_id: 'signature_request_id', - requester_email_address: 'requester_email_address', - title: 'title', - original_title: 'original_title', - subject: 'subject', - message: 'message', + signature_request_id: "signature_request_id", + requester_email_address: "requester_email_address", + title: "title", + original_title: "original_title", + subject: "subject", + message: "message", metadata: { - key: 'value', + key: "value", }, created_at: 1, is_complete: true, is_declined: false, has_error: false, - final_copy_uri: 'final_copy_uri', - files_url: 'files_url', - signing_url: 'signing_url', - details_url: 'details_url', - cc_email_addresses: ['cc_email_addresses'], - signing_redirect_url: 'signing_redirect_url', - template_ids: ['template-id'], + final_copy_uri: "final_copy_uri", + files_url: "files_url", + signing_url: "signing_url", + details_url: "details_url", + cc_email_addresses: ["cc_email_addresses"], + signing_redirect_url: "signing_redirect_url", + template_ids: ["template-id"], custom_fields: [ { - name: 'name', - type: 'text', - value: 'value', + name: "name", + type: "text", + value: "value", required: true, - api_id: 'api_id', - editor: 'editor', + api_id: "api_id", + editor: "editor", }, { - name: 'name', - type: 'checkbox', + name: "name", + type: "checkbox", value: true, required: true, - api_id: 'api_id', - editor: 'editor', + api_id: "api_id", + editor: "editor", }, ], response_data: [ { - name: 'name', - type: 'type', - value: 'value', + name: "name", + type: "type", + value: "value", required: true, - api_id: 'api_id', - signature_id: 'signature_id', + api_id: "api_id", + signature_id: "signature_id", }, ], signatures: [ { - signature_id: 'signature_id', - signer_email_address: 'signer_email_address', - signer_name: 'signer_name', - signer_role: 'signer_role', + signature_id: "signature_id", + signer_email_address: "signer_email_address", + signer_name: "signer_name", + signer_role: "signer_role", order: 1, - status_code: 'awaiting_signature', - decline_reason: 'decline_reason', + status_code: "awaiting_signature", + decline_reason: "decline_reason", signed_at: 1, last_viewed_at: 2, last_reminded_at: 3, has_pin: false, - reassigned_by: 'reassigned_by', - reassignment_reason: 'reassignment_reason', + reassigned_by: "reassigned_by", + reassignment_reason: "reassignment_reason", error: null, }, ], @@ -171,58 +171,58 @@ const signatureListRequestResponse: HelloSign.SignatureListRequestResponse = { }; // $ExpectType Promise -hsClient.signatureRequest.get('signature_request_id'); +hsClient.signatureRequest.get("signature_request_id"); // $ExpectType Promise -hsClient.signatureRequest.list({ page: 0, page_size: 10, query: 'query' }); +hsClient.signatureRequest.list({ page: 0, page_size: 10, query: "query" }); // $ExpectType Promise -hsClient.signatureRequest.send({ signers: [{ email_address: 'email_address', name: 'name' }] }); +hsClient.signatureRequest.send({ signers: [{ email_address: "email_address", name: "name" }] }); // $ExpectType Promise hsClient.signatureRequest.sendWithTemplate({ - signers: [{ email_address: 'email_address', name: 'name' }], - template_id: 'template_id', + signers: [{ email_address: "email_address", name: "name" }], + template_id: "template_id", }); // $ExpectType Promise -hsClient.signatureRequest.createEmbedded({ signers: [{ email_address: 'email_address', name: 'name' }] }); +hsClient.signatureRequest.createEmbedded({ signers: [{ email_address: "email_address", name: "name" }] }); // $ExpectType Promise hsClient.signatureRequest.createEmbeddedWithTemplate({ - signers: [{ email_address: 'email_address', name: 'name' }], - template_id: 'template_id', + signers: [{ email_address: "email_address", name: "name" }], + template_id: "template_id", }); // $ExpectType Promise -hsClient.signatureRequest.remind('signature_request_id', {}); +hsClient.signatureRequest.remind("signature_request_id", {}); // $ExpectType Promise -hsClient.signatureRequest.download('signature_request_id'); +hsClient.signatureRequest.download("signature_request_id"); // $ExpectType Promise<{ file_url: string; expires_at: Date; } & BaseResponse> -hsClient.signatureRequest.download('signature_request_id', { file_type: 'pdf', get_url: true }); +hsClient.signatureRequest.download("signature_request_id", { file_type: "pdf", get_url: true }); // $ExpectType Promise<{ data_uri: string; expires_at: Date; } & BaseResponse> -hsClient.signatureRequest.download('signature_request_id', { file_type: 'pdf', get_data_uri: true }); +hsClient.signatureRequest.download("signature_request_id", { file_type: "pdf", get_data_uri: true }); // $ExpectType Promise -hsClient.signatureRequest.cancel('signature_request_id'); +hsClient.signatureRequest.cancel("signature_request_id"); // $ExpectType Promise -hsClient.signatureRequest.removeAccess('signature_request_id'); +hsClient.signatureRequest.removeAccess("signature_request_id"); // $ExpectType Promise -hsClient.signatureRequest.releaseHold('signature_request_id'); +hsClient.signatureRequest.releaseHold("signature_request_id"); export const eventHandler = async (data: EventResponse): Promise => { const eventType = data.event.event_type; const eventTime: string = data.event.event_time; switch (eventType) { - case 'signature_request_signed': + case "signature_request_signed": return signatureRequestSigned(data); - case 'signature_request_downloadable': + case "signature_request_downloadable": return signatureRequestDownloadable(data); default: return; @@ -232,52 +232,52 @@ export const eventHandler = async (data: EventResponse): Promise => { // EmbeddedModule const embeddedResponse: HelloSign.EmbeddedResponse = { embedded: { - sign_url: 'sign_url', + sign_url: "sign_url", expires_at: 1, - edit_url: 'edit_url', + edit_url: "edit_url", }, ...baseResponse, }; // $ExpectType Promise -hsClient.embedded.getSignUrl('signature_id'); +hsClient.embedded.getSignUrl("signature_id"); // $ExpectType Promise -hsClient.embedded.getEditUrl('template_id'); +hsClient.embedded.getEditUrl("template_id"); // $ExpectType Promise -hsClient.embedded.postEditUrl('template_id', { template_id: 'template_id' }); +hsClient.embedded.postEditUrl("template_id", { template_id: "template_id" }); // OAuthModule const oauthResponse: HelloSign.OAuthResponse = { oauth: { - refresh_token: 'refresh_token', + refresh_token: "refresh_token", }, ...baseResponse, }; // $ExpectType Promise -hsClient.oauth.getToken({ state: 'state', code: 'code' }); +hsClient.oauth.getToken({ state: "state", code: "code" }); // $ExpectType Promise -hsClient.oauth.refreshToken('refresh_token'); +hsClient.oauth.refreshToken("refresh_token"); // TeamModule const teamResponse: HelloSign.TeamResponse = { team: { - name: 'name', + name: "name", accounts: [ { - account_id: 'account_id', - email_address: 'email_address', + account_id: "account_id", + email_address: "email_address", is_locked: false, - role_code: 'role_code', + role_code: "role_code", }, ], invited_accounts: [ { - account_id: 'account_id', - email_address: 'email_address', + account_id: "account_id", + email_address: "email_address", }, ], }, @@ -288,84 +288,84 @@ const teamResponse: HelloSign.TeamResponse = { hsClient.team.get(); // $ExpectType Promise -hsClient.team.create({ name: 'name' }); +hsClient.team.create({ name: "name" }); // $ExpectType Promise -hsClient.team.update({ name: 'name' }); +hsClient.team.update({ name: "name" }); // $ExpectType Promise hsClient.team.destroy(); // $ExpectType Promise -hsClient.team.addMember({ email_address: 'email_address', account_id: 'account_id' }); +hsClient.team.addMember({ email_address: "email_address", account_id: "account_id" }); // $ExpectType Promise hsClient.team.removeMember({ - email_address: 'email_address', - account_id: 'account_id', - new_owner_email_address: 'new_owner_email_address', + email_address: "email_address", + account_id: "account_id", + new_owner_email_address: "new_owner_email_address", }); // TemplateModule const customField: HelloSign.CustomFieldTemplate = { - name: '', - type: '', - signer: '', + name: "", + type: "", + signer: "", x: 1, y: 1, width: 100, height: 100, required: true, - api_id: '', - group: '', + api_id: "", + group: "", avg_text_length: { num_lines: 1, num_chars_per_line: 20, }, - named_form_fields: '', - reusable_form_id: '', + named_form_fields: "", + reusable_form_id: "", }; const templateResponse: HelloSign.TemplateResponse = { template: { - template_id: '', - title: '', - message: '', + template_id: "", + title: "", + message: "", metadata: { - key: 'value', + key: "value", }, signer_roles: [ { - name: '', + name: "", order: 1, }, ], cc_roles: [ { - name: 'name', + name: "name", }, ], documents: [ { - name: '', + name: "", index: 0, field_groups: [ { - name: 'name', - rule: 'rule', + name: "name", + rule: "rule", }, ], form_fields: [ { - api_id: '', - name: '', - type: '', + api_id: "", + name: "", + type: "", x: 1, y: 2, width: 100, height: 100, required: true, - group: 'group', + group: "group", }, ], custom_fields: [customField], @@ -388,39 +388,39 @@ const templatesReponse: HelloSign.TemplatesResponse = { }; // $ExpectType Promise -hsClient.template.get('template_id'); +hsClient.template.get("template_id"); // $ExpectType Promise -hsClient.template.list({ page: 0, page_size: 10, query: 'query' }); +hsClient.template.list({ page: 0, page_size: 10, query: "query" }); // $ExpectType Promise -hsClient.template.addUser('template_id', { email_address: 'email_address', account_id: 'account_id' }); +hsClient.template.addUser("template_id", { email_address: "email_address", account_id: "account_id" }); // $ExpectType Promise -hsClient.template.removeUser('template_id', { email_address: 'email_address', account_id: 'account_id' }); +hsClient.template.removeUser("template_id", { email_address: "email_address", account_id: "account_id" }); // $ExpectType Promise hsClient.template.createEmbeddedDraft(templateResponse.template); // $ExpectType Promise -hsClient.template.delete('template_id'); +hsClient.template.delete("template_id"); // $ExpectType Promise -hsClient.template.files('template_id'); +hsClient.template.files("template_id"); // $ExpectType Promise<{ file_url: string; expires_at: Date; } & BaseResponse> -hsClient.template.files('template_id', { file_type: 'pdf', get_url: true }); +hsClient.template.files("template_id", { file_type: "pdf", get_url: true }); // $ExpectType Promise<{ data_uri: string; expires_at: Date; } & BaseResponse> -hsClient.template.files('template_id', { file_type: 'pdf', get_data_uri: true }); +hsClient.template.files("template_id", { file_type: "pdf", get_data_uri: true }); // UnclaimedDraftModule const unclamaimedDraftResponse: HelloSign.UnclaimedDraftResponse = { unclaimed_draft: { - signature_request_id: 'signature_request_id', - claim_url: 'claim_url', - signing_redirect_url: 'signing_redirect_url', - requesting_redirect_url: 'requesting_redirect_url', + signature_request_id: "signature_request_id", + claim_url: "claim_url", + signing_redirect_url: "signing_redirect_url", + requesting_redirect_url: "requesting_redirect_url", expires_at: 1, test_mode: 1, }, @@ -428,36 +428,36 @@ const unclamaimedDraftResponse: HelloSign.UnclaimedDraftResponse = { }; // $ExpectType Promise -hsClient.unclaimedDraft.create({ type: 'type' }); +hsClient.unclaimedDraft.create({ type: "type" }); // $ExpectType Promise -hsClient.unclaimedDraft.createEmbedded({ type: 'type' }); +hsClient.unclaimedDraft.createEmbedded({ type: "type" }); // $ExpectType Promise -hsClient.unclaimedDraft.createEmbeddedWithTemplate({ type: 'type' }); +hsClient.unclaimedDraft.createEmbeddedWithTemplate({ type: "type" }); // $ExpectType Promise -hsClient.unclaimedDraft.editAndResend('request_id', { type: 'type' }); +hsClient.unclaimedDraft.editAndResend("request_id", { type: "type" }); // ApiAppModule const apiAppResponse: HelloSign.ApiAppResponse = { api_app: { - client_id: '', + client_id: "", created_at: 1, - name: '', - domain: '', - callback_url: '', + name: "", + domain: "", + callback_url: "", is_approved: true, owner_account: { - account_id: '', - email_address: '', + account_id: "", + email_address: "", }, options: { can_insert_everywhere: true, }, oauth: null, white_labeling_options: { - key: 'value', + key: "value", }, }, ...baseResponse, @@ -470,19 +470,19 @@ const apiAppListResponse: HelloSign.ApiAppListResponse = { }; // $ExpectType Promise -hsClient.apiApp.get('client_id'); +hsClient.apiApp.get("client_id"); // $ExpectType Promise hsClient.apiApp.list({ page: 1, page_size: 20 }); // $ExpectType Promise -hsClient.apiApp.create('client_id', { name: 'name' }); +hsClient.apiApp.create("client_id", { name: "name" }); // $ExpectType Promise -hsClient.apiApp.update('client_id', { name: 'name' }); +hsClient.apiApp.update("client_id", { name: "name" }); // $ExpectType Promise -hsClient.apiApp.delete('client_id'); +hsClient.apiApp.delete("client_id"); const signatureRequestSigned = async (data: EventResponse) => { const { ...metadata } = data.signature_request.metadata; @@ -492,30 +492,30 @@ const signatureRequestSigned = async (data: EventResponse) => { // advisor signed const { signer_email_address: advisorEmail, signer_name: advisorName } = signatures[0]; const { signer_email_address: investorEmail, signer_name: investorName } = signatures[1]; - if (signatures[1].status_code !== 'awaiting_signature') return; + if (signatures[1].status_code !== "awaiting_signature") return; } else if ( - signatures.length === 2 && - signatures[1].signature_id === data.event.event_metadata.related_signature_id + signatures.length === 2 + && signatures[1].signature_id === data.event.event_metadata.related_signature_id ) { } else if ( - signatures.length === 1 && - signatures[0].signature_id === data.event.event_metadata.related_signature_id + signatures.length === 1 + && signatures[0].signature_id === data.event.event_metadata.related_signature_id ) { } else { - throw new Error('SIGNATURE DOES NOT MATCH EXPECTED DETAILS'); + throw new Error("SIGNATURE DOES NOT MATCH EXPECTED DETAILS"); } }; const signatureRequestDownloadable = async (data: EventResponse) => { - const allSigned = data.signature_request.signatures.every(signature => signature.status_code === 'signed'); + const allSigned = data.signature_request.signatures.every(signature => signature.status_code === "signed"); if (!allSigned) return; const { ...metadata } = data.signature_request.metadata; const fileStream = await hsClient.signatureRequest.download(data.signature_request.signature_request_id, { - file_type: 'pdf', + file_type: "pdf", }); - const file = fs.createWriteStream('TEST'); + const file = fs.createWriteStream("TEST"); fileStream.pipe(file); const signatures = data.signature_request.signatures; @@ -527,7 +527,7 @@ const signatureRequestDownloadable = async (data: EventResponse) => { } else if (signatures.length === 1) { sigA = signatures[0]; } else { - throw new Error('SIGNATURE DOES NOT MATCH EXPECTED DETAILS'); + throw new Error("SIGNATURE DOES NOT MATCH EXPECTED DETAILS"); } const { signer_email_address, signer_name, ...sig } = sigA; @@ -545,7 +545,7 @@ export const getSignatureData = async (sigReqId: string) => { } else if (signatures.length === 1) { sigA = signatures[0]; } else { - throw new Error('SIGNATURE DOES NOT MATCH EXPECTED DETAILS'); + throw new Error("SIGNATURE DOES NOT MATCH EXPECTED DETAILS"); } const { signer_email_address: sigAEmail, signer_name: sigAName } = sigA; @@ -563,34 +563,34 @@ export const getSignatureData = async (sigReqId: string) => { export const getSignatureURL = async (sigReqId: string) => { const data = await hsClient.signatureRequest.get(sigReqId); const signatures = data.signature_request.signatures; - const signature = signatures.find(sig => sig.status_code === 'awaiting_signature'); - if (!signature) throw new Error('Signature awaiting not found'); + const signature = signatures.find(sig => sig.status_code === "awaiting_signature"); + if (!signature) throw new Error("Signature awaiting not found"); const urlRequest = await hsClient.embedded.getSignUrl(signature.signature_id); return urlRequest.embedded.sign_url; }; export const sendSigningRequest = async (pdfFilePath: string) => { const metadata = { - documentType: 'TEST', + documentType: "TEST", }; const data = await hsClient.signatureRequest.createEmbedded({ test_mode: 0 || 1, - clientId: 'TEST', - subject: 'TEST', + clientId: "TEST", + subject: "TEST", signers: [ { - email_address: 'test@example.com', - name: 'Testy McTest', - role: 'Signer', + email_address: "test@example.com", + name: "Testy McTest", + role: "Signer", }, ], file: [pdfFilePath], form_fields_per_document: [ [ { - api_id: 'test1', - type: 'signature', + api_id: "test1", + type: "signature", x: 370, y: 689, width: 223, @@ -600,8 +600,8 @@ export const sendSigningRequest = async (pdfFilePath: string) => { page: 10, }, { - api_id: 'test2', - type: 'date_signed', + api_id: "test2", + type: "date_signed", x: 360, y: 742, width: 120, @@ -611,8 +611,8 @@ export const sendSigningRequest = async (pdfFilePath: string) => { page: 10, }, { - api_id: 'test3', - type: 'signature', + api_id: "test3", + type: "signature", x: 318, y: 722, width: 281, @@ -622,8 +622,8 @@ export const sendSigningRequest = async (pdfFilePath: string) => { page: 0, }, { - api_id: 'test4', - type: 'date_signed', + api_id: "test4", + type: "date_signed", x: 54, y: 730, width: 104, @@ -633,8 +633,8 @@ export const sendSigningRequest = async (pdfFilePath: string) => { page: 1, }, { - api_id: 'signature_declaration', - type: 'signature', + api_id: "signature_declaration", + type: "signature", x: 306, y: 656, width: 307, @@ -644,8 +644,8 @@ export const sendSigningRequest = async (pdfFilePath: string) => { page: 22, }, { - api_id: 'date_declaration', - type: 'date_signed', + api_id: "date_declaration", + type: "date_signed", x: 350, y: 714, width: 120, @@ -659,7 +659,7 @@ export const sendSigningRequest = async (pdfFilePath: string) => { metadata, }); const signatures = data.signature_request.signatures; - const signature = signatures.find((sig: any) => sig.status_code === 'awaiting_signature')!; + const signature = signatures.find((sig: any) => sig.status_code === "awaiting_signature")!; const signed_at: number | null = signature.signed_at; const urlRequest = await hsClient.embedded.getSignUrl(signature.signature_id); return { @@ -670,25 +670,25 @@ export const sendSigningRequest = async (pdfFilePath: string) => { export const sendSigningRequestWithTemplates = async (pdfFilePath: string) => { const metadata = { - documentType: 'TEST', + documentType: "TEST", }; const data = await hsClient.signatureRequest.createEmbedded({ test_mode: 0 || 1, - clientId: 'TEST', - subject: 'TEST', + clientId: "TEST", + subject: "TEST", signers: [ { - email_address: 'test@example.com', - name: 'Testy McTest', - role: 'Signer', + email_address: "test@example.com", + name: "Testy McTest", + role: "Signer", }, ], - template_id: 'test template id', + template_id: "test template id", metadata, }); const signatures = data.signature_request.signatures; - const signature = signatures.find((sig: any) => sig.status_code === 'awaiting_signature')!; + const signature = signatures.find((sig: any) => sig.status_code === "awaiting_signature")!; const signed_at: number | null = signature.signed_at; const urlRequest = await hsClient.embedded.getSignUrl(signature.signature_id); return { diff --git a/types/hellosign-sdk/index.d.ts b/types/hellosign-sdk/index.d.ts index 0207b78ae80698..112bd4ae3d9b54 100644 --- a/types/hellosign-sdk/index.d.ts +++ b/types/hellosign-sdk/index.d.ts @@ -5,7 +5,7 @@ // TypeScript Version: 3.8 /// -import { IncomingMessage } from 'http'; +import { IncomingMessage } from "http"; declare class HelloSign { constructor(options: HelloSign.HelloSignOptions); @@ -49,22 +49,22 @@ declare namespace HelloSign { type HelloSignOptions = | { - key: string; - } + key: string; + } | { - username: string; - password: string; - } + username: string; + password: string; + } | { - key: string; - client_id: string; - client_secret: string; - }; + key: string; + client_id: string; + client_secret: string; + }; interface BaseResponse { - resHeaders: IncomingMessage['headers']; - statusCode?: IncomingMessage['statusCode']; - statusMessage?: IncomingMessage['statusMessage']; + resHeaders: IncomingMessage["headers"]; + statusCode?: IncomingMessage["statusCode"]; + statusMessage?: IncomingMessage["statusMessage"]; } interface ListInfo { @@ -109,7 +109,7 @@ declare namespace HelloSign { signer_name: string; signer_role: string; order: number; - status_code: string | 'awaiting_signature' | 'signed' | 'declined'; + status_code: string | "awaiting_signature" | "signed" | "declined"; decline_reason: string; signed_at: number | null; last_viewed_at: number | null; @@ -121,15 +121,15 @@ declare namespace HelloSign { } type Field = | string - | 'text' - | 'checkbox' - | 'date_signed' - | 'dropdown' - | 'initials' - | 'radio' - | 'signature' - | 'text-merge' - | 'checkbox-merge'; + | "text" + | "checkbox" + | "date_signed" + | "dropdown" + | "initials" + | "radio" + | "signature" + | "text-merge" + | "checkbox-merge"; interface SignatureRequest { test_mode: number; signature_request_id: string; @@ -154,21 +154,23 @@ declare namespace HelloSign { signing_redirect_url: string; template_ids: null | string[]; custom_fields?: - | Array<{ - name: string; - type: 'text'; - value: string; - required: boolean; - api_id: string; - editor: string; - } | { - name: string; - type: 'checkbox'; - value: boolean; - required: boolean; - api_id: string; - editor: string; - }> + | Array< + { + name: string; + type: "text"; + value: string; + required: boolean; + api_id: string; + editor: string; + } | { + name: string; + type: "checkbox"; + value: boolean; + required: boolean; + api_id: string; + editor: string; + } + > | undefined; response_data: Array<{ api_id: string; @@ -192,16 +194,16 @@ declare namespace HelloSign { signer: number; name?: string | undefined; validation_type?: - | 'numbers_only' - | 'letters_only' - | 'phone_number' - | 'bank_routing_number' - | 'bank_account_number' - | 'email_address' - | 'zip_code' - | 'social_security_number' - | 'employer_identification_number' - | 'custom_regex' + | "numbers_only" + | "letters_only" + | "phone_number" + | "bank_routing_number" + | "bank_account_number" + | "email_address" + | "zip_code" + | "social_security_number" + | "employer_identification_number" + | "custom_regex" | undefined; } interface SignatureRequestRequestOptions { @@ -224,19 +226,19 @@ declare namespace HelloSign { }>; attachments?: | Array<{ - name?: string | undefined; - instructions?: string | undefined; - signer_index?: string | undefined; - required?: boolean | undefined; - }> + name?: string | undefined; + instructions?: string | undefined; + signer_index?: string | undefined; + required?: boolean | undefined; + }> | undefined; custom_fields?: | Array<{ - name: string; - value: string | boolean; - editor?: string | undefined; - required?: boolean | undefined; - }> + name: string; + value: string | boolean; + editor?: string | undefined; + required?: boolean | undefined; + }> | undefined; cc_email_addresses?: string[] | undefined; ccs?: Record | undefined; @@ -248,23 +250,23 @@ declare namespace HelloSign { form_fields_per_document?: FormField[][] | undefined; signing_options?: | { - draw?: boolean | undefined; - type?: boolean | undefined; - upload?: boolean | undefined; - phone?: boolean | undefined; - default: string; - } + draw?: boolean | undefined; + type?: boolean | undefined; + upload?: boolean | undefined; + phone?: boolean | undefined; + default: string; + } | undefined; field_options?: | { - date_format: - | 'MM / DD / YYYY' - | 'MM - DD - YYYY' - | 'DD / MM / YYYY' - | 'DD - MM - YYYY' - | 'YYYY / MM / DD' - | 'YYYY - MM - DD'; - } + date_format: + | "MM / DD / YYYY" + | "MM - DD - YYYY" + | "DD / MM / YYYY" + | "DD - MM - YYYY" + | "YYYY / MM / DD" + | "YYYY - MM - DD"; + } | undefined; signing_redirect_url?: string | undefined; } @@ -278,7 +280,7 @@ declare namespace HelloSign { file_url?: string | undefined; expires_at?: number | undefined; } - type FilesOptions = { file_type: 'pdf'; get_url?: boolean; get_data_uri?: boolean } | { file_type: 'zip' }; + type FilesOptions = { file_type: "pdf"; get_url?: boolean; get_data_uri?: boolean } | { file_type: "zip" }; interface SignatureRequestModule { get(signatureRequestId: string): Promise; list(params?: { @@ -293,19 +295,18 @@ declare namespace HelloSign { requestId: string, options?: Options, ): Promise< - Options extends { file_type: 'pdf'; get_url: true } - ? { file_url: string; expires_at: Date } & BaseResponse - : Options extends { file_type: 'pdf'; get_data_uri: true } - ? { data_uri: string; expires_at: Date } & BaseResponse + Options extends { file_type: "pdf"; get_url: true } ? { file_url: string; expires_at: Date } & BaseResponse + : Options extends { file_type: "pdf"; get_data_uri: true } + ? { data_uri: string; expires_at: Date } & BaseResponse : IncomingMessage >; cancel(requestId: string): Promise; removeAccess(requestId: string): Promise; createEmbedded( - options: Omit, + options: Omit, ): Promise; createEmbeddedWithTemplate( - options: Omit, + options: Omit, ): Promise; releaseHold(requestId: string): Promise; } @@ -334,9 +335,9 @@ declare namespace HelloSign { force_subject_message?: any; editor_options?: | { - allow_edit_signers?: boolean | undefined; - allow_edit_documents?: boolean | undefined; - } + allow_edit_signers?: boolean | undefined; + allow_edit_documents?: boolean | undefined; + } | undefined; } interface EmbeddedModule { @@ -351,7 +352,7 @@ declare namespace HelloSign { end_date: string; report_type: string[]; } - interface Report extends Omit { + interface Report extends Omit { success?: string | undefined; } interface ReportResponse extends BaseResponse { @@ -400,8 +401,8 @@ declare namespace HelloSign { } interface TeamModule { get(): Promise; - create(options: Pick): Promise; - update(options: Pick): Promise; + create(options: Pick): Promise; + update(options: Pick): Promise; destroy(): Promise; addMember(options: AccountIdOrEmailRequestOptions): Promise; removeMember( @@ -434,8 +435,8 @@ declare namespace HelloSign { reusable_form_id: string; } - interface Template - extends Partial<{ + interface Template extends + Partial<{ template_id: string; title: string; message: string; @@ -473,7 +474,8 @@ declare namespace HelloSign { is_embedded: boolean; can_edit: boolean; is_locked: boolean; - }> {} + }> + {} interface TemplateResponse extends BaseResponse { template: Template; } @@ -495,10 +497,9 @@ declare namespace HelloSign { templateId: string, options?: Options, ) => Promise< - Options extends { file_type: 'pdf'; get_url: true } - ? { file_url: string; expires_at: Date } & BaseResponse - : Options extends { file_type: 'pdf'; get_data_uri: true } - ? { data_uri: string; expires_at: Date } & BaseResponse + Options extends { file_type: "pdf"; get_url: true } ? { file_url: string; expires_at: Date } & BaseResponse + : Options extends { file_type: "pdf"; get_data_uri: true } + ? { data_uri: string; expires_at: Date } & BaseResponse : IncomingMessage >; } @@ -523,26 +524,26 @@ declare namespace HelloSign { message?: string | undefined; signers?: | Array<{ - email_address?: string | undefined; - name?: string | undefined; - order?: number | undefined; - }> + email_address?: string | undefined; + name?: string | undefined; + order?: number | undefined; + }> | undefined; attachments?: | Array<{ - name?: string | undefined; - instructions?: string | undefined; - signer_index?: string | undefined; - required?: boolean | undefined; - }> + name?: string | undefined; + instructions?: string | undefined; + signer_index?: string | undefined; + required?: boolean | undefined; + }> | undefined; custom_fields?: | Array<{ - name: string; - value: string | boolean; - editor?: string | undefined; - required?: boolean | undefined; - }> + name: string; + value: string | boolean; + editor?: string | undefined; + required?: boolean | undefined; + }> | undefined; cc_email_addresses?: string[] | undefined; signing_redirect_url?: string | undefined; @@ -555,23 +556,23 @@ declare namespace HelloSign { form_fields_per_document?: FormField[][] | undefined; signing_options?: | { - draw?: boolean | undefined; - type?: boolean | undefined; - upload?: boolean | undefined; - phone?: boolean | undefined; - default: string; - } + draw?: boolean | undefined; + type?: boolean | undefined; + upload?: boolean | undefined; + phone?: boolean | undefined; + default: string; + } | undefined; field_options?: | { - date_format: - | 'MM / DD / YYYY' - | 'MM - DD - YYYY' - | 'DD / MM / YYYY' - | 'DD - MM - YYYY' - | 'YYYY / MM / DD' - | 'YYYY - MM - DD'; - } + date_format: + | "MM / DD / YYYY" + | "MM - DD - YYYY" + | "DD / MM / YYYY" + | "DD - MM - YYYY" + | "YYYY / MM / DD" + | "YYYY - MM - DD"; + } | undefined; is_for_embedded_signing?: number | undefined; } @@ -586,25 +587,25 @@ declare namespace HelloSign { } type HellosignEvents = - | 'signature_request_viewed' - | 'signature_request_signed' - | 'signature_request_downloadable' - | 'signature_request_sent' - | 'signature_request_declined' - | 'signature_request_reassigned' - | 'signature_request_remind' - | 'signature_request_all_signed' - | 'signature_request_email_bounce' - | 'signature_request_invalid' - | 'signature_request_canceled' - | 'signature_request_prepared' - | 'file_error' - | 'unknown_error' - | 'sign_url_invalid' - | 'account_confirmed' - | 'template_created' - | 'template_error' - | 'callback_test'; + | "signature_request_viewed" + | "signature_request_signed" + | "signature_request_downloadable" + | "signature_request_sent" + | "signature_request_declined" + | "signature_request_reassigned" + | "signature_request_remind" + | "signature_request_all_signed" + | "signature_request_email_bounce" + | "signature_request_invalid" + | "signature_request_canceled" + | "signature_request_prepared" + | "file_error" + | "unknown_error" + | "sign_url_invalid" + | "account_confirmed" + | "template_created" + | "template_error" + | "callback_test"; interface Event { /** @@ -628,11 +629,12 @@ declare namespace HelloSign { >; }; } - type EventResponse = Partial & - Partial & - Partial & - Event & - Response; + type EventResponse = + & Partial + & Partial + & Partial + & Event + & Response; interface ApiApp { client_id: string; @@ -669,15 +671,15 @@ declare namespace HelloSign { custom_logo_file?: any; oauth?: | { - callback_url: string; - scopes: string; - } + callback_url: string; + scopes: string; + } | undefined; white_labeling_options?: any[] | undefined; options?: | { - can_insert_everywhere?: boolean | undefined; - } + can_insert_everywhere?: boolean | undefined; + } | undefined; } interface ApiAppModule { diff --git a/types/hepburn/hepburn-tests.ts b/types/hepburn/hepburn-tests.ts index a74529eca5e546..ab9b8d03f0b804 100644 --- a/types/hepburn/hepburn-tests.ts +++ b/types/hepburn/hepburn-tests.ts @@ -1,4 +1,4 @@ -import hepburn = require('hepburn'); +import hepburn = require("hepburn"); import { cleanRomaji, containsHiragana, @@ -10,26 +10,26 @@ import { splitRomaji, toHiragana, toKatakana, -} from 'hepburn'; +} from "hepburn"; -hepburn.fromKana('ひらがな'); // $ExpectType string -hepburn.toHiragana('HIRAGANA'); // $ExpectType string -hepburn.toKatakana('TŌKYŌ'); // $ExpectType string -hepburn.cleanRomaji('SYUNNEI'); // $ExpectType string -hepburn.splitKana('ひらがな'); // $ExpectType string[] -hepburn.splitRomaji('TŌKYŌ'); // $ExpectType string[] -hepburn.containsHiragana('ひらがな'); // $ExpectType boolean -hepburn.containsKatakana('トーキョー'); // $ExpectType boolean -hepburn.containsKana('ひらがな'); // $ExpertType boolean -hepburn.containsKanji('漢字'); // $ExportType boolean +hepburn.fromKana("ひらがな"); // $ExpectType string +hepburn.toHiragana("HIRAGANA"); // $ExpectType string +hepburn.toKatakana("TŌKYŌ"); // $ExpectType string +hepburn.cleanRomaji("SYUNNEI"); // $ExpectType string +hepburn.splitKana("ひらがな"); // $ExpectType string[] +hepburn.splitRomaji("TŌKYŌ"); // $ExpectType string[] +hepburn.containsHiragana("ひらがな"); // $ExpectType boolean +hepburn.containsKatakana("トーキョー"); // $ExpectType boolean +hepburn.containsKana("ひらがな"); // $ExpertType boolean +hepburn.containsKanji("漢字"); // $ExportType boolean -fromKana('ひらがな'); // $ExpectType string -toHiragana('HIRAGANA'); // $ExpectType string -toKatakana('TŌKYŌ'); // $ExpectType string -cleanRomaji('SYUNNEI'); // $ExpectType string -splitKana('ひらがな'); // $ExpectType string[] -splitRomaji('TŌKYŌ'); // $ExpectType string[] -containsHiragana('ひらがな'); // $ExpectType boolean -containsKatakana('トーキョー'); // $ExpectType boolean -containsKana('ひらがな'); // $ExpertType boolean -containsKanji('漢字'); // $ExportType boolean +fromKana("ひらがな"); // $ExpectType string +toHiragana("HIRAGANA"); // $ExpectType string +toKatakana("TŌKYŌ"); // $ExpectType string +cleanRomaji("SYUNNEI"); // $ExpectType string +splitKana("ひらがな"); // $ExpectType string[] +splitRomaji("TŌKYŌ"); // $ExpectType string[] +containsHiragana("ひらがな"); // $ExpectType boolean +containsKatakana("トーキョー"); // $ExpectType boolean +containsKana("ひらがな"); // $ExpertType boolean +containsKanji("漢字"); // $ExportType boolean diff --git a/types/heredatalens/heredatalens-tests.ts b/types/heredatalens/heredatalens-tests.ts index 6b66cc9de578d2..a21ae5adce6c13 100644 --- a/types/heredatalens/heredatalens-tests.ts +++ b/types/heredatalens/heredatalens-tests.ts @@ -7,75 +7,77 @@ */ let serviceOptions: H.datalens.Service.Options = { - subDomain: 'sub', - version: 'version', - access_token: 'token', - refresh_token: 'token', - domainSharding: ['a', 'b'], - baseUrl: 'url' + subDomain: "sub", + version: "version", + access_token: "token", + refresh_token: "token", + domainSharding: ["a", "b"], + baseUrl: "url", }; let queryTileProviderTileParamNames: H.datalens.QueryTileProvider.TileParamNames = { - x: 'x', - y: 'y', - z: 'z' + x: "x", + y: "y", + z: "z", }; let queryTileProviderOptions: H.datalens.QueryTileProvider.Options = { - queryId: 'id', - queryParams: 'params', - tileParamNames: queryTileProviderTileParamNames + queryId: "id", + queryParams: "params", + tileParamNames: queryTileProviderTileParamNames, }; let service: H.datalens.Service = new H.datalens.Service(serviceOptions); -service.request('method', 'endpoint', 'params', 'body', (result: any) => {}, (error: any) => {}).then((data: any) => {}); -service.fetchQueryData('id', 'params', (result: any) => {}, (error: any) => {}).then((data: any) => {}); -service.fetchQueryStats('id', 'query', (result: any) => {}, (error: any) => {}).then((data: any) => {}); -service.fetchLayer('name', 'params', (result: any) => {}, (error: any) => {}).then((data: any) => {}); -service.fetchLayerTile('name', 1, 2, 3, 'params', (result: any) => {}, (error: any) => {}).then((data: any) => {}); -service.setTokens('token', 'refresh_token'); -service.configure('app_id', 'app_code', true, true, new H.service.Url('scheme', 'host')); +service.request("method", "endpoint", "params", "body", (result: any) => {}, (error: any) => {}).then( + (data: any) => {}, +); +service.fetchQueryData("id", "params", (result: any) => {}, (error: any) => {}).then((data: any) => {}); +service.fetchQueryStats("id", "query", (result: any) => {}, (error: any) => {}).then((data: any) => {}); +service.fetchLayer("name", "params", (result: any) => {}, (error: any) => {}).then((data: any) => {}); +service.fetchLayerTile("name", 1, 2, 3, "params", (result: any) => {}, (error: any) => {}).then((data: any) => {}); +service.setTokens("token", "refresh_token"); +service.configure("app_id", "app_code", true, true, new H.service.Url("scheme", "host")); let queryTileProvider = new H.datalens.QueryTileProvider(service, queryTileProviderOptions); -queryTileProvider.setQueryId('some id'); -queryTileProvider.setQueryParams('some params'); +queryTileProvider.setQueryId("some id"); +queryTileProvider.setQueryParams("some params"); queryTileProvider.setTileParamNames(queryTileProviderTileParamNames); -let provider = new H.datalens.Provider({ columns: ['1', '2'], rows: [[], []]}); +let provider = new H.datalens.Provider({ columns: ["1", "2"], rows: [[], []] }); provider.getData(); -provider.setData({ columns: ['3', '4'], rows: [[], []]}); +provider.setData({ columns: ["3", "4"], rows: [[], []] }); let queryProviderOptions: H.datalens.QueryProvider.Options = { - queryId: 'id', - queryParams: 'params' + queryId: "id", + queryParams: "params", }; -let queryProvider = new H.datalens.QueryProvider({ columns: ['1', '2'], rows: [[], []]}, queryProviderOptions); -queryProvider.setQueryId('id'); -queryProvider.setQueryParams('params'); +let queryProvider = new H.datalens.QueryProvider({ columns: ["1", "2"], rows: [[], []] }, queryProviderOptions); +queryProvider.setQueryId("id"); +queryProvider.setQueryParams("params"); queryProvider.reload(); queryProvider.getData(); -queryProvider.setData({ columns: ['3', '4'], rows: [[], []]}); +queryProvider.setData({ columns: ["3", "4"], rows: [[], []] }); let rasterLayerOptions: H.datalens.RasterLayer.Options = { - dataToRows: (): H.datalens.RasterLayer.Row[] => [], - rowToTilePoint: (): H.datalens.RasterLayer.TilePoint => ({ x: 1, y: 2 }), - buffer: (): number => 1, - renderTile: () => {} + dataToRows: (): H.datalens.RasterLayer.Row[] => [], + rowToTilePoint: (): H.datalens.RasterLayer.TilePoint => ({ x: 1, y: 2 }), + buffer: (): number => 1, + renderTile: () => {}, }; let rasterLayer = new H.datalens.RasterLayer(); rasterLayer.redraw(); let heatmapLayerOptions: H.datalens.HeatmapLayer.Options = { - dataToRows: (): H.datalens.HeatmapLayer.Row[] => [], - rowToTilePoint: (): H.datalens.HeatmapLayer.TilePoint => ({ x: 1, y: 2, value: 5, count: 5 }), - bandwidth: 5, - valueRange: (): number[] => [], - countRange: (): number[] => [], - colorScale: (): string => '2', - alphaScale: (): number => 1, - aggregation: H.datalens.HeatmapLayer.Aggregation.SUM, - inputScale: H.datalens.HeatmapLayer.InputScale.LINEAR + dataToRows: (): H.datalens.HeatmapLayer.Row[] => [], + rowToTilePoint: (): H.datalens.HeatmapLayer.TilePoint => ({ x: 1, y: 2, value: 5, count: 5 }), + bandwidth: 5, + valueRange: (): number[] => [], + countRange: (): number[] => [], + colorScale: (): string => "2", + alphaScale: (): number => 1, + aggregation: H.datalens.HeatmapLayer.Aggregation.SUM, + inputScale: H.datalens.HeatmapLayer.InputScale.LINEAR, }; let heatmapLayer = new H.datalens.HeatmapLayer(queryTileProvider, heatmapLayerOptions); @@ -84,78 +86,99 @@ heatmapLayer.dispose(); heatmapLayer.redraw(); let objectLayerOptions: H.datalens.ObjectLayer.Options = { - dataToRows: (): H.datalens.ObjectLayer.Row[] => [], - rowToMapObject: (): H.map.Object => new H.map.Object(), - rowToStyle: (): H.datalens.ObjectLayer.ObjectStyleOptions => ({ icon: new H.map.Icon('x'), style: {}, arrows: {}, zIndex: 1 }), - dataDomains: 2, - clustering: { rowToDataPoint: (): H.clustering.DataPoint => ({ lat: 12.1, lng: 1.12, alt: 5, ctx: H.geo.AltitudeContext.GL, wt: 2, data: {} }), - options: (): H.clustering.Provider.ClusteringOptions => ({}) } + dataToRows: (): H.datalens.ObjectLayer.Row[] => [], + rowToMapObject: (): H.map.Object => new H.map.Object(), + rowToStyle: (): H.datalens.ObjectLayer.ObjectStyleOptions => ({ + icon: new H.map.Icon("x"), + style: {}, + arrows: {}, + zIndex: 1, + }), + dataDomains: 2, + clustering: { + rowToDataPoint: (): H.clustering.DataPoint => ({ + lat: 12.1, + lng: 1.12, + alt: 5, + ctx: H.geo.AltitudeContext.GL, + wt: 2, + data: {}, + }), + options: (): H.clustering.Provider.ClusteringOptions => ({}), + }, }; let objectLayer = new H.datalens.ObjectLayer(provider, objectLayerOptions); objectLayer.redraw(); -objectLayer.updateObjectStyle(new H.map.Object(), { icon: new H.map.Icon('x'), style: {}, arrows: {}, zIndex: 1 }); +objectLayer.updateObjectStyle(new H.map.Object(), { icon: new H.map.Icon("x"), style: {}, arrows: {}, zIndex: 1 }); let rawDataProviderOptions: H.datalens.RawDataProvider.Options = { - dataUrl: 'url', - dataToFeatures: (): H.datalens.RawDataProvider.Feature[] => [], - featuresToRows: (): H.datalens.ObjectLayer.Row[] => [] + dataUrl: "url", + dataToFeatures: (): H.datalens.RawDataProvider.Feature[] => [], + featuresToRows: (): H.datalens.ObjectLayer.Row[] => [], }; let rawDataProvider = new H.datalens.RawDataProvider(rawDataProviderOptions); let spatialTileProviderOptions: H.datalens.SpatialTileProvider.Options = { - layerName: 'name', - queryParams: 'params' + layerName: "name", + queryParams: "params", }; -let spatialProvider: H.datalens.SpatialTileProvider = new H.datalens.SpatialTileProvider(service, spatialTileProviderOptions); +let spatialProvider: H.datalens.SpatialTileProvider = new H.datalens.SpatialTileProvider( + service, + spatialTileProviderOptions, +); let spatialLayerOptions: H.datalens.SpatialLayer.Options = { - dataToRows: (): H.datalens.SpatialLayer.Row[] => [], - rowToSpatialId: (): string => 'asd', - featureToSpatialId: (): string => 'asd', - rowToStyle: (): any => { return; }, - defaultStyle: (): any => { return; }, - transformFeature: 1 + dataToRows: (): H.datalens.SpatialLayer.Row[] => [], + rowToSpatialId: (): string => "asd", + featureToSpatialId: (): string => "asd", + rowToStyle: (): any => { + return; + }, + defaultStyle: (): any => { + return; + }, + transformFeature: 1, }; let spatialLayer = new H.datalens.SpatialLayer(provider, spatialProvider, spatialLayerOptions); let layer = new H.datalens.ObjectLayer( - provider, - { - rowToMapObject: (cluster) => { - return new H.map.Marker(cluster.getPosition()); - }, - clustering: { - rowToDataPoint: (row) => { - return new H.clustering.DataPoint(row.lat, row.lng, 1); - }, - options: () => { - return { - eps: 25 * devicePixelRatio, // px - minWeight: 20 - }; - } - }, - rowToStyle: (cluster) => { - const size = 32; - - const icon = H.datalens.ObjectLayer.createIcon([ - 'svg', - { - viewBox: [-size, -size, 2 * size, 2 * size] + provider, + { + rowToMapObject: (cluster) => { + return new H.map.Marker(cluster.getPosition()); }, - ['circle', { - cx: 0, - cy: 0, - r: size, - fill: cluster.isCluster() ? 'orange' : 'transparent' - }] - ], { size, crossOrigin: false }); - - return { icon }; - } - } + clustering: { + rowToDataPoint: (row) => { + return new H.clustering.DataPoint(row.lat, row.lng, 1); + }, + options: () => { + return { + eps: 25 * devicePixelRatio, // px + minWeight: 20, + }; + }, + }, + rowToStyle: (cluster) => { + const size = 32; + + const icon = H.datalens.ObjectLayer.createIcon([ + "svg", + { + viewBox: [-size, -size, 2 * size, 2 * size], + }, + ["circle", { + cx: 0, + cy: 0, + r: size, + fill: cluster.isCluster() ? "orange" : "transparent", + }], + ], { size, crossOrigin: false }); + + return { icon }; + }, + }, ); diff --git a/types/heredatalens/index.d.ts b/types/heredatalens/index.d.ts index c3034bf557dee2..2b99efab8ab1fc 100644 --- a/types/heredatalens/index.d.ts +++ b/types/heredatalens/index.d.ts @@ -37,7 +37,14 @@ declare namespace H.datalens { * @param onError - Callback called on an unsuccessful request with the Error object * @returns - Response Promise */ - request(method: string, endpoint: string, params?: any, body?: any, onResult?: (result: any) => void, onError?: (error: any) => void): Promise; + request( + method: string, + endpoint: string, + params?: any, + body?: any, + onResult?: (result: any) => void, + onError?: (error: any) => void, + ): Promise; /** * This method fetches query data for a given query ID. @@ -49,7 +56,12 @@ declare namespace H.datalens { * @param onError - Callback called on an unsuccessful request with the Error object * @returns - Response Promise */ - fetchQueryData(queryId: string, params?: any, onResult?: (result: any) => void, onError?: (error: any) => void): Promise; + fetchQueryData( + queryId: string, + params?: any, + onResult?: (result: any) => void, + onError?: (error: any) => void, + ): Promise; /** * This method fetches statistical data for the Data Lens query (eg minimum and maximum values for the query metric). @@ -60,7 +72,12 @@ declare namespace H.datalens { * @param onError - Callback called on an unsuccessful request with the Error object * @returns - Response Promise */ - fetchQueryStats(queryId: string, statsQuery: any, onResult?: (result: any) => void, onError?: (error: any) => void): Promise; + fetchQueryStats( + queryId: string, + statsQuery: any, + onResult?: (result: any) => void, + onError?: (error: any) => void, + ): Promise; /** * This method fetches a layer of geometries (eg buildings or administrative boundaries). @@ -70,7 +87,12 @@ declare namespace H.datalens { * @param onError - Callback called on an unsuccessful request with the Error object * @returns - Response Promise */ - fetchLayer(layerName: string, params?: any, onResult?: (result: any) => void, onError?: (error: any) => void): Promise; + fetchLayer( + layerName: string, + params?: any, + onResult?: (result: any) => void, + onError?: (error: any) => void, + ): Promise; /** * This method fetches vector tile data from the layer. @@ -82,8 +104,15 @@ declare namespace H.datalens { * @param onError - Callback called on an unsuccessful request with the Error object * @returns - Typed array with tile data */ - fetchLayerTile(layerName: string, x: QueryTileProvider.X, y: QueryTileProvider.Y, z: QueryTileProvider.Zoom, - params?: any, onResult?: (result: any) => void, onError?: (error: any) => void): Promise; + fetchLayerTile( + layerName: string, + x: QueryTileProvider.X, + y: QueryTileProvider.Y, + z: QueryTileProvider.Zoom, + params?: any, + onResult?: (result: any) => void, + onError?: (error: any) => void, + ): Promise; /** * Sets the access and refresh tokens used to authenticate all requests against the Data Lens REST API. @@ -197,7 +226,7 @@ declare namespace H.datalens { * This method is normally used when updating your visualization. * @param queryParams - Query dynamic parameters */ - setQueryParams(queryParams: any|null): void; + setQueryParams(queryParams: any | null): void; /** * Fetches new data from the Data Lens REST API. @@ -256,7 +285,7 @@ declare namespace H.datalens { * Updates the query's dynamic parameters to be used in the next call of the Data Lens REST API. * Note that new data will be fetched only after the reload method is called. This method is normally used when updating your visualization. */ - setQueryParams(queryParams: any|null): void; + setQueryParams(queryParams: any | null): void; /** * Updates the names of the dynamic parameters that defines tiles. This method is only needed when the query ID is updated. @@ -357,7 +386,12 @@ declare namespace H.datalens { */ interface Options { /** Defines how the input tile data is split by rows. You can specify this callback to define client-side aggregation and filtering. This callback is called for each tile. */ - dataToRows?(data: Service.Data, x: QueryTileProvider.X, y: QueryTileProvider.Y, zoom: QueryTileProvider.Zoom): Row[]; + dataToRows?( + data: Service.Data, + x: QueryTileProvider.X, + y: QueryTileProvider.Y, + zoom: QueryTileProvider.Zoom, + ): Row[]; /** Defines how the row is translated to the RasterLayer.TilePoint. This callback is called for each row that is returned from dataToRows. */ rowToTilePoint?(row: Row, x: X, y: Y): TilePoint; /** @@ -422,8 +456,12 @@ declare namespace H.datalens { /** * Default value for dataToRows callback option. It represents each row as an object where property names correspond to data column names. */ - static defaultDataToRows: (data: Service.Data, x: QueryTileProvider.X, y: QueryTileProvider.Y, zoom: QueryTileProvider.Zoom) => - HeatmapLayer.Row[]; + static defaultDataToRows: ( + data: Service.Data, + x: QueryTileProvider.X, + y: QueryTileProvider.Y, + zoom: QueryTileProvider.Zoom, + ) => HeatmapLayer.Row[]; /** * Set of possible values for the inputScale option @@ -461,7 +499,12 @@ declare namespace H.datalens { */ interface Options { /** Defines how the input tile data is split by rows. You can specify this callback to define client-side aggregation and filtering. This callback is called for each tile. */ - dataToRows?(data: Service.Data, x: QueryTileProvider.X, y: QueryTileProvider.Y, zoom: QueryTileProvider.Zoom): Row[]; + dataToRows?( + data: Service.Data, + x: QueryTileProvider.X, + y: QueryTileProvider.Y, + zoom: QueryTileProvider.Zoom, + ): Row[]; /** Defines how the row is translated to the HeatmapLayer.TilePoint. This callback is called for each row that is returned from dataToRows. */ rowToTilePoint(row: Row, x: X, y: Y): TilePoint; /** @@ -578,7 +621,7 @@ declare namespace H.datalens { /** Specifies that the sum aggregation was applied to the bucket value */ SUM, /** Specifies that the average aggregation was applied to the bucket value */ - AVERAGE + AVERAGE, } /** @@ -591,7 +634,7 @@ declare namespace H.datalens { /** Linear scale */ LINEAR, /** Logarithmic scale */ - LOG + LOG, } } @@ -607,7 +650,10 @@ declare namespace H.datalens { * @param provider - Data source (tiled or not) * @param options - Defines data processing, clustering and data-driven styling */ - constructor(provider: map.provider.RemoteTileProvider | Provider | QueryProvider | QueryTileProvider, options: ObjectLayer.Options); + constructor( + provider: map.provider.RemoteTileProvider | Provider | QueryProvider | QueryTileProvider, + options: ObjectLayer.Options, + ); /** * Default value for dataToRows callback option. It represents each row as an object where property names correspond to data column names. @@ -743,8 +789,14 @@ declare namespace H.datalens { /** Defines how the input data is mapped to an array of GeoJSON features */ dataToFeatures?(obj: any): Feature[]; /** Defines how GeoJSON features on a tile should be mapped to data rows, which are inputs to layers such as ObjectLayer and HeatmapLayer */ - featuresToRows?(features: Feature[], x: QueryTileProvider.X, y: QueryTileProvider.Y, z: QueryTileProvider.Zoom, - tileSize: TileSize, helpers: Helpers): ObjectLayer.Row[]; + featuresToRows?( + features: Feature[], + x: QueryTileProvider.X, + y: QueryTileProvider.Y, + z: QueryTileProvider.Zoom, + tileSize: TileSize, + helpers: Helpers, + ): ObjectLayer.Row[]; } /** @@ -765,8 +817,12 @@ declare namespace H.datalens { */ interface Helpers { /** Translates geographical coordinates (latitude, longitude) to world pixel coordinates. */ - latLngToPixel?(latitude: Latitude, longitude: Longitude, z: QueryTileProvider.Zoom, - tileSize: TileSize): PixelCoordinates; + latLngToPixel?( + latitude: Latitude, + longitude: Longitude, + z: QueryTileProvider.Zoom, + tileSize: TileSize, + ): PixelCoordinates; /** Translates world pixel coordinates to geographical coordinates (latitude, longitude). */ pixelToLatLng?(x: PX, y: PY, z: QueryTileProvider.Zoom, tileSize: TileSize): GeoCoordinates; /** Takes CSV data as input, parses it, and return the parsed result. */ @@ -850,7 +906,12 @@ declare namespace H.datalens { */ interface Options { /** Defines how the input tile data is split by rows. You can specify this callback to define client-side aggregation and filtering. This callback is called for each tile. */ - dataToRows?(data: Service.Data, x: QueryTileProvider.X, y: QueryTileProvider.Y, z: QueryTileProvider.Zoom): Row[]; + dataToRows?( + data: Service.Data, + x: QueryTileProvider.X, + y: QueryTileProvider.Y, + z: QueryTileProvider.Zoom, + ): Row[]; /** Defines how to get the spatial ID from a data row. This callback is called for each row that is returned from dataToRows. */ rowToSpatialId(row: Row): string; /** Defines how to get the spatial ID from a geometry feature. This callback is called for each geometry feature in the vector tile. */ diff --git a/types/heremaps/heremaps-tests.ts b/types/heremaps/heremaps-tests.ts index af2ca02d08a5d9..f277e841a114ac 100644 --- a/types/heremaps/heremaps-tests.ts +++ b/types/heremaps/heremaps-tests.ts @@ -16,11 +16,11 @@ function capture(resultContainer: HTMLElement, map: H.Map, ui: H.ui.UI) { map.capture( (canvas: HTMLCanvasElement) => { if (canvas) { - resultContainer.innerHTML = ''; + resultContainer.innerHTML = ""; resultContainer.appendChild(canvas); } else { // For example when map is in Panorama mode - resultContainer.innerHTML = 'Capturing is not supported'; + resultContainer.innerHTML = "Capturing is not supported"; } }, [ui], @@ -36,14 +36,14 @@ function capture(resultContainer: HTMLElement, map: H.Map, ui: H.ui.UI) { */ // Step 1: initialize communication with the platform let platform = new H.service.Platform({ - apikey: '{YOUR_APIKEY}', + apikey: "{YOUR_APIKEY}", useHTTPS: true, useCIT: true, }); let defaultLayers = platform.createDefaultLayers(); -let mapContainer = document.getElementById('map'); +let mapContainer = document.getElementById("map"); // Step 2: initialize a map let map = new H.Map(mapContainer, defaultLayers.vector.normal.map, { @@ -59,21 +59,21 @@ let map = new H.Map(mapContainer, defaultLayers.vector.normal.map, { let behavior = new H.mapevents.Behavior(new H.mapevents.MapEvents(map)); // Step 4: Create the default UI -let ui = H.ui.UI.createDefault(map, defaultLayers, 'en-US'); +let ui = H.ui.UI.createDefault(map, defaultLayers, "en-US"); // Step 6: Create "Capture" button and place for showing the captured area -let resultContainer = document.getElementById('panel'); +let resultContainer = document.getElementById("panel"); // Create container for the "Capture" button -let containerNode = document.createElement('div'); -containerNode.setAttribute('style', 'position:absolute;top:0;left:0;background-color:#fff; padding:10px;'); -containerNode.className = 'btn-group'; +let containerNode = document.createElement("div"); +containerNode.setAttribute("style", "position:absolute;top:0;left:0;background-color:#fff; padding:10px;"); +containerNode.className = "btn-group"; // Create the "Capture" button -let captureBtn = document.createElement('input'); -captureBtn.value = 'Capture'; -captureBtn.type = 'button'; -captureBtn.className = 'btn btn-sm btn-default'; +let captureBtn = document.createElement("input"); +captureBtn.value = "Capture"; +captureBtn.type = "button"; +captureBtn.className = "btn btn-sm btn-default"; // Add both button and container to the DOM containerNode.appendChild(captureBtn); @@ -84,7 +84,7 @@ captureBtn.onclick = () => { capture(resultContainer, map, ui); }; -let icon = new H.map.Icon('svg', { size: 5, crossOrigin: false }); +let icon = new H.map.Icon("svg", { size: 5, crossOrigin: false }); let polyline = new H.map.Polyline(new H.geo.LineString()); // tslint:disable-next-line:array-type @@ -108,9 +108,9 @@ let polyline2 = new H.map.Polyline(lineString); let router = platform.getRoutingService(); let calculateRouteParams = { - waypoint0: 'geo!52.5,13.4', - waypoint1: 'geo!52.5,13.45', - mode: 'fastest;car;traffic:disabled', + waypoint0: "geo!52.5,13.4", + waypoint1: "geo!52.5,13.45", + mode: "fastest;car;traffic:disabled", }; router.calculateRoute( calculateRouteParams, @@ -127,8 +127,8 @@ let entryPoint = H.service.PlacesService.EntryPoint; places.request( entryPoint.SEARCH, { - at: '52.5044,13.3909', - q: 'pizza', + at: "52.5044,13.3909", + q: "pizza", }, response => { console.log(response); @@ -139,18 +139,18 @@ places.request( console.log(resp); }, resp => { - console.log('ERROR: ' + resp); + console.log("ERROR: " + resp); }, ); }, error => { - console.log('ERROR: ' + error); + console.log("ERROR: " + error); }, ); let geocoder = platform.getGeocodingService(); let geocodingParams: H.service.ServiceParameters = { - searchText: '425 W Randolph Street, Chicago', + searchText: "425 W Randolph Street, Chicago", }; geocoder.geocode( geocodingParams, @@ -166,9 +166,9 @@ geocoder.geocode( // deprecated but w/e let enterprieseRouter = platform.getEnterpriseRoutingService(); let calculateIsoline: H.service.ServiceParameters = { - start: 'geo!52.5,13.4', - distance: '1000,2000', - mode: 'fastest;car;traffic:disabled', + start: "geo!52.5,13.4", + distance: "1000,2000", + mode: "fastest;car;traffic:disabled", }; enterprieseRouter.calculateIsoline( calculateIsoline, @@ -210,8 +210,8 @@ engine.setAnimationEase(H.util.animation.ease.EASE_IN_QUAD); const engineListener = (e: Event) => { console.log(e); }; -engine.addEventListener('tap', engineListener); -engine.removeEventListener('tap', engineListener); +engine.addEventListener("tap", engineListener); +engine.removeEventListener("tap", engineListener); // Get group bounds const group = new H.map.Group(); @@ -229,22 +229,22 @@ map.setCenter(position).setZoom(18); const geoJSON = map.screenToGeo(0, 0).toGeoJSON(); // Test H.data.geojson.Reader https://developer.here.com/documentation/examples/maps-js/data/display-geojson-on-map -const reader = new H.data.geojson.Reader('data/berlin.json', { +const reader = new H.data.geojson.Reader("data/berlin.json", { style: (mapObject) => { if (mapObject instanceof H.map.Polygon) { mapObject.setStyle({ - fillColor: 'rgba(255, 0, 0, 0.5)', - strokeColor: 'rgba(0, 0, 255, 0.2)', - lineWidth: 3 + fillColor: "rgba(255, 0, 0, 0.5)", + strokeColor: "rgba(0, 0, 255, 0.2)", + lineWidth: 3, }); } - } + }, }); // Test https://developer.here.com/documentation/maps/3.1.3.0/dev_guide/topics_api/h-map-spatialstyle-linecap.html new H.map.Circle(position, 35) - .setStyle({ lineCap: 'butt' }) - .setStyle({ lineCap: 'round' }) - .setStyle({ lineCap: 'square' }) - .setStyle({ lineCap: 'arrow-head' }) - .setStyle({ lineCap: 'arrow-tail' }); + .setStyle({ lineCap: "butt" }) + .setStyle({ lineCap: "round" }) + .setStyle({ lineCap: "square" }) + .setStyle({ lineCap: "arrow-head" }) + .setStyle({ lineCap: "arrow-tail" }); diff --git a/types/heremaps/index.d.ts b/types/heremaps/index.d.ts index 00a56d604d0ef5..69f243a8b44fed 100644 --- a/types/heremaps/index.d.ts +++ b/types/heremaps/index.d.ts @@ -100,7 +100,14 @@ declare namespace H { * @param opt_x2 {number=} - The X coordinate of the right edge of the capturing rectangle defaults to viewport width * @param opt_y2 {number=} - The Y coordinate of the bottom edge of the capturing rectangle defaults to viewport height */ - capture(callback?: (canvas: HTMLCanvasElement) => void, opt_capturables?: H.util.ICapturable[], opt_x1?: number, opt_y1?: number, opt_x2?: number, opt_y2?: number): void; + capture( + callback?: (canvas: HTMLCanvasElement) => void, + opt_capturables?: H.util.ICapturable[], + opt_x1?: number, + opt_y1?: number, + opt_x2?: number, + opt_y2?: number, + ): void; /** * This method sets the rendering engine type for the map. Rendering engine is responsible for displaying i.e tiles and data on the map. @@ -119,7 +126,13 @@ declare namespace H { * @param opt_layer {H.map.layer.BaseTileLayer=} - The layer to store, default is the current base layer * @returns {H.util.Request} - A handle to the created storage request */ - storeContent(opt_onprogress?: (req: H.util.Request) => void, opt_bounds?: H.geo.Rect, opt_min?: number, opt_max?: number, opt_layer?: H.map.layer.BaseTileLayer): H.util.Request; + storeContent( + opt_onprogress?: (req: H.util.Request) => void, + opt_bounds?: H.geo.Rect, + opt_min?: number, + opt_max?: number, + opt_layer?: H.map.layer.BaseTileLayer, + ): H.util.Request; /** * To clear the entire stored content @@ -211,7 +224,7 @@ declare namespace H { * @param mapObjects {(Array | H.map.Group)} * @returns {H.Map} - the map instance */ - removeObjects(mapObjects: (H.map.Object[] | H.map.Group)): H.Map; + removeObjects(mapObjects: H.map.Object[] | H.map.Group): H.Map; /** * Returns the top most z-ordered map object found under the specific screen coordinates. Coordinates are viewport pixel coordinates starting from top left corner as (0, 0) point. @@ -234,7 +247,7 @@ declare namespace H { * This method will dispatch event on the event target object * @param evt {(H.util.Event | string)} - event object or event name */ - dispatchEvent(evt: (H.util.Event | string)): void; + dispatchEvent(evt: H.util.Event | string): void; /** * Removes listeners from this object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners. @@ -492,7 +505,7 @@ declare namespace H { * This method will dispatch event on the event target object * @param evt {(H.util.Event | string)} - event object or event name */ - dispatchEvent(evt: (H.util.Event | string)): void; + dispatchEvent(evt: H.util.Event | string): void; /** * Removes listeners from this object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners. @@ -556,7 +569,12 @@ declare namespace H { * @param cacheOnly {boolean} - Indicates whether only cached objects are to be considered * @returns {Array} - a list of intersecting objects */ - requestDomMarkers(bounds: H.geo.Rect, zoomLevel: number, visiblesOnly: boolean, cacheOnly: boolean): H.map.DomMarker[]; + requestDomMarkers( + bounds: H.geo.Rect, + zoomLevel: number, + visiblesOnly: boolean, + cacheOnly: boolean, + ): H.map.DomMarker[]; /** * This method always returns true as we don't have information about visual representation until we have the clustering result and apply the theme. @@ -572,7 +590,12 @@ declare namespace H { * @param cacheOnly {boolean} - Indicates whether only cached objects are to be considered * @returns {Array} - a list of intersecting objects */ - requestMarkers(bounds: H.geo.Rect, zoomLevel: number, visiblesOnly: boolean, cacheOnly: boolean): H.map.Marker[]; + requestMarkers( + bounds: H.geo.Rect, + zoomLevel: number, + visiblesOnly: boolean, + cacheOnly: boolean, + ): H.map.Marker[]; /** * This method always returns true as we don't have information about visual representation until we have the clustering result and apply the theme. @@ -588,7 +611,12 @@ declare namespace H { * @param cacheOnly {boolean} - Indicates whether only cached objects are to be considered * @returns {Array} - a list of intersecting objects */ - requestSpatials(bounds: H.geo.Rect, zoomLevel: number, visiblesOnly: boolean, cacheOnly: boolean): H.map.Spatial[]; + requestSpatials( + bounds: H.geo.Rect, + zoomLevel: number, + visiblesOnly: boolean, + cacheOnly: boolean, + ): H.map.Spatial[]; /** * Returns the spatial objects which intersect the given tile @@ -597,7 +625,11 @@ declare namespace H { * @param cacheOnly {boolean} - Indicates whether only cached objects are to be considered * @returns {Array} - a list of intersecting objects */ - requestSpatialsByTile(tile: H.map.provider.Tile, visiblesOnly: boolean, cacheOnly: boolean): H.map.Spatial[]; + requestSpatialsByTile( + tile: H.map.provider.Tile, + visiblesOnly: boolean, + cacheOnly: boolean, + ): H.map.Spatial[]; /** * Returns the accumulate invalidations of this provider's objects that have occurred. @@ -724,7 +756,12 @@ declare namespace H { * @param state {H.data.AbstractReader.State} - The state of the target firing an event * @param message {string} - The message associated with an event */ - constructor(target: (H.data.AbstractReader | H.map.Object), type: string, state: H.data.AbstractReader.State, message: string); + constructor( + target: H.data.AbstractReader | H.map.Object, + type: string, + state: H.data.AbstractReader.State, + message: string, + ); } /** @@ -957,7 +994,11 @@ declare namespace H { * @param opt_start {number=} - The point's start index (inclusive) to iterate from, defaults to 0. * @param opt_end {number=} - The point's end index (exclusive) to iterate to, defaults to Infinity. */ - eachLatLngAlt(eachFn: (lat: H.geo.Latitude, lng: H.geo.Longitude, alt: H.geo.Altitude, index: number) => void, opt_start?: number, opt_end?: number): void; + eachLatLngAlt( + eachFn: (lat: H.geo.Latitude, lng: H.geo.Longitude, alt: H.geo.Altitude, index: number) => void, + opt_start?: number, + opt_end?: number, + ): void; /** * To obtain whether a leg (formed by the given two longitudes) crosses the International Date Line. @@ -1417,7 +1458,12 @@ declare namespace H { * @param opt_out {H.geo.Rect=} - an optional rectangular area to store the result * @returns {H.geo.Rect} - either the rectangular area passed as out parameter or a new rectangular area */ - mergeLatLng(lat: H.geo.Latitude, lng: H.geo.Longitude, opt_skipValidation?: boolean, opt_out?: H.geo.Rect): H.geo.Rect; + mergeLatLng( + lat: H.geo.Latitude, + lng: H.geo.Longitude, + opt_skipValidation?: boolean, + opt_out?: H.geo.Rect, + ): H.geo.Rect; /** * This method returns the smallest bounding box that covers this rectangular area and the point supplied by the caller. @@ -1447,7 +1493,14 @@ declare namespace H { * @param opt_out {H.geo.Rect=} - an optional rectangular area to store the result * @returns {H.geo.Rect} - either the rectangular area passed as out parameter or a new rectangular area */ - mergeTopLeftBottomRight(top: H.geo.Latitude, left: H.geo.Longitude, bottom: H.geo.Latitude, right: H.geo.Longitude, opt_skipValidation?: boolean, opt_out?: H.geo.Rect): H.geo.Rect; + mergeTopLeftBottomRight( + top: H.geo.Latitude, + left: H.geo.Longitude, + bottom: H.geo.Latitude, + right: H.geo.Longitude, + opt_skipValidation?: boolean, + opt_out?: H.geo.Rect, + ): H.geo.Rect; /** * This method checks if the intersection of two bounding boxes is non-empty. @@ -1470,8 +1523,17 @@ declare namespace H { * @param opt_out {H.geo.Rect=} - an optional rect to store the results * @returns {H.geo.Rect} - either the opt_out rect or a new rect */ - static merge(topA: H.geo.Latitude, leftA: H.geo.Longitude, bottomA: H.geo.Latitude, rightA: H.geo.Longitude, topB: H.geo.Latitude, leftB: H.geo.Longitude, bottomB: H.geo.Latitude, - rightB: H.geo.Longitude, opt_out?: H.geo.Rect): H.geo.Rect; + static merge( + topA: H.geo.Latitude, + leftA: H.geo.Longitude, + bottomA: H.geo.Latitude, + rightA: H.geo.Longitude, + topB: H.geo.Latitude, + leftB: H.geo.Longitude, + bottomB: H.geo.Latitude, + rightB: H.geo.Longitude, + opt_out?: H.geo.Rect, + ): H.geo.Rect; /** * This method creates a rectangular area from a top-left and bottom-right point pair. @@ -1480,7 +1542,11 @@ declare namespace H { * @param opt_skipValidation {boolean=} - a boolean flag indicating whether to check validity of the arguments * @returns {H.geo.Rect} - returns the rectangular area defined by the top-left and bottom-right corners */ - static fromPoints(topLeft: H.geo.IPoint, bottomRight: H.geo.IPoint, opt_skipValidation?: boolean): H.geo.Rect; + static fromPoints( + topLeft: H.geo.IPoint, + bottomRight: H.geo.IPoint, + opt_skipValidation?: boolean, + ): H.geo.Rect; /** * This method creates the minimum rectangular area covering all of the points in the argument array. @@ -1563,7 +1629,11 @@ declare namespace H { * @param opt_deleteCount - The number of interior rings to remove, defaults to Infinity. * @param var_args - repeatable, The interior rings to insert. */ - spliceInteriors(opt_index?: number, opt_deleteCount?: number, ...var_args: H.geo.LineString[]): H.geo.LineString[]; + spliceInteriors( + opt_index?: number, + opt_deleteCount?: number, + ...var_args: H.geo.LineString[] + ): H.geo.LineString[]; } namespace Polygon { @@ -1576,9 +1646,9 @@ declare namespace H { } } - class MultiPolygon extends H.geo.MultiGeometry { } + class MultiPolygon extends H.geo.MultiGeometry {} - class MultiPoint extends H.geo.MultiGeometry { } + class MultiPoint extends H.geo.MultiGeometry {} } /***** lang *****/ @@ -1613,14 +1683,14 @@ declare namespace H { * Returns this marker's current icon. * @returns {!(H.map.Icon | H.map.DomIcon)} */ - getIcon(): (H.map.Icon | H.map.DomIcon); + getIcon(): H.map.Icon | H.map.DomIcon; /** * Sets the marker's current icon. * @param icon {!(H.map.Icon | H.map.DomIcon)} - The new marker icon * @returns {H.map.AbstractMarker} - the marker itself */ - setIcon(icon: (H.map.Icon | H.map.DomIcon)): H.map.AbstractMarker; + setIcon(icon: H.map.Icon | H.map.DomIcon): H.map.AbstractMarker; /** * @description This property ensure that the marker can receive drag events. @@ -1659,14 +1729,14 @@ declare namespace H { * Constructor * @param opt_options {(H.map.ArrowStyle | H.map.ArrowStyle.Options)=} */ - constructor(opt_options?: (H.map.ArrowStyle | H.map.ArrowStyle.Options)); + constructor(opt_options?: H.map.ArrowStyle | H.map.ArrowStyle.Options); /** * This method checks value-equality with another arrow style. * @param other {(H.map.ArrowStyle | H.map.ArrowStyle.Options)} - the arrow style to compare with * @returns {boolean} - true if the arrow styles are value-equal, otherwise false */ - equals(other: (H.map.ArrowStyle | H.map.ArrowStyle.Options)): boolean; + equals(other: H.map.ArrowStyle | H.map.ArrowStyle.Options): boolean; } namespace ArrowStyle { @@ -1787,7 +1857,7 @@ declare namespace H { * @param element {!(Element | string)} - The element or markup to use for this icon * @param opt_options {H.map.DomIcon.Options=} */ - constructor(element: (Element | string), opt_options?: H.map.DomIcon.Options); + constructor(element: Element | string, opt_options?: H.map.DomIcon.Options); } namespace DomIcon { @@ -1870,12 +1940,15 @@ declare namespace H { constructor(opt_options?: H.map.Group.Options); /** - * * @param callback {function(!H.map.Object, number, !H.map.Group)} * @param opt_recursive {boolean=} - Indicates whether sub groups should be traversed recursively * @param opt_context {*=} - The context to use as "this" within the callback */ - forEach(callback: (object: H.map.Object, n: number, group: H.map.Group) => void, opt_recursive?: boolean, opt_context?: any): void; + forEach( + callback: (object: H.map.Object, n: number, group: H.map.Group) => void, + opt_recursive?: boolean, + opt_context?: any, + ): void; /** * To get a list of all objects of this group. On groups with many chilren this method can cause a higher memory and CPU consumption. Alternatively you case use H.map.Group#forEach @@ -1993,7 +2066,16 @@ declare namespace H { * @param zoom {number} - changes current zoom level (for view works as moveZ) * @param opt_timestamp {number=} */ - control(moveX: number, moveY: number, moveZ: number, angleX: number, angleY: number, angleZ: number, zoom: number, opt_timestamp?: number): void; + control( + moveX: number, + moveY: number, + moveZ: number, + angleX: number, + angleY: number, + angleZ: number, + zoom: number, + opt_timestamp?: number, + ): void; /** * This method ends current control, which will stop ongoing animation triggered by the startControl method. This method can prevent kinetics as well as it can adjust the final view if @@ -2002,7 +2084,10 @@ declare namespace H { * @param opt_adjustView {function(H.map.ViewModel.ILookAtData)=} - user defined function which can adjust the final view this function takes last requestedData from the view model and * should return a modified H.map.ViewModel.CameraData which will be set as the final view */ - endControl(opt_preventKinetics?: boolean, opt_adjustView?: (data: H.map.ViewModel.ILookAtData) => void): void; + endControl( + opt_preventKinetics?: boolean, + opt_adjustView?: (data: H.map.ViewModel.ILookAtData) => void, + ): void; } /** @@ -2053,7 +2138,7 @@ declare namespace H { * @param bitmap {!(string | HTMLImageElement | HTMLCanvasElement)} - Either an image URL, a SVG markup, an image or a canvas. * @param opt_options {H.map.Icon.Options=} */ - constructor(bitmap: (string | HTMLImageElement | HTMLCanvasElement), opt_options?: H.map.Icon.Options); + constructor(bitmap: string | HTMLImageElement | HTMLCanvasElement, opt_options?: H.map.Icon.Options); /** * Returns the icon's bitmap loading state @@ -2065,7 +2150,7 @@ declare namespace H { * Returns the bitmap of this icon or null if the bitmap is not ready yet (see H.map.Icon#getState) * @returns {?(HTMLImageElement | HTMLCanvasElement)} */ - getBitmap(): (HTMLImageElement | HTMLCanvasElement); + getBitmap(): HTMLImageElement | HTMLCanvasElement; /** * Returns the size of this icon or null if a size wasn't specified in the constructor's options and the state of this icon is not H.map.Icon.prototype.State.READY @@ -2108,7 +2193,7 @@ declare namespace H { * This method will dispatch event on the event target object * @param evt {(H.util.Event | string)} - event object or event name */ - dispatchEvent(evt: (H.util.Event | string)): void; + dispatchEvent(evt: H.util.Event | string): void; /** * Removes listeners from this object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners. @@ -2195,7 +2280,12 @@ declare namespace H { * @param callback {function(HTMLCanvasElement=)} - Callback function to call once result of the capturing is ready * @param opt_errback {function(string)=} - Callback function to call if error occurred during capturing */ - capture(canvas: HTMLCanvasElement, pixelRatio: number, callback?: (canvas: HTMLCanvasElement) => void, opt_errback?: (s: string) => void): void; + capture( + canvas: HTMLCanvasElement, + pixelRatio: number, + callback?: (canvas: HTMLCanvasElement) => void, + opt_errback?: (s: string) => void, + ): void; } namespace Imprint { @@ -2353,7 +2443,7 @@ declare namespace H { * This method will dispatch event on the event target object * @param evt {(H.util.Event | string)} - event object or event name */ - dispatchEvent(evt: (H.util.Event | string)): void; + dispatchEvent(evt: H.util.Event | string): void; /** * Removes listeners from this object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners. @@ -2417,7 +2507,11 @@ declare namespace H { * @param bitmap {!(string | HTMLImageElement | HTMLCanvasElement)} - Either an image URL, a SVG markup, an image or a canvas. * @param opt_options {H.map.Overlay.Options=} - Optional values values to initialize this overlay */ - constructor(bounds: H.geo.Rect, bitmap: (string | HTMLImageElement | HTMLCanvasElement), opt_options?: H.map.Overlay.Options); + constructor( + bounds: H.geo.Rect, + bitmap: string | HTMLImageElement | HTMLCanvasElement, + opt_options?: H.map.Overlay.Options, + ); /** * This method returns this overlay's current bounds. @@ -2436,14 +2530,14 @@ declare namespace H { * Returns this overlay's current bitmap. * @returns {?(HTMLImageElement | HTMLCanvasElement)} - the bitmap of this Overlay or null if it isn't ready yet */ - getBitmap(): (HTMLImageElement | HTMLCanvasElement); + getBitmap(): HTMLImageElement | HTMLCanvasElement; /** * Sets the overlay's current bitmap. * @param bitmap {!(string | HTMLImageElement | HTMLCanvasElement)} - Either an image URL, a SVG markup, an image or a canvas. * @returns {H.map.Overlay} - the overlay itself */ - setBitmap(bitmap: (string | HTMLImageElement | HTMLCanvasElement)): H.map.Overlay; + setBitmap(bitmap: string | HTMLImageElement | HTMLCanvasElement): H.map.Overlay; /** * Returns this overlay's current opacity. @@ -2494,7 +2588,10 @@ declare namespace H { * The geometry that defines the surface of the polygon. H.geo.LineString is interpreted as an exterior ring of H.geo.Polygon object. * @param opt_options {H.map.Spatial.Options=} - optional initialization parameters */ - constructor(geometry: H.geo.LineString | H.geo.Polygon | H.geo.MultiPolygon, opt_options?: H.map.Polygon.Options); + constructor( + geometry: H.geo.LineString | H.geo.Polygon | H.geo.MultiPolygon, + opt_options?: H.map.Polygon.Options, + ); /** * To set the indicator whether this polygon covers the north pole. It's needed for Polygons whose strip is defined as lines arround the world on longitude axis (for example a circle whose @@ -2813,7 +2910,7 @@ declare namespace H { * @param opt_style {(H.map.SpatialStyle | H.map.SpatialStyle.Options)=} - The style to set. If it evaluates to a falsy the H.map.SpatialStyle.DEFAULT_STYLE is used. * @returns {H.map.Spatial} - the Spatial instance itself */ - setStyle(opt_style?: (H.map.SpatialStyle | H.map.SpatialStyle.Options)): H.map.Spatial; + setStyle(opt_style?: H.map.SpatialStyle | H.map.SpatialStyle.Options): H.map.Spatial; /** * To get the arrow style of this spatial object or undefined if no style is defined. A returned arrow style is treated as immutable and must not be modified afterwards to prevent @@ -2827,7 +2924,7 @@ declare namespace H { * @param opt_arrows {(H.map.ArrowStyle | H.map.ArrowStyle.Options)=} - the arrow style to be applied * @returns {H.map.Spatial} - the Spatial instance itself */ - setArrows(opt_arrows?: (H.map.ArrowStyle | H.map.ArrowStyle.Options)): H.map.Spatial; + setArrows(opt_arrows?: H.map.ArrowStyle | H.map.ArrowStyle.Options): H.map.Spatial; /** * Indicates whether this spatial object represents a closed shape @@ -2901,14 +2998,14 @@ declare namespace H { * Constructor * @param opt_options {(H.map.SpatialStyle | H.map.SpatialStyle.Options)=} - The optional style attributes */ - constructor(opt_options?: (H.map.SpatialStyle | H.map.SpatialStyle.Options)); + constructor(opt_options?: H.map.SpatialStyle | H.map.SpatialStyle.Options); /** * This method checks value-equality with another style. * @param other {(H.map.SpatialStyle | H.map.SpatialStyle.Options)} - the style to compare with * @returns {boolean} - true if the styles are value-equal, otherwise false */ - equals(other: (H.map.SpatialStyle | H.map.SpatialStyle.Options)): boolean; + equals(other: H.map.SpatialStyle | H.map.SpatialStyle.Options): boolean; /** * Returns a copy of spatial style object and replaces the passed style attributes into it. @@ -2935,12 +3032,12 @@ declare namespace H { /** * The style of the end caps for a line, one of 'butt', 'round', 'square', 'arrow-head' or 'arrow-tail'. */ - type LineCap = 'butt' | 'round' | 'square' | 'arrow-head' | 'arrow-tail'; + type LineCap = "butt" | "round" | "square" | "arrow-head" | "arrow-tail"; /** * The type of corner created, when two lines meet, one of 'round', 'bevel' or 'miter'. */ - type LineJoin = 'round' | 'bevel' | 'miter'; + type LineJoin = "round" | "bevel" | "miter"; /** * Options used to initialize a style. If a property is not set, the default value from H.map.SpatialStyle is taken. @@ -3016,20 +3113,31 @@ declare namespace H { * @param angleZ {number} - The rotation of on screen's z axis as degrees per millisecond. * @param opt_zoom {number=} - The modification of the zoom level as levels per millisecond */ - control(moveX: number, moveY: number, moveZ: number, angleX: number, angleY: number, angleZ: number, opt_zoom?: number): void; + control( + moveX: number, + moveY: number, + moveZ: number, + angleX: number, + angleY: number, + angleZ: number, + opt_zoom?: number, + ): void; /** * A method to signal the end of a control operation. * @param opt_preventKinetics {boolean=} - A flag to indicate whether a kinetic effect is performed * @param opt_adjustView {function(H.map.ViewModel.ILookAtData)=} - An callback to adjust the final ViewModel by modifying the passed camera data. */ - endControl(opt_preventKinetics?: boolean, opt_adjustView?: (data: H.map.ViewModel.ILookAtData) => void): void; + endControl( + opt_preventKinetics?: boolean, + opt_adjustView?: (data: H.map.ViewModel.ILookAtData) => void, + ): void; /** * This method will dispatch event on the event target object * @param evt {(H.util.Event | string)} - event object or event name */ - dispatchEvent(evt: (H.util.Event | string)): void; + dispatchEvent(evt: H.util.Event | string): void; /** * Removes listeners from this object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners. @@ -3154,7 +3262,7 @@ declare namespace H { * This method will dispatch event on the event target object * @param evt {(H.util.Event | string)} - event object or event name */ - dispatchEvent(evt: (H.util.Event | string)): void; + dispatchEvent(evt: H.util.Event | string): void; /** * Removes listeners from this object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners. @@ -3267,7 +3375,13 @@ declare namespace H { * @param prioCenter {H.math.Point} - The priority center as an offset in screen pixel relative to the center * @returns {H.map.layer.ITileLayer.Response} - returns an array if tile which are already loaded */ - getProviderTiles(tileBounds: H.math.Rect, isCDB: boolean, zoomLevel: number, cacheOnly: boolean, prioCenter: H.math.Point): H.map.layer.ITileLayer.Response; + getProviderTiles( + tileBounds: H.math.Rect, + isCDB: boolean, + zoomLevel: number, + cacheOnly: boolean, + prioCenter: H.math.Point, + ): H.map.layer.ITileLayer.Response; } /** @@ -3282,7 +3396,12 @@ declare namespace H { * @param prioCenter {H.math.Point} - The priority center as an offset in screen pixel relative to the center * @returns {(H.map.layer.IMarkerLayer.Response | H.map.layer.IMarkerLayer.TiledResponse)} - a response object containing the number of markers and the markers themselves */ - requestMarkers(boundingRect: H.geo.Rect, zoomLevel: number, cacheOnly: boolean, prioCenter: H.math.Point): (H.map.layer.IMarkerLayer.Response | H.map.layer.IMarkerLayer.TiledResponse); + requestMarkers( + boundingRect: H.geo.Rect, + zoomLevel: number, + cacheOnly: boolean, + prioCenter: H.math.Point, + ): H.map.layer.IMarkerLayer.Response | H.map.layer.IMarkerLayer.TiledResponse; /** * This method requests dom marker objects for provided bounding rectangle. @@ -3292,8 +3411,14 @@ declare namespace H { * @param prioCenter {H.math.Point} - The priority center as an offset in screen pixel relative to the center * @returns {(H.map.layer.IMarkerLayer.Response | H.map.layer.IMarkerLayer.TiledResponse)} - a response object containing the number of markers and the markers themselves */ - requestDomMarkers(boundingRect: H.geo.Rect, zoomLevel: number, cacheOnly: boolean, prioCenter: H.math.Point): (H.map.layer.IMarkerLayer.Response | - H.map.layer.IMarkerLayer.TiledResponse); + requestDomMarkers( + boundingRect: H.geo.Rect, + zoomLevel: number, + cacheOnly: boolean, + prioCenter: H.math.Point, + ): + | H.map.layer.IMarkerLayer.Response + | H.map.layer.IMarkerLayer.TiledResponse; } namespace IMarkerLayer { @@ -3333,7 +3458,12 @@ declare namespace H { * @param prioCenter {H.math.Point} - The priority center as an offset in screen pixel relative to the center * @returns {H.map.layer.ITileLayer.Response} - a response object containing the total number of tiles requested and the tile objects that could be immediately returned */ - requestTiles(boundingRect: H.geo.Rect, zoomLevel: number, cacheOnly: boolean, prioCenter: H.math.Point): H.map.layer.ITileLayer.Response; + requestTiles( + boundingRect: H.geo.Rect, + zoomLevel: number, + cacheOnly: boolean, + prioCenter: H.math.Point, + ): H.map.layer.ITileLayer.Response; /** * This method requests a single tile according to tile coordinates. It returns either a Tile object if it is already loaded or undefined and starts loading the tile @@ -3420,7 +3550,7 @@ declare namespace H { * This method will dispatch event on the event target object * @param evt {(H.util.Event | string)} - event object or event name */ - dispatchEvent(evt: (H.util.Event | string)): void; + dispatchEvent(evt: H.util.Event | string): void; /** * Removes listeners from this object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners. @@ -3472,7 +3602,12 @@ declare namespace H { * @param prioCenter {H.math.Point} - The priority center as an offset in screen pixel relative to the center * @returns {(H.map.layer.IMarkerLayer.Response | H.map.layer.IMarkerLayer.TiledResponse)} - a response object containing the number of markers and the markers themselves */ - requestMarkers(boundingRect: H.geo.Rect, zoomLevel: number, cacheOnly: boolean, prioCenter: H.math.Point): (H.map.layer.IMarkerLayer.Response | H.map.layer.IMarkerLayer.TiledResponse); + requestMarkers( + boundingRect: H.geo.Rect, + zoomLevel: number, + cacheOnly: boolean, + prioCenter: H.math.Point, + ): H.map.layer.IMarkerLayer.Response | H.map.layer.IMarkerLayer.TiledResponse; /** * This method requests dom marker objects for provided bounding rectangle. @@ -3482,8 +3617,14 @@ declare namespace H { * @param prioCenter {H.math.Point} - The priority center as an offset in screen pixel relative to the center * @returns {(H.map.layer.IMarkerLayer.Response | H.map.layer.IMarkerLayer.TiledResponse)} - a response object containing the number of markers and the markers themselves */ - requestDomMarkers(boundingRect: H.geo.Rect, zoomLevel: number, cacheOnly: boolean, prioCenter: H.math.Point): (H.map.layer.IMarkerLayer.Response | - H.map.layer.IMarkerLayer.TiledResponse); + requestDomMarkers( + boundingRect: H.geo.Rect, + zoomLevel: number, + cacheOnly: boolean, + prioCenter: H.math.Point, + ): + | H.map.layer.IMarkerLayer.Response + | H.map.layer.IMarkerLayer.TiledResponse; } /** @@ -3496,7 +3637,10 @@ declare namespace H { * @param provider {H.map.provider.ObjectProvider} - the ObjectProvider which provides the map objects to this object layer. * @param opt_options {H.map.layer.ObjectLayer.Options=} - The options for this layer */ - constructor(provider: H.map.provider.ObjectProvider | H.clustering.Provider, opt_options?: H.map.layer.ObjectLayer.Options); + constructor( + provider: H.map.provider.ObjectProvider | H.clustering.Provider, + opt_options?: H.map.layer.ObjectLayer.Options, + ); /** * This method returns current ObjectLayer's data provider @@ -3512,7 +3656,12 @@ declare namespace H { * @param prioCenter {H.math.Point} - The priority center as an offset in screen pixel relative to the center * @returns {H.map.layer.ObjectLayer.OverlaysResponse} */ - requestOverlays(bounds: H.geo.Rect, zoomLevel: number, cacheOnly: boolean, prioCenter: H.math.Point): H.map.layer.ObjectLayer.OverlaysResponse; + requestOverlays( + bounds: H.geo.Rect, + zoomLevel: number, + cacheOnly: boolean, + prioCenter: H.math.Point, + ): H.map.layer.ObjectLayer.OverlaysResponse; /** * This method requests tiles for the current bounding rectangle at the given zoom level (z-value). @@ -3522,7 +3671,12 @@ declare namespace H { * @param prioCenter {H.math.Point} - The priority center as an offset in screen pixel relative to the center * @returns {H.map.layer.ITileLayer.Response} - a response object containing the total number of tiles requested and the tile objects that could be immediately returned */ - requestTiles(boundingRect: H.geo.Rect, zoomLevel: number, cacheOnly: boolean, prioCenter: H.math.Point): H.map.layer.ITileLayer.Response; + requestTiles( + boundingRect: H.geo.Rect, + zoomLevel: number, + cacheOnly: boolean, + prioCenter: H.math.Point, + ): H.map.layer.ITileLayer.Response; /** * This method requests a single tile according to tile coordinates. It returns either a Tile object if it is already loaded or undefined and starts loading the tile @@ -3550,7 +3704,12 @@ declare namespace H { * @param prioCenter {H.math.Point} - The priority center as an offset in screen pixel relative to the center * @returns {(H.map.layer.IMarkerLayer.Response | H.map.layer.IMarkerLayer.TiledResponse)} - a response object containing the number of markers and the markers themselves */ - requestMarkers(boundingRect: H.geo.Rect, zoomLevel: number, cacheOnly: boolean, prioCenter: H.math.Point): (H.map.layer.IMarkerLayer.Response | H.map.layer.IMarkerLayer.TiledResponse); + requestMarkers( + boundingRect: H.geo.Rect, + zoomLevel: number, + cacheOnly: boolean, + prioCenter: H.math.Point, + ): H.map.layer.IMarkerLayer.Response | H.map.layer.IMarkerLayer.TiledResponse; /** * This method requests dom marker objects for provided bounding rectangle. @@ -3560,8 +3719,14 @@ declare namespace H { * @param prioCenter {H.math.Point} - The priority center as an offset in screen pixel relative to the center * @returns {(H.map.layer.IMarkerLayer.Response | H.map.layer.IMarkerLayer.TiledResponse)} - a response object containing the number of markers and the markers themselves */ - requestDomMarkers(boundingRect: H.geo.Rect, zoomLevel: number, cacheOnly: boolean, prioCenter: H.math.Point): (H.map.layer.IMarkerLayer.Response | - H.map.layer.IMarkerLayer.TiledResponse); + requestDomMarkers( + boundingRect: H.geo.Rect, + zoomLevel: number, + cacheOnly: boolean, + prioCenter: H.math.Point, + ): + | H.map.layer.IMarkerLayer.Response + | H.map.layer.IMarkerLayer.TiledResponse; } namespace ObjectLayer { @@ -3610,7 +3775,12 @@ declare namespace H { * @param prioCenter {H.math.Point} - The priority center as an offset in screen pixel relative to the center * @returns {H.map.layer.ITileLayer.Response} - a response object containing the total number of tiles requested and the tile objects that could be immediately returned */ - requestTiles(boundingRect: H.geo.Rect, zoomLevel: number, cacheOnly: boolean, prioCenter: H.math.Point): H.map.layer.ITileLayer.Response; + requestTiles( + boundingRect: H.geo.Rect, + zoomLevel: number, + cacheOnly: boolean, + prioCenter: H.math.Point, + ): H.map.layer.ITileLayer.Response; update: H.util.Event; } @@ -3785,7 +3955,13 @@ declare namespace H { min?: number | undefined; max?: number | undefined; - requestData(n1: number, n2: number, n3: number, markerCallback: (markers: H.map.AbstractMarker[]) => void, f: () => void): H.util.ICancelable; + requestData( + n1: number, + n2: number, + n3: number, + markerCallback: (markers: H.map.AbstractMarker[]) => void, + f: () => void, + ): H.util.ICancelable; providesDomMarkers?: boolean | undefined; } @@ -3829,7 +4005,12 @@ declare namespace H { * @param cacheOnly {boolean} - Indicates whether only cached objects are to be considered * @returns {Array} - a list of intersecting objects */ - requestOverlays(geoRect: H.geo.Rect, zoomLevel: number, visiblesOnly: boolean, cacheOnly: boolean): H.map.Overlay[]; + requestOverlays( + geoRect: H.geo.Rect, + zoomLevel: number, + visiblesOnly: boolean, + cacheOnly: boolean, + ): H.map.Overlay[]; /** * Checks whether this provider is currently providing spatial map objects. A concrete implementation of ObjectProvider must override it if it currently provides Spatials. @@ -3845,7 +4026,12 @@ declare namespace H { * @param cacheOnly {boolean} - Indicates whether only cached objects are to be considered * @returns {Array} - a list of intersecting objects */ - requestSpatials(geoRect: H.geo.Rect, zoomLevel: number, visiblesOnly: boolean, cacheOnly: boolean): H.map.Spatial[]; + requestSpatials( + geoRect: H.geo.Rect, + zoomLevel: number, + visiblesOnly: boolean, + cacheOnly: boolean, + ): H.map.Spatial[]; /** * Returns the spatial objects which intersect the given tile @@ -3854,7 +4040,11 @@ declare namespace H { * @param cacheOnly {boolean} - Indicates whether only cached objects are to be considered * @returns {Array} - a list of intersecting objects */ - requestSpatialsByTile(tile: H.map.provider.Tile, visiblesOnly: boolean, cacheOnly: boolean): H.map.Spatial[]; + requestSpatialsByTile( + tile: H.map.provider.Tile, + visiblesOnly: boolean, + cacheOnly: boolean, + ): H.map.Spatial[]; /** * Checks whether this provider is currently providing Marker map objects. A concrete implementation of ObjectProvider must override it if it currently provides Markers. @@ -3870,7 +4060,12 @@ declare namespace H { * @param cacheOnly {boolean} - Indicates whether only cached objects are to be considered * @returns {Array} - a list of intersecting objects */ - requestMarkers(geoRect: H.geo.Rect, zoomLevel: number, visiblesOnly: boolean, cacheOnly: boolean): H.map.Marker[]; + requestMarkers( + geoRect: H.geo.Rect, + zoomLevel: number, + visiblesOnly: boolean, + cacheOnly: boolean, + ): H.map.Marker[]; /** * Checks whether this provider is currently providing DomMarker map objects. A concrete implementation of ObjectProvider must override it if it currently provides Markers. @@ -3886,7 +4081,12 @@ declare namespace H { * @param cacheOnly {boolean} - Indicates whether only cached objects are to be considered * @returns {Array} - a list of intersecting objects */ - requestDomMarkers(geoRect: H.geo.Rect, zoomLevel: number, visiblesOnly: boolean, cacheOnly: boolean): H.map.DomMarker[]; + requestDomMarkers( + geoRect: H.geo.Rect, + zoomLevel: number, + visiblesOnly: boolean, + cacheOnly: boolean, + ): H.map.DomMarker[]; } /** @@ -3932,7 +4132,7 @@ declare namespace H { * This method will dispatch event on the event target object * @param evt {(H.util.Event | string)} - event object or event name */ - dispatchEvent(evt: (H.util.Event | string)): void; + dispatchEvent(evt: H.util.Event | string): void; /** * Removes listeners from this object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners. @@ -4071,7 +4271,13 @@ declare namespace H { * @param opt_options {Object=} - free form options object. These options are meant to be used in tile specific rendering cases * @returns {H.map.provider.Tile} */ - createTileInternal(x: number, y: number, z: number, data: (HTMLImageElement | HTMLCanvasElement), opt_options?: { [key: string]: any }): H.map.provider.Tile; + createTileInternal( + x: number, + y: number, + z: number, + data: HTMLImageElement | HTMLCanvasElement, + opt_options?: { [key: string]: any }, + ): H.map.provider.Tile; /** * This method creates a tile key consisting of the provider's uri, and the tile's x, y and z coordinates, seperated by underscores e.g.: "4711_7_42_23" @@ -4127,7 +4333,12 @@ declare namespace H { * @param dataModel {H.map.DataModel} - An object encapsulating the data to be rendered on the map (layers and objects) * @param options {H.map.render.RenderEngine.Options} - An object containing the render engine initialization options */ - constructor(viewPort: H.map.ViewPort, viewModel: H.map.ViewModel, dataModel: H.map.DataModel, options: H.map.render.RenderEngine.Options); + constructor( + viewPort: H.map.ViewPort, + viewModel: H.map.ViewModel, + dataModel: H.map.DataModel, + options: H.map.render.RenderEngine.Options, + ); /** * This method adds a listener for a specific event. @@ -4137,7 +4348,12 @@ declare namespace H { * @param opt_capture {boolean=} - true indicates that the method should listen in the capture phase (bubble otherwise) * @param opt_scope {Object=} - An object defining the scope for the handler function */ - addEventListener(type: string, handler: (evt: Event) => void, opt_capture?: boolean, opt_scope?: {}): void; + addEventListener( + type: string, + handler: (evt: Event) => void, + opt_capture?: boolean, + opt_scope?: {}, + ): void; /** * This method removes a previously added listener from the EventTarget instance. @@ -4146,7 +4362,12 @@ declare namespace H { * @param opt_capture {boolean=} - true indicates that the method should listen in the capture phase (bubble otherwise) * @param opt_scope {Object=} - An object defining the scope for the handler function */ - removeEventListener(type: string, handler: (evt: Event) => void, opt_capture?: boolean, opt_scope?: {}): void; + removeEventListener( + type: string, + handler: (evt: Event) => void, + opt_capture?: boolean, + opt_scope?: {}, + ): void; /** * This method dispatches an event on the EventTarget object. @@ -4272,7 +4493,12 @@ declare namespace H { * @param dataModel {H.map.DataModel} - An object encapsulating the data to be rendered on the map (layers and objects) * @param options {H.map.render.RenderEngine.Options} - An object containing the render engine initialization options */ - constructor(viewPort: H.map.ViewPort, viewModel: H.map.ViewModel, dataModel: H.map.DataModel, options: H.map.render.RenderEngine.Options); + constructor( + viewPort: H.map.ViewPort, + viewModel: H.map.ViewModel, + dataModel: H.map.DataModel, + options: H.map.render.RenderEngine.Options, + ); /** * This method sets the length (duration) for all animations run by the render engine in milliseconds. @@ -4313,7 +4539,12 @@ declare namespace H { * @param opt_capture {boolean=} - true indicates that the method should listen in the capture phase (bubble otherwise) * @param opt_scope {Object=} - An object defining the scope for the handler function */ - addEventListener(type: string, handler: (evt: Event) => void, opt_capture?: boolean, opt_scope?: {}): void; + addEventListener( + type: string, + handler: (evt: Event) => void, + opt_capture?: boolean, + opt_scope?: {}, + ): void; /** * This method removes a previously added listener from the EventTarget instance. @@ -4322,7 +4553,12 @@ declare namespace H { * @param opt_capture {boolean=} - true indicates that the method should listen in the capture phase (bubble otherwise) * @param opt_scope {Object=} - An object defining the scope for the handler function */ - removeEventListener(type: string, handler: (evt: Event) => void, opt_capture?: boolean, opt_scope?: {}): void; + removeEventListener( + type: string, + handler: (evt: Event) => void, + opt_capture?: boolean, + opt_scope?: {}, + ): void; /** * This method dispatches an event on the EventTarget object. @@ -4436,7 +4672,7 @@ declare namespace H { * @param target {(H.Map | H.map.Object)} - The event's target element * @param originalEvent {Event} - target of the event */ - constructor(viewportX: number, viewportY: number, target: (H.Map | H.map.Object), originalEvent: Event); + constructor(viewportX: number, viewportY: number, target: H.Map | H.map.Object, originalEvent: Event); viewportX: H.util.ContextItem[]; viewportY: number; @@ -4466,8 +4702,15 @@ declare namespace H { * @param target {(H.Map | H.map.Object)} - target map object which triggered event * @param originalEvent {Event} - original dom event */ - constructor(type: string, pointers: H.mapevents.Pointer[], changedPointers: H.mapevents.Pointer[], targetPointers: H.mapevents.Pointer[], currentPointer: H.mapevents.Pointer, - target: (H.Map | H.map.Object), originalEvent: Event); + constructor( + type: string, + pointers: H.mapevents.Pointer[], + changedPointers: H.mapevents.Pointer[], + targetPointers: H.mapevents.Pointer[], + currentPointer: H.mapevents.Pointer, + target: H.Map | H.map.Object, + originalEvent: Event, + ); /** * Sets defaultPrevented to true. Which can be used to prevent some default behavior. @@ -4484,8 +4727,8 @@ declare namespace H { targetPointers: H.mapevents.Pointer[]; currentPointer: H.mapevents.Pointer; originalEvent: Event; - target: (H.map.Object | H.Map); - currentTarget: (H.map.Object | H.Map); + target: H.map.Object | H.Map; + currentTarget: H.map.Object | H.Map; type: string; defaultPrevented: boolean; } @@ -4535,14 +4778,21 @@ declare namespace H { * @param opt_button {H.mapevents.Pointer.Button=} - Indicates which pointer device button has changed. * @param opt_buttons {number=} - Indicates which pointer device buttons are being pressed, expressed as a bitmask. Uses the same values, as "buttons" in Pointer Events spec. */ - constructor(viewportX: number, viewportY: number, id: number, type: string, opt_button?: H.mapevents.Pointer.Button, opt_buttons?: H.math.BitMask); + constructor( + viewportX: number, + viewportY: number, + id: number, + type: string, + opt_button?: H.mapevents.Pointer.Button, + opt_buttons?: H.math.BitMask, + ); viewportX: number; viewportY: number; - target: (H.map.Object | H.Map); + target: H.map.Object | H.Map; id: number; type: string; - dragTarget: (H.map.Object | H.Map); + dragTarget: H.map.Object | H.Map; button: H.mapevents.Pointer.Button; } @@ -4593,7 +4843,13 @@ declare namespace H { * @param target {(H.Map | H.map.Object)} - The event's target element * @param originalEvent {Event} - target of the event */ - constructor(deltaY: number, viewportX: number, viewportY: number, target: (H.Map | H.map.Object), originalEvent: Event); + constructor( + deltaY: number, + viewportX: number, + viewportY: number, + target: H.Map | H.map.Object, + originalEvent: Event, + ); delta: number; viewportX: number; @@ -4828,7 +5084,13 @@ declare namespace H { * the opt_baseUrl to use HTTPS. * @returns {H.service.IConfigurable} */ - configure(appId: string, appCode: string, useHTTPS: boolean, useCIT: boolean, opt_baseUrl?: H.service.Url): H.service.IConfigurable; + configure( + appId: string, + appCode: string, + useHTTPS: boolean, + useCIT: boolean, + opt_baseUrl?: H.service.Url, + ): H.service.IConfigurable; } namespace AbstractRestService { @@ -4841,10 +5103,10 @@ declare namespace H { interface DefaultLayers { vector: { normal: { - map: H.map.layer.TileLayer, - traffic: H.map.layer.TileLayer, - trafficincidents: H.map.layer.MarkerTileLayer - } + map: H.map.layer.TileLayer; + traffic: H.map.layer.TileLayer; + trafficincidents: H.map.layer.MarkerTileLayer; + }; }; raster: { normal: H.service.MapType; @@ -4871,7 +5133,11 @@ declare namespace H { * @param onResult {function(H.service.ServiceResult)} - this function will be called once the Enterprise Routing REST API provides a response to the request. * @param onError {function(Error)} - this function will be called if a communication error occurs during the JSON-P request */ - calculateRoute(calculateRouteParams: H.service.ServiceParameters, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): void; + calculateRoute( + calculateRouteParams: H.service.ServiceParameters, + onResult: (result: H.service.ServiceResult) => void, + onError: (error: Error) => void, + ): void; /** * This method sends a "getroute" request to Enterprise Routing REST API and calls the onResult callback function once the service response was received - providing @@ -4880,7 +5146,11 @@ declare namespace H { * @param onResult {function(H.service.ServiceResult)} - this function will be called once the Enterprise Routing REST API provides a response to the request. * @param onError {function(Error)} - this function will be called if a communication error occurs during the JSON-P request */ - getRoute(getRouteParams: H.service.ServiceParameters, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): void; + getRoute( + getRouteParams: H.service.ServiceParameters, + onResult: (result: H.service.ServiceResult) => void, + onError: (error: Error) => void, + ): void; /** * This method sends a "getlinkinfo" request to Enterprise Routing REST API and calls the onResult callback function once the service response was received - providing @@ -4889,7 +5159,11 @@ declare namespace H { * @param onResult {function(H.service.ServiceResult)} - this function will be called once the Enterprise Routing REST API provides a response to the request. * @param onError {function(Error)} - this function will be called if a communication error occurs during the JSON-P request */ - getLinkInfo(getLinkInfoParams: H.service.ServiceParameters, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): void; + getLinkInfo( + getLinkInfoParams: H.service.ServiceParameters, + onResult: (result: H.service.ServiceResult) => void, + onError: (error: Error) => void, + ): void; /** * This method sends a "calculateisoline" request to Enterprise Routing REST API and calls the onResult callback function once the service response was received - providing @@ -4898,7 +5172,11 @@ declare namespace H { * @param onResult {function(H.service.ServiceResult)} - this function will be called once the Enterprise Routing REST API provides a response to the request. * @param onError {function(Error)} - this function will be called if a communication error occurs during the JSON-P request */ - calculateIsoline(calculateIsolineParams: H.service.ServiceParameters, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): void; + calculateIsoline( + calculateIsolineParams: H.service.ServiceParameters, + onResult: (result: H.service.ServiceResult) => void, + onError: (error: Error) => void, + ): void; } namespace EnterpriseRoutingService { @@ -4933,7 +5211,11 @@ declare namespace H { * @param onError {function(Error)} - this function will be called if a communication error occurs during the JSON-P request * @returns {H.service.JsonpRequestHandle} */ - geocode(geoodingParams: H.service.ServiceParameters, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): H.service.JsonpRequestHandle; + geocode( + geoodingParams: H.service.ServiceParameters, + onResult: (result: H.service.ServiceResult) => void, + onError: (error: Error) => void, + ): H.service.JsonpRequestHandle; /** * This method sends a reverse geocoding request to Geocoder REST API and calls the onResult callback function once the service response was received - providing a H.service.ServiceResult @@ -4943,7 +5225,11 @@ declare namespace H { * @param onError {function(Error)} - this function will be called if a communication error occurs during the JSON-P request * @returns {H.service.JsonpRequestHandle} */ - reverseGeocode(reverseGeocodingParams: H.service.ServiceParameters, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): H.service.JsonpRequestHandle; + reverseGeocode( + reverseGeocodingParams: H.service.ServiceParameters, + onResult: (result: H.service.ServiceResult) => void, + onError: (error: Error) => void, + ): H.service.JsonpRequestHandle; /** * This method sends a landmark search request to Geocoder REST API and calls the onResult callback function once the service response was received - providing a H.service.ServiceResult @@ -4953,7 +5239,11 @@ declare namespace H { * @param onError {function(Error)} - this function will be called if a communication error occurs during the JSON-P request * @returns {H.service.JsonpRequestHandle} */ - search(searchParams: H.service.ServiceParameters, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): H.service.JsonpRequestHandle; + search( + searchParams: H.service.ServiceParameters, + onResult: (result: H.service.ServiceResult) => void, + onError: (error: Error) => void, + ): H.service.JsonpRequestHandle; } namespace GeocodingService { @@ -4981,7 +5271,13 @@ declare namespace H { * the opt_baseUrl to use HTTPS. * @returns {H.service.IConfigurable} */ - configure(appId: string, appCode: string, useHTTPS: boolean, useCIT: boolean, opt_baseUrl?: H.service.Url): H.service.IConfigurable; + configure( + appId: string, + appCode: string, + useHTTPS: boolean, + useCIT: boolean, + opt_baseUrl?: H.service.Url, + ): H.service.IConfigurable; } /** @@ -5032,8 +5328,14 @@ declare namespace H { * @param opt_options {H.service.TileProviderOptions=} - additional set of options for the provider * @returns {H.map.provider.ImageTileProvider} - the image tile provider */ - createTileProvider(tileType: string, scheme: string, tileSize: number, format: string, opt_additionalParameters?: H.service.ServiceParameters, opt_options?: H.service.TileProviderOptions): - H.map.provider.ImageTileProvider; + createTileProvider( + tileType: string, + scheme: string, + tileSize: number, + format: string, + opt_additionalParameters?: H.service.ServiceParameters, + opt_options?: H.service.TileProviderOptions, + ): H.map.provider.ImageTileProvider; /** * This method creates a tile layer. This layer can be used as a layer on a map's data model. @@ -5047,8 +5349,16 @@ declare namespace H { * @param opt_options {H.service.TileProviderOptions=} - additional set of options for the provider * @returns {H.map.layer.TileLayer} - the tile layer */ - createTileLayer(tileType: string, scheme: string, tileSize: number, format: string, opt_additionalParameters?: H.service.ServiceParameters, opt_opacity?: number, opt_dark?: boolean, - opt_options?: H.service.TileProviderOptions): H.map.layer.TileLayer; + createTileLayer( + tileType: string, + scheme: string, + tileSize: number, + format: string, + opt_additionalParameters?: H.service.ServiceParameters, + opt_opacity?: number, + opt_dark?: boolean, + opt_options?: H.service.TileProviderOptions, + ): H.map.layer.TileLayer; /** * This methods receive configuration parameters from the platform, that can be used by the object implementing the interface. @@ -5060,7 +5370,13 @@ declare namespace H { * the opt_baseUrl to use HTTPS. * @returns {H.service.IConfigurable} */ - configure(appId: string, appCode: string, useHTTPS: boolean, useCIT: boolean, opt_baseUrl?: H.service.Url): H.service.IConfigurable; + configure( + appId: string, + appCode: string, + useHTTPS: boolean, + useCIT: boolean, + opt_baseUrl?: H.service.Url, + ): H.service.IConfigurable; } namespace MapTileService { @@ -5140,8 +5456,12 @@ declare namespace H { * @param onError {Function} - callback which is called when error occured (i.e request timeout) * @returns {H.service.JsonpRequestHandle} - jsonp request handle */ - request(entryPoint: H.service.PlacesService.EntryPoint, entryPointParams: {}, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): - H.service.JsonpRequestHandle; + request( + entryPoint: H.service.PlacesService.EntryPoint, + entryPointParams: {}, + onResult: (result: H.service.ServiceResult) => void, + onError: (error: Error) => void, + ): H.service.JsonpRequestHandle; /** * Function triggers places api 'search' entry point. Please refer to documentation for parameter specification and response handling. @@ -5150,7 +5470,11 @@ declare namespace H { * @param onError {Function} * @returns {H.service.JsonpRequestHandle} - jsonp request handle */ - search(searchParams: H.service.ServiceParameters, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): H.service.JsonpRequestHandle; + search( + searchParams: H.service.ServiceParameters, + onResult: (result: H.service.ServiceResult) => void, + onError: (error: Error) => void, + ): H.service.JsonpRequestHandle; /** * Function triggers places api 'suggestions' entry point. Please refer to documentation for parameter specification and response handling. @@ -5159,7 +5483,11 @@ declare namespace H { * @param onError {Function} * @returns {H.service.JsonpRequestHandle} - jsonp request handle */ - suggest(suggestParams: H.service.ServiceParameters, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): H.service.JsonpRequestHandle; + suggest( + suggestParams: H.service.ServiceParameters, + onResult: (result: H.service.ServiceResult) => void, + onError: (error: Error) => void, + ): H.service.JsonpRequestHandle; /** * Function triggers places api 'explore' entry point. Please refer to documentation for parameter specification and response handling. @@ -5168,7 +5496,11 @@ declare namespace H { * @param onError {Function} * @returns {H.service.JsonpRequestHandle} - jsonp request handle */ - explore(exploreParams: H.service.ServiceParameters, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): H.service.JsonpRequestHandle; + explore( + exploreParams: H.service.ServiceParameters, + onResult: (result: H.service.ServiceResult) => void, + onError: (error: Error) => void, + ): H.service.JsonpRequestHandle; /** * Function triggers places api 'around' entry point. Please refer to documentation for parameter specification and response handling. @@ -5177,7 +5509,11 @@ declare namespace H { * @param onError {Function} * @returns {H.service.JsonpRequestHandle} - jsonp request handle */ - around(aroundParams: H.service.ServiceParameters, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): H.service.JsonpRequestHandle; + around( + aroundParams: H.service.ServiceParameters, + onResult: (result: H.service.ServiceResult) => void, + onError: (error: Error) => void, + ): H.service.JsonpRequestHandle; /** * Function triggers places api 'here' entry point. Please refer to documentation for parameter specification and response handling. @@ -5186,7 +5522,11 @@ declare namespace H { * @param onError {Function} * @returns {H.service.JsonpRequestHandle} - jsonp request handle */ - here(hereParams: H.service.ServiceParameters, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): H.service.JsonpRequestHandle; + here( + hereParams: H.service.ServiceParameters, + onResult: (result: H.service.ServiceResult) => void, + onError: (error: Error) => void, + ): H.service.JsonpRequestHandle; /** * Function triggers places api 'categories' entry point. Please refer to documentation for parameter specification and response handling. @@ -5195,7 +5535,11 @@ declare namespace H { * @param onError {Function} * @returns {H.service.JsonpRequestHandle} - jsonp request handle */ - categories(categoriesParams: H.service.ServiceParameters, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): H.service.JsonpRequestHandle; + categories( + categoriesParams: H.service.ServiceParameters, + onResult: (result: H.service.ServiceResult) => void, + onError: (error: Error) => void, + ): H.service.JsonpRequestHandle; /** * This method should be used to follow hyperlinks available in results returned by dicovery queries. @@ -5205,7 +5549,12 @@ declare namespace H { * @param opt_additionalParameters {Object=} - additional parameters to send with request * @returns {H.service.JsonpRequestHandle} - jsonp resquest handle */ - follow(hyperlink: string, onResult: (result: H.service.ServiceResult) => void, onError: (error: Error) => void, opt_additionalParameters?: {}): H.service.JsonpRequestHandle; + follow( + hyperlink: string, + onResult: (result: H.service.ServiceResult) => void, + onError: (error: Error) => void, + opt_additionalParameters?: {}, + ): H.service.JsonpRequestHandle; } namespace PlacesService { @@ -5315,16 +5664,24 @@ declare namespace H { * POI Categories as described at the Map Tile API documentation POI Categories chapter. * @returns {H.service.DefaultLayers} - a set of tile layers ready to use */ - createDefaultLayers(opt_tileSize?: (H.service.Platform.DefaultLayersOptions | number), opt_ppi?: number, - opt_lang?: string, opt_secondaryLang?: string, opt_style?: string, - opt_pois?: (string | boolean)): H.service.DefaultLayers; + createDefaultLayers( + opt_tileSize?: H.service.Platform.DefaultLayersOptions | number, + opt_ppi?: number, + opt_lang?: string, + opt_secondaryLang?: string, + opt_style?: string, + opt_pois?: string | boolean, + ): H.service.DefaultLayers; /** * This method returns an instance of H.service.RoutingService to query the Routing API. * @param opt_options {H.service.RoutingService.Options=} * @returns {H.service.RoutingService} */ - getRoutingService(opt_options?: H.service.RoutingService.Options, opt_version?: number): H.service.RoutingService; + getRoutingService( + opt_options?: H.service.RoutingService.Options, + opt_version?: number, + ): H.service.RoutingService; /** * @deprecated since 3.1.30.12 - This service is no longer being actively developed. @@ -5345,7 +5702,9 @@ declare namespace H { * @param opt_options {H.service.EnterpriseRoutingService.Options=} * @returns {H.service.EnterpriseRoutingService} */ - getEnterpriseRoutingService(opt_options?: H.service.EnterpriseRoutingService.Options): H.service.EnterpriseRoutingService; + getEnterpriseRoutingService( + opt_options?: H.service.EnterpriseRoutingService.Options, + ): H.service.EnterpriseRoutingService; } namespace Platform { @@ -5414,7 +5773,11 @@ declare namespace H { * @param onResult {function(H.service.RoutingServiceResult)} - this function will be called once the Routing REST API provides a response to the request. * @param onError {function(Error)} - this function will be called if a communication error occurs during the JSON-P request */ - calculateRoute(calculateRouteParams: H.service.ServiceParameters, onResult: (result: H.service.RoutingService.RoutingServiceResult) => void, onError: (error: Error) => void): void; + calculateRoute( + calculateRouteParams: H.service.ServiceParameters, + onResult: (result: H.service.RoutingService.RoutingServiceResult) => void, + onError: (error: Error) => void, + ): void; } namespace RoutingService { @@ -5431,8 +5794,8 @@ declare namespace H { interface RoutingServiceResult extends H.service.ServiceResult { routes: Array<{ - id: string, - sections: RoutingServiceSection[], + id: string; + sections: RoutingServiceSection[]; }>; } @@ -5440,19 +5803,19 @@ declare namespace H { id: string; type: string; transport: { - mode: string, + mode: string; }; arrival: { - time: string, - place: RoutingServicePlace, + time: string; + place: RoutingServicePlace; }; departure: { - time: string, - place: RoutingServicePlace + time: string; + place: RoutingServicePlace; }; summary: { - duration: number - length: number + duration: number; + length: number; }; polyline: string; } @@ -5483,137 +5846,139 @@ declare namespace H { [key: string]: any; response?: { - language?: string | undefined, - route?: Array<{ - leg: Array<{ - maneuver: Array<{ - id: string, - instruction: string, - length: number, - note: string[], - position: { - latitude: number, - longitude: number - }, - shape: string[], - travelTime: number, - _type: string - }> - }>, - mode: { - feature: any[], - trafficMode: string, - transportModes: string[], - type: string - } - shape: string[], - summary: { - baseTime: number, - distance: number, - flags: string[], - text: string, - trafficTime: number, - travelTime: number - } - waypoint: Array<{ - label: string, - linkId: string, - mappedPosition: { - latitude: number, - longitude: number - }, - mappedRoadName: string, - originalPosition: { - latitude: number, - longitude: number - }, - shapeIndex: number, - sideOfStreet: string, - spot: number, - type: string + language?: string | undefined; + route?: + | Array<{ + leg: Array<{ + maneuver: Array<{ + id: string; + instruction: string; + length: number; + note: string[]; + position: { + latitude: number; + longitude: number; + }; + shape: string[]; + travelTime: number; + _type: string; + }>; + }>; + mode: { + feature: any[]; + trafficMode: string; + transportModes: string[]; + type: string; + }; + shape: string[]; + summary: { + baseTime: number; + distance: number; + flags: string[]; + text: string; + trafficTime: number; + travelTime: number; + }; + waypoint: Array<{ + label: string; + linkId: string; + mappedPosition: { + latitude: number; + longitude: number; + }; + mappedRoadName: string; + originalPosition: { + latitude: number; + longitude: number; + }; + shapeIndex: number; + sideOfStreet: string; + spot: number; + type: string; + }>; }> - }> | undefined, - metaInfo: {} + | undefined; + metaInfo: {}; } | undefined; results?: { - items?: any[] | undefined, - next?: string | undefined + items?: any[] | undefined; + next?: string | undefined; } | undefined; search?: { context: { - href: string, + href: string; location: { address: { - city: string, - country: string, - countryCode: string, - county: string, - district: string, - house: string, - postalCode: string, - stateCode: string, - street: string, - text: string - }, - position: number[] - }, - type: string - } + city: string; + country: string; + countryCode: string; + county: string; + district: string; + house: string; + postalCode: string; + stateCode: string; + street: string; + text: string; + }; + position: number[]; + }; + type: string; + }; } | undefined; Response?: { MetaInfo: { - Timestamp: string - }, + Timestamp: string; + }; View: Array<{ Result: Array<{ Location: { Address: { AdditionalData: Array<{ - key: string, - value: string - }>, - City: string, - Country: string, - County: string, - District: string, - HouseNumber: string, - Label: string, - PostalCode: string, - State: string, - Street: string - }, + key: string; + value: string; + }>; + City: string; + Country: string; + County: string; + District: string; + HouseNumber: string; + Label: string; + PostalCode: string; + State: string; + Street: string; + }; DisplayPosition: { - Latitude: number, - Longitude: number - }, - LocationId: string, - LocationType: string, + Latitude: number; + Longitude: number; + }; + LocationId: string; + LocationType: string; MapView: { BottomRight: { - Latitude: number, - Longitude: number - }, + Latitude: number; + Longitude: number; + }; TopLeft: { - Latitude: number, - Longitude: number - } - }, + Latitude: number; + Longitude: number; + }; + }; NavigationPosition: Array<{ - Latitude: number, - Longitude: number - }> - }, - MatchLevel: string, + Latitude: number; + Longitude: number; + }>; + }; + MatchLevel: string; MatchQuality: { - City: number, - HouseNumber: number, - Street: number[] - }, - MatchType: string, - Relevance: number - }> - }>, - isolines: any[] + City: number; + HouseNumber: number; + Street: number[]; + }; + MatchType: string; + Relevance: number; + }>; + }>; + isolines: any[]; } | undefined; } @@ -5644,7 +6009,11 @@ declare namespace H { * @param onError {function()} * @returns {H.service.JsonpRequestHandle} */ - requestIncidents(serviceParams: H.service.ServiceParameters, onResponse: (result: H.service.ServiceResult) => void, onError: (error: Error) => void): H.service.JsonpRequestHandle; + requestIncidents( + serviceParams: H.service.ServiceParameters, + onResponse: (result: H.service.ServiceResult) => void, + onError: (error: Error) => void, + ): H.service.JsonpRequestHandle; /** * This method requests traffic incident information by tile coordinates @@ -5656,8 +6025,14 @@ declare namespace H { * @param opt_serviceParams {H.service.ServiceParameters=} - optional service parameters to be added to the request * @returns {H.service.JsonpRequestHandle} */ - requestIncidentsByTile(x: number, y: number, z: number, onResponse: (result: H.service.ServiceResult) => void, onError: (error: Error) => void, - opt_serviceParams?: H.service.ServiceParameters): H.service.JsonpRequestHandle; + requestIncidentsByTile( + x: number, + y: number, + z: number, + onResponse: (result: H.service.ServiceResult) => void, + onError: (error: Error) => void, + opt_serviceParams?: H.service.ServiceParameters, + ): H.service.JsonpRequestHandle; } namespace Service { @@ -5688,7 +6063,14 @@ declare namespace H { * @param opt_port {number=} - The port of the host on which the host listens. If a string is passed it must be convertible to an integer. * @param opt_anchor {string=} - an optional anchor part of the URL (usually preceded by '#'); */ - constructor(scheme: string, host: string, opt_path?: string, opt_params?: {}, opt_port?: number, opt_anchor?: string); + constructor( + scheme: string, + host: string, + opt_path?: string, + opt_params?: {}, + opt_port?: number, + opt_anchor?: string, + ); /** * This function parses a URL string and returns a H.service.Url object. The URL string must contain at least a scheme and a host. @@ -5815,13 +6197,13 @@ declare namespace H { * @param values {Array} - The list of values to be associated to a key in a query string. The the values order in the list will be preserved in the query string. * @throws {H.lang.InvalidArgumentError} - in case the argument of the constructor is not an array or its elements have types different from string and number. */ - constructor(values: Array); + constructor(values: Array); /** * Returns the array of values. * @returns {Array} */ - getValues(): Array; + getValues(): Array; } } @@ -5858,8 +6240,14 @@ declare namespace H { * @param opt_scheme {string=} - the scheme for which the meta info tiles a requested (default is 'normal.day') * @returns {H.map.provider.TileProvider} - the tile provider */ - createTileProvider(tileSize: number, pixelRatio: number, opt_categoryFilter?: string[], opt_additionalParameters?: H.service.ServiceParameters, opt_tileType?: string, - opt_scheme?: string): H.map.provider.TileProvider; + createTileProvider( + tileSize: number, + pixelRatio: number, + opt_categoryFilter?: string[], + opt_additionalParameters?: H.service.ServiceParameters, + opt_tileType?: string, + opt_scheme?: string, + ): H.map.provider.TileProvider; /** * This method creates a tile layer. This layer can be used as a layer on a map's data model. @@ -5871,8 +6259,14 @@ declare namespace H { * @param opt_scheme {string=} - the scheme for which the meta info tiles a requested (default is 'normal.day') * @returns {H.map.layer.TileLayer} - the tile layer */ - createTileLayer(tileSize: number, pixelRatio: number, opt_categoryFilter?: string[], opt_additionalParameters?: H.service.ServiceParameters, opt_tileType?: string, - opt_scheme?: string): H.map.layer.TileLayer; + createTileLayer( + tileSize: number, + pixelRatio: number, + opt_categoryFilter?: string[], + opt_additionalParameters?: H.service.ServiceParameters, + opt_tileType?: string, + opt_scheme?: string, + ): H.map.layer.TileLayer; /** * This methods receive configuration parameters from the platform, that can be used by the object implementing the interface. @@ -5884,7 +6278,13 @@ declare namespace H { * in the opt_baseUrl to use HTTPS. * @returns {H.service.IConfigurable} */ - configure(appId: string, appCode: string, useHTTPS: boolean, useCIT: boolean, opt_baseUrl?: H.service.Url): H.service.IConfigurable; + configure( + appId: string, + appCode: string, + useHTTPS: boolean, + useCIT: boolean, + opt_baseUrl?: H.service.Url, + ): H.service.IConfigurable; } namespace Service { @@ -5928,7 +6328,11 @@ declare namespace H { * @param opt_params {H.service.ServiceParameters=} - an additional set of URL parameters * @param opt_options {H.service.metaInfo.TileProvider.Options=} - additional parameters */ - constructor(service: (H.service.metaInfo.Service | H.service.MapTileService), opt_params?: H.service.ServiceParameters, opt_options?: H.service.metaInfo.TileProvider.Options); + constructor( + service: H.service.metaInfo.Service | H.service.MapTileService, + opt_params?: H.service.ServiceParameters, + opt_options?: H.service.metaInfo.TileProvider.Options, + ); } namespace TileProvider { @@ -6061,7 +6465,11 @@ declare namespace H { * @param onResult {function(H.service.ServiceResult)} - this function will be called once the Venue Maps API provides a response to the request * @param onError {function(string)} - this function will be called if a communication error occurs during request and error type is passed as an argument */ - discover(serviceParams: H.service.ServiceParameters, onResult: (res: H.service.ServiceResult) => void, onError: (s: string) => void): void; + discover( + serviceParams: H.service.ServiceParameters, + onResult: (res: H.service.ServiceResult) => void, + onError: (s: string) => void, + ): void; /** * This method creates a tile layer which can be added to the map in order to see the venues. It uses Interaction Tile endpoint of the Venue Maps API, more at @@ -6087,7 +6495,13 @@ declare namespace H { * in the opt_baseUrl to use HTTPS. * @returns {H.service.IConfigurable} */ - configure(appId: string, appCode: string, useHTTPS: boolean, useCIT: boolean, opt_baseUrl?: H.service.Url): H.service.IConfigurable; + configure( + appId: string, + appCode: string, + useHTTPS: boolean, + useCIT: boolean, + opt_baseUrl?: H.service.Url, + ): H.service.IConfigurable; } namespace Service { @@ -6121,7 +6535,12 @@ declare namespace H { * @param data {*} - The meta data of this space * @param opt_isFloorSpace {boolean=} - Indicates whether this space represents a floor itself, defaults to false */ - constructor(provider: H.map.provider.ObjectProvider, uid: string, data?: any, opt_isFloorSpace?: boolean); + constructor( + provider: H.map.provider.ObjectProvider, + uid: string, + data?: any, + opt_isFloorSpace?: boolean, + ); /** * The method indicates whether the spatial object represents the whole floor space or a space within a floor boundaries, that belongs to the floor. @@ -6134,7 +6553,7 @@ declare namespace H { * consistency currently it is not allowed to change the font family and the size of the labels. * @param labelStyle {(H.map.SpatialStyle | H.map.SpatialStyle.Options)} - Custom label style */ - initLabelStyle(labelStyle: (H.map.SpatialStyle | H.map.SpatialStyle.Options)): void; + initLabelStyle(labelStyle: H.map.SpatialStyle | H.map.SpatialStyle.Options): void; /** * Method returns parent object - floor (see H.service.venues.Floor) of the space. @@ -6580,7 +6999,11 @@ declare namespace H { * @param opt_locale {(H.ui.i18n.Localization | string)=} - the language to use (or a full localization object). * @returns {H.ui.UI} - the UI instance configured with the default controls */ - static createDefault(map: H.Map, mapTypes: H.service.Platform.MapTypes | H.service.DefaultLayers, opt_locale?: H.ui.i18n.Localization | string): H.ui.UI; + static createDefault( + map: H.Map, + mapTypes: H.service.Platform.MapTypes | H.service.DefaultLayers, + opt_locale?: H.ui.i18n.Localization | string, + ): H.ui.UI; /** * This method is used to capture the element view @@ -6589,7 +7012,12 @@ declare namespace H { * @param callback {ICapturable~captureCallback} - Callback function to call once result of the capturing is ready * @param opt_errback {ICapturable~errorCallback} - Callback function to call if error occurred during capturing */ - capture(canvas: HTMLCanvasElement, pixelRation: number, callback: (canvas?: HTMLCanvasElement) => void, opt_errback?: (error: string) => void): void; + capture( + canvas: HTMLCanvasElement, + pixelRation: number, + callback: (canvas?: HTMLCanvasElement) => void, + opt_errback?: (error: string) => void, + ): void; /** * @param canvas {HTMLCanvasElement=} @@ -6929,7 +7357,11 @@ declare namespace H { * @param opt_onDrop {function(string, ?, number)=} - A callback to be invoked when a data element is dropped from the cache * @param opt_filter {(function(string, ?, number): boolean)=} - A function to filter data elements that are not to be cached */ - constructor(maxSize: number, opt_onDrop?: (s: string, i: any, n: number) => void, opt_filter?: (s: string, i: any, n: number) => boolean); + constructor( + maxSize: number, + opt_onDrop?: (s: string, i: any, n: number) => void, + opt_filter?: (s: string, i: any, n: number) => boolean, + ); /** * This method sets this cache's maximum size to a new size. If the cache's contents exceed the new size, least recently used data elements will be dropped. @@ -6980,7 +7412,11 @@ declare namespace H { * @param opt_ctx {Object=} - an optional context object to be used as this within the callback * @param opt_matcher {(function(string, ?, number): boolean)=} - an optional match predicate to customize on which entries the callback will be called */ - forEach(callback: (s: string, i: any, n: number) => void, opt_ctx?: any, opt_matcher?: (s: string, i: any, n: number) => boolean): void; + forEach( + callback: (s: string, i: any, n: number) => void, + opt_ctx?: any, + opt_matcher?: (s: string, i: any, n: number) => boolean, + ): void; /** * This method removes all data elements from the cache. If the optional match predicate is passed to this method only those data elements will be removed for which the predicate @@ -7070,7 +7506,7 @@ declare namespace H { * This method will dispatch event on the event target object * @param evt {(H.util.Event | string)} - event object or event name */ - dispatchEvent(evt: (H.util.Event | string)): void; + dispatchEvent(evt: H.util.Event | string): void; /** * Removes listeners from this object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners. @@ -7167,7 +7603,12 @@ declare namespace H { * @param opt_capture {boolean=} - if set to true will listen in the capture phase (bubble otherwise) * @param opt_scope {Object=} - scope for the handler function */ - addEventListener(type: string, handler: EventListenerOrEventListenerObject, opt_capture?: boolean, opt_scope?: any): void; + addEventListener( + type: string, + handler: EventListenerOrEventListenerObject, + opt_capture?: boolean, + opt_scope?: any, + ): void; /** * This method will removed previously added listener from the event target @@ -7176,7 +7617,12 @@ declare namespace H { * @param opt_capture {boolean=} - if set to true will listen in the capture phase (bubble otherwise) * @param opt_scope {Object=} - scope for the handler function */ - removeEventListener(type: string, handler: EventListenerOrEventListenerObject, opt_capture?: boolean, opt_scope?: any): void; + removeEventListener( + type: string, + handler: EventListenerOrEventListenerObject, + opt_capture?: boolean, + opt_scope?: any, + ): void; /** * This method will dispatch event on the event target object @@ -7232,7 +7678,11 @@ declare namespace H { * @param opt_ctx {Object=} - an optional context object to be used as this within the callback * @param opt_matcher {(function(string, ?, number): boolean)=} - an optional match predicate to customize on which entries the callback will be called */ - forEach(callback: (s: string, t: any, n: number) => void, opt_ctx?: {}, opt_matcher?: ((s: string, t: any, n: number) => boolean)): void; + forEach( + callback: (s: string, t: any, n: number) => void, + opt_ctx?: {}, + opt_matcher?: (s: string, t: any, n: number) => boolean, + ): void; /** * This method removes all data elements from the cache. If the optional match predicate is passed to this method only those data elements will be removed for which the predicate @@ -7240,13 +7690,13 @@ declare namespace H { * @param opt_matcher {(function(string, ?, number): boolean)=} - an optional function that receives an entries id, data and size and may return true or false to either remove it or * leave the entry in the cache respectively */ - removeAll(opt_matcher?: ((s: string, t: any, n: number) => boolean)): void; + removeAll(opt_matcher?: (s: string, t: any, n: number) => boolean): void; /** * This method registers a callback that should be called each time an entry is dropped from the cache. * @param callback {(function(string, ?, number))} - the callback to be invoked for each entry */ - registerOnDrop(callback: ((s: string, t: any, n: number) => void)): void; + registerOnDrop(callback: (s: string, t: any, n: number) => void): void; } /** @@ -7267,7 +7717,12 @@ declare namespace H { * @param callback {ICapturable~captureCallback} - Callback function to call once result of the capturing is ready * @param opt_errback {ICapturable~errorCallback} - Callback function to call if error occurred during capturing */ - capture(canvas: HTMLCanvasElement, pixelRation: number, callback: (canvas?: HTMLCanvasElement) => void, opt_errback?: (error: string) => void): void; + capture( + canvas: HTMLCanvasElement, + pixelRation: number, + callback: (canvas?: HTMLCanvasElement) => void, + opt_errback?: (error: string) => void, + ): void; /** * @param canvas {HTMLCanvasElement=} @@ -7351,7 +7806,7 @@ declare namespace H { * This method will dispatch event on the event target object * @param evt {(H.util.Event | string)} - event object or event name */ - dispatchEvent(evt: (H.util.Event | string)): void; + dispatchEvent(evt: H.util.Event | string): void; /** * Removes listeners from this object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners. diff --git a/types/heroku-client/heroku-client-tests.ts b/types/heroku-client/heroku-client-tests.ts index ac88e54b7f8643..e4a93ff3cf1d6b 100644 --- a/types/heroku-client/heroku-client-tests.ts +++ b/types/heroku-client/heroku-client-tests.ts @@ -1,29 +1,29 @@ -import Heroku = require('heroku-client'); +import Heroku = require("heroku-client"); const heroku = new Heroku({ token: process.env.HEROKU_API_TOKEN }); (async () => { // $ExpectType Promise - heroku.get('/apps'); + heroku.get("/apps"); // $ExpectType Promise - heroku.post('/apps'); + heroku.post("/apps"); // $ExpectType Promise - heroku.post('/apps', { body: { name: 'my-new-app' } }); + heroku.post("/apps", { body: { name: "my-new-app" } }); // $ExpectType Promise - heroku.patch('/apps/my-app', { body: { name: 'my-renamed-app' } }); + heroku.patch("/apps/my-app", { body: { name: "my-renamed-app" } }); // $ExpectType Promise - heroku.delete('/apps/my-old-app'); + heroku.delete("/apps/my-old-app"); // $ExpectType Promise heroku.request({ - method: 'GET', - path: '/apps', + method: "GET", + path: "/apps", headers: { - Foo: 'Bar', + Foo: "Bar", }, parseJSON: false, }); diff --git a/types/heroku-client/index.d.ts b/types/heroku-client/index.d.ts index e14d4dedc506a7..b98c95cc00f24e 100644 --- a/types/heroku-client/index.d.ts +++ b/types/heroku-client/index.d.ts @@ -5,7 +5,7 @@ /// -import http = require('http'); +import http = require("http"); interface RequestURL { host: string; @@ -33,7 +33,7 @@ interface HerokuClientOptions extends Partial { headers?: Record; json?: boolean; logger?: RequestLogger; - method?: 'GET' | 'POST' | 'PATCH' | 'DELETE'; + method?: "GET" | "POST" | "PATCH" | "DELETE"; middleware?: (res: http.ServerResponse, cbk: () => void) => void; parseJSON?: boolean; partial?: boolean; @@ -135,17 +135,17 @@ declare class Heroku { constructor(options: HerokuClientOptions); - request(options: HerokuClientOptions): ReturnType; + request(options: HerokuClientOptions): ReturnType; - get(path: string, options?: HerokuClientOptions): ReturnType; + get(path: string, options?: HerokuClientOptions): ReturnType; - put(path: string, options?: HerokuClientOptions): ReturnType; + put(path: string, options?: HerokuClientOptions): ReturnType; - post(path: string, options?: HerokuClientOptions): ReturnType; + post(path: string, options?: HerokuClientOptions): ReturnType; - patch(path: string, options?: HerokuClientOptions): ReturnType; + patch(path: string, options?: HerokuClientOptions): ReturnType; - delete(path: string, options?: HerokuClientOptions): ReturnType; + delete(path: string, options?: HerokuClientOptions): ReturnType; } export = Heroku; diff --git a/types/heroku-logger/heroku-logger-tests.ts b/types/heroku-logger/heroku-logger-tests.ts index 9be06befa94029..ef5cb1b23f03de 100644 --- a/types/heroku-logger/heroku-logger-tests.ts +++ b/types/heroku-logger/heroku-logger-tests.ts @@ -1,11 +1,11 @@ -import * as logger from 'heroku-logger'; +import * as logger from "heroku-logger"; // tslint:disable-next-line:no-duplicate-imports -import { Logger, LoggerConfig } from 'heroku-logger'; +import { Logger, LoggerConfig } from "heroku-logger"; -logger.trace(''); // $ExpectType void -logger.debug(''); // $ExpectType void -logger.info(''); // $ExpectType void -logger.warn(''); // $ExpectType void -logger.error(''); // $ExpectType void -logger.fatal(''); // $ExpectType void +logger.trace(""); // $ExpectType void +logger.debug(""); // $ExpectType void +logger.info(""); // $ExpectType void +logger.warn(""); // $ExpectType void +logger.error(""); // $ExpectType void +logger.fatal(""); // $ExpectType void new logger.Logger({}); // $ExpectType Logger diff --git a/types/hex-array/hex-array-tests.ts b/types/hex-array/hex-array-tests.ts index 198174349ce96c..63d0c849cb5df9 100644 --- a/types/hex-array/hex-array-tests.ts +++ b/types/hex-array/hex-array-tests.ts @@ -1,6 +1,6 @@ -import * as hexArray from 'hex-array'; +import * as hexArray from "hex-array"; hexArray.toString(new Uint8Array([0x1, 0x2, 0x3]), { uppercase: true }); // $ExpectType string hexArray.toString(new Uint8Array([0x1, 0x2, 0x3])); // $ExpectType string -hexArray.fromString('abcd'); // $ExpectType Uint8Array +hexArray.fromString("abcd"); // $ExpectType Uint8Array diff --git a/types/hex-color-regex/hex-color-regex-tests.ts b/types/hex-color-regex/hex-color-regex-tests.ts index fcb53a412730dc..1b8053f883a191 100644 --- a/types/hex-color-regex/hex-color-regex-tests.ts +++ b/types/hex-color-regex/hex-color-regex-tests.ts @@ -1,4 +1,4 @@ -import hexColorRegex = require('hex-color-regex'); +import hexColorRegex = require("hex-color-regex"); hexColorRegex(); // $ExpectType RegExp hexColorRegex({ strict: true }); // $ExpectType RegExp diff --git a/types/hex-rgba/hex-rgba-tests.ts b/types/hex-rgba/hex-rgba-tests.ts index b18149419c9e44..81bbdad5684093 100644 --- a/types/hex-rgba/hex-rgba-tests.ts +++ b/types/hex-rgba/hex-rgba-tests.ts @@ -1,4 +1,4 @@ -import hexToRgba = require('hex-rgba'); +import hexToRgba = require("hex-rgba"); -const rgba = hexToRgba('#1b2b34', 40); -const rgbaWithoutOpacity = hexToRgba('#1b2b34'); +const rgba = hexToRgba("#1b2b34", 40); +const rgbaWithoutOpacity = hexToRgba("#1b2b34"); diff --git a/types/hex-to-uuid/hex-to-uuid-tests.ts b/types/hex-to-uuid/hex-to-uuid-tests.ts index 44ee5f9ebd84ed..25b337e5bf06da 100644 --- a/types/hex-to-uuid/hex-to-uuid-tests.ts +++ b/types/hex-to-uuid/hex-to-uuid-tests.ts @@ -1,7 +1,7 @@ -import hexToUuid = require('hex-to-uuid'); +import hexToUuid = require("hex-to-uuid"); // $ExpectType string -hexToUuid('0xd3fd354067184687956bc8618a26e335'); +hexToUuid("0xd3fd354067184687956bc8618a26e335"); // @ts-expect-error hexToUuid(); diff --git a/types/hex2dec/hex2dec-tests.ts b/types/hex2dec/hex2dec-tests.ts index fef345ce1942d1..f20d82263fea61 100644 --- a/types/hex2dec/hex2dec-tests.ts +++ b/types/hex2dec/hex2dec-tests.ts @@ -1,7 +1,7 @@ -import hex2dec = require('hex2dec'); +import hex2dec = require("hex2dec"); -hex2dec.hexToDec('0xFA'); // $ExpectType string | null -hex2dec.hexToDec('nonsense'); // $ExpectType string | null -hex2dec.decToHex('250'); // $ExpectType string | null -hex2dec.decToHex('250', { prefix: false }); // $ExpectType string | null -hex2dec.decToHex('nonsense'); // $ExpectType string | null +hex2dec.hexToDec("0xFA"); // $ExpectType string | null +hex2dec.hexToDec("nonsense"); // $ExpectType string | null +hex2dec.decToHex("250"); // $ExpectType string | null +hex2dec.decToHex("250", { prefix: false }); // $ExpectType string | null +hex2dec.decToHex("nonsense"); // $ExpectType string | null diff --git a/types/hexo-fs/hexo-fs-tests.ts b/types/hexo-fs/hexo-fs-tests.ts index d678e91f34565b..c04741ffe79c0c 100644 --- a/types/hexo-fs/hexo-fs-tests.ts +++ b/types/hexo-fs/hexo-fs-tests.ts @@ -1,19 +1,19 @@ -import 'mocha'; -import fs = require('hexo-fs'); -import chai = require('chai'); -import Promise = require('bluebird'); -import { FSWatcher } from 'chokidar'; +import "mocha"; +import fs = require("hexo-fs"); +import chai = require("chai"); +import Promise = require("bluebird"); +import { FSWatcher } from "chokidar"; const should = chai.should(); -let string = ''; +let string = ""; let strings = [string]; let bool = false; let boolPromise: Promise; let stringPromise: Promise; let stringsPromise: Promise; -let stringOrStrings: string|string[]; -let stringOrStringsPromise: Promise; +let stringOrStrings: string | string[]; +let stringOrStringsPromise: Promise; let watcherPromise: Promise; let writeStream: fs.WriteStream; let writeStreamPromise: Promise; @@ -35,24 +35,24 @@ fs.mkdirs(string, err => { fs.mkdirsSync(string); // $ExpectType Bluebird -fs.writeFile(string, 'foo'); +fs.writeFile(string, "foo"); -fs.writeFile(string, 'foo', err => { +fs.writeFile(string, "foo", err => { should.not.exist(err); }); // $ExpectType void -fs.writeFileSync(string, 'foo'); +fs.writeFileSync(string, "foo"); // $ExpectType Bluebird -fs.appendFile(string, 'foo'); +fs.appendFile(string, "foo"); -fs.appendFile(string, 'bar', err => { +fs.appendFile(string, "bar", err => { should.not.exist(err); }); // $ExpectType void -fs.appendFileSync(string, 'bar'); +fs.appendFileSync(string, "bar"); // $ExpectType Bluebird fs.copyFile(string, string); diff --git a/types/hexo-fs/index.d.ts b/types/hexo-fs/index.d.ts index 117e99b6914f34..fd556d3b473c97 100644 --- a/types/hexo-fs/index.d.ts +++ b/types/hexo-fs/index.d.ts @@ -4,69 +4,69 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Minimum TypeScript Version: 3.9 -import Promise = require('bluebird'); +import Promise = require("bluebird"); import { - PathLike, - Stats, - ReadStream, - WriteStream, // chmod, chmodSync, - // fchmod, - fchmodSync, - // lchmod, - lchmodSync, // chown, chownSync, - // fchown, - fchownSync, - // lchown, - lchownSync, // close, closeSync, createReadStream, createWriteStream, + // fchmod, + fchmodSync, + // fchown, + fchownSync, + // fstat, + fstatSync, // fsync, fsyncSync, + // ftruncate, + ftruncateSync, + // futimes, + futimesSync, + // lchmod, + lchmodSync, + // lchown, + lchownSync, // link, linkSync, + // lstat, + lstatSync, // mkdir, mkdirSync, // open, openSync, - // symlink, - symlinkSync, - // read, - readSync, + PathLike, // readdir, readdirSync, // readlink, readlinkSync, + ReadStream, + // read, + readSync, // realpath, realpathSync, // rename, renameSync, + Stats, // stat, statSync, - // fstat, - fstatSync, - // lstat, - lstatSync, + // symlink, + symlinkSync, // truncate, truncateSync, - // ftruncate, - ftruncateSync, // unlink, unlinkSync, + unwatchFile, // utimes, utimesSync, - // futimes, - futimesSync, watchFile, - unwatchFile, + WriteStream, // write, - writeSync -} from 'graceful-fs'; + writeSync, +} from "graceful-fs"; export interface DirectoryOptions { ignoreHidden?: boolean | undefined; @@ -96,7 +96,12 @@ export function appendFile(path: string, data: any, callback?: (err: any) => voi /** * Appends data to a file. */ -export function appendFile(path: string, data: any, options: string | AppendFileOptions, callback?: (err: any) => void): Promise; +export function appendFile( + path: string, + data: any, + options: string | AppendFileOptions, + callback?: (err: any) => void, +): Promise; /** * Synchronous version of fs.appendFile. */ @@ -126,7 +131,12 @@ export function copyDir(src: string, dest: string, callback?: (err: any, value?: /** * Copies a directory from src to dest. It returns an array of copied files. */ -export function copyDir(src: string, dest: string, options?: DirectoryOptions, callback?: (err: any, value?: string[]) => void): Promise; +export function copyDir( + src: string, + dest: string, + options?: DirectoryOptions, + callback?: (err: any, value?: string[]) => void, +): Promise; /** * Copies a file from src to dest. */ @@ -139,13 +149,20 @@ export { createReadStream, createWriteStream }; /** * Deletes all files in a directory. It returns an array of deleted files. */ -export function emptyDir(path: string, callback?: (err: any, value?: string | string[]) => void): Promise; +export function emptyDir( + path: string, + callback?: (err: any, value?: string | string[]) => void, +): Promise; export function emptyDir( path: string, options?: DirectoryOptions & { exclude?: string[] | undefined }, - callback?: (err: any, value?: string | string[]) => void + callback?: (err: any, value?: string | string[]) => void, ): Promise; -export function emptyDirSync(path: string, options?: DirectoryOptions & { exclude?: string[] | undefined }, parent?: string): string | string[]; +export function emptyDirSync( + path: string, + options?: DirectoryOptions & { exclude?: string[] | undefined }, + parent?: string, +): string | string[]; // ensurePath /** @@ -161,7 +178,10 @@ export function ensurePathSync(path: string): string; /** * Creates the parent directories if they does not exist and returns a writable stream. */ -export function ensureWriteStream(path: string, callback?: (err: any, value?: WriteStream) => void): Promise; +export function ensureWriteStream( + path: string, + callback?: (err: any, value?: WriteStream) => void, +): Promise; /** * Creates the parent directories if they does not exist and returns a writable stream. */ @@ -175,19 +195,22 @@ export function ensureWriteStream( autoClose?: boolean | undefined; start?: number | undefined; }, - callback?: (err: any, value?: WriteStream) => void + callback?: (err: any, value?: WriteStream) => void, ): Promise; /** * Synchronous version of fs.ensureWriteStream. */ -export function ensureWriteStreamSync(path: string, options?: string | { - flags?: string | undefined; - defaultEncoding?: string | undefined; - fd?: number | undefined; - mode?: number | undefined; - autoClose?: boolean | undefined; - start?: number | undefined; -}): WriteStream; +export function ensureWriteStreamSync( + path: string, + options?: string | { + flags?: string | undefined; + defaultEncoding?: string | undefined; + fd?: number | undefined; + mode?: number | undefined; + autoClose?: boolean | undefined; + start?: number | undefined; + }, +): WriteStream; // exists /** @@ -216,7 +239,11 @@ export function listDir(path: string, callback?: (err: any, value?: string[]) => /** * Lists files in a directory. */ -export function listDir(path: string, options?: DirectoryOptions, callback?: (err: any, value?: string[]) => void): Promise; +export function listDir( + path: string, + options?: DirectoryOptions, + callback?: (err: any, value?: string[]) => void, +): Promise; /** * Synchronous version of `fs.listDir`. */ @@ -250,14 +277,20 @@ export function read( buffer: TBuffer, offset: number, length: number, - position: number | null -): Promise<{ bytesRead: number, buffer: TBuffer }>; // promisify + position: number | null, +): Promise<{ bytesRead: number; buffer: TBuffer }>; // promisify export { readSync }; // readdir -export function readdir(path: PathLike, options?: { encoding: BufferEncoding | null } | BufferEncoding | null): Promise; // promisify +export function readdir( + path: PathLike, + options?: { encoding: BufferEncoding | null } | BufferEncoding | null, +): Promise; // promisify export function readdir(path: PathLike, options: "buffer" | { encoding: "buffer" }): Promise; // promisify -export function readdir(path: PathLike, options?: { encoding?: string | null | undefined } | string | null): Promise>; // promisify +export function readdir( + path: PathLike, + options?: { encoding?: string | null | undefined } | string | null, +): Promise>; // promisify export { readdirSync }; // readFile @@ -270,24 +303,39 @@ export function readFile(path: PathLike | number, callback?: (err: any, value?: */ export function readFile( path: PathLike | number, - options?: { encoding?: string | undefined; flag?: string | undefined; escape?: boolean | undefined; }, - callback?: (err: any, value?: string) => void + options?: { encoding?: string | undefined; flag?: string | undefined; escape?: boolean | undefined }, + callback?: (err: any, value?: string) => void, ): Promise; /** * Synchronous version of `fs.readFile`. */ -export function readFileSync(path: PathLike | number, options?: { encoding?: string | undefined; flag?: string | undefined; escape?: boolean | undefined; }): string; +export function readFileSync( + path: PathLike | number, + options?: { encoding?: string | undefined; flag?: string | undefined; escape?: boolean | undefined }, +): string; // readlink -export function readlink(path: PathLike, options?: { encoding?: BufferEncoding | null | undefined } | BufferEncoding | null): Promise; // promisify -export function readlink(path: PathLike, options: { encoding: 'buffer' } | 'buffer'): Promise; // promisify -export function readlink(path: PathLike, options?: { encoding?: string | null | undefined } | string | null): Promise; // promisify +export function readlink( + path: PathLike, + options?: { encoding?: BufferEncoding | null | undefined } | BufferEncoding | null, +): Promise; // promisify +export function readlink(path: PathLike, options: { encoding: "buffer" } | "buffer"): Promise; // promisify +export function readlink( + path: PathLike, + options?: { encoding?: string | null | undefined } | string | null, +): Promise; // promisify export { readlinkSync }; // realpath -export function realpath(path: PathLike, options?: { encoding?: BufferEncoding | null | undefined } | BufferEncoding | null): Promise; // promisify -export function realpath(path: PathLike, options: { encoding: 'buffer' } | 'buffer'): Promise; // promisify -export function realpath(path: PathLike, options?: { encoding?: string | null | undefined } | string | null): Promise; // promisify +export function realpath( + path: PathLike, + options?: { encoding?: BufferEncoding | null | undefined } | BufferEncoding | null, +): Promise; // promisify +export function realpath(path: PathLike, options: { encoding: "buffer" } | "buffer"): Promise; // promisify +export function realpath( + path: PathLike, + options?: { encoding?: string | null | undefined } | string | null, +): Promise; // promisify export { realpathSync }; // rename @@ -302,12 +350,12 @@ export function rmdirSync(path: string): void; export function stat(path: PathLike): Promise; // promisify export function fstat(fd: number): Promise; // promisify export function lstat(path: PathLike): Promise; // promisify -export { statSync, fstatSync, lstatSync }; +export { fstatSync, lstatSync, statSync }; // truncate export function truncate(path: PathLike, len?: number | null): Promise; // promisify export function ftruncate(fd: number, len?: number | null): Promise; // promisify -export { truncateSync, ftruncateSync }; +export { ftruncateSync, truncateSync }; // unlink export function unlink(path: PathLike): Promise; // promisify @@ -316,17 +364,21 @@ export { unlinkSync }; // utimes export function utimes(path: PathLike, atime: string | number | Date, mtime: string | number | Date): Promise; // promisify export function futimes(fd: number, atime: string | number | Date, mtime: string | number | Date): Promise; // promisify -export { utimesSync, futimesSync }; +export { futimesSync, utimesSync }; // watch -import { FSWatcher, WatchOptions } from 'chokidar'; +import { FSWatcher, WatchOptions } from "chokidar"; /** * Watches changes of a file or a directory. * * See Chokidar API for more info. */ -export function watch(path: string | string[], options?: WatchOptions, callback?: (err: any, value?: FSWatcher) => void): Promise; -export { watchFile, unwatchFile }; +export function watch( + path: string | string[], + options?: WatchOptions, + callback?: (err: any, value?: FSWatcher) => void, +): Promise; +export { unwatchFile, watchFile }; // write export function write( @@ -334,14 +386,14 @@ export function write( buffer?: TBuffer, offset?: number, length?: number, - position?: number | null -): Promise<{ bytesWritten: number, buffer: TBuffer }>; // promisify + position?: number | null, +): Promise<{ bytesWritten: number; buffer: TBuffer }>; // promisify export function write( fd: number, string: any, position?: number | null, - encoding?: string | null -): Promise<{ bytesWritten: number, buffer: string }>; // promisify + encoding?: string | null, +): Promise<{ bytesWritten: number; buffer: string }>; // promisify export { writeSync }; // writeFile @@ -355,16 +407,28 @@ export function writeFile(path: string, data: any, callback?: (err: any) => void export function writeFile( path: string, data: any, - options?: string | { encoding?: string | null | undefined; mode?: string | number | undefined; flag?: string | undefined }, - callback?: (err: any) => void + options?: string | { + encoding?: string | null | undefined; + mode?: string | number | undefined; + flag?: string | undefined; + }, + callback?: (err: any) => void, ): Promise; /** * Synchronous version of `fs.writeFile`. */ -export function writeFileSync(path: string, data: any, options?: string | { encoding?: string | null | undefined; mode?: string | number | undefined; flag?: string | undefined }): void; +export function writeFileSync( + path: string, + data: any, + options?: string | { + encoding?: string | null | undefined; + mode?: string | number | undefined; + flag?: string | undefined; + }, +): void; // Static classes -export { Stats, ReadStream, WriteStream } from 'graceful-fs'; +export { ReadStream, Stats, WriteStream } from "graceful-fs"; // util export function escapeEOL(str: string): string; diff --git a/types/hexo-log/hexo-log-tests.ts b/types/hexo-log/hexo-log-tests.ts index a6fbcced579b69..925858c4be8815 100644 --- a/types/hexo-log/hexo-log-tests.ts +++ b/types/hexo-log/hexo-log-tests.ts @@ -1,8 +1,8 @@ -import logger = require('hexo-log'); +import logger = require("hexo-log"); declare function it(s: string, cb: () => void): void; -it('add alias for levels', () => { +it("add alias for levels", () => { const log = logger(); log.d === log.debug; @@ -12,41 +12,41 @@ it('add alias for levels', () => { log.log === log.info; }); -it('default name is hexo', () => { +it("default name is hexo", () => { const log = logger(); - log.fields.name === 'hexo'; + log.fields.name === "hexo"; }); -it('options.name', () => { - const log = logger({ name: 'foo' }); - log.fields === 'foo'; +it("options.name", () => { + const log = logger({ name: "foo" }); + log.fields === "foo"; }); -it('level should be trace if options.debug is true', () => { +it("level should be trace if options.debug is true", () => { const log = logger({ debug: true }); // TODO // log.streams[0].level.should.eql(10); }); -it('should add file stream if options.debug is true', () => { +it("should add file stream if options.debug is true", () => { const log = logger({ debug: true }); // TODO // log.streams[1].path === 'debug.log'; }); -it('should remove console stream if options.silent is true', () => { +it("should remove console stream if options.silent is true", () => { const log = logger({ silent: true }); // TODO // log.streams.length === 0; }); -it('should display time if options.debug is true', () => { +it("should display time if options.debug is true", () => { const log = logger({ debug: true }); - log.info('test'); + log.info("test"); }); -it('should print error to process.stderr stream', () => { +it("should print error to process.stderr stream", () => { const log = logger(); - log.error('test'); + log.error("test"); }); diff --git a/types/hexo-log/index.d.ts b/types/hexo-log/index.d.ts index ab9709c90fcf70..be10ba06077a47 100644 --- a/types/hexo-log/index.d.ts +++ b/types/hexo-log/index.d.ts @@ -4,8 +4,8 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.0 -import bunyan = require('hexo-bunyan'); -import streams = require('stream'); +import bunyan = require("hexo-bunyan"); +import streams = require("stream"); declare class HexoLogger extends bunyan { /** @@ -154,6 +154,8 @@ declare class HexoLogger extends bunyan { log(format: any, ...params: any[]): void; } -declare function createLogger(options?: { name?: string | undefined; silent?: boolean | undefined; debug?: boolean | undefined; }): HexoLogger; +declare function createLogger( + options?: { name?: string | undefined; silent?: boolean | undefined; debug?: boolean | undefined }, +): HexoLogger; export = createLogger; diff --git a/types/hexo-util/hexo-util-tests.ts b/types/hexo-util/hexo-util-tests.ts index fd416975835c7b..714ee87db8b815 100644 --- a/types/hexo-util/hexo-util-tests.ts +++ b/types/hexo-util/hexo-util-tests.ts @@ -13,18 +13,18 @@ import { slugize, spawn, truncate, - wordWrap -} from 'hexo-util'; + wordWrap, +} from "hexo-util"; -import { expect } from 'chai'; +import { expect } from "chai"; -import { Readable } from 'stream'; -import { createHash } from 'crypto'; -import { join } from 'path'; +import { createHash } from "crypto"; +import { join } from "path"; +import { Readable } from "stream"; let buffer = Buffer.alloc(0); -let directory: { [x: string]: any; } = {}; -let string = ''; +let directory: { [x: string]: any } = {}; +let string = ""; const cacheStream = new CacheStream(); const hashStream = new HashStream(); @@ -35,245 +35,272 @@ readable.pipe(cacheStream); buffer = cacheStream.getCache(); cacheStream.destroy(); -directory = camelCaseKeys({ foo_bar: 'test' }); -directory = camelCaseKeys({ foo_bar: 'test' }); -directory = camelCaseKeys({ _foo_bar: 'test', __bar_baz: 'foo' }); -directory = camelCaseKeys({ fooBar: 'test' }); +directory = camelCaseKeys({ foo_bar: "test" }); +directory = camelCaseKeys({ foo_bar: "test" }); +directory = camelCaseKeys({ _foo_bar: "test", __bar_baz: "foo" }); +directory = camelCaseKeys({ fooBar: "test" }); -escapeDiacritic('Hell\u00F2 w\u00F2rld') === 'Hello world'; -escapeHTML('

Hello "world".

') === '<p>Hello "world".</p>'; -escapeRegExp('hello*world') === 'hello\\*world'; +escapeDiacritic("Hell\u00F2 w\u00F2rld") === "Hello world"; +escapeHTML("

Hello \"world\".

") === "<p>Hello "world".</p>"; +escapeRegExp("hello*world") === "hello\\*world"; const sha1 = (content: string) => { - const hash = createHash('sha1'); + const hash = createHash("sha1"); hash.update(content); return hash.digest(); }; -string = '123456'; +string = "123456"; hash(string).equals(sha1(string)); sha1(string).equals(hashStream.read()); -const testString = JSON.stringify({ - foo: 1, - bar: 2 -}, null, ' '); +const testString = JSON.stringify( + { + foo: 1, + bar: 2, + }, + null, + " ", +); string = highlight(testString); string = highlight(testString, { gutter: false }); string = highlight(testString, { wrap: false }); string = highlight(testString, { firstLine: 3 }); -string = highlight(testString, { lang: 'json' }); +string = highlight(testString, { lang: "json" }); string = highlight(testString, { autoDetect: true }); -string = highlight('test', { lang: 'jrowiejrowi' }); -string = highlight(testString, { caption: 'hello world' }); - -string = highlight([ - 'function fib(i){', - '\tif (i <= 1) return i;', - '\treturn fib(i - 1) + fib(i - 2);', - '}' -].join('\n'), { tab: ' ', lang: 'js' }); - -string = highlight([ - 'const string = `', - ' Multi', - ' line', - ' string', - '`' -].join('\n'), { lang: 'js' }); - -string = highlight([ - 'const string = `', - ' Multi', - '', - ' string', - '`' -].join('\n'), { lang: 'js' }); - -string = highlight([ - '"use strict";', - 'const string = `', - ' Multi', - '', - ' string', - '`' -].join('\n'), { autoDetect: true }); - -string = highlight([ - 'roses are red', - 'violets are blue', - 'sugar is sweet', - 'and so are you' -].join('\n'), { mark: [1, 3, 5] }); - -string.includes('class="line marked">roses'); -string.includes('class="line">violets'); -string.includes('class="line marked">sugar'); -string.includes('class="line">and'); - -const gutterStart = '
';
-const codeStart = '
';
-
-string = highlight([
-    'a => {',
-    '    if (a > 3)',
-    '        return true;',
-    '    return false;',
-    '}'
-].join('\n'), { hljs: true, lang: 'javascript' });
+string = highlight("test", { lang: "jrowiejrowi" });
+string = highlight(testString, { caption: "hello world" });
+
+string = highlight(
+    [
+        "function fib(i){",
+        "\tif (i <= 1) return i;",
+        "\treturn fib(i - 1) + fib(i - 2);",
+        "}",
+    ].join("\n"),
+    { tab: "  ", lang: "js" },
+);
+
+string = highlight(
+    [
+        "const string = `",
+        "  Multi",
+        "  line",
+        "  string",
+        "`",
+    ].join("\n"),
+    { lang: "js" },
+);
+
+string = highlight(
+    [
+        "const string = `",
+        "  Multi",
+        "",
+        "  string",
+        "`",
+    ].join("\n"),
+    { lang: "js" },
+);
+
+string = highlight(
+    [
+        "\"use strict\";",
+        "const string = `",
+        "  Multi",
+        "",
+        "  string",
+        "`",
+    ].join("\n"),
+    { autoDetect: true },
+);
+
+string = highlight(
+    [
+        "roses are red",
+        "violets are blue",
+        "sugar is sweet",
+        "and so are you",
+    ].join("\n"),
+    { mark: [1, 3, 5] },
+);
+
+string.includes("class=\"line marked\">roses");
+string.includes("class=\"line\">violets");
+string.includes("class=\"line marked\">sugar");
+string.includes("class=\"line\">and");
+
+const gutterStart = "
";
+const codeStart = "
";
+
+string = highlight(
+    [
+        "a => {",
+        "    if (a > 3)",
+        "        return true;",
+        "    return false;",
+        "}",
+    ].join("\n"),
+    { hljs: true, lang: "javascript" },
+);
 
 string.includes(gutterStart);
 string.includes(codeStart);
-string.includes('code class="hljs javascript"');
-string.includes('class="hljs-function"');
-
-string = highlight([
-    'a => {',
-    '    if (a > 3)',
-    '        return true;',
-    '    return false;',
-    '}'
-].join('\n'), { hljs: true, gutter: false, lang: 'javascript' });
+string.includes("code class=\"hljs javascript\"");
+string.includes("class=\"hljs-function\"");
+
+string = highlight(
+    [
+        "a => {",
+        "    if (a > 3)",
+        "        return true;",
+        "    return false;",
+        "}",
+    ].join("\n"),
+    { hljs: true, gutter: false, lang: "javascript" },
+);
 
 !string.includes(gutterStart);
 !string.includes(codeStart);
-string.includes('code class="hljs javascript"');
-string.includes('class="hljs-function"');
+string.includes("code class=\"hljs javascript\"");
+string.includes("class=\"hljs-function\"");
 
-string = htmlTag('hr');
-string = htmlTag('img', { src: 'http://placekitten.com/200/300' });
-string = htmlTag('img', {
-    src: 'http://placekitten.com/200/300',
+string = htmlTag("hr");
+string = htmlTag("img", { src: "http://placekitten.com/200/300" });
+string = htmlTag("img", {
+    src: "http://placekitten.com/200/300",
     width: 200,
-    height: 300
+    height: 300,
 });
-string = htmlTag('a', { href: 'http://zespia.tw' }, 'My blog');
-string = htmlTag('ul', {}, '
  • Hello!', false); +string = htmlTag("a", { href: "http://zespia.tw" }, "My blog"); +string = htmlTag("ul", {}, "
  • Hello!", false); { - const pattern = new Pattern('posts/:id'); - const result = pattern.match('/posts/89'); + const pattern = new Pattern("posts/:id"); + const result = pattern.match("/posts/89"); - result![0] === 'posts/89'; - result![1] === '89'; - result!.id === '89'; + result![0] === "posts/89"; + result![1] === "89"; + result!.id === "89"; } { - const pattern = new Pattern('posts/*path'); - const result = pattern.match('posts/2013/hello-world'); + const pattern = new Pattern("posts/*path"); + const result = pattern.match("posts/2013/hello-world"); - result![0] === 'posts/2013/hello-world'; - result![1] === '2013/hello-world'; - result!.path === '2013/hello-world'; + result![0] === "posts/2013/hello-world"; + result![1] === "2013/hello-world"; + result!.path === "2013/hello-world"; } { - const pattern = new Pattern('posts/:id?'); - const result = pattern.match('posts/'); + const pattern = new Pattern("posts/:id?"); + const result = pattern.match("posts/"); - result![0] === 'posts/'; + result![0] === "posts/"; result![1] === undefined; result!.id === undefined; } { - const pattern = new Pattern('posts/:id?'); - const result = pattern.match('posts/89'); + const pattern = new Pattern("posts/:id?"); + const result = pattern.match("posts/89"); - result![0] === 'posts/89'; - result![1] === '89'; - result!.id === '89'; + result![0] === "posts/89"; + result![1] === "89"; + result!.id === "89"; } { const pattern = new Pattern(/ab?cd/); - pattern.match('abcd')!.length !== 0; - pattern.match('acd')!.length !== 0; + pattern.match("abcd")!.length !== 0; + pattern.match("acd")!.length !== 0; } { const pattern = new Pattern(str => { - str === 'foo'; + str === "foo"; return {}; }); - pattern.match('foo').should.eql({}); + pattern.match("foo").should.eql({}); } -let permalink = new Permalink(':year/:month/:day/:title'); +let permalink = new Permalink(":year/:month/:day/:title"); -permalink.rule === ':year/:month/:day/:title'; +permalink.rule === ":year/:month/:day/:title"; permalink.regex; // $ExpectType RegExp -permalink.params.should.eql(['year', 'month', 'day', 'title']); +permalink.params.should.eql(["year", "month", "day", "title"]); -permalink = new Permalink(':year/:month/:day/:title', { +permalink = new Permalink(":year/:month/:day/:title", { segments: { year: /(\d{4})/, month: /(\d{2})/, - day: /(\d{2})/ - } + day: /(\d{2})/, + }, }); -permalink.rule === ':year/:month/:day/:title'; +permalink.rule === ":year/:month/:day/:title"; permalink.regex; // $ExpectType RegExp -permalink.params.should.eql(['year', 'month', 'day', 'title']); -permalink.test('2014/01/31/test'); -!permalink.test('foweirojwoier'); - -expect(permalink.parse('2014/01/31/test')).eql({ - year: '2014', - month: '01', - day: '31', - title: 'test' +permalink.params.should.eql(["year", "month", "day", "title"]); +permalink.test("2014/01/31/test"); +!permalink.test("foweirojwoier"); + +expect(permalink.parse("2014/01/31/test")).eql({ + year: "2014", + month: "01", + day: "31", + title: "test", }); permalink.stringify({ - year: '2014', - month: '01', - day: '31', - title: 'test' -}) === '2014/01/31/test'; - -slugize('Hello World') === 'Hello-World'; -slugize('Hell\u00F2 w\u00F2rld') === 'Hello-world'; -slugize('Hello World') === 'Hello-World'; -slugize('~Hello World~') === 'Hello-World'; -slugize('Hello ~`!@#$%^&*()-_+=[]{}|\\;:"\'<>,.?/World') === 'Hello-World'; -slugize('Hello World', { separator: '_' }) === 'Hello_World'; -slugize('Hello World', { transform: 1 }) === 'hello-world'; -slugize('Hello World', { transform: 2 }) === 'HELLO-WORLD'; -slugize('遊戲') === '遊戲'; - -async () => { - const fixturePath = join(__dirname, 'spawn_test.txt'); - - string = await spawn('cat', [fixturePath]); + year: "2014", + month: "01", + day: "31", + title: "test", +}) === "2014/01/31/test"; + +slugize("Hello World") === "Hello-World"; +slugize("Hell\u00F2 w\u00F2rld") === "Hello-world"; +slugize("Hello World") === "Hello-World"; +slugize("~Hello World~") === "Hello-World"; +slugize("Hello ~`!@#$%^&*()-_+=[]{}|\\;:\"'<>,.?/World") === "Hello-World"; +slugize("Hello World", { separator: "_" }) === "Hello_World"; +slugize("Hello World", { transform: 1 }) === "hello-world"; +slugize("Hello World", { transform: 2 }) === "HELLO-WORLD"; +slugize("遊戲") === "遊戲"; + +(async () => { + const fixturePath = join(__dirname, "spawn_test.txt"); + + string = await spawn("cat", [fixturePath]); try { - await spawn('cat', ['nothing']); + await spawn("cat", ["nothing"]); } catch (err) { - err.message.trim() === 'cat: nothing: No such file or directory'; + err.message.trim() === "cat: nothing: No such file or directory"; err.code === 1; } - string = await spawn('cat', [fixturePath], { encoding: 'hex' }); - buffer = await spawn('cat', [fixturePath], { encoding: null }); + string = await spawn("cat", [fixturePath], { encoding: "hex" }); + buffer = await spawn("cat", [fixturePath], { encoding: null }); - await spawn('echo', ['something'], { stdio: 'inherit' }); -}; - -string = truncate('Once upon a time in a world far far away'); -string = truncate('Once upon'); -string = truncate('Once upon a time in a world far far away', { length: 17 }); -string = truncate('Once upon a time in a world far far away', { length: 17, separator: ' ' }); -string = truncate('And they found that many people were sleeping better.', { length: 25, omission: '... (continued)' }); + await spawn("echo", ["something"], { stdio: "inherit" }); +}); -string = wordWrap('Once upon a time'); -string = wordWrap('Once upon a time, in a kingdom called Far Far Away, a king fell ill, and finding a successor to the throne turned out to be more trouble than anyone could have imagined...'); -string = wordWrap('Once upon a time', { width: 8 }); -string = wordWrap('Once upon a time', { width: 1 }); +string = truncate("Once upon a time in a world far far away"); +string = truncate("Once upon"); +string = truncate("Once upon a time in a world far far away", { length: 17 }); +string = truncate("Once upon a time in a world far far away", { length: 17, separator: " " }); +string = truncate("And they found that many people were sleeping better.", { length: 25, omission: "... (continued)" }); + +string = wordWrap("Once upon a time"); +string = wordWrap( + "Once upon a time, in a kingdom called Far Far Away, a king fell ill, and finding a successor to the throne turned out to be more trouble than anyone could have imagined...", +); +string = wordWrap("Once upon a time", { width: 8 }); +string = wordWrap("Once upon a time", { width: 1 }); diff --git a/types/hexo-util/index.d.ts b/types/hexo-util/index.d.ts index 23a6a13b64f546..f91b9d3c5e0233 100644 --- a/types/hexo-util/index.d.ts +++ b/types/hexo-util/index.d.ts @@ -7,15 +7,15 @@ /// +import { SpawnOptions, StdioOptions } from "child_process"; import { Transform } from "stream"; -import { SpawnOptions, StdioOptions } from 'child_process'; export class CacheStream extends Transform { destroy(): this; getCache(): Buffer; } -export function camelCaseKeys(obj: { [x: string]: any; }): { [x: string]: any; }; +export function camelCaseKeys(obj: { [x: string]: any }): { [x: string]: any }; export function escapeRegExp(str: string): string; @@ -39,7 +39,12 @@ export function highlight(str: string, options?: { autoDetect?: boolean | undefined; }): string; -export function htmlTag(tag: string, attrs?: string[] | ArrayLike | { [x: string]: any }, text?: string | null, escape?: boolean): string; +export function htmlTag( + tag: string, + attrs?: string[] | ArrayLike | { [x: string]: any }, + text?: string | null, + escape?: boolean, +): string; export interface Pattern { test(str: string): boolean; @@ -49,19 +54,19 @@ export interface Pattern { export const Pattern: { new(rule: Pattern | ((str: string) => T)): Pattern; new(rule: RegExp): Pattern; - new(rule: string): Pattern<{ 0: string; [index: number]: any; } & { [name: string]: any; } | undefined>; + new(rule: string): Pattern<{ 0: string; [index: number]: any } & { [name: string]: any } | undefined>; }; export class Permalink { constructor(rule: string, options?: { - segments?: { [name: string]: string | RegExp; } | undefined; + segments?: { [name: string]: string | RegExp } | undefined; }); rule: string; regex: RegExp; params: string[]; test(str: string): boolean; - parse(str: string): { [param: string]: any; } | undefined; - stringify(data: { [name: string]: string; }): string; + parse(str: string): { [param: string]: any } | undefined; + stringify(data: { [name: string]: string }): string; } export function slugize(str: string, options?: { @@ -76,7 +81,7 @@ export interface hexoSpawnOptions extends SpawnOptions { export interface hexoSpawnDisableEncodingOptions extends SpawnOptions { verbose?: boolean | undefined; - encoding: '' | false | null; + encoding: "" | false | null; } export interface hexoSpawnOverrideStdioOptions extends hexoSpawnOptions { @@ -87,12 +92,23 @@ export interface hexoSpawnDisableEncodingAndOverrideStdioOptions extends hexoSpa stdio: StdioOptions; } -export function spawn(command: string, args: string[], options: hexoSpawnDisableEncodingAndOverrideStdioOptions): Promise; -export function spawn(command: string, args: string[], options: hexoSpawnOverrideStdioOptions): Promise; +export function spawn( + command: string, + args: string[], + options: hexoSpawnDisableEncodingAndOverrideStdioOptions, +): Promise; +export function spawn( + command: string, + args: string[], + options: hexoSpawnOverrideStdioOptions, +): Promise; export function spawn(command: string, args: string[], options: hexoSpawnDisableEncodingOptions): Promise; export function spawn(command: string, args: string[], options?: hexoSpawnOptions): Promise; -export function spawn(command: string, options: hexoSpawnDisableEncodingAndOverrideStdioOptions): Promise; +export function spawn( + command: string, + options: hexoSpawnDisableEncodingAndOverrideStdioOptions, +): Promise; export function spawn(command: string, options: hexoSpawnOverrideStdioOptions): Promise; export function spawn(command: string, options: hexoSpawnDisableEncodingOptions): Promise; export function spawn(command: string, options?: hexoSpawnOptions): Promise; diff --git a/types/hexo/hexo-tests.ts b/types/hexo/hexo-tests.ts index 0c4bfa1afcd355..6e1cc5a33a0de8 100644 --- a/types/hexo/hexo-tests.ts +++ b/types/hexo/hexo-tests.ts @@ -1,24 +1,24 @@ -import Hexo = require('hexo'); -import fs = require('fs'); -import Bunyan = require('bunyan'); -import { ParsedArgs } from 'minimist'; -import util = require('hexo-util'); -import http = require('http'); -import Bluebird = require('bluebird'); +import Hexo = require("hexo"); +import fs = require("fs"); +import Bunyan = require("bunyan"); +import { ParsedArgs } from "minimist"; +import util = require("hexo-util"); +import http = require("http"); +import Bluebird = require("bluebird"); const config: Hexo.InstanceOptions = {}; config.debug = false; config.safe = false; config.silent = false; -config.config = '_config.yml'; +config.config = "_config.yml"; config.draft = false; config.drafts = false; let h: Hexo; h = hexo; h = new Hexo(); -h = new Hexo('./'); -h = new Hexo('./', config); +h = new Hexo("./"); +h = new Hexo("./", config); const logger: Bunyan = h.log; console.log(h.base_dir); @@ -92,36 +92,36 @@ h.init().then(async () => { h.source.unwatch(); await h.load(); - h.call('config', { _: ['arg1'] }, (err, value) => {}); + h.call("config", { _: ["arg1"] }, (err, value) => {}); await h.exit(); }); -h.on('ready', () => { - h.on('deployBefore', () => {}); - h.on('deployAfter', () => {}); - h.on('exit', err => { +h.on("ready", () => { + h.on("deployBefore", () => {}); + h.on("deployAfter", () => {}); + h.on("exit", err => { console.log(err); }); - h.on('generateBefore', () => {}); - h.on('generateAfter', () => {}); - h.on('new', param => { + h.on("generateBefore", () => {}); + h.on("generateAfter", () => {}); + h.on("new", param => { const path: string = param.path; const content: string = param.content; }); - h.on('processBefore', (type, path) => { - const t: Hexo.Box.File['type'] = type; + h.on("processBefore", (type, path) => { + const t: Hexo.Box.File["type"] = type; const p: string = path; }); - h.on('processAfter', (type, path) => { - const t: Hexo.Box.File['type'] = type; + h.on("processAfter", (type, path) => { + const t: Hexo.Box.File["type"] = type; const p: string = path; }); - h.on('ready', () => {}); + h.on("ready", () => {}); { let local: Hexo.Locals.Post[] = []; - const model = hexo.locals.get('posts'); + const model = hexo.locals.get("posts"); local = model.toArray(); const count: number = model.count(); @@ -132,7 +132,7 @@ h.on('ready', () => { { let local: Hexo.Locals.Page[] = []; - const model = hexo.locals.get('pages'); + const model = hexo.locals.get("pages"); local = model.toArray(); const count: number = model.count(); @@ -143,7 +143,7 @@ h.on('ready', () => { { let local: Hexo.Locals.Category[] = []; - const model = hexo.locals.get('categories'); + const model = hexo.locals.get("categories"); local = model.toArray(); const count: number = model.count(); @@ -154,7 +154,7 @@ h.on('ready', () => { { let local: Hexo.Locals.Tag[] = []; - const model = hexo.locals.get('tags'); + const model = hexo.locals.get("tags"); local = model.toArray(); const count: number = model.count(); @@ -164,42 +164,42 @@ h.on('ready', () => { } { - h.locals.set('some-data', () => 'some vlue'); - h.locals.remove('some-data'); + h.locals.set("some-data", () => "some vlue"); + h.locals.remove("some-data"); h.locals.toObject(); h.locals.invalidate(); } { - const route = h.route.get('index.html'); + const route = h.route.get("index.html"); if (route) { console.log(route.modified); console.log(route.read()); } const data: Hexo.Router.Data = { - data: 'some data', + data: "some data", modified: true, }; data.data = new Buffer([]); - data.data = () => 'return'; + data.data = () => "return"; let router: Hexo.Router; router = h.route; - router = h.route.set('index.html', 'content'); - router = h.route.set('index.html', new Buffer([])); - router = h.route.set('index.html', new util.Pattern(() => false)); - router = h.route.set('index.html', { data: 'index', modified: false }); + router = h.route.set("index.html", "content"); + router = h.route.set("index.html", new Buffer([])); + router = h.route.set("index.html", new util.Pattern(() => false)); + router = h.route.set("index.html", { data: "index", modified: false }); - router = h.route.remove('index.html'); + router = h.route.remove("index.html"); const list: string[] = h.route.list(); - const format: string = h.route.format('/'); + const format: string = h.route.format("/"); } { h.source.process(() => {}); - h.source.addProcessor('path', file => { + h.source.addProcessor("path", file => { console.log(file.source); console.log(file.path); console.log(file.type); @@ -210,12 +210,12 @@ h.on('ready', () => { console.log(content); }); - file.read({ encoding: 'utf8', flag: 'r' }, (err, content) => { + file.read({ encoding: "utf8", flag: "r" }, (err, content) => { console.log(err, content.toString()); console.log(content); }); - file.readSync({ encoding: 'utf8', flag: 'r' }); + file.readSync({ encoding: "utf8", flag: "r" }); file.stat((err, stat) => { console.log(err); @@ -232,7 +232,7 @@ h.on('ready', () => { const stat: fs.Stats = file.statSync(); - let render = ''; + let render = ""; file.render({}, (err, result) => { render = result; }); @@ -248,36 +248,36 @@ h.on('ready', () => { { let _bool = true; - _bool = h.render.isRenderable('path'); - _bool = h.render.isRenderableSync('path'); + _bool = h.render.isRenderable("path"); + _bool = h.render.isRenderableSync("path"); const option: Hexo.Render.Data = { - engine: 'ejs', - text: 'test', + engine: "ejs", + text: "test", path: __filename, }; - let _string = ''; - h.render.render({ text: 'example', engine: 'swig' }).then(result => { + let _string = ""; + h.render.render({ text: "example", engine: "swig" }).then(result => { _string = result; }); h.render.render({ path: __filename }).then(result => { _string = result; }); - h.render.render({ text: '' }, { foo: 'foo' }).then(result => { + h.render.render({ text: "" }, { foo: "foo" }).then(result => { _string = result; }); - _string = h.render.renderSync({ text: 'example' }); + _string = h.render.renderSync({ text: "example" }); - _string = h.render.getOutput('ejs'); + _string = h.render.getOutput("ejs"); } { const data: Hexo.Post.Data = {}; - data.title = 'Title'; - data.slug = 'URL'; - data.layout = 'layout_name'; - data.path = 'path'; + data.title = "Title"; + data.slug = "URL"; + data.layout = "layout_name"; + data.path = "path"; data.date = new Date(); h.post.create(data, false, () => {}); @@ -287,22 +287,22 @@ h.on('ready', () => { h.post.publish(data, () => {}); const renderData: Hexo.Post.RenderData = {}; - renderData.content = 'content'; - renderData.engine = 'ejs'; + renderData.content = "content"; + renderData.engine = "ejs"; h.post.render(null, renderData, () => {}); } { - h.scaffold.get('post').then(result => ''); - h.scaffold.set('post', '').then(() => {}); - h.scaffold.remove('post').then(() => {}); + h.scaffold.get("post").then(result => ""); + h.scaffold.set("post", "").then(() => {}); + h.scaffold.remove("post").then(() => {}); } { - const themeConfig: Hexo['config'] = h.theme.config; + const themeConfig: Hexo["config"] = h.theme.config; let v: Hexo.View | undefined; - h.theme.setView('path-name', {}); - v = h.theme.getView('post'); + h.theme.setView("path-name", {}); + v = h.theme.getView("post"); if (v) { console.log(v.path); console.log(v.source); @@ -311,103 +311,103 @@ h.on('ready', () => { v.renderSync(); } - h.theme.removeView('path-name'); + h.theme.removeView("path-name"); h.theme.process(() => {}); } { const options: Hexo.extend.Console.Options = {}; - options.usage = '[layout] '; + options.usage = "[layout] <title>"; options.arguments = [ - { name: 'layout', desc: 'Post layout' }, - { name: 'title', desc: 'Post title' }, + { name: "layout", desc: "Post layout" }, + { name: "title", desc: "Post title" }, ]; - options.options = [{ name: '-r, --replace', desc: 'Replace existing files' }]; - options.desc = 'desc'; + options.options = [{ name: "-r, --replace", desc: "Replace existing files" }]; + options.desc = "desc"; - h.extend.console.register('name', 'description', options, args => { + h.extend.console.register("name", "description", options, args => { const a: ParsedArgs = args; }); - h.extend.console.register('name', options, args => {}); - h.extend.console.register('name', 'description', args => {}); - h.extend.console.register('name', args => {}); + h.extend.console.register("name", options, args => {}); + h.extend.console.register("name", "description", args => {}); + h.extend.console.register("name", args => {}); } { - h.extend.deployer.register('name', args => { + h.extend.deployer.register("name", args => { console.log(args.type); console.log(args.someExtraArg); }); } { - h.extend.filter.register('before_post_render', data => data); - h.extend.filter.register('before_post_render', data => undefined); - h.extend.filter.register('before_post_render', data => undefined, 1); + h.extend.filter.register("before_post_render", data => data); + h.extend.filter.register("before_post_render", data => undefined); + h.extend.filter.register("before_post_render", data => undefined, 1); - h.extend.filter.register('after_post_render', data => data); - h.extend.filter.register('after_post_render', data => undefined); - h.extend.filter.register('after_post_render', data => undefined, 1); + h.extend.filter.register("after_post_render", data => data); + h.extend.filter.register("after_post_render", data => undefined); + h.extend.filter.register("after_post_render", data => undefined, 1); - h.extend.filter.register('before_exit', () => {}); - h.extend.filter.register('before_exit', () => {}, 1); + h.extend.filter.register("before_exit", () => {}); + h.extend.filter.register("before_exit", () => {}, 1); - h.extend.filter.register('before_generate', data => data); - h.extend.filter.register('before_generate', data => undefined); - h.extend.filter.register('before_generate', data => undefined, 1); + h.extend.filter.register("before_generate", data => data); + h.extend.filter.register("before_generate", data => undefined); + h.extend.filter.register("before_generate", data => undefined, 1); - h.extend.filter.register('after_generate', () => {}); - h.extend.filter.register('after_generate', () => {}, 1); + h.extend.filter.register("after_generate", () => {}); + h.extend.filter.register("after_generate", () => {}, 1); - h.extend.filter.register('template_locals', locals => locals); - h.extend.filter.register('template_locals', locals => undefined); - h.extend.filter.register('template_locals', locals => undefined, 1); + h.extend.filter.register("template_locals", locals => locals); + h.extend.filter.register("template_locals", locals => undefined); + h.extend.filter.register("template_locals", locals => undefined, 1); - h.extend.filter.register('after_init', () => {}); - h.extend.filter.register('after_init', () => {}, 1); + h.extend.filter.register("after_init", () => {}); + h.extend.filter.register("after_init", () => {}, 1); - h.extend.filter.register('new_post_path', (data, replace) => undefined); - h.extend.filter.register('new_post_path', (data, replace) => undefined, 1); + h.extend.filter.register("new_post_path", (data, replace) => undefined); + h.extend.filter.register("new_post_path", (data, replace) => undefined, 1); - h.extend.filter.register('post_permalink', permalink => permalink); - h.extend.filter.register('post_permalink', permalink => permalink, 1); + h.extend.filter.register("post_permalink", permalink => permalink); + h.extend.filter.register("post_permalink", permalink => permalink, 1); - h.extend.filter.register('after_render:html', (result, data) => result); - h.extend.filter.register('after_render:html', (result, data) => result, 1); + h.extend.filter.register("after_render:html", (result, data) => result); + h.extend.filter.register("after_render:html", (result, data) => result, 1); - h.extend.filter.register('after_clean', () => {}); - h.extend.filter.register('after_clean', () => {}, 1); + h.extend.filter.register("after_clean", () => {}); + h.extend.filter.register("after_clean", () => {}, 1); - h.extend.filter.register('server_middleware', app => { + h.extend.filter.register("server_middleware", app => { app.use((req: http.IncomingMessage, res: http.ServerResponse) => { - res.setHeader('X-Powered-By', 'Hexo'); + res.setHeader("X-Powered-By", "Hexo"); }); }); const filter = (data: any) => data; - h.extend.filter.register('custom_filter', filter); - h.extend.filter.unregister('custom_filter', filter); + h.extend.filter.register("custom_filter", filter); + h.extend.filter.unregister("custom_filter", filter); const options: Hexo.extend.Filter.Options = {}; - options.args = ['foo', 'bar']; + options.args = ["foo", "bar"]; options.context = h; - h.extend.filter.exec('custom_filter', options); - h.extend.filter.exec('custom_filter'); - h.extend.filter.execSync('custom_filter', options); - h.extend.filter.execSync('custom_filter'); + h.extend.filter.exec("custom_filter", options); + h.extend.filter.exec("custom_filter"); + h.extend.filter.execSync("custom_filter", options); + h.extend.filter.execSync("custom_filter"); } { const ret: Hexo.extend.Generator.Return = { data: {}, - layout: 'layout-name', - path: '/', + layout: "layout-name", + path: "/", }; - h.extend.generator.register('name', local => ret); - h.extend.generator.register('name', local => [ret]); - h.extend.generator.register('name', local => Bluebird.resolve(ret)); - h.extend.generator.register('name', local => Bluebird.resolve([ret])); - h.extend.generator.register('name', local => { + h.extend.generator.register("name", local => ret); + h.extend.generator.register("name", local => [ret]); + h.extend.generator.register("name", local => Bluebird.resolve(ret)); + h.extend.generator.register("name", local => Bluebird.resolve([ret])); + h.extend.generator.register("name", local => { console.log(local.data); const categories: Hexo.Locals.Category[] = local.categories.toArray(); const pages: Hexo.Locals.Page[] = local.pages.toArray(); @@ -416,16 +416,16 @@ h.on('ready', () => { return ret; }); - h.extend.generator.register('name', local => { - return { path: '/', data: '' }; + h.extend.generator.register("name", local => { + return { path: "/", data: "" }; }); } { - h.extend.helper.register('name', (...args) => { - return 'ret'; + h.extend.helper.register("name", (...args) => { + return "ret"; }); - const helper = h.extend.helper.get('name'); + const helper = h.extend.helper.get("name"); helper && helper(); const helpers = h.extend.helper.list(); for (const name in helpers) { @@ -435,14 +435,14 @@ h.on('ready', () => { } { - h.extend.migrator.register('name', args => { + h.extend.migrator.register("name", args => { const a: ParsedArgs = args; }); } { let f: Hexo.Box.File; - h.extend.processor.register('pattern', file => (f = file)); + h.extend.processor.register("pattern", file => (f = file)); h.extend.processor.register(/pattern/, file => (f = file)); h.extend.processor.register( str => true, @@ -453,29 +453,29 @@ h.on('ready', () => { { h.extend.renderer.register( - 'ts', - 'js', + "ts", + "js", function(data: Hexo.extend.RendererData, options) { console.log(this); console.log(data.path); console.log(data.text); - return 'result'; + return "result"; }, true, ); h.extend.renderer.register( - 'ts', - 'js', + "ts", + "js", function(data, options) { console.log(this); - return Promise.resolve('result'); + return Promise.resolve("result"); }, false, ); - h.extend.renderer.register('ts', 'js', function(data, options) { + h.extend.renderer.register("ts", "js", function(data, options) { console.log(this); - return Bluebird.resolve('result'); + return Bluebird.resolve("result"); }); } @@ -484,12 +484,12 @@ h.on('ready', () => { option.async = true; option.ends = true; - h.extend.tag.register('name', (args, content) => { + h.extend.tag.register("name", (args, content) => { if (content) { const c: string = content; } const a: string[] = args; - return 'content'; + return "content"; }); } }); diff --git a/types/hexo/index.d.ts b/types/hexo/index.d.ts index 2ad25b8ebd4a57..edcdd119cf4045 100644 --- a/types/hexo/index.d.ts +++ b/types/hexo/index.d.ts @@ -4,16 +4,16 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.0 -import { EventEmitter } from 'events'; -import moment = require('moment'); -import { ParsedArgs } from 'minimist'; -import Logger = require('bunyan'); -import underscore = require('underscore'); -import connect = require('connect'); -import Stream = require('stream'); -import util = require('hexo-util'); -import fs = require('fs'); -import Bluebird = require('bluebird'); +import { EventEmitter } from "events"; +import moment = require("moment"); +import { ParsedArgs } from "minimist"; +import Logger = require("bunyan"); +import underscore = require("underscore"); +import connect = require("connect"); +import Stream = require("stream"); +import util = require("hexo-util"); +import fs = require("fs"); +import Bluebird = require("bluebird"); declare global { const hexo: Hexo; @@ -400,47 +400,47 @@ declare class Hexo extends EventEmitter { /** * Emitted before deployment begins. */ - on(ev: 'deployBefore', fn: () => void): this; + on(ev: "deployBefore", fn: () => void): this; /** * Emitted after deployment finishes. */ - on(ev: 'deployAfter', fn: () => void): this; + on(ev: "deployAfter", fn: () => void): this; /** * Emitted before Hexo exits. */ - on(ev: 'exit', fn: (err: any) => void): this; + on(ev: "exit", fn: (err: any) => void): this; /** * Emitted before generation begins. */ - on(ev: 'generateBefore', fn: () => void): this; + on(ev: "generateBefore", fn: () => void): this; /** * Emitted after generation finishes. */ - on(ev: 'generateAfter', fn: () => void): this; + on(ev: "generateAfter", fn: () => void): this; /** * Emitted after a new post has been created. This event returns the post data: */ - on(ev: 'new', fn: (post: { path: string; content: string }) => void): this; + on(ev: "new", fn: (post: { path: string; content: string }) => void): this; /** * Emitted before processing begins. This event returns a path representing the root directory of the box. */ - on(ev: 'processBefore', fn: (type: Hexo.Box.File['type'], path: string) => void): this; + on(ev: "processBefore", fn: (type: Hexo.Box.File["type"], path: string) => void): this; /** * Emitted after processing finishes. This event returns a path representing the root directory of the box. */ - on(ev: 'processAfter', fn: (type: Hexo.Box.File['type'], path: string) => void): this; + on(ev: "processAfter", fn: (type: Hexo.Box.File["type"], path: string) => void): this; /** * Emitted after initialization finishes. */ - on(ev: 'ready', fn: () => void): this; + on(ev: "ready", fn: () => void): this; } declare namespace Hexo { @@ -454,10 +454,10 @@ declare namespace Hexo { } interface Locals { - get(type: 'posts'): Model<Locals.Post>; - get(type: 'pages'): Model<Locals.Page>; - get(type: 'categories'): Model<Locals.Category>; - get(type: 'tags'): Model<Locals.Tag>; + get(type: "posts"): Model<Locals.Post>; + get(type: "pages"): Model<Locals.Page>; + get(type: "categories"): Model<Locals.Category>; + get(type: "tags"): Model<Locals.Tag>; /** * Get a Variable */ @@ -572,7 +572,7 @@ declare namespace Hexo { * Executed before a post is rendered. Refer to post rendering to learn the execution steps. */ register( - type: 'before_post_render', + type: "before_post_render", fn: (data: { content: string; [key: string]: any }) => { content: string; [key: string]: any } | void, priority?: number, ): void; @@ -581,7 +581,7 @@ declare namespace Hexo { * Executed after a post is rendered. Refer to post rendering to learn the execution steps. */ register( - type: 'after_post_render', + type: "after_post_render", fn: (data: { content: string; [key: string]: any }) => { content: string; [key: string]: any } | void, priority?: number, ): void; @@ -589,23 +589,23 @@ declare namespace Hexo { /** * Executed before Hexo is about to exit – this will run right after `hexo.exit` is called. */ - register(type: 'before_exit', fn: () => void, priority?: number): void; + register(type: "before_exit", fn: () => void, priority?: number): void; /** * Executed before generation begins. */ - register(type: 'before_generate', fn: (data: any) => any, priority?: number): void; + register(type: "before_generate", fn: (data: any) => any, priority?: number): void; /** * Executed after generation finishes. */ - register(type: 'after_generate', fn: () => void, priority?: number): void; + register(type: "after_generate", fn: () => void, priority?: number): void; /** * Modify [local variables](https://hexo.io/docs/variables) in templates. */ register( - type: 'template_locals', + type: "template_locals", fn: (locals: TemplateLocals) => TemplateLocals | void, priority?: number, ): void; @@ -613,13 +613,13 @@ declare namespace Hexo { /** * Executed after Hexo is initialized – this will run right after `hexo.init` completes. */ - register(type: 'after_init', fn: () => void, priority?: number): void; + register(type: "after_init", fn: () => void, priority?: number): void; /** * Executed when creating a post to determine the path of new posts. */ register( - type: 'new_post_path', + type: "new_post_path", fn: (data: Post.Data, replace: boolean | undefined) => void, priority?: number, ): void; @@ -627,13 +627,13 @@ declare namespace Hexo { /** * Used to determine the permalink of posts. */ - register(type: 'post_permalink', fn: (permalink: string) => string, priority?: number): void; + register(type: "post_permalink", fn: (permalink: string) => string, priority?: number): void; /** * Executed after rendering finishes. You can see rendering for more info. */ register( - type: 'after_render:html', + type: "after_render:html", fn: (result: string, data: { path: string; text: string; [key: string]: any }) => string | void, priority?: number, ): void; @@ -641,13 +641,13 @@ declare namespace Hexo { /** * Executed after generated files and cache are removed with hexo clean command. */ - register(type: 'after_clean', fn: () => void, priority?: number): void; + register(type: "after_clean", fn: () => void, priority?: number): void; /** * Add middleware to the server. app is a Connect instance. */ register( - type: 'server_middleware', + type: "server_middleware", fn: (app: connect.Server) => connect.Server | void, priority?: number, ): void; @@ -844,7 +844,7 @@ declare namespace Hexo { /** * File type. The value can be `create` , `update` , `skip`, `delete` . */ - readonly type: 'create' | 'update' | 'skip' | 'delete'; + readonly type: "create" | "update" | "skip" | "delete"; /** * The information from path matching. @@ -1003,7 +1003,7 @@ interface TemplateLocals { */ config: HexoConfig; theme: HexoConfig; - env: Hexo['env']; + env: Hexo["env"]; layout: string; view_dir: string; site: any; diff --git a/types/hh-mm-ss/hh-mm-ss-tests.ts b/types/hh-mm-ss/hh-mm-ss-tests.ts index 1beb59b7eeed37..6c30c457843f82 100644 --- a/types/hh-mm-ss/hh-mm-ss-tests.ts +++ b/types/hh-mm-ss/hh-mm-ss-tests.ts @@ -1,21 +1,21 @@ -import { fromMs, fromS, toMs, toS } from 'hh-mm-ss'; +import { fromMs, fromS, toMs, toS } from "hh-mm-ss"; // $ExpectType string const ms = fromMs(60000); // $ExpectType string -const msWithFormat = fromMs(60000, 'mm:ss'); +const msWithFormat = fromMs(60000, "mm:ss"); // $ExpectType string const s = fromS(3000); // $ExpectType string -const sWithFormat = fromS(3000, 'hh:mm:ss'); +const sWithFormat = fromS(3000, "hh:mm:ss"); // $ExpectType number -const ms2 = toMs('12:23:34'); +const ms2 = toMs("12:23:34"); // $ExpectType number -const msWithFormat2 = toMs('12:23:34', 'mm:ss'); +const msWithFormat2 = toMs("12:23:34", "mm:ss"); // $ExpectType number -const s2 = toS('12:23:34'); +const s2 = toS("12:23:34"); // $ExpectType number -const sWithFormat2 = toS('12:23:34', 'mm:ss'); +const sWithFormat2 = toS("12:23:34", "mm:ss"); diff --git a/types/hid/hid-tests.ts b/types/hid/hid-tests.ts index 3230595b98ac54..bb3152ef0cec43 100644 --- a/types/hid/hid-tests.ts +++ b/types/hid/hid-tests.ts @@ -11,7 +11,7 @@ import { send_feature_report, set_nonblocking, write, -} from 'hid'; +} from "hid"; enumerate(); // $ExpectType DeviceDescriptor[] @@ -21,7 +21,7 @@ get_feature_report(device, Buffer.from([])); // $ExpectType number get_feature_report_async(device, Buffer.from([]), () => {}); // $ExpectType void -open_path('foo'); // $ExpectType OpaqueDevice +open_path("foo"); // $ExpectType OpaqueDevice read(device, Buffer.from([])); // $ExpectType number diff --git a/types/hidefile/index.d.ts b/types/hidefile/index.d.ts index 2eba5689d1d1cb..e153abe68c84f5 100644 --- a/types/hidefile/index.d.ts +++ b/types/hidefile/index.d.ts @@ -5,44 +5,44 @@ /// <reference types="node" /> -import { URL } from 'url'; +import { URL } from "url"; export function hide( path: string | Buffer | URL, - callback: (error: Error | null, newpath?: string | Buffer | URL) => unknown + callback: (error: Error | null, newpath?: string | Buffer | URL) => unknown, ): void; export function hideSync( - path: string | Buffer | URL + path: string | Buffer | URL, ): string | Buffer | URL; export function isDotPrefixed( - path: string | Buffer | URL + path: string | Buffer | URL, ): boolean; export function isHidden( path: string | Buffer | URL, - callback: (error: Error | null, result: boolean) => unknown + callback: (error: Error | null, result: boolean) => unknown, ): void; export function isHiddenSync( - path: string | Buffer | URL + path: string | Buffer | URL, ): boolean; export function reveal( path: string | Buffer | URL, - callback: (error: Error | null, newpath?: string | Buffer | URL) => unknown + callback: (error: Error | null, newpath?: string | Buffer | URL) => unknown, ): void; export function revealSync( - path: string | Buffer | URL + path: string | Buffer | URL, ): string | Buffer | URL; export function shouldBeHidden( path: string | Buffer | URL, - callback: (error: Error | null, result: boolean) => unknown + callback: (error: Error | null, result: boolean) => unknown, ): void; export function shouldBeHiddenSync( - path: string | Buffer | URL + path: string | Buffer | URL, ): boolean; diff --git a/types/hidefile/test/hidefile-tests.cjs.ts b/types/hidefile/test/hidefile-tests.cjs.ts index 374f896be4423e..a7cd79361d3682 100644 --- a/types/hidefile/test/hidefile-tests.cjs.ts +++ b/types/hidefile/test/hidefile-tests.cjs.ts @@ -1,4 +1,4 @@ -import hidefile = require('hidefile'); +import hidefile = require("hidefile"); hidefile.hide("./", () => {}); // $ExpectType void hidefile.hideSync("./"); // $ExpectType string | Buffer | URL diff --git a/types/hifo/hifo-tests.ts b/types/hifo/hifo-tests.ts index 7f96534126b6dc..b80f17bf21d53a 100644 --- a/types/hifo/hifo-tests.ts +++ b/types/hifo/hifo-tests.ts @@ -1,10 +1,10 @@ -import hifo = require('hifo'); +import hifo = require("hifo"); // test type exports type Hif = hifo.Hifo<unknown>; type CompFn = hifo.CompareFn<unknown>; type ObjKey = hifo.ObjectKey; -type ObjWithNumericValue = hifo.ObjectWithNumericValue<'foo'>; +type ObjWithNumericValue = hifo.ObjectWithNumericValue<"foo">; interface Person { name: string; @@ -12,20 +12,20 @@ interface Person { id: number; } const people = [ - { name: 'Alice', age: 23, id: 1 }, - { name: 'Eve', age: 45, id: 2 }, - { name: 'Jane', age: 19, id: 3 }, - { name: 'Bob', age: 30, id: 4 }, - { name: 'John', age: 60, id: 5 }, + { name: "Alice", age: 23, id: 1 }, + { name: "Eve", age: 45, id: 2 }, + { name: "Jane", age: 19, id: 3 }, + { name: "Bob", age: 30, id: 4 }, + { name: "John", age: 60, id: 5 }, ]; hifo.lowest(); // $ExpectType CompareFn<number> -hifo.lowest('age'); // $ExpectType CompareFn<ObjectWithNumericValue<"age">> -hifo.lowest('age', 'id'); // $ExpectType CompareFn<ObjectWithNumericValue<"age" | "id">> +hifo.lowest("age"); // $ExpectType CompareFn<ObjectWithNumericValue<"age">> +hifo.lowest("age", "id"); // $ExpectType CompareFn<ObjectWithNumericValue<"age" | "id">> hifo.highest(); // $ExpectType CompareFn<number> -const highestByAge = hifo.highest('age'); // $ExpectType CompareFn<ObjectWithNumericValue<"age">> -const highestByAgeAndId = hifo.highest('age', 'id'); // $ExpectType CompareFn<ObjectWithNumericValue<"age" | "id">> +const highestByAge = hifo.highest("age"); // $ExpectType CompareFn<ObjectWithNumericValue<"age">> +const highestByAgeAndId = hifo.highest("age", "id"); // $ExpectType CompareFn<ObjectWithNumericValue<"age" | "id">> const highestNum = hifo(hifo.highest()); // $ExpectType Hifo<number> hifo(hifo.highest(), 3); // $ExpectType Hifo<number> @@ -37,18 +37,18 @@ oldestObjAge.add(people[0]); hifo<Person>(highestByAgeAndId, 3); // $ExpectType Hifo<Person> const oldestObjAgeId = hifo(highestByAgeAndId, 3); // $ExpectType Hifo<ObjectWithNumericValue<"age" | "id">> oldestObjAgeId.add(people[0]); -hifo<Person>(hifo.highest('age', 'id'), 3); // $ExpectType Hifo<Person> -hifo(hifo.highest('age', 'id'), 3); // $ExpectType Hifo<ObjectWithNumericValue<"age" | "id">> +hifo<Person>(hifo.highest("age", "id"), 3); // $ExpectType Hifo<Person> +hifo(hifo.highest("age", "id"), 3); // $ExpectType Hifo<ObjectWithNumericValue<"age" | "id">> hifo((left: { foo: string }, right: { foo: string }) => left.foo.length - right.foo.length); // $ExpectType Hifo<{ foo: string; }> // @ts-expect-error -hifo<Person>(hifo.highest('name'), 3); // $ExpectType Hifo<Person> -const oldestName = hifo(hifo.highest('name'), 3); // $ExpectType Hifo<ObjectWithNumericValue<"name">> +hifo<Person>(hifo.highest("name"), 3); // $ExpectType Hifo<Person> +const oldestName = hifo(hifo.highest("name"), 3); // $ExpectType Hifo<ObjectWithNumericValue<"name">> // @ts-expect-error oldestName.add(people[0]); // @ts-expect-error -hifo<Person>(hifo.highest('age', 'name'), 3); // $ExpectType Hifo<Person> -const oldestAgeName = hifo(hifo.highest('age', 'name'), 3); // $ExpectType Hifo<ObjectWithNumericValue<"age" | "name">> +hifo<Person>(hifo.highest("age", "name"), 3); // $ExpectType Hifo<Person> +const oldestAgeName = hifo(hifo.highest("age", "name"), 3); // $ExpectType Hifo<ObjectWithNumericValue<"age" | "name">> // @ts-expect-error oldestAgeName.add(people[0]); @@ -63,8 +63,8 @@ highestNum.reset(); // $ExpectType Hifo<number> oldest.size; // $ExpectType number oldest.data; // $ExpectType readonly Person[] -oldest.init(hifo.lowest('age')); // $ExpectType Hifo<Person> -oldest.init(hifo.lowest('age'), 3); // $ExpectType Hifo<Person> +oldest.init(hifo.lowest("age")); // $ExpectType Hifo<Person> +oldest.init(hifo.lowest("age"), 3); // $ExpectType Hifo<Person> oldest.sort; // $ExpectType CompareFn<Person> oldest.add(people[0]); // $ExpectType Hifo<Person> oldest.insert(people[0]); // $ExpectType number diff --git a/types/hifo/index.d.ts b/types/hifo/index.d.ts index ffe8f9de1ff5dd..fb12b8a9020fc9 100644 --- a/types/hifo/index.d.ts +++ b/types/hifo/index.d.ts @@ -46,15 +46,15 @@ declare namespace hifo { TKeyPrimary extends ObjectKey, TObject extends ObjectWithNumericValue<TKeyPrimary | TKeySecondary>, TKeySecondary extends ObjectKey = never, - // eslint-disable-next-line @definitelytyped/no-unnecessary-generics - >(primary: TKeyPrimary, secondary?: TKeySecondary): CompareFn<TObject>; + > // eslint-disable-next-line @definitelytyped/no-unnecessary-generics + (primary: TKeyPrimary, secondary?: TKeySecondary): CompareFn<TObject>; function lowest(): CompareFn<number>; function highest< TKeyPrimary extends ObjectKey, TObject extends ObjectWithNumericValue<TKeyPrimary | TKeySecondary>, TKeySecondary extends ObjectKey = never, - // eslint-disable-next-line @definitelytyped/no-unnecessary-generics - >(primary: TKeyPrimary, secondary?: TKeySecondary): CompareFn<TObject>; + > // eslint-disable-next-line @definitelytyped/no-unnecessary-generics + (primary: TKeyPrimary, secondary?: TKeySecondary): CompareFn<TObject>; function highest(): CompareFn<number>; const Hifo: Hifo<unknown>; diff --git a/types/hig__button/hig__button-tests.tsx b/types/hig__button/hig__button-tests.tsx index 2b4adb5da0c773..182d7260c4ab37 100644 --- a/types/hig__button/hig__button-tests.tsx +++ b/types/hig__button/hig__button-tests.tsx @@ -1,11 +1,11 @@ -import * as React from 'react'; -import Button, { targets, types, widths, AvailableTargets, AvailableTypes, AvailableWidths } from '@hig/button'; +import Button, { AvailableTargets, AvailableTypes, AvailableWidths, targets, types, widths } from "@hig/button"; +import * as React from "react"; /** Button */ const emptyFunc = () => {}; const disabled = true; const icon = <div />; -const link = ''; +const link = ""; const onClick = emptyFunc; const onBlur = emptyFunc; const onFocus = emptyFunc; @@ -16,7 +16,7 @@ const onMouseLeave = emptyFunc; const onMouseUp = emptyFunc; const stylesheet = emptyFunc; const target = targets.BLANK; -const title = ''; +const title = ""; const type = types.FLAT; const width = widths.GROW; diff --git a/types/hig__button/index.d.ts b/types/hig__button/index.d.ts index 6bbff4e9144636..131e62abaa075d 100644 --- a/types/hig__button/index.d.ts +++ b/types/hig__button/index.d.ts @@ -7,28 +7,28 @@ // Turn off automatic exporting export {}; -import * as React from 'react'; +import * as React from "react"; type Callback = () => void; export interface Targets { - SELF: '_self'; - BLANK: '_blank'; - PARENT: '_parent'; - TOP: '_top'; + SELF: "_self"; + BLANK: "_blank"; + PARENT: "_parent"; + TOP: "_top"; } export interface Types { - FLAT: 'flat'; - OUTLINE: 'outline'; - SOLID: 'solid'; + FLAT: "flat"; + OUTLINE: "outline"; + SOLID: "solid"; /** @deprecated */ - PRIMARY: 'primary'; + PRIMARY: "primary"; /** @deprecated */ - SECONDARY: 'secondary'; + SECONDARY: "secondary"; } export interface Widths { - SHRINK: 'shrink'; - GROW: 'grow'; + SHRINK: "shrink"; + GROW: "grow"; } export type AvailableTargets = Targets[keyof Targets]; export type AvailableTypes = Types[keyof Types]; diff --git a/types/highcharts-ng/highcharts-ng-tests.ts b/types/highcharts-ng/highcharts-ng-tests.ts index 6f79d6e79ac158..ce0f454446b5ea 100644 --- a/types/highcharts-ng/highcharts-ng-tests.ts +++ b/types/highcharts-ng/highcharts-ng-tests.ts @@ -1,45 +1,48 @@ /// <reference types="angular" /> -var app = angular.module('app', ['highcharts-ng']); +var app = angular.module("app", ["highcharts-ng"]); class AppController { chartConfig: HighChartsNGConfig = { options: { chart: { - type: 'bar' + type: "bar", }, tooltip: { style: { padding: 10, - fontWeight: 'bold' - } + fontWeight: "bold", + }, }, credits: { - enabled: false + enabled: false, }, - plotOptions: {} + plotOptions: {}, }, series: [ { - data: [10, 15, 12, 8, 7] + data: [10, 15, 12, 8, 7], }, { - data: [[0, 10], [1, 15], [2, 12], [3, 8], [4, 7]] + data: [[0, 10], [1, 15], [2, 12], [3, 8], [4, 7]], }, { - data: [{ name: "A", y: 10 }, { name: "B", y: 15 }, { name: "C", y: 12 }, { name: "D", y: 8 }, { name: "E", y: 7 }] - } + data: [{ name: "A", y: 10 }, { name: "B", y: 15 }, { name: "C", y: 12 }, { name: "D", y: 8 }, { + name: "E", + y: 7, + }], + }, ], title: { - text: 'My Awesome Chart' + text: "My Awesome Chart", }, loading: true, - noData: 'No data here' + noData: "No data here", }; constructor($timeout: ng.ITimeoutService) { var vm = this; $timeout(function() { - //Some async action + // Some async action vm.chartConfig.loading = false; }); } diff --git a/types/highcharts-ng/index.d.ts b/types/highcharts-ng/index.d.ts index 35abdc1d1506ce..3885a50c12ac58 100644 --- a/types/highcharts-ng/index.d.ts +++ b/types/highcharts-ng/index.d.ts @@ -9,40 +9,40 @@ import { ChartObject, IndividualSeriesOptions, Options } from "highcharts"; declare global { interface HighChartsNGConfig { options: Options; - //The below properties are watched separately for changes. + // The below properties are watched separately for changes. - //Series object (optional) - a list of series using normal highcharts series options. + // Series object (optional) - a list of series using normal highcharts series options. series?: IndividualSeriesOptions[] | undefined; - //Title configuration (optional) + // Title configuration (optional) title?: { text?: string | undefined; } | undefined; - //Boolean to control showng loading status on chart (optional) - //Could be a string if you want to show specific loading text. + // Boolean to control showng loading status on chart (optional) + // Could be a string if you want to show specific loading text. loading?: boolean | string | undefined; - //Configuration for the xAxis (optional). Currently only one x axis can be dynamically controlled. - //properties currentMin and currentMax provied 2-way binding to the chart's maximimum and minimum + // Configuration for the xAxis (optional). Currently only one x axis can be dynamically controlled. + // properties currentMin and currentMax provied 2-way binding to the chart's maximimum and minimum xAxis?: { currentMin?: number | undefined; currentMax?: number | undefined; - title?: { text?: string | undefined } | undefined + title?: { text?: string | undefined } | undefined; } | undefined; - //Whether to use HighStocks instead of HighCharts (optional). Defaults to false. + // Whether to use HighStocks instead of HighCharts (optional). Defaults to false. useHighStocks?: boolean | undefined; - //size (optional) if left out the chart will default to size of the div or something sensible. + // size (optional) if left out the chart will default to size of the div or something sensible. size?: { width?: number | undefined; height?: number | undefined; } | undefined; - //function (optional) - setup some logic for the chart + // function (optional) - setup some logic for the chart func?: ((chart: ChartObject) => void) | undefined; - //no data text (optional) to show if all series are empty + // no data text (optional) to show if all series are empty noData?: string | undefined; } - //Instantiated Chart + // Instantiated Chart interface HighChartsNGChart extends HighChartsNGConfig { - //This is a simple way to access all the Highcharts API that is not currently managed by this directive. + // This is a simple way to access all the Highcharts API that is not currently managed by this directive. getHighcharts(): ChartObject; } } diff --git a/types/highland/highland-tests.ts b/types/highland/highland-tests.ts index 19d1dad819ff32..e1a90143bdd313 100644 --- a/types/highland/highland-tests.ts +++ b/types/highland/highland-tests.ts @@ -68,7 +68,10 @@ interface StrBarArrMap { declare class MyPromise<T> implements PromiseLike<T> { constructor(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (err: any) => void) => void); - then<TResult1 = T, TResult2 = never>(onfulfilled?: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): PromiseLike<TResult1 | TResult2>; + then<TResult1 = T, TResult2 = never>( + onfulfilled?: (value: T) => TResult1 | PromiseLike<TResult1>, + onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>, + ): PromiseLike<TResult1 | TResult2>; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -152,16 +155,22 @@ fooStream = _<Foo>((push, next) => { fooStream = _(fooStream); fooStream = _<Foo>(readable); fooStream = _<Foo>(readable, (r, cb) => { - return; + return; }); fooStream = _<Foo>(readable, (r, cb) => { - return () => { return; } + return () => { + return; + }; }); fooStream = _<Foo>(readable, (r, cb) => { - return { continueOnError: true }; + return { continueOnError: true }; }); fooStream = _<Foo>(readable, (r, cb) => { - return { onDestroy: () => { return; } }; + return { + onDestroy: () => { + return; + }, + }; }); fooStream = _<Foo>(str, emitter); fooStream = _<Foo>(str, emitter, num); @@ -212,12 +221,12 @@ barStream = fooStream.consume( err: Error, x: Foo | Highland.Nil, push: (err: Error, value?: Bar | Highland.Nil) => void, - next: () => void + next: () => void, ) => { push(err); push(null, bar); next(); - } + }, ); barStream = fooStream.consume<Bar>((err, x, push, next) => { @@ -237,7 +246,7 @@ fooStream = fooStream.errors( push(err); push(null, x); push(null, foo); - } + }, ); fooStream = fooStream.errors((err, push) => { @@ -273,7 +282,7 @@ fooStream = fooStream.head(); fooStream = fooStream.intersperse(foo); // $ExpectType Stream<Foo | Bar> -fooStream.intersperse(bar) +fooStream.intersperse(bar); barStream = fooStream.invoke<Bar>(str, anyArr); @@ -286,13 +295,13 @@ barStream = fooStream.map((x: Foo) => { }); // $ExpectType Stream<Pick<Baz, "foo" | "bar">> -bazStream.pick(['foo', 'bar']); +bazStream.pick(["foo", "bar"]); // $ExpectType Stream<Partial<Foo>> -fooStream.pickBy((key, value) => key === 'foo'); +fooStream.pickBy((key, value) => key === "foo"); // $ExpectType Stream<() => string> -fooStream.pluck('foo'); +fooStream.pluck("foo"); barStream = fooStream.pluck<Bar>(str); fooStream = fooStream.ratelimit(3, 1000); @@ -338,16 +347,16 @@ fooStream = fooStream.sortBy((a: Foo, b: Foo) => 1); fooStream.split(); // $ExpectType Stream<string> -_(['']).split(); +_([""]).split(); // @ts-expect-error -fooStream.splitBy(",") +fooStream.splitBy(","); // $ExpectType Stream<string> -_(['']).splitBy(',') +_([""]).splitBy(","); // $ExpectType Stream<string> -_(['']).splitBy(/,/) +_([""]).splitBy(/,/); fooStream = fooStream.stopOnError((e: Error) => {}); @@ -359,7 +368,7 @@ fooStream = fooStream.throttle(num); fooStream = fooStream.where(obj); -bazStream = bazStream.where({baz: true}); +bazStream = bazStream.where({ baz: true }); fooStream = fooStream.uniq(); @@ -473,10 +482,10 @@ fooStream.toCallback((err: Error, x: Foo) => {}); fooStream.toCallback((err: Error) => {}); fooStream.toNodeStream(); -fooStream.toNodeStream({objectMode: false}); -fooStream.toNodeStream({objectMode: true}); +fooStream.toNodeStream({ objectMode: false }); +fooStream.toNodeStream({ objectMode: true }); -fooStream.toPromise(Promise).then((foo: Foo) => {}) +fooStream.toPromise(Promise).then((foo: Foo) => {}); // Type inference for the generic parameter only seems to work with TS 3.5 or above. // Rather than bump the required version, I'm not testing type inference here. @@ -566,4 +575,4 @@ num = _.add(num, num); numCurNum = _.add(num); -//missing not +// missing not diff --git a/types/highland/index.d.ts b/types/highland/index.d.ts index 8ed7f11058616e..83d4b84274711a 100644 --- a/types/highland/index.d.ts +++ b/types/highland/index.d.ts @@ -19,14 +19,14 @@ // Uses trick described in https://github.com/microsoft/TypeScript/pull/33050#issuecomment-552218239 // with string keys to support TS 2.8 type Flattened<R> = { - value: R, - stream: R extends Highland.Stream<infer U> ? Flattened<U> : never, + value: R; + stream: R extends Highland.Stream<infer U> ? Flattened<U> : never; array: R extends Array<infer U> ? Flattened<U> : never; -}[R extends Array<any> ? 'array' : R extends Highland.Stream<any> ? 'stream' : 'value']; +}[R extends Array<any> ? "array" : R extends Highland.Stream<any> ? "stream" : "value"]; // Describes a constructor for a particular promise library interface PConstructor<T, P extends PromiseLike<T>> { - new(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): P + new(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): P; } /** * Highland: the high-level streams library @@ -34,7 +34,6 @@ interface PConstructor<T, P extends PromiseLike<T>> { * Highland may be freely distributed under the Apache 2.0 license. * https://github.com/caolan/highland * Copyright (c) Caolan McMahon - * */ interface HighlandStatic { /** @@ -132,7 +131,9 @@ interface HighlandStatic { */ <R>(): Highland.Stream<R>; <R>(source: R[]): Highland.Stream<R>; - <R>(source: (push: (err: Error | null, x?: R | Highland.Nil) => void, next: () => void) => void): Highland.Stream<R>; + <R>( + source: (push: (err: Error | null, x?: R | Highland.Nil) => void, next: () => void) => void, + ): Highland.Stream<R>; <R>(source: Highland.Stream<R>): Highland.Stream<R>; <R>(source: NodeJS.ReadableStream, onFinished?: Highland.OnFinished): Highland.Stream<R>; @@ -438,7 +439,6 @@ interface HighlandStatic { } declare namespace Highland { - // hacky unique // TODO do we need this? interface Nil { @@ -460,9 +460,9 @@ declare namespace Highland { /** * Used as a Redirect marker when writing to a Stream's incoming buffer */ - // TODO is this public? + // TODO is this public? class StreamRedirect<R> { - constructor(to: Stream<R>) + constructor(to: Stream<R>); to: Stream<R>; } @@ -472,7 +472,6 @@ declare namespace Highland { * Actual Stream constructor wrapped the the main exported function */ interface Stream<R> extends NodeJS.EventEmitter { - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // STREAM OBJECTS // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -628,7 +627,14 @@ declare namespace Highland { * @param {Function} f - the function to handle errors and values * @api public */ - consume<U>(f: (err: Error, x: R | Highland.Nil, push: (err: Error | null, value?: U | Highland.Nil) => void, next: () => void) => void): Stream<U>; + consume<U>( + f: ( + err: Error, + x: R | Highland.Nil, + push: (err: Error | null, value?: U | Highland.Nil) => void, + next: () => void, + ) => void, + ): Stream<U>; /** * Holds off pushing data events downstream until there has been no more @@ -757,8 +763,8 @@ declare namespace Highland { * @api public */ // TODO verify this - group(f: (x: R) => string): Stream<{[prop:string]:R[]}>; - group(prop: string): Stream<{[prop:string]:R[]}>; + group(f: (x: R) => string): Stream<{ [prop: string]: R[] }>; + group(prop: string): Stream<{ [prop: string]: R[] }>; /** * Creates a new Stream with only the first value from the source. @@ -836,7 +842,6 @@ declare namespace Highland { map<U>(f: (x: R) => U): Stream<U>; /** - * * Retrieves copies of all elements in the collection, * with only the whitelisted keys. If one of the whitelisted * keys does not exist, it will be ignored. @@ -849,7 +854,6 @@ declare namespace Highland { */ pick<Prop extends keyof R>(props: Prop[]): Stream<Pick<R, Prop>>; /** - * * Retrieves copies of all the elements in the collection * that satisfy a given predicate. Note: When using ES3, * only enumerable elements are selected. Both enumerable @@ -861,7 +865,7 @@ declare namespace Highland { * @param {Function} f - the predicate function * @api public */ - pickBy<Prop extends keyof R>(f: (key: Prop, value: R[Prop]) => boolean): Stream<Partial<R>> + pickBy<Prop extends keyof R>(f: (key: Prop, value: R[Prop]) => boolean): Stream<Partial<R>>; /** * Retrieves values associated with a given property from all elements in @@ -1285,7 +1289,7 @@ declare namespace Highland { * @param {Number} n - the maximum number of concurrent reads/buffers * @api public */ - parallel<U>(this: Stream<Stream<U>>, n: number): Stream<U> + parallel<U>(this: Stream<Stream<U>>, n: number): Stream<U>; /** * Reads values from a Stream of Streams, emitting them on a Single output @@ -1374,7 +1378,6 @@ declare namespace Highland { through<U>(f: (x: Stream<R>) => U): U; through(thru: NodeJS.ReadWriteStream): Stream<any>; - /** * Takes two Streams and returns a Stream of corresponding pairs. * @@ -1475,7 +1478,7 @@ declare namespace Highland { * @param {Function} f - the iterator function * @api public */ - each(f: (x: R) => void): Pick<Stream<R>, 'done'>; + each(f: (x: R) => void): Pick<Stream<R>, "done">; /** * Pipes a Highland Stream to a [Node Writable @@ -1511,7 +1514,7 @@ declare namespace Highland { * @api public */ pipe<U>(dest: Stream<U>): Stream<U>; - pipe<U extends NodeJS.WritableStream>(dest: U, options?: { end?: boolean | undefined }): U + pipe<U extends NodeJS.WritableStream>(dest: U, options?: { end?: boolean | undefined }): U; /** * Consumes a single item from the Stream. Unlike consume, this function will @@ -1614,7 +1617,7 @@ declare namespace Highland { interface PipeableStream<T, R> extends Stream<R> {} interface PipeOptions { - end: boolean + end: boolean; } type MappingHint = number | string[] | Function; @@ -1626,9 +1629,8 @@ declare namespace Highland { type OnFinished = (r: NodeJS.ReadableStream, cb: (...args: any[]) => void) => void | Function | CleanupObject; } -declare var highland:HighlandStatic; +declare var highland: HighlandStatic; -declare module 'highland' { +declare module "highland" { export = highland; } - diff --git a/types/highlight-words-core/highlight-words-core-tests.ts b/types/highlight-words-core/highlight-words-core-tests.ts index f75e8feda73a25..f36ccf62e0e912 100644 --- a/types/highlight-words-core/highlight-words-core-tests.ts +++ b/types/highlight-words-core/highlight-words-core-tests.ts @@ -1,7 +1,7 @@ -import { findAll } from 'highlight-words-core'; +import { findAll } from "highlight-words-core"; -const textToHighlight = 'This is some text to highlight.'; -const searchWords = ['This', 'i']; +const textToHighlight = "This is some text to highlight."; +const searchWords = ["This", "i"]; findAll({ searchWords, diff --git a/types/highlightjs/highlightjs-tests.ts b/types/highlightjs/highlightjs-tests.ts index 93059c85f835fb..16a1521aa34841 100644 --- a/types/highlightjs/highlightjs-tests.ts +++ b/types/highlightjs/highlightjs-tests.ts @@ -1,4 +1,4 @@ -import hljs = require('highlightjs'); +import hljs = require("highlightjs"); const code = "using System;\npublic class Test\n{\npublic static void Main()\n{\n// your code goes here\n}\n}"; const lang = "cs"; diff --git a/types/highlightjs/index.d.ts b/types/highlightjs/index.d.ts index 65076b7e558bd2..e4678858bb9596 100644 --- a/types/highlightjs/index.d.ts +++ b/types/highlightjs/index.d.ts @@ -6,16 +6,18 @@ declare namespace hljs { // tslint:disable-next-line:no-empty-interface - interface Node { } + interface Node {} export function highlight( name: string, value: string, ignore_illegals?: boolean, - continuation?: ICompiledMode): IHighlightResult; + continuation?: ICompiledMode, + ): IHighlightResult; export function highlightAuto( value: string, - languageSubset?: string[]): IAutoHighlightResult; + languageSubset?: string[], + ): IAutoHighlightResult; export function fixMarkup(value: string): string; @@ -28,16 +30,18 @@ declare namespace hljs { export function registerLanguage( name: string, - language: (hljs?: HLJSStatic) => IModeBase): void; + language: (hljs?: HLJSStatic) => IModeBase, + ): void; export function listLanguages(): string[]; export function getLanguage(name: string): IMode; export function inherit(parent: object, obj: object): object; export function COMMENT( - begin: (string | RegExp), - end: (string | RegExp), - inherits: IModeBase): IMode; + begin: string | RegExp, + end: string | RegExp, + inherits: IModeBase, + ): IMode; // Common regexps export const IDENT_RE: string; diff --git a/types/hijackresponse/hijackresponse-tests.ts b/types/hijackresponse/hijackresponse-tests.ts index 526abb1e7ff1f1..4ec62c74118fd5 100644 --- a/types/hijackresponse/hijackresponse-tests.ts +++ b/types/hijackresponse/hijackresponse-tests.ts @@ -1,5 +1,5 @@ -import * as express from 'express'; -import * as hijackResponse from 'hijackresponse'; +import * as express from "express"; +import * as hijackResponse from "hijackresponse"; const app = express(); diff --git a/types/hijackresponse/index.d.ts b/types/hijackresponse/index.d.ts index 9305e685d32c14..614f2e195a0410 100644 --- a/types/hijackresponse/index.d.ts +++ b/types/hijackresponse/index.d.ts @@ -4,13 +4,13 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Minimum TypeScript Version: 3.5 -import express = require('express'); -import { Readable } from 'stream'; +import express = require("express"); +import { Readable } from "stream"; declare namespace e { interface HijackedResponse<ResBody = any> - extends express.Response<ResBody>, - Omit<Readable, keyof express.Response> { + extends express.Response<ResBody>, Omit<Readable, keyof express.Response> + { destroyHijacked: () => boolean; unhijack: () => express.Response; } diff --git a/types/hippy__react/hippy__react-tests.tsx b/types/hippy__react/hippy__react-tests.tsx index 78c0cf69ad5de9..e3b4cbf17e785b 100644 --- a/types/hippy__react/hippy__react-tests.tsx +++ b/types/hippy__react/hippy__react-tests.tsx @@ -1,33 +1,33 @@ -import * as React from 'react'; import { - Platform, + Animation, + AnimationSet, + AsyncStorage, + callNativeWithPromise, + Clipboard, + ConsoleModule, + Dimensions, + Hippy, + HippyEventEmitter, + Image, ListView, Modal, Navigator, + NetInfo, + NetworkModule, + PixelRatio, + Platform, RefreshWrapper, ScrollView, + StyleSheet, + Text, TextInput, - ViewPager, + UIManagerModule, View, - Text, - Image, + ViewPager, WaterfallView, - HippyEventEmitter, - callNativeWithPromise, - UIManagerModule, - Dimensions, - Animation, - AnimationSet, - AsyncStorage, - NetInfo, - Hippy, - Clipboard, - ConsoleModule, - NetworkModule, - PixelRatio, WebView, - StyleSheet, -} from '@hippy/react'; +} from "@hippy/react"; +import * as React from "react"; function Comp() { const textInput = React.useRef<TextInput>(null); @@ -37,20 +37,20 @@ function Comp() { }, []); React.useEffect(() => { - NetInfo.addEventListener('change', () => {}); + NetInfo.addEventListener("change", () => {}); }, [NetInfo]); React.useEffect(() => { (async () => { const str = await Clipboard.getString(); - ConsoleModule.log('Clipboard.getString', str); - Clipboard.setString('something'); + ConsoleModule.log("Clipboard.getString", str); + Clipboard.setString("something"); })(); }, []); return ( - <View overflow="hidden" style={{ overflow: 'hidden', collapsable: true }}> - <View overflow="visible" style={{ overflow: 'visible', collapsable: false }} /> + <View overflow="hidden" style={{ overflow: "hidden", collapsable: true }}> + <View overflow="visible" style={{ overflow: "visible", collapsable: false }} /> <Text> 'test' <Text>'nested'</Text> @@ -74,7 +74,7 @@ function Comp() { } new Hippy({ - appName: 'demo', + appName: "demo", entryPage: () => { return <View />; }, @@ -83,7 +83,7 @@ new Hippy({ const styles = StyleSheet.create({ style1: { - borderStyle: 'solid', - overflow: 'visible', + borderStyle: "solid", + overflow: "visible", }, }); diff --git a/types/hippy__react/index.d.ts b/types/hippy__react/index.d.ts index a5f9b60392faf8..6e7da3e22b6988 100644 --- a/types/hippy__react/index.d.ts +++ b/types/hippy__react/index.d.ts @@ -3,8 +3,8 @@ // Definitions by: zeroyu <https://github.com/zerosrat> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import * as React from 'react'; -import * as ReactReconciler from 'react-reconciler'; +import * as React from "react"; +import * as ReactReconciler from "react-reconciler"; // // Hippy Event @@ -231,32 +231,32 @@ interface ViewStyle { borderLeftColor?: string | number; borderBottomColor?: string | number; borderRightColor?: string | number; - borderStyle?: 'solid' | 'dotted' | 'dashed'; + borderStyle?: "solid" | "dotted" | "dashed"; boxShadowOpacity?: number; boxShadowRadius?: number; boxShadowColor?: string; boxShadowOffsetX?: number; boxShadowOffsetY?: number; fontSize?: number; - position?: 'relative' | 'absolute'; - flexDirection?: 'row' | 'column'; - flexWrap?: 'nowrap' | 'wrap' | 'wrap-reverse'; + position?: "relative" | "absolute"; + flexDirection?: "row" | "column"; + flexWrap?: "nowrap" | "wrap" | "wrap-reverse"; justifyContent?: - | 'start' - | 'center' - | 'end' - | 'flex-start' - | 'flex-end' - | 'left' - | 'right' - | 'normal' - | 'space-between' - | 'space-around' - | 'space-evenly' - | 'stretch'; - alignItems?: 'stretch' | 'center' | 'flex-start' | 'flex-end' | 'baseline'; - alignSelf?: 'stretch' | 'center' | 'flex-start' | 'flex-end' | 'baseline'; - overflow?: 'hidden' | 'visible'; + | "start" + | "center" + | "end" + | "flex-start" + | "flex-end" + | "left" + | "right" + | "normal" + | "space-between" + | "space-around" + | "space-evenly" + | "stretch"; + alignItems?: "stretch" | "center" | "flex-start" | "flex-end" | "baseline"; + alignSelf?: "stretch" | "center" | "flex-start" | "flex-end" | "baseline"; + overflow?: "hidden" | "visible"; flex?: any; flexGrow?: number; flexShrink?: number; @@ -292,20 +292,20 @@ declare type TextStyle = { // fontStyle?: 'normal' | 'italic', fontWeight?: ____FontWeight_Internal; lineHeight?: number; - textAlign?: 'auto' | 'left' | 'right' | 'center' | 'justify'; + textAlign?: "auto" | "left" | "right" | "center" | "justify"; } & ViewStyle; type ____FontWeight_Internal = - | 'normal' - | 'bold' - | '100' - | '200' - | '300' - | '400' - | '500' - | '600' - | '700' - | '800' - | '900'; + | "normal" + | "bold" + | "100" + | "200" + | "300" + | "400" + | "500" + | "600" + | "700" + | "800" + | "900"; type TextStyleProp = GenericStyleProp<TextStyle>; // @@ -354,7 +354,7 @@ interface ImageProps extends LayoutableProps, ClickableProps, TouchableProps { /** * Image resize mode, as same as containMode */ - resizeMode?: 'cover' | 'contain' | 'stretch' | 'repeat' | 'center'; + resizeMode?: "cover" | "contain" | "stretch" | "repeat" | "center"; /** * When the image is resized, the corners of the size specified by capInsets @@ -410,11 +410,11 @@ declare class Image extends React.Component<ImageProps> { ) => void; static prefetch: (url: string) => void; static get resizeMode(): { - contain: 'contain'; - cover: 'cover'; - stretch: 'stretch'; - center: 'center'; - repeat: 'repeat'; // iOS Only + contain: "contain"; + cover: "cover"; + stretch: "stretch"; + center: "center"; + repeat: "repeat"; // iOS Only }; } @@ -626,7 +626,7 @@ declare class ListView extends React.Component<ListViewProps> { collapsePullHeader: () => void; } -type ModalOrientation = 'portrait' | 'portrait-upside-down' | 'landscape' | 'landscape-left' | 'landscape-right'; +type ModalOrientation = "portrait" | "portrait-upside-down" | "landscape" | "landscape-left" | "landscape-right"; interface ModalProps extends LayoutableProps, ClickableProps, TouchableProps { /** * Show or hide @@ -682,7 +682,7 @@ interface ModalProps extends LayoutableProps, ClickableProps, TouchableProps { * * Default: 'slide' */ - animationType?: 'none' | 'slide' | 'fade' | 'slide_fade'; + animationType?: "none" | "slide" | "fade" | "slide_fade"; /** * Modal supports orientations @@ -867,7 +867,7 @@ interface ScrollViewProps extends LayoutableProps, ClickableProps, TouchableProp * iOS only * https://developer.apple.com/documentation/uikit/uiscrollview/keyboarddismissmode */ - keyboardDismissMode?: 'none' | 'on-drag' | 'interactive' | 'onDrag'; + keyboardDismissMode?: "none" | "on-drag" | "interactive" | "onDrag"; /** * Called when the momentum scroll starts (scroll which occurs as the ScrollView starts gliding). @@ -944,7 +944,7 @@ interface TextProps extends LayoutableProps, ClickableProps, TouchableProps { * * The default is `tail`. */ - ellipsizeMode?: 'head' | 'middle' | 'tail' | 'clip'; + ellipsizeMode?: "head" | "middle" | "tail" | "clip"; children?: string[] | React.ReactNode; text?: string; style?: TextStyleProp; @@ -996,7 +996,7 @@ interface TextInputProps extends LayoutableProps, ClickableProps, TouchableProps * * `phone-pad` * * `search` */ - keyboardType?: 'default' | 'numeric' | 'password' | 'email' | 'phone-pad' | 'search'; + keyboardType?: "default" | "numeric" | "password" | "email" | "phone-pad" | "search"; /** * Determines how the return key should look. @@ -1008,7 +1008,7 @@ interface TextInputProps extends LayoutableProps, ClickableProps, TouchableProps * * `search` * * `send` */ - returnKeyType?: 'done' | 'go' | 'next' | 'search' | 'send'; + returnKeyType?: "done" | "go" | "next" | "search" | "send"; /** * Limits the maximum number of characters that can be entered. @@ -1145,7 +1145,7 @@ interface ViewProps extends LayoutableProps, ClickableProps, TouchableProps { * * Default: iOS is 'visible', android is 'hidden'. */ - overflow?: 'visible' | 'hidden'; + overflow?: "visible" | "hidden"; focusable?: boolean; requestFocus?: boolean; nextFocusDownId?: string | ReactReconciler.Fiber; @@ -1172,7 +1172,7 @@ interface PageScrollEvent { position: number; offset: number; } -type PageScrollState = 'idle' | 'dragging' | 'settling'; +type PageScrollState = "idle" | "dragging" | "settling"; interface PageScrollStateEvent { pageScrollState: PageScrollState; } @@ -1199,7 +1199,7 @@ interface ViewPagerProps extends LayoutableProps { * iOS only * https://developer.apple.com/documentation/uikit/uiscrollview/keyboarddismissmode */ - keyboardDismissMode?: 'none' | 'on-drag' | 'interactive' | 'onDrag'; + keyboardDismissMode?: "none" | "on-drag" | "interactive" | "onDrag"; /** * Fires at most once per page is selected @@ -1389,7 +1389,7 @@ interface WebViewProps { /** * Request method */ - method?: 'get' | 'post'; + method?: "get" | "post"; style?: ViewStyleProp; @@ -1450,7 +1450,7 @@ type HippyEventRevoker = EventEmitterRevoker; type AnimationValue = number | { animationId: number } | string; type AnimationCallback = () => void; -type AnimationDirection = 'left' | 'right' | 'top' | 'bottom' | 'center'; +type AnimationDirection = "left" | "right" | "top" | "bottom" | "center"; interface AnimationOptions { /** @@ -1471,7 +1471,7 @@ interface AnimationOptions { /** * Timeline mode of animation */ - mode?: 'timing'; // TODO: fill more options + mode?: "timing"; // TODO: fill more options /** * Delay starting time @@ -1482,7 +1482,7 @@ interface AnimationOptions { * Value type, leave it blank in most case, except use rotate/color related * animation, set it to be 'deg' or 'color'. */ - valueType?: 'deg'; // TODO: fill more options + valueType?: "deg"; // TODO: fill more options /** * Animation start position @@ -1492,12 +1492,12 @@ interface AnimationOptions { /** * Animation interpolation type */ - timingFunction?: 'linear' | 'ease' | 'bezier' | 'in' | 'ease-in' | 'out' | 'ease-out' | 'inOut' | 'ease-in-out'; + timingFunction?: "linear" | "ease" | "bezier" | "in" | "ease-in" | "out" | "ease-out" | "inOut" | "ease-in-out"; /** * Animation repeat times, use 'loop' to be always repeating. */ - repeatCount?: number | 'loop'; + repeatCount?: number | "loop"; inputRange?: any[]; outputRange?: any[]; @@ -1523,7 +1523,7 @@ interface AnimationChild { } interface AnimationSetOption { children: AnimationChild[]; - repeatCount: number | 'loop'; + repeatCount: number | "loop"; virtual?: any; // TODO: What's it? } declare class AnimationSet { @@ -1582,13 +1582,13 @@ interface Bridge { callNativeWithPromise<T>(moduleName: string, methodName: string, ...args: any[]): Promise<T>; removeNativeCallback(callbackId: number): void; } -declare const callNative: Bridge['callNative']; -declare const callNativeWithCallbackId: Bridge['callNativeWithCallbackId']; -declare const callNativeWithPromise: Bridge['callNativeWithPromise']; -declare const removeNativeCallback: Bridge['removeNativeCallback']; +declare const callNative: Bridge["callNative"]; +declare const callNativeWithCallbackId: Bridge["callNativeWithCallbackId"]; +declare const callNativeWithPromise: Bridge["callNativeWithPromise"]; +declare const removeNativeCallback: Bridge["removeNativeCallback"]; interface Dimensions { - get(dim: 'window' | 'screen'): { + get(dim: "window" | "screen"): { height: number; width: number; scale: number; @@ -1661,7 +1661,7 @@ interface NavigatorProps { declare class Navigator extends React.Component<NavigatorProps> {} interface Platform { - OS: 'ios' | 'android'; + OS: "ios" | "android"; } export const Platform: Platform; @@ -1711,7 +1711,7 @@ interface Element extends ViewNode { attributes: Attributes; } interface UIManagerModule { - getElementFromFiberRef(ref: ReactReconciler.Fiber | Element): Element | ReactReconciler.Fiber['stateNode']; + getElementFromFiberRef(ref: ReactReconciler.Fiber | Element): Element | ReactReconciler.Fiber["stateNode"]; getNodeIdByRef(ref: string | ReactReconciler.Fiber | Element): number; callUIFunction(ref: Element | ReactReconciler.Fiber, funcName: string, ...options: any[]): void; measureInWindowByMethod( diff --git a/types/hiredis/hiredis-tests.ts b/types/hiredis/hiredis-tests.ts index 9a32fb975593f0..433e01132e7fcd 100644 --- a/types/hiredis/hiredis-tests.ts +++ b/types/hiredis/hiredis-tests.ts @@ -1,4 +1,4 @@ -import { Reader, Config, createConnection } from "hiredis"; +import { Config, createConnection, Reader } from "hiredis"; const socket = createConnection(6379, "localhost"); diff --git a/types/hiredis/index.d.ts b/types/hiredis/index.d.ts index 97a3f8d98c7f86..c7154d0d9225ff 100644 --- a/types/hiredis/index.d.ts +++ b/types/hiredis/index.d.ts @@ -8,13 +8,13 @@ import * as net from "net"; export interface Config { - return_buffers: boolean; + return_buffers: boolean; } export class Reader { - constructor(config?: Config); - feed(reply: string | Buffer): void; - get(): string | Buffer; + constructor(config?: Config); + feed(reply: string | Buffer): void; + get(): string | Buffer; } export function createConnection(port: number, host: string): net.Socket; diff --git a/types/history-events/history-events-tests.ts b/types/history-events/history-events-tests.ts index b276ad27a657ba..f7d411d699820b 100644 --- a/types/history-events/history-events-tests.ts +++ b/types/history-events/history-events-tests.ts @@ -1,22 +1,22 @@ -import type { HistoryEvent } from 'history-events'; -import historyEvents = require('history-events'); +import type { HistoryEvent } from "history-events"; +import historyEvents = require("history-events"); if (historyEvents.isHistorySupported()) { const handler = (ev: HistoryEvent) => { - console.log(ev, 'fired'); - console.log('Event Name:', ev.eventName); - console.log('State:', ev.state); + console.log(ev, "fired"); + console.log("Event Name:", ev.eventName); + console.log("State:", ev.state); }; - window.addEventListener('pushstate', handler); - window.addEventListener('replacestate', handler); - window.addEventListener('changestate', handler); + window.addEventListener("pushstate", handler); + window.addEventListener("replacestate", handler); + window.addEventListener("changestate", handler); - window.onpushstate = () => console.log('pushstate fired'); - window.onreplacestate = () => console.log('replacestate fired'); - window.onchangestate = () => console.log('changestate fired'); + window.onpushstate = () => console.log("pushstate fired"); + window.onreplacestate = () => console.log("replacestate fired"); + window.onchangestate = () => console.log("changestate fired"); - historyEvents.triggerEvent(window, 'pushstate', { foo: 'bar' }); - historyEvents.addEventListener(window, 'changestate', console.log); - historyEvents.removeEventListener(window, 'changestate', console.log); + historyEvents.triggerEvent(window, "pushstate", { foo: "bar" }); + historyEvents.addEventListener(window, "changestate", console.log); + historyEvents.removeEventListener(window, "changestate", console.log); } diff --git a/types/history.js/history.js-tests.ts b/types/history.js/history.js-tests.ts index eb5e2fb5e96fe6..f3d586b4351dfe 100644 --- a/types/history.js/history.js-tests.ts +++ b/types/history.js/history.js-tests.ts @@ -1,17 +1,15 @@ - - -// Since History is defined in lib.d.ts as well +// Since History is defined in lib.d.ts as well // the name for our interfaces was chosen to be Historyjs // However at runtime you would need to do -// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/277 -var Historyjs: Historyjs = <any>History; +// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/277 +var Historyjs: Historyjs = <any> History; function tests() { if (!Historyjs.enabled) { return false; } - Historyjs.Adapter.bind(window, 'statechange', () => { + Historyjs.Adapter.bind(window, "statechange", () => { var State = Historyjs.getState(); Historyjs.log(State.data, State.title, State.url); }); diff --git a/types/history.js/index.d.ts b/types/history.js/index.d.ts index fa1710f4e0c749..30a8e0ef4bf9b9 100644 --- a/types/history.js/index.d.ts +++ b/types/history.js/index.d.ts @@ -3,7 +3,6 @@ // Definitions by: Boris Yankov <https://github.com/borisyankov>, Gidon Junge <https://github.com/gjunge> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - interface HistoryAdapter { bind(element: any, event: string, callback: () => void): void; trigger(element: any, event: string): void; @@ -17,14 +16,13 @@ interface HistoryAdapter { // var Historyjs: Historyjs = <any>History; interface Historyjs { - enabled: boolean; pushState(data: any, title: string, url: string, queue?: boolean): boolean; replaceState(data: any, title: string, url: string, queue?: boolean): boolean; getState(friendly?: boolean, create?: boolean): HistoryState; - getStateId (passedState: HistoryState): string; - getStateById (id: string): HistoryState; + getStateId(passedState: HistoryState): string; + getStateById(id: string): HistoryState; getStateByIndex(index: number): HistoryState; getCurrentIndex(): number; getHash(): string; @@ -46,7 +44,7 @@ interface Historyjs { * @param {HistoryState} newState * @return {Boolean} */ - setTitle (newState: HistoryState): boolean + setTitle(newState: HistoryState): boolean; clearQueue(): Historyjs; clearAllIntervals(): void; getRootUrl(): string; @@ -54,7 +52,7 @@ interface Historyjs { emulated: { hashChange?: any; pushState?: any; - } + }; } interface HistoryState { diff --git a/types/historykana/historykana-tests.ts b/types/historykana/historykana-tests.ts index f801ce4f52add6..bd7a4b06f1db79 100644 --- a/types/historykana/historykana-tests.ts +++ b/types/historykana/historykana-tests.ts @@ -16,7 +16,7 @@ const inputHistory = [ "山田たろ", "山田たろう", "山田太郎", - "山田太郎" + "山田太郎", ]; const result = historykana(inputHistory); diff --git a/types/hjson/hjson-tests.ts b/types/hjson/hjson-tests.ts index 9f1f89eb8ed794..d10db338af3165 100644 --- a/types/hjson/hjson-tests.ts +++ b/types/hjson/hjson-tests.ts @@ -1,4 +1,4 @@ -import hjson = require('hjson'); +import hjson = require("hjson"); let deserializedObj: any; let deserializeOptions: hjson.DeserializeOptions; @@ -9,10 +9,10 @@ let deserailizeObjWithoutLegacyRoot: any; deserializeOptions = {}; serializeOptions = {}; -deserializedObj = hjson.parse('foo'); -deserializedObj = hjson.parse('foo', deserializeOptions); +deserializedObj = hjson.parse("foo"); +deserializedObj = hjson.parse("foo", deserializeOptions); -serializedObj = hjson.stringify({ foo: 'bar' }); -serializedObj = hjson.stringify({ foo: 'bar' }, serializeOptions); +serializedObj = hjson.stringify({ foo: "bar" }); +serializedObj = hjson.stringify({ foo: "bar" }, serializeOptions); -deserailizeObjWithoutLegacyRoot = hjson.parse('foo', {legacyRoot: false}); +deserailizeObjWithoutLegacyRoot = hjson.parse("foo", { legacyRoot: false }); diff --git a/types/hjson/index.d.ts b/types/hjson/index.d.ts index 16f6a29a17b251..d60c0a3feccb32 100644 --- a/types/hjson/index.d.ts +++ b/types/hjson/index.d.ts @@ -5,63 +5,63 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export interface DeserializeOptions { - /** - * keep white space and comments. This is useful if - * you want to edit an hjson file and save it while preserving comments (default false) - */ - keepWsc?: boolean | undefined; - /** - * Turn off legacy support for omitting root braces (defaults true) - */ - legacyRoot?: boolean | undefined; + /** + * keep white space and comments. This is useful if + * you want to edit an hjson file and save it while preserving comments (default false) + */ + keepWsc?: boolean | undefined; + /** + * Turn off legacy support for omitting root braces (defaults true) + */ + legacyRoot?: boolean | undefined; } export interface SerializeOptions { - /** - * keep white space. See parse. - */ - keepWsc?: boolean | undefined; - /** - * makes braces appear on the same line as the key name. Default false. - */ - bracesSameLine?: boolean | undefined; - /** - * show braces for the root object. Default true. - */ - emitRootBraces?: boolean | undefined; - /** - * controls how strings are displayed. (setting separator implies "strings") - * "min": no quotes whenever possible (default) - * "keys": use quotes around keys - * "strings": use quotes around string values - * "all": use quotes around keys and string values - */ - quotes?: 'min' | 'keys' | 'strings' | 'all' | undefined; - /** - * controls how multiline strings are displayed. (setting quotes implies "off") - * "std": strings containing \n are shown in multiline format (default) - * "no-tabs": like std but disallow tabs - * "off": show in JSON format - */ - multiline?: 'std' | 'no-tabs' | 'off' | undefined; - /** - * output a comma separator between elements. Default false - */ - separator?: boolean | undefined; - /** - * specifies the indentation of nested structures. - * If it is a number, it will specify the number of spaces to indent at each level. - * If it is a string (such as '\t' or ' '), it contains the characters used to indent at each level. - */ - space?: number | string | undefined; - /** - * specifies the EOL sequence (default is set by Hjson.setEndOfLine()) - */ - eol?: string | undefined; - /** - * output ascii color codes - */ - colors?: boolean | undefined; + /** + * keep white space. See parse. + */ + keepWsc?: boolean | undefined; + /** + * makes braces appear on the same line as the key name. Default false. + */ + bracesSameLine?: boolean | undefined; + /** + * show braces for the root object. Default true. + */ + emitRootBraces?: boolean | undefined; + /** + * controls how strings are displayed. (setting separator implies "strings") + * "min": no quotes whenever possible (default) + * "keys": use quotes around keys + * "strings": use quotes around string values + * "all": use quotes around keys and string values + */ + quotes?: "min" | "keys" | "strings" | "all" | undefined; + /** + * controls how multiline strings are displayed. (setting quotes implies "off") + * "std": strings containing \n are shown in multiline format (default) + * "no-tabs": like std but disallow tabs + * "off": show in JSON format + */ + multiline?: "std" | "no-tabs" | "off" | undefined; + /** + * output a comma separator between elements. Default false + */ + separator?: boolean | undefined; + /** + * specifies the indentation of nested structures. + * If it is a number, it will specify the number of spaces to indent at each level. + * If it is a string (such as '\t' or ' '), it contains the characters used to indent at each level. + */ + space?: number | string | undefined; + /** + * specifies the EOL sequence (default is set by Hjson.setEndOfLine()) + */ + eol?: string | undefined; + /** + * output ascii color codes + */ + colors?: boolean | undefined; } /*~ If this module has methods, declare them as functions like so. diff --git a/types/hl7/events/adt.event.d.ts b/types/hl7/events/adt.event.d.ts index 2d50a0a667ea4e..ac398606713624 100644 --- a/types/hl7/events/adt.event.d.ts +++ b/types/hl7/events/adt.event.d.ts @@ -2,7 +2,7 @@ import { PID, PV1 } from "../segments"; import { Base } from "./base.event"; export interface ADT extends Base { - EVN: any; - PID: PID; - PV1: PV1; + EVN: any; + PID: PID; + PV1: PV1; } diff --git a/types/hl7/events/base.event.d.ts b/types/hl7/events/base.event.d.ts index 2b6b262f53f520..eaf006b939303d 100644 --- a/types/hl7/events/base.event.d.ts +++ b/types/hl7/events/base.event.d.ts @@ -1,6 +1,6 @@ import { MSH } from "../segments"; export interface Base { - MSH: MSH; - NTE?: any; + MSH: MSH; + NTE?: any; } diff --git a/types/hl7/events/index.d.ts b/types/hl7/events/index.d.ts index 47ebd2b521fc1d..7556abf19699d3 100644 --- a/types/hl7/events/index.d.ts +++ b/types/hl7/events/index.d.ts @@ -1,11 +1,11 @@ // import { ADT } from './adt.event'; -export * from './base.event'; -export * from './adt.event'; -export * from './orm.event'; -export * from './siu.event'; -export * from './oru.event'; -export * from './omg.event'; +export * from "./adt.event"; +export * from "./base.event"; +export * from "./omg.event"; +export * from "./orm.event"; +export * from "./oru.event"; +export * from "./siu.event"; /** * The standard is written from the assumption that an event in the real world of healthcare creates the need for data to flow among systems. diff --git a/types/hl7/events/omg.event.d.ts b/types/hl7/events/omg.event.d.ts index 33b17f50c04b8d..401258d6b4bc26 100644 --- a/types/hl7/events/omg.event.d.ts +++ b/types/hl7/events/omg.event.d.ts @@ -1,20 +1,20 @@ -import { PID, PV1, ORC, OBR, OBX } from "../segments"; +import { OBR, OBX, ORC, PID, PV1 } from "../segments"; import { Base } from "./base.event"; export interface OMG extends Base { - SFT?: any; - PID: PID; - PD1?: any; - MK1?: any; - PV1: PV1; - PV2?: any; - ORC: ORC; - OBR: OBR; - TQ1?: any; - TQ2?: any; - CTD?: any; - OBX: OBX; - FT1?: any; - SPM?: any; - DSC?: any; + SFT?: any; + PID: PID; + PD1?: any; + MK1?: any; + PV1: PV1; + PV2?: any; + ORC: ORC; + OBR: OBR; + TQ1?: any; + TQ2?: any; + CTD?: any; + OBX: OBX; + FT1?: any; + SPM?: any; + DSC?: any; } diff --git a/types/hl7/events/orm.event.d.ts b/types/hl7/events/orm.event.d.ts index 53129ef42b9c2b..187888c4d274a3 100644 --- a/types/hl7/events/orm.event.d.ts +++ b/types/hl7/events/orm.event.d.ts @@ -2,22 +2,22 @@ import { OBR, OBX, ORC, PID, PV1 } from "../segments"; import { Base } from "./base.event"; export interface ORM extends Base { - PID: PID; - PD1?: any; - PV1?: PV1; - PV2?: any; - IN1?: any; - IN2?: any; - IN3?: any; - GT1?: any; - AL1?: any; - ORC: ORC; - OBR: OBR; - OBX: OBX; - CTD?: any; - DG1?: any; - FT1?: any; - CTI?: any; - BLG?: any; - ZDS: any; + PID: PID; + PD1?: any; + PV1?: PV1; + PV2?: any; + IN1?: any; + IN2?: any; + IN3?: any; + GT1?: any; + AL1?: any; + ORC: ORC; + OBR: OBR; + OBX: OBX; + CTD?: any; + DG1?: any; + FT1?: any; + CTI?: any; + BLG?: any; + ZDS: any; } diff --git a/types/hl7/events/oru.event.d.ts b/types/hl7/events/oru.event.d.ts index c3896d8fa7a85d..41954a12fea0f3 100644 --- a/types/hl7/events/oru.event.d.ts +++ b/types/hl7/events/oru.event.d.ts @@ -1,20 +1,20 @@ -import { PID, PV1, ORC, OBR, OBX } from "../segments"; +import { OBR, OBX, ORC, PID, PV1 } from "../segments"; import { Base } from "./base.event"; export interface ORU extends Base { - SFT?: any; - PID: PID; - PD1?: any; - MK1?: any; - PV1: PV1; - PV2?: any; - ORC: ORC; - OBR: OBR; - TQ1?: any; - TQ2?: any; - CTD?: any; - OBX: OBX; - FT1?: any; - SPM?: any; - DSC?: any; + SFT?: any; + PID: PID; + PD1?: any; + MK1?: any; + PV1: PV1; + PV2?: any; + ORC: ORC; + OBR: OBR; + TQ1?: any; + TQ2?: any; + CTD?: any; + OBX: OBX; + FT1?: any; + SPM?: any; + DSC?: any; } diff --git a/types/hl7/events/siu.event.d.ts b/types/hl7/events/siu.event.d.ts index 573ffb6c00a756..5addaf63873207 100644 --- a/types/hl7/events/siu.event.d.ts +++ b/types/hl7/events/siu.event.d.ts @@ -1,5 +1,5 @@ -import { PID, PV1, OBX, ORC, OBR, AIS, AIL } from '../segments'; -import { Base } from './base.event'; +import { AIL, AIS, OBR, OBX, ORC, PID, PV1 } from "../segments"; +import { Base } from "./base.event"; export interface SIU extends Base { PID: PID; diff --git a/types/hl7/hl7-tests.ts b/types/hl7/hl7-tests.ts index 38aebf7b77ca94..023471127377d9 100644 --- a/types/hl7/hl7-tests.ts +++ b/types/hl7/hl7-tests.ts @@ -2,39 +2,39 @@ import { hl7 } from "hl7"; // Types your Event const message: hl7.TriggerEvent["ORM"] = { - MSH: { - "MSH.1": "", - "MSH.2": "", - "MSH.3": "", - "MSH.4": "", - "MSH.5": "", - "MSH.6": "", - "MSH.7": "", - "MSH.8": "", - "MSH.9": "", - "MSH.10": "", - "MSH.11": "", - "MSH.12": "", - "MSH.13": "", - "MSH.14": "", - "MSH.15": "", - "MSH.16": "", - "MSH.17": "", - "MSH.18": "", - "MSH.19": "", - "MSH.20": "", - "MSH.21": "", - }, - PID: { - "PID.5": { - "PID.5.1": "Smith", - "PID.5.2": "John", + MSH: { + "MSH.1": "", + "MSH.2": "", + "MSH.3": "", + "MSH.4": "", + "MSH.5": "", + "MSH.6": "", + "MSH.7": "", + "MSH.8": "", + "MSH.9": "", + "MSH.10": "", + "MSH.11": "", + "MSH.12": "", + "MSH.13": "", + "MSH.14": "", + "MSH.15": "", + "MSH.16": "", + "MSH.17": "", + "MSH.18": "", + "MSH.19": "", + "MSH.20": "", + "MSH.21": "", }, - }, - ORC: {}, - OBR: {}, - OBX: {}, - ZDS: {}, + PID: { + "PID.5": { + "PID.5.1": "Smith", + "PID.5.2": "John", + }, + }, + ORC: {}, + OBR: {}, + OBX: {}, + ZDS: {}, }; // Then it will types your Segment diff --git a/types/hl7/index.d.ts b/types/hl7/index.d.ts index b9307ac5a182f7..d4add452225904 100644 --- a/types/hl7/index.d.ts +++ b/types/hl7/index.d.ts @@ -5,8 +5,8 @@ // import './segments'; // import './events'; -import { ADT, OMG, ORM, ORU, SIU } from './events'; -import { AIL, AIS, MSH, OBR, OBX, ORC, PID, PV1 } from './segments'; +import { ADT, OMG, ORM, ORU, SIU } from "./events"; +import { AIL, AIS, MSH, OBR, OBX, ORC, PID, PV1 } from "./segments"; // import TriggerEvent = require('./events'); // import Segment = require('./segments'); diff --git a/types/hl7/segments/ail.segment.d.ts b/types/hl7/segments/ail.segment.d.ts index 25fd116bfd1d93..bf7c0f29c7257a 100644 --- a/types/hl7/segments/ail.segment.d.ts +++ b/types/hl7/segments/ail.segment.d.ts @@ -8,16 +8,16 @@ * [documentation](https://hl7-definition.caristix.com/v2/HL7v2.5.1/Segments/AIL) */ export interface AIL { - 'AIS.1': string; - 'AIS.2': string; - 'AIS.3': string; - 'AIS.4': string; - 'AIS.5': string; - 'AIS.6': string; - 'AIS.7': string; - 'AIS.8': string; - 'AIS.9': string; - 'AIS.10': string; - 'AIS.11': string; - 'AIS.12': string; + "AIS.1": string; + "AIS.2": string; + "AIS.3": string; + "AIS.4": string; + "AIS.5": string; + "AIS.6": string; + "AIS.7": string; + "AIS.8": string; + "AIS.9": string; + "AIS.10": string; + "AIS.11": string; + "AIS.12": string; } diff --git a/types/hl7/segments/ais.segment.d.ts b/types/hl7/segments/ais.segment.d.ts index 55e265ad11ae11..b1827fc2789b3d 100644 --- a/types/hl7/segments/ais.segment.d.ts +++ b/types/hl7/segments/ais.segment.d.ts @@ -6,16 +6,16 @@ * [documentation](https://hl7-definition.caristix.com/v2/HL7v2.5.1/Segments/AIS) */ export interface AIS { - 'AIS.1': string; - 'AIS.2': string; - 'AIS.3': string; - 'AIS.4': string; - 'AIS.5': string; - 'AIS.6': string; - 'AIS.7': string; - 'AIS.8': string; - 'AIS.9': string; - 'AIS.10': string; - 'AIS.11': string; - 'AIS.12': string; + "AIS.1": string; + "AIS.2": string; + "AIS.3": string; + "AIS.4": string; + "AIS.5": string; + "AIS.6": string; + "AIS.7": string; + "AIS.8": string; + "AIS.9": string; + "AIS.10": string; + "AIS.11": string; + "AIS.12": string; } diff --git a/types/hl7/segments/index.d.ts b/types/hl7/segments/index.d.ts index 76ac1a78a99a6c..dcf6fcb7327361 100644 --- a/types/hl7/segments/index.d.ts +++ b/types/hl7/segments/index.d.ts @@ -1,11 +1,11 @@ -export * from './ail.segment'; -export * from './pid.segment'; -export * from './msh.segment'; -export * from './pv1.segment'; -export * from './orc.segment'; -export * from './obr.segment'; -export * from './obx.segment'; -export * from './ais.segment'; +export * from "./ail.segment"; +export * from "./ais.segment"; +export * from "./msh.segment"; +export * from "./obr.segment"; +export * from "./obx.segment"; +export * from "./orc.segment"; +export * from "./pid.segment"; +export * from "./pv1.segment"; /** * A segment is a logical grouping of data fields. Segments of a message may be required or optional. diff --git a/types/hl7/segments/msh.segment.d.ts b/types/hl7/segments/msh.segment.d.ts index 1d05782b9180f7..d31134843551b1 100644 --- a/types/hl7/segments/msh.segment.d.ts +++ b/types/hl7/segments/msh.segment.d.ts @@ -11,7 +11,7 @@ export interface MSH { * * [documentation](https://hl7-definition.caristix.com/v2/HL7v2.8/Fields/MSH.1) */ - 'MSH.1': string; + "MSH.1": string; /** * Encoding Characters * @description This field contains the separator between the segment ID and the first real field, MSH-2 Encoding Characters. @@ -19,7 +19,7 @@ export interface MSH { * * [documentation](https://hl7-definition.caristix.com/v2/HL7v2.8/Fields/MSH.2) */ - 'MSH.2': string; + "MSH.2": string; /** * Sending Application * @description This field contains the separator between the segment ID and the first real field, MSH-2 Encoding Characters. @@ -27,7 +27,7 @@ export interface MSH { * * [documentation](https://hl7-definition.caristix.com/v2/HL7v2.8/Fields/MSH.3) */ - 'MSH.3': string; + "MSH.3": string; /** * Sending Facility * @description This field contains the separator between the segment ID and the first real field, MSH-2 Encoding Characters. @@ -35,7 +35,7 @@ export interface MSH { * * [documentation](https://hl7-definition.caristix.com/v2/HL7v2.8/Fields/MSH.4) */ - 'MSH.4': string; + "MSH.4": string; /** * Receiving Application * @description This field contains the separator between the segment ID and the first real field, MSH-2 Encoding Characters. @@ -43,7 +43,7 @@ export interface MSH { * * [documentation](https://hl7-definition.caristix.com/v2/HL7v2.8/Fields/MSH.5) */ - 'MSH.5': string; + "MSH.5": string; /** * Receiving Facility * @description This field contains the separator between the segment ID and the first real field, MSH-2 Encoding Characters. @@ -51,7 +51,7 @@ export interface MSH { * * [documentation](https://hl7-definition.caristix.com/v2/HL7v2.8/Fields/MSH.6) */ - 'MSH.6': string; + "MSH.6": string; /** * Date/Time Of Message * @description This field contains the separator between the segment ID and the first real field, MSH-2 Encoding Characters. @@ -59,7 +59,7 @@ export interface MSH { * * [documentation](https://hl7-definition.caristix.com/v2/HL7v2.8/Fields/MSH.7) */ - 'MSH.7': string; + "MSH.7": string; /** * Security * @description This field contains the separator between the segment ID and the first real field, MSH-2 Encoding Characters. @@ -67,7 +67,7 @@ export interface MSH { * * [documentation](https://hl7-definition.caristix.com/v2/HL7v2.8/Fields/MSH.8) */ - 'MSH.8': string; + "MSH.8": string; /** * Message Type * @description This field contains the separator between the segment ID and the first real field, MSH-2 Encoding Characters. @@ -75,7 +75,7 @@ export interface MSH { * * [documentation](https://hl7-definition.caristix.com/v2/HL7v2.8/Fields/MSH.9) */ - 'MSH.9': string; + "MSH.9": string; /** * Message Control ID * @description This field contains the separator between the segment ID and the first real field, MSH-2 Encoding Characters. @@ -83,7 +83,7 @@ export interface MSH { * * [documentation](https://hl7-definition.caristix.com/v2/HL7v2.8/Fields/MSH.10) */ - 'MSH.10': string; + "MSH.10": string; /** * Processing ID * @description This field contains the separator between the segment ID and the first real field, MSH-2 Encoding Characters. @@ -91,7 +91,7 @@ export interface MSH { * * [documentation](https://hl7-definition.caristix.com/v2/HL7v2.8/Fields/MSH.11) */ - 'MSH.11': string; + "MSH.11": string; /** * Version ID * @description This field contains the separator between the segment ID and the first real field, MSH-2 Encoding Characters. @@ -99,7 +99,7 @@ export interface MSH { * * [documentation](https://hl7-definition.caristix.com/v2/HL7v2.8/Fields/MSH.12) */ - 'MSH.12': string; + "MSH.12": string; /** * Sequence Number * @description This field contains the separator between the segment ID and the first real field, MSH-2 Encoding Characters. @@ -107,7 +107,7 @@ export interface MSH { * * [documentation](https://hl7-definition.caristix.com/v2/HL7v2.8/Fields/MSH.13) */ - 'MSH.13': string; + "MSH.13": string; /** * Continuation Pointer * @description This field contains the separator between the segment ID and the first real field, MSH-2 Encoding Characters. @@ -115,7 +115,7 @@ export interface MSH { * * [documentation](https://hl7-definition.caristix.com/v2/HL7v2.8/Fields/MSH.14) */ - 'MSH.14': string; + "MSH.14": string; /** * Accept Acknowledgment Type * @description This field contains the separator between the segment ID and the first real field, MSH-2 Encoding Characters. @@ -123,7 +123,7 @@ export interface MSH { * * [documentation](https://hl7-definition.caristix.com/v2/HL7v2.8/Fields/MSH.15) */ - 'MSH.15': string; + "MSH.15": string; /** * Application Acknowledgment Type * @description This field contains the separator between the segment ID and the first real field, MSH-2 Encoding Characters. @@ -131,7 +131,7 @@ export interface MSH { * * [documentation](https://hl7-definition.caristix.com/v2/HL7v2.8/Fields/MSH.16) */ - 'MSH.16': string; + "MSH.16": string; /** * Country Code * @description This field contains the separator between the segment ID and the first real field, MSH-2 Encoding Characters. @@ -139,7 +139,7 @@ export interface MSH { * * [documentation](https://hl7-definition.caristix.com/v2/HL7v2.8/Fields/MSH.17) */ - 'MSH.17': string; + "MSH.17": string; /** * Character Set * @description This field contains the separator between the segment ID and the first real field, MSH-2 Encoding Characters. @@ -147,7 +147,7 @@ export interface MSH { * * [documentation](https://hl7-definition.caristix.com/v2/HL7v2.8/Fields/MSH.18) */ - 'MSH.18': string; + "MSH.18": string; /** * Principal Language Of Message * @description This field contains the separator between the segment ID and the first real field, MSH-2 Encoding Characters. @@ -155,7 +155,7 @@ export interface MSH { * * [documentation](https://hl7-definition.caristix.com/v2/HL7v2.8/Fields/MSH.19) */ - 'MSH.19': string; + "MSH.19": string; /** * Alternate Character Set Handling Scheme * @description This field contains the separator between the segment ID and the first real field, MSH-2 Encoding Characters. @@ -163,7 +163,7 @@ export interface MSH { * * [documentation](https://hl7-definition.caristix.com/v2/HL7v2.8/Fields/MSH.20) */ - 'MSH.20': string; + "MSH.20": string; /** * Message Profile Identifier * @description This field contains the separator between the segment ID and the first real field, MSH-2 Encoding Characters. @@ -171,5 +171,5 @@ export interface MSH { * * [documentation](https://hl7-definition.caristix.com/v2/HL7v2.8/Fields/MSH.21) */ - 'MSH.21': string; + "MSH.21": string; } diff --git a/types/hl7/segments/obr.segment.d.ts b/types/hl7/segments/obr.segment.d.ts index db8cea0cbad52b..4c0b987110327b 100644 --- a/types/hl7/segments/obr.segment.d.ts +++ b/types/hl7/segments/obr.segment.d.ts @@ -4,52 +4,52 @@ * * [documentation](https://hl7-definition.caristix.com/v2/HL7v2.5.1/Segments/OBR) */ - export interface OBR { - 'OBR.1'?: string; - 'OBR.2'?: string; - 'OBR.3'?: string; - 'OBR.4'?: string; - 'OBR.5'?: string; - 'OBR.6'?: string; - 'OBR.7'?: string; - 'OBR.8'?: string; - 'OBR.9'?: string; - 'OBR.10'?: string; - 'OBR.11'?: string; - 'OBR.12'?: string; - 'OBR.13'?: string; - 'OBR.14'?: string; - 'OBR.15'?: string; - 'OBR.16'?: string; - 'OBR.17'?: string; - 'OBR.18'?: string; - 'OBR.19'?: string; - 'OBR.20'?: string; - 'OBR.22'?: string; - 'OBR.23'?: string; - 'OBR.24'?: string; - 'OBR.25'?: string; - 'OBR.26'?: string; - 'OBR.27'?: string; - 'OBR.28'?: string; - 'OBR.29'?: string; - 'OBR.30'?: string; - 'OBR.31'?: string; - 'OBR.32'?: string; - 'OBR.33'?: string; - 'OBR.34'?: string; - 'OBR.35'?: string; - 'OBR.36'?: string; - 'OBR.37'?: string; - 'OBR.38'?: string; - 'OBR.40'?: string; - 'OBR.41'?: string; - 'OBR.42'?: string; - 'OBR.43'?: string; - 'OBR.44'?: string; - 'OBR.45'?: string; - 'OBR.46'?: string; - 'OBR.47'?: string; - 'OBR.48'?: string; - 'OBR.49'?: string; +export interface OBR { + "OBR.1"?: string; + "OBR.2"?: string; + "OBR.3"?: string; + "OBR.4"?: string; + "OBR.5"?: string; + "OBR.6"?: string; + "OBR.7"?: string; + "OBR.8"?: string; + "OBR.9"?: string; + "OBR.10"?: string; + "OBR.11"?: string; + "OBR.12"?: string; + "OBR.13"?: string; + "OBR.14"?: string; + "OBR.15"?: string; + "OBR.16"?: string; + "OBR.17"?: string; + "OBR.18"?: string; + "OBR.19"?: string; + "OBR.20"?: string; + "OBR.22"?: string; + "OBR.23"?: string; + "OBR.24"?: string; + "OBR.25"?: string; + "OBR.26"?: string; + "OBR.27"?: string; + "OBR.28"?: string; + "OBR.29"?: string; + "OBR.30"?: string; + "OBR.31"?: string; + "OBR.32"?: string; + "OBR.33"?: string; + "OBR.34"?: string; + "OBR.35"?: string; + "OBR.36"?: string; + "OBR.37"?: string; + "OBR.38"?: string; + "OBR.40"?: string; + "OBR.41"?: string; + "OBR.42"?: string; + "OBR.43"?: string; + "OBR.44"?: string; + "OBR.45"?: string; + "OBR.46"?: string; + "OBR.47"?: string; + "OBR.48"?: string; + "OBR.49"?: string; } diff --git a/types/hl7/segments/obx.segment.d.ts b/types/hl7/segments/obx.segment.d.ts index 2facdb5b53f062..3c30e845cce700 100644 --- a/types/hl7/segments/obx.segment.d.ts +++ b/types/hl7/segments/obx.segment.d.ts @@ -6,24 +6,24 @@ * * [documentation](https://hl7-definition.caristix.com/v2/HL7v2.5.1/Segments/OBX) */ - export interface OBX { - 'OBX.1'?: string; - 'OBX.2'?: string; - 'OBX.3'?: string; - 'OBX.4'?: string; - 'OBX.5'?: string; - 'OBX.6'?: string; - 'OBX.7'?: string; - 'OBX.8'?: string; - 'OBX.9'?: string; - 'OBX.10'?: string; - 'OBX.11'?: string; - 'OBX.12'?: string; - 'OBX.13'?: string; - 'OBX.14'?: string; - 'OBX.15'?: string; - 'OBX.16'?: string; - 'OBX.17'?: string; - 'OBX.18'?: string; - 'OBX.19'?: string; +export interface OBX { + "OBX.1"?: string; + "OBX.2"?: string; + "OBX.3"?: string; + "OBX.4"?: string; + "OBX.5"?: string; + "OBX.6"?: string; + "OBX.7"?: string; + "OBX.8"?: string; + "OBX.9"?: string; + "OBX.10"?: string; + "OBX.11"?: string; + "OBX.12"?: string; + "OBX.13"?: string; + "OBX.14"?: string; + "OBX.15"?: string; + "OBX.16"?: string; + "OBX.17"?: string; + "OBX.18"?: string; + "OBX.19"?: string; } diff --git a/types/hl7/segments/orc.segment.d.ts b/types/hl7/segments/orc.segment.d.ts index 6f17f22334608a..62082e7efba792 100644 --- a/types/hl7/segments/orc.segment.d.ts +++ b/types/hl7/segments/orc.segment.d.ts @@ -6,35 +6,35 @@ * * [documentation](https://hl7-definition.caristix.com/v2/HL7v2.5.1/Segments/ORC) */ - export interface ORC { - 'ORC.1'?: string; - 'ORC.2'?: string; - 'ORC.3'?: string; - 'ORC.4'?: string; - 'ORC.5'?: string; - 'ORC.6'?: string; - 'ORC.7'?: string; - 'ORC.8'?: string; - 'ORC.9'?: string; - 'ORC.10'?: string; - 'ORC.11'?: string; - 'ORC.12'?: string; - 'ORC.13'?: string; - 'ORC.14'?: string; - 'ORC.15'?: string; - 'ORC.16'?: string; - 'ORC.17'?: string; - 'ORC.18'?: string; - 'ORC.19'?: string; - 'ORC.20'?: string; - 'ORC.22'?: string; - 'ORC.23'?: string; - 'ORC.24'?: string; - 'ORC.25'?: string; - 'ORC.26'?: string; - 'ORC.27'?: string; - 'ORC.28'?: string; - 'ORC.29'?: string; - 'ORC.30'?: string; - 'ORC.31'?: string; +export interface ORC { + "ORC.1"?: string; + "ORC.2"?: string; + "ORC.3"?: string; + "ORC.4"?: string; + "ORC.5"?: string; + "ORC.6"?: string; + "ORC.7"?: string; + "ORC.8"?: string; + "ORC.9"?: string; + "ORC.10"?: string; + "ORC.11"?: string; + "ORC.12"?: string; + "ORC.13"?: string; + "ORC.14"?: string; + "ORC.15"?: string; + "ORC.16"?: string; + "ORC.17"?: string; + "ORC.18"?: string; + "ORC.19"?: string; + "ORC.20"?: string; + "ORC.22"?: string; + "ORC.23"?: string; + "ORC.24"?: string; + "ORC.25"?: string; + "ORC.26"?: string; + "ORC.27"?: string; + "ORC.28"?: string; + "ORC.29"?: string; + "ORC.30"?: string; + "ORC.31"?: string; } diff --git a/types/hl7/segments/pid.segment.d.ts b/types/hl7/segments/pid.segment.d.ts index 5753b442395d55..1a0d6dac1706c5 100644 --- a/types/hl7/segments/pid.segment.d.ts +++ b/types/hl7/segments/pid.segment.d.ts @@ -5,100 +5,100 @@ * * [documentation](https://hl7-definition.caristix.com/v2/HL7v2.5.1/Segments/PID) */ - export interface PID { - 'PID.1'?: string; - 'PID.2'?: string; - 'PID.3'?: string[]; - 'PID.4'?: string; - 'PID.5': { +export interface PID { + "PID.1"?: string; + "PID.2"?: string; + "PID.3"?: string[]; + "PID.4"?: string; + "PID.5": { /** * Family Name */ - 'PID.5.1'?: string; + "PID.5.1"?: string; /** * Given Name */ - 'PID.5.2'?: string; + "PID.5.2"?: string; /** * Second And Further Given Names Or Initials Thereof */ - 'PID.5.3'?: string; + "PID.5.3"?: string; /** * Suffix */ - 'PID.5.4'?: string; + "PID.5.4"?: string; /** * Prefix */ - 'PID.5.5'?: string; + "PID.5.5"?: string; /** * Degree */ - 'PID.5.6'?: string; + "PID.5.6"?: string; /** * Name Type Code */ - 'PID.5.7'?: string; + "PID.5.7"?: string; /** * Name Representation Code */ - 'PID.5.8'?: string; + "PID.5.8"?: string; /** * Name Context */ - 'PID.5.9'?: string; + "PID.5.9"?: string; /** * Name Validity Range */ - 'PID.5.10'?: string; + "PID.5.10"?: string; /** * Name Assembly Order */ - 'PID.5.11'?: string; + "PID.5.11"?: string; /** * Effective Date */ - 'PID.5.12'?: string; + "PID.5.12"?: string; /** * Expiration Date */ - 'PID.5.13'?: string; + "PID.5.13"?: string; /** * Professional Suffix */ - 'PID.5.14'?: string; + "PID.5.14"?: string; }; - 'PID.6'?: string; - 'PID.7'?: string; - 'PID.8'?: string; - 'PID.9'?: string; - 'PID.10'?: string; - 'PID.11'?: string; - 'PID.12'?: string; - 'PID.13'?: string; - 'PID.14'?: string; - 'PID.15'?: string; - 'PID.16'?: string; - 'PID.17'?: string; - 'PID.18'?: string; - 'PID.19'?: string; - 'PID.20'?: string; - 'PID.22'?: string; - 'PID.23'?: string; - 'PID.24'?: string; - 'PID.25'?: string; - 'PID.26'?: string; - 'PID.27'?: string; - 'PID.28'?: string; - 'PID.29'?: string; - 'PID.30'?: string; - 'PID.31'?: string; - 'PID.32'?: string; - 'PID.33'?: string; - 'PID.34'?: string; - 'PID.35'?: string; - 'PID.36'?: string; - 'PID.37'?: string; - 'PID.38'?: string; - 'PID.39'?: string; + "PID.6"?: string; + "PID.7"?: string; + "PID.8"?: string; + "PID.9"?: string; + "PID.10"?: string; + "PID.11"?: string; + "PID.12"?: string; + "PID.13"?: string; + "PID.14"?: string; + "PID.15"?: string; + "PID.16"?: string; + "PID.17"?: string; + "PID.18"?: string; + "PID.19"?: string; + "PID.20"?: string; + "PID.22"?: string; + "PID.23"?: string; + "PID.24"?: string; + "PID.25"?: string; + "PID.26"?: string; + "PID.27"?: string; + "PID.28"?: string; + "PID.29"?: string; + "PID.30"?: string; + "PID.31"?: string; + "PID.32"?: string; + "PID.33"?: string; + "PID.34"?: string; + "PID.35"?: string; + "PID.36"?: string; + "PID.37"?: string; + "PID.38"?: string; + "PID.39"?: string; } diff --git a/types/hl7/segments/pv1.segment.d.ts b/types/hl7/segments/pv1.segment.d.ts index a1273c202f6345..1316c7c20fcbbb 100644 --- a/types/hl7/segments/pv1.segment.d.ts +++ b/types/hl7/segments/pv1.segment.d.ts @@ -8,54 +8,54 @@ */ export interface PV1 { - 'PV1.1': string; - 'PV1.2': string; - 'PV1.3': string; - 'PV1.4': string; - 'PV1.5': string; - 'PV1.6': string; - 'PV1.7': string; - 'PV1.8': string; - 'PV1.9': string; - 'PV1.10': string; - 'PV1.11': string; - 'PV1.12': string; - 'PV1.13': string; - 'PV1.14': string; - 'PV1.15': string; - 'PV1.16': string; - 'PV1.17': string; - 'PV1.18': string; - 'PV1.19': string; - 'PV1.20': string; - 'PV1.22': string; - 'PV1.23': string; - 'PV1.24': string; - 'PV1.25': string; - 'PV1.26': string; - 'PV1.27': string; - 'PV1.28': string; - 'PV1.29': string; - 'PV1.30': string; - 'PV1.31': string; - 'PV1.32': string; - 'PV1.33': string; - 'PV1.34': string; - 'PV1.35': string; - 'PV1.36': string; - 'PV1.37': string; - 'PV1.38': string; - 'PV1.40': string; - 'PV1.41': string; - 'PV1.42': string; - 'PV1.43': string; - 'PV1.44': string; - 'PV1.45': string; - 'PV1.46': string; - 'PV1.47': string; - 'PV1.48': string; - 'PV1.49': string; - 'PV1.50': string; - 'PV1.51': string; - 'PV1.52': string; + "PV1.1": string; + "PV1.2": string; + "PV1.3": string; + "PV1.4": string; + "PV1.5": string; + "PV1.6": string; + "PV1.7": string; + "PV1.8": string; + "PV1.9": string; + "PV1.10": string; + "PV1.11": string; + "PV1.12": string; + "PV1.13": string; + "PV1.14": string; + "PV1.15": string; + "PV1.16": string; + "PV1.17": string; + "PV1.18": string; + "PV1.19": string; + "PV1.20": string; + "PV1.22": string; + "PV1.23": string; + "PV1.24": string; + "PV1.25": string; + "PV1.26": string; + "PV1.27": string; + "PV1.28": string; + "PV1.29": string; + "PV1.30": string; + "PV1.31": string; + "PV1.32": string; + "PV1.33": string; + "PV1.34": string; + "PV1.35": string; + "PV1.36": string; + "PV1.37": string; + "PV1.38": string; + "PV1.40": string; + "PV1.41": string; + "PV1.42": string; + "PV1.43": string; + "PV1.44": string; + "PV1.45": string; + "PV1.46": string; + "PV1.47": string; + "PV1.48": string; + "PV1.49": string; + "PV1.50": string; + "PV1.51": string; + "PV1.52": string; } diff --git a/types/hls-parser/hls-parser-tests.ts b/types/hls-parser/hls-parser-tests.ts index 629fe268547cbc..66a2d6875a18af 100644 --- a/types/hls-parser/hls-parser-tests.ts +++ b/types/hls-parser/hls-parser-tests.ts @@ -1,6 +1,6 @@ -import HLS = require('hls-parser'); +import HLS = require("hls-parser"); -const playlist = HLS.parse(''); +const playlist = HLS.parse(""); if (playlist.isMasterPlaylist) { // Master playlist @@ -14,10 +14,10 @@ const { MediaPlaylist, MasterPlaylist, Segment, PrefetchSegment, PartialSegment, new MediaPlaylist({ targetDuration: 9, - playlistType: 'VOD', + playlistType: "VOD", segments: [ new Segment({ - uri: 'low/1.m3u8', + uri: "low/1.m3u8", duration: 9, mediaSequenceNumber: 0, discontinuitySequence: 0, @@ -28,12 +28,12 @@ new MediaPlaylist({ // open lhls new MediaPlaylist({ targetDuration: 9, - playlistType: 'VOD', + playlistType: "VOD", lowLatencyCompatibility: { canBlockReload: false, canSkipUntil: false, holdBack: 2, partHoldBack: 2 }, partTargetDuration: 0.333, segments: [ new Segment({ - uri: 'low/1.m3u8', + uri: "low/1.m3u8", duration: 9, mediaSequenceNumber: 0, discontinuitySequence: 0, @@ -41,7 +41,7 @@ new MediaPlaylist({ ], prefetchSegments: [ new PrefetchSegment({ - uri: 'test/1.m3u8', + uri: "test/1.m3u8", mediaSequenceNumber: 1, discontinuitySequence: 0, }), @@ -51,23 +51,23 @@ new MediaPlaylist({ // apple ll-hls new MediaPlaylist({ targetDuration: 9, - playlistType: 'VOD', + playlistType: "VOD", segments: [ new Segment({ - uri: 'low/1.m3u8', + uri: "low/1.m3u8", duration: 9, mediaSequenceNumber: 0, discontinuitySequence: 0, parts: [ new PartialSegment({ - uri: 'test/1.1.ts', + uri: "test/1.1.ts", }), ], }), ], renditionReports: [ new RenditionReport({ - uri: 'high/1.m3u8', + uri: "high/1.m3u8", }), ], }); diff --git a/types/hls-parser/index.d.ts b/types/hls-parser/index.d.ts index 1b94ec0098e95c..6cb2fff375c0f6 100644 --- a/types/hls-parser/index.d.ts +++ b/types/hls-parser/index.d.ts @@ -20,7 +20,7 @@ export interface Options { } export class Data { - type: 'playlist' | 'segment'; + type: "playlist" | "segment"; } export namespace types { @@ -88,7 +88,7 @@ export namespace types { endlist: boolean; - playlistType?: 'EVENT' | 'VOD' | undefined; + playlistType?: "EVENT" | "VOD" | undefined; isIFrame: boolean; @@ -110,7 +110,7 @@ export namespace types { mediaSequenceBase?: number | undefined; discontinuitySequenceBase?: number | undefined; endlist?: boolean | undefined; - playlistType?: 'EVENT' | 'VOD' | undefined; + playlistType?: "EVENT" | "VOD" | undefined; isIFrame?: boolean | undefined; segments?: readonly Segment[] | undefined; prefetchSegments?: readonly PrefetchSegment[] | undefined; @@ -140,13 +140,13 @@ export namespace types { hdcpLevel?: string | undefined; - audio: ReadonlyArray<Rendition<'AUDIO'>>; + audio: ReadonlyArray<Rendition<"AUDIO">>; - video: ReadonlyArray<Rendition<'VIDEO'>>; + video: ReadonlyArray<Rendition<"VIDEO">>; - subtitles: ReadonlyArray<Rendition<'SUBTITLES'>>; + subtitles: ReadonlyArray<Rendition<"SUBTITLES">>; - closedCaptions: ReadonlyArray<Rendition<'CLOSED-CAPTIONS'>>; + closedCaptions: ReadonlyArray<Rendition<"CLOSED-CAPTIONS">>; currentRenditions: { audio?: number | undefined; @@ -164,17 +164,17 @@ export namespace types { resolution?: { width: number; height: number } | undefined; frameRate?: number | undefined; hdcpLevel?: string | undefined; - audio?: ReadonlyArray<Rendition<'AUDIO'>> | undefined; - video?: ReadonlyArray<Rendition<'VIDEO'>> | undefined; - subtitles?: ReadonlyArray<Rendition<'SUBTITLES'>> | undefined; - closedCaptions?: ReadonlyArray<Rendition<'CLOSED-CAPTIONS'>> | undefined; + audio?: ReadonlyArray<Rendition<"AUDIO">> | undefined; + video?: ReadonlyArray<Rendition<"VIDEO">> | undefined; + subtitles?: ReadonlyArray<Rendition<"SUBTITLES">> | undefined; + closedCaptions?: ReadonlyArray<Rendition<"CLOSED-CAPTIONS">> | undefined; currentRenditions?: | { - audio?: number | undefined; - video?: number | undefined; - subtitles?: number | undefined; - closedCaptions?: number | undefined; - } + audio?: number | undefined; + video?: number | undefined; + subtitles?: number | undefined; + closedCaptions?: number | undefined; + } | undefined; }); } diff --git a/types/hmac-blake2b/hmac-blake2b-tests.ts b/types/hmac-blake2b/hmac-blake2b-tests.ts index 2ca06c943947d9..d3e7e3291c7d29 100644 --- a/types/hmac-blake2b/hmac-blake2b-tests.ts +++ b/types/hmac-blake2b/hmac-blake2b-tests.ts @@ -1,5 +1,5 @@ /// <reference types="node" /> -import hmac = require('hmac-blake2b'); +import hmac = require("hmac-blake2b"); hmac.BYTES; // $ExpectType 64 hmac.KEYBYTES; // $ExpectType 128 diff --git a/types/hmscore__react-native-hms-push/index.d.ts b/types/hmscore__react-native-hms-push/index.d.ts index d7cd31078613fb..1b2c2628a6037e 100644 --- a/types/hmscore__react-native-hms-push/index.d.ts +++ b/types/hmscore__react-native-hms-push/index.d.ts @@ -3,19 +3,19 @@ // Definitions by: Pedro Medeiros <https://github.com/despotes> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import { HmsPushEventType } from './src/HmsPushEvent'; -import { ResultResponse } from './src/ResultResponse'; -import { RemoteMessageBuilderInterface } from './src/RemoteMessageBuilder'; -import { LocalNotificationAttributes, Importance, RepeatType, Visibility, Priority } from './src/LocalNotification'; -import RNRemoteMessage from './src/RNRemoteMessage'; -import { ProfileType, ProfileTypeEnum } from './src/HmsPushProfileTypes'; -import { BackgroundRemoteMessage, RemoteDataMessageObject, RemoteDataMessageWithExtras } from './src/RemoteDataMessage'; -import { HmsPushResultCodeInterface } from './src/HmsPushResultCode'; +import { HmsPushEventType } from "./src/HmsPushEvent"; +import { ProfileType, ProfileTypeEnum } from "./src/HmsPushProfileTypes"; +import { HmsPushResultCodeInterface } from "./src/HmsPushResultCode"; +import { Importance, LocalNotificationAttributes, Priority, RepeatType, Visibility } from "./src/LocalNotification"; +import { BackgroundRemoteMessage, RemoteDataMessageObject, RemoteDataMessageWithExtras } from "./src/RemoteDataMessage"; +import { RemoteMessageBuilderInterface } from "./src/RemoteMessageBuilder"; +import { ResultResponse } from "./src/ResultResponse"; +import RNRemoteMessage from "./src/RNRemoteMessage"; export type LocalNotificationOptions = | { - [k in keyof LocalNotificationAttributes]?: unknown; - } + [k in keyof LocalNotificationAttributes]?: unknown; + } | { [extras: string]: unknown }; declare namespace HmsLocalNotification { @@ -92,22 +92,22 @@ declare const HmsPushEvent: HmsPushEventType; declare const HmsPushResultCode: HmsPushResultCodeInterface; export { - RNRemoteMessage, - HmsPushEvent, - RemoteMessageBuilder, HmsLocalNotification, + HmsPushEvent, HmsPushInstanceId, + HmsPushMessaging, HmsPushOpenDevice, HmsPushProfile, - HmsPushMessaging, HmsPushResultCode, + RemoteMessageBuilder, + RNRemoteMessage, }; export { - RemoteDataMessageObject, - RemoteDataMessageWithExtras, HmsPushEventType, HmsPushResultCodeInterface, + RemoteDataMessageObject, + RemoteDataMessageWithExtras, RemoteMessageBuilderInterface, }; diff --git a/types/hmscore__react-native-hms-push/src/HmsPushEvent.d.ts b/types/hmscore__react-native-hms-push/src/HmsPushEvent.d.ts index 6a9e06ce17c7c3..f8a904780970fb 100644 --- a/types/hmscore__react-native-hms-push/src/HmsPushEvent.d.ts +++ b/types/hmscore__react-native-hms-push/src/HmsPushEvent.d.ts @@ -1,18 +1,18 @@ -import { RemoteDataMessageObject, RemoteDataMessageWithExtras } from './RemoteDataMessage'; -import { NativeEventSubscription } from 'react-native'; -import { ResultResponse } from './ResultResponse'; +import { NativeEventSubscription } from "react-native"; +import { RemoteDataMessageObject, RemoteDataMessageWithExtras } from "./RemoteDataMessage"; +import { ResultResponse } from "./ResultResponse"; export interface HmsPushEvents { - REMOTE_DATA_MESSAGE_RECEIVED: 'REMOTE_DATA_MESSAGE_RECEIVED'; - ON_TOKEN_RECEIVED_EVENT: 'ON_TOKEN_RECEIVED_EVENT'; - ON_TOKEN_ERROR_EVENT: 'ON_TOKEN_ERROR_EVENT'; - NOTIFICATION_OPENED_EVENT: 'NOTIFICATION_OPENED_EVENT'; - LOCAL_NOTIFICATION_ACTION_EVENT: 'LOCAL_NOTIFICATION_ACTION_EVENT'; - ON_PUSH_MESSAGE_SENT: 'ON_PUSH_MESSAGE_SENT'; - ON_PUSH_MESSAGE_SENT_ERROR: 'ON_PUSH_MESSAGE_SENT_ERROR'; - ON_PUSH_MESSAGE_SENT_DELIVERED: 'ON_PUSH_MESSAGE_SENT_DELIVERED'; - ON_MULTI_SENDER_TOKEN_RECEIVED_EVENT: 'ON_MULTI_SENDER_TOKEN_RECEIVED_EVENT'; - ON_MULTI_SENDER_TOKEN_ERROR_EVENT: 'ON_MULTI_SENDER_TOKEN_ERROR_EVENT'; + REMOTE_DATA_MESSAGE_RECEIVED: "REMOTE_DATA_MESSAGE_RECEIVED"; + ON_TOKEN_RECEIVED_EVENT: "ON_TOKEN_RECEIVED_EVENT"; + ON_TOKEN_ERROR_EVENT: "ON_TOKEN_ERROR_EVENT"; + NOTIFICATION_OPENED_EVENT: "NOTIFICATION_OPENED_EVENT"; + LOCAL_NOTIFICATION_ACTION_EVENT: "LOCAL_NOTIFICATION_ACTION_EVENT"; + ON_PUSH_MESSAGE_SENT: "ON_PUSH_MESSAGE_SENT"; + ON_PUSH_MESSAGE_SENT_ERROR: "ON_PUSH_MESSAGE_SENT_ERROR"; + ON_PUSH_MESSAGE_SENT_DELIVERED: "ON_PUSH_MESSAGE_SENT_DELIVERED"; + ON_MULTI_SENDER_TOKEN_RECEIVED_EVENT: "ON_MULTI_SENDER_TOKEN_RECEIVED_EVENT"; + ON_MULTI_SENDER_TOKEN_ERROR_EVENT: "ON_MULTI_SENDER_TOKEN_ERROR_EVENT"; } export interface HmsPushEventListeners { diff --git a/types/hmscore__react-native-hms-push/src/HmsPushResultCode.d.ts b/types/hmscore__react-native-hms-push/src/HmsPushResultCode.d.ts index f07839527d736c..60a362fae77652 100644 --- a/types/hmscore__react-native-hms-push/src/HmsPushResultCode.d.ts +++ b/types/hmscore__react-native-hms-push/src/HmsPushResultCode.d.ts @@ -1,281 +1,281 @@ export interface HmsPushResultCodeInterface { // Success - SUCCESS: '0'; + SUCCESS: "0"; // Error - ERROR: '-1'; + ERROR: "-1"; // Bundle is null; exception - NULL_BUNDLE: '333'; + NULL_BUNDLE: "333"; // You do not have a token. Apply for a token. - ERROR_NO_TOKEN: '907122030'; + ERROR_NO_TOKEN: "907122030"; // The current network is unavailable. Check the network connection. - ERROR_NO_NETWORK: '907122031'; + ERROR_NO_NETWORK: "907122031"; // The token has expired. Delete the token and apply for a new one. - ERROR_TOKEN_INVALID: '907122032'; + ERROR_TOKEN_INVALID: "907122032"; // If the Push service is unavailable; contact Huawei technical support. - ERROR_SERVICE_NOT_AVAILABLE: '907122046'; + ERROR_SERVICE_NOT_AVAILABLE: "907122046"; // If the Push server returns an error; contact Huawei technical support. - ERROR_PUSH_SERVER: '907122047'; + ERROR_PUSH_SERVER: "907122047"; // Unknown error. Contact Huawei technical support. - ERROR_UNKNOWN: '907122045'; + ERROR_UNKNOWN: "907122045"; // The number of subscribed topics exceeds 2000. - ERROR_TOPIC_EXCEED: '907122034'; + ERROR_TOPIC_EXCEED: "907122034"; // Failed to send the subscription topic. Contact Huawei technical support. - ERROR_TOPIC_SEND: '907122035'; + ERROR_TOPIC_SEND: "907122035"; // Push rights are not enabled. Enable the service and set push service parameters at AppGallery Connect. - ERROR_NO_RIGHT: '907122036'; + ERROR_NO_RIGHT: "907122036"; // Failed to apply for the token. Contact Huawei technical support. - ERROR_GET_TOKEN_ERR: '907122037'; + ERROR_GET_TOKEN_ERR: "907122037"; // No storage location is selected for the application or the storage location is invalid. - ERROR_STORAGE_LOCATION_EMPTY: '907122038'; + ERROR_STORAGE_LOCATION_EMPTY: "907122038"; // Failed to apply for a token. Cross-region token application is not allowed. - ERROR_NOT_ALLOW_CROSS_APPLY: '907122053'; + ERROR_NOT_ALLOW_CROSS_APPLY: "907122053"; // The message body size exceeds the maximum. - ERROR_SIZE: '907122041'; + ERROR_SIZE: "907122041"; // The message contains invalid parameters. - ERROR_INVALID_PARAMETERS: '907122042'; + ERROR_INVALID_PARAMETERS: "907122042"; // The number of sent messages reaches the upper limit. The messages will be discarded. - ERROR_TOO_MANY_MESSAGES: '907122043'; + ERROR_TOO_MANY_MESSAGES: "907122043"; // The message lifetime expires before the message is successfully sent to the APP server. - ERROR_TTL_EXCEEDED: '907122044'; + ERROR_TTL_EXCEEDED: "907122044"; // Huawei Mobile Services (APK) can't connect Huawei Push Kit. - ERROR_HMS_CLIENT_API: '907122048'; + ERROR_HMS_CLIENT_API: "907122048"; // The current EMUI version is too early to use the capability. - ERROR_OPERATION_NOT_SUPPORTED: '907122049'; + ERROR_OPERATION_NOT_SUPPORTED: "907122049"; // The operation cannot be performed in the main thread. - ERROR_MAIN_THREAD: '907122050'; + ERROR_MAIN_THREAD: "907122050"; // The device certificate authentication fails. - ERROR_HMS_DEVICE_AUTH_FAILED_SELF_MAPPING: '907122051'; + ERROR_HMS_DEVICE_AUTH_FAILED_SELF_MAPPING: "907122051"; // Failed to bind the service. - ERROR_BIND_SERVICE_SELF_MAPPING: '907122052'; + ERROR_BIND_SERVICE_SELF_MAPPING: "907122052"; // The SDK is being automatically initialized. Try again later. - ERROR_AUTO_INITIALIZING: '907122054'; + ERROR_AUTO_INITIALIZING: "907122054"; /*The input parameter is incorrect. Check whether the related configuration information is correct. * Example =app_id in the agconnect - services.json file; * Check whether the build.gradle file is configured with the certificate signature. */ - ERROR_ARGUMENTS_INVALID: '907135000'; + ERROR_ARGUMENTS_INVALID: "907135000"; // Internal Push error. Contact Huawei technical support engineers. - ERROR_INTERNAL_ERROR: '907135001'; + ERROR_INTERNAL_ERROR: "907135001"; // The service does not exist. The invoked interface does not exist. - ERROR_NAMING_INVALID: '907135002'; + ERROR_NAMING_INVALID: "907135002"; // The ApiClient object is invalid. - ERROR_CLIENT_API_INVALID: '907135003'; + ERROR_CLIENT_API_INVALID: "907135003"; // Invoking AIDL times out. Contact Huawei technical support. - ERROR_EXECUTE_TIMEOUT: '907135004'; + ERROR_EXECUTE_TIMEOUT: "907135004"; // The current area does not support this service. - ERROR_NOT_IN_SERVICE: '907135005'; + ERROR_NOT_IN_SERVICE: "907135005"; // If the AIDL connection session is invalid; contact Huawei technical support. - ERROR_SESSION_INVALID: '907135006'; + ERROR_SESSION_INVALID: "907135006"; // An error occurred when invoking an unspecified API. - ERROR_API_NOT_SPECIFIED: '1002'; + ERROR_API_NOT_SPECIFIED: "1002"; /* Failed to invoke the gateway to query the application scope. * Check whether the current app has been created and enabled in AppGallery Connect. * If yes; contact Huawei technical support. */ - ERROR_GET_SCOPE_ERROR: '907135700'; + ERROR_GET_SCOPE_ERROR: "907135700"; /* Scope is not configured on the AppGallery Connect. * Check whether the current app has been created and enabled in AppGallery Connect. * If yes; contact Huawei technical support. */ - ERROR_SCOPE_LIST_EMPTY: '907135701'; + ERROR_SCOPE_LIST_EMPTY: "907135701"; /* The certificate fingerprint is not configured on the AppGallery Connect. * 1. Check whether your phone can access the Internet. * 2. Check whether the correct certificate fingerprint is configured in AppGallery Connect. For details; see AppGallery Connect configuration in Development Preparations. * 3. If the check result is correct; contact Huawei technical support. */ - ERROR_CERT_FINGERPRINT_EMPTY: '907135702'; + ERROR_CERT_FINGERPRINT_EMPTY: "907135702"; // Permission is not configured on the AppGallery Connect. - ERROR_PERMISSION_LIST_EMPTY: '907135703'; + ERROR_PERMISSION_LIST_EMPTY: "907135703"; // The authentication information of the application does not exist. - ERROR_AUTH_INFO_NOT_EXIST: '6002'; + ERROR_AUTH_INFO_NOT_EXIST: "6002"; // An error occurred during certificate fingerprint verification. // Check whether the correct certificate fingerprint is configured in AppGallery Connect. For details; see AppGallery Connect configuration in Development Preparations. - ERROR_CERT_FINGERPRINT_ERROR: '6003'; + ERROR_CERT_FINGERPRINT_ERROR: "6003"; // Interface authentication =The permission does not exist and is not applied for in AppGallery Connect. - ERROR_PERMISSION_NOT_EXIST: '6004'; + ERROR_PERMISSION_NOT_EXIST: "6004"; // Interface authentication =unauthorized. - ERROR_PERMISSION_NOT_AUTHORIZED: '6005'; + ERROR_PERMISSION_NOT_AUTHORIZED: "6005"; // Interface authentication =The authorization expires. - ERROR_PERMISSION_EXPIRED: '6006'; + ERROR_PERMISSION_EXPIRED: "6006"; } export enum HmsPushResultCodeEnum { // Success - SUCCESS = '0', + SUCCESS = "0", // Error - ERROR = '-1', + ERROR = "-1", // Bundle is null, exception - NULL_BUNDLE = '333', + NULL_BUNDLE = "333", // You do not have a token. Apply for a token. - ERROR_NO_TOKEN = '907122030', + ERROR_NO_TOKEN = "907122030", // The current network is unavailable. Check the network connection. - ERROR_NO_NETWORK = '907122031', + ERROR_NO_NETWORK = "907122031", // The token has expired. Delete the token and apply for a new one. - ERROR_TOKEN_INVALID = '907122032', + ERROR_TOKEN_INVALID = "907122032", // If the Push service is unavailable, contact Huawei technical support. - ERROR_SERVICE_NOT_AVAILABLE = '907122046', + ERROR_SERVICE_NOT_AVAILABLE = "907122046", // If the Push server returns an error, contact Huawei technical support. - ERROR_PUSH_SERVER = '907122047', + ERROR_PUSH_SERVER = "907122047", // Unknown error. Contact Huawei technical support. - ERROR_UNKNOWN = '907122045', + ERROR_UNKNOWN = "907122045", // The number of subscribed topics exceeds 2000. - ERROR_TOPIC_EXCEED = '907122034', + ERROR_TOPIC_EXCEED = "907122034", // Failed to send the subscription topic. Contact Huawei technical support. - ERROR_TOPIC_SEND = '907122035', + ERROR_TOPIC_SEND = "907122035", // Push rights are not enabled. Enable the service and set push service parameters at AppGallery Connect. - ERROR_NO_RIGHT = '907122036', + ERROR_NO_RIGHT = "907122036", // Failed to apply for the token. Contact Huawei technical support. - ERROR_GET_TOKEN_ERR = '907122037', + ERROR_GET_TOKEN_ERR = "907122037", // No storage location is selected for the application or the storage location is invalid. - ERROR_STORAGE_LOCATION_EMPTY = '907122038', + ERROR_STORAGE_LOCATION_EMPTY = "907122038", // Failed to apply for a token. Cross-region token application is not allowed. - ERROR_NOT_ALLOW_CROSS_APPLY = '907122053', + ERROR_NOT_ALLOW_CROSS_APPLY = "907122053", // The message body size exceeds the maximum. - ERROR_SIZE = '907122041', + ERROR_SIZE = "907122041", // The message contains invalid parameters. - ERROR_INVALID_PARAMETERS = '907122042', + ERROR_INVALID_PARAMETERS = "907122042", // The number of sent messages reaches the upper limit. The messages will be discarded. - ERROR_TOO_MANY_MESSAGES = '907122043', + ERROR_TOO_MANY_MESSAGES = "907122043", // The message lifetime expires before the message is successfully sent to the APP server. - ERROR_TTL_EXCEEDED = '907122044', + ERROR_TTL_EXCEEDED = "907122044", // Huawei Mobile Services (APK) can't connect Huawei Push Kit. - ERROR_HMS_CLIENT_API = '907122048', + ERROR_HMS_CLIENT_API = "907122048", // The current EMUI version is too early to use the capability. - ERROR_OPERATION_NOT_SUPPORTED = '907122049', + ERROR_OPERATION_NOT_SUPPORTED = "907122049", // The operation cannot be performed in the main thread. - ERROR_MAIN_THREAD = '907122050', + ERROR_MAIN_THREAD = "907122050", // The device certificate authentication fails. - ERROR_HMS_DEVICE_AUTH_FAILED_SELF_MAPPING = '907122051', + ERROR_HMS_DEVICE_AUTH_FAILED_SELF_MAPPING = "907122051", // Failed to bind the service. - ERROR_BIND_SERVICE_SELF_MAPPING = '907122052', + ERROR_BIND_SERVICE_SELF_MAPPING = "907122052", // The SDK is being automatically initialized. Try again later. - ERROR_AUTO_INITIALIZING = '907122054', + ERROR_AUTO_INITIALIZING = "907122054", /*The input parameter is incorrect. Check whether the related configuration information is correct. * Example =app_id in the agconnect - services.json file, * Check whether the build.gradle file is configured with the certificate signature. */ - ERROR_ARGUMENTS_INVALID = '907135000', + ERROR_ARGUMENTS_INVALID = "907135000", // Internal Push error. Contact Huawei technical support engineers. - ERROR_INTERNAL_ERROR = '907135001', + ERROR_INTERNAL_ERROR = "907135001", // The service does not exist. The invoked interface does not exist. - ERROR_NAMING_INVALID = '907135002', + ERROR_NAMING_INVALID = "907135002", // The ApiClient object is invalid. - ERROR_CLIENT_API_INVALID = '907135003', + ERROR_CLIENT_API_INVALID = "907135003", // Invoking AIDL times out. Contact Huawei technical support. - ERROR_EXECUTE_TIMEOUT = '907135004', + ERROR_EXECUTE_TIMEOUT = "907135004", // The current area does not support this service. - ERROR_NOT_IN_SERVICE = '907135005', + ERROR_NOT_IN_SERVICE = "907135005", // If the AIDL connection session is invalid, contact Huawei technical support. - ERROR_SESSION_INVALID = '907135006', + ERROR_SESSION_INVALID = "907135006", // An error occurred when invoking an unspecified API. - ERROR_API_NOT_SPECIFIED = '1002', + ERROR_API_NOT_SPECIFIED = "1002", /* Failed to invoke the gateway to query the application scope. * Check whether the current app has been created and enabled in AppGallery Connect. * If yes, contact Huawei technical support. */ - ERROR_GET_SCOPE_ERROR = '907135700', + ERROR_GET_SCOPE_ERROR = "907135700", /* Scope is not configured on the AppGallery Connect. * Check whether the current app has been created and enabled in AppGallery Connect. * If yes, contact Huawei technical support. */ - ERROR_SCOPE_LIST_EMPTY = '907135701', + ERROR_SCOPE_LIST_EMPTY = "907135701", /* The certificate fingerprint is not configured on the AppGallery Connect. * 1. Check whether your phone can access the Internet. * 2. Check whether the correct certificate fingerprint is configured in AppGallery Connect. For details, see AppGallery Connect configuration in Development Preparations. * 3. If the check result is correct, contact Huawei technical support. */ - ERROR_CERT_FINGERPRINT_EMPTY = '907135702', + ERROR_CERT_FINGERPRINT_EMPTY = "907135702", // Permission is not configured on the AppGallery Connect. - ERROR_PERMISSION_LIST_EMPTY = '907135703', + ERROR_PERMISSION_LIST_EMPTY = "907135703", // The authentication information of the application does not exist. - ERROR_AUTH_INFO_NOT_EXIST = '6002', + ERROR_AUTH_INFO_NOT_EXIST = "6002", // An error occurred during certificate fingerprint verification. // Check whether the correct certificate fingerprint is configured in AppGallery Connect. For details, see AppGallery Connect configuration in Development Preparations. - ERROR_CERT_FINGERPRINT_ERROR = '6003', + ERROR_CERT_FINGERPRINT_ERROR = "6003", // Interface authentication =The permission does not exist and is not applied for in AppGallery Connect. - ERROR_PERMISSION_NOT_EXIST = '6004', + ERROR_PERMISSION_NOT_EXIST = "6004", // Interface authentication =unauthorized. - ERROR_PERMISSION_NOT_AUTHORIZED = '6005', + ERROR_PERMISSION_NOT_AUTHORIZED = "6005", // Interface authentication =The authorization expires. - ERROR_PERMISSION_EXPIRED = '6006', + ERROR_PERMISSION_EXPIRED = "6006", } diff --git a/types/hmscore__react-native-hms-push/src/LocalNotification/Importance.d.ts b/types/hmscore__react-native-hms-push/src/LocalNotification/Importance.d.ts index 644c6b641c9c6a..6485fb0d852e01 100644 --- a/types/hmscore__react-native-hms-push/src/LocalNotification/Importance.d.ts +++ b/types/hmscore__react-native-hms-push/src/LocalNotification/Importance.d.ts @@ -1,9 +1,9 @@ export interface Importance { - max: 'max'; - high: 'high'; - default: 'default'; - low: 'low'; - min: 'min'; - none: 'none'; - unspecified: 'unspecified'; + max: "max"; + high: "high"; + default: "default"; + low: "low"; + min: "min"; + none: "none"; + unspecified: "unspecified"; } diff --git a/types/hmscore__react-native-hms-push/src/LocalNotification/LocalNotificationAttributes.d.ts b/types/hmscore__react-native-hms-push/src/LocalNotification/LocalNotificationAttributes.d.ts index ada8efd287b638..fa32588c7fc22c 100644 --- a/types/hmscore__react-native-hms-push/src/LocalNotification/LocalNotificationAttributes.d.ts +++ b/types/hmscore__react-native-hms-push/src/LocalNotification/LocalNotificationAttributes.d.ts @@ -1,38 +1,38 @@ export interface LocalNotificationAttributes { - id: 'id'; - message: 'message'; - fireDate: 'fireDate'; - title: 'title'; - ticker: 'ticker'; - showWhen: 'showWhen'; - autoCancel: 'autoCancel'; - largeIcon: 'largeIcon'; - largeIconUrl: 'largeIconUrl'; - smallIcon: 'smallIcon'; - bigText: 'bigText'; - subText: 'subText'; - bigPictureUrl: 'bigPictureUrl'; - shortcutId: 'shortcutId'; - number: 'number'; - channelId: 'channelId'; - channelName: 'channelName'; - channelDescription: 'channelDescription'; - color: 'color'; - group: 'group'; - groupSummary: 'groupSummary'; - playSound: 'playSound'; - soundName: 'soundName'; - vibrate: 'vibrate'; - vibrateDuration: 'vibrateDuration'; - actions: 'actions'; - invokeApp: 'invokeApp'; - tag: 'tag'; - repeatType: 'repeatType'; - repeatTime: 'repeatTime'; - ongoing: 'ongoing'; - allowWhileIdle: 'allowWhileIdle'; - dontNotifyInForeground: 'dontNotifyInForeground'; - priority: 'priority'; - importance: 'importance'; - visibility: 'visibility'; + id: "id"; + message: "message"; + fireDate: "fireDate"; + title: "title"; + ticker: "ticker"; + showWhen: "showWhen"; + autoCancel: "autoCancel"; + largeIcon: "largeIcon"; + largeIconUrl: "largeIconUrl"; + smallIcon: "smallIcon"; + bigText: "bigText"; + subText: "subText"; + bigPictureUrl: "bigPictureUrl"; + shortcutId: "shortcutId"; + number: "number"; + channelId: "channelId"; + channelName: "channelName"; + channelDescription: "channelDescription"; + color: "color"; + group: "group"; + groupSummary: "groupSummary"; + playSound: "playSound"; + soundName: "soundName"; + vibrate: "vibrate"; + vibrateDuration: "vibrateDuration"; + actions: "actions"; + invokeApp: "invokeApp"; + tag: "tag"; + repeatType: "repeatType"; + repeatTime: "repeatTime"; + ongoing: "ongoing"; + allowWhileIdle: "allowWhileIdle"; + dontNotifyInForeground: "dontNotifyInForeground"; + priority: "priority"; + importance: "importance"; + visibility: "visibility"; } diff --git a/types/hmscore__react-native-hms-push/src/LocalNotification/Priority.d.ts b/types/hmscore__react-native-hms-push/src/LocalNotification/Priority.d.ts index 39121df50acb0c..f1c3f9a0adef26 100644 --- a/types/hmscore__react-native-hms-push/src/LocalNotification/Priority.d.ts +++ b/types/hmscore__react-native-hms-push/src/LocalNotification/Priority.d.ts @@ -1,7 +1,7 @@ export interface Priority { - max: 'max'; - high: 'high'; - default: 'default'; - low: 'low'; - min: 'min'; + max: "max"; + high: "high"; + default: "default"; + low: "low"; + min: "min"; } diff --git a/types/hmscore__react-native-hms-push/src/LocalNotification/RepeatType.d.ts b/types/hmscore__react-native-hms-push/src/LocalNotification/RepeatType.d.ts index 57baac44f45c2e..a60862d38b6067 100644 --- a/types/hmscore__react-native-hms-push/src/LocalNotification/RepeatType.d.ts +++ b/types/hmscore__react-native-hms-push/src/LocalNotification/RepeatType.d.ts @@ -1,7 +1,7 @@ export interface RepeatType { - hour: 'hour'; - minute: 'minute'; - day: 'day'; - week: 'week'; - customTime: 'custom_time'; + hour: "hour"; + minute: "minute"; + day: "day"; + week: "week"; + customTime: "custom_time"; } diff --git a/types/hmscore__react-native-hms-push/src/LocalNotification/Visibility.d.ts b/types/hmscore__react-native-hms-push/src/LocalNotification/Visibility.d.ts index fdf87170ae3444..22a10afed2adc1 100644 --- a/types/hmscore__react-native-hms-push/src/LocalNotification/Visibility.d.ts +++ b/types/hmscore__react-native-hms-push/src/LocalNotification/Visibility.d.ts @@ -1,5 +1,5 @@ export interface Visibility { - public: 'public'; - secret: 'secret'; - private: 'private'; + public: "public"; + secret: "secret"; + private: "private"; } diff --git a/types/hmscore__react-native-hms-push/src/LocalNotification/index.d.ts b/types/hmscore__react-native-hms-push/src/LocalNotification/index.d.ts index 65bd0e019240d9..a82538c2462587 100644 --- a/types/hmscore__react-native-hms-push/src/LocalNotification/index.d.ts +++ b/types/hmscore__react-native-hms-push/src/LocalNotification/index.d.ts @@ -1,5 +1,5 @@ -export { LocalNotificationAttributes } from './LocalNotificationAttributes'; -export { Importance } from './Importance'; -export { Visibility } from './Visibility'; -export { Priority } from './Priority'; -export { RepeatType } from './RepeatType'; +export { Importance } from "./Importance"; +export { LocalNotificationAttributes } from "./LocalNotificationAttributes"; +export { Priority } from "./Priority"; +export { RepeatType } from "./RepeatType"; +export { Visibility } from "./Visibility"; diff --git a/types/hmscore__react-native-hms-push/src/RNRemoteMessage.d.ts b/types/hmscore__react-native-hms-push/src/RNRemoteMessage.d.ts index 8fffa355555eed..a5f0d2f8828ac6 100644 --- a/types/hmscore__react-native-hms-push/src/RNRemoteMessage.d.ts +++ b/types/hmscore__react-native-hms-push/src/RNRemoteMessage.d.ts @@ -1,59 +1,59 @@ -import { RemoteDataMessageObject } from './RemoteDataMessage'; +import { RemoteDataMessageObject } from "./RemoteDataMessage"; export default class RNRemoteMessage { - static INSTANCE_ID_SCOPE: 'HCM'; + static INSTANCE_ID_SCOPE: "HCM"; static PRIORITY_UNKNOWN: 0; static PRIORITY_HIG: 1; static PRIORITY_NORMAL: 2; - static COLLAPSEKEY: 'collapseKey'; - static DATA: 'data'; - static DATAOFMAP: 'dataOfMap'; - static MESSAGEID: 'messageId'; - static MESSAGETYPE: 'messageType'; - static ORIGINALURGENCY: 'originalUrgency'; - static URGENCY: 'urgency'; - static TTL: 'ttl'; - static SENTTIME: 'sentTime'; - static TO: 'to'; - static FROM: 'from'; - static TOKEN: 'token'; - static ANALYTIC_INFO: 'analyticInfo'; - static ANALYTIC_INFO_MAP: 'analyticInfoMap'; + static COLLAPSEKEY: "collapseKey"; + static DATA: "data"; + static DATAOFMAP: "dataOfMap"; + static MESSAGEID: "messageId"; + static MESSAGETYPE: "messageType"; + static ORIGINALURGENCY: "originalUrgency"; + static URGENCY: "urgency"; + static TTL: "ttl"; + static SENTTIME: "sentTime"; + static TO: "to"; + static FROM: "from"; + static TOKEN: "token"; + static ANALYTIC_INFO: "analyticInfo"; + static ANALYTIC_INFO_MAP: "analyticInfoMap"; static NOTIFICATION: { - TITLE: 'title'; - TITLELOCALIZATIONKEY: 'titleLocalizationKey'; - TITLELOCALIZATIONARGS: 'titleLocalizationArgs'; - BODYLOCALIZATIONKEY: 'bodyLocalizationKey'; - BODYLOCALIZATIONARGS: 'bodyLocalizationArgs'; - BODY: 'body'; - ICON: 'icon'; - SOUND: 'Sound'; - TAG: 'Tag'; - COLOR: 'Color'; - CLICKACTION: 'ClickAction'; - CHANNELID: 'ChannelId'; - IMAGEURL: 'ImageUrl'; - LINK: 'Link'; - NOTIFYID: 'NotifyId'; - WHEN: 'When'; - LIGHTSETTINGS: 'LightSettings'; - BADGENUMBER: 'BadgeNumber'; - IMPORTANCE: 'Importance'; - TICKER: 'Ticker'; - VIBRATECONFIG: 'vibrateConfig'; - VISIBILITY: 'visibility'; - INTENTURI: 'intentUri'; - ISAUTOCANCEL: 'isAutoCancel'; - ISLOCALONLY: 'isLocalOnly'; - ISDEFAULTLIGHT: 'isDefaultLight'; - ISDEFAULTSOUND: 'isDefaultSound'; - ISDEFAULTVIBRATE: 'isDefaultVibrate'; + TITLE: "title"; + TITLELOCALIZATIONKEY: "titleLocalizationKey"; + TITLELOCALIZATIONARGS: "titleLocalizationArgs"; + BODYLOCALIZATIONKEY: "bodyLocalizationKey"; + BODYLOCALIZATIONARGS: "bodyLocalizationArgs"; + BODY: "body"; + ICON: "icon"; + SOUND: "Sound"; + TAG: "Tag"; + COLOR: "Color"; + CLICKACTION: "ClickAction"; + CHANNELID: "ChannelId"; + IMAGEURL: "ImageUrl"; + LINK: "Link"; + NOTIFYID: "NotifyId"; + WHEN: "When"; + LIGHTSETTINGS: "LightSettings"; + BADGENUMBER: "BadgeNumber"; + IMPORTANCE: "Importance"; + TICKER: "Ticker"; + VIBRATECONFIG: "vibrateConfig"; + VISIBILITY: "visibility"; + INTENTURI: "intentUri"; + ISAUTOCANCEL: "isAutoCancel"; + ISLOCALONLY: "isLocalOnly"; + ISDEFAULTLIGHT: "isDefaultLight"; + ISDEFAULTSOUND: "isDefaultSound"; + ISDEFAULTVIBRATE: "isDefaultVibrate"; }; - constructor(options: RemoteDataMessageObject['msg']); + constructor(options: RemoteDataMessageObject["msg"]); parseMsgAllAttribute(): string; getCollapseKey(): string; diff --git a/types/hmscore__react-native-hms-push/src/RemoteDataMessage.d.ts b/types/hmscore__react-native-hms-push/src/RemoteDataMessage.d.ts index 844b4880699ef3..9a2a14fbb4f4d2 100644 --- a/types/hmscore__react-native-hms-push/src/RemoteDataMessage.d.ts +++ b/types/hmscore__react-native-hms-push/src/RemoteDataMessage.d.ts @@ -61,7 +61,7 @@ export interface RemoteDataMessageWithExtras { [x: string]: any; }; }; - remoteMessage: RemoteDataMessageObject['msg']; + remoteMessage: RemoteDataMessageObject["msg"]; } -export type BackgroundRemoteMessage = RemoteDataMessageObject['msg']; +export type BackgroundRemoteMessage = RemoteDataMessageObject["msg"]; diff --git a/types/hmscore__react-native-hms-push/src/RemoteMessageBuilder.d.ts b/types/hmscore__react-native-hms-push/src/RemoteMessageBuilder.d.ts index a89eca89cbc8bf..9c210d6889ec9c 100644 --- a/types/hmscore__react-native-hms-push/src/RemoteMessageBuilder.d.ts +++ b/types/hmscore__react-native-hms-push/src/RemoteMessageBuilder.d.ts @@ -1,10 +1,10 @@ export interface RemoteMessageBuilderInterface { - TO: 'to'; - MESSAGE_ID: 'messageId'; - MESSAGE_TYPE: 'messageType'; - TTL: 'ttl'; - COLLAPSE_KEY: 'collapseKey'; - RECEIPT_MODE: 'receiptMode'; - SEND_MODE: 'sendMode'; - DATA: 'data'; + TO: "to"; + MESSAGE_ID: "messageId"; + MESSAGE_TYPE: "messageType"; + TTL: "ttl"; + COLLAPSE_KEY: "collapseKey"; + RECEIPT_MODE: "receiptMode"; + SEND_MODE: "sendMode"; + DATA: "data"; } diff --git a/types/hmscore__react-native-hms-push/src/ResultResponse.d.ts b/types/hmscore__react-native-hms-push/src/ResultResponse.d.ts index bbaad6b502d006..c60125e32543d6 100644 --- a/types/hmscore__react-native-hms-push/src/ResultResponse.d.ts +++ b/types/hmscore__react-native-hms-push/src/ResultResponse.d.ts @@ -1,4 +1,4 @@ -import { HmsPushResultCodeEnum } from './HmsPushResultCode'; +import { HmsPushResultCodeEnum } from "./HmsPushResultCode"; export interface ResultResponse<T> { result: T; diff --git a/types/hmscore__react-native-hms-push/test/backgroundHandler-test.tsx b/types/hmscore__react-native-hms-push/test/backgroundHandler-test.tsx index ac93092e104a60..727a279a5469a1 100644 --- a/types/hmscore__react-native-hms-push/test/backgroundHandler-test.tsx +++ b/types/hmscore__react-native-hms-push/test/backgroundHandler-test.tsx @@ -14,22 +14,22 @@ limitations under the License. */ -import { HmsPushMessaging, RNRemoteMessage, HmsLocalNotification, HmsPushEvent } from '@hmscore/react-native-hms-push'; +import { HmsLocalNotification, HmsPushEvent, HmsPushMessaging, RNRemoteMessage } from "@hmscore/react-native-hms-push"; HmsPushEvent.onNotificationOpenedApp(result => { - console.log('onNotificationOpenedApp', result); + console.log("onNotificationOpenedApp", result); }); HmsPushMessaging.setBackgroundMessageHandler(dataMessage => { HmsLocalNotification.localNotification({ - [HmsLocalNotification.Attr.title]: '[Headless] DataMessage Received', + [HmsLocalNotification.Attr.title]: "[Headless] DataMessage Received", [HmsLocalNotification.Attr.message]: new RNRemoteMessage(dataMessage).getDataOfMap(), // $ExpectType string }) .then(result => { - console.log('[Headless] DataMessage Received', result); + console.log("[Headless] DataMessage Received", result); }) .catch(err => { - console.log('[LocalNotification Default] Error/Exception: ' + JSON.stringify(err)); + console.log("[LocalNotification Default] Error/Exception: " + JSON.stringify(err)); }); return Promise.resolve(); diff --git a/types/hmscore__react-native-hms-push/test/localnotification-test.tsx b/types/hmscore__react-native-hms-push/test/localnotification-test.tsx index 9e24293835a221..4010819138c26a 100644 --- a/types/hmscore__react-native-hms-push/test/localnotification-test.tsx +++ b/types/hmscore__react-native-hms-push/test/localnotification-test.tsx @@ -14,31 +14,31 @@ limitations under the License. */ -import * as React from 'react'; -import { View, TouchableOpacity, Text, ScrollView, TextInput } from 'react-native'; +import * as React from "react"; +import { ScrollView, Text, TextInput, TouchableOpacity, View } from "react-native"; -import { HmsLocalNotification } from '@hmscore/react-native-hms-push'; +import { HmsLocalNotification } from "@hmscore/react-native-hms-push"; const defaultNotification = { - [HmsLocalNotification.Attr.title]: 'Notification Title', - [HmsLocalNotification.Attr.message]: 'Notification Message', // (required) - [HmsLocalNotification.Attr.ticker]: 'Optional Ticker', + [HmsLocalNotification.Attr.title]: "Notification Title", + [HmsLocalNotification.Attr.message]: "Notification Message", // (required) + [HmsLocalNotification.Attr.ticker]: "Optional Ticker", [HmsLocalNotification.Attr.showWhen]: true, // [HmsLocalNotification.Attr.largeIconUrl]: 'https://developer.huawei.com/Enexport/sites/default/images/en/Develop/hms/push/push2-tuidedao.png', // - [HmsLocalNotification.Attr.largeIcon]: 'ic_launcher', - [HmsLocalNotification.Attr.smallIcon]: 'ic_notification', - [HmsLocalNotification.Attr.bigText]: 'This is a bigText', - [HmsLocalNotification.Attr.subText]: 'This is a subText', - [HmsLocalNotification.Attr.color]: 'white', + [HmsLocalNotification.Attr.largeIcon]: "ic_launcher", + [HmsLocalNotification.Attr.smallIcon]: "ic_notification", + [HmsLocalNotification.Attr.bigText]: "This is a bigText", + [HmsLocalNotification.Attr.subText]: "This is a subText", + [HmsLocalNotification.Attr.color]: "white", [HmsLocalNotification.Attr.vibrate]: false, [HmsLocalNotification.Attr.vibrateDuration]: 1000, - [HmsLocalNotification.Attr.tag]: 'hms_tag', + [HmsLocalNotification.Attr.tag]: "hms_tag", [HmsLocalNotification.Attr.groupSummary]: false, [HmsLocalNotification.Attr.ongoing]: false, [HmsLocalNotification.Attr.importance]: HmsLocalNotification.Importance.max, [HmsLocalNotification.Attr.dontNotifyInForeground]: false, [HmsLocalNotification.Attr.autoCancel]: false, // for Custom Actions, it should be false - [HmsLocalNotification.Attr.actions]: '["Yes", "No"]', + [HmsLocalNotification.Attr.actions]: "[\"Yes\", \"No\"]", [HmsLocalNotification.Attr.invokeApp]: false, // [HmsLocalNotification.Attr.channelId]: 'huawei-hms-rn-push-channel-id', // Please read the documentation before using this param }; @@ -57,10 +57,10 @@ export default class App extends React.Component<{}, State> { super(props); this.state = { - title: 'HMS Push', - message: 'This is Local Notification', - bigText: 'This is a bigText', - subText: 'This is a subText', + title: "HMS Push", + message: "This is Local Notification", + bigText: "This is a bigText", + subText: "This is a subText", tag: undefined, }; } @@ -83,10 +83,10 @@ export default class App extends React.Component<{}, State> { [HmsLocalNotification.Attr.allowWhileIdle]: true, }) .then(result => { - console.log('LocalNotification Scheduled', result); + console.log("LocalNotification Scheduled", result); }) .catch(err => { - console.log('[LocalNotification Scheduled] Error/Exception: ' + JSON.stringify(err)); + console.log("[LocalNotification Scheduled] Error/Exception: " + JSON.stringify(err)); }); } @@ -100,10 +100,10 @@ export default class App extends React.Component<{}, State> { [HmsLocalNotification.Attr.tag]: this.state.tag, }) .then(result => { - console.log('LocalNotification Default', result); + console.log("LocalNotification Default", result); }) .catch(err => { - console.log('[LocalNotification Default] Error/Exception: ' + JSON.stringify(err)); + console.log("[LocalNotification Default] Error/Exception: " + JSON.stringify(err)); }); } @@ -119,10 +119,10 @@ export default class App extends React.Component<{}, State> { [HmsLocalNotification.Attr.vibrateDuration]: 5000, }) .then(result => { - console.log('LocalNotification Vibrate', result); + console.log("LocalNotification Vibrate", result); }) .catch(err => { - console.log('[LocalNotification Vibrate] Error/Exception: ' + JSON.stringify(err)); + console.log("[LocalNotification Vibrate] Error/Exception: " + JSON.stringify(err)); }); } @@ -137,10 +137,10 @@ export default class App extends React.Component<{}, State> { [HmsLocalNotification.Attr.repeatType]: HmsLocalNotification.RepeatType.minute, }) .then(result => { - console.log('LocalNotification Repeat', result); + console.log("LocalNotification Repeat", result); }) .catch(err => { - console.log('[LocalNotification Repeat] Error/Exception: ' + JSON.stringify(err)); + console.log("[LocalNotification Repeat] Error/Exception: " + JSON.stringify(err)); }); } localNotificationSound() { @@ -152,13 +152,13 @@ export default class App extends React.Component<{}, State> { [HmsLocalNotification.Attr.subText]: this.state.subText, [HmsLocalNotification.Attr.tag]: this.state.tag, [HmsLocalNotification.Attr.playSound]: true, - [HmsLocalNotification.Attr.soundName]: 'huawei_bounce.mp3', + [HmsLocalNotification.Attr.soundName]: "huawei_bounce.mp3", }) .then(result => { - console.log('LocalNotification Sound', result); + console.log("LocalNotification Sound", result); }) .catch(err => { - console.log('[LocalNotification Sound] Error/Exception: ' + JSON.stringify(err)); + console.log("[LocalNotification Sound] Error/Exception: " + JSON.stringify(err)); }); } localNotificationPriority() { @@ -172,10 +172,10 @@ export default class App extends React.Component<{}, State> { [HmsLocalNotification.Attr.priority]: HmsLocalNotification.Priority.max, }) .then(result => { - console.log('LocalNotification Priority', result); + console.log("LocalNotification Priority", result); }) .catch(err => { - console.log('[LocalNotification Priority] Error/Exception: ' + JSON.stringify(err)); + console.log("[LocalNotification Priority] Error/Exception: " + JSON.stringify(err)); }); } @@ -190,10 +190,10 @@ export default class App extends React.Component<{}, State> { [HmsLocalNotification.Attr.ongoing]: true, }) .then(result => { - console.log('LocalNotification Ongoing', result); + console.log("LocalNotification Ongoing", result); }) .catch(err => { - console.log('[LocalNotification Ongoing] Error/Exception: ' + JSON.stringify(err)); + console.log("[LocalNotification Ongoing] Error/Exception: " + JSON.stringify(err)); }); } localNotificationBigImage() { @@ -205,13 +205,13 @@ export default class App extends React.Component<{}, State> { [HmsLocalNotification.Attr.subText]: this.state.subText, [HmsLocalNotification.Attr.tag]: this.state.tag, [HmsLocalNotification.Attr.bigPictureUrl]: - 'https://www-file.huawei.com/-/media/corp/home/image/logo_400x200.png', + "https://www-file.huawei.com/-/media/corp/home/image/logo_400x200.png", }) .then(result => { - console.log('LocalNotification BigImage', result); + console.log("LocalNotification BigImage", result); }) .catch(err => { - console.log('[LocalNotification BigImage] Error/Exception: ' + JSON.stringify(err)); + console.log("[LocalNotification BigImage] Error/Exception: " + JSON.stringify(err)); }); } @@ -223,12 +223,12 @@ export default class App extends React.Component<{}, State> { <TextInput value={this.state.title} placeholder="title" - onChangeText={e => this.changeNotificationValue('title', e)} + onChangeText={e => this.changeNotificationValue("title", e)} /> <TextInput value={this.state.tag} placeholder="tag" - onChangeText={e => this.changeNotificationValue('tag', e)} + onChangeText={e => this.changeNotificationValue("tag", e)} /> </View> <View> @@ -236,7 +236,7 @@ export default class App extends React.Component<{}, State> { <TextInput value={this.state.message} placeholder="message" - onChangeText={e => this.changeNotificationValue('message', e)} + onChangeText={e => this.changeNotificationValue("message", e)} /> </View> <View> @@ -244,7 +244,7 @@ export default class App extends React.Component<{}, State> { <TextInput value={this.state.bigText} placeholder="bigText" - onChangeText={e => this.changeNotificationValue('bigText', e)} + onChangeText={e => this.changeNotificationValue("bigText", e)} /> </View> <View> @@ -252,7 +252,7 @@ export default class App extends React.Component<{}, State> { <TextInput value={this.state.subText} placeholder="subText" - onChangeText={e => this.changeNotificationValue('subText', e)} + onChangeText={e => this.changeNotificationValue("subText", e)} /> </View> @@ -291,10 +291,10 @@ export default class App extends React.Component<{}, State> { onPress={() => { HmsLocalNotification.cancelAllNotifications() .then(result => { - console.log('cancelAllNotifications', result); + console.log("cancelAllNotifications", result); }) .catch(err => { - console.log('[cancelAllNotifications] Error/Exception: ' + JSON.stringify(err)); + console.log("[cancelAllNotifications] Error/Exception: " + JSON.stringify(err)); }); }} > @@ -304,10 +304,10 @@ export default class App extends React.Component<{}, State> { onPress={() => { HmsLocalNotification.getNotifications() .then(result => { - console.log('getNotifications', result); + console.log("getNotifications", result); }) .catch(err => { - console.log('[getNotifications] Error/Exception: ' + JSON.stringify(err)); + console.log("[getNotifications] Error/Exception: " + JSON.stringify(err)); }); }} > @@ -319,11 +319,11 @@ export default class App extends React.Component<{}, State> { onPress={() => { HmsLocalNotification.cancelScheduledNotifications() .then(result => { - console.log('cancelScheduledNotifications', result); + console.log("cancelScheduledNotifications", result); }) .catch(err => { console.log( - '[cancelScheduledNotifications] Error/Exception: ' + JSON.stringify(err), + "[cancelScheduledNotifications] Error/Exception: " + JSON.stringify(err), ); }); }} @@ -334,10 +334,10 @@ export default class App extends React.Component<{}, State> { onPress={() => { HmsLocalNotification.getScheduledNotifications() .then(result => { - console.log('getScheduledNotifications', result); + console.log("getScheduledNotifications", result); }) .catch(err => { - console.log('[getScheduledNotifications] Error/Exception: ' + JSON.stringify(err)); + console.log("[getScheduledNotifications] Error/Exception: " + JSON.stringify(err)); }); }} > @@ -347,12 +347,12 @@ export default class App extends React.Component<{}, State> { <View> <TouchableOpacity onPress={() => { - HmsLocalNotification.cancelNotificationsWithTag('tag') + HmsLocalNotification.cancelNotificationsWithTag("tag") .then(result => { - console.log('cancelNotificationsWithTag', result); + console.log("cancelNotificationsWithTag", result); }) .catch(err => { - console.log('[cancelNotificationsWithTag] Error/Exception: ' + JSON.stringify(err)); + console.log("[cancelNotificationsWithTag] Error/Exception: " + JSON.stringify(err)); }); }} > @@ -362,10 +362,10 @@ export default class App extends React.Component<{}, State> { onPress={() => { HmsLocalNotification.getChannels() .then(result => { - console.log('getChannels', result); + console.log("getChannels", result); }) .catch(err => { - console.log('[getChannels] Error/Exception: ' + JSON.stringify(err)); + console.log("[getChannels] Error/Exception: " + JSON.stringify(err)); }); }} > @@ -377,10 +377,10 @@ export default class App extends React.Component<{}, State> { onPress={() => { HmsLocalNotification.cancelNotifications() .then(result => { - console.log('cancelNotifications', result); + console.log("cancelNotifications", result); }) .catch(err => { - console.log('[cancelNotifications] Error/Exception: ' + JSON.stringify(err)); + console.log("[cancelNotifications] Error/Exception: " + JSON.stringify(err)); }); }} > @@ -388,12 +388,12 @@ export default class App extends React.Component<{}, State> { </TouchableOpacity> <TouchableOpacity onPress={() => { - HmsLocalNotification.deleteChannel('hms-channel-custom') + HmsLocalNotification.deleteChannel("hms-channel-custom") .then(result => { - console.log('deleteChannel', result); + console.log("deleteChannel", result); }) .catch(err => { - console.log('[deleteChannel] Error/Exception: ' + JSON.stringify(err)); + console.log("[deleteChannel] Error/Exception: " + JSON.stringify(err)); }); }} > @@ -403,12 +403,12 @@ export default class App extends React.Component<{}, State> { <View> <TouchableOpacity onPress={() => { - HmsLocalNotification.channelBlocked('huawei-hms-rn-push-channel-id') + HmsLocalNotification.channelBlocked("huawei-hms-rn-push-channel-id") .then(result => { - console.log('channelBlocked', result); + console.log("channelBlocked", result); }) .catch(err => { - console.log('[channelBlocked] Error/Exception: ' + JSON.stringify(err)); + console.log("[channelBlocked] Error/Exception: " + JSON.stringify(err)); }); }} > @@ -416,12 +416,12 @@ export default class App extends React.Component<{}, State> { </TouchableOpacity> <TouchableOpacity onPress={() => { - HmsLocalNotification.channelExists('huawei-hms-rn-push-channel-id') + HmsLocalNotification.channelExists("huawei-hms-rn-push-channel-id") .then(result => { - console.log('channelExists', result); + console.log("channelExists", result); }) .catch(err => { - console.log('[channelExists] Error/Exception: ' + JSON.stringify(err)); + console.log("[channelExists] Error/Exception: " + JSON.stringify(err)); }); }} > diff --git a/types/hmscore__react-native-hms-push/test/main-test.tsx b/types/hmscore__react-native-hms-push/test/main-test.tsx index 4c4c1580b8051a..3a7d75fa9c38bc 100644 --- a/types/hmscore__react-native-hms-push/test/main-test.tsx +++ b/types/hmscore__react-native-hms-push/test/main-test.tsx @@ -14,20 +14,20 @@ limitations under the License. */ -import { Component } from 'react'; -import { NativeEventSubscription } from 'react-native'; +import { Component } from "react"; +import { NativeEventSubscription } from "react-native"; import { + HmsLocalNotification, HmsPushEvent, - RNRemoteMessage, - HmsPushMessaging, HmsPushInstanceId, - HmsLocalNotification, + HmsPushMessaging, HmsPushOpenDevice, - RemoteMessageBuilder, HmsPushProfile, HmsPushResultCode, -} from '@hmscore/react-native-hms-push'; + RemoteMessageBuilder, + RNRemoteMessage, +} from "@hmscore/react-native-hms-push"; interface State { topic: string; @@ -50,8 +50,8 @@ export default class App extends Component<{}, State> { super(props); this.state = { - topic: '', - subjectId: '<project_id>', + topic: "", + subjectId: "<project_id>", }; this.componentDidMount = this.componentDidMount.bind(this); @@ -62,56 +62,56 @@ export default class App extends Component<{}, State> { const RNRemoteMessageObj = new RNRemoteMessage(result.msg); HmsLocalNotification.localNotification({ - [HmsLocalNotification.Attr.title]: 'DataMessage Received', + [HmsLocalNotification.Attr.title]: "DataMessage Received", [HmsLocalNotification.Attr.message]: RNRemoteMessageObj.getDataOfMap(), }); - console.log('onRemoteMessageReceived', result); + console.log("onRemoteMessageReceived", result); }); this.onTokenReceivedListener = HmsPushEvent.onTokenReceived(result => { - console.log('onTokenReceived', result); + console.log("onTokenReceived", result); }); this.onTokenErrorListener = HmsPushEvent.onTokenError(result => { - console.log('onTokenError', result); + console.log("onTokenError", result); if (result.result_code === HmsPushResultCode.ERROR_CLIENT_API_INVALID) { - console.log('Invalid Client'); + console.log("Invalid Client"); } }); this.onMultiSenderTokenReceivedListener = HmsPushEvent.onMultiSenderTokenReceived(result => { - console.log('onMultiSenderTokenReceived', result); + console.log("onMultiSenderTokenReceived", result); }); this.onMultiSenderTokenErrorListener = HmsPushEvent.onMultiSenderTokenError(result => { - console.log('onMultiSenderTokenError', result); + console.log("onMultiSenderTokenError", result); }); this.onPushMessageSentListener = HmsPushEvent.onPushMessageSent(result => { - console.log('onPushMessageSent', result); + console.log("onPushMessageSent", result); }); this.onMessageSentErrorListener = HmsPushEvent.onPushMessageSentError(result => { - console.log('onMessageSentError', result); + console.log("onMessageSentError", result); }); this.onMessageSentDeliveredListener = HmsPushEvent.onPushMessageSentDelivered(result => { - console.log('onMessageSentDelivered', result); + console.log("onMessageSentDelivered", result); }); this.onLocalNotificationActionListener = HmsPushEvent.onLocalNotificationAction(result => { - console.log('onLocalNotificationAction', result); + console.log("onLocalNotificationAction", result); const notification = JSON.parse(result.dataJSON); - if (notification.action === 'Yes') { + if (notification.action === "Yes") { HmsLocalNotification.cancelNotificationsWithId([notification.id]); } - console.log('onLocalNotificationAction-Clicked', notification.action); + console.log("onLocalNotificationAction-Clicked", notification.action); }); this.onNotificationOpenedAppListener = HmsPushEvent.onNotificationOpenedApp(result => { - console.log('onNotificationOpenedApp', result); + console.log("onNotificationOpenedApp", result); }); } @@ -137,228 +137,228 @@ export default class App extends Component<{}, State> { turnOnPush() { HmsPushMessaging.turnOnPush() .then(result => { - console.log('turnOnPush', result); + console.log("turnOnPush", result); }) .catch(err => { - console.log('[turnOnPush] Error/Exception: ' + JSON.stringify(err)); + console.log("[turnOnPush] Error/Exception: " + JSON.stringify(err)); }); } turnOffPush() { HmsPushMessaging.turnOffPush() .then(result => { - console.log('turnOffPush', result); + console.log("turnOffPush", result); }) .catch(err => { - console.log('[turnOffPush] Error/Exception: ' + JSON.stringify(err)); + console.log("[turnOffPush] Error/Exception: " + JSON.stringify(err)); }); } getID() { HmsPushInstanceId.getId() .then(result => { - console.log('getId', result); + console.log("getId", result); }) .catch(err => { - console.log('[getID] Error/Exception: ' + JSON.stringify(err)); + console.log("[getID] Error/Exception: " + JSON.stringify(err)); }); } getAAID() { HmsPushInstanceId.getAAID() .then(result => { - console.log('getAAID', result); + console.log("getAAID", result); }) .catch(err => { - console.log('[getAAID] Error/Exception: ' + JSON.stringify(err)); + console.log("[getAAID] Error/Exception: " + JSON.stringify(err)); }); } getOdid() { HmsPushOpenDevice.getOdid() .then(result => { - console.log('getOdid', result); + console.log("getOdid", result); }) .catch(err => { - console.log('[getOdid] Error/Exception: ' + JSON.stringify(err)); + console.log("[getOdid] Error/Exception: " + JSON.stringify(err)); }); } getToken() { - HmsPushInstanceId.getToken('') + HmsPushInstanceId.getToken("") .then(result => { - console.log('getToken', result); + console.log("getToken", result); }) .catch(err => { - console.log('[getToken] Error/Exception: ' + JSON.stringify(err)); + console.log("[getToken] Error/Exception: " + JSON.stringify(err)); }); } getTokenWithSubjectId() { HmsPushInstanceId.getTokenWithSubjectId(this.state.subjectId) .then(result => { - console.log('getTokenWithSubjectId', result); + console.log("getTokenWithSubjectId", result); }) .catch(err => { - console.log('[getTokenWithSubjectId] Error/Exception: ' + JSON.stringify(err)); + console.log("[getTokenWithSubjectId] Error/Exception: " + JSON.stringify(err)); }); } getCreationTime() { HmsPushInstanceId.getCreationTime() .then(result => { - console.log('getCreationTime', result); + console.log("getCreationTime", result); }) .catch(err => { - console.log('[getCreationTime] Error/Exception: ' + JSON.stringify(err)); + console.log("[getCreationTime] Error/Exception: " + JSON.stringify(err)); }); } deleteAAID() { HmsPushInstanceId.deleteAAID() .then(result => { - console.log('deleteAAID', result); + console.log("deleteAAID", result); }) .catch(err => { - console.log('[deleteAAID] Error/Exception: ' + JSON.stringify(err)); + console.log("[deleteAAID] Error/Exception: " + JSON.stringify(err)); }); } deleteToken() { - HmsPushInstanceId.deleteToken('') + HmsPushInstanceId.deleteToken("") .then(result => { - console.log('deleteToken', result); + console.log("deleteToken", result); }) .catch(err => { - console.log('[deleteToken] Error/Exception: ' + JSON.stringify(err)); + console.log("[deleteToken] Error/Exception: " + JSON.stringify(err)); }); } deleteTokenWithSubjectId() { HmsPushInstanceId.deleteTokenWithSubjectId(this.state.subjectId) .then(result => { - console.log('deleteTokenWithSubjectId', result); + console.log("deleteTokenWithSubjectId", result); }) .catch(err => { - console.log('[deleteTokenWithSubjectId] Error/Exception: ' + JSON.stringify(err)); + console.log("[deleteTokenWithSubjectId] Error/Exception: " + JSON.stringify(err)); }); } subscribe() { HmsPushMessaging.subscribe(this.state.topic) .then(result => { - console.log('subscribe', result); + console.log("subscribe", result); }) .catch(err => { console.log(JSON.stringify(err)); - console.log('[subscribe] Error/Exception: ' + JSON.stringify(err)); + console.log("[subscribe] Error/Exception: " + JSON.stringify(err)); }); } unsubscribe() { HmsPushMessaging.unsubscribe(this.state.topic) .then(result => { - console.log('unsubscribe', result); + console.log("unsubscribe", result); }) .catch(err => { - console.log('[unsubscribe] Error/Exception: ' + JSON.stringify(err)); + console.log("[unsubscribe] Error/Exception: " + JSON.stringify(err)); }); } sendRemoteMessage() { HmsPushMessaging.sendRemoteMessage({ - [RemoteMessageBuilder.TO]: '', + [RemoteMessageBuilder.TO]: "", // [RemoteMessageBuilder.MESSAGE_ID]: '', // Auto generated - [RemoteMessageBuilder.MESSAGE_TYPE]: 'hms', - [RemoteMessageBuilder.COLLAPSE_KEY]: '-1', + [RemoteMessageBuilder.MESSAGE_TYPE]: "hms", + [RemoteMessageBuilder.COLLAPSE_KEY]: "-1", [RemoteMessageBuilder.TTL]: 120, [RemoteMessageBuilder.RECEIPT_MODE]: 1, [RemoteMessageBuilder.SEND_MODE]: 1, - [RemoteMessageBuilder.DATA]: { key1: 'test', message: 'huawei-test' }, + [RemoteMessageBuilder.DATA]: { key1: "test", message: "huawei-test" }, }) .then(result => { - console.log('sendRemoteMessage', result); + console.log("sendRemoteMessage", result); }) .catch(err => { - console.log('[sendRemoteMessage] Error/Exception: ' + JSON.stringify(err)); + console.log("[sendRemoteMessage] Error/Exception: " + JSON.stringify(err)); }); } isAutoInitEnabled() { HmsPushMessaging.isAutoInitEnabled() .then(result => { - console.log('isAutoInitEnabled', result); + console.log("isAutoInitEnabled", result); }) .catch(err => { - console.log('[isAutoInitEnabled] Error/Exception: ' + JSON.stringify(err)); + console.log("[isAutoInitEnabled] Error/Exception: " + JSON.stringify(err)); }); } setAutoInitEnabled(value: boolean) { HmsPushMessaging.setAutoInitEnabled(value) .then(result => { - console.log('setAutoInitEnabled', result); + console.log("setAutoInitEnabled", result); }) .catch(err => { - console.log('[setAutoInitEnabled] Error/Exception: ' + JSON.stringify(err)); + console.log("[setAutoInitEnabled] Error/Exception: " + JSON.stringify(err)); }); } getInitialNotification() { HmsPushMessaging.getInitialNotification() .then(result => { - console.log('getInitialNotification', result); + console.log("getInitialNotification", result); }) .catch(err => { - console.log('[getInitialNotification] Error/Exception: ' + JSON.stringify(err)); + console.log("[getInitialNotification] Error/Exception: " + JSON.stringify(err)); }); } isSupportProfile() { HmsPushProfile.isSupportProfile() .then(result => { - console.log('isSupportProfile', result); + console.log("isSupportProfile", result); }) .catch(err => { - console.log('[isSupportProfile] Error/Exception: ' + JSON.stringify(err)); + console.log("[isSupportProfile] Error/Exception: " + JSON.stringify(err)); }); } addProfile() { - HmsPushProfile.addProfile(HmsPushProfile.Type.HUAWEI_PROFILE, 'profileId') + HmsPushProfile.addProfile(HmsPushProfile.Type.HUAWEI_PROFILE, "profileId") .then(result => { - console.log('addProfile', result); + console.log("addProfile", result); }) .catch(err => { - console.log('[addProfile] Error/Exception: ' + JSON.stringify(err)); + console.log("[addProfile] Error/Exception: " + JSON.stringify(err)); }); } addProfileWithSubjectId() { - HmsPushProfile.addProfileWithSubjectId('<subject_Id>', HmsPushProfile.Type.HUAWEI_PROFILE, '<profileId>') + HmsPushProfile.addProfileWithSubjectId("<subject_Id>", HmsPushProfile.Type.HUAWEI_PROFILE, "<profileId>") .then(result => { - console.log('addProfileWithSubjectId', result); + console.log("addProfileWithSubjectId", result); }) .catch(err => { - console.log('[addProfileWithSubjectId] Error/Exception: ' + JSON.stringify(err)); + console.log("[addProfileWithSubjectId] Error/Exception: " + JSON.stringify(err)); }); } deleteProfile() { - HmsPushProfile.deleteProfile('<profile_Id>') + HmsPushProfile.deleteProfile("<profile_Id>") .then(result => { - console.log('deleteProfile', result); + console.log("deleteProfile", result); }) .catch(err => { - console.log('[deleteProfile] Error/Exception: ' + JSON.stringify(err)); + console.log("[deleteProfile] Error/Exception: " + JSON.stringify(err)); }); } deleteProfileWithSubjectId() { - HmsPushProfile.deleteProfileWithSubjectId('<subject_Id>', '<profile_Id>') + HmsPushProfile.deleteProfileWithSubjectId("<subject_Id>", "<profile_Id>") .then(result => { - console.log('deleteProfileWithSubjectId', result); + console.log("deleteProfileWithSubjectId", result); }) .catch(err => { - console.log('[deleteProfileWithSubjectId] Error/Exception: ' + JSON.stringify(err)); + console.log("[deleteProfileWithSubjectId] Error/Exception: " + JSON.stringify(err)); }); } diff --git a/types/hoek/hoek-tests.ts b/types/hoek/hoek-tests.ts index 4bfc98232a41ca..78f22957340f4b 100644 --- a/types/hoek/hoek-tests.ts +++ b/types/hoek/hoek-tests.ts @@ -13,19 +13,19 @@ let nestedObj = { x: { a: [1, 2, 3], b: 123456, - c: new Date() + c: new Date(), }, - y: 'y', - z: new Date() + y: "y", + z: new Date(), }; let copy = Hoek.clone(nestedObj); copy.x.b = 100; -console.log(copy.y); // results in 'y' +console.log(copy.y); // results in 'y' console.log(nestedObj.x.b); // results in 123456 -console.log(copy.x.b); // results in 100 +console.log(copy.x.b); // results in 100 // cloneWithShallow(obj, keys) @@ -34,19 +34,19 @@ nestedObj = { x: { a: [1, 2, 3], b: 123456, - c: new Date() + c: new Date(), }, - y: 'y', - z: new Date() + y: "y", + z: new Date(), }; -copy = Hoek.cloneWithShallow(nestedObj, ['x']); +copy = Hoek.cloneWithShallow(nestedObj, ["x"]); copy.x.b = 100; -console.log(copy.y); // results in 'y' +console.log(copy.y); // results in 'y' console.log(nestedObj.x.b); // results in 100 -console.log(copy.x.b); // results in 100 +console.log(copy.x.b); // results in 100 // merge(target, source, isNullOverride, isMergeArrays) @@ -54,14 +54,14 @@ const target = { a: 1, b: 2 }; const source = { a: 0, c: 5 }; const source2 = { a: null, c: 5 }; -Hoek.merge(target, source); // results in {a: 0, b: 2, c: 5} -Hoek.merge(target, source2); // results in {a: null, b: 2, c: 5} +Hoek.merge(target, source); // results in {a: 0, b: 2, c: 5} +Hoek.merge(target, source2); // results in {a: null, b: 2, c: 5} Hoek.merge(target, source2, false); // results in {a: 1, b: 2, c: 5} const targetArray = [1, 2, 3]; const sourceArray = [4, 5]; -Hoek.merge(targetArray, sourceArray); // results in [1, 2, 3, 4, 5] +Hoek.merge(targetArray, sourceArray); // results in [1, 2, 3, 4, 5] Hoek.merge(targetArray, sourceArray, true, false); // results in [4, 5] // applyToDefaults(defaults, options, isNullOverride) @@ -81,18 +81,18 @@ config = Hoek.applyToDefaults(defaults, options1, true); // results in { host: n const defaults1 = { server: { host: "localhost", - port: 8000 + port: 8000, }, - name: 'example' + name: "example", }; const options2 = { server: { port: 8080 } }; -const config1 = Hoek.applyToDefaultsWithShallow(defaults1, options2, ['server']); // results in { server: { port: 8080 }, name: 'example' } +const config1 = Hoek.applyToDefaultsWithShallow(defaults1, options2, ["server"]); // results in { server: { port: 8080 }, name: 'example' } // deepEqual(b, a, [options]) -Hoek.deepEqual({ a: [1, 2], b: 'string', c: { d: true } }, { a: [1, 2], b: 'string', c: { d: true } }); // results in true +Hoek.deepEqual({ a: [1, 2], b: "string", c: { d: true } }, { a: [1, 2], b: "string", c: { d: true } }); // results in true Hoek.deepEqual(Object.create(null), {}, { prototype: false }); // results in true Hoek.deepEqual(Object.create(null), {}); // results in false @@ -100,16 +100,16 @@ Hoek.deepEqual(Object.create(null), {}); // results in false let array = [1, 2, 2, 3, 3, 4, 5, 6]; -const newArray = Hoek.unique(array); // results in [1,2,3,4,5,6] +const newArray = Hoek.unique(array); // results in [1,2,3,4,5,6] let array1 = [{ id: 1 }, { id: 1 }, { id: 2 }]; -const newArray1 = Hoek.unique(array1, "id"); // results in [{id: 1}, {id: 2}] +const newArray1 = Hoek.unique(array1, "id"); // results in [{id: 1}, {id: 2}] // mapToObject(array, key) array = [1, 2, 3]; -let newObject = Hoek.mapToObject(array); // results in {"1": true, "2": true, "3": true} +let newObject = Hoek.mapToObject(array); // results in {"1": true, "2": true, "3": true} array1 = [{ id: 1 }, { id: 2 }]; newObject = Hoek.mapToObject(array1, "id"); // results in {"1": true, "2": true} @@ -123,9 +123,9 @@ const newArray2 = Hoek.intersect(array, array2); // results in [1] // contain(ref, values, [options]) -Hoek.contain('aaa', 'a', { only: true }); // true -Hoek.contain([{ a: 1 }], [{ a: 1 }], { deep: true }); // true -Hoek.contain([1, 2, 2], [1, 2], { once: true }); // false +Hoek.contain("aaa", "a", { only: true }); // true +Hoek.contain([{ a: 1 }], [{ a: 1 }], { deep: true }); // true +Hoek.contain([1, 2, 2], [1, 2], { once: true }); // false Hoek.contain({ a: 1, b: 2, c: 3 }, { a: 1, d: 4 }, { part: true }); // true // flatten(array, [target]) @@ -141,39 +141,39 @@ flattenedArray = Hoek.flatten(array3, target1); // results in [4, [5], 1, 2, 3] // reach(obj, chain, [options]) -let chain = 'a.b.c'; +let chain = "a.b.c"; let obj = { a: { b: { c: 1 } } }; Hoek.reach(obj, chain); // returns 1 -chain = 'a.b.-1'; +chain = "a.b.-1"; const obj1 = { a: { b: [2, 3, 6] } }; Hoek.reach(obj1, chain); // returns 6 // reachTemplate(obj, template, [options]) -chain = 'a.b.c'; +chain = "a.b.c"; obj = { a: { b: { c: 1 } } }; -Hoek.reachTemplate(obj, '1+{a.b.c}=2'); // returns '1+1=2' +Hoek.reachTemplate(obj, "1+{a.b.c}=2"); // returns '1+1=2' // transform(obj, transform, [options]) const source1 = { address: { - one: '123 main street', - two: 'PO Box 1234' + one: "123 main street", + two: "PO Box 1234", }, - title: 'Warehouse', - state: 'CA' + title: "Warehouse", + state: "CA", }; let result = Hoek.transform(source1, { - 'person.address.lineOne': 'address.one', - 'person.address.lineTwo': 'address.two', - title: 'title', - 'person.address.region': 'state' + "person.address.lineOne": "address.one", + "person.address.lineTwo": "address.two", + title: "title", + "person.address.region": "state", }); // Results in // { @@ -195,7 +195,7 @@ const shallow = Hoek.shallow({ a: { b: 1 } }); let a: any = {}; a.b = a; -Hoek.stringify(a); // Returns '[Cannot display object: Converting circular structure to JSON]' +Hoek.stringify(a); // Returns '[Cannot display object: Converting circular structure to JSON]' // Timer @@ -218,25 +218,25 @@ Hoek.base64urlDecode("aG9law=="); // escapeHtml(string) -const string = '<html> hey </html>'; +const string = "<html> hey </html>"; const escapedString = Hoek.escapeHtml(string); // returns <html> hey </html> // escapeHeaderAttribute(attribute) -a = Hoek.escapeHeaderAttribute('I said "go w\\o me"'); // returns I said \"go w\\o me\" +a = Hoek.escapeHeaderAttribute("I said \"go w\\o me\""); // returns I said \"go w\\o me\" // escapeRegex(string) -a = Hoek.escapeRegex('4^f$s.4*5+-_?%=#!:@|~\\/`"(>)[<]d{}s,'); // returns 4\^f\$s\.4\*5\+\-_\?%\=#\!\:@\|~\\\/`"\(>\)\[<\]d\{\}s\, +a = Hoek.escapeRegex("4^f$s.4*5+-_?%=#!:@|~\\/`\"(>)[<]d{}s,"); // returns 4\^f\$s\.4\*5\+\-_\?%\=#\!\:@\|~\\\/`"\(>\)\[<\]d\{\}s\, // assert(condition, message) const x = 1; const y = 2 as number; -Hoek.assert(x === y, 'x should equal y'); // Throws 'x should equal y' +Hoek.assert(x === y, "x should equal y"); // Throws 'x should equal y' -Hoek.assert(x === y, new Error('x should equal y')); // Throws the given error object +Hoek.assert(x === y, new Error("x should equal y")); // Throws the given error object // abort(message) @@ -255,13 +255,13 @@ console.log(stack2); // nextTick(fn) let myFn = () => { - console.log('Do this later'); + console.log("Do this later"); }; const nextFn = Hoek.nextTick(myFn); nextFn(); -console.log('Do this first'); +console.log("Do this first"); // Results in: // @@ -271,7 +271,7 @@ console.log('Do this first'); // once(fn) myFn = () => { - console.log('Ran myFn'); + console.log("Ran myFn"); }; const onceFn = Hoek.once(myFn); @@ -284,8 +284,8 @@ Hoek.ignore(); // uniqueFilename(path, extension) -const result1 = Hoek.uniqueFilename('./test/modules', 'txt'); // results in "full/path/test/modules/{random}.txt" +const result1 = Hoek.uniqueFilename("./test/modules", "txt"); // results in "full/path/test/modules/{random}.txt" // isInteger(value) -result = Hoek.isInteger('23'); +result = Hoek.isInteger("23"); diff --git a/types/hogan.js/hogan.js-tests.ts b/types/hogan.js/hogan.js-tests.ts index ae8bec20f62f34..1289cfaca1d59e 100644 --- a/types/hogan.js/hogan.js-tests.ts +++ b/types/hogan.js/hogan.js-tests.ts @@ -1,4 +1,4 @@ -import Hogan = require('hogan.js'); +import Hogan = require("hogan.js"); // $ExpectType HoganTemplate const compiled = Hogan.compile("{{#if}}{{value}}{{/if}}"); @@ -7,11 +7,11 @@ const compiled = Hogan.compile("{{#if}}{{value}}{{/if}}"); Hogan.compile("<%_foo%><%value%><%/foo%>", { asString: true, sectionTags: [{ - o: '_foo', - c: 'foo' + o: "_foo", + c: "foo", }], - delimiters: '<% %>', - disableLambda: true + delimiters: "<% %>", + disableLambda: true, }); // $ExpectType string diff --git a/types/hogan.js/index.d.ts b/types/hogan.js/index.d.ts index c507c9f6337e28..de149c181faf59 100644 --- a/types/hogan.js/index.d.ts +++ b/types/hogan.js/index.d.ts @@ -55,11 +55,11 @@ export { HoganTemplate as Template, HoganTemplate as template }; export function compile( text: string, - options?: HoganOptions & { asString: false } + options?: HoganOptions & { asString: false }, ): HoganTemplate; export function compile( text: string, - options?: HoganOptions & { asString: true } + options?: HoganOptions & { asString: true }, ): string; /** * Compiles templates to HoganTemplate objects, which have a render method. @@ -70,7 +70,7 @@ export function compile( */ export function compile( text: string, - options?: HoganOptions + options?: HoganOptions, ): HoganTemplate | string; /** * Scans templates returning an array of found tokens. @@ -91,5 +91,5 @@ export function scan(text: string, delimiters?: string): Token[]; export function parse( tokens: ReadonlyArray<Token>, text?: undefined, - options?: HoganOptions + options?: HoganOptions, ): Tree; diff --git a/types/hoist-non-react-statics/hoist-non-react-statics-tests.tsx b/types/hoist-non-react-statics/hoist-non-react-statics-tests.tsx index 243c2518bb4069..a6dd8476159b6d 100644 --- a/types/hoist-non-react-statics/hoist-non-react-statics-tests.tsx +++ b/types/hoist-non-react-statics/hoist-non-react-statics-tests.tsx @@ -1,11 +1,11 @@ -import * as React from 'react'; -import * as PropTypes from 'prop-types'; +import * as PropTypes from "prop-types"; +import * as React from "react"; -import hoistNonReactStatics = require('hoist-non-react-statics'); +import hoistNonReactStatics = require("hoist-non-react-statics"); function TestClassComponents() { class A extends React.Component<{ x: number; y?: number | null | undefined }> { - static a = 'a'; + static a = "a"; static propTypes = { x: PropTypes.number.isRequired, @@ -18,7 +18,7 @@ function TestClassComponents() { } class B extends React.Component { - static b = 'b'; + static b = "b"; static propTypes = { n: PropTypes.number.isRequired, @@ -76,22 +76,22 @@ function TestClassComponents() { // convenience to avoid having to model the component's type with static fields. function TestFunctionalComponents() { - const A = ({x, y}: {x: number; y?: number | undefined}) => <div>{x + (y || 0)}</div>; + const A = ({ x, y }: { x: number; y?: number | undefined }) => <div>{x + (y || 0)}</div>; // tslint:disable-next-line:prefer-object-spread const AWithStatics = Object.assign(A, { - a: 'a', + a: "a", propTypes: { x: PropTypes.number.isRequired, y: PropTypes.number, }, }); - const B = ({n}: {n: number}) => <div>{n}</div>; + const B = ({ n }: { n: number }) => <div>{n}</div>; // tslint:disable-next-line:prefer-object-spread const BWithStatics = Object.assign(B, { - b: 'b', + b: "b", propTypes: { n: PropTypes.number.isRequired, }, @@ -134,22 +134,22 @@ function TestFunctionalComponents() { } function TestMemoComponents() { - const A = ({x, y}: {x: number; y?: number | undefined}) => <div>{x + (y || 0)}</div>; + const A = ({ x, y }: { x: number; y?: number | undefined }) => <div>{x + (y || 0)}</div>; // tslint:disable-next-line:prefer-object-spread const AWithStatics = Object.assign(A, { - a: 'a', + a: "a", propTypes: { x: PropTypes.number.isRequired, y: PropTypes.number, }, }); - const B = React.memo(({n}: {n: number}) => <div>{n}</div>); + const B = React.memo(({ n }: { n: number }) => <div>{n}</div>); // tslint:disable-next-line:prefer-object-spread const BWithStatics = Object.assign(B, { - b: 'b', + b: "b", propTypes: { n: PropTypes.number.isRequired, }, @@ -192,11 +192,11 @@ function TestMemoComponents() { } function TestForwardRefComponents() { - const A = ({x, y}: {x: number; y?: number | undefined}) => <div>{x + (y || 0)}</div>; + const A = ({ x, y }: { x: number; y?: number | undefined }) => <div>{x + (y || 0)}</div>; // tslint:disable-next-line:prefer-object-spread const AWithStatics = Object.assign(A, { - a: 'a', + a: "a", propTypes: { x: PropTypes.number.isRequired, y: PropTypes.number, @@ -204,12 +204,12 @@ function TestForwardRefComponents() { }); const B = React.forwardRef( - ({n}: {n: number}, ref: React.Ref<HTMLDivElement>) => <div ref={ref}>{n}</div> + ({ n }: { n: number }, ref: React.Ref<HTMLDivElement>) => <div ref={ref}>{n}</div>, ); // tslint:disable-next-line:prefer-object-spread const BWithStatics = Object.assign(B, { - b: 'b', + b: "b", propTypes: { n: PropTypes.number.isRequired, }, diff --git a/types/hoist-non-react-statics/index.d.ts b/types/hoist-non-react-statics/index.d.ts index fc90d9713dc8f4..0aad97bdd060dd 100644 --- a/types/hoist-non-react-statics/index.d.ts +++ b/types/hoist-non-react-statics/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -import * as React from 'react'; +import * as React from "react"; interface REACT_STATICS { childContextTypes: true; @@ -31,7 +31,7 @@ interface KNOWN_STATICS { } interface MEMO_STATICS { - '$$typeof': true; + "$$typeof": true; compare: true; defaultProps: true; displayName: true; @@ -40,7 +40,7 @@ interface MEMO_STATICS { } interface FORWARD_REF_STATICS { - '$$typeof': true; + "$$typeof": true; render: true; defaultProps: true; displayName: true; @@ -51,17 +51,17 @@ declare namespace hoistNonReactStatics { type NonReactStatics< S extends React.ComponentType<any>, C extends { - [key: string]: true - } = {} + [key: string]: true; + } = {}, > = { - [key in Exclude< - keyof S, - S extends React.MemoExoticComponent<any> - ? keyof MEMO_STATICS | keyof C - : S extends React.ForwardRefExoticComponent<any> - ? keyof FORWARD_REF_STATICS | keyof C - : keyof REACT_STATICS | keyof KNOWN_STATICS | keyof C - >]: S[key] + [ + key in Exclude< + keyof S, + S extends React.MemoExoticComponent<any> ? keyof MEMO_STATICS | keyof C + : S extends React.ForwardRefExoticComponent<any> ? keyof FORWARD_REF_STATICS | keyof C + : keyof REACT_STATICS | keyof KNOWN_STATICS | keyof C + > + ]: S[key]; }; } @@ -69,8 +69,8 @@ declare function hoistNonReactStatics< T extends React.ComponentType<any>, S extends React.ComponentType<any>, C extends { - [key: string]: true - } = {} + [key: string]: true; + } = {}, >( TargetComponent: T, SourceComponent: S, diff --git a/types/holderjs/holderjs-tests.ts b/types/holderjs/holderjs-tests.ts index 2992b5e9a35ade..15443b22d4752e 100644 --- a/types/holderjs/holderjs-tests.ts +++ b/types/holderjs/holderjs-tests.ts @@ -1,9 +1,9 @@ import * as Holder from "holderjs"; -const myImage = document.getElementById('myImage'); +const myImage = document.getElementById("myImage"); Holder.run({ - images: myImage + images: myImage, }); Holder.run(); diff --git a/types/honeybadger/honeybadger-tests.ts b/types/honeybadger/honeybadger-tests.ts index ac7fee7b4ce752..6ed7518311a401 100644 --- a/types/honeybadger/honeybadger-tests.ts +++ b/types/honeybadger/honeybadger-tests.ts @@ -1,11 +1,11 @@ -import Honeybadger = require('honeybadger'); +import Honeybadger = require("honeybadger"); Honeybadger.configure({ - apiKey: 'abcdef', - developmentEnvironments: ['development'], + apiKey: "abcdef", + developmentEnvironments: ["development"], }); -const err = Error('error'); +const err = Error("error"); Honeybadger.notify(err, function notifyCallback(err: Error, notice: any) { if (err) console.error(err); @@ -25,17 +25,17 @@ Honeybadger.resetContext({ user_id: 123, }); -const other_hb = Honeybadger.factory({ apiKey: 'zxcvbnm' }); -other_hb.notify('This will go to an alternate project.'); +const other_hb = Honeybadger.factory({ apiKey: "zxcvbnm" }); +other_hb.notify("This will go to an alternate project."); Honeybadger.onUncaughtException(err => { console.log(err); }); function handler(event: any, context: any) { - console.log('Event:', event); - console.log('Context:', context); - throw new Error('Something went wrong.'); + console.log("Event:", event); + console.log("Context:", context); + throw new Error("Something went wrong."); console.log("Shouldn't make it here."); } diff --git a/types/honeybadger/index.d.ts b/types/honeybadger/index.d.ts index 669d54ad5a651c..b7972df22bd94d 100644 --- a/types/honeybadger/index.d.ts +++ b/types/honeybadger/index.d.ts @@ -5,8 +5,8 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.9 -import { RequestHandler, ErrorRequestHandler } from 'express'; -import { EventEmitter } from 'events'; +import { EventEmitter } from "events"; +import { ErrorRequestHandler, RequestHandler } from "express"; declare namespace honeybadger { interface ConfigureOptions { diff --git a/types/hooker/hooker-tests.ts b/types/hooker/hooker-tests.ts index be657711d2ffd1..6c529855494b53 100644 --- a/types/hooker/hooker-tests.ts +++ b/types/hooker/hooker-tests.ts @@ -1,66 +1,66 @@ -import hooker = require('hooker'); +import hooker = require("hooker"); function tests() { var objectToHook: any = { - hello: 'world' + hello: "world", }; - hooker.hook(objectToHook, 'hello', () => { }); - hooker.hook(objectToHook, 'hello', (): any => { + hooker.hook(objectToHook, "hello", () => {}); + hooker.hook(objectToHook, "hello", (): any => { return null; }); - hooker.hook(objectToHook, ['hello', 'foo'], () => { }); - hooker.hook(objectToHook, ['hello', 'bar'], (): any => { + hooker.hook(objectToHook, ["hello", "foo"], () => {}); + hooker.hook(objectToHook, ["hello", "bar"], (): any => { return null; }); - hooker.hook(objectToHook, 'bar', () => { - return hooker.filter(this, ['foo', 'bar']); + hooker.hook(objectToHook, "bar", () => { + return hooker.filter(this, ["foo", "bar"]); }); - hooker.hook(objectToHook, 'bar', () => { - return hooker.override('good'); + hooker.hook(objectToHook, "bar", () => { + return hooker.override("good"); }); - hooker.hook(objectToHook, 'bar', () => { - return hooker.preempt('good'); + hooker.hook(objectToHook, "bar", () => { + return hooker.preempt("good"); }); - hooker.orig(objectToHook, 'hello'); - hooker.orig(objectToHook, ['hello', 'foo']); - hooker.hook(objectToHook, 'foo', { - pre: () => { } + hooker.orig(objectToHook, "hello"); + hooker.orig(objectToHook, ["hello", "foo"]); + hooker.hook(objectToHook, "foo", { + pre: () => {}, }); - hooker.hook(objectToHook, 'foo', { + hooker.hook(objectToHook, "foo", { pre: () => { return hooker.preempt(1); - } + }, }); - hooker.hook(objectToHook, 'foo', { + hooker.hook(objectToHook, "foo", { pre: () => { return hooker.override(1); - } + }, }); - hooker.hook(objectToHook, 'foo', { + hooker.hook(objectToHook, "foo", { pre: () => { - return hooker.filter(1, ['abc']); - } + return hooker.filter(1, ["abc"]); + }, }); - hooker.hook(objectToHook, 'foo', { - post: () => { } + hooker.hook(objectToHook, "foo", { + post: () => {}, }); - hooker.hook(objectToHook, 'foo', { + hooker.hook(objectToHook, "foo", { post: () => { - return hooker.filter(1, ['abc']); - } + return hooker.filter(1, ["abc"]); + }, }); - hooker.hook(objectToHook, 'foo', { - once: false + hooker.hook(objectToHook, "foo", { + once: false, }); - hooker.hook(objectToHook, 'foo', { - passName: true + hooker.hook(objectToHook, "foo", { + passName: true, }); - hooker.hook(objectToHook, 'foo', { - pre: () => { }, + hooker.hook(objectToHook, "foo", { + pre: () => {}, post: () => { return hooker.filter(this, []); }, once: true, - passName: false + passName: false, }); } diff --git a/types/hooker/index.d.ts b/types/hooker/index.d.ts index a807608167aea3..1ff237cd14a851 100644 --- a/types/hooker/index.d.ts +++ b/types/hooker/index.d.ts @@ -3,15 +3,14 @@ // Definitions by: Michael Zabka <https://github.com/misak113> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare type HookerPostHookFunction = (result: any, ...args: any[]) => IHookerPostHookResult|void; -declare type HookerPreHookFunction = (...args: any[]) => IHookerPreHookResult|void; +declare type HookerPostHookFunction = (result: any, ...args: any[]) => IHookerPostHookResult | void; +declare type HookerPreHookFunction = (...args: any[]) => IHookerPreHookResult | void; declare module "hooker" { - function hook(object: any, props: string|string[], options: IHookerOptions): void; - function hook(object: any, props: string|string[], prehookFunction: HookerPreHookFunction): void; - function unhook(object: any, props?: string|string[]): string[]; - function orig(object: any, props: string|string[]): Function; + function hook(object: any, props: string | string[], options: IHookerOptions): void; + function hook(object: any, props: string | string[], prehookFunction: HookerPreHookFunction): void; + function unhook(object: any, props?: string | string[]): string[]; + function orig(object: any, props: string | string[]): Function; function override(value: any): HookerOverride; function preempt(value: any): HookerPreempt; function filter(context: any, args: any[]): HookerFilter; diff --git a/types/hookrouter/hookrouter-tests.ts b/types/hookrouter/hookrouter-tests.ts index c27ef936c760f2..338019bb29ff3c 100644 --- a/types/hookrouter/hookrouter-tests.ts +++ b/types/hookrouter/hookrouter-tests.ts @@ -1,38 +1,38 @@ import { A, - setLinkProps, - useControlledInterceptor, - interceptRoute, get, - remove, - navigate, - setPath, + getBasepath, getPath, getTitle, - useRedirect, - useRoutes, - usePath, getWorkingPath, - getBasepath, - resolvePath, + interceptRoute, + navigate, prepareRoute, + remove, + resolvePath, + setLinkProps, + setPath, + useControlledInterceptor, + usePath, useQueryParams, -} from 'hookrouter'; + useRedirect, + useRoutes, +} from "hookrouter"; // $ExpectType AProps -setLinkProps({ href: '/route' }); +setLinkProps({ href: "/route" }); // @ts-expect-error setLinkProps({ onClick: () => null }); // $ExpectType ReactHTMLElement<HTMLAnchorElement> -A({ href: '/route' }); +A({ href: "/route" }); // $ExpectType [InterceptedPath, () => void, () => void, () => void] useControlledInterceptor(); // $ExpectType string[] -interceptRoute('/route1', '/route2'); +interceptRoute("/route1", "/route2"); // $ExpectType RouteObject<any> | null get(2); @@ -44,7 +44,7 @@ remove(2); useQueryParams(); // $ExpectType void -useRedirect('/route1', '/route2'); +useRedirect("/route1", "/route2"); // @ts-expect-error navigate(); @@ -56,13 +56,13 @@ navigate(1); getBasepath(); // $ExpectType string -resolvePath('path'); +resolvePath("path"); // $ExpectType [RegExp, string[]] -prepareRoute('/route'); +prepareRoute("/route"); // $ExpectType void -setPath('/route'); +setPath("/route"); // $ExpectType string usePath(); @@ -71,19 +71,19 @@ usePath(); usePath(true, true); // $ExpectType string -getWorkingPath('id'); +getWorkingPath("id"); // $ExpectType string getTitle(); // $ExpectType number | null useRoutes({ - '/': () => 42, + "/": () => 42, }); // $ExpectType (() => number) | null useRoutes({ - '/': () => () => 1 + 1, + "/": () => () => 1 + 1, }); // $ExpectType any diff --git a/types/hookrouter/index.d.ts b/types/hookrouter/index.d.ts index 28254950b78eaa..b55b578b10c51f 100644 --- a/types/hookrouter/index.d.ts +++ b/types/hookrouter/index.d.ts @@ -4,7 +4,7 @@ // Sam Calvert <https://github.com/sam-outschool> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.4 -import * as React from 'react'; +import * as React from "react"; export namespace HookRouter { type InterceptedPath = string | null; interface AProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> { diff --git a/types/hopscotch/hopscotch-tests.ts b/types/hopscotch/hopscotch-tests.ts index 0690e17e4bf2ac..aa00cea6d3f39c 100644 --- a/types/hopscotch/hopscotch-tests.ts +++ b/types/hopscotch/hopscotch-tests.ts @@ -1,55 +1,53 @@ - - var tourDefinition: TourDefinition = { - id: 'intro-tour', - steps: [ - { - target: '.popupTarget', - placement: 'bottom', - title: 'A tour step', - content: 'A tour message' - }, - { - target: [".aSelector"], - placement: 'bottom', + id: "intro-tour", + steps: [ + { + target: ".popupTarget", + placement: "bottom", + title: "A tour step", + content: "A tour message", + }, + { + target: [".aSelector"], + placement: "bottom", + + yOffset: 10, + width: 400, + xOffset: -420, + arrowOffset: 380, + }, + { + target: ".domainPatterns form", + placement: "right", + title: "A question?", + content: "Hello!", + onShow: function() {}, + }, + { + target: ".home-button", + placement: "left", + title: "Let's get started", + content: "Content", - yOffset: 10, - width: 400, - xOffset: -420, - arrowOffset: 380 - }, - { - target: '.domainPatterns form', - placement: 'right', - title: 'A question?', - content: "Hello!", - onShow: function () { } - }, - { - target: '.home-button', - placement: 'left', - title: "Let's get started", - content: "Content", + multipage: true, + nextOnTargetClick: true, + showNextButton: false, + }, + { + target: ".buttons", + placement: "top", - multipage: true, - nextOnTargetClick: true, - showNextButton: false - }, - { - target: '.buttons', - placement: 'top', - - title: 'Another title', - content: "A message", + title: "Another title", + content: "A message", - showNextButton: false, - nextOnTargetClick: true, - onShow: function () { } - } - ], - skipIfNoElement: false, - onClose: function () { }, - onEnd: function () { } + showNextButton: false, + nextOnTargetClick: true, + onShow: function() {}, + }, + ], + skipIfNoElement: false, + onClose: function() {}, + onEnd: function() {}, }; hopscotch.startTour(tourDefinition); diff --git a/types/hopscotch/index.d.ts b/types/hopscotch/index.d.ts index 5b3659a9befda4..2bb42a189ba57c 100644 --- a/types/hopscotch/index.d.ts +++ b/types/hopscotch/index.d.ts @@ -4,164 +4,164 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare type CallbackNameNamesOrDefinition = string | string[] | (() => void); -declare type placementTypes = 'top' | 'bottom' | 'right' | 'left'; +declare type placementTypes = "top" | "bottom" | "right" | "left"; interface HopscotchConfiguration { - bubbleWidth?: number | undefined; - buddleHeight?: number | undefined; - - smoothScroll?: boolean | undefined; - scrollDuration?: number | undefined; - scrollTopMargin?: number | undefined; - - showCloseButton?: boolean | undefined; - showNextButton?: boolean | undefined; - showPrevButton?: boolean | undefined; - - arrowWidth?: number | undefined; - skipIfNoElement?: boolean | undefined; - nextOnTargetClick?: boolean | undefined; - - onNext?: CallbackNameNamesOrDefinition | undefined; - onPrev?: CallbackNameNamesOrDefinition | undefined; - onStart?: CallbackNameNamesOrDefinition | undefined; - onEnd?: CallbackNameNamesOrDefinition | undefined; - onClose?: CallbackNameNamesOrDefinition | undefined; - onError?: CallbackNameNamesOrDefinition | undefined; - onShow?: CallbackNameNamesOrDefinition | undefined; - - i18n?: { - nextBtn?: string | undefined; - prevBtn?: string | undefined; - doneBtn?: string | undefined; - skipBtn?: string | undefined; - closeTooltip?: string | undefined; - stepNums?: string[] | undefined; - } | undefined + bubbleWidth?: number | undefined; + buddleHeight?: number | undefined; + + smoothScroll?: boolean | undefined; + scrollDuration?: number | undefined; + scrollTopMargin?: number | undefined; + + showCloseButton?: boolean | undefined; + showNextButton?: boolean | undefined; + showPrevButton?: boolean | undefined; + + arrowWidth?: number | undefined; + skipIfNoElement?: boolean | undefined; + nextOnTargetClick?: boolean | undefined; + + onNext?: CallbackNameNamesOrDefinition | undefined; + onPrev?: CallbackNameNamesOrDefinition | undefined; + onStart?: CallbackNameNamesOrDefinition | undefined; + onEnd?: CallbackNameNamesOrDefinition | undefined; + onClose?: CallbackNameNamesOrDefinition | undefined; + onError?: CallbackNameNamesOrDefinition | undefined; + onShow?: CallbackNameNamesOrDefinition | undefined; + + i18n?: { + nextBtn?: string | undefined; + prevBtn?: string | undefined; + doneBtn?: string | undefined; + skipBtn?: string | undefined; + closeTooltip?: string | undefined; + stepNums?: string[] | undefined; + } | undefined; } interface TourDefinition extends HopscotchConfiguration { - id: string; - steps: StepDefinition[]; + id: string; + steps: StepDefinition[]; } interface StepDefinition { - placement: placementTypes; - target: string | HTMLElement | Array<string | HTMLElement> + placement: placementTypes; + target: string | HTMLElement | Array<string | HTMLElement>; - title?: string | undefined; - content?: string | undefined; + title?: string | undefined; + content?: string | undefined; - width?: number | undefined; - padding?: number | undefined; + width?: number | undefined; + padding?: number | undefined; - xOffset?: number | 'center' | undefined; - yOffset?: number | 'center' | undefined; - arrowOffset?: number | 'center' | undefined; + xOffset?: number | "center" | undefined; + yOffset?: number | "center" | undefined; + arrowOffset?: number | "center" | undefined; - delay?: number | undefined; - zIndex?: number | undefined; + delay?: number | undefined; + zIndex?: number | undefined; - showNextButton?: boolean | undefined; - showPrevButton?: boolean | undefined; - showCTAButton?: boolean | undefined; + showNextButton?: boolean | undefined; + showPrevButton?: boolean | undefined; + showCTAButton?: boolean | undefined; - ctaLabel?: string | undefined; - multipage?: boolean | undefined; - showSkip?: boolean | undefined; - fixedElement?: boolean | undefined; - nextOnTargetClick?: boolean | undefined; + ctaLabel?: string | undefined; + multipage?: boolean | undefined; + showSkip?: boolean | undefined; + fixedElement?: boolean | undefined; + nextOnTargetClick?: boolean | undefined; - onPrev?: CallbackNameNamesOrDefinition | undefined; - onNext?: CallbackNameNamesOrDefinition | undefined; - onShow?: CallbackNameNamesOrDefinition | undefined; - onCTA?: CallbackNameNamesOrDefinition | undefined; + onPrev?: CallbackNameNamesOrDefinition | undefined; + onNext?: CallbackNameNamesOrDefinition | undefined; + onShow?: CallbackNameNamesOrDefinition | undefined; + onCTA?: CallbackNameNamesOrDefinition | undefined; } interface HopscotchStatic { - /** - * Actually starts the tour. Optional stepNum argument specifies what step to start at. - */ - startTour(tour: TourDefinition, stepNum?: number): void; - - /** - * Skips to a given step in the tour - */ - showStep(id: number): void; - - /** - * Goes back one step in the tour - */ - prevStep(): void; - - /** - * Goes forward one step in the tour - */ - nextStep(): void; - - /** - * Ends the current tour. If clearCookie is set to false, the tour state is preserved. - * Otherwise, if clearCookie is set to true or is not provided, the tour state is cleared. - */ - endTour(clearCookie: boolean): void; - - /** - * Sets options for running the tour. - */ - configure(options: HopscotchConfiguration): void; - - /** - * Returns the currently running tour. - */ - getCurrTour(): TourDefinition; - - /** - * Returns the currently running tour. - */ - getCurrStepNum(): number; - - /** - * Checks for tour state saved in sessionStorage/cookies and returns the state if - * it exists. Use this method to determine whether or not you should resume a tour. - */ - getState(): string; - - /** - * Adds a callback for one of the event types. Valid event types are: - * *start*, *end*, *next*, *prev*, *show*, *close*, *error* - */ - listen(eventName: string, callback: () => void): void; - - /** - * Removes a callback for one of the event types. - */ - unlisten(eventName: string, callback: () => void): void; - - /** - * Remove callbacks for hopscotch events. If tourOnly is set to true, only removes - * callbacks specified by a tour (callbacks set by hopscotch.configure or hopscotch.listen - * will remain). If eventName is null or undefined, callbacks for all events will be removed. - */ - removeCallbacks(eventName?: string, tourOnly?: boolean): void; - - /** - * Registers a callback helper. See the section about Helpers below. - */ - registerHelper(id: string, helper: (...args: any[]) => void): void; - - /** - * Resets i18n strings to original default values. - */ - resetDefaultI18N(): void; - - /** - * Resets all config options to original values. - */ - resetDefaultOptions(): void; + /** + * Actually starts the tour. Optional stepNum argument specifies what step to start at. + */ + startTour(tour: TourDefinition, stepNum?: number): void; + + /** + * Skips to a given step in the tour + */ + showStep(id: number): void; + + /** + * Goes back one step in the tour + */ + prevStep(): void; + + /** + * Goes forward one step in the tour + */ + nextStep(): void; + + /** + * Ends the current tour. If clearCookie is set to false, the tour state is preserved. + * Otherwise, if clearCookie is set to true or is not provided, the tour state is cleared. + */ + endTour(clearCookie: boolean): void; + + /** + * Sets options for running the tour. + */ + configure(options: HopscotchConfiguration): void; + + /** + * Returns the currently running tour. + */ + getCurrTour(): TourDefinition; + + /** + * Returns the currently running tour. + */ + getCurrStepNum(): number; + + /** + * Checks for tour state saved in sessionStorage/cookies and returns the state if + * it exists. Use this method to determine whether or not you should resume a tour. + */ + getState(): string; + + /** + * Adds a callback for one of the event types. Valid event types are: + * *start*, *end*, *next*, *prev*, *show*, *close*, *error* + */ + listen(eventName: string, callback: () => void): void; + + /** + * Removes a callback for one of the event types. + */ + unlisten(eventName: string, callback: () => void): void; + + /** + * Remove callbacks for hopscotch events. If tourOnly is set to true, only removes + * callbacks specified by a tour (callbacks set by hopscotch.configure or hopscotch.listen + * will remain). If eventName is null or undefined, callbacks for all events will be removed. + */ + removeCallbacks(eventName?: string, tourOnly?: boolean): void; + + /** + * Registers a callback helper. See the section about Helpers below. + */ + registerHelper(id: string, helper: (...args: any[]) => void): void; + + /** + * Resets i18n strings to original default values. + */ + resetDefaultI18N(): void; + + /** + * Resets all config options to original values. + */ + resetDefaultOptions(): void; } declare var hopscotch: HopscotchStatic; declare module "hopscotch" { - export = hopscotch; + export = hopscotch; } diff --git a/types/host-validation/host-validation-tests.ts b/types/host-validation/host-validation-tests.ts index d842ff18e87970..0ea1332ffb5d66 100644 --- a/types/host-validation/host-validation-tests.ts +++ b/types/host-validation/host-validation-tests.ts @@ -18,56 +18,54 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -import * as express from 'express'; -import * as hostValidation from 'host-validation'; +import * as express from "express"; +import * as hostValidation from "host-validation"; const app = express(); // allow development hosts, a domain name, and a regex for all subdomains // host can accept strings or regular expressions -app.use(hostValidation({ hosts: ['127.0.0.1:3000', - 'localhost:3000', - 'mydomain.com', - /.*\.mydomain\.com/] })); +app.use(hostValidation({ hosts: ["127.0.0.1:3000", "localhost:3000", "mydomain.com", /.*\.mydomain\.com/] })); // referer headers can accept strings or regular expressions -app.use(hostValidation({ referers: ['http://trusted-site.com/login.php', - /^http:\/\/othersite\.com\/login\/.*/] })); +app.use(hostValidation({ referers: ["http://trusted-site.com/login.php", /^http:\/\/othersite\.com\/login\/.*/] })); // only accept POSTs from HTTPS referrers -app.use(hostValidation({ referers: [/^https:\/\//]})); +app.use(hostValidation({ referers: [/^https:\/\//] })); // you can include both host and referer values in the config // by default, only requests that match BOTH Host and Referer values will be allowed -app.use(hostValidation({ hosts: ['trusted-host.com'], - referers: ['https://trusted-host.com/login.php'] })); +app.use(hostValidation({ hosts: ["trusted-host.com"], referers: ["https://trusted-host.com/login.php"] })); // you can use the { mode: 'either' } value in the config accept requests that match // either the hosts or the referers requirements. Accepted values for mode include // 'both' and 'either'. The default value is 'both' if none is specified. -app.use(hostValidation({ hosts: ['trusted-host.com'], - referers: ['https://trusted-host.com/login.php'], - mode: 'either' })); +app.use( + hostValidation({ hosts: ["trusted-host.com"], referers: ["https://trusted-host.com/login.php"], mode: "either" }), +); // route-specific rules can be specified like any Express.js middleware -app.use('/login', hostValidation({ hosts: ['trusted-host.com'] })); -app.use('/from-twitter', hostValidation({ referers: [/^https:\/\/twitter.com\//] })); +app.use("/login", hostValidation({ hosts: ["trusted-host.com"] })); +app.use("/from-twitter", hostValidation({ referers: [/^https:\/\/twitter.com\//] })); // Add a custom error handler that's run when host or referer validation fails. // This function overwrites the default behavior of responding to failed requests // with a 403 Forbidden error. -app.use('/brew-tea', hostValidation({ - hosts: ['office-teapot'], - fail: (req, res, next) => { - // send a 418 "I'm a Teapot" Error - res.status(418).send('I\'m the office teapot. Refer to me only as such.'); - } -})); +app.use( + "/brew-tea", + hostValidation({ + hosts: ["office-teapot"], + fail: (req, res, next) => { + // send a 418 "I'm a Teapot" Error + res.status(418).send("I'm the office teapot. Refer to me only as such."); + }, + }), +); -app.get('/', (req, res) => { - res.send('Hello trusted client, thanks for including 127.0.0.1 in your Host header.'); +app.get("/", (req, res) => { + res.send("Hello trusted client, thanks for including 127.0.0.1 in your Host header."); }); app.listen(3000, () => { - console.log('server allowing HTTP requests from 127.0.0.1 on port 3000'); + console.log("server allowing HTTP requests from 127.0.0.1 on port 3000"); }); diff --git a/types/host-validation/index.d.ts b/types/host-validation/index.d.ts index 2b0ec998798dc2..2d27bee46805e7 100644 --- a/types/host-validation/index.d.ts +++ b/types/host-validation/index.d.ts @@ -4,18 +4,17 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -import { Request, Response, NextFunction } from 'express'; +import { NextFunction, Request, Response } from "express"; declare namespace hostValidation { interface config { - hosts?: Array<string|RegExp> | undefined; - referers?: Array<string|RegExp> | undefined; - mode?: 'both' | 'either' | undefined; + hosts?: Array<string | RegExp> | undefined; + referers?: Array<string | RegExp> | undefined; + mode?: "both" | "either" | undefined; fail?(req: Request, res: Response, next: NextFunction): void; } } -declare function hostValidation(opts: hostValidation.config): - (req: Request, res: Response, next: NextFunction) => void; +declare function hostValidation(opts: hostValidation.config): (req: Request, res: Response, next: NextFunction) => void; export = hostValidation; diff --git a/types/hosted-git-info/hosted-git-info-tests.ts b/types/hosted-git-info/hosted-git-info-tests.ts index 550bbd80e820e1..ee73537b2bf46c 100644 --- a/types/hosted-git-info/hosted-git-info-tests.ts +++ b/types/hosted-git-info/hosted-git-info-tests.ts @@ -1,20 +1,20 @@ -import HostedGitInfo = require('hosted-git-info'); +import HostedGitInfo = require("hosted-git-info"); -HostedGitInfo.fromUrl(''); -HostedGitInfo.fromUrl('', {}); +HostedGitInfo.fromUrl(""); +HostedGitInfo.fromUrl("", {}); -new HostedGitInfo('github', 'DefinitelyTyped', undefined, 'DefinitelyTyped'); +new HostedGitInfo("github", "DefinitelyTyped", undefined, "DefinitelyTyped"); -new HostedGitInfo('github', 'webpack-contrib', undefined, 'copy-webpack-plugin', '40e6ae58', 'https'); +new HostedGitInfo("github", "webpack-contrib", undefined, "copy-webpack-plugin", "40e6ae58", "https"); -const info = new HostedGitInfo('gitlab', 'bagrounds', undefined, 'monad-id', '6d3c759b', 'docs'); +const info = new HostedGitInfo("gitlab", "bagrounds", undefined, "monad-id", "6d3c759b", "docs"); -info.hashformat(''); +info.hashformat(""); info.hash(); info.ssh({}); info.sshurl({}); -info.browse('', '', {}); -info.browse('', {}); +info.browse("", "", {}); +info.browse("", {}); info.browse({}); info.docs({}); info.bugs({}); @@ -23,6 +23,6 @@ info.git({}); info.shortcut({}); info.path({}); info.tarball({}); -info.file('', {}); +info.file("", {}); info.getDefaultRepresentation(); info.toString({}); diff --git a/types/hosted-git-info/index.d.ts b/types/hosted-git-info/index.d.ts index 82dce4970a6fa2..09035710cce3e9 100644 --- a/types/hosted-git-info/index.d.ts +++ b/types/hosted-git-info/index.d.ts @@ -77,21 +77,21 @@ declare namespace GitHost { treepath?: string | undefined; } - type Hosts = 'github' | 'bitbucket' | 'gitlab' | 'gist'; + type Hosts = "github" | "bitbucket" | "gitlab" | "gist"; type Representation = - | 'hash' - | 'ssh' - | 'sshurl' - | 'browse' - | 'docs' - | 'bugs' - | 'https' - | 'git' - | 'shortcut' - | 'path' - | 'tarball' - | 'file'; + | "hash" + | "ssh" + | "sshurl" + | "browse" + | "docs" + | "bugs" + | "https" + | "git" + | "shortcut" + | "path" + | "tarball" + | "file"; } export = GitHost; diff --git a/types/hostile/hostile-tests.ts b/types/hostile/hostile-tests.ts index 1e12346f9fe50a..9a61b84691a5d1 100644 --- a/types/hostile/hostile-tests.ts +++ b/types/hostile/hostile-tests.ts @@ -1,16 +1,16 @@ -import hostile = require('hostile'); +import hostile = require("hostile"); const getLines: hostile.Lines = hostile.get(false); hostile.get(true, (error: Error | null, lines: hostile.Lines) => {}); -const getFileLines: hostile.Lines = hostile.getFile('path/to/hosts', false); +const getFileLines: hostile.Lines = hostile.getFile("path/to/hosts", false); hostile.getFile(hostile.HOSTS, true, (error: Error | null, lines: hostile.Lines) => {}); -hostile.set('192.168.0.1', 'definitelytyped.org'); -hostile.set('192.168.0.1', 'definitelytyped.org', (error: Error | null) => {}); +hostile.set("192.168.0.1", "definitelytyped.org"); +hostile.set("192.168.0.1", "definitelytyped.org", (error: Error | null) => {}); -hostile.remove('192.168.0.1', 'definitelytyped.org'); -hostile.remove('192.168.0.1', 'definitelytyped.org', (error: Error | null) => {}); +hostile.remove("192.168.0.1", "definitelytyped.org"); +hostile.remove("192.168.0.1", "definitelytyped.org", (error: Error | null) => {}); hostile.writeFile(getFileLines, false); hostile.writeFile(getLines, true, (error: Error | null) => {}); diff --git a/types/hostile/index.d.ts b/types/hostile/index.d.ts index c0c1110bb8cf27..5f760613156b66 100644 --- a/types/hostile/index.d.ts +++ b/types/hostile/index.d.ts @@ -3,9 +3,9 @@ // Definitions by: Andrew Leedham <https://github.com/AndrewLeedham> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export const HOSTS: 'C:/Windows/System32/drivers/etc/hosts' | '/etc/hosts'; +export const HOSTS: "C:/Windows/System32/drivers/etc/hosts" | "/etc/hosts"; -export type Line = string | [string /* host */, string /* ip */]; +export type Line = string | [string, /* host */ string /* ip */]; export type Lines = Line[]; export type Callback = (error: Error | null) => void; export type GetCallback = (error: Error | null, lines: Lines) => void; diff --git a/types/hot-formula-parser/hot-formula-parser-tests.ts b/types/hot-formula-parser/hot-formula-parser-tests.ts index 75ac04b2bdf26d..0db486c6721925 100644 --- a/types/hot-formula-parser/hot-formula-parser-tests.ts +++ b/types/hot-formula-parser/hot-formula-parser-tests.ts @@ -1,36 +1,36 @@ import { - Parser, columnIndexToLabel, columnLabelToIndex, error, extractLabel, + Parser, rowIndexToLabel, rowLabelToIndex, toLabel, -} from 'hot-formula-parser/index.mjs'; +} from "hot-formula-parser/index.mjs"; -import p = require('hot-formula-parser'); +import p = require("hot-formula-parser"); // $ExpectType Parser const parser = new Parser(); // $ExpectType { result: string | number | boolean | null; error: FormulaErrorId | null; } -parser.parse('SUM(1, 2)'); +parser.parse("SUM(1, 2)"); // $ExpectType Parser -parser.setFunction('YIELD_5', _ => 5); +parser.setFunction("YIELD_5", _ => 5); // $ExpectType (params: unknown) => unknown -parser.getFunction('YIELD_5'); +parser.getFunction("YIELD_5"); // $ExpectType Parser -parser.setVariable('FOO', 42); +parser.setVariable("FOO", 42); // $ExpectType unknown -parser.getVariable('FOO'); +parser.getVariable("FOO"); // $ExpectType [Coordinate, Coordinate] -extractLabel('A1'); +extractLabel("A1"); // $ExpectType string toLabel({ index: 0, isAbsolute: false }, { index: 1 }); @@ -39,40 +39,40 @@ toLabel({ index: 0, isAbsolute: false }, { index: 1 }); columnIndexToLabel(1); // $ExpectType number -columnLabelToIndex('AA'); +columnLabelToIndex("AA"); // $ExpectType string rowIndexToLabel(1); // $ExpectType number -rowLabelToIndex('2'); +rowLabelToIndex("2"); // $ExpectType FormulaErrorId | null -error('#DIV/0!'); +error("#DIV/0!"); // $ExpectType FormulaErrorId | null -error('DIV/0'); +error("DIV/0"); // $ExpectType Parser const cjsParser = new p.Parser(); // $ExpectType { result: string | number | boolean | null; error: FormulaErrorId | null; } -cjsParser.parse('SUM(1, 2)'); +cjsParser.parse("SUM(1, 2)"); // $ExpectType Parser -cjsParser.setFunction('YIELD_5', _ => 5); +cjsParser.setFunction("YIELD_5", _ => 5); // $ExpectType (params: unknown) => unknown -cjsParser.getFunction('YIELD_5'); +cjsParser.getFunction("YIELD_5"); // $ExpectType Parser -cjsParser.setVariable('FOO', 42); +cjsParser.setVariable("FOO", 42); // $ExpectType unknown -cjsParser.getVariable('FOO'); +cjsParser.getVariable("FOO"); // $ExpectType [Coordinate, Coordinate] -p.extractLabel('A1'); +p.extractLabel("A1"); // $ExpectType string p.toLabel({ index: 0, isAbsolute: false }, { index: 1 }); @@ -81,16 +81,16 @@ p.toLabel({ index: 0, isAbsolute: false }, { index: 1 }); p.columnIndexToLabel(1); // $ExpectType number -p.columnLabelToIndex('AA'); +p.columnLabelToIndex("AA"); // $ExpectType string p.rowIndexToLabel(1); // $ExpectType number -p.rowLabelToIndex('2'); +p.rowLabelToIndex("2"); // $ExpectType FormulaErrorId | null -p.error('#DIV/0!'); +p.error("#DIV/0!"); // $ExpectType FormulaErrorId | null -p.error('DIV/0'); +p.error("DIV/0"); diff --git a/types/hot-formula-parser/index.d.mts b/types/hot-formula-parser/index.d.mts index ee01cc9bd3233f..8e893de15df158 100644 --- a/types/hot-formula-parser/index.d.mts +++ b/types/hot-formula-parser/index.d.mts @@ -1 +1 @@ -export * from './index.js'; +export * from "./index.js"; diff --git a/types/hot-formula-parser/index.d.ts b/types/hot-formula-parser/index.d.ts index d2ea14911d9cf5..a0cb59ce39a5fe 100644 --- a/types/hot-formula-parser/index.d.ts +++ b/types/hot-formula-parser/index.d.ts @@ -24,14 +24,14 @@ export class Parser { * @param hook - hook's name. * @param handler - the callback to produce the side effect. */ - on(hook: 'callVariable', handler: (name: string, done: DoneCallback) => void): void; - on(hook: 'callFunction', handler: (name: string, params: unknown, done: DoneCallback) => void): void; + on(hook: "callVariable", handler: (name: string, done: DoneCallback) => void): void; + on(hook: "callFunction", handler: (name: string, params: unknown, done: DoneCallback) => void): void; on( - hook: 'callCellValue', + hook: "callCellValue", handler: (cellCoord: { row: Coordinate; label: string; column: Coordinate }, done: DoneCallback) => void, ): void; on( - hook: 'callRangeValue', + hook: "callRangeValue", handler: ( startCellCoord: { row: Coordinate; label: string; column: Coordinate }, endCellCoord: { row: Coordinate; label: string; column: Coordinate }, @@ -140,16 +140,16 @@ export function rowIndexToLabel(row: number): string; */ export function rowLabelToIndex(label: string): number; -export const ERROR: 'ERROR'; -export const ERROR_DIV_ZERO: 'DIV/0'; -export const ERROR_NAME: 'NAME'; -export const ERROR_NOT_AVAILABLE: 'N/A'; -export const ERROR_NULL: 'NULL'; -export const ERROR_NUM: 'NUM'; -export const ERROR_REF: 'REF'; -export const ERROR_VALUE: 'VALUE'; +export const ERROR: "ERROR"; +export const ERROR_DIV_ZERO: "DIV/0"; +export const ERROR_NAME: "NAME"; +export const ERROR_NOT_AVAILABLE: "N/A"; +export const ERROR_NULL: "NULL"; +export const ERROR_NUM: "NUM"; +export const ERROR_REF: "REF"; +export const ERROR_VALUE: "VALUE"; -export type FormulaErrorId = '#ERROR!' | '#DIV/0!' | '#NAME?' | '#N/A' | '#NULL!' | '#NUM!' | '#REF!' | '#VALUE!'; +export type FormulaErrorId = "#ERROR!" | "#DIV/0!" | "#NAME?" | "#N/A" | "#NULL!" | "#NUM!" | "#REF!" | "#VALUE!"; export type FormulaErrorType = | typeof ERROR | typeof ERROR_DIV_ZERO @@ -169,389 +169,389 @@ export type FormulaErrorType = export function error(error: FormulaErrorType | FormulaErrorId): FormulaErrorId | null; export const SUPPORTED_FORMULAS: readonly [ - 'ABS', - 'ACCRINT', - 'ACOS', - 'ACOSH', - 'ACOT', - 'ACOTH', - 'ADD', - 'AGGREGATE', - 'AND', - 'ARABIC', - 'ARGS2ARRAY', - 'ASIN', - 'ASINH', - 'ATAN', - 'ATAN2', - 'ATANH', - 'AVEDEV', - 'AVERAGE', - 'AVERAGEA', - 'AVERAGEIF', - 'AVERAGEIFS', - 'BASE', - 'BESSELI', - 'BESSELJ', - 'BESSELK', - 'BESSELY', - 'BETA.DIST', - 'BETA.INV', - 'BETADIST', - 'BETAINV', - 'BIN2DEC', - 'BIN2HEX', - 'BIN2OCT', - 'BINOM.DIST', - 'BINOM.DIST.RANGE', - 'BINOM.INV', - 'BINOMDIST', - 'BITAND', - 'BITLSHIFT', - 'BITOR', - 'BITRSHIFT', - 'BITXOR', - 'CEILING', - 'CEILINGMATH', - 'CEILINGPRECISE', - 'CHAR', - 'CHISQ.DIST', - 'CHISQ.DIST.RT', - 'CHISQ.INV', - 'CHISQ.INV.RT', - 'CHOOSE', - 'CHOOSE', - 'CLEAN', - 'CODE', - 'COLUMN', - 'COLUMNS', - 'COMBIN', - 'COMBINA', - 'COMPLEX', - 'CONCATENATE', - 'CONFIDENCE', - 'CONFIDENCE.NORM', - 'CONFIDENCE.T', - 'CONVERT', - 'CORREL', - 'COS', - 'COSH', - 'COT', - 'COTH', - 'COUNT', - 'COUNTA', - 'COUNTBLANK', - 'COUNTIF', - 'COUNTIFS', - 'COUNTIN', - 'COUNTUNIQUE', - 'COVARIANCE.P', - 'COVARIANCE.S', - 'CSC', - 'CSCH', - 'CUMIPMT', - 'CUMPRINC', - 'DATE', - 'DATEVALUE', - 'DAY', - 'DAYS', - 'DAYS360', - 'DB', - 'DDB', - 'DEC2BIN', - 'DEC2HEX', - 'DEC2OCT', - 'DECIMAL', - 'DEGREES', - 'DELTA', - 'DEVSQ', - 'DIVIDE', - 'DOLLARDE', - 'DOLLARFR', - 'E', - 'EDATE', - 'EFFECT', - 'EOMONTH', - 'EQ', - 'ERF', - 'ERFC', - 'EVEN', - 'EXACT', - 'EXP', - 'EXPON.DIST', - 'EXPONDIST', - 'F.DIST', - 'F.DIST.RT', - 'F.INV', - 'F.INV.RT', - 'FACT', - 'FACTDOUBLE', - 'FALSE', - 'FDIST', - 'FDISTRT', - 'FIND', - 'FINV', - 'FINVRT', - 'FISHER', - 'FISHERINV', - 'FLATTEN', - 'FLOOR', - 'FORECAST', - 'FREQUENCY', - 'FV', - 'FVSCHEDULE', - 'GAMMA', - 'GAMMA.DIST', - 'GAMMA.INV', - 'GAMMADIST', - 'GAMMAINV', - 'GAMMALN', - 'GAMMALN.PRECISE', - 'GAUSS', - 'GCD', - 'GEOMEAN', - 'GESTEP', - 'GROWTH', - 'GTE', - 'HARMEAN', - 'HEX2BIN', - 'HEX2DEC', - 'HEX2OCT', - 'HOUR', - 'HTML2TEXT', - 'HYPGEOM.DIST', - 'HYPGEOMDIST', - 'IF', - 'IMABS', - 'IMAGINARY', - 'IMARGUMENT', - 'IMCONJUGATE', - 'IMCOS', - 'IMCOSH', - 'IMCOT', - 'IMCSC', - 'IMCSCH', - 'IMDIV', - 'IMEXP', - 'IMLN', - 'IMLOG10', - 'IMLOG2', - 'IMPOWER', - 'IMPRODUCT', - 'IMREAL', - 'IMSEC', - 'IMSECH', - 'IMSIN', - 'IMSINH', - 'IMSQRT', - 'IMSUB', - 'IMSUM', - 'IMTAN', - 'INT', - 'INTERCEPT', - 'INTERVAL', - 'IPMT', - 'IRR', - 'ISBINARY', - 'ISBLANK', - 'ISEVEN', - 'ISLOGICAL', - 'ISNONTEXT', - 'ISNUMBER', - 'ISODD', - 'ISODD', - 'ISOWEEKNUM', - 'ISPMT', - 'ISTEXT', - 'JOIN', - 'KURT', - 'LARGE', - 'LCM', - 'LEFT', - 'LEN', - 'LINEST', - 'LN', - 'LOG', - 'LOG10', - 'LOGEST', - 'LOGNORM.DIST', - 'LOGNORM.INV', - 'LOGNORMDIST', - 'LOGNORMINV', - 'LOWER', - 'LT', - 'LTE', - 'MATCH', - 'MAX', - 'MAXA', - 'MEDIAN', - 'MID', - 'MIN', - 'MINA', - 'MINUS', - 'MINUTE', - 'MIRR', - 'MOD', - 'MODE.MULT', - 'MODE.SNGL', - 'MODEMULT', - 'MODESNGL', - 'MONTH', - 'MROUND', - 'MULTINOMIAL', - 'MULTIPLY', - 'NE', - 'NEGBINOM.DIST', - 'NEGBINOMDIST', - 'NETWORKDAYS', - 'NOMINAL', - 'NORM.DIST', - 'NORM.INV', - 'NORM.S.DIST', - 'NORM.S.INV', - 'NORMDIST', - 'NORMINV', - 'NORMSDIST', - 'NORMSINV', - 'NOT', - 'NOW', - 'NPER', - 'NPV', - 'NUMBERS', - 'OCT2BIN', - 'OCT2DEC', - 'OCT2HEX', - 'ODD', - 'OR', - 'PDURATION', - 'PEARSON', - 'PERCENTILEEXC', - 'PERCENTILEINC', - 'PERCENTRANKEXC', - 'PERCENTRANKINC', - 'PERMUT', - 'PERMUTATIONA', - 'PHI', - 'PI', - 'PMT', - 'POISSON.DIST', - 'POISSONDIST', - 'POW', - 'POWER', - 'PPMT', - 'PROB', - 'PRODUCT', - 'PROPER', - 'PV', - 'QUARTILE.EXC', - 'QUARTILE.INC', - 'QUARTILEEXC', - 'QUARTILEINC', - 'QUOTIENT', - 'RADIANS', - 'RAND', - 'RANDBETWEEN', - 'RANK.AVG', - 'RANK.EQ', - 'RANKAVG', - 'RANKEQ', - 'RATE', - 'REFERENCE', - 'REGEXEXTRACT', - 'REGEXMATCH', - 'REGEXREPLACE', - 'REPLACE', - 'REPT', - 'RIGHT', - 'ROMAN', - 'ROUND', - 'ROUNDDOWN', - 'ROUNDUP', - 'ROW', - 'ROWS', - 'RRI', - 'RSQ', - 'SEARCH', - 'SEC', - 'SECH', - 'SECOND', - 'SERIESSUM', - 'SIGN', - 'SIN', - 'SINH', - 'SKEW', - 'SKEW.P', - 'SKEWP', - 'SLN', - 'SLOPE', - 'SMALL', - 'SPLIT', - 'SPLIT', - 'SQRT', - 'SQRTPI', - 'STANDARDIZE', - 'STDEV.P', - 'STDEV.S', - 'STDEVA', - 'STDEVP', - 'STDEVPA', - 'STDEVS', - 'STEYX', - 'SUBSTITUTE', - 'SUBTOTAL', - 'SUM', - 'SUMIF', - 'SUMIFS', - 'SUMPRODUCT', - 'SUMSQ', - 'SUMX2MY2', - 'SUMX2PY2', - 'SUMXMY2', - 'SWITCH', - 'SYD', - 'T', - 'T.DIST', - 'T.DIST.2T', - 'T.DIST.RT', - 'T.INV', - 'T.INV.2T', - 'TAN', - 'TANH', - 'TBILLEQ', - 'TBILLPRICE', - 'TBILLYIELD', - 'TDIST', - 'TDIST2T', - 'TDISTRT', - 'TIME', - 'TIMEVALUE', - 'TINV', - 'TINV2T', - 'TODAY', - 'TRANSPOSE', - 'TREND', - 'TRIM', - 'TRIMMEAN', - 'TRUE', - 'TRUNC', - 'UNICHAR', - 'UNICODE', - 'UNIQUE', - 'UPPER', - 'VAR.P', - 'VAR.S', - 'VARA', - 'VARP', - 'VARPA', - 'VARS', - 'WEEKDAY', - 'WEEKNUM', - 'WEIBULL.DIST', - 'WEIBULLDIST', - 'WORKDAY', - 'XIRR', - 'XNPV', - 'XOR', - 'YEAR', - 'YEARFRAC', + "ABS", + "ACCRINT", + "ACOS", + "ACOSH", + "ACOT", + "ACOTH", + "ADD", + "AGGREGATE", + "AND", + "ARABIC", + "ARGS2ARRAY", + "ASIN", + "ASINH", + "ATAN", + "ATAN2", + "ATANH", + "AVEDEV", + "AVERAGE", + "AVERAGEA", + "AVERAGEIF", + "AVERAGEIFS", + "BASE", + "BESSELI", + "BESSELJ", + "BESSELK", + "BESSELY", + "BETA.DIST", + "BETA.INV", + "BETADIST", + "BETAINV", + "BIN2DEC", + "BIN2HEX", + "BIN2OCT", + "BINOM.DIST", + "BINOM.DIST.RANGE", + "BINOM.INV", + "BINOMDIST", + "BITAND", + "BITLSHIFT", + "BITOR", + "BITRSHIFT", + "BITXOR", + "CEILING", + "CEILINGMATH", + "CEILINGPRECISE", + "CHAR", + "CHISQ.DIST", + "CHISQ.DIST.RT", + "CHISQ.INV", + "CHISQ.INV.RT", + "CHOOSE", + "CHOOSE", + "CLEAN", + "CODE", + "COLUMN", + "COLUMNS", + "COMBIN", + "COMBINA", + "COMPLEX", + "CONCATENATE", + "CONFIDENCE", + "CONFIDENCE.NORM", + "CONFIDENCE.T", + "CONVERT", + "CORREL", + "COS", + "COSH", + "COT", + "COTH", + "COUNT", + "COUNTA", + "COUNTBLANK", + "COUNTIF", + "COUNTIFS", + "COUNTIN", + "COUNTUNIQUE", + "COVARIANCE.P", + "COVARIANCE.S", + "CSC", + "CSCH", + "CUMIPMT", + "CUMPRINC", + "DATE", + "DATEVALUE", + "DAY", + "DAYS", + "DAYS360", + "DB", + "DDB", + "DEC2BIN", + "DEC2HEX", + "DEC2OCT", + "DECIMAL", + "DEGREES", + "DELTA", + "DEVSQ", + "DIVIDE", + "DOLLARDE", + "DOLLARFR", + "E", + "EDATE", + "EFFECT", + "EOMONTH", + "EQ", + "ERF", + "ERFC", + "EVEN", + "EXACT", + "EXP", + "EXPON.DIST", + "EXPONDIST", + "F.DIST", + "F.DIST.RT", + "F.INV", + "F.INV.RT", + "FACT", + "FACTDOUBLE", + "FALSE", + "FDIST", + "FDISTRT", + "FIND", + "FINV", + "FINVRT", + "FISHER", + "FISHERINV", + "FLATTEN", + "FLOOR", + "FORECAST", + "FREQUENCY", + "FV", + "FVSCHEDULE", + "GAMMA", + "GAMMA.DIST", + "GAMMA.INV", + "GAMMADIST", + "GAMMAINV", + "GAMMALN", + "GAMMALN.PRECISE", + "GAUSS", + "GCD", + "GEOMEAN", + "GESTEP", + "GROWTH", + "GTE", + "HARMEAN", + "HEX2BIN", + "HEX2DEC", + "HEX2OCT", + "HOUR", + "HTML2TEXT", + "HYPGEOM.DIST", + "HYPGEOMDIST", + "IF", + "IMABS", + "IMAGINARY", + "IMARGUMENT", + "IMCONJUGATE", + "IMCOS", + "IMCOSH", + "IMCOT", + "IMCSC", + "IMCSCH", + "IMDIV", + "IMEXP", + "IMLN", + "IMLOG10", + "IMLOG2", + "IMPOWER", + "IMPRODUCT", + "IMREAL", + "IMSEC", + "IMSECH", + "IMSIN", + "IMSINH", + "IMSQRT", + "IMSUB", + "IMSUM", + "IMTAN", + "INT", + "INTERCEPT", + "INTERVAL", + "IPMT", + "IRR", + "ISBINARY", + "ISBLANK", + "ISEVEN", + "ISLOGICAL", + "ISNONTEXT", + "ISNUMBER", + "ISODD", + "ISODD", + "ISOWEEKNUM", + "ISPMT", + "ISTEXT", + "JOIN", + "KURT", + "LARGE", + "LCM", + "LEFT", + "LEN", + "LINEST", + "LN", + "LOG", + "LOG10", + "LOGEST", + "LOGNORM.DIST", + "LOGNORM.INV", + "LOGNORMDIST", + "LOGNORMINV", + "LOWER", + "LT", + "LTE", + "MATCH", + "MAX", + "MAXA", + "MEDIAN", + "MID", + "MIN", + "MINA", + "MINUS", + "MINUTE", + "MIRR", + "MOD", + "MODE.MULT", + "MODE.SNGL", + "MODEMULT", + "MODESNGL", + "MONTH", + "MROUND", + "MULTINOMIAL", + "MULTIPLY", + "NE", + "NEGBINOM.DIST", + "NEGBINOMDIST", + "NETWORKDAYS", + "NOMINAL", + "NORM.DIST", + "NORM.INV", + "NORM.S.DIST", + "NORM.S.INV", + "NORMDIST", + "NORMINV", + "NORMSDIST", + "NORMSINV", + "NOT", + "NOW", + "NPER", + "NPV", + "NUMBERS", + "OCT2BIN", + "OCT2DEC", + "OCT2HEX", + "ODD", + "OR", + "PDURATION", + "PEARSON", + "PERCENTILEEXC", + "PERCENTILEINC", + "PERCENTRANKEXC", + "PERCENTRANKINC", + "PERMUT", + "PERMUTATIONA", + "PHI", + "PI", + "PMT", + "POISSON.DIST", + "POISSONDIST", + "POW", + "POWER", + "PPMT", + "PROB", + "PRODUCT", + "PROPER", + "PV", + "QUARTILE.EXC", + "QUARTILE.INC", + "QUARTILEEXC", + "QUARTILEINC", + "QUOTIENT", + "RADIANS", + "RAND", + "RANDBETWEEN", + "RANK.AVG", + "RANK.EQ", + "RANKAVG", + "RANKEQ", + "RATE", + "REFERENCE", + "REGEXEXTRACT", + "REGEXMATCH", + "REGEXREPLACE", + "REPLACE", + "REPT", + "RIGHT", + "ROMAN", + "ROUND", + "ROUNDDOWN", + "ROUNDUP", + "ROW", + "ROWS", + "RRI", + "RSQ", + "SEARCH", + "SEC", + "SECH", + "SECOND", + "SERIESSUM", + "SIGN", + "SIN", + "SINH", + "SKEW", + "SKEW.P", + "SKEWP", + "SLN", + "SLOPE", + "SMALL", + "SPLIT", + "SPLIT", + "SQRT", + "SQRTPI", + "STANDARDIZE", + "STDEV.P", + "STDEV.S", + "STDEVA", + "STDEVP", + "STDEVPA", + "STDEVS", + "STEYX", + "SUBSTITUTE", + "SUBTOTAL", + "SUM", + "SUMIF", + "SUMIFS", + "SUMPRODUCT", + "SUMSQ", + "SUMX2MY2", + "SUMX2PY2", + "SUMXMY2", + "SWITCH", + "SYD", + "T", + "T.DIST", + "T.DIST.2T", + "T.DIST.RT", + "T.INV", + "T.INV.2T", + "TAN", + "TANH", + "TBILLEQ", + "TBILLPRICE", + "TBILLYIELD", + "TDIST", + "TDIST2T", + "TDISTRT", + "TIME", + "TIMEVALUE", + "TINV", + "TINV2T", + "TODAY", + "TRANSPOSE", + "TREND", + "TRIM", + "TRIMMEAN", + "TRUE", + "TRUNC", + "UNICHAR", + "UNICODE", + "UNIQUE", + "UPPER", + "VAR.P", + "VAR.S", + "VARA", + "VARP", + "VARPA", + "VARS", + "WEEKDAY", + "WEEKNUM", + "WEIBULL.DIST", + "WEIBULLDIST", + "WORKDAY", + "XIRR", + "XNPV", + "XOR", + "YEAR", + "YEARFRAC", ]; diff --git a/types/howler/howler-tests.ts b/types/howler/howler-tests.ts index ac924b459fc013..b9cfb8612f63d1 100644 --- a/types/howler/howler-tests.ts +++ b/types/howler/howler-tests.ts @@ -1,28 +1,28 @@ -import './test/globals'; +import "./test/globals"; -import { Howl, Howler } from 'howler'; +import { Howl, Howler } from "howler"; // Set global volume Howler.volume(0.8); const sound1 = new Howl({ - src: ['sound.mp3'], + src: ["sound.mp3"], }); sound1.play(); const sound2 = new Howl({ - src: ['sound.webm', 'sound.mp3', 'sound.wav'], + src: ["sound.webm", "sound.mp3", "sound.wav"], autoplay: true, loop: true, volume: 0.5, - onend: function () { - console.log('Finished!'); + onend: function() { + console.log("Finished!"); }, }); const sound3 = new Howl({ - src: ['sounds.webm', 'sounds.mp3'], + src: ["sounds.webm", "sounds.mp3"], sprite: { blast: [0, 1000], laser: [2000, 3000], @@ -31,24 +31,24 @@ const sound3 = new Howl({ }); // Shoot the laser! -sound3.play('laser'); +sound3.play("laser"); const sound4 = new Howl({ - src: ['sound.webm', 'sound.mp3'], + src: ["sound.webm", "sound.mp3"], }); // Clear listener after first call. -sound4.once('load', function () { +sound4.once("load", function() { sound4.play(); }); // Fires when the sound finishes playing. -sound4.on('end', function () { - console.log('Finished!'); +sound4.on("end", function() { + console.log("Finished!"); }); const sound5 = new Howl({ - src: ['sound.webm', 'sound.mp3'], + src: ["sound.webm", "sound.mp3"], }); // Play returns a unique Sound ID that can be passed @@ -69,4 +69,4 @@ sound5.seek(id1); sound5.seek(id1, 5); // $ExpectType Howl -sound5.off('play', 2); +sound5.off("play", 2); diff --git a/types/howler/index.d.ts b/types/howler/index.d.ts index 28f98d352a09ce..26ef7e928d649c 100644 --- a/types/howler/index.d.ts +++ b/types/howler/index.d.ts @@ -21,9 +21,9 @@ export interface PannerAttributes { coneInnerAngle?: number | undefined; coneOuterAngle?: number | undefined; coneOuterGain?: number | undefined; - distanceModel?: 'inverse' | 'linear'; + distanceModel?: "inverse" | "linear"; maxDistance?: number; - panningModel?: 'HRTF' | 'equalpower'; + panningModel?: "HRTF" | "equalpower"; refDistance?: number; rolloffFactor?: number; } @@ -112,7 +112,7 @@ export interface HowlOptions extends HowlListeners { * download the entire file, for example). * @default true */ - preload?: boolean | 'metadata' | undefined; + preload?: boolean | "metadata" | undefined; /** * Set to true to automatically start playback when sound is loaded. @@ -163,10 +163,10 @@ export interface HowlOptions extends HowlListeners { */ xhr?: | { - method?: string | undefined; - headers?: Record<string, string> | undefined; - withCredentials?: boolean | undefined; - } + method?: string | undefined; + headers?: Record<string, string> | undefined; + withCredentials?: boolean | undefined; + } | undefined; } @@ -197,51 +197,51 @@ export class Howl { playing(id?: number): boolean; duration(id?: number): number; - state(): 'unloaded' | 'loading' | 'loaded'; + state(): "unloaded" | "loading" | "loaded"; load(): this; unload(): null; - on(event: 'load', callback: () => void, id?: number): this; - on(event: 'loaderror' | 'playerror', callback: HowlErrorCallback, id?: number): this; + on(event: "load", callback: () => void, id?: number): this; + on(event: "loaderror" | "playerror", callback: HowlErrorCallback, id?: number): this; on( - event: 'play' | 'end' | 'pause' | 'stop' | 'mute' | 'volume' | 'rate' | 'seek' | 'fade' | 'unlock', + event: "play" | "end" | "pause" | "stop" | "mute" | "volume" | "rate" | "seek" | "fade" | "unlock", callback: HowlCallback, id?: number, ): this; on(event: string, callback: HowlCallback | HowlErrorCallback, id?: number): this; - once(event: 'load', callback: () => void, id?: number): this; - once(event: 'loaderror' | 'playerror', callback: HowlErrorCallback, id?: number): this; + once(event: "load", callback: () => void, id?: number): this; + once(event: "loaderror" | "playerror", callback: HowlErrorCallback, id?: number): this; once( - event: 'play' | 'end' | 'pause' | 'stop' | 'mute' | 'volume' | 'rate' | 'seek' | 'fade' | 'unlock', + event: "play" | "end" | "pause" | "stop" | "mute" | "volume" | "rate" | "seek" | "fade" | "unlock", callback: HowlCallback, id?: number, ): this; once(event: string, callback: HowlCallback | HowlErrorCallback, id?: number): this; - off(event: 'load', callback?: () => void, id?: number): this; - off(event: 'loaderror' | 'playerror', callback?: HowlErrorCallback, id?: number): this; + off(event: "load", callback?: () => void, id?: number): this; + off(event: "loaderror" | "playerror", callback?: HowlErrorCallback, id?: number): this; off( - event: 'play' | 'end' | 'pause' | 'stop' | 'mute' | 'volume' | 'rate' | 'seek' | 'fade' | 'unlock', + event: "play" | "end" | "pause" | "stop" | "mute" | "volume" | "rate" | "seek" | "fade" | "unlock", callback?: HowlCallback, id?: number, ): this; // off() also supports passing id as second argument: internally it is type checked and treated as an id if it is a number off( event: - | 'load' - | 'loaderror' - | 'playerror' - | 'play' - | 'end' - | 'pause' - | 'stop' - | 'mute' - | 'volume' - | 'rate' - | 'seek' - | 'fade' - | 'unlock', + | "load" + | "loaderror" + | "playerror" + | "play" + | "end" + | "pause" + | "stop" + | "mute" + | "volume" + | "rate" + | "seek" + | "fade" + | "unlock", id: number, ): this; off(event?: string, callback?: HowlCallback | HowlErrorCallback, id?: number): this; @@ -285,7 +285,7 @@ export interface HowlerGlobal { orientation(x: number, y?: number, z?: number, xUp?: number, yUp?: number, zUp?: number): this; } -import { Howl as _Howl, HowlerGlobal as _HowlerGlobal } from '.'; +import { Howl as _Howl, HowlerGlobal as _HowlerGlobal } from "."; export { Howler }; declare global { @@ -295,7 +295,7 @@ declare global { var Howl: typeof _Howl; var HowlerGlobal: { prototype: _HowlerGlobal; - new (): _HowlerGlobal; + new(): _HowlerGlobal; }; var Howler: HowlerGlobal; } diff --git a/types/howler/test/globals.ts b/types/howler/test/globals.ts index 376a3d9d9332ba..a17f3cd50d6ec8 100644 --- a/types/howler/test/globals.ts +++ b/types/howler/test/globals.ts @@ -1,12 +1,12 @@ -new globalThis.Howl({ src: 'sound.mp3' }); -new this.Howl({ src: 'sound.mp3' }); -new window.Howl({ src: 'sound.mp3' }); -new Howl({ src: 'sound.mp3' }); +new globalThis.Howl({ src: "sound.mp3" }); +new this.Howl({ src: "sound.mp3" }); +new window.Howl({ src: "sound.mp3" }); +new Howl({ src: "sound.mp3" }); globalThis.Howler.volume(0.8); this.Howler.volume(0.8); window.Howler.volume(0.8); Howler.volume(0.8); -let a: Howl = new globalThis.Howl({ src: 'sound.mp3' }); +let a: Howl = new globalThis.Howl({ src: "sound.mp3" }); let b: HowlerGlobal = globalThis.Howler; diff --git a/types/hoxy/hoxy-tests.ts b/types/hoxy/hoxy-tests.ts index 837424c636657d..91b9037f546c3c 100644 --- a/types/hoxy/hoxy-tests.ts +++ b/types/hoxy/hoxy-tests.ts @@ -1,25 +1,25 @@ -import { createServer } from 'hoxy'; +import { createServer } from "hoxy"; const a = createServer(); // $ExpectType Proxy a.listen(1); // $ExpectType Proxy a.listen(1, () => {}); // $ExpectType Proxy -a.listen(2, '0.0.0.0'); // $ExpectType Proxy -a.listen(2, '0.0.0.0', () => {}); // $ExpectType Proxy +a.listen(2, "0.0.0.0"); // $ExpectType Proxy +a.listen(2, "0.0.0.0", () => {}); // $ExpectType Proxy -a.listen(2, '0.0.0.0', 22); // $ExpectType Proxy -a.listen(3, '0.0.0.0', () => {}); // $ExpectType Proxy +a.listen(2, "0.0.0.0", 22); // $ExpectType Proxy +a.listen(3, "0.0.0.0", () => {}); // $ExpectType Proxy -a.log('error'); // $ExpectType Proxy -a.log('error', process.stderr); // $ExpectType Proxy -a.log('info', log => { +a.log("error"); // $ExpectType Proxy +a.log("error", process.stderr); // $ExpectType Proxy +a.log("info", log => { log; // $ExpectType Log }); a.close(); // $ExpectType void -a.intercept('request', (request, response, cycle) => { +a.intercept("request", (request, response, cycle) => { request; // $ExpectType Request request.protocol; // $ExpectType string request.hostname; // $ExpectType string diff --git a/types/hoxy/index.d.ts b/types/hoxy/index.d.ts index 8648dd3d4db689..8c15959009ea41 100644 --- a/types/hoxy/index.d.ts +++ b/types/hoxy/index.d.ts @@ -3,8 +3,8 @@ // Definitions by: _TrueLecter_ <https://github.com/TrueLecter> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import { Writable } from 'stream'; -import cheerio = require('cheerio'); +import { Writable } from "stream"; +import cheerio = require("cheerio"); /** * Key and certificate to be passed to https.createServer() @@ -85,12 +85,12 @@ export function createServer(opts?: CreateServerOptions): Proxy; /** * Request phase */ -export type Phase = 'request' | 'request-sent' | 'response' | 'response-sent'; +export type Phase = "request" | "request-sent" | "response" | "response-sent"; /** * Body parsers */ -export type BodyParser = '$' | 'json' | 'params' | 'buffer' | 'string'; +export type BodyParser = "$" | "json" | "params" | "buffer" | "string"; export type TesterFunction<T> = (arg: T) => boolean; @@ -176,7 +176,7 @@ export interface InterceptOptions { /** * Request method */ -export type HttpMethod = 'POST' | 'GET' | 'PUT' | 'PATCH' | 'DELETE'; +export type HttpMethod = "POST" | "GET" | "PUT" | "PATCH" | "DELETE"; export class Request { private constructor(); @@ -333,7 +333,7 @@ export class Response { tee(stream: Writable): void; } -export type ServeStrategy = 'replace' | 'overlay' | 'mirror'; +export type ServeStrategy = "replace" | "overlay" | "mirror"; export interface ServeOptions { /** @@ -399,7 +399,7 @@ export class Cycle { export type InterceptionHandler = (this: Proxy, req: Request, res: Response, cycle: Cycle) => Promise<void> | void; -export type LogLevel = 'error' | 'warn' | 'info' | 'debug'; +export type LogLevel = "error" | "warn" | "info" | "debug"; export interface Log { level: LogLevel; diff --git a/types/hpp/hpp-tests.ts b/types/hpp/hpp-tests.ts index 8786ab702de09d..68fb5dfd48277f 100644 --- a/types/hpp/hpp-tests.ts +++ b/types/hpp/hpp-tests.ts @@ -1,5 +1,5 @@ -import express = require('express'); -import hpp = require('hpp'); +import express = require("express"); +import hpp = require("hpp"); const app = express(); @@ -7,11 +7,11 @@ app.use(hpp()); app.use(hpp({ checkBody: true, - checkBodyOnlyForContentType: 'urlencoded', + checkBodyOnlyForContentType: "urlencoded", checkQuery: true, - whitelist: ['foo', 'bar'] + whitelist: ["foo", "bar"], })); app.use(hpp({ - whitelist: 'foobar' + whitelist: "foobar", })); diff --git a/types/hpp/index.d.ts b/types/hpp/index.d.ts index ec136a66f0fd69..fc75559c6245cc 100644 --- a/types/hpp/index.d.ts +++ b/types/hpp/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -import * as express from 'express'; +import * as express from "express"; declare namespace hpp { interface Options { diff --git a/types/hsl-to-hex/hsl-to-hex-tests.ts b/types/hsl-to-hex/hsl-to-hex-tests.ts index 9b29128abf9d24..f21d9ff6aeabd4 100644 --- a/types/hsl-to-hex/hsl-to-hex-tests.ts +++ b/types/hsl-to-hex/hsl-to-hex-tests.ts @@ -1,3 +1,3 @@ -import hslToHex from 'hsl-to-hex'; +import hslToHex from "hsl-to-hex"; hslToHex(100, 100, 50); // $ExpectType string diff --git a/types/hsl-to-rgb-for-reals/hsl-to-rgb-for-reals-tests.ts b/types/hsl-to-rgb-for-reals/hsl-to-rgb-for-reals-tests.ts index d8b942ea67d0f0..1127957fd1eff8 100644 --- a/types/hsl-to-rgb-for-reals/hsl-to-rgb-for-reals-tests.ts +++ b/types/hsl-to-rgb-for-reals/hsl-to-rgb-for-reals-tests.ts @@ -1,3 +1,3 @@ -import hslToRgb = require('hsl-to-rgb-for-reals'); +import hslToRgb = require("hsl-to-rgb-for-reals"); hslToRgb(223, 0.44, 0.56); // $ExpectType [red: number, green: number, blue: number] diff --git a/types/hsl-to-rgb-for-reals/index.d.ts b/types/hsl-to-rgb-for-reals/index.d.ts index 53f27cdd42daf9..acc3f6b2620e25 100644 --- a/types/hsl-to-rgb-for-reals/index.d.ts +++ b/types/hsl-to-rgb-for-reals/index.d.ts @@ -8,5 +8,9 @@ * * e.g. hslToRgb(223, 0.44, 0.56) to [93, 121, 192] */ -declare function hslToRgb(hue: number, saturation: number, lightness: number): [red: number, green: number, blue: number]; +declare function hslToRgb( + hue: number, + saturation: number, + lightness: number, +): [red: number, green: number, blue: number]; export = hslToRgb; diff --git a/types/html-docx-js/html-docx-js-tests.ts b/types/html-docx-js/html-docx-js-tests.ts index e9f4d72f1a2eb5..910c2a142a90dc 100644 --- a/types/html-docx-js/html-docx-js-tests.ts +++ b/types/html-docx-js/html-docx-js-tests.ts @@ -1,4 +1,4 @@ -import { asBlob } from 'html-docx-js'; +import { asBlob } from "html-docx-js"; const html = ` <!DOCTYPE html> @@ -20,16 +20,16 @@ asBlob(1234); // @ts-expect-error asBlob(html, null); // @ts-expect-error -asBlob(html, { orientation: 'invalid' }); +asBlob(html, { orientation: "invalid" }); // @ts-expect-error -asBlob(html, { foo: ['bar'] }); +asBlob(html, { foo: ["bar"] }); // Valid ways to call asBlob(html); // $ExpectType Blob | Buffer asBlob(html, {}); // $ExpectType Blob | Buffer const result1 = asBlob(html, { - orientation: 'landscape', + orientation: "landscape", margins: { top: 100, right: 100, diff --git a/types/html-docx-js/index.d.ts b/types/html-docx-js/index.d.ts index 4a2f057e648b24..e2c4c3ed1ff13a 100644 --- a/types/html-docx-js/index.d.ts +++ b/types/html-docx-js/index.d.ts @@ -22,7 +22,7 @@ export function asBlob( /** * Page orientation. Must be `landscape` or `portrait` (default). */ - orientation?: 'landscape' | 'portrait' | undefined; + orientation?: "landscape" | "portrait" | undefined; /** * A map of margin sizes (expressed in twentieths of point, see * [WordprocessingML documentation](http://officeopenxml.com/WPsectionPgMar.php) diff --git a/types/html-encoding-sniffer/html-encoding-sniffer-tests.ts b/types/html-encoding-sniffer/html-encoding-sniffer-tests.ts index dddc0d6c6cee89..1e92a82f498c3d 100644 --- a/types/html-encoding-sniffer/html-encoding-sniffer-tests.ts +++ b/types/html-encoding-sniffer/html-encoding-sniffer-tests.ts @@ -1,9 +1,9 @@ -import htmlEncodingSniffer = require('html-encoding-sniffer'); +import htmlEncodingSniffer = require("html-encoding-sniffer"); // test type exports type Opts = htmlEncodingSniffer.Options; const bytes = new Uint8Array([1, 2]); htmlEncodingSniffer(bytes); // $ExpectType string -htmlEncodingSniffer(bytes, { defaultEncoding: 'utf-8' }); // $ExpectType string -htmlEncodingSniffer(bytes, { transportLayerEncodingLabel: 'utf-8' }); // $ExpectType string +htmlEncodingSniffer(bytes, { defaultEncoding: "utf-8" }); // $ExpectType string +htmlEncodingSniffer(bytes, { transportLayerEncodingLabel: "utf-8" }); // $ExpectType string diff --git a/types/html-entities-decoder/html-entities-decoder-tests.ts b/types/html-entities-decoder/html-entities-decoder-tests.ts index 25c830d170940a..f36b58e663737a 100644 --- a/types/html-entities-decoder/html-entities-decoder-tests.ts +++ b/types/html-entities-decoder/html-entities-decoder-tests.ts @@ -1,3 +1,3 @@ -import htmlEntitiesDecoder = require('html-entities-decoder'); +import htmlEntitiesDecoder = require("html-entities-decoder"); htmlEntitiesDecoder("1 © 2 ""); // $ExpectType string diff --git a/types/html-entities-decoder/index.d.ts b/types/html-entities-decoder/index.d.ts index dc848aec0155c4..0fc8736be234fe 100644 --- a/types/html-entities-decoder/index.d.ts +++ b/types/html-entities-decoder/index.d.ts @@ -13,6 +13,6 @@ * const input = '1 © 2 "' * const output = decode(input) // 1 © 2 " */ - declare function htmlEntitiesDecoder(str: string): string; +declare function htmlEntitiesDecoder(str: string): string; - export = htmlEntitiesDecoder; +export = htmlEntitiesDecoder; diff --git a/types/html-escape/html-escape-tests.ts b/types/html-escape/html-escape-tests.ts index eb6847d98c512f..1da845dd107b9d 100644 --- a/types/html-escape/html-escape-tests.ts +++ b/types/html-escape/html-escape-tests.ts @@ -1,4 +1,4 @@ -import htmlEscape = require('html-escape'); +import htmlEscape = require("html-escape"); htmlEscape; // $ExpectType (str: string) => string -htmlEscape('foo <bar> baz'); // $ExpectType string +htmlEscape("foo <bar> baz"); // $ExpectType string diff --git a/types/html-escape/v1/html-escape-tests.ts b/types/html-escape/v1/html-escape-tests.ts index eb6847d98c512f..1da845dd107b9d 100644 --- a/types/html-escape/v1/html-escape-tests.ts +++ b/types/html-escape/v1/html-escape-tests.ts @@ -1,4 +1,4 @@ -import htmlEscape = require('html-escape'); +import htmlEscape = require("html-escape"); htmlEscape; // $ExpectType (str: string) => string -htmlEscape('foo <bar> baz'); // $ExpectType string +htmlEscape("foo <bar> baz"); // $ExpectType string diff --git a/types/html-escaper/html-escaper-tests.ts b/types/html-escaper/html-escaper-tests.ts index 92808ad8269f56..6b083e20d614a5 100644 --- a/types/html-escaper/html-escaper-tests.ts +++ b/types/html-escaper/html-escaper-tests.ts @@ -1,4 +1,4 @@ -import { escape, unescape } from 'html-escaper' ; +import { escape, unescape } from "html-escaper"; // $ExpectType string const escaped = escape("<bella>"); diff --git a/types/html-minifier-terser/html-minifier-terser-tests.ts b/types/html-minifier-terser/html-minifier-terser-tests.ts index e8d3d2fabc8c1d..a90741916acd94 100644 --- a/types/html-minifier-terser/html-minifier-terser-tests.ts +++ b/types/html-minifier-terser/html-minifier-terser-tests.ts @@ -1,17 +1,17 @@ -import HtmlMinifier, { minify } from 'html-minifier-terser'; +import HtmlMinifier, { minify } from "html-minifier-terser"; // $ExpectType Promise<string> -HtmlMinifier.minify('<p title="blah" id="moo">foo</p>'); +HtmlMinifier.minify("<p title=\"blah\" id=\"moo\">foo</p>"); (async () => { // $ExpectType string - await HtmlMinifier.minify('<p title="blah" id="moo">foo</p>'); + await HtmlMinifier.minify("<p title=\"blah\" id=\"moo\">foo</p>"); // $ExpectType string - await minify('<p title="blah" id="moo">foo</p>', {}); + await minify("<p title=\"blah\" id=\"moo\">foo</p>", {}); // $ExpectType string - await minify('<p title="blah" id="moo">foo</p>', { + await minify("<p title=\"blah\" id=\"moo\">foo</p>", { caseSensitive: true, collapseBooleanAttributes: true, collapseInlineTagWhitespace: true, @@ -36,8 +36,8 @@ HtmlMinifier.minify('<p title="blah" id="moo">foo</p>'); preserveLineBreaks: true, preventAttributesEscaping: true, processConditionalComments: true, - processScripts: ['text/v-text'], - quoteCharacter: '"', + processScripts: ["text/v-text"], + quoteCharacter: "\"", removeAttributeQuotes: true, removeComments: true, removeEmptyAttributes: true, diff --git a/types/html-minifier/html-minifier-tests.ts b/types/html-minifier/html-minifier-tests.ts index 14847b1d34795e..7385aa6f68cdb8 100644 --- a/types/html-minifier/html-minifier-tests.ts +++ b/types/html-minifier/html-minifier-tests.ts @@ -1,8 +1,8 @@ -import * as HTMLMinifier from 'html-minifier'; +import * as HTMLMinifier from "html-minifier"; const minify = HTMLMinifier.minify; -const result = minify('<p title="blah" id="moo">foo</p>', { - removeAttributeQuotes: true, - continueOnParseError: true, +const result = minify("<p title=\"blah\" id=\"moo\">foo</p>", { + removeAttributeQuotes: true, + continueOnParseError: true, }); result; // '<p title=blah id=moo>foo</p>' diff --git a/types/html-minifier/index.d.ts b/types/html-minifier/index.d.ts index 6ca55121eb3934..9bc1702a0b9796 100644 --- a/types/html-minifier/index.d.ts +++ b/types/html-minifier/index.d.ts @@ -4,9 +4,9 @@ // Piotr Błażejewicz <https://github.com/peterblazejewicz> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import * as UglifyJS from 'uglify-js'; -import * as CleanCSS from 'clean-css'; -import * as RelateUrl from 'relateurl'; +import * as CleanCSS from "clean-css"; +import * as RelateUrl from "relateurl"; +import * as UglifyJS from "uglify-js"; export function minify(text: string, options?: Options): string; diff --git a/types/html-minifier/v1/html-minifier-tests.ts b/types/html-minifier/v1/html-minifier-tests.ts index 4196a870e65388..9333cd0eb8ee00 100644 --- a/types/html-minifier/v1/html-minifier-tests.ts +++ b/types/html-minifier/v1/html-minifier-tests.ts @@ -1,8 +1,7 @@ - -import * as HTMLMinifier from 'html-minifier'; +import * as HTMLMinifier from "html-minifier"; const minify = HTMLMinifier.minify; -var result = minify('<p title="blah" id="moo">foo</p>', { - removeAttributeQuotes: true +var result = minify("<p title=\"blah\" id=\"moo\">foo</p>", { + removeAttributeQuotes: true, }); result; // '<p title=blah id=moo>foo</p>' diff --git a/types/html-minifier/v1/index.d.ts b/types/html-minifier/v1/index.d.ts index 5d65bcf8794426..156972917ffdbb 100644 --- a/types/html-minifier/v1/index.d.ts +++ b/types/html-minifier/v1/index.d.ts @@ -6,9 +6,9 @@ /// <reference types="uglify-js" /> -import * as UglifyJS from 'uglify-js'; -import * as CleanCSS from 'clean-css'; -import * as RelateUrl from 'relateurl'; +import * as CleanCSS from "clean-css"; +import * as RelateUrl from "relateurl"; +import * as UglifyJS from "uglify-js"; declare namespace HTMLMinifier { function minify(text: string, options?: Options): string; diff --git a/types/html-parser/html-parser-tests.ts b/types/html-parser/html-parser-tests.ts index 638b1c76caeeef..f82d7612981990 100644 --- a/types/html-parser/html-parser-tests.ts +++ b/types/html-parser/html-parser-tests.ts @@ -1,4 +1,4 @@ -import { parse, parseFile, sanitize, RegExpOptions, CallbacksOption, Token } from 'html-parser'; +import { CallbacksOption, parse, parseFile, RegExpOptions, sanitize, Token } from "html-parser"; // test data const attributes = (arg: string) => arg; @@ -15,7 +15,7 @@ const cdata = (content: string) => {}; const xmlProlog = () => {}; const text = (value: string) => {}; const emptyRegExpOptions: RegExpOptions = {}; -const filledRegExpOptions: RegExpOptions = {attribute: new RegExp(''), name: new RegExp('')}; +const filledRegExpOptions: RegExpOptions = { attribute: new RegExp(""), name: new RegExp("") }; const emptyCallbackOptions: CallbacksOption = {}; const filled: CallbacksOption = { attribute, @@ -26,20 +26,20 @@ const filled: CallbacksOption = { docType, cdata, xmlProlog, - text + text, }; // parse tests: -parse(''); -parse('', emptyCallbackOptions, emptyRegExpOptions); -parse('', filled, filledRegExpOptions); +parse(""); +parse("", emptyCallbackOptions, emptyRegExpOptions); +parse("", filled, filledRegExpOptions); // parseFile tests: -parseFile('', '', emptyCallbackOptions, attributes); -parseFile('', '', filled, attributes); +parseFile("", "", emptyCallbackOptions, attributes); +parseFile("", "", filled, attributes); // sanitize tests: -sanitize(''); -sanitize('', {attributes: [ 'hello' ], elements: [ 'hi' ], comments: true, docTypes: false}); -sanitize('', {attributes, elements, comments, docTypes }); -sanitize('', { attributes: ['hello'] }); +sanitize(""); +sanitize("", { attributes: ["hello"], elements: ["hi"], comments: true, docTypes: false }); +sanitize("", { attributes, elements, comments, docTypes }); +sanitize("", { attributes: ["hello"] }); diff --git a/types/html-parser/index.d.ts b/types/html-parser/index.d.ts index 0b2da82a77d318..1b5a88d8d495f6 100644 --- a/types/html-parser/index.d.ts +++ b/types/html-parser/index.d.ts @@ -6,7 +6,7 @@ // TypeScript Version: 2.4 export type Callback = (arg: any) => any; -export type Token = '>' | '/>' | '?>'; +export type Token = ">" | "/>" | "?>"; export interface CallbacksOption { attribute?(name: string, value: any): void; @@ -34,6 +34,11 @@ export interface RemovalCallback { export function parse(htmlString: string, callbacks?: CallbacksOption, regex?: RegExpOptions): void; -export function parseFile(fileName: string, encoding: string | undefined, callbacks: CallbacksOption, callback: Callback): void; +export function parseFile( + fileName: string, + encoding: string | undefined, + callbacks: CallbacksOption, + callback: Callback, +): void; export function sanitize(htmlString: string, removalCallbacks?: RemovalCallback): string; diff --git a/types/html-pdf-node/html-pdf-node-tests.ts b/types/html-pdf-node/html-pdf-node-tests.ts index db44c756d02b8b..b52d0bb9ae2ae2 100644 --- a/types/html-pdf-node/html-pdf-node-tests.ts +++ b/types/html-pdf-node/html-pdf-node-tests.ts @@ -1,4 +1,4 @@ -import { generatePdfs, generatePdf } from "html-pdf-node/index"; +import { generatePdf, generatePdfs } from "html-pdf-node/index"; // $ExpectType void generatePdf( @@ -12,7 +12,7 @@ generatePdf( (err, buffer) => { // $ExpectType Buffer buffer; - } + }, ); // $ExpectType void @@ -23,7 +23,7 @@ generatePdfs( }, { content: "<h1>Hello World!</h1>", - } + }, ], { format: "A4", @@ -32,5 +32,5 @@ generatePdfs( (err, buffer) => { // $ExpectType Buffer buffer; - } + }, ); diff --git a/types/html-pdf/html-pdf-tests.ts b/types/html-pdf/html-pdf-tests.ts index 2f6bad3a99ba44..9b2b8c8332d8ae 100644 --- a/types/html-pdf/html-pdf-tests.ts +++ b/types/html-pdf/html-pdf-tests.ts @@ -1,10 +1,10 @@ -import * as fs from 'fs'; -import * as pdf from 'html-pdf'; +import * as fs from "fs"; +import * as pdf from "html-pdf"; -var html = fs.readFileSync('./test/businesscard.html', 'utf8'); -var options: pdf.CreateOptions = { format: 'Letter', localUrlAccess: true }; +var html = fs.readFileSync("./test/businesscard.html", "utf8"); +var options: pdf.CreateOptions = { format: "Letter", localUrlAccess: true }; -pdf.create(html, options).toFile('./businesscard.pdf', (err: Error, res: pdf.FileInfo) => { - if (err) return console.log(err); - console.log(res); // { filename: '/app/businesscard.pdf' } +pdf.create(html, options).toFile("./businesscard.pdf", (err: Error, res: pdf.FileInfo) => { + if (err) return console.log(err); + console.log(res); // { filename: '/app/businesscard.pdf' } }); diff --git a/types/html-pdf/index.d.ts b/types/html-pdf/index.d.ts index fd145e5161230d..b47edb77eefffe 100644 --- a/types/html-pdf/index.d.ts +++ b/types/html-pdf/index.d.ts @@ -5,103 +5,103 @@ /// <reference types="node" /> -declare module 'html-pdf' { - - import * as fs from 'fs'; - - export interface CreateOptions { - - // Export options - directory?: string | undefined; - - // Papersize Options: http://phantomjs.org/api/webpage/property/paper-size.html - height?: string | undefined; - width?: string | undefined; - format?: 'A3' | 'A4' | 'A5' | 'Legal' | 'Letter' | 'Tabloid' | undefined; - orientation?: 'portrait' | 'landscape' | undefined; - - // Page options - border?: string | { - top?: string | undefined; - right?: string | undefined; - bottom?: string | undefined; - left?: string | undefined; - } | undefined; - - paginationOffset?: number | undefined; - - header?: { - height?: string | undefined; - contents?: string | undefined; - } | undefined; - footer?: { - height?: string | undefined; - contents?: { - first?: string | undefined; - [page: number]: string; - default?: string | undefined; - last?: string | undefined; - } | undefined; - } | undefined; - - // Rendering options - base?: string | undefined; - - // Zooming option, can be used to scale images if `options.type` is not pdf - zoomFactor?: string | undefined; - - // File options - type?: 'png' | 'jpeg' | 'pdf' | undefined; - quality?: string | undefined; - - // Script options - phantomPath?: string | undefined; - phantomArgs?: string[] | undefined; - - // Prevent local file:// access by passing '--local-url-access=false' to phantomjs - // For security reasons you should keep the default value if you render - // arbitrary html/js. - // The default is `false` - localUrlAccess?: boolean | undefined; - - script?: string | undefined; - timeout?: number | undefined; - - // Time we should wait after window load - renderDelay?: 'manual' | number | undefined; - - // HTTP Headers that are used for requests - httpHeaders?: { - [header: string]: string; - } | undefined; - - // To run Node application as Windows service - childProcessOptions?: { - detached?: boolean | undefined; - } | undefined; - - // HTTP Cookies that are used for requests - httpCookies?: Array<{ - name: string; - value: string; - domain?: string | undefined; - path: string; - httponly?: boolean | undefined; - secure?: boolean | undefined; - expires?: number | undefined; - }> | undefined; - } - - export interface FileInfo { - filename: string; - } - - export interface CreateResult { - toBuffer(callback: (err: Error, buffer: Buffer) => void): void; - toFile(callback: (err: Error, res: FileInfo) => void): void; - toFile(filename?: string, callback?: (err: Error, res: FileInfo) => void): void; - toStream(callback: (err: Error, stream: fs.ReadStream) => void): void; - } - - export function create(html: string, options?: CreateOptions): CreateResult; +declare module "html-pdf" { + import * as fs from "fs"; + + export interface CreateOptions { + // Export options + directory?: string | undefined; + + // Papersize Options: http://phantomjs.org/api/webpage/property/paper-size.html + height?: string | undefined; + width?: string | undefined; + format?: "A3" | "A4" | "A5" | "Legal" | "Letter" | "Tabloid" | undefined; + orientation?: "portrait" | "landscape" | undefined; + + // Page options + border?: string | { + top?: string | undefined; + right?: string | undefined; + bottom?: string | undefined; + left?: string | undefined; + } | undefined; + + paginationOffset?: number | undefined; + + header?: { + height?: string | undefined; + contents?: string | undefined; + } | undefined; + footer?: { + height?: string | undefined; + contents?: { + first?: string | undefined; + [page: number]: string; + default?: string | undefined; + last?: string | undefined; + } | undefined; + } | undefined; + + // Rendering options + base?: string | undefined; + + // Zooming option, can be used to scale images if `options.type` is not pdf + zoomFactor?: string | undefined; + + // File options + type?: "png" | "jpeg" | "pdf" | undefined; + quality?: string | undefined; + + // Script options + phantomPath?: string | undefined; + phantomArgs?: string[] | undefined; + + // Prevent local file:// access by passing '--local-url-access=false' to phantomjs + // For security reasons you should keep the default value if you render + // arbitrary html/js. + // The default is `false` + localUrlAccess?: boolean | undefined; + + script?: string | undefined; + timeout?: number | undefined; + + // Time we should wait after window load + renderDelay?: "manual" | number | undefined; + + // HTTP Headers that are used for requests + httpHeaders?: { + [header: string]: string; + } | undefined; + + // To run Node application as Windows service + childProcessOptions?: { + detached?: boolean | undefined; + } | undefined; + + // HTTP Cookies that are used for requests + httpCookies?: + | Array<{ + name: string; + value: string; + domain?: string | undefined; + path: string; + httponly?: boolean | undefined; + secure?: boolean | undefined; + expires?: number | undefined; + }> + | undefined; + } + + export interface FileInfo { + filename: string; + } + + export interface CreateResult { + toBuffer(callback: (err: Error, buffer: Buffer) => void): void; + toFile(callback: (err: Error, res: FileInfo) => void): void; + toFile(filename?: string, callback?: (err: Error, res: FileInfo) => void): void; + toStream(callback: (err: Error, stream: fs.ReadStream) => void): void; + } + + export function create(html: string, options?: CreateOptions): CreateResult; } diff --git a/types/html-replace-webpack-plugin/html-replace-webpack-plugin-tests.ts b/types/html-replace-webpack-plugin/html-replace-webpack-plugin-tests.ts index a56a198e0e6af1..66650a7d22a7bb 100644 --- a/types/html-replace-webpack-plugin/html-replace-webpack-plugin-tests.ts +++ b/types/html-replace-webpack-plugin/html-replace-webpack-plugin-tests.ts @@ -1,38 +1,38 @@ -import { Configuration } from 'webpack'; +import { Configuration } from "webpack"; -import HtmlReplaceWebpackPlugin = require('html-replace-webpack-plugin'); +import HtmlReplaceWebpackPlugin = require("html-replace-webpack-plugin"); new HtmlReplaceWebpackPlugin({ - pattern: 'foo', - replacement: '`foo` has been replaced with `bar`', + pattern: "foo", + replacement: "`foo` has been replaced with `bar`", }); const resource: { [type: string]: any } = { - js: { bootstrap: '//cdn/bootstrap/bootstrap.min.js' }, - css: { bootstrap: '//cdn/bootstrap/bootstrap.min.css' }, - img: { 'the-girl': '//cdn/img/the-girl.jpg' }, + js: { bootstrap: "//cdn/bootstrap/bootstrap.min.js" }, + css: { bootstrap: "//cdn/bootstrap/bootstrap.min.css" }, + img: { "the-girl": "//cdn/img/the-girl.jpg" }, }; const tpl: { [type: string]: string } = { - img: '<img src="%s">', - css: '<link rel="stylesheet" type="text/css" href="%s">', - js: '<script type="text/javascript" src="%s"></script>', + img: "<img src=\"%s\">", + css: "<link rel=\"stylesheet\" type=\"text/css\" href=\"%s\">", + js: "<script type=\"text/javascript\" src=\"%s\"></script>", }; const webpackConfiguration: Configuration = { plugins: [ new HtmlReplaceWebpackPlugin([ { - pattern: 'foo', - replacement: '`foo` has been replaced with `bar`', + pattern: "foo", + replacement: "`foo` has been replaced with `bar`", }, { - pattern: '@@title', - replacement: 'html replace webpack plugin', + pattern: "@@title", + replacement: "html replace webpack plugin", }, { pattern: /<p>(.+?)<\/p>/g, // /g => replace all - replacement: '<div>$1</div>', + replacement: "<div>$1</div>", }, { pattern: /(<!--\s*|@@)(css|js|img):([\w-\/]+)(\s*-->)?/g, @@ -47,7 +47,7 @@ const webpackConfiguration: Configuration = { const url = resource[type][file]; // $1==='@@' <--EQ--> $4===undefined - return $4 === undefined ? url : tpl[type].replace('%s', url); + return $4 === undefined ? url : tpl[type].replace("%s", url); }, }, ]), diff --git a/types/html-replace-webpack-plugin/index.d.ts b/types/html-replace-webpack-plugin/index.d.ts index 676bcad4bbced2..f21c4d79e2baf1 100644 --- a/types/html-replace-webpack-plugin/index.d.ts +++ b/types/html-replace-webpack-plugin/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.7 -import { Plugin } from 'webpack'; +import { Plugin } from "webpack"; // Cannot have varargs in the middle of a type, so we need to unfortunately make the rest `any[]` // https://github.com/microsoft/TypeScript/issues/1360 diff --git a/types/html-tableify/html-tableify-tests.ts b/types/html-tableify/html-tableify-tests.ts index 4966c05f8590b9..a1029c9e441829 100644 --- a/types/html-tableify/html-tableify-tests.ts +++ b/types/html-tableify/html-tableify-tests.ts @@ -1,45 +1,45 @@ -import tableify = require('html-tableify'); +import tableify = require("html-tableify"); const html = tableify( [ { - name: 'optionalArray', - description: 'Description of optionalArray.', - required: '', - type: 'array', - defaultValue: '[]', + name: "optionalArray", + description: "Description of optionalArray.", + required: "", + type: "array", + defaultValue: "[]", }, { - name: 'optionalBool', - description: 'Description of optionalBool.', - required: '', - type: 'bool', - defaultValue: 'false', + name: "optionalBool", + description: "Description of optionalBool.", + required: "", + type: "bool", + defaultValue: "false", }, ], { headers: [ { - name: 'name', - align: 'left', - title: 'Your Name', + name: "name", + align: "left", + title: "Your Name", }, { - name: 'description', - align: 'left', + name: "description", + align: "left", }, { - name: 'type', - align: 'left', + name: "type", + align: "left", }, { - name: 'required', - align: 'center', + name: "required", + align: "center", }, { - name: 'defaultValue', - align: 'center', - title: 'Default Value', + name: "defaultValue", + align: "center", + title: "Default Value", }, ], }, @@ -48,18 +48,18 @@ const html = tableify( const html2 = tableify( [ { - name: 'optionalArray', - description: 'Description of optionalArray.', - required: '', - type: 'array', - defaultValue: '[]', + name: "optionalArray", + description: "Description of optionalArray.", + required: "", + type: "array", + defaultValue: "[]", }, { - name: 'optionalBool', - description: 'Description of optionalBool.', - required: '', - type: 'bool', - defaultValue: 'false', + name: "optionalBool", + description: "Description of optionalBool.", + required: "", + type: "bool", + defaultValue: "false", }, ], { diff --git a/types/html-tableify/index.d.ts b/types/html-tableify/index.d.ts index 14fb70a92049ec..4e72898783fd27 100644 --- a/types/html-tableify/index.d.ts +++ b/types/html-tableify/index.d.ts @@ -15,7 +15,7 @@ declare function tableify<T extends keyof any>(data: Array<tableify.Datum<T>>, config?: tableify.Config<T>): string; declare namespace tableify { - type Alignment = 'center' | 'left' | 'right'; + type Alignment = "center" | "left" | "right"; /** Object of optional values for each key `T`. */ type Datum<T extends keyof any> = { diff --git a/types/html-to-draftjs/html-to-draftjs-tests.ts b/types/html-to-draftjs/html-to-draftjs-tests.ts index 967869b1942df7..d5ff9a9e6f8fec 100644 --- a/types/html-to-draftjs/html-to-draftjs-tests.ts +++ b/types/html-to-draftjs/html-to-draftjs-tests.ts @@ -1,7 +1,7 @@ -import htmlToDraft from 'html-to-draftjs'; -import { ContentBlock } from 'draft-js'; +import { ContentBlock } from "draft-js"; +import htmlToDraft from "html-to-draftjs"; -const blocksFromHtml = htmlToDraft('<p>test</p>'); +const blocksFromHtml = htmlToDraft("<p>test</p>"); // $ExpectType ContentBlock[] const contentBlocks = blocksFromHtml.contentBlocks; diff --git a/types/html-to-draftjs/index.d.ts b/types/html-to-draftjs/index.d.ts index d6b176386ace37..38b03f4911c137 100644 --- a/types/html-to-draftjs/index.d.ts +++ b/types/html-to-draftjs/index.d.ts @@ -4,12 +4,13 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.9 -import { ContentBlock, RawDraftEntity } from 'draft-js'; +import { ContentBlock, RawDraftEntity } from "draft-js"; export default function htmlToDraft( text: string, customChunkRenderer?: ( - nodeName: string, node: HTMLElement + nodeName: string, + node: HTMLElement, ) => RawDraftEntity | undefined, ): { contentBlocks: ContentBlock[]; diff --git a/types/html-to-pdfmake/html-to-pdfmake-tests.ts b/types/html-to-pdfmake/html-to-pdfmake-tests.ts index e764ec8631c127..ef0a35d90f522b 100644 --- a/types/html-to-pdfmake/html-to-pdfmake-tests.ts +++ b/types/html-to-pdfmake/html-to-pdfmake-tests.ts @@ -1,5 +1,5 @@ -import { Content } from "pdfmake/interfaces"; import htmlToPdfmake from "html-to-pdfmake"; +import { Content } from "pdfmake/interfaces"; export const validExample: Content = htmlToPdfmake( ` @@ -41,7 +41,7 @@ export const validExample: Content = htmlToPdfmake( }, removeExtraBlanks: true, showhidden: true, - ignoreStyles: ['font-family'], + ignoreStyles: ["font-family"], imagesByReference: true, fontSizes: [1, 2, 3, 4, 5, 6, 7], replaceText: (text: string) => text.replace(/-/g, "\\u2011"), diff --git a/types/html-to-pdfmake/index.d.ts b/types/html-to-pdfmake/index.d.ts index 9960e6f2cdfc3c..62233610bf9085 100644 --- a/types/html-to-pdfmake/index.d.ts +++ b/types/html-to-pdfmake/index.d.ts @@ -15,12 +15,12 @@ declare function htmlToPdfmake( /** * If you use Node, then you'll have to pass the window object */ - window: import('jsdom').DOMWindow; + window: import("jsdom").DOMWindow; /** * You can overwrite the default styles using defaultStyles. * Please, note that the above default styles are stronger than the ones defined in the style classes. */ - defaultStyles: import('pdfmake/interfaces').StyleDictionary; + defaultStyles: import("pdfmake/interfaces").StyleDictionary; /** * In some cases, you may see some extra blank spaces in the PDF. Because removing them could be quite resource consuming, the option is false by default. */ @@ -51,7 +51,7 @@ declare function htmlToPdfmake( * By passing tableAutoSize with true, then the program will try to define widths and heights for the tables, based on CSS properties width and height that have been provided to TH or TD. */ tableAutoSize: boolean; - }> -): import('pdfmake/interfaces').Content; + }>, +): import("pdfmake/interfaces").Content; export = htmlToPdfmake; diff --git a/types/html-to-rtf/html-to-rtf-tests.ts b/types/html-to-rtf/html-to-rtf-tests.ts index a9f2dc22c7a277..0e00fc0e26ac64 100644 --- a/types/html-to-rtf/html-to-rtf-tests.ts +++ b/types/html-to-rtf/html-to-rtf-tests.ts @@ -1,4 +1,4 @@ -import * as htmlToRtf from 'html-to-rtf'; +import * as htmlToRtf from "html-to-rtf"; const html = ` <h1>Title <span style="color:rgb(255,0,0);">with</span> tag h1<h1> @@ -26,4 +26,4 @@ const html = ` </table> </div> `; -htmlToRtf.saveRtfInFile('<Path>/<FileName>.rtf', htmlToRtf.convertHtmlToRtf(html)); +htmlToRtf.saveRtfInFile("<Path>/<FileName>.rtf", htmlToRtf.convertHtmlToRtf(html)); diff --git a/types/html-to-text/html-to-text-tests.ts b/types/html-to-text/html-to-text-tests.ts index dc5ce80ad59940..4924c5aa07e382 100644 --- a/types/html-to-text/html-to-text-tests.ts +++ b/types/html-to-text/html-to-text-tests.ts @@ -1,12 +1,19 @@ -import { compile, FormatCallback, FormatOptions, htmlToText, HtmlToTextOptions, - SelectorDefinition, TagDefinition } from 'html-to-text'; -import { BlockTextBuilder } from 'html-to-text/lib/block-text-builder'; +import { + compile, + FormatCallback, + FormatOptions, + htmlToText, + HtmlToTextOptions, + SelectorDefinition, + TagDefinition, +} from "html-to-text"; +import { BlockTextBuilder } from "html-to-text/lib/block-text-builder"; // Test code that also provides sample implementations -const headerOptions: TagDefinition = { +const headerOptions: TagDefinition = { options: { - uppercase: false + uppercase: false, }, format: "headerFormatter", }; @@ -16,13 +23,13 @@ const headerOptions: TagDefinition = { const options1: HtmlToTextOptions = { baseElements: { selectors: ["a", "h1"], - orderBy: 'selectors', + orderBy: "selectors", returnDomByDefault: true, }, decodeEntities: false, encodeCharacters: { "☺️": ":smiley:", - "😀": ":grinning-face:" + "😀": ":grinning-face:", }, limits: { ellipsis: "...turtles hidden here...", @@ -38,22 +45,22 @@ const options1: HtmlToTextOptions = { preserveNewlines: true, whitespaceCharacters: " abcdef", wordwrap: 80, - }; +}; - const options2: HtmlToTextOptions = { +const options2: HtmlToTextOptions = { baseElements: { - orderBy: 'occurrence', + orderBy: "occurrence", }, wordwrap: false, - }; +}; - const options3: HtmlToTextOptions = { +const options3: HtmlToTextOptions = { wordwrap: null, - }; +}; // FormatOptions coverage -const formatOptions1: FormatOptions = { +const formatOptions1: FormatOptions = { leadingLineBreaks: 3, trailingLineBreaks: 3, baseUrl: "url", @@ -73,10 +80,10 @@ const formatOptions1: FormatOptions = { string: "tag", prefix: "prefix", suffix: "suffix", - "private-option": { data: "some-data"}, + "private-option": { data: "some-data" }, }; -const formatOptions2: FormatOptions = { +const formatOptions2: FormatOptions = { linkBrackets: false, }; @@ -93,7 +100,7 @@ if (0) { builder.addLineBreak(); builder.addWordBreakOpportunity(); builder.addInline("inline", { noWordTransform: true }); - builder.addLiteral('lit'); + builder.addLiteral("lit"); builder.openBlock({ leadingLineBreaks: 2, reservedLineLength: 24, @@ -109,7 +116,7 @@ if (0) { interRowLineBreaks: 2, leadingLineBreaks: 1, }); - builder.openList({ prefixAlign: "right", }); // test alternate value + builder.openList({ prefixAlign: "right" }); // test alternate value builder.openListItem({ prefix: ">>" }); builder.closeListItem(); builder.closeList({ trailingLineBreaks: 2 }); @@ -132,14 +139,14 @@ if (0) { // Test code that also provides sample implementations -const testOptions: FormatOptions = { - uppercase: false +const testOptions: FormatOptions = { + uppercase: false, }; -const headerSelector: SelectorDefinition = { - selector: 'h2', +const headerSelector: SelectorDefinition = { + selector: "h2", options: { - uppercase: false + uppercase: false, }, format: "headerFormatter", }; @@ -149,12 +156,13 @@ const headerSelector: SelectorDefinition = { const headerFormatter: FormatCallback = (elem, walk, builder, options) => { builder.openBlock({ leadingLineBreaks: options.leadingLineBreaks || 2 }); walk(elem.children, builder); - builder.closeBlock({ trailingLineBreaks: options.trailingLineBreaks || 2, + builder.closeBlock({ + trailingLineBreaks: options.trailingLineBreaks || 2, blockTransform: str => { const underline = str.substring(str.lastIndexOf("\n") + 1) .replace(/./g, "="); return `${str}\n${underline}`; - } + }, }); }; @@ -171,8 +179,7 @@ const htmlOptions: HtmlToTextOptions = { builder.openBlock({ leadingLineBreaks: options.leadingLineBreaks || 2 }); walk(elem.children, builder); const trailingLineBreaks = options.trailingLineBreaks || 2; - builder.closeBlock({ trailingLineBreaks, - blockTransform: str => `${str} **hdr**\n` }); + builder.closeBlock({ trailingLineBreaks, blockTransform: str => `${str} **hdr**\n` }); }, blockFormatter: (elem, walk, builder, options) => { const reservedLineLength = 2; @@ -180,11 +187,10 @@ const htmlOptions: HtmlToTextOptions = { builder.openBlock({ leadingLineBreaks, reservedLineLength }); walk(elem.children, builder); const trailingLineBreaks = options.trailingLineBreaks || 2; - builder.closeBlock({ trailingLineBreaks, - blockTransform: str => `**blk** ${str}\n` }); + builder.closeBlock({ trailingLineBreaks, blockTransform: str => `**blk** ${str}\n` }); }, textFormatter: (elem, walk, builder, options) => { - builder.options.formatters['heading'](elem, walk, builder, options); + builder.options.formatters["heading"](elem, walk, builder, options); }, transform: (elem, walk, builder, options) => { builder.pushWordTransform((str) => "transformed"); @@ -197,27 +203,27 @@ const htmlOptions: HtmlToTextOptions = { }, }, selectors: [ - { selector: 'a', + { + selector: "a", options: { - linkBrackets: ['===> ', ' <==='], + linkBrackets: ["===> ", " <==="], hideLinkHrefIfSameAsText: true, }, format: "anchor", }, - { selector: 'h1', - options: testOptions, format: "headerFormatter", }, - { selector: 'h3', - format: "textFormatter", - }, - { selector: 'blockquote', + { selector: "h1", options: testOptions, format: "headerFormatter" }, + { selector: "h3", format: "textFormatter" }, + { + selector: "blockquote", options: { - trimEmptyLines: false + trimEmptyLines: false, }, format: "blockFormatter", }, - { selector: 'p', + { + selector: "p", options: { - trimEmptyLines: false + trimEmptyLines: false, }, format: "transform", }, @@ -227,10 +233,10 @@ const htmlOptions: HtmlToTextOptions = { const htmlString = `<h1>h1</h1><p><b>bold</b></p><p><i>italic</i></p> <h3>h3</h3><blockquote>block quote</blockquote>`; -console.log('\nProcessing string with default options'); +console.log("\nProcessing string with default options"); console.log(htmlToText(htmlString)); -console.log('\nProcessing string with custom options'); +console.log("\nProcessing string with custom options"); const text = htmlToText(htmlString, htmlOptions); console.log(text); @@ -238,7 +244,7 @@ if (!text.match(/\*\*hdr\*\*/)) { console.error("Formatter not called!"); } -const allElements = '<a>a</a>\ +const allElements = "<a>a</a>\ <blockquote>b</blockquote>\ <h1>h</h1>\ <hr />\ @@ -247,15 +253,16 @@ const allElements = '<a>a</a>\ <ol></ol>\ <p>😀 p ☺️</p>\ <table></table>\ -<ul></ul>'; +<ul></ul>"; const elementFormatter: FormatCallback = (elem, walk, builder, options) => { builder.openBlock({ leadingLineBreaks: options.leadingLineBreaks || 2 }); // walk(elem.children?, builder); - builder.closeBlock({ trailingLineBreaks: options.trailingLineBreaks || 2, + builder.closeBlock({ + trailingLineBreaks: options.trailingLineBreaks || 2, blockTransform: str => { return `--${elem.name}--\n`; - } + }, }); }; @@ -274,13 +281,13 @@ const fmtOptions: HtmlToTextOptions = { unorderedList: elementFormatter, }, }; -console.log('\nEmit all elements with "--" wrapping'); +console.log("\nEmit all elements with \"--\" wrapping"); console.log(htmlToText(allElements, fmtOptions)); -const blockTextTestElements = '<a>a</a>\ +const blockTextTestElements = "<a>a</a>\ <blockquote>b</blockquote>\ <p>1234567890123456789012345678901234567890</p>\ -<table></table>'; +<table></table>"; const fmtOptionsTable: HtmlToTextOptions = { formatters: { @@ -288,7 +295,7 @@ const fmtOptionsTable: HtmlToTextOptions = { builder.openBlock({ leadingLineBreaks: options.leadingLineBreaks || 2 }); builder.openTable(); builder.openTableRow(); - builder.openTableCell({ maxColumnWidth: 22}); + builder.openTableCell({ maxColumnWidth: 22 }); builder.addInline("Cell 1 data", { noWordTransform: false }); builder.closeTableCell({ colspan: 2 }); builder.openTableCell({ maxColumnWidth: 6 }); @@ -301,105 +308,105 @@ const fmtOptionsTable: HtmlToTextOptions = { }, }, }; -console.log('\nTest current table builder interfaces'); +console.log("\nTest current table builder interfaces"); console.log(htmlToText(blockTextTestElements, fmtOptionsTable)); const selOptions: HtmlToTextOptions = { decodeEntities: true, encodeCharacters: { - "☺️": ":smiley:", - "😀": ":grinning-face:" + "☺️": ":smiley:", + "😀": ":grinning-face:", }, preserveNewlines: false, formatters: { h1Formatter: (elem, walk, builder, options) => { builder.addInline("preheading: ", { noWordTransform: false }); walk(elem.children, builder); - } + }, }, selectors: [ { selector: "h1", - format: 'h1Formatter', + format: "h1Formatter", }, { selector: "hr", - options: {length: 5}, + options: { length: 5 }, }, - ] + ], }; -console.log('\nTest with selectors'); +console.log("\nTest with selectors"); console.log(htmlToText(allElements, selOptions)); -console.log('\nTest with compiler function'); +console.log("\nTest with compiler function"); const converter = compile(selOptions); console.log(converter(allElements)); -console.log('\nTest with any tag'); +console.log("\nTest with any tag"); console.log(htmlToText("<h1>Starting foo test</h1><foo>bar</foo>", { formatters: { fooFormatter: (elem, walk, builder, options) => { builder.addInline("fooFormatter: ", { noWordTransform: false }); walk(elem.children, builder); - } + }, }, selectors: [ { selector: "foo", - format: 'fooFormatter', + format: "fooFormatter", }, - ] + ], })); -console.log('\nTest with linkBrackets false'); +console.log("\nTest with linkBrackets false"); console.log(htmlToText("<a href=\"https://github.com/DefinitelyTyped\">Link</a>", { selectors: [ { selector: "a", - options: { linkBrackets: false } - } - ] + options: { linkBrackets: false }, + }, + ], })); -console.log('\nTest with custom linkBrackets'); +console.log("\nTest with custom linkBrackets"); console.log(htmlToText("<a href=\"https://github.com/DefinitelyTyped\">Link</a>", { selectors: [ { selector: "a", - options: { linkBrackets: ['@', '@'] } - } - ] + options: { linkBrackets: ["@", "@"] }, + }, + ], })); -console.log('\nTest without linkBrackets'); +console.log("\nTest without linkBrackets"); console.log(htmlToText("<a href=\"https://github.com/DefinitelyTyped\">Link</a>", { selectors: [ { selector: "a", - options: { linkBrackets: undefined } - } - ] + options: { linkBrackets: undefined }, + }, + ], })); -console.log('\nTest with user defined options that should be in output'); +console.log("\nTest with user defined options that should be in output"); console.log(htmlToText("<h1>Starting foo test</h1><foo>bar</foo>", { formatters: { fooFormatter: (elem, walk, builder, options) => { builder.addInline(`beginning ${options.foo} fooFormatter: `, { noWordTransform: false }); walk(elem.children, builder); - } + }, }, selectors: [ { selector: "foo", - format: 'fooFormatter', + format: "fooFormatter", options: { foo: "show-me" }, }, - ] + ], })); -console.log('\nTest list functions'); +console.log("\nTest list functions"); console.log(htmlToText("<h1>Starting list test</h1><my-list><li>first</li><li>second</li></my-list>", { formatters: { listFormatter: (elem, walk, builder, options) => { @@ -407,42 +414,42 @@ console.log(htmlToText("<h1>Starting list test</h1><my-list><li>first</li><li>se const maxPrefixLength = prefix.length; const listItems = (elem.children || []) - .filter(child => child.type !== 'text' || !/^\s*$/.test(child.data || "")) - .map((child) => { - if (child.name !== 'li') { - return { node: child, prefix: '' }; - } - return { node: child, prefix }; - }); - if (!listItems.length) { return; } + .filter(child => child.type !== "text" || !/^\s*$/.test(child.data || "")) + .map((child) => { + if (child.name !== "li") { + return { node: child, prefix: "" }; + } + return { node: child, prefix }; + }); + if (!listItems.length) return; builder.openList({ - interRowLineBreaks: 1, - leadingLineBreaks: options.leadingLineBreaks || 2, - maxPrefixLength, - prefixAlign: 'left' + interRowLineBreaks: 1, + leadingLineBreaks: options.leadingLineBreaks || 2, + maxPrefixLength, + prefixAlign: "left", }); for (const { node, prefix } of listItems) { - builder.openListItem({ prefix }); - walk([node], builder); - builder.closeListItem(); + builder.openListItem({ prefix }); + walk([node], builder); + builder.closeListItem(); } builder.closeList({ trailingLineBreaks: options.trailingLineBreaks || 2 }); - } + }, }, selectors: [ { selector: "h1", options: { - uppercase: false + uppercase: false, }, }, { selector: "my-list", - format: 'listFormatter', + format: "listFormatter", options: { foo: "show-me" }, }, - ] + ], })); diff --git a/types/html-to-text/index.d.ts b/types/html-to-text/index.d.ts index 75b00e5f8ef9e2..1991396c68cdfe 100644 --- a/types/html-to-text/index.d.ts +++ b/types/html-to-text/index.d.ts @@ -5,7 +5,7 @@ // Chris. Webster <https://github.com/webstech> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import { BlockTextBuilder } from './lib/block-text-builder'; +import { BlockTextBuilder } from "./lib/block-text-builder"; export type compiledFunction = (str: string) => string; export type metaData = any; @@ -14,7 +14,7 @@ export type metaData = any; * Preprocess options, compile selectors into a decision tree, * return a function intended for batch processing. */ - export function compile(options?: HtmlToTextOptions): compiledFunction; +export function compile(options?: HtmlToTextOptions): compiledFunction; /** * Convert given HTML content to plain text string. @@ -26,8 +26,7 @@ export type metaData = any; * }); * console.log(text); // HELLO WORLD */ -export function htmlToText(html: string, options?: HtmlToTextOptions, - metadata?: metaData): string; +export function htmlToText(html: string, options?: HtmlToTextOptions, metadata?: metaData): string; export { htmlToText as convert }; export interface HtmlToTextOptions { @@ -103,12 +102,12 @@ export interface HtmlToTextOptions { * @deprecated Use selectors instead. */ tags?: TagDefinitions | undefined; - } +} - /** - * Options for narrowing down to informative parts of HTML document. - */ - export interface BaseElementsOptions { +/** + * Options for narrowing down to informative parts of HTML document. + */ +export interface BaseElementsOptions { /** * The resulting text output will be composed from the text content of elements * matched with these selectors. @@ -122,7 +121,7 @@ export interface HtmlToTextOptions { * * `'occurrence'` - all bases will appear in the same order as in input HTML. */ - orderBy?: 'selectors' | 'occurrence' | undefined; + orderBy?: "selectors" | "occurrence" | undefined; /** * Use the entire document if none of provided selectors matched. */ @@ -183,7 +182,7 @@ export interface LongWordSplitOptions { /** * Describes how to handle tags matched by a selector. */ - export interface SelectorDefinition { +export interface SelectorDefinition { /** * CSS selector. Refer to README for notes on supported selectors etc. */ @@ -316,11 +315,11 @@ export interface FormatOptions { /** * (Only for: `inlineSurround` formatter.) String prefix to be inserted before inline tag contents. */ - prefix?: string | undefined; + prefix?: string | undefined; /** * (Only for: `inlineSurround` formatter.) String suffix to be inserted after inline tag contents. */ - suffix?: string | undefined; + suffix?: string | undefined; /** * User defined values are supported. */ @@ -329,7 +328,7 @@ export interface FormatOptions { * @deprecated Use linkBrackets instead. * (Only for: `anchor` formatter.) Don't print brackets around links. */ - noLinkBrackets?: boolean | undefined; + noLinkBrackets?: boolean | undefined; } /** @@ -368,8 +367,12 @@ export interface DomNode { /** * A function to stringify a DOM node. */ -export type FormatCallback = (elem: DomNode, walk: RecursiveCallback, - builder: BlockTextBuilder, formatOptions: FormatOptions) => void; +export type FormatCallback = ( + elem: DomNode, + walk: RecursiveCallback, + builder: BlockTextBuilder, + formatOptions: FormatOptions, +) => void; /** * A function to process child nodes. @@ -381,7 +384,7 @@ export type RecursiveCallback = (nodes: DomNode[], builder: BlockTextBuilder) => * Type of object passed to tags in the options. */ export interface TagDefinitions { - ''?: TagDefinition | undefined; + ""?: TagDefinition | undefined; a?: TagDefinition | undefined; article?: TagDefinition | undefined; aside?: TagDefinition | undefined; diff --git a/types/html-to-text/lib/block-text-builder.d.ts b/types/html-to-text/lib/block-text-builder.d.ts index b826f46ec49223..0ff05897620c56 100644 --- a/types/html-to-text/lib/block-text-builder.d.ts +++ b/types/html-to-text/lib/block-text-builder.d.ts @@ -1,4 +1,4 @@ -import { FormatCallback } from '../index'; +import { FormatCallback } from "../index"; /** * types of options for BlockTextBuilder methods. These replace previously positional options. */ @@ -154,6 +154,6 @@ export interface BlockTextBuilder { * to the caller. See the test driver for sample usage. */ options: { - formatters: Record<string, FormatCallback>; + formatters: Record<string, FormatCallback>; }; } diff --git a/types/html-truncate/html-truncate-tests.ts b/types/html-truncate/html-truncate-tests.ts index 0086fac36d8595..2ee4fcbfe5c41c 100644 --- a/types/html-truncate/html-truncate-tests.ts +++ b/types/html-truncate/html-truncate-tests.ts @@ -1,19 +1,19 @@ -import Truncate = require('html-truncate'); +import Truncate = require("html-truncate"); -Truncate('hello world', 4); // $ExpectType string +Truncate("hello world", 4); // $ExpectType string // $ExpectType string -Truncate('<p><div>hello world</div></p>', 4, { +Truncate("<p><div>hello world</div></p>", 4, { keepImageTag: true, ellipsis: true, }); // $ExpectType string -Truncate('<p><div>hello world</div></p>', 6, { +Truncate("<p><div>hello world</div></p>", 6, { keepImageTag: false, - ellipsis: '---', + ellipsis: "---", }); -Truncate('a good little fox is <span>a good</span> little forest creature', 26, { truncateLastWord: false }); // $ExpectType string +Truncate("a good little fox is <span>a good</span> little forest creature", 26, { truncateLastWord: false }); // $ExpectType string -Truncate('a good little fox is <span>a good</span> little forest creature', 29, { truncateLastWord: false, slop: 2 }); // $ExpectType string +Truncate("a good little fox is <span>a good</span> little forest creature", 29, { truncateLastWord: false, slop: 2 }); // $ExpectType string diff --git a/types/html-validator/html-validator-tests.ts b/types/html-validator/html-validator-tests.ts index ae27d025d6908c..daf946cbc81e4f 100644 --- a/types/html-validator/html-validator-tests.ts +++ b/types/html-validator/html-validator-tests.ts @@ -1,4 +1,4 @@ -import validateHtml = require('html-validator'); +import validateHtml = require("html-validator"); const testHtml = ` <!DOCTYPE html> @@ -15,9 +15,9 @@ const testHtml = ` validateHtml({ data: testHtml, - format: 'json', + format: "json", headers: { - 'Content-Type': 'text/html' + "Content-Type": "text/html", }, }).then((validationResults: validateHtml.ParsedJsonAsValidationResults) => { if (validationResults.messages.length === 0) { @@ -27,13 +27,13 @@ validateHtml({ validationResults.messages.forEach((violation: validateHtml.ValidationMessageObject) => { switch (violation.type) { - case 'error': + case "error": console.log(`W3C standard violation: ${violation.message}`); break; - case 'info': + case "info": console.warn(`W3C guidelines neglect: ${violation.message}`); break; - case 'non-document-error': + case "non-document-error": console.log(`W3C Non-Document error: ${violation.message}`); break; } diff --git a/types/html-validator/index.d.ts b/types/html-validator/index.d.ts index 8b8d2a79f35686..f2da283ed7ba30 100644 --- a/types/html-validator/index.d.ts +++ b/types/html-validator/index.d.ts @@ -8,14 +8,14 @@ declare function HtmlValidator( options: - HtmlValidator.OptionsForHtmlFileAsValidationTargetAndObjectAsResult | - HtmlValidator.OptionsForExternalUrlAsValidationTargetAndObjectAsResult + | HtmlValidator.OptionsForHtmlFileAsValidationTargetAndObjectAsResult + | HtmlValidator.OptionsForExternalUrlAsValidationTargetAndObjectAsResult, ): Promise<HtmlValidator.ParsedJsonAsValidationResults>; declare function HtmlValidator( options: - HtmlValidator.OptionsForHtmlFileAsValidationTargetAndTextAsResults | - HtmlValidator.OptionsForExternalUrlAsValidationTargetAndTextAsResults + | HtmlValidator.OptionsForHtmlFileAsValidationTargetAndTextAsResults + | HtmlValidator.OptionsForExternalUrlAsValidationTargetAndTextAsResults, ): Promise<string>; declare namespace HtmlValidator { @@ -37,28 +37,28 @@ declare namespace HtmlValidator { // Could be used to avoid string literals enum ValidationResultsOutputFormats { - json = 'json', - html = 'html', - xhtml = 'xhtml', - xml = 'xml', - gnu = 'gnu', - text = 'text', + json = "json", + html = "html", + xhtml = "xhtml", + xml = "xml", + gnu = "gnu", + text = "text", } interface OptionsForHtmlFileAsValidationTargetAndObjectAsResult extends OptionsForHtmlFileAsValidationTarget { - format?: 'json' | undefined; + format?: "json" | undefined; } interface OptionsForHtmlFileAsValidationTargetAndTextAsResults extends OptionsForHtmlFileAsValidationTarget { - format: 'html' | 'xhtml' | 'xml' | 'gnu' | 'text'; + format: "html" | "xhtml" | "xml" | "gnu" | "text"; } interface OptionsForExternalUrlAsValidationTargetAndObjectAsResult extends OptionsForExternalUrlAsValidationTarget { - format?: 'json' | undefined; + format?: "json" | undefined; } interface OptionsForExternalUrlAsValidationTargetAndTextAsResults extends OptionsForHtmlFileAsValidationTarget { - format: 'html' | 'xhtml' | 'xml' | 'gnu' | 'text'; + format: "html" | "xhtml" | "xml" | "gnu" | "text"; } interface ParsedJsonAsValidationResults { @@ -67,18 +67,18 @@ declare namespace HtmlValidator { // Could be used to avoid string literals enum ValidationMessageTypes { - error = 'error', - info = 'info', - 'non-document-error' = 'non-document-error', + error = "error", + info = "info", + "non-document-error" = "non-document-error", } // Could be used to avoid string literals enum ValidationMessageSubTypes { - fatal = 'fatal', - internal = 'internal', - io = 'io', - schema = 'schema', - warning = 'warning', + fatal = "fatal", + internal = "internal", + io = "io", + schema = "schema", + warning = "warning", } interface ValidationMessageBasicObject { @@ -95,21 +95,27 @@ declare namespace HtmlValidator { } interface ValidationMessageBasicErrorObject { - type: 'error'; - subType?: 'fatal' | undefined; + type: "error"; + subType?: "fatal" | undefined; } interface ValidationMessageBasicInfoObject { - type: 'info'; - subType?: 'warning' | undefined; + type: "info"; + subType?: "warning" | undefined; } interface ValidationMessageBasicNonDocumentErrorObject { - type: 'non-document-error'; - subType?: 'internal' | 'io' | 'schema' | undefined; + type: "non-document-error"; + subType?: "internal" | "io" | "schema" | undefined; } - type ValidationMessageSimpleObject = (ValidationMessageBasicErrorObject | ValidationMessageBasicInfoObject | ValidationMessageBasicNonDocumentErrorObject) & ValidationMessageBasicObject; + type ValidationMessageSimpleObject = + & ( + | ValidationMessageBasicErrorObject + | ValidationMessageBasicInfoObject + | ValidationMessageBasicNonDocumentErrorObject + ) + & ValidationMessageBasicObject; type ValidationMessageLocationObject = ValidationMessageSimpleObject & ValidationMessageBasicLocationObject; type ValidationMessageObject = ValidationMessageSimpleObject | ValidationMessageLocationObject; diff --git a/types/html-webpack-plugin/html-webpack-plugin-tests.ts b/types/html-webpack-plugin/html-webpack-plugin-tests.ts index 77a5fff03ed5fb..3e280f09b6d0c1 100644 --- a/types/html-webpack-plugin/html-webpack-plugin-tests.ts +++ b/types/html-webpack-plugin/html-webpack-plugin-tests.ts @@ -1,23 +1,23 @@ -import HtmlWebpackPlugin = require('html-webpack-plugin'); -import { Compiler, compilation } from 'webpack'; +import HtmlWebpackPlugin = require("html-webpack-plugin"); +import { compilation, Compiler } from "webpack"; const plugin = new HtmlWebpackPlugin(); const webpackCompilation: compilation.Compilation = {} as any; -const templateFunction = () => ''; -plugin.evaluateCompilationResult(webpackCompilation, '').then(res => { - if (typeof res === 'function') { +const templateFunction = () => ""; +plugin.evaluateCompilationResult(webpackCompilation, "").then(res => { + if (typeof res === "function") { res({}); } else { res.trim(); } }); plugin.executeTemplate(templateFunction, undefined, undefined, webpackCompilation).then(res => res.trim()); -plugin.postProcessHtml('', undefined, undefined).then(res => res.trim()); +plugin.postProcessHtml("", undefined, undefined).then(res => res.trim()); const optionsArray: HtmlWebpackPlugin.Options[] = [ { - title: 'test', + title: "test", }, { minify: { @@ -30,14 +30,14 @@ const optionsArray: HtmlWebpackPlugin.Options[] = [ }, }, { - arbitrary: 'data', + arbitrary: "data", }, { - chunksSortMode: 'manual', + chunksSortMode: "manual", }, // All default params { - template: 'default_index.ejs', + template: "default_index.ejs", templateParameters: (compilation, assets, options) => { return { compilation, @@ -46,11 +46,11 @@ const optionsArray: HtmlWebpackPlugin.Options[] = [ webpackConfig: {}, htmlWebpackPlugin: { files: assets, - options - } + options, + }, }; }, - filename: 'index.html', + filename: "index.html", hash: false, inject: true, compile: true, @@ -58,78 +58,78 @@ const optionsArray: HtmlWebpackPlugin.Options[] = [ minify: false, cache: true, showErrors: true, - chunks: 'all', + chunks: "all", excludeChunks: [], - chunksSortMode: 'auto', + chunksSortMode: "auto", meta: {}, - title: 'Webpack App', - xhtml: false + title: "Webpack App", + xhtml: false, }, // Config from 'appcache' example { - filename: 'index.html', - template: 'template.html', + filename: "index.html", + template: "template.html", minify: { - removeComments: true, - collapseWhitespace: true - } + removeComments: true, + collapseWhitespace: true, + }, }, // Config from 'custom-template' example { - template: 'template.html' + template: "template.html", }, { - templateContent: false + templateContent: false, }, { - templateContent: '<html></html>' + templateContent: "<html></html>", }, { - templateContent: () => '<html></html>' + templateContent: () => "<html></html>", }, // Config from 'favicon' example { - title: 'HtmlWebpackPlugin example', - favicon: 'favicon.ico', - filename: 'favicon.html' + title: "HtmlWebpackPlugin example", + favicon: "favicon.ico", + filename: "favicon.html", }, // Config from 'inline' example { inject: false, cache: false, - template: 'template.jade', - filename: 'index.html', - favicon: 'favicon.ico', - title: 'Jade demo' + template: "template.jade", + filename: "index.html", + favicon: "favicon.ico", + title: "Jade demo", }, // Config from 'sort-manually' example { inject: true, - filename: 'first-file.html', - template: 'template.html', - chunksSortMode: 'manual', - chunks: ['a', 'b', 'c'] + filename: "first-file.html", + template: "template.html", + chunksSortMode: "manual", + chunks: ["a", "b", "c"], }, // Config from 'template-parameters' example { templateParameters: { - foo: 'bar' + foo: "bar", }, - template: 'index.ejs' - } + template: "index.ejs", + }, ]; const plugins: HtmlWebpackPlugin[] = optionsArray.map(options => new HtmlWebpackPlugin(options)); // Webpack plugin `apply` function function apply(compiler: Compiler) { - compiler.hooks.compilation.tap('SomeWebpackPlugin', (compilation: compilation.Compilation) => { + compiler.hooks.compilation.tap("SomeWebpackPlugin", (compilation: compilation.Compilation) => { (compilation.hooks as HtmlWebpackPlugin.Hooks).htmlWebpackPluginAfterHtmlProcessing.tap( - 'MyPlugin', + "MyPlugin", (data) => { - data.html += 'The Magic Footer'; + data.html += "The Magic Footer"; return data; - } + }, ); }); } diff --git a/types/html-webpack-plugin/index.d.ts b/types/html-webpack-plugin/index.d.ts index f524374c3ea343..e9664ffe3b3d9e 100644 --- a/types/html-webpack-plugin/index.d.ts +++ b/types/html-webpack-plugin/index.d.ts @@ -6,9 +6,9 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.7 -import { Plugin, compilation, Compiler } from 'webpack'; -import { AsyncSeriesWaterfallHook } from 'tapable'; -import { Options as HtmlMinifierOptions } from 'html-minifier'; +import { Options as HtmlMinifierOptions } from "html-minifier"; +import { AsyncSeriesWaterfallHook } from "tapable"; +import { compilation, Compiler, Plugin } from "webpack"; export = HtmlWebpackPlugin; @@ -17,11 +17,19 @@ type TemplateFunction = (param: object) => string; declare class HtmlWebpackPlugin extends Plugin { constructor(options?: HtmlWebpackPlugin.Options); - apply(compiler: Compiler): void; + apply(compiler: Compiler): void; - evaluateCompilationResult(compilation: compilation.Compilation, content: string): Promise<string | TemplateFunction>; + evaluateCompilationResult( + compilation: compilation.Compilation, + content: string, + ): Promise<string | TemplateFunction>; - executeTemplate(templateFunction: TemplateFunction, chunks: any, assets: any, compilation: compilation.Compilation): Promise<string>; + executeTemplate( + templateFunction: TemplateFunction, + chunks: any, + assets: any, + compilation: compilation.Compilation, + ): Promise<string>; postProcessHtml(html: string, assets: any, assetTags: any): Promise<string>; } @@ -55,16 +63,17 @@ declare namespace HtmlWebpackPlugin { * Default: `'auto'`. */ chunksSortMode?: - 'none' - | 'auto' - | 'dependency' - | 'manual' - | ((a: compilation.Chunk, b: compilation.Chunk) => number) | undefined; + | "none" + | "auto" + | "dependency" + | "manual" + | ((a: compilation.Chunk, b: compilation.Chunk) => number) + | undefined; /** * Allows you to add only some chunks (e.g. only the unit-test chunk). * Default: 'all'. */ - chunks?: 'all' | string[] | undefined; + chunks?: "all" | string[] | undefined; /** * Allows you to skip some chunks (e.g. don't add the unit-test chunk). * Default: `[]`. @@ -93,7 +102,7 @@ declare namespace HtmlWebpackPlugin { * 'head' will place the scripts in the head element. * Default: `true`. */ - inject?: 'body' | 'head' | boolean | undefined; + inject?: "body" | "head" | boolean | undefined; /** * Allows to inject meta-tags, e.g. meta: `{viewport: 'width=device-width, initial-scale=1, shrink-to-fit=no'}`. * Default: `{}`. @@ -124,9 +133,10 @@ declare namespace HtmlWebpackPlugin { * Allows to overwrite the parameters used in the template. */ templateParameters?: - false + | false | ((compilation: compilation.Compilation, assets: TemplateParametersAssets, options: Options) => any) - | { [key: string]: any } | undefined; + | { [key: string]: any } + | undefined; /** * The title to use for the generated HTML document. * Default: `'Webpack App'`. diff --git a/types/html-webpack-template/html-webpack-template-tests.ts b/types/html-webpack-template/html-webpack-template-tests.ts index fdf1a369111e5a..782c05412ef2dc 100644 --- a/types/html-webpack-template/html-webpack-template-tests.ts +++ b/types/html-webpack-template/html-webpack-template-tests.ts @@ -1,5 +1,5 @@ -import HtmlWebpackPlugin = require('html-webpack-plugin'); -import * as template from 'html-webpack-template'; +import HtmlWebpackPlugin = require("html-webpack-plugin"); +import * as template from "html-webpack-template"; const optionsArray: template.Options[] = [ { @@ -9,48 +9,48 @@ const optionsArray: template.Options[] = [ // template: 'node_modules/html-webpack-template/index.ejs', /** Optional */ - appMountId: 'app', + appMountId: "app", appMountIds: [ - 'root0', - 'root1', + "root0", + "root1", ], - baseHref: 'http://example.com/awesome', - devServer: 'http://localhost:3001', + baseHref: "http://example.com/awesome", + devServer: "http://localhost:3001", googleAnalytics: { - trackingId: 'UA-XXXX-XX', + trackingId: "UA-XXXX-XX", pageViewOnLoad: true, }, links: [ - 'https://fonts.googleapis.com/css?family=Roboto', + "https://fonts.googleapis.com/css?family=Roboto", { - href: '/apple-touch-icon.png', - rel: 'apple-touch-icon', - sizes: '180x180', + href: "/apple-touch-icon.png", + rel: "apple-touch-icon", + sizes: "180x180", }, { - href: '/favicon-32x32.png', - rel: 'icon', - sizes: '32x32', - type: 'image/png', + href: "/favicon-32x32.png", + rel: "icon", + sizes: "32x32", + type: "image/png", }, ], meta: [ { - description: 'A better default template for html-webpack-plugin.', + description: "A better default template for html-webpack-plugin.", }, ], mobile: true, - inlineManifestWebpackName: 'webpackManifest', + inlineManifestWebpackName: "webpackManifest", scripts: [ - 'http://example.com/somescript.js', + "http://example.com/somescript.js", { - src: '/myModule.js', - type: 'module', + src: "/myModule.js", + type: "module", }, ], window: { env: { - apiHost: 'http://myapi.com/api/v1', + apiHost: "http://myapi.com/api/v1", }, }, @@ -58,7 +58,7 @@ const optionsArray: template.Options[] = [ * And any other config options from html-webpack-plugin: * https://github.com/ampedandwired/html-webpack-plugin#configuration */ - title: 'My App', + title: "My App", }, ]; diff --git a/types/html-webpack-template/index.d.ts b/types/html-webpack-template/index.d.ts index 986dd6e952c9f1..c896a5485897e4 100644 --- a/types/html-webpack-template/index.d.ts +++ b/types/html-webpack-template/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.7 -import { Options as HtmlWebpackPluginOptions } from 'html-webpack-plugin'; +import { Options as HtmlWebpackPluginOptions } from "html-webpack-plugin"; export = HtmlWebpackTemplate; diff --git a/types/html/html-tests.ts b/types/html/html-tests.ts index 3a8e4f2d793f3f..20219d3b1eceb1 100644 --- a/types/html/html-tests.ts +++ b/types/html/html-tests.ts @@ -1,12 +1,12 @@ -import { prettyPrint } from 'html'; +import { prettyPrint } from "html"; -prettyPrint('<h2><strong>Hello, <a href="http://example.com">World</a>!</strong></h2>'); // $ExpectType string -prettyPrint('<h2><strong>Hello, <a href="http://example.com">World</a>!</strong></h2>', {}); // $ExpectType string -prettyPrint('<h2><strong>Hello, <a href="http://example.com">World</a>!</strong></h2>', { - brace_style: 'collapse', - indent_scripts: 'keep', +prettyPrint("<h2><strong>Hello, <a href=\"http://example.com\">World</a>!</strong></h2>"); // $ExpectType string +prettyPrint("<h2><strong>Hello, <a href=\"http://example.com\">World</a>!</strong></h2>", {}); // $ExpectType string +prettyPrint("<h2><strong>Hello, <a href=\"http://example.com\">World</a>!</strong></h2>", { + brace_style: "collapse", + indent_scripts: "keep", indent_size: 2, - indent_char: ' ', + indent_char: " ", max_char: 5, unformatted: [], }); diff --git a/types/html/index.d.ts b/types/html/index.d.ts index 602b4d1f1444a0..8c3f38239b2783 100644 --- a/types/html/index.d.ts +++ b/types/html/index.d.ts @@ -9,9 +9,9 @@ export interface PrintOptions { * or put braces on own line (Allman / ANSI style, `expand`), * or just put end braces on own line (`end-expand`). Default: `collapse`. */ - brace_style?: 'collapse' | 'expand' | 'end-expand' | undefined; + brace_style?: "collapse" | "expand" | "end-expand" | undefined; /** Default: `normal`. */ - indent_scripts?: 'keep' | 'separate' | 'normal' | undefined; + indent_scripts?: "keep" | "separate" | "normal" | undefined; /** indentation size. Default: 4. */ indent_size?: number | undefined; /** character to indent with. Default: " " (space). */ diff --git a/types/html2json/html2json-tests.ts b/types/html2json/html2json-tests.ts index 961d73eec34f3c..223b1a478382a0 100644 --- a/types/html2json/html2json-tests.ts +++ b/types/html2json/html2json-tests.ts @@ -1,19 +1,19 @@ -import { html2json, json2html, Node } from 'html2json'; +import { html2json, json2html, Node } from "html2json"; const json = { - node: 'root', + node: "root", child: [ { - node: 'element', - tag: 'div', + node: "element", + tag: "div", child: [ { - node: 'text', - text: 'this is div', + node: "text", + text: "this is div", }, ], }, ], } as any as Node; -const html = '<div test="test">this is div</div>'; +const html = "<div test=\"test\">this is div</div>"; html2json(html); json2html(json); diff --git a/types/html2json/index.d.ts b/types/html2json/index.d.ts index 323d6f44b1a890..8d710fd0cc1cd2 100644 --- a/types/html2json/index.d.ts +++ b/types/html2json/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export interface Node { - node: 'root' | 'element' | 'text' | 'comment'; + node: "root" | "element" | "text" | "comment"; tag?: string; child?: Node[] | Node; text?: string; diff --git a/types/html4-id/test/html4-id-tests.cjs.ts b/types/html4-id/test/html4-id-tests.cjs.ts index a04c95e052d7bf..c9daf4d4937bb9 100644 --- a/types/html4-id/test/html4-id-tests.cjs.ts +++ b/types/html4-id/test/html4-id-tests.cjs.ts @@ -1,3 +1,3 @@ -import idify = require('html4-id'); +import idify = require("html4-id"); -idify('This is a test!'); // $ExpectType string +idify("This is a test!"); // $ExpectType string diff --git a/types/html4-id/test/html4-id-tests.global.ts b/types/html4-id/test/html4-id-tests.global.ts index 0987f84d9bdf4f..7c6c7ba72e6536 100644 --- a/types/html4-id/test/html4-id-tests.global.ts +++ b/types/html4-id/test/html4-id-tests.global.ts @@ -1 +1 @@ -idify('This is a test!'); // $ExpectType string +idify("This is a test!"); // $ExpectType string diff --git a/types/html5-history/html5-history-tests.ts b/types/html5-history/html5-history-tests.ts index b492e46366bd60..e89413bf8461ba 100644 --- a/types/html5-history/html5-history-tests.ts +++ b/types/html5-history/html5-history-tests.ts @@ -1,4 +1,4 @@ -import * as History from 'html5-history'; +import * as History from "html5-history"; History.init(); History.getState(); diff --git a/types/html5-to-pdf/html5-to-pdf-tests.ts b/types/html5-to-pdf/html5-to-pdf-tests.ts index f089d2686de07c..ef0c7eaf529126 100644 --- a/types/html5-to-pdf/html5-to-pdf-tests.ts +++ b/types/html5-to-pdf/html5-to-pdf-tests.ts @@ -1,6 +1,6 @@ -import HTML5ToPDF = require('html5-to-pdf'); +import HTML5ToPDF = require("html5-to-pdf"); -const options = { inputBody: '<html><body>Hello World</body></html>' }; +const options = { inputBody: "<html><body>Hello World</body></html>" }; const converter = new HTML5ToPDF(options); converter.parseOptions(options); // $ExpectType ParsedOptions converter.build(); // $ExpectType Promise<Buffer> diff --git a/types/html5-to-pdf/index.d.ts b/types/html5-to-pdf/index.d.ts index 5bbec8c4a704d2..5ac5019566cbe9 100644 --- a/types/html5-to-pdf/index.d.ts +++ b/types/html5-to-pdf/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Sam Alexander <https://github.com/samalexander> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import { LaunchOptions, PDFOptions, Page } from 'puppeteer'; +import { LaunchOptions, Page, PDFOptions } from "puppeteer"; declare class HTML5ToPDF { constructor(options: HTML5ToPDF.Options); @@ -24,7 +24,7 @@ declare namespace HTML5ToPDF { /** * File type */ - type: 'css' | 'js'; + type: "css" | "js"; /** * File path */ @@ -46,7 +46,7 @@ declare namespace HTML5ToPDF { * [COMPATIBLE]\ * Page size */ - pageSize?: 'A3' | 'A4' | 'Legal' | 'Tabloid' | undefined; + pageSize?: "A3" | "A4" | "Legal" | "Tabloid" | undefined; /** * [COMPATIBLE]\ * True for landscape, false for portrait. diff --git a/types/html5plus/index.d.ts b/types/html5plus/index.d.ts index 9da629250b2cda..f8aad76789d21a 100644 --- a/types/html5plus/index.d.ts +++ b/types/html5plus/index.d.ts @@ -5,260 +5,260 @@ /** * HTML5+接口,统一浏览器自定义扩展,提供增强的功能、性能扩展规范,使得开发者可开发出跨平台的app,并接近原生的功能和性能。 - * + * * 参考: [http://www.html5plus.org/doc/h5p.html](http://www.html5plus.org/doc/h5p.html) */ declare const plus: Plus; /** * HTML5+接口,统一浏览器自定义扩展,提供增强的功能、性能扩展规范,使得开发者可开发出跨平台的app,并接近原生的功能和性能。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) */ interface Plus { /** * Accelerometer模块管理设备加速度传感器,用于获取设备加速度信息,包括x(屏幕水平方向)、y(垂直屏幕水平方向)、z(垂直屏幕平面方向)三个方向的加速度信息。通过plus.accelerometer获取设备加速度传感器管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) */ accelerometer: PlusAccelerometer; /** * Native.js for Android封装一条通过JS语法直接调用Native Java接口通道,通过plus.android可调用几乎所有的系统API。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) */ android: PlusAndroid; /** * Audio模块用于提供音频的录制和播放功能,可调用系统的麦克风设备进行录音操作,也可调用系统的扬声器设备播放音频文件。通过plus.audio获取音频管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ audio: PlusAudio; /** * Bluetooth模块用于管理蓝牙设备,搜索附近蓝牙设备、连接实现数据通信等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ bluetooth: PlusBluetooth; /** * Camera模块管理设备的摄像头,可用于拍照、摄像操作,通过plus.camera获取摄像头管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) */ camera: PlusCamera; /** * Contacts模块管理系统通讯录,用于可对系统通讯录进行增、删、改、查等操作。通过plus.contacts获取系统通讯录管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ contacts: PlusContacts; /** * Device模块管理设备信息,用于获取手机设备的相关信息,如IMEI、IMSI、型号、厂商等。通过plus.device获取设备信息管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ device: PlusDevice; /** * Screen模块管理设备屏幕信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ screen: PlusScreen; /** * Display模块管理应用可使用的显示区域信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ display: PlusDisplay; /** * networkinfo模块用于获取网络信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ networkinfo: PlusNetworkinfo; /** * OS模块管理操作系统信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ os: PlusOs; /** * Downloader模块管理网络文件下载任务,用于从服务器下载各种文件,并支持跨域访问操作。通过plus.downloader获取下载管理对象。Downloader下载使用HTTP的GET/POST方式请求下载文件,符合标准HTTP/HTTPS传输协议。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ downloader: PlusDownloader; /** * Fingerprint模块管理指纹识别。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) */ fingerprint: PlusFingerprint; /** * Gallery模块管理系统相册,支持从相册中选择图片或视频文件、保存图片或视频文件到相册等功能。通过plus.gallery获取相册管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ gallery: PlusGallery; /** * Geolocation模块管理设备位置信息,用于获取地理位置信息,如经度、纬度等。通过plus.geolocation可获取设备位置管理对象。虽然W3C已经提供标准API获取位置信息,但在某些平台存在差异或未实现,为了保持各平台的统一性,定义此规范接口获取位置信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ geolocation: PlusGeolocation; /** * iBeacon模块用于搜索附件的iBeacon设备(*请使用HBuilderX并更新到最新版本*)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) */ ibeacon: PlusIbeacon; /** * IO模块管理本地文件系统,用于对文件系统的目录浏览、文件的读取、文件的写入等操作。通过plus.io可获取文件系统管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ io: PlusIo; /** * Native.js for iOS封装一条通过JS语法直接调用Native Objective-C接口通道,通过plus.ios可调用几乎所有的系统API。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) */ ios: PlusIos; /** * Key管理设备按键事件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) */ key: PlusKey; /** * Messaging模块管理设备通讯功能,可用于短信、彩信、邮件发送等。通过plus.messaging可获取设备通讯管理对象。另外也可以直接通过html中的href直接快速发送短信、拨打电话、发送邮件等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) */ messaging: PlusMessaging; /** * nativeObj管理系统原生对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ nativeObj: PlusNativeObj; /** * nativeUI管理系统原生界面,可用于弹出系统原生提示对话框窗口、时间日期选择对话框、等待对话框等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ nativeUI: PlusNativeUI; /** * navigator用于管理浏览器运行环境信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ navigator: PlusNavigator; /** * Orientation模块管理设备的方向信息,包括alpha、beta、gamma三个方向信息,通过plus.orientation可获取设备方向管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) */ orientation: PlusOrientation; /** * Proximity模块管理设备距离传感器,可获取当前设备的接近距离信息,通过plus.proximity可获取设备距离传感管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/proximity.html](http://www.html5plus.org/doc/zh_cn/proximity.html) */ proximity: PlusProximity; /** * Runtime模块管理运行环境,可用于获取当前运行环境信息、与其它程序进行通讯等。通过plus.runtime可获取运行环境管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ runtime: PlusRuntime; /** * Storage模块管理应用本地数据存储区,用于应用数据的保存和读取。应用本地数据与localStorage、sessionStorage的区别在于数据有效域不同,前者可在应用内跨域操作,数据存储期是持久化的,并且没有容量限制。通过plus.storage可获取应用本地数据管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/storage.html](http://www.html5plus.org/doc/zh_cn/storage.html) */ storage: PlusStorage; /** * Stream模块操作流应用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ stream: PlusStream; /** * Uploader模块管理网络上传任务,用于从本地上传各种文件到服务器,并支持跨域访问操作。通过plus.uploader可获取上传管理对象。Uploader上传使用HTTP的POST方式提交数据,数据格式符合Multipart/form-data规范,即rfc1867(Form-based File Upload in HTML)协议。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ uploader: PlusUploader; /** * Video模块管理多媒体视频相关能力,可用创建视频播放控件,直播推流控件等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ video: PlusVideo; /** * Webview模块管理应用窗口界面,实现多窗口的逻辑控制管理操作。通过plus.webview可获取应用界面管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ webview: PlusWebview; /** * XMLHttpRequest模块管理网络请求,与标准HTML中的XMLHttpRequest用途一致,差别在于前者可以进行跨域访问。通过plus.net可获取网络请求管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ net: PlusNet; /** * Zip模块管理文件压缩和解压,通过plus.zip可获取压缩管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) */ zip: PlusZip; /** * Barcode模块管理条码扫描,支持常见的条码(一维码及二维码)的扫描识别功能。可调用设备的摄像头对条码图片扫描进行数据输入,解码后返回码数据及码类型。通过plus.barcode可获取条码码管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ barcode: PlusBarcode; /** * Maps模块管理地图控件,用于在web页面中显示地图控件,提供各种接口操作地图控件,如添加标点、路线等。通过plus.maps可获取地图管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ maps: PlusMaps; /** * OAuth模块管理客户端的用户登录授权验证功能,允许应用访问第三方平台的资源。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ oauth: PlusOauth; /** * Payment模块管理支付功能,用于提供网页安全支付能力,支持通过Web接口进行支付操作。通过plus.payment可获取支付管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ payment: PlusPayment; /** * Push模块管理推送消息功能,可以实现在线、离线的消息推送,通过plus.push可获取推送消息管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ push: PlusPush; /** * Share模块管理客户端的社交分享功能,提供调用终端社交软件的分享能力。通过plus.share可获取社交分享管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ share: PlusShare; /** * Speech模块管理语音输入功能,提供语音识别功能,可支持用户通过麦克风设备进行语音输入内容。通过plus.speech可获取语音输入管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) */ speech: PlusSpeech; /** * Statistic模块管理统计功能,用于提供应用内统计的能力,支持统计和分析用户属性和用户行为数据。通过plus.statistic可获取统计管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/statistic.html](http://www.html5plus.org/doc/zh_cn/statistic.html) */ statistic: PlusStatistic; @@ -266,21 +266,21 @@ interface Plus { /** * Accelerometer模块管理设备加速度传感器,用于获取设备加速度信息,包括x(屏幕水平方向)、y(垂直屏幕水平方向)、z(垂直屏幕平面方向)三个方向的加速度信息。通过plus.accelerometer获取设备加速度传感器管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) */ interface PlusAccelerometer { /** * 设备加速度信息对象 * JSON对象,保存获取设备的加速度信息,包括x、y、z三个方向的加速度信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) */ Acceleration?: PlusAccelerometerAcceleration | undefined; /** * 监听设备加速度感应器参数 * JSON对象,用于设置获取设备加速度信息的参数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) */ AccelerometerOption?: PlusAccelerometerAccelerometerOption | undefined; @@ -288,23 +288,30 @@ interface PlusAccelerometer { * 获取当前设备的加速度信息 * 加速度是设备在当前方向上所做相对运动变化(增、减量)的运动传感器。加速度信息包括x、y、z三个方向的信息。 * 加速度信息可通过successCB回调函数返回。加速度信息获取失败则调用回调函数errorCB。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) */ - getCurrentAcceleration(successCB?: (result: PlusAccelerometerAcceleration) => void, errorCB?: (result: any) => void): void; + getCurrentAcceleration( + successCB?: (result: PlusAccelerometerAcceleration) => void, + errorCB?: (result: any) => void, + ): void; /** * 监听设备加速度变化信息 * 加速度是设备在当前方向上所做相对运动变化(增、减量)的运动传感器。加速度信息包括x、y、z三个方向的信息。 * watchAcceleration每隔固定时间就获取一次设备的加速度信息,通过successCB回调函数返回。可通过option的frequency参数设定获取设备加速度信息的时间间隔。 * 加速度信息获取失败则调用回调函数errorCB。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) */ - watchAcceleration(successCB?: (result: PlusAccelerometerAcceleration) => void, errorCB?: (result: any) => void, options?: PlusAccelerometerAccelerometerOption): number; + watchAcceleration( + successCB?: (result: PlusAccelerometerAcceleration) => void, + errorCB?: (result: any) => void, + options?: PlusAccelerometerAccelerometerOption, + ): number; /** * 关闭监听设备加速度信息 * 关闭监听设备加速度信息,应用关闭调用watchAcceleration方法的开启的监听操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) */ clearWatch(watchId?: number): void; @@ -313,28 +320,28 @@ interface PlusAccelerometer { /** * 设备加速度信息对象 * JSON对象,保存获取设备的加速度信息,包括x、y、z三个方向的加速度信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) */ interface PlusAccelerometerAcceleration { /** * x轴方向的加速度 * 获取当前设备x轴方向的加速度,浮点型数据,与物理学中的加速度值一致。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) */ xAxis?: number | undefined; /** * y轴方向的加速度 * 获取当前设备y轴方向的加速度,浮点型数据,与物理学中的加速度值一致。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) */ yAxis?: number | undefined; /** * z轴方向的加速度 * 获取当前设备z轴方向的加速度,浮点型数据,与物理学中的加速度值一致。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) */ zAxis?: number | undefined; @@ -343,14 +350,14 @@ interface PlusAccelerometerAcceleration { /** * 监听设备加速度感应器参数 * JSON对象,用于设置获取设备加速度信息的参数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) */ interface PlusAccelerometerAccelerometerOption { /** * 更新加速度信息间隔时间 * 监听器获取加速度信息的时间间隔,单位为ms,默认值为500ms - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/accelerometer.html](http://www.html5plus.org/doc/zh_cn/accelerometer.html) */ frequency?: number | undefined; @@ -358,7 +365,7 @@ interface PlusAccelerometerAccelerometerOption { /** * Native.js for Android封装一条通过JS语法直接调用Native Java接口通道,通过plus.android可调用几乎所有的系统API。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) */ interface PlusAndroid { @@ -366,7 +373,7 @@ interface PlusAndroid { * Java类对象 * Java类对象,可通过其属性获取类的常量,可通过方法来操作类的静态变量和方法,也通过new方法来创建类的实例对象。 * 对于类的常量,则直接通过.后面跟随常量名称调用即可。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) */ ClassObject?: PlusAndroidClassObject | undefined; @@ -374,7 +381,7 @@ interface PlusAndroid { * Java实例对象 * Java实例对象,可通过其方法来操作实例的变量和方法。 * 注意:必须通过plusGetAttribute()方法读取实例对象的属性值,通过plusSetAttribute()方法设置实例对象的属性值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) */ InstanceObject?: PlusAndroidInstanceObject | undefined; @@ -382,51 +389,51 @@ interface PlusAndroid { * 导入Java类对象 * 导入类对象后,就可以通过.操作符直接调用对象(类对象/实例对象)的方法。 * 注意:导入类对象将会消耗较多的系统资源,通常不应该导入过多的类对象,可以使用plus.android.invoke()来调用未导入类实例对象的方法。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) */ importClass(classname?: string): PlusAndroidClassObject; /** * 创建实例对象 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) */ newObject(classname?: string, args?: any): PlusAndroidInstanceObject; /** * 获取对象(类对象/实例对象)的属性值 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) */ getAttribute(obj?: PlusAndroidInstanceObject, name?: string): any; /** * 设置对象(类对象/实例对象)的属性值 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) */ setAttribute(obj?: PlusAndroidInstanceObject, name?: string, value?: any): void; /** * 调用对象(类对象/实例对象)的方法 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) */ invoke(obj?: PlusAndroidInstanceObject, name?: string, args?: any): any; /** * 实现Interface的方法 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) */ implements(name?: string, obj?: any): PlusAndroidInstanceObject; /** * 获取应用主Activity实例对象 * Android平台完整Java类名为android.app.Activity,完整API请参考Android开发文档 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) */ runtimeMainActivity(): PlusAndroidInstanceObject; /** * 获取当前Webview窗口对象的native层实例对象 * Android平台完整Java类名为android.webkit.Webview,完整API请参考Android开发文档 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) */ currentWebview(): PlusAndroidInstanceObject; @@ -436,19 +443,19 @@ interface PlusAndroid { * Java类对象 * Java类对象,可通过其属性获取类的常量,可通过方法来操作类的静态变量和方法,也通过new方法来创建类的实例对象。 * 对于类的常量,则直接通过.后面跟随常量名称调用即可。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) */ interface PlusAndroidClassObject { /** * 获取Java类对象的静态属性 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) */ plusGetAttribute(name?: string): any; /** * 设置Java类对象的静态属性 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) */ plusSetAttribute(name?: string, value?: any): void; @@ -458,19 +465,19 @@ interface PlusAndroidClassObject { * Java实例对象 * Java实例对象,可通过其方法来操作实例的变量和方法。 * 注意:必须通过plusGetAttribute()方法读取实例对象的属性值,通过plusSetAttribute()方法设置实例对象的属性值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) */ interface PlusAndroidInstanceObject { /** * 获取Java实例对象的属性 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) */ plusGetAttribute(name?: string): any; /** * 设置Java实例对象的属性 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/android.html](http://www.html5plus.org/doc/zh_cn/android.html) */ plusSetAttribute(name?: string, value?: any): void; @@ -478,47 +485,47 @@ interface PlusAndroidInstanceObject { /** * Audio模块用于提供音频的录制和播放功能,可调用系统的麦克风设备进行录音操作,也可调用系统的扬声器设备播放音频文件。通过plus.audio获取音频管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ interface PlusAudio { /** * 录音对象 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ AudioRecorder?: PlusAudioAudioRecorder | undefined; /** * 音频播放对象 * 音频播放对象,用于音频文件的播放。不能通过new方法直接创建,只能通过audio.createPlayer方法创建。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ AudioPlayer?: PlusAudioAudioPlayer | undefined; /** * JSON对象,调用麦克风设备进行录音的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ RecordOptions?: PlusAudioRecordOptions | undefined; /** * 设备的扬声器音频输出线路 * 音频输出线路常量,值为0。音频播放时在设备的扬声器输出。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ ROUTE_SPEAKER?: number | undefined; /** * 设备听筒音频输出线路 * 音频输出线路常量,值为1。音频播放时在设备的听筒输出。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ ROUTE_EARPIECE?: number | undefined; /** * 获取当前设备的录音对象 * 获取当前设备的录音对象,进行录音操作,录音对象是设备的独占资源,在同一时间仅可执行一个录音操作,否则可能会导致操作失败。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ getRecorder(): PlusAudioAudioRecorder; @@ -526,7 +533,7 @@ interface PlusAudio { * 创建音频播放对象 * 创建一个音频文件播放对象,用于打开音频文件并播放。 * 可通过path参数指定要播放的音频文件。创建后返回播放对象,通过Audio.play方法开始播放。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ createPlayer(path?: string): PlusAudioAudioPlayer; @@ -534,35 +541,39 @@ interface PlusAudio { /** * 录音对象 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ interface PlusAudioAudioRecorder { /** * 数组,设备录音支持的采用率 * 属性类型为Array(String),若不支持此属性则返回空数组对象。支持的录音采样率,字符串格式为“采样频率”,如“8000”;其单位为Hz。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ supportedSamplerates?: string | undefined; /** * 数组,设备录音支持的文件格式 * 属性类型为Array(String),若不支持此属性则返回空数组对象。支持的录音文件的格式,字符串格式为文件格式后缀名,如"mp3"、"aac"、"wav"等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ supportedFormats?: string | undefined; /** * 调用设备麦克风进行录音操作 * 调用设备麦克风开始录音操作,录音完成需调用stop方法停止。录音完成后将通过successCB回调返回录音后的文件数据。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ - record(option?: PlusAudioRecordOptions, successCB?: (result: string) => void, errorCB?: (result: any) => void): void; + record( + option?: PlusAudioRecordOptions, + successCB?: (result: string) => void, + errorCB?: (result: any) => void, + ): void; /** * 结束录音操作 * 结束录音操作,通知设备完成录音操作。录音完成后将调用record方法中传入的successCB回调返回录音文件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ stop(): void; @@ -571,27 +582,27 @@ interface PlusAudioAudioRecorder { /** * 音频播放对象 * 音频播放对象,用于音频文件的播放。不能通过new方法直接创建,只能通过audio.createPlayer方法创建。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ interface PlusAudioAudioPlayer { /** * 开始播放音频 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ play(successCB?: () => void, errorCB?: (result: any) => void): void; /** * 暂停播放音频 * 需先调用createPlayer方法创建音频播放对象,并开始播放。音频播放对象在播放状态才能暂停,在其它状态调用此方法无任何作用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ pause(): void; /** * 恢复播放音频 * 音频播放对象在暂停状态才能恢复播放,在其它状态调用此方法无任何作用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ resume(): void; @@ -599,35 +610,35 @@ interface PlusAudioAudioPlayer { * 停止播放音频 * 停止播放音频,音频播放对象在播放或暂停状态才能停止播放,在其它状态调用此方法无任何作用。 * 停止播放后如果需要继续播放,则需调用play方法重新开始播放。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ stop(): void; /** * 跳到指定位置播放音频 * 跳到指定位置播放音频,音频播放对象在播放或暂停状态才能跳到指定播放音频,在其它状态调用此方法无任何作用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ seekTo(position?: number): void; /** * 获取音频流的总长度 * 获取音频流的总长度,单位为秒,若长度未知则返回-1。如果还未获取到音频流信息则返回NaN,此时需要延迟获取此信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ getDuration(): number; /** * 获取音频流当前播放的位置 * 获取音频流当前播放的位置(已播放的长度),单位为s。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ getPosition(): number; /** * 设置音频输出线路 * 可在音频文件开始播放前或播放的过程中改变音频输出线路,默认使用扬声器(plus.audio.ROUTE_SPEAKER)输出线路。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ setRoute(route?: number): void; @@ -635,7 +646,7 @@ interface PlusAudioAudioPlayer { /** * JSON对象,调用麦克风设备进行录音的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ interface PlusAudioRecordOptions { @@ -647,10 +658,10 @@ interface PlusAudioRecordOptions { * 默认值为"mono"。 * - mono: 单声道录音 * - stereo: 立体声录音 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ - channels?: 'mono' | 'stereo' | undefined; + channels?: "mono" | "stereo" | undefined; /** * 保存录音文件的路径 * 可设置具体文件名,也可只设置路径,如果以“/”结尾则表明是路径,文件名由录音程序自动生成。 @@ -659,21 +670,21 @@ interface PlusAudioRecordOptions { * - _doc/: 应用私有文档目录 * - _documents/: 共享文档目录 * - _downloads/: 共享下载目录 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ - filename?: '_www/' | '_doc/' | '_documents/' | '_downloads/' | undefined; + filename?: "_www/" | "_doc/" | "_documents/" | "_downloads/" | undefined; /** * 录音文件的采样率 * 需通过supportedSamplerates属性获取设备支持的采样率,若设置无效的值,则使用系统默认的采样率。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ samplerate?: string | undefined; /** * 录音文件的格式 * 需通过supportedFormats属性获取设备支持的录音格式,若设置无效的值,则使用系统默认的录音格式。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/audio.html](http://www.html5plus.org/doc/zh_cn/audio.html) */ format?: string | undefined; @@ -681,31 +692,31 @@ interface PlusAudioRecordOptions { /** * Bluetooth模块用于管理蓝牙设备,搜索附近蓝牙设备、连接实现数据通信等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ interface PlusBluetooth { /** * 蓝牙设备信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ BluetoothDeviceInfo?: PlusBluetoothBluetoothDeviceInfo | undefined; /** * 蓝牙设备服务信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ BluetoothService?: PlusBluetoothBluetoothService | undefined; /** * 蓝牙设备特征值 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ Bluetoothcharacteristic?: PlusBluetoothBluetoothcharacteristic | undefined; /** * 蓝牙设备特征值支持的操作类型 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ BluetoothcharacteristicProperties?: PlusBluetoothBluetoothcharacteristicProperties | undefined; @@ -713,112 +724,174 @@ interface PlusBluetooth { * 关闭蓝牙模块 * 断开所有已经建立的连接,释放系统资源,要求在蓝牙功能使用完成后调用(于openBluetoothAdapter成对使用)。 * 关闭成功后触发options参数中的success回调,失败触发options参数中的fail回调。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ - closeBluetoothAdapter(success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + closeBluetoothAdapter( + success?: (result: any) => void, + fail?: (result: any) => void, + complete?: (result: any) => void, + ): void; /** * 获取本机蓝牙适配器状态 * 获取成功后触发options参数中的success回调,失败触发options参数中的fail回调。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ - getBluetoothAdapterState(success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + getBluetoothAdapterState( + success?: (result: any) => void, + fail?: (result: any) => void, + complete?: (result: any) => void, + ): void; /** * 获取已搜索到的蓝牙设备 * 包括已经和本机处于连接状态的设备。 * 获取成功后触发options参数中的success回调,失败触发options参数中的fail回调。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ - getBluetoothDevices(success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + getBluetoothDevices( + success?: (result: any) => void, + fail?: (result: any) => void, + complete?: (result: any) => void, + ): void; /** * 根据uuid获取处于已连接的设备 * 获取成功后触发options参数中的success回调,失败触发options参数中的fail回调。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ - getConnectedBluetoothDevices(services?: any [], success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + getConnectedBluetoothDevices( + services?: any[], + success?: (result: any) => void, + fail?: (result: any) => void, + complete?: (result: any) => void, + ): void; /** * 监听蓝牙适配器状态变化事件 * 蓝牙适配器状态发生变化时触发回调。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ onBluetoothAdapterStateChange(changeCB?: (result: any) => void): void; /** * 监听搜索到新设备的事件 * 搜索到新设备时触发回调。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ onBluetoothDeviceFound(callback?: (result: any) => void): void; /** * 初始化蓝牙模块 * 初始化成功后触发options参数中的success回调,失败触发options参数中的fail回调。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ - openBluetoothAdapter(success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + openBluetoothAdapter( + success?: (result: any) => void, + fail?: (result: any) => void, + complete?: (result: any) => void, + ): void; /** * 开始搜索附近的蓝牙设备 * 此操作比较耗费系统资源,请在搜索并连接到设备后调用stopBluetoothDevicesDiscovery方法停止搜索。 * 搜索成功后触发options参数中的success回调,失败触发options参数中的fail回调。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ - startBluetoothDevicesDiscovery(services?: any [], allowDuplicatesKey?: boolean, interval?: number, success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + startBluetoothDevicesDiscovery( + services?: any[], + allowDuplicatesKey?: boolean, + interval?: number, + success?: (result: any) => void, + fail?: (result: any) => void, + complete?: (result: any) => void, + ): void; /** * 停止搜寻附近的蓝牙外围设备 * 若已经找到需要的蓝牙设备并不需要继续搜索时,应该调用该接口停止蓝牙搜索。 * 停止成功后触发options参数中的success回调,失败触发options参数中的fail回调。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ - stopBluetoothDevicesDiscovery(success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + stopBluetoothDevicesDiscovery( + success?: (result: any) => void, + fail?: (result: any) => void, + complete?: (result: any) => void, + ): void; /** * 断开与低功耗蓝牙设备的连接 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ - closeBLEConnection(deviceId?: string, success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + closeBLEConnection( + deviceId?: string, + success?: (result: any) => void, + fail?: (result: any) => void, + complete?: (result: any) => void, + ): void; /** * 连接低功耗蓝牙设备 * 若之前已有搜索过某个蓝牙设备,并成功建立连接,可直接传入之前搜索获取的deviceId尝试连接该设备,无需进行搜索操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ - createBLEConnection(deviceId?: string, timeout?: number, success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + createBLEConnection( + deviceId?: string, + timeout?: number, + success?: (result: any) => void, + fail?: (result: any) => void, + complete?: (result: any) => void, + ): void; /** * 获取蓝牙设备指定服务中所有特征值(characteristic) - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ - getBLEDeviceCharacteristics(deviceId?: string, serviceId?: string, success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + getBLEDeviceCharacteristics( + deviceId?: string, + serviceId?: string, + success?: (result: any) => void, + fail?: (result: any) => void, + complete?: (result: any) => void, + ): void; /** * 获取蓝牙设备的所有服务(service) - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ - getBLEDeviceServices(deviceId?: string, success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + getBLEDeviceServices( + deviceId?: string, + success?: (result: any) => void, + fail?: (result: any) => void, + complete?: (result: any) => void, + ): void; /** * 启用低功耗蓝牙设备特征值变化时的notify功能,订阅特征值 * 蓝牙设备服务的特征值必须支持notify或indicate才可以成功调用。 * 另外,必须先启用notifyBLECharacteristicValueChange才能监听到设备characteristicValueChange事件,即特征值发生变化时通过onBLECharacteristicValueChange注册的事件回调。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ - notifyBLECharacteristicValueChange(deviceId?: string, serviceId?: string, characteristicId?: string, state?: boolean, success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + notifyBLECharacteristicValueChange( + deviceId?: string, + serviceId?: string, + characteristicId?: string, + state?: boolean, + success?: (result: any) => void, + fail?: (result: any) => void, + complete?: (result: any) => void, + ): void; /** * 监听低功耗蓝牙设备的特征值变化事件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ onBLECharacteristicValueChange(callback?: (result: any) => void): void; /** * 监听低功耗蓝牙设备连接状态变化事件 * 包括开发者主动连接或断开连接,设备丢失,连接异常断开等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ onBLEConnectionStateChange(callback?: (result: any) => void): void; @@ -826,66 +899,81 @@ interface PlusBluetooth { * 读取低功耗蓝牙设备指定特征值的二进制数据值 * 指定的特征值需支持read操作才可以成功调用。 * 并行调用多次可能导致读取失败,读取的数据需要在onBLECharacteristicValueChange方法注册的回调中获取。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ - readBLECharacteristicValue(deviceId?: string, serviceId?: string, characteristicId?: string, success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + readBLECharacteristicValue( + deviceId?: string, + serviceId?: string, + characteristicId?: string, + success?: (result: any) => void, + fail?: (result: any) => void, + complete?: (result: any) => void, + ): void; /** * 向低功耗蓝牙设备指定特征值写入二进制数据 * 指定的特征值需支持write操作才可以成功调用。 * 并行调用多次可能导致读取失败,系统可能会限制单次传输的数据大小,超过最大字节数后可能会发生写入错误,建议每次写入不超过20字节。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ - writeBLECharacteristicValue(deviceId?: string, serviceId?: string, characteristicId?: string, value?: ArrayBuffer, success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + writeBLECharacteristicValue( + deviceId?: string, + serviceId?: string, + characteristicId?: string, + value?: ArrayBuffer, + success?: (result: any) => void, + fail?: (result: any) => void, + complete?: (result: any) => void, + ): void; } /** * 蓝牙设备信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ interface PlusBluetoothBluetoothDeviceInfo { /** * 蓝牙设备名称 * 某些设备可能没有此字段值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ name?: string | undefined; /** * 蓝牙设备的id - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ deviceId?: string | undefined; /** * 蓝牙设备的信号强度 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ RSSI?: string | undefined; /** * 蓝牙设备的广播数据段中的ManufacturerData数据段 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ advertisData?: ArrayBuffer | undefined; /** * 蓝牙设备的广播数据段中的ServiceUUIDs数据段 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ - advertisServiceUUIDs?: any [] | undefined; + advertisServiceUUIDs?: any[] | undefined; /** * 蓝牙设备的广播数据段中的LocalName数据段 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ localName?: string | undefined; /** * 蓝牙设备的广播数据段中的ServiceData数据段 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ serviceData?: any; @@ -893,19 +981,19 @@ interface PlusBluetoothBluetoothDeviceInfo { /** * 蓝牙设备服务信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ interface PlusBluetoothBluetoothService { /** * 蓝牙设备服务的uuid - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ uuid?: string | undefined; /** * 是否为设备的主服务 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ isPrimary?: boolean | undefined; @@ -913,19 +1001,19 @@ interface PlusBluetoothBluetoothService { /** * 蓝牙设备特征值 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ interface PlusBluetoothBluetoothcharacteristic { /** * 蓝牙设备特征值的uuid - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ uuid?: string | undefined; /** * 设备特征值支持的操作类型 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ properties?: PlusBluetoothBluetoothcharacteristicProperties | undefined; @@ -933,31 +1021,31 @@ interface PlusBluetoothBluetoothcharacteristic { /** * 蓝牙设备特征值支持的操作类型 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ interface PlusBluetoothBluetoothcharacteristicProperties { /** * 特征值是否支持read操作 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ read?: boolean | undefined; /** * 特征值是否支持write操作 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ write?: boolean | undefined; /** * 特征值是否支持notify操作 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ notify?: boolean | undefined; /** * 特征值是否支持indicate操作 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/bluetooth.html](http://www.html5plus.org/doc/zh_cn/bluetooth.html) */ indicate?: boolean | undefined; @@ -965,32 +1053,32 @@ interface PlusBluetoothBluetoothcharacteristicProperties { /** * Camera模块管理设备的摄像头,可用于拍照、摄像操作,通过plus.camera获取摄像头管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) */ interface PlusCamera { /** * 摄像头对象 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) */ Camera?: PlusCameraCamera | undefined; /** * JSON对象,调用摄像头的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) */ CameraOptions?: PlusCameraCameraOptions | undefined; /** * JSON对象,弹出拍照或摄像界面指示位置 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) */ PopPosition?: PlusCameraPopPosition | undefined; /** * 获取摄像头管理对象 * 获取需要操作的摄像头对象,如果要进行拍照或摄像操作,需先通过此方法获取摄像头对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) */ getCamera(index?: number): PlusCameraCamera; @@ -998,7 +1086,7 @@ interface PlusCamera { /** * 摄像头对象 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) */ interface PlusCameraCamera { @@ -1006,58 +1094,66 @@ interface PlusCameraCamera { * 字符串数组,摄像头支持的拍照分辨率 * 属性类型为String[],若不支持此属性则返回空数组对象。 * 摄像头支持的拍照图片分辨率字符串形式“WIDTH*Height”,如“400*800”;如果支持任意自定义分辨率则“*”。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) */ - supportedImageResolutions?: any [] | undefined; + supportedImageResolutions?: any[] | undefined; /** * 字符串数组,摄像头支持的摄像分辨率 * 属性类型为String[],若不支持此属性则返回空数组对象。 * 摄像头支持的视频分辨率字符串形式为“WIDTH*Height”,如“400*800”;如果支持任意自定义分辨率则“*”。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) */ - supportedVideoResolutions?: any [] | undefined; + supportedVideoResolutions?: any[] | undefined; /** * 字符串数组,摄像头支持的拍照文件格式 * 属性类型为String[],若不支持此属性则返回空数组对象。 * 摄像头支持的图片文件格式字符串形式为文件格式后缀名,如“jpg”、“png”、“bmp”。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) */ - supportedImageFormats?: any [] | undefined; + supportedImageFormats?: any[] | undefined; /** * 字符串数组,摄像头支持的摄像文件格式 * 属性类型为String[],若不支持此属性则返回空数组对象。 * 摄像头支持的视频文件格式字符串形式为文件格式后缀名,如“3gp”、“mp4”、“avi”。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) */ - supportedVideoFormats?: any [] | undefined; + supportedVideoFormats?: any[] | undefined; /** * 进行拍照操作 * 摄像头资源为独占资源,如果其它程序或页面已经占用摄像头,再次操作则失败。 * 拍照操作成功将通过successCB返回拍照获取的图片路径。 * 可通过option设置摄像头的各种属性参数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) */ - captureImage(successCB?: (result: string) => void, errorCB?: (result: any) => void, options?: PlusCameraCameraOptions): void; + captureImage( + successCB?: (result: string) => void, + errorCB?: (result: any) => void, + options?: PlusCameraCameraOptions, + ): void; /** * 调用摄像头进行摄像操作 * 摄像头资源为独占资源,如果其它程序或页面已经占用摄像头,再次操作则失败。 * 拍照操作成功将通过successCB返回摄像获取的视频文件路径。 * 可通过option设置摄像头的各种属性参数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) */ - startVideoCapture(successCB?: (result: string) => void, errorCB?: (result: any) => void, option?: PlusCameraCameraOptions): void; + startVideoCapture( + successCB?: (result: string) => void, + errorCB?: (result: any) => void, + option?: PlusCameraCameraOptions, + ): void; /** * 结束摄像操作 * 开始调用摄像头进行摄像操作后,可在后台结束摄像操作,与用户在界面结束操作效果一致。 * 摄像操作成功将通过startVideoCapture函数中的successCB返回拍照获取的图片路径。 * 用户如果没有进行摄像操作关闭摄像头页面则调用失败回调函数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) */ stopVideoCapture(): void; @@ -1065,7 +1161,7 @@ interface PlusCameraCamera { /** * JSON对象,调用摄像头的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) */ interface PlusCameraCameraOptions { @@ -1076,14 +1172,14 @@ interface PlusCameraCameraOptions { * - _doc/: 应用私有文档目录 * - _documents/: 共享文档目录 * - _downloads/: 共享下载目录 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) */ - filename?: '_doc/' | '_documents/' | '_downloads/' | undefined; + filename?: "_doc/" | "_documents/" | "_downloads/" | undefined; /** * 拍照或摄像的文件格式 * 可通过Camera对象的supportedImageFormats或supportedVideoFormats获取,如果设置的参数无效则使用系统默认值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) */ format?: string | undefined; @@ -1092,16 +1188,16 @@ interface PlusCameraCameraOptions { * 拍照或摄像界面默认使用的摄像头编号,1表示主摄像头,2表示辅摄像头。 * - 1: 使用设备主摄像头 * - 2: 使用设备辅摄像头 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) */ - index?: '1' | '2' | undefined; + index?: "1" | "2" | undefined; /** * 视频长度 * 单位为秒(s),小于等于0表示不限定视频长度。 * 默认值为0(不限定视频长度)。 * 注意:仅在调用拍摄视频(startVideoCapture)时有效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) */ videoMaximumDuration?: number | undefined; @@ -1113,21 +1209,21 @@ interface PlusCameraCameraOptions { * false - 不调整。 * 默认值为true。 * 注意:自动调整图片方向将消耗部分系统资源,可能会导致拍照后回调触发时机延迟,将此值设置为false则可避免延迟问题。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) */ optimize?: boolean | undefined; /** * 拍照或摄像使用的分辨率 * 可通过Camera对象的supportedImageResolutions或supportedVideoResolutions获取,如果设置的参数无效则使用系统默认值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) */ resolution?: string | undefined; /** * 拍照或摄像界面弹出指示区域 * 对于大屏幕设备如iPad,拍照或摄像界面为弹出窗口,此时可通过此参数设置弹出窗口位置,其为JSON对象,格式如{top:"10px",left:"10px",width:"200px",height:"200px"},默认弹出位置为屏幕居中。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) */ popover?: PlusCameraPopPosition | undefined; @@ -1135,35 +1231,35 @@ interface PlusCameraCameraOptions { /** * JSON对象,弹出拍照或摄像界面指示位置 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) */ interface PlusCameraPopPosition { /** * 指示区域距离容器顶部的距离 * 弹出拍照或摄像窗口指示区域距离容器顶部的距离,支持像素值(如"100px")和百分比(如"50%")。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) */ top?: string | undefined; /** * 指示区域距离容器左侧的距离 * 弹出拍照或摄像窗口指示区域距离容器左侧的距离,支持像素值(如"100px")和百分比(如"50%")。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) */ left?: string | undefined; /** * 指示区域的宽度 * 弹出拍照或摄像窗口指示区域的宽度,支持像素值(如"100px")和百分比(如"50%")。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) */ width?: string | undefined; /** * 指示区域的高度 * 弹出拍照或摄像窗口指示区域的高度,支持像素值(如"100px")和百分比(如"50%")。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/camera.html](http://www.html5plus.org/doc/zh_cn/camera.html) */ height?: string | undefined; @@ -1171,113 +1267,122 @@ interface PlusCameraPopPosition { /** * Contacts模块管理系统通讯录,用于可对系统通讯录进行增、删、改、查等操作。通过plus.contacts获取系统通讯录管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ interface PlusContacts { /** * 通讯录对象 * 通讯录管理对象,可对系统通讯录进行联系人的增、删、改、查操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ AddressBook?: PlusContactsAddressBook | undefined; /** * 联系人对象 * 联系人对象,包括联系人的各种信息,如名称、电话号码、地址等。也包括新增、删除联系人的操作方法。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ Contact?: PlusContactsContact | undefined; /** * JSON对象,联系人域数据对象 * 联系人域数据对象,保存联系人特定域信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ ContactField?: PlusContactsContactField | undefined; /** * JSON对象,联系人名称对象 * 联系人名称对象,保存联系人名称信息,如姓、名等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ ContactName?: PlusContactsContactName | undefined; /** * JSON对象,联系人地址对象 * 联系人地址对象,保存联系人地址信息,如国家、省份、城市等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ ContactAddress?: PlusContactsContactAddress | undefined; /** * JSON对象,联系人所属组织信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ ContactOrganization?: PlusContactsContactOrganization | undefined; /** * JSON对象,查找联系人参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ ContactFindOption?: PlusContactsContactFindOption | undefined; /** * JSON对象,联系人查找过滤器 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ ContactFindFilter?: PlusContactsContactFindFilter | undefined; /** * 手机通讯录 * 通讯录类型常量,数值类型,固定值为0,用于获取系统的联系人信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ ADDRESSBOOK_PHONE?: number | undefined; /** * SIM卡通讯录 * 通讯录类型常量,数值类型,固定值为1,用于获取SIM卡上的联系人信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ ADDRESSBOOK_SIM?: number | undefined; /** * 获取通讯录对象 * 根据指定通讯录类型获取通讯录对象,获取通讯录对象后可对其进行增、删、改操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ - getAddressBook(type?: number, successCB?: (result: PlusContactsAddressBook) => void, errorCB?: (result: any) => void): void; + getAddressBook( + type?: number, + successCB?: (result: PlusContactsAddressBook) => void, + errorCB?: (result: any) => void, + ): void; } /** * 通讯录对象 * 通讯录管理对象,可对系统通讯录进行联系人的增、删、改、查操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ interface PlusContactsAddressBook { /** * 创建联系人 * 创建一个系统联系人,并返回联系人对象,可对联系人对象进行操作设置联系人信息,如名称、地址、电话等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ create(): PlusContactsContact; /** * 在通讯录中查找联系人 * 在通讯录中安装指定的规则查找联系人,contactFields可设定查找返回的联系人中包含的字段值,查找联系人成功时通过successCB回调返回,查找联系人失败则通过errorCB回调返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ - find(contactFields?: string [], successCB?: (result: PlusContactsContact) => void, errorCB?: (result: any) => void, findOptions?: PlusContactsContactFindOption): void; + find( + contactFields?: string[], + successCB?: (result: PlusContactsContact) => void, + errorCB?: (result: any) => void, + findOptions?: PlusContactsContactFindOption, + ): void; } /** * 联系人对象 * 联系人对象,包括联系人的各种信息,如名称、电话号码、地址等。也包括新增、删除联系人的操作方法。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ interface PlusContactsContact { @@ -1285,73 +1390,73 @@ interface PlusContactsContact { * 联系人的id * 联系人id由系统分配维护,从系统获取联系人时自动赋值,再次查询时可使用此id值进行检索。 * 注意:此值为只读属性,改写此值可能会导致无法预期的错误。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ id?: string | undefined; /** * 联系人显示的名字 * 联系人显示的名字通常由其姓和名组合而成。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ displayName?: string | undefined; /** * 联系人的名称 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ name?: PlusContactsContactName | undefined; /** * 联系人的昵称 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ nickname?: string | undefined; /** * 数组,联系人的电话 * 如果联系人中未保存电话信息,则返回空数组。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ phoneNumbers?: PlusContactsContactField | undefined; /** * 数组,联系人的邮箱 * 如果联系人中未保存邮箱信息,则返回空数组。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ emails?: PlusContactsContactField | undefined; /** * 数组,联系人的地址 * 如果联系人中未保存地址信息,则返回空数组。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ addresses?: PlusContactsContactAddress | undefined; /** * 数组,联系人的即时通讯地址 * 如果联系人中未保存即时通讯地址信息,则返回空数组。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ ims?: PlusContactsContactField | undefined; /** * 数组,联系人所属组织信息 * 如果联系人中未保存所属组织信息,则返回空数组。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ organizations?: PlusContactsContactOrganization | undefined; /** * 联系人的生日 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ birthday?: Date | undefined; /** * 联系人的备注 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ note?: string | undefined; @@ -1360,41 +1465,41 @@ interface PlusContactsContact { * 其值为头像图片url地址或图片数据: * url地址:仅支持本地图片地址,可以是绝对路径或相对路径,如“_doc/a.png”; * 图片数据:必须符合Data URI scheme(RFC2397)格式的数据,如“image/png;base64,XXXX”,其中XXXX为base64编码的图片数据。在获取联系人时默认返回此类型的数据。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ photos?: PlusContactsContactField | undefined; /** * 数组,联系人的组名 * 如果联系人中未保存组名信息,则返回空数组。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ categories?: PlusContactsContactField | undefined; /** * 数组,联系人的网址 * 如果联系人中未保存网址信息,则返回空数组。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ urls?: PlusContactsContactField | undefined; /** * 克隆联系人 * 克隆联系人,创建出一个新的联系人对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ clone(): PlusContactsContact; /** * 删除联系人 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ remove(successCB?: () => void, errorCB?: (result: any) => void): void; /** * 保存联系人 * 将联系人数据保存到通讯录中,操作成功将通过successCB回调函数返回保存结果,操作失败将通过通过errorCB回调函数返回错误信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ save(successCB?: () => void, errorCB?: (result: any) => void): void; @@ -1403,25 +1508,25 @@ interface PlusContactsContact { /** * JSON对象,联系人域数据对象 * 联系人域数据对象,保存联系人特定域信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ interface PlusContactsContactField { /** * 联系人域类型,如电话号码中的“mobile”、“home”、“company” - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ type?: string | undefined; /** * 联系人域值 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ value?: string | undefined; /** * 是否为首选项 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ preferred?: boolean | undefined; @@ -1430,43 +1535,43 @@ interface PlusContactsContactField { /** * JSON对象,联系人名称对象 * 联系人名称对象,保存联系人名称信息,如姓、名等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ interface PlusContactsContactName { /** * 联系人的完整名称,由其它字段组合生成 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ formatted?: string | undefined; /** * 联系人的姓 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ familyName?: string | undefined; /** * 联系人的名 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ givenName?: string | undefined; /** * 联系人的中间名 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ middleName?: string | undefined; /** * 联系人的前缀(如Mr.或Dr.) - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ honorificPrefix?: string | undefined; /** * 联系人的后缀 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ honorificSuffix?: string | undefined; @@ -1475,55 +1580,55 @@ interface PlusContactsContactName { /** * JSON对象,联系人地址对象 * 联系人地址对象,保存联系人地址信息,如国家、省份、城市等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ interface PlusContactsContactAddress { /** * 联系人地址类型,如“home”表示家庭地址、“company”表示单位地址 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ type?: string | undefined; /** * 完整地址,由其它字段组合而成 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ formatted?: string | undefined; /** * 完整的街道地址 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ streetAddress?: string | undefined; /** * 城市或地区 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ locality?: string | undefined; /** * 省或地区 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ region?: string | undefined; /** * 国家 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ country?: string | undefined; /** * 邮政编码 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ postalCode?: string | undefined; /** * 是否为首选项 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ preferred?: boolean | undefined; @@ -1531,37 +1636,37 @@ interface PlusContactsContactAddress { /** * JSON对象,联系人所属组织信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ interface PlusContactsContactOrganization { /** * 联系人所属组织类型,如"company" - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ type?: string | undefined; /** * 联系人所属组织名称 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ name?: string | undefined; /** * 联系人所属组织部门 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ department?: string | undefined; /** * 联系人在组织中的职位 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ title?: string | undefined; /** * 是否为首选项 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ preferred?: boolean | undefined; @@ -1569,20 +1674,20 @@ interface PlusContactsContactOrganization { /** * JSON对象,查找联系人参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ interface PlusContactsContactFindOption { /** * 数组,查找时的过滤器 * 可设置为空,表示不过滤。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ filter?: PlusContactsContactFindFilter | undefined; /** * 是否查找多个联系人,默认值为true - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ multiple?: boolean | undefined; @@ -1590,26 +1695,26 @@ interface PlusContactsContactFindOption { /** * JSON对象,联系人查找过滤器 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ interface PlusContactsContactFindFilter { /** * 区配的逻辑 * 可取“and”、“or”、“not”,默认值为“and”。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ logic?: string | undefined; /** * 区配的联系人域,可取联系人的属性名称 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ field?: string | undefined; /** * 区配的联系人值,可使用区配符号“?”和“*” - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/contacts.html](http://www.html5plus.org/doc/zh_cn/contacts.html) */ value?: string | undefined; @@ -1617,7 +1722,7 @@ interface PlusContactsContactFindFilter { /** * Device模块管理设备信息,用于获取手机设备的相关信息,如IMEI、IMSI、型号、厂商等。通过plus.device获取设备信息管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ interface PlusDevice { @@ -1626,7 +1731,7 @@ interface PlusDevice { * 调用此属性获取设备的国际移动设备身份码。 * 如果设备不支持则返回空字符串。 * 如果设备存在多个身份码,则以“,”字符分割拼接,如“862470039452950,862470039452943”。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ imei?: string | undefined; @@ -1635,15 +1740,15 @@ interface PlusDevice { * 字符串数组类型,获取设备上插入SIM的国际移动设备身份码。 * 如果设备支持多卡模式则返回所有SIM身份码。 * 如果设备不支持或没有插入SIM卡则返回空数组。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ - imsi?: any [] | undefined; + imsi?: any[] | undefined; /** * 设备的型号 * 调用此属性获取设备的型号信息。 * 如果设备不支持则返回空字符串。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ model?: string | undefined; @@ -1651,63 +1756,63 @@ interface PlusDevice { * 设备的生产厂商 * 调用此属性获取设备的生产厂商信息。 * 如果设备不支持则返回空字符串。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ vendor?: string | undefined; /** * 设备的唯一标识 * 调用此属性获取设备的唯一标识号。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ uuid?: string | undefined; /** * 拨打电话 * 调用系统程序拨打电话。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ dial(number?: string, confirm?: boolean): void; /** * 发出蜂鸣声 * 调用此方法使得设备发出蜂鸣声。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ beep(times?: number): void; /** * 设备振动 * 调用此方法使得设备振动。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ vibrate(milliseconds?: number): void; /** * 设置应用是否保持唤醒(屏幕常亮)状态 * 调用此方法设置应用是否一直保持唤醒状态,保持唤醒状态将会导致程序屏幕常亮、系统不会自动锁屏,从而导致消耗更多的电量。若未设置一直保持唤醒状态则会根据系统设置自动锁定屏幕。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ setWakelock(lock?: boolean): void; /** * 获取程序是否一直保持唤醒(屏幕常亮)状态 * 调用此方法获取程序是否一致保持唤醒状态。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ isWakelock(): boolean; /** * 设置设备的系统音量 * 调用此方法调节设备的系统音量。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ setVolume(volume?: number): void; /** * 获取设备的系统音量 * 系统音量值范围为0到1,0表示静音,1表示最大音量值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ getVolume(): number; @@ -1715,7 +1820,7 @@ interface PlusDevice { /** * Screen模块管理设备屏幕信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ interface PlusScreen { @@ -1723,7 +1828,7 @@ interface PlusScreen { * 设备屏幕高度分辨率 * 设备屏幕区域包括系统状态栏显示区域和应用显示区域,screen获取的是设备屏幕总区域的逻辑分辨率,单位为px。 * 如果需要获取实际分辨率则需要乘以比例值scale。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ resolutionHeight?: number | undefined; @@ -1731,42 +1836,42 @@ interface PlusScreen { * 设备屏幕宽度分辨率 * 设备屏幕区域包括系统状态栏显示区域和应用显示区域,screen获取的是设备屏幕总区域的分辨率,单位为px。 * 如果需要获取实际分辨率则需要乘以比例值scale。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ resolutionWidth?: number | undefined; /** * 逻辑分辨率与实际分辨率的比例 * 屏幕分辨率分逻辑分辨率率和实际分辨率,在html页面中使用的像素值都是相对于逻辑分辨率,此值就是逻辑分辨率和实际分辨率的比例,实际分辨率=逻辑分辨率*比例。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ scale?: number | undefined; /** * 设备屏幕水平方向的密度 * 设备屏幕的密度为每英寸所显示的像素点数,密度越高显示清晰度越高,单位为dpi。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ dpiX?: number | undefined; /** * 设备屏幕垂直方向的密度 * 设备屏幕的密度为每英寸所显示的像素点数,密度越高显示清晰度越高,单位为dpi。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ dpiY?: number | undefined; /** * 设置屏幕亮度 * 调用此方法调节设备屏幕亮度。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ setBrightness(brightness?: number): void; /** * 获取屏幕亮度值 * 屏幕亮度值范围为0到1,0表示最低亮度值,1表示最高亮度值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ getBrightness(): number; @@ -1774,14 +1879,14 @@ interface PlusScreen { * 锁定屏幕方向 * 锁定屏幕方向后屏幕只能按锁定的屏幕方向显示,关闭当前页面后仍然有效。 * 可再次调用此方法修改屏幕锁定方向或调用unlockOrientation()方法恢复到应用的默认值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ lockOrientation(orientation?: string): void; /** * 解除锁定屏幕方向 * 解除锁定屏幕方向后将恢复应用默认的屏幕显示方向(通常为应用打包发布时设置的方向)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ unlockOrientation(): void; @@ -1789,7 +1894,7 @@ interface PlusScreen { /** * Display模块管理应用可使用的显示区域信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ interface PlusDisplay { @@ -1797,7 +1902,7 @@ interface PlusDisplay { * 应用可使用的屏幕高度逻辑分辨率 * 设备屏幕区域包括系统状态栏显示区域和应用显示区域,display获取的是应用显示区域的逻辑分辨率,单位为px。 * 如果需要获取实际分辨率则需要乘以比例值scale。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ resolutionHeight?: number | undefined; @@ -1805,7 +1910,7 @@ interface PlusDisplay { * 应用可使用的屏幕宽度逻辑分辨率 * 设备屏幕区域包括系统状态栏显示区域和应用显示区域,display获取的是应用显示区域的逻辑分辨率,单位为px。 * 如果需要获取实际分辨率则需要乘以比例值scale。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ resolutionWidth?: number | undefined; @@ -1813,63 +1918,63 @@ interface PlusDisplay { /** * networkinfo模块用于获取网络信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ interface PlusNetworkinfo { /** * 网络连接状态未知 * 网络状态常量,表示当前设备网络状态未知,固定值为0。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ CONNECTION_UNKNOW?: number | undefined; /** * 未连接网络 * 网络状态常量,当前设备网络未连接网络,固定值为1。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ CONNECTION_NONE?: number | undefined; /** * 有线网络 * 网络状态常量,当前设备连接到有线网络,固定值为2。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ CONNECTION_ETHERNET?: number | undefined; /** * 无线WIFI网络 * 网络状态常量,当前设备连接到无线WIFI网络,固定值为3。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ CONNECTION_WIFI?: number | undefined; /** * 蜂窝移动2G网络 * 网络状态常量,当前设备连接到蜂窝移动2G网络,固定值为4。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ CONNECTION_CELL2G?: number | undefined; /** * 蜂窝移动3G网络 * 网络状态常量,当前设备连接到蜂窝移动3G网络,固定值为5。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ CONNECTION_CELL3G?: number | undefined; /** * 蜂窝移动4G网络 * 网络状态常量,当前设备连接到蜂窝移动4G网络,固定值为6。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ CONNECTION_CELL4G?: number | undefined; /** * 获取设备当前连接的网络类型 * 获取当前设备连接的网络类型,返回值为网络类型常量,可取值CONNECTION_*常量。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ getCurrentType(): number; @@ -1877,101 +1982,103 @@ interface PlusNetworkinfo { /** * OS模块管理操作系统信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ interface PlusOs { /** * 系统语言信息 * 获取当前操作系统设置的系统语言,字符串类型数据。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ language?: string | undefined; /** * 系统版本信息 * 获取当前操作系统的版本信息,字符串类型数据。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ version?: string | undefined; /** * 系统的名称 * 获取当前操作系统的名称,字符串类型数据。 - * - iOS: + * - iOS: * iOS系统。 - * - * - Android: + * + * - Android: * Android系统。 - * - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ - name?: 'iOS' | 'Android' | undefined; + name?: "iOS" | "Android" | undefined; /** * 系统的供应商信息 * 获取当前操作系统的供应商名称,字符串类型数据。 - * - Apple: + * - Apple: * iOS设备,包括iPhone、iPad、iTouch。 - * - * - Google: + * + * - Google: * Android设备。 - * - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/device.html](http://www.html5plus.org/doc/zh_cn/device.html) */ - vendor?: 'Apple' | 'Google' | undefined; + vendor?: "Apple" | "Google" | undefined; } /** * Downloader模块管理网络文件下载任务,用于从服务器下载各种文件,并支持跨域访问操作。通过plus.downloader获取下载管理对象。Downloader下载使用HTTP的GET/POST方式请求下载文件,符合标准HTTP/HTTPS传输协议。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ interface PlusDownloader { /** * Download对象管理一个下载任务 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ Download?: PlusDownloaderDownload | undefined; /** * 下载任务事件类型 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ DownloadEvent?: PlusDownloaderDownloadEvent | undefined; /** * 下载任务状态 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ DownloadState?: PlusDownloaderDownloadState | undefined; /** * 下载任务参数 * 在创建下载任务时设置的参数,如设置下载任务使用的HTTP协议类型、优先级等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ DownloadOptions?: PlusDownloaderDownloadOptions | undefined; /** * 新建下载任务 * 请求下载管理创建新的下载任务,创建成功则返回Download对象,用于管理下载任务。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ - createDownload(url?: string, options?: PlusDownloaderDownloadOptions, completedCB?: (result0: PlusDownloaderDownload, result1: number) => void): PlusDownloaderDownload; + createDownload( + url?: string, + options?: PlusDownloaderDownloadOptions, + completedCB?: (result0: PlusDownloaderDownload, result1: number) => void, + ): PlusDownloaderDownload; /** * 枚举下载任务 * 枚举指定状态的下载任务列表,通过enumCB回调函数返回结果。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ - enumerate(enumCB?: (result: any []) => void, state?: PlusDownloaderDownloadState): void; + enumerate(enumCB?: (result: any[]) => void, state?: PlusDownloaderDownloadState): void; /** * 清除下载任务 * 清除指定状态的下载任务。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ clear(state?: PlusDownloaderDownloadState): void; @@ -1979,7 +2086,7 @@ interface PlusDownloader { * 开始所有下载任务 * 开始所有处于为开始调度或暂停状态的下载任务。 * 若下载任务数超过可并发处理的总数,超出的任务处于调度状态(等待下载),当有任务完成时根据调度状态任务的优先级选择任务开始下载。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ startAll(): void; @@ -1987,49 +2094,49 @@ interface PlusDownloader { /** * Download对象管理一个下载任务 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ interface PlusDownloaderDownload { /** * 下载任务的标识 * 在创建任务时系统自动分配,用于标识下载任务的唯一性。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ id?: string | undefined; /** * 下载文件的地址 * 调用plus.donwloader.createDownload()方法创建下载任务时设置的值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ url?: string | undefined; /** * 任务的状态 * 表示当前下载任务的状态,可通过addEventListener()方法监听statechanged事件监听任务状态的变化。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ state?: PlusDownloaderDownloadState | undefined; /** * 下载任务的参数 * 调用plus.donwloader.createDownload()方法创建下载任务时设置的参数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ options?: PlusDownloaderDownloadOptions | undefined; /** * 下载的文件名称 * 下载任务在本地保存的文件路径,下载任务完成时更新,可通过此值访问下载的文件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ filename?: string | undefined; /** * 已完成下载文件的大小 * 整数类型,单位为字节(byte),下载任务开始传输数据时,每次触发statechanged事件或下载任务完成时更新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ downloadedSize?: number | undefined; @@ -2037,7 +2144,7 @@ interface PlusDownloaderDownload { * 下载任务文件的总大小 * 整数类型,单位为字节(byte),下载任务开始传输数据时更新,在此之前其值为0。 * 此值是从HTTP请求头中获取,如果服务器未返回则此值始终为0。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ totalSize?: number | undefined; @@ -2045,21 +2152,25 @@ interface PlusDownloaderDownload { * 取消下载任务 * 如果任务未完成,则终止下载,并从任务列表中删除。 * 如下载未完成,将删除已下载的临时文件,如果下载已完成,将不删除已下载的文件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ abort(): void; /** * 添加下载任务事件监听器 * 下载任务添加事件监听器后,当监听的事件发生时触发listener回调。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ - addEventListener(type?: string, listener?: (result0: PlusDownloaderDownload, result1: number) => void, capture?: boolean): void; + addEventListener( + type?: string, + listener?: (result0: PlusDownloaderDownload, result1: number) => void, + capture?: boolean, + ): void; /** * 获取下载请求HTTP响应头部信息 * HTTP响应头部全部内容作为未解析的字符串返回,如果没有接收到这个HTTP响应头数据或者下载请求未完成则为空字符串。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ getAllResponseHeaders(): string; @@ -2067,7 +2178,7 @@ interface PlusDownloaderDownload { * 获取下载请求指定的HTTP响应头部的值 * 其参数是要返回的HTTP响应头部的名称,可以使用任何大小写来制定这个头部名字,和响应头部的比较是不区分大小写的。 * 如果没有接收到这个头部或者下载请求未完成则为空字符串;如果接收到多个有指定名称的头部,这个头部的值被连接起来并返回,使用逗号和空格分隔开各个头部的值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ getResponseHeader(headerName?: string): string; @@ -2075,14 +2186,14 @@ interface PlusDownloaderDownload { * 暂停下载任务 * 暂停下载任务,如果任务已经处于初始状态或暂停状态则无任何响应。 * 通常在任务已开始后暂停任务。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ pause(): void; /** * 恢复暂停的下载任务 * 继续暂停的下载任务,如果任务处于非暂停状态则无任何响应。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ resume(): void; @@ -2090,7 +2201,7 @@ interface PlusDownloaderDownload { * 设置下载请求的HTTP头数据 * Http的Header应该包含在通过后续start()调用而发起的请求中,此方法必需在调用start()之前设置才能生效。 * 如果带有指定名称的头部已经被指定了,这个头部的新值就是:之前指定的值,加上逗号、以及这个调用指定的值(形成一个数组)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ setRequestHeader(headerName?: string, headerValue?: string): void; @@ -2098,7 +2209,7 @@ interface PlusDownloaderDownload { * 开始下载任务 * 开始下载任务,如果任务已经处于开始状态则无任何响应。 * 在创建任务或任务下载失败后调用可重新开始下载。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ start(): void; @@ -2106,14 +2217,14 @@ interface PlusDownloaderDownload { /** * 下载任务事件类型 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ interface PlusDownloaderDownloadEvent { /** * 下载任务状态变化事件 * 当下载任务状态发生变化时触发此事件,事件原型参考DownloadStateChangedCallback。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ statechanged?: string | undefined; @@ -2121,7 +2232,7 @@ interface PlusDownloaderDownloadEvent { /** * 下载任务状态 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ type PlusDownloaderDownloadState = undefined | 0 | 1 | 2 | 3 | 4 | 5 | -1; @@ -2129,7 +2240,7 @@ type PlusDownloaderDownloadState = undefined | 0 | 1 | 2 | 3 | 4 | 5 | -1; /** * 下载任务参数 * 在创建下载任务时设置的参数,如设置下载任务使用的HTTP协议类型、优先级等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ interface PlusDownloaderDownloadOptions { @@ -2138,14 +2249,14 @@ interface PlusDownloaderDownloadOptions { * 支持http协议的“GET”、“POST”,默认为“GET”请求。 * - GET: GET请求 * - POST: POST请求 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ - method?: 'GET' | 'POST' | undefined; + method?: "GET" | "POST" | undefined; /** * POST请求时提交的数据 * 仅在网络请求类型method设置为"POST"时有效,"GET"请求时忽略此数据。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ data?: string | undefined; @@ -2158,14 +2269,14 @@ interface PlusDownloaderDownloadOptions { * - _doc/: 应用私有文档目录 * - _documents/: 共享文档目录 * - _downloads/: 共享下载目录 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ - filename?: '_doc/' | '_documents/' | '_downloads/' | undefined; + filename?: "_doc/" | "_documents/" | "_downloads/" | undefined; /** * 下载任务的优先级 * 数值类型,数值越大优先级越高,默认优先级值为0。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ priority?: number | undefined; @@ -2173,21 +2284,21 @@ interface PlusDownloaderDownloadOptions { * 下载任务超时时间 * 数值类型,单位为s(秒),默认值为120s。 * 超时时间为服务器响应请求的时间(不是下载任务完成的总时间),如果设置为0则表示永远不超时。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ timeout?: number | undefined; /** * 下载任务重试次数 * 数值类型,默认为重试3次。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ retry?: number | undefined; /** * 下载任务重试间隔时间 * 数值类型,单位为s(秒),默认值为30s。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/downloader.html](http://www.html5plus.org/doc/zh_cn/downloader.html) */ retryInterval?: number | undefined; @@ -2195,27 +2306,27 @@ interface PlusDownloaderDownloadOptions { /** * Fingerprint模块管理指纹识别。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) */ interface PlusFingerprint { /** * JSON对象,指纹识别认证参数 * 用于设置指纹识别认证界面显示的提示信息等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) */ AuthenticateOptions?: PlusFingerprintAuthenticateOptions | undefined; /** * JSON对象,指纹识别错误信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) */ FingerprintError?: PlusFingerprintFingerprintError | undefined; /** * 当前设备环境是否支持指纹识别 * 目前还有很多设备没有指纹识别模块,需要调用此方法判断是否可使用指纹识别功能。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) */ isSupport(): boolean; @@ -2223,7 +2334,7 @@ interface PlusFingerprint { * 当前设备是否设置密码锁屏 * 如果设备没有设置密码锁屏,则无法使用指纹识别功能,建议调用指纹识别前先使用此接口检查。 * 调用plus.fingerprint.authenticate会返回失败。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) */ isKeyguardSecure(): boolean; @@ -2231,22 +2342,26 @@ interface PlusFingerprint { * 当前设备是否已经录入指纹 * 如果设备没有录入指纹,则无法使用指纹识别功能,建议调用指纹识别前先使用此接口检查。 * 调用plus.fingerprint.authenticate会返回失败。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) */ isEnrolledFingerprints(): boolean; /** * 指纹识别认证 * 用户可以开始输入指纹进行识别,如果认证成功则触发successCB回调,识别失败则触发errorCB回调返回错误信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) */ - authenticate(successCB?: () => void, errorCB?: (result: PlusFingerprintFingerprintError) => void, options?: PlusFingerprintAuthenticateOptions): void; + authenticate( + successCB?: () => void, + errorCB?: (result: PlusFingerprintFingerprintError) => void, + options?: PlusFingerprintAuthenticateOptions, + ): void; /** * 取消指纹识别认证 * 取消当前正在处理的指纹识别认证操作。 * 如果当前没有进行指纹识别则不进行任何操作;如果当前正在进行指纹识别则触发错误回调(错误码为“CANCEL”)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) */ cancel(): void; @@ -2255,14 +2370,14 @@ interface PlusFingerprint { /** * JSON对象,指纹识别认证参数 * 用于设置指纹识别认证界面显示的提示信息等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) */ interface PlusFingerprintAuthenticateOptions { /** * 在指纹识别过程中显示在界面上的提示信息 * 如果指纹识别认证过程中不显示提示框,则不显示此信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) */ message?: string | undefined; @@ -2270,28 +2385,28 @@ interface PlusFingerprintAuthenticateOptions { /** * JSON对象,指纹识别错误信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) */ interface PlusFingerprintFingerprintError { /** * 不支持指纹识别 * 当前设备不支持指纹识别功能时返回此错误,错误代码常量值为1。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) */ UNSUPPORT?: number | undefined; /** * 设备未设置密码锁屏 * 当前设备为设置密码锁屏导致无法使用指纹识别功能时返回此错误,错误代码常量值为2。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) */ KEYGUARD_INSECURE?: number | undefined; /** * 未录入指纹识别 * 当前设备未录入指纹导致无法使用指纹识别功能时返回此错误,错误代码常量值为3。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) */ FINGERPRINT_UNENROLLED?: number | undefined; @@ -2299,7 +2414,7 @@ interface PlusFingerprintFingerprintError { * 指纹识别不匹配 * 用户指纹识别认证不通过时返回此错误,错误代码常量值为4。 * 用户每次尝试指纹识别认证未通过都会触发此错误,此时还可以继续识别认证。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) */ AUTHENTICATE_MISMATCH?: number | undefined; @@ -2307,35 +2422,35 @@ interface PlusFingerprintFingerprintError { * 指纹识别次数超过限制 * 用户多次指纹识别认证不通过时返回此错误,错误代码常量值为5。 * 通常出现此错误后系统会锁定一段时间禁止使用指纹识别,如果再次调用指纹识别认证会立即返回此错误,因此出现此错误时应该提示用户使用其它方式进行认证。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) */ AUTHENTICATE_OVERLIMIT?: number | undefined; /** * 取消指纹识别 * 用户取消指纹识别认证时返回此错误,错误代码常量值为6。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) */ CANCEL?: number | undefined; /** * 未知错误 * 其它未知错误,错误代码常量值为7。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) */ UNKNOWN_ERROR?: number | undefined; /** * 错误代码 * 取值范围为FingerprintError对象的错误常量值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) */ code?: number | undefined; /** * 错误描述信息 * 详细错误描述信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/fingerprint.html](http://www.html5plus.org/doc/zh_cn/fingerprint.html) */ message?: string | undefined; @@ -2343,62 +2458,70 @@ interface PlusFingerprintFingerprintError { /** * Gallery模块管理系统相册,支持从相册中选择图片或视频文件、保存图片或视频文件到相册等功能。通过plus.gallery获取相册管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ interface PlusGallery { /** * JSON对象,从相册中选择文件的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ GalleryOptions?: PlusGalleryGalleryOptions | undefined; /** * 相册选择文件过滤类型 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ GalleryFilter?: PlusGalleryGalleryFilter | undefined; /** * 保存图片到相册成功事件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ GallerySaveEvent?: PlusGalleryGallerySaveEvent | undefined; /** * JSON对象,弹出拍照或摄像界面指示位置 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ PopPosition?: PlusGalleryPopPosition | undefined; /** * 从系统相册选择文件(图片或视频) * 从系统相册中选择图片或视频文件。每次仅能选择一个文件,选择后将返回选择的文件路径。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ - pick(succesCB?: (result: string) => void, errorCB?: (result: any) => void, options?: PlusGalleryGalleryOptions): void; + pick( + succesCB?: (result: string) => void, + errorCB?: (result: any) => void, + options?: PlusGalleryGalleryOptions, + ): void; /** * 保存文件到系统相册中 * 保存文件到系统相册中。 * 每次仅能保存一个文件,支持图片类型(jpg/jpeg、png、bmp等格式)和视频文件(3gp、mov等格式)。 * 若保存的文件系统不支持,则通过errorCB返回错误信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ - save(path ?: string, succesCB?: (result: PlusGalleryGallerySaveEvent) => void, errorCB?: (result: any) => void): void; + save( + path?: string, + succesCB?: (result: PlusGalleryGallerySaveEvent) => void, + errorCB?: (result: any) => void, + ): void; } /** * JSON对象,从相册中选择文件的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ interface PlusGalleryGalleryOptions { /** * 是否显示系统相册文件选择界面的动画 * 可取值true、false,默认值为true。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ animation?: boolean | undefined; @@ -2406,7 +2529,7 @@ interface PlusGalleryGalleryOptions { * 选择文件保存的路径 * 某些系统不能直接使用系统相册的路径,这时需要将选择的文件保存到应用可访问的目录中,可通过此参数设置保存文件的路径。 * 如果路径中包括文件后缀名称,则表明指定文件路径及名称,否则仅指定文件保存目录,文件名称自动生成。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ filename?: string | undefined; @@ -2416,29 +2539,29 @@ interface PlusGalleryGalleryOptions { * - image: 仅可选择图片文件 * - video: 仅可选择视频文件 * - none: 可选择图片或视频文件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ - filter?: 'image' | 'video' | 'none' | undefined; + filter?: "image" | "video" | "none" | undefined; /** * 最多选择的图片数量 * 仅在支持多选时有效,取值范围为1到Infinity,默认值为Infinity,即不限制选择的图片数。 * 如果设置的值非法则使用默认值Infinity。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ maximum?: number | undefined; /** * 是否支持多选图片 * 可从系统相册中选择多张图片,选择图片后通过GalleryMultiplePickSuccessCallback回调返回选择的图片。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ multiple?: boolean | undefined; /** * 超过最多选择图片数量事件 * 使用相册多选图片时,可通过maximum属性设置最多选择的图片数量,当用户操作选择的数量大于此时触发此事件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ onmaxed?: (() => void) | undefined; @@ -2446,7 +2569,7 @@ interface PlusGalleryGalleryOptions { * 相册选择界面弹出指示区域 * 对于大屏幕设备如iPad,相册选择界面为弹出窗口,此时可通过此参数设置弹出窗口位置。 * 其为JSON对象,格式如{top:"10px",left:"10px",width:"200px",height:"200px"},所有值为像素值,左上坐标相对于容器的位置,默认弹出位置为屏幕居中。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ popover?: PlusGalleryPopPosition | undefined; @@ -2454,15 +2577,15 @@ interface PlusGalleryGalleryOptions { * 已选择的图片路径列表 * 仅在多图片选择时生效,相册选择界面将选中指定的图片路径列表。 * 如果指定的路径无效,则忽略此项;如果指定的路径数超过maximum属性指定的最大选择数目则超出的图片不选中。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ - selected?: any [] | undefined; + selected?: any[] | undefined; /** * 是否使用系统相册文件选择界面 * multiple属性设置为true时,如果系统自带相册选择控件时则优先使用,否则使用5+统一相册选择控件;设置为false则不使用系统自带相册选择控件,直接使用5+统一相册选择界面。 * 默认值为true。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ system?: boolean | undefined; @@ -2470,25 +2593,25 @@ interface PlusGalleryGalleryOptions { /** * 相册选择文件过滤类型 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ interface PlusGalleryGalleryFilter { /** * 仅可选择图片文件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ image?: string | undefined; /** * 仅可选择视频文件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ video?: string | undefined; /** * 不过滤,可选择图片或视频文件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ none?: string | undefined; @@ -2496,13 +2619,13 @@ interface PlusGalleryGalleryFilter { /** * 保存图片到相册成功事件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ interface PlusGalleryGallerySaveEvent { /** * 保存到相册的图片路径 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ path?: string | undefined; @@ -2510,35 +2633,35 @@ interface PlusGalleryGallerySaveEvent { /** * JSON对象,弹出拍照或摄像界面指示位置 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ interface PlusGalleryPopPosition { /** * 指示区域距离容器顶部的距离 * 弹出拍照或摄像窗口指示区域距离容器顶部的距离,单位支持像素值(如"100px")和百分比(如"50%"),如不写单位则为像素值值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ top?: string | undefined; /** * 指示区域距离容器左侧的距离 * 弹出拍照或摄像窗口指示区域距离容器左侧的距离,单位支持像素值(如"100px")和百分比(如"50%"),如不写单位则为像素值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ left?: string | undefined; /** * 指示区域的宽度 * 弹出拍照或摄像窗口指示区域的宽度,单位支持像素值(如"100px")和百分比(如"50%"),如不写单位则为像素值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ width?: string | undefined; /** * 指示区域的高度 * 弹出拍照或摄像窗口指示区域的高度,单位支持像素值(如"100px")和百分比(如"50%"),如不写单位则为像素值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/gallery.html](http://www.html5plus.org/doc/zh_cn/gallery.html) */ height?: string | undefined; @@ -2546,59 +2669,67 @@ interface PlusGalleryPopPosition { /** * Geolocation模块管理设备位置信息,用于获取地理位置信息,如经度、纬度等。通过plus.geolocation可获取设备位置管理对象。虽然W3C已经提供标准API获取位置信息,但在某些平台存在差异或未实现,为了保持各平台的统一性,定义此规范接口获取位置信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ interface PlusGeolocation { /** * JSON对象,设备位置信息数据 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ Position?: PlusGeolocationPosition | undefined; /** * JSON对象,地址信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ Address?: PlusGeolocationAddress | undefined; /** * JSON对象,地理坐标信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ Coordinates?: PlusGeolocationCoordinates | undefined; /** * JSON对象,监听设备位置信息参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ PositionOptions?: PlusGeolocationPositionOptions | undefined; /** * JSON对象,定位错误信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ GeolocationError?: PlusGeolocationGeolocationError | undefined; /** * 获取当前设备位置信息 * 位置信息将通过手机GPS设备或其它信息如IP地址、移动网络信号获取,由于获取位置信息可能需要较长的时间,当成功获取位置信息后将通过successCB回调函数返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ - getCurrentPosition(successCB?: (result: PlusGeolocationPosition) => void, errorCB?: (result: PlusGeolocationGeolocationError) => void, options?: PlusGeolocationPositionOptions): void; + getCurrentPosition( + successCB?: (result: PlusGeolocationPosition) => void, + errorCB?: (result: PlusGeolocationGeolocationError) => void, + options?: PlusGeolocationPositionOptions, + ): void; /** * 监听设备位置变化信息 * 位置信息将通过手机GPS设备或其它信息如IP地址、移动网络信号获取。 * 当位置信息更新后将通过successCB回调函数返回。 * 位置信息获取失败则调用回调函数errorCB。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ - watchPosition(successCB?: (result: PlusGeolocationPosition) => void, errorCB?: (result: PlusGeolocationGeolocationError) => void, option?: PlusGeolocationPositionOptions): number; + watchPosition( + successCB?: (result: PlusGeolocationPosition) => void, + errorCB?: (result: PlusGeolocationGeolocationError) => void, + option?: PlusGeolocationPositionOptions, + ): number; /** * 关闭监听设备位置信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ clearWatch(watchId?: number): void; @@ -2606,13 +2737,13 @@ interface PlusGeolocation { /** * JSON对象,设备位置信息数据 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ interface PlusGeolocationPosition { /** * 地理坐标信息,包括经纬度、海拔、速度等信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ coords?: PlusGeolocationCoordinates | undefined; @@ -2623,14 +2754,14 @@ interface PlusGeolocationPosition { * "gcj02":表示国测局经纬度坐标系; * "bd09":表示百度墨卡托坐标系; * "bd09ll":表示百度经纬度坐标系。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ coordsType?: string | undefined; /** * 获取到地理坐标的时间戳信息 * 时间戳值为从1970年1月1日至今的毫秒数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ timestamp?: number | undefined; @@ -2638,14 +2769,14 @@ interface PlusGeolocationPosition { * 获取到地理位置对应的地址信息 * 获取地址信息需要连接到服务器进行解析,所以会消耗更多的资源,如果不需要获取地址信息可通过设置PositionOptions参数的geocode属性值为false避免获取地址信息。 * 如果没有获取到地址信息则返回undefined。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ address?: PlusGeolocationAddress | undefined; /** * 获取完整地址描述信息 * 如果没有获取到地址信息则返回undefined。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ addresses?: string | undefined; @@ -2653,70 +2784,70 @@ interface PlusGeolocationPosition { /** * JSON对象,地址信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ interface PlusGeolocationAddress { /** * 国家 * 如“中国”,如果无法获取此信息则返回undefined。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ country?: string | undefined; /** * 省份名称 * 如“北京市”,如果无法获取此信息则返回undefined。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ province?: string | undefined; /** * 城市名称 * 如“北京市”,如果无法获取此信息则返回undefined。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ city?: string | undefined; /** * 区(县)名称 * 如“朝阳区”,如果无法获取此信息则返回undefined。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ district?: string | undefined; /** * 街道信息 * 如“酒仙桥路”,如果无法获取此信息则返回undefined。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ street?: string | undefined; /** * 获取街道门牌号信息 * 如“3号”,如果无法获取此信息则返回undefined。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ streetNum?: string | undefined; /** * POI信息 * 如“电子城.国际电子总部”,如果无法获取此信息则返回undefined。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ poiName?: string | undefined; /** * 邮政编码 * 如“100016”,如果无法获取此信息则返回undefined。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ postalCode?: string | undefined; /** * 城市代码 * 如“010”,如果无法获取此信息则返回undefined。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ cityCode?: string | undefined; @@ -2724,56 +2855,56 @@ interface PlusGeolocationAddress { /** * JSON对象,地理坐标信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ interface PlusGeolocationCoordinates { /** * 坐标纬度值 * 数据类型对象,地理坐标中的纬度值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ latitude?: number | undefined; /** * 坐标经度值 * 数据类型对象,地理坐标中的经度值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ longitude?: number | undefined; /** * 海拔信息 * 数据类型对象,如果无法获取此信息,则此值为空(null)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ altitude?: number | undefined; /** * 地理坐标信息的精确度信息 * 数据类型对象,单位为米,其有效值必须大于0。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ accuracy?: number | undefined; /** * 海拔的精确度信息 * 数据类型对象,单位为米,其有效值必须大于0。如果无法获取海拔信息,则此值为空(null)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ altitudeAccuracy?: number | undefined; /** * 表示设备移动的方向 * 数据类型对象,范围为0到360,表示相对于正北方向的角度。如果无法获取此信息,则此值为空(null)。如果设备没有移动则此值为NaN。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ heading?: number | undefined; /** * 表示设备移动的速度 * 数据类型对象,单位为米每秒(m/s),其有效值必须大于0。如果无法获取速度信息,则此值为空(null)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ speed?: number | undefined; @@ -2781,21 +2912,21 @@ interface PlusGeolocationCoordinates { /** * JSON对象,监听设备位置信息参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ interface PlusGeolocationPositionOptions { /** * 是否高精确度获取位置信息 * 高精度获取表示需要使用更多的系统资源,默认值为false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ enableHighAccuracy?: boolean | undefined; /** * 获取位置信息的超时时间 * 单位为毫秒(ms),默认值为不超时。如果在指定的时间内没有获取到位置信息则触发错误回调函数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ timeout?: number | undefined; @@ -2803,7 +2934,7 @@ interface PlusGeolocationPositionOptions { * 获取位置信息的间隔时间 * 单位为毫秒(ms),默认值为5000(即5秒)。调用plus.geolocation.watchPosition时为更新位置信息的间隔时间。 * 注意:在不同定位模块下支持范围值可能不同,如百度定位模块的间隔范围为大于等于1秒,如果设置的值小于最小值则使用最小值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ maximumAge?: number | undefined; @@ -2818,10 +2949,10 @@ interface PlusGeolocationPositionOptions { * - system: 优先使用系统定位模块 * - baidu: 优先使用百度定位模块 * - amap: 优先使用高德定位模块 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ - provider?: 'system' | 'baidu' | 'amap' | undefined; + provider?: "system" | "baidu" | "amap" | undefined; /** * 指定获取的定位数据坐标系类型 * 可取以下坐标系类型: @@ -2831,7 +2962,7 @@ interface PlusGeolocationPositionOptions { * "bd09ll":表示百度经纬度坐标系; * provider为"system"时,默认使用"wgs84"坐标系;provider为"baidu"时,默认使用"gcj02"坐标系;provider为"amap"时,默认使用"gcj02"坐标系。 * 如果设置的坐标系类型provider不支持,则返回错误。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ coordsType?: string | undefined; @@ -2839,7 +2970,7 @@ interface PlusGeolocationPositionOptions { * 是否解析地址信息 * 解析的地址信息保存到Position对象的address、addresses属性中,true表示解析地址信息,false表示不解析地址信息,返回的Position对象的address、addresses属性值为undefined,默认值为true。 * 如果解析地址信息失败则返回的Position对象的address、addresses属性值为null。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ geocode?: boolean | undefined; @@ -2847,49 +2978,49 @@ interface PlusGeolocationPositionOptions { /** * JSON对象,定位错误信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ interface PlusGeolocationGeolocationError { /** * 访问权限被拒绝 * 系统不允许程序获取定位功能,错误代码常量值为1。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ PERMISSION_DENIED?: number | undefined; /** * 位置信息不可用 * 无法获取有效的位置信息,错误代码常量值为2。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ POSITION_UNAVAILABLE?: number | undefined; /** * 获取位置信息超时 * 无法在指定的时间内获取位置信息,错误代码常量值为3。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ TIMEOUT?: number | undefined; /** * 未知错误 * 其它未知错误导致无法获取位置信息,错误代码常量值为4。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ UNKNOWN_ERROR?: number | undefined; /** * 错误代码 * 取值范围为GeolocationError对象的常量值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ code?: number | undefined; /** * 错误描述信息 * 详细错误描述信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/geolocation.html](http://www.html5plus.org/doc/zh_cn/geolocation.html) */ message?: string | undefined; @@ -2897,48 +3028,58 @@ interface PlusGeolocationGeolocationError { /** * iBeacon模块用于搜索附件的iBeacon设备(*请使用HBuilderX并更新到最新版本*)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) */ interface PlusIbeacon { /** * iBeacon设备信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) */ IBeaconInfo?: PlusIbeaconIBeaconInfo | undefined; /** * 开始搜索附近的iBeacon设备 * 搜索成功后触发successCB回调,失败触发errorCB回调。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) */ - startBeaconDiscovery(uuids?: any [], ignoretoothAvailable?: boolean, success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + startBeaconDiscovery( + uuids?: any[], + ignoretoothAvailable?: boolean, + success?: (result: any) => void, + fail?: (result: any) => void, + complete?: (result: any) => void, + ): void; /** * 停止搜索附近的iBeacon设备 * 取消成功后触发successCB回调,失败触发errorCB回调。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) */ - stopBeaconDiscovery(success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; + stopBeaconDiscovery( + success?: (result: any) => void, + fail?: (result: any) => void, + complete?: (result: any) => void, + ): void; /** * 获取已搜索到的iBeacon设备 * 获取成功后触发successCB回调,失败触发errorCB回调。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) */ getBeacons(success?: (result: any) => void, fail?: (result: any) => void, complete?: (result: any) => void): void; /** * 监听iBeacon设备更新 * iBeacon设备更新后触发updateCB回调。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) */ onBeaconUpdate(updateCB?: (result: any) => void): void; /** * 监听iBeacon服务状态变化 * iBeacon服务状态变化时触发changeCB回调。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) */ onBeaconServiceChange(changeCB?: (result: any) => void): void; @@ -2946,43 +3087,43 @@ interface PlusIbeacon { /** * iBeacon设备信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) */ interface PlusIbeaconIBeaconInfo { /** * iBeacon设备广播的uuid - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) */ uuid?: string | undefined; /** * iBeacon设备的主id - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) */ major?: string | undefined; /** * iBeacon设备的次id - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) */ minor?: string | undefined; /** * iBeacon设备的距离 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) */ proximity?: number | undefined; /** * iBeacon设备的距离精度信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) */ accuracy?: number | undefined; /** * iBeacon设备的信号强度 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ibeacon.html](http://www.html5plus.org/doc/zh_cn/ibeacon.html) */ rssi?: string | undefined; @@ -2990,31 +3131,31 @@ interface PlusIbeaconIBeaconInfo { /** * IO模块管理本地文件系统,用于对文件系统的目录浏览、文件的读取、文件的写入等操作。通过plus.io可获取文件系统管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ interface PlusIo { /** * 文件系统中的目录对象,用于管理特定的本地目录 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ DirectoryEntry?: PlusIoDirectoryEntry | undefined; /** * 读取目录信息对象,用于获取目录中包含的文件及子目录 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ DirectoryReader?: PlusIoDirectoryReader | undefined; /** * 文件系统中的文件数据对象,用于获取文件的数据 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ File?: PlusIoFile | undefined; /** * 文件系统中的文件对象,用于管理特定的本地文件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ FileEntry?: PlusIoFileEntry | undefined; @@ -3022,7 +3163,7 @@ interface PlusIo { * 文件系统中的读取文件对象,用于获取文件的内容 * FileReader对象是从设备文件系统读取文件FileReader对象是从设备文件系统读取文件的一种方式,文件以文本或者Base64编码的字符串形式读出来。 * 用户注册自己的事件监听器来接收loadstart、progress、load、loadend、error和abort事件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ FileReader?: PlusIoFileReader | undefined; @@ -3031,27 +3172,27 @@ interface PlusIo { * FileWriter对象是从设备文件系统写入文件FileWriter对象是从设备文件系统写入文件的一种方式,用户注册自己的事件监听器来接收writestart、progress、write、writeend、error和abort事件。 * 一个FileWriter对象是为单个文件的操作而创建。你可以使用该对象多次对相应文件进行写入操作。FileWriter维护该文件的指针位置及长度属性,这样你就可以寻找和写入文件的任何地方。 * 默认情况下,FileWriter从文件的开头开始写入(将覆盖现有数据)。FileWriter对象的seek方法可设置文件操作指定位置,如fw.seek(fw.length-1)写入操作就会从文件的末尾开始。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ FileWriter?: PlusIoFileWriter | undefined; /** * 文件系统对象,用于管理特定本地文件目录 * 文件系统对象表示一个应用可访问的根目录。name属性用于标识此根目录的名称,与LocalFileSystem中的文件系统类型一一对应。root属性为文件目录对象,用于实际操作文件系统,参考DirectoryEntry。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ FileSystem?: PlusIoFileSystem | undefined; /** * JSON对象,获取文件操作的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ Flags?: PlusIoFlags | undefined; /** * JSON对象,保存文件或目录的状态信息对象 * 可通过DirectoryEntry或FileEntry对象的getMetaData方法获取 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ Metadata?: PlusIoMetadata | undefined; @@ -3059,21 +3200,21 @@ interface PlusIo { * 文件或目录操作事件对象 * 所有文件或目录操作事件回调函数中都创建该对象的实例。 * 该对象从DOMEvent继承而来,可通过该其target属性获取事件触发的文件或目录操作对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ FileEvent?: PlusIoFileEvent | undefined; /** * 文件路径类型 * 在文件系统中的文件路径需转换成URL格式,已方便runtime快速加载。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ URLType?: PlusIoURLType | undefined; /** * 相对路径URL * 只能在扩展API中使用,相对于基座提供的特定目录,以“_”开头。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ RelativeURL?: PlusIoRelativeURL | undefined; @@ -3081,7 +3222,7 @@ interface PlusIo { * 本地路径URL * 可在html页面中直接访问本地资源,以“file:///”开头,后面跟随系统的绝对路径。 * 如示例:“file:///D:/res/hello.html”。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ LocalURL?: PlusIoLocalURL | undefined; @@ -3089,7 +3230,7 @@ interface PlusIo { * 网络路径URL * 可在html页面中以网络资源模式访问本地资源,以“http://”开头,后面跟随相对路径。 * 如示例:“http://localhost:13131/_www/res/icon.png”,其中“_www”字段可支持类型与相对路径URL一致。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ RemoteURL?: PlusIoRemoteURL | undefined; @@ -3097,28 +3238,28 @@ interface PlusIo { * 应用运行资源目录常量 * 本地文件系统常量,Number类型,固定值1。应用运行资源目录,仅本应用可访问。 * 为了确保应用资源的安全性,此目录只可读。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ PRIVATE_WWW?: number | undefined; /** * 应用私有文档目录常量 * 本地文件系统常量,Number类型,固定值2。应用私有文档目录,仅本应用可读写。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ PRIVATE_DOC?: number | undefined; /** * 程序公用文档目录常量 * 本地文件系统常量,Number类型,固定值3。程序公用文档目录,所有应用可读写。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ PUBLIC_DOCUMENTS?: number | undefined; /** * 程序公用下载目录常量 * 本地文件系统常量,Number类型,固定值4。程序公用下载目录,所有应用可读写。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ PUBLIC_DOWNLOADS?: number | undefined; @@ -3126,23 +3267,31 @@ interface PlusIo { * 请求本地文件系统对象 * 获取指定的文件系统,可通过type指定获取文件系统的类型。 * 获取指定的文件系统对象成功通过succesCB回调返回,失败则通过errorCB返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ - requestFileSystem(type?: number, succesCB?: (result: PlusIoFileSystem) => void, errorCB?: (result: any) => void): void; + requestFileSystem( + type?: number, + succesCB?: (result: PlusIoFileSystem) => void, + errorCB?: (result: any) => void, + ): void; /** * 通过URL参数获取目录对象或文件对象 * 快速获取指定的目录或文件操作对象,如通过URL值“_www/test.html”可直接获取文件操作对象。 * url值可支持相对路径URL、本地路径URL。 * 获取指定的文件或目录操作对象成功通过succesCB回调返回,如果指定URL路径或文件不存在则失败通过errorCB回调返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ - resolveLocalFileSystemURL(url ?: string, succesCB?: (result: PlusIoDirectoryEntry) => void, errorCB?: (result: any) => void): void; + resolveLocalFileSystemURL( + url?: string, + succesCB?: (result: PlusIoDirectoryEntry) => void, + errorCB?: (result: any) => void, + ): void; /** * 将本地URL路径转换成平台绝对路径 * 绝对路径符合各平台文件路径格式,通常用于Native.JS调用系统原生文件操作API,也可以在前面添加“file://”后在html页面中直接使用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ convertLocalFileSystemURL(url?: string): string; @@ -3150,7 +3299,7 @@ interface PlusIo { * 将平台绝对路径转换成本地URL路径 * 绝对路径符合各平台文件路径格式,转换后变成RelativeURL类型格式。 * 功能与convertLocalFileSystemURL方法相反,将绝对路径转换成相对路径。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ convertAbsoluteFileSystem(path?: string): string; @@ -3158,37 +3307,37 @@ interface PlusIo { /** * 文件系统中的目录对象,用于管理特定的本地目录 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ interface PlusIoDirectoryEntry { /** * 操作对象的是否为文件,DirectoryEntry对象固定其值为false - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ isFile?: boolean | undefined; /** * 操作对象是否为目录,DirectoryEntry对象固定其值为true - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ isDirectory?: boolean | undefined; /** * 目录操作对象的名称,不包括路径 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ name?: string | undefined; /** * 目录操作对象的完整路径,文件系统的绝对路径 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ fullPath?: string | undefined; /** * 文件操作对象所属的文件系统对象,参考FileSystem - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ fileSystem?: PlusIoFileSystem | undefined; @@ -3196,10 +3345,14 @@ interface PlusIoDirectoryEntry { * 获取目录的属性 * 用于获取文件或目录的属性信息。 * 获取属性信息成功通过succesCB回调返回,失败则通过errorCB返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ - getMetadata(succesCB?: (result: PlusIoMetadata) => void, errorCB?: (result: any) => void, recursive?: boolean): void; + getMetadata( + succesCB?: (result: PlusIoMetadata) => void, + errorCB?: (result: any) => void, + recursive?: boolean, + ): void; /** * 移动目录 * 以下情况移动目录将会导致失败: @@ -3208,10 +3361,15 @@ interface PlusIoDirectoryEntry { * 要移动到的目标路径被文件占用; * 要移动到的目标目录已经存在并且不为空。 * 移动目录成功通过succesCB回调返回,失败则通过errorCB返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ - moveTo(parent?: PlusIoDirectoryEntry, newName?: string, succesCB?: (result: PlusIoDirectoryEntry) => void, errorCB?: (result: any) => void): void; + moveTo( + parent?: PlusIoDirectoryEntry, + newName?: string, + succesCB?: (result: PlusIoDirectoryEntry) => void, + errorCB?: (result: any) => void, + ): void; /** * 拷贝目录 * 以下情况拷贝目录将会导致失败: @@ -3220,25 +3378,30 @@ interface PlusIoDirectoryEntry { * 要拷贝到的目标路径被文件占用; * 要拷贝到的目标目录已经存在并且不为空。 * 拷贝目录成功通过succesCB回调返回,失败则通过errorCB返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ - copyTo(parent?: PlusIoDirectoryEntry, newName?: string, succesCB?: (result: PlusIoDirectoryEntry) => void, errorCB?: (result: any) => void): void; + copyTo( + parent?: PlusIoDirectoryEntry, + newName?: string, + succesCB?: (result: PlusIoDirectoryEntry) => void, + errorCB?: (result: any) => void, + ): void; /** * 获取目录路径转换为URL地址 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ toURL(): string; /** * 获取目录路径转换为本地路径URL地址 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ toLocalURL(): string; /** * 获取目录路径转换为网络路径URL地址 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ toRemoteURL(): string; @@ -3248,21 +3411,21 @@ interface PlusIoDirectoryEntry { * 目录中存在文件; * 删除根目录; * 删除目录成功通过succesCB回调返回,失败则通过errorCB返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ remove(succesCB?: (result: PlusIoDirectoryEntry) => void, errorCB?: (result: any) => void): void; /** * 获取目录所属的父目录 * 获取父目录成功通过succesCB回调返回,失败则通过errorCB返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ getParent(succesCB?: (result: PlusIoDirectoryEntry) => void, errorCB?: (result: any) => void): void; /** * 创建目录读取对象 * 创建一个目录读取对象,用户读取目下的文件及子目录。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ createReader(): PlusIoDirectoryReader; @@ -3270,24 +3433,34 @@ interface PlusIoDirectoryEntry { * 创建或打开子目录 * 创建或打开当前目录指定的目录。 * 创建或打开目录操作成功通过succesCB回调返回,失败则通过errorCB返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ - getDirectory(path?: string, flag?: PlusIoFlags, succesCB?: (result: PlusIoDirectoryEntry) => void, errorCB?: (result: any) => void): void; + getDirectory( + path?: string, + flag?: PlusIoFlags, + succesCB?: (result: PlusIoDirectoryEntry) => void, + errorCB?: (result: any) => void, + ): void; /** * 创建或打开文件 * 创建或打开当前目录下指定的文件。 * 创建或打开文件操作对象成功通过succesCB回调返回,失败则通过errorCB返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ - getFile(path?: string, flag?: PlusIoFlags, succesCB?: (result: PlusIoDirectoryEntry) => void, errorCB?: (result: any) => void): void; + getFile( + path?: string, + flag?: PlusIoFlags, + succesCB?: (result: PlusIoDirectoryEntry) => void, + errorCB?: (result: any) => void, + ): void; /** * 递归删除目录 * 删除目录将会删除其下的所有文件及子目录 * 不能删除根目录,如果操作删除根目录将会删除目录下的文件及子目录,不会删除根目录自身。 * 删除目录成功通过succesCB回调返回,失败则通过errorCB返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ removeRecursively(succesCB?: (result: PlusIoDirectoryEntry) => void, errorCB?: (result: any) => void): void; @@ -3295,7 +3468,7 @@ interface PlusIoDirectoryEntry { /** * 读取目录信息对象,用于获取目录中包含的文件及子目录 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ interface PlusIoDirectoryReader { @@ -3303,7 +3476,7 @@ interface PlusIoDirectoryReader { * 获取当前目录中的所有文件和子目录 * 获取当前目录下的所有文件和子目录。 * 获取操作成功通过succesCB回调返回,失败则通过errorCB返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ readEntries(succesCB?: (result: PlusIoDirectoryEntry) => void, errorCB?: (result: any) => void): void; @@ -3311,45 +3484,45 @@ interface PlusIoDirectoryReader { /** * 文件系统中的文件数据对象,用于获取文件的数据 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ interface PlusIoFile { /** * 文件数据对象的数据大小,单位为字节 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ size?: number | undefined; /** * 文件数据对象MIME类型 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ type?: string | undefined; /** * 文件数据对象的名称,不包括路径 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ name?: string | undefined; /** * 文件对象的最后修改时间 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ lastModifiedDate?: Date | undefined; /** * 获取文件指定的数据内容 * 获取文件指定的数据内容,其中end必须大于start。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ slice(start?: number, end?: number): PlusIoFile; /** * 关闭文件数据对象 * 当文件数据对象不再使用时,可通过此方法关闭,释放系统资源。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ close(): void; @@ -3357,37 +3530,37 @@ interface PlusIoFile { /** * 文件系统中的文件对象,用于管理特定的本地文件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ interface PlusIoFileEntry { /** * 文件操作对象的是否为文件,FileEntry对象固定其值为true - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ isFile?: boolean | undefined; /** * 文件操作对象是否为目录,FileEntry对象固定其值为false - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ isDirectory?: boolean | undefined; /** * 文件操作对象的名称,不包括路径 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ name?: string | undefined; /** * 文件操作对象的完整路径,文件系统的绝对路径 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ fullPath?: string | undefined; /** * 文件操作对象所属的文件系统对象,参考FileSystem - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ fileSystem?: PlusIoFileSystem | undefined; @@ -3395,7 +3568,7 @@ interface PlusIoFileEntry { * 获取文件的属性信息 * 用于获取文件的属性信息。 * 获取属性信息成功通过succesCB回调返回,失败则通过errorCB返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ getMetadata(succesCB?: (result: PlusIoMetadata) => void, errorCB?: (result: any) => void): void; @@ -3405,64 +3578,74 @@ interface PlusIoFileEntry { * 要移动到的目标目录无效; * 要移动到的目标路径被其它文件占用; * 移动文件成功通过succesCB回调返回,失败则通过errorCB返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ - moveTo(parent?: PlusIoDirectoryEntry, newName?: string, succesCB?: (result: PlusIoDirectoryEntry) => void, errorCB?: (result: any) => void): void; + moveTo( + parent?: PlusIoDirectoryEntry, + newName?: string, + succesCB?: (result: PlusIoDirectoryEntry) => void, + errorCB?: (result: any) => void, + ): void; /** * 拷贝文件 * 以下情况拷贝文件将会导致失败: * 要拷贝到的目标目录无效; * 要拷贝到的目标路径被其它文件占用; * 拷贝文件成功通过succesCB回调返回,失败则通过errorCB返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ - copyTo(parent?: PlusIoDirectoryEntry, newName?: string, succesCB?: (result: PlusIoDirectoryEntry) => void, errorCB?: (result: any) => void): void; + copyTo( + parent?: PlusIoDirectoryEntry, + newName?: string, + succesCB?: (result: PlusIoDirectoryEntry) => void, + errorCB?: (result: any) => void, + ): void; /** * 获取文件路径转换为URL地址 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ toURL(): string; /** * 获取文件路径转换为本地路径URL地址 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ toLocalURL(): string; /** * 获取文件路径转换为网络路径URL地址 * URL地址格式为以“http://localhost:13131/”开头的网络路径。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ toRemoteURL(): string; /** * 删除文件 * 删除文件成功通过succesCB回调返回,失败则通过errorCB返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ remove(succesCB?: (result: PlusIoDirectoryEntry) => void, errorCB?: (result: any) => void): void; /** * 获取文件所属的父目录 * 获取父目录成功通过succesCB回调返回,失败则通过errorCB返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ getParent(succesCB?: (result: PlusIoDirectoryEntry) => void, errorCB?: (result: any) => void): void; /** * 获取文件关联的写文件操作对象FileWriter * 获取写文件操作对象成功通过succesCB回调返回,失败则通过errorCB返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ createWriter(succesCB?: (result: PlusIoFileWriter) => void, errorCB?: (result: any) => void): void; /** * 获取文件数据对象 * 获取文件数据对象成功通过succesCB回调返回,失败则通过errorCB返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ file(succesCB?: (result: PlusIoFile) => void, errorCB?: (result: any) => void): void; @@ -3472,82 +3655,82 @@ interface PlusIoFileEntry { * 文件系统中的读取文件对象,用于获取文件的内容 * FileReader对象是从设备文件系统读取文件FileReader对象是从设备文件系统读取文件的一种方式,文件以文本或者Base64编码的字符串形式读出来。 * 用户注册自己的事件监听器来接收loadstart、progress、load、loadend、error和abort事件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ interface PlusIoFileReader { /** * 值为0,开始读取文件状态 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ EMPTY?: number | undefined; /** * 值为1,正在读取文件状态 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ LOADING?: number | undefined; /** * 值为2,读文件操作完成状态 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ DONE?: number | undefined; /** * 当前读取文件所处的状态 * 可取上面定义的常量值,EMPTY(0)、LOADING(1)、DONE(2)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ readyState?: number | undefined; /** * 已读取文件的内容 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ result?: string | undefined; /** * 文件操作错误代码 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ error?: number | undefined; /** * 读取文件开始时的回调函数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ onloadstart?: ((result: PlusIoFileEvent) => void) | undefined; /** * 读取文件过程中的回调函数 * 用于获取文件读取进度。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ onprogress?: ((result: PlusIoFileEvent) => void) | undefined; /** * 读取文件成功完成的回调函数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ onload?: ((result: PlusIoFileEvent) => void) | undefined; /** * 取消读取文件时的回调函数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ onabort?: ((result: PlusIoFileEvent) => void) | undefined; /** * 文件读取操作失败时调用的回调函数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ onerror?: ((result: PlusIoFileEvent) => void) | undefined; /** * 文件读取操作完成时的回调函数 * 不管成功或失败都会触发。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ onloadend?: ((result: PlusIoFileEvent) => void) | undefined; @@ -3555,24 +3738,24 @@ interface PlusIoFileReader { * 终止文件读取操作 * 读取文件操作开始后,可通过此方法取消读取文件。 * 调用此方法后将触发文件读取对象的onabort事件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ abort(): void; /** * 以URL编码格式读取文件数据内容 * 读取文件的数据内容,并将数据内容进行URL编码。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ - readAsDataURL(file?: PlusIoFile, encoding ?: string): void; + readAsDataURL(file?: PlusIoFile, encoding?: string): void; /** * 以文本格式读取文件数据内容 * 读取文件的数据内容。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ - readAsText(file?: PlusIoFile, encoding ?: string): void; + readAsText(file?: PlusIoFile, encoding?: string): void; } /** @@ -3580,88 +3763,88 @@ interface PlusIoFileReader { * FileWriter对象是从设备文件系统写入文件FileWriter对象是从设备文件系统写入文件的一种方式,用户注册自己的事件监听器来接收writestart、progress、write、writeend、error和abort事件。 * 一个FileWriter对象是为单个文件的操作而创建。你可以使用该对象多次对相应文件进行写入操作。FileWriter维护该文件的指针位置及长度属性,这样你就可以寻找和写入文件的任何地方。 * 默认情况下,FileWriter从文件的开头开始写入(将覆盖现有数据)。FileWriter对象的seek方法可设置文件操作指定位置,如fw.seek(fw.length-1)写入操作就会从文件的末尾开始。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ interface PlusIoFileWriter { /** * 值为0,写文件初始化状态 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ INIT?: number | undefined; /** * 值为1,正在写入文件状态 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ WRITING?: number | undefined; /** * 值为2,写文件操作完成状态 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ DONE?: number | undefined; /** * 当前写入文件所处的状态 * 可取上面定义的常量值,INIT(0)、WRITING(1)、DONE(2)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ readyState?: number | undefined; /** * 文件当前的长度,单位为字节 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ length?: number | undefined; /** * 文件当前操作的指针位置 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ position?: number | undefined; /** * 文件写入操作错误代码 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ error?: number | undefined; /** * 写入文件开始时的回调函数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ onwritestart?: ((result: PlusIoFileEvent) => void) | undefined; /** * 写入文件过程中的回调函数 * 用于获取文件读取进度。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ onprogress?: ((result: PlusIoFileEvent) => void) | undefined; /** * 写入文件成功完成的回调函数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ onwrite?: ((result: PlusIoFileEvent) => void) | undefined; /** * 取消写入文件时的回调函数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ onabort?: ((result: PlusIoFileEvent) => void) | undefined; /** * 文件写入操作失败时调用的回调函数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ onerror?: ((result: PlusIoFileEvent) => void) | undefined; /** * 文件写入操作完成时的回调函数 * 不管成功或失败都会触发。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ onwriteend?: ((result: PlusIoFileEvent) => void) | undefined; @@ -3669,7 +3852,7 @@ interface PlusIoFileWriter { * 终止文件写入操作 * 写入文件数据操作开始后,可通过此方法取消写入文件数据操作。 * 调用此方法后将触发文件写入对象的onabort事件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ abort(): void; @@ -3677,44 +3860,44 @@ interface PlusIoFileWriter { * 定位文件操作位置 * 定位文件的操作位置,有效值为0到文件的总长度减1。 * 0表示文件的起始位置。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ seek(position?: number): void; /** * 按照指定长度截断文件 * 从文件当前定位的位置开始,按照指定长度截断文件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ - truncate(length ?: number): void; + truncate(length?: number): void; /** * 向文件中写入数据 * 从文件当前定位的位置开始,写入数据到文件中。 * 如果文件中已经存在数据,新写入的数据将覆盖已有数据。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ - write(data ?: string): void; + write(data?: string): void; } /** * 文件系统对象,用于管理特定本地文件目录 * 文件系统对象表示一个应用可访问的根目录。name属性用于标识此根目录的名称,与LocalFileSystem中的文件系统类型一一对应。root属性为文件目录对象,用于实际操作文件系统,参考DirectoryEntry。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ interface PlusIoFileSystem { /** * 文件系统的名称 * 值为文件系统类型常量值字符串,如“PRIVATE_WWW”、“PRIVATE_DOCUMENTS”。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ name?: string | undefined; /** * 文件系统的根目录 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ root?: PlusIoDirectoryEntry | undefined; @@ -3722,21 +3905,21 @@ interface PlusIoFileSystem { /** * JSON对象,获取文件操作的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ interface PlusIoFlags { /** * 是否创建对象标记 * 指示如果文件或目录不存在时是否进行创建,默认值为false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ create?: boolean | undefined; /** * 反向操作标记 * 其本身没有任何效果,需与create属性值设置为true时一起使用,如果目标文件或目录已经存在则会导致文件或目录打开失败,默认值为false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ exclusive?: boolean | undefined; @@ -3745,34 +3928,34 @@ interface PlusIoFlags { /** * JSON对象,保存文件或目录的状态信息对象 * 可通过DirectoryEntry或FileEntry对象的getMetaData方法获取 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ interface PlusIoMetadata { /** * 文件或目录的最后修改时间 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ modificationTime?: Date | undefined; /** * 文件的大小 * 若获取的是目录对象的属性则值为0。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ size?: number | undefined; /** * 包含的子目录数 * 若自身是文件则其值为0。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ directoryCount?: number | undefined; /** * 目录的文件数 * 若自身是文件则其值为0。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ fileCount?: number | undefined; @@ -3782,14 +3965,14 @@ interface PlusIoMetadata { * 文件或目录操作事件对象 * 所有文件或目录操作事件回调函数中都创建该对象的实例。 * 该对象从DOMEvent继承而来,可通过该其target属性获取事件触发的文件或目录操作对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ interface PlusIoFileEvent { /** * 文件或目录操作对象 * 在不同的回调中指向的对象不同,可指向的对象包括:FileEntry、DirectoryEntry、FileReader、FileWriter。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ target?: PlusIoDirectoryEntry | undefined; @@ -3798,28 +3981,28 @@ interface PlusIoFileEvent { /** * 文件路径类型 * 在文件系统中的文件路径需转换成URL格式,已方便runtime快速加载。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ interface PlusIoURLType { /** * 相对路径URL * 只能在扩展API中使用,相对于基座提供的特定目录,以“_”开头。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ RelativeURL?: PlusIoRelativeURL | undefined; /** * 本地路径URL * 可在html页面中直接访问本地资源,以“file:///”开头,后面跟随系统的绝对路径。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ LocalURL?: PlusIoLocalURL | undefined; /** * 网络路径URL * 可在html页面中以网络资源模式访问本地资源,以“http://”开头,后面跟随相对路径。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ RomoteURL?: string | undefined; @@ -3828,7 +4011,7 @@ interface PlusIoURLType { /** * 相对路径URL * 只能在扩展API中使用,相对于基座提供的特定目录,以“_”开头。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ interface PlusIoRelativeURL { @@ -3836,28 +4019,28 @@ interface PlusIoRelativeURL { * 应用资源目录 * 保存应用的所有html、css、js等资源文件,与文件系统中根目录PRIVATE_WWW一致,后面加相对路径如“_www/res/icon.png”。 * 注意:应用资源目录是只读目录,只能读取次目录下的文件,不能修改或新建。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ _www?: string | undefined; /** * 应用私有文档目录 * 用于保存应用运行期业务逻辑数据,与文件系统中根目录PRIVATE_DOCUMENTS,如“_doc/userdata.xml”。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ _doc?: string | undefined; /** * 程序公用文档目录 * 用于保存程序中各应用间可共享文件的目录,与文件系统中根目录PUBLIC_DOCUMENTS,如“_document/share.doc”。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ _documents?: string | undefined; /** * 程序公用下载目录 * 用于保存程序下载文件的目录,与文件系统中根目录PUBLIC_DOWNLOADS,如“_download/mydoc.doc”。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ _downloads?: string | undefined; @@ -3867,7 +4050,7 @@ interface PlusIoRelativeURL { * 本地路径URL * 可在html页面中直接访问本地资源,以“file:///”开头,后面跟随系统的绝对路径。 * 如示例:“file:///D:/res/hello.html”。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ type PlusIoLocalURL = any; @@ -3875,14 +4058,14 @@ type PlusIoLocalURL = any; * 网络路径URL * 可在html页面中以网络资源模式访问本地资源,以“http://”开头,后面跟随相对路径。 * 如示例:“http://localhost:13131/_www/res/icon.png”,其中“_www”字段可支持类型与相对路径URL一致。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/io.html](http://www.html5plus.org/doc/zh_cn/io.html) */ type PlusIoRemoteURL = any; /** * Native.js for iOS封装一条通过JS语法直接调用Native Objective-C接口通道,通过plus.ios可调用几乎所有的系统API。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) */ interface PlusIos { @@ -3890,7 +4073,7 @@ interface PlusIos { * Objective-C类对象 * Objective-C类对象,可通过其属性获取类的常量,可通过方法来操作类的静态方法,也通过new方法来创建类的实例对象。 * 对于类的静态方法,则直接通过.后面跟随方法名称调用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) */ ClassObject?: PlusIosClassObject | undefined; @@ -3898,7 +4081,7 @@ interface PlusIos { * Objective-C实例对象 * Objective-C实例对象,可通过其方法来操作示例的变量和方法。 * 注意:必须通过plusGetAttribute()方法读取示例对象的属性值,通过plusSetAttribute()方法设置示例对象的属性值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) */ InstanceObject?: PlusIosInstanceObject | undefined; @@ -3907,38 +4090,38 @@ interface PlusIos { * 导入类对象后,就可以通过.操作符直接调用对象(类对象/实例对象)的方法。 * 通过.操作符号调用方法时,不需要使用":"来分割参数。 * 注意:导入类对象将会消耗较多的系统资源,不应该导入过多的类对象,可以使用plus.ios.invoke()来调用未导入类实例对象的方法。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) */ importClass(classname?: string): PlusIosClassObject; /** * 创建实例对象 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) */ newObject(classname?: string, args?: any): PlusIosInstanceObject; /** * 销毁实例对象 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) */ deleteObject(obj?: any): void; /** * 调用对象(类对象/示例对象)的方法 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) */ invoke(obj?: PlusIosInstanceObject, name?: string, args?: any): any; /** * 实现代理的方法 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) */ implements(name?: string, obj?: any): PlusIosInstanceObject; /** * 获取当前Webview窗口对象的native层UIWebview实例对象 * UIWebview对象的API请参考Apple开发文档 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) */ currentWebview(): PlusIosInstanceObject; @@ -3948,7 +4131,7 @@ interface PlusIos { * Objective-C类对象 * Objective-C类对象,可通过其属性获取类的常量,可通过方法来操作类的静态方法,也通过new方法来创建类的实例对象。 * 对于类的静态方法,则直接通过.后面跟随方法名称调用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) */ type PlusIosClassObject = any; @@ -3957,19 +4140,19 @@ type PlusIosClassObject = any; * Objective-C实例对象 * Objective-C实例对象,可通过其方法来操作示例的变量和方法。 * 注意:必须通过plusGetAttribute()方法读取示例对象的属性值,通过plusSetAttribute()方法设置示例对象的属性值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) */ interface PlusIosInstanceObject { /** * 获取Objective-C实例对象的属性 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) */ plusGetAttribute(name?: string): any; /** * 设置Objective-C示例对象的属性 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/ios.html](http://www.html5plus.org/doc/zh_cn/ios.html) */ plusSetAttribute(name?: string, value?: any): void; @@ -3977,19 +4160,19 @@ interface PlusIosInstanceObject { /** * Key管理设备按键事件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) */ interface PlusKey { /** * 按键类型 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) */ KeyType?: PlusKeyKeyType | undefined; /** * 按键事件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) */ KeyEvent?: PlusKeyKeyEvent | undefined; @@ -3999,14 +4182,14 @@ interface PlusKey { * 应用中存在多个Webview窗口时,按照窗口的显示栈顺序从后往前查找,查找到添加按键事件监听器的窗口后停止(中断前面Webview窗口对按键事件的监听),并向窗口触发执行按键回调事件。 * 在同一Webview窗口中可多次调用此方法对同一事件添加多个监听器,触发时按照添加的顺序先后调用。 * 注意:此方法无法监听软键盘的按键事件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) */ addEventListener(event?: PlusKeyKeyType, listener?: (result: PlusKeyKeyEvent) => void, capture?: boolean): void; /** * 隐藏软键盘 * 隐藏已经显示的软键盘,如果软键盘没有显示则不做任何操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) */ hideSoftKeybord(): void; @@ -4014,21 +4197,21 @@ interface PlusKey { * 设置辅助输入类型 * input的type类型为text获取焦点时,在软键盘上方显示辅助输入条方便用户快速输入。 * 在页面中input编辑框type类型不为"tel"、"email"时生效(type为tel类型时一定显示tel的辅助输入条,type为email时一定显示email的辅助输入条)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) */ setAssistantType(type?: string): void; /** * 显示软键盘 * 强制显示系统软键盘,如果软键盘已经显示则不做任何操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) */ showSoftKeybord(): void; /** * 移除按键事件监听器 * 从窗口移除指定的事件监听器。若没有查找到对应的事件监听器,则无任何作用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) */ removeEventListener(event?: PlusKeyKeyType, listener?: (result: PlusKeyKeyEvent) => void): void; @@ -4036,14 +4219,14 @@ interface PlusKey { /** * 按键类型 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) */ interface PlusKeyKeyType { /** * 设备“返回”按钮按键事件 * 如果需要改变默认“返回”按钮的处理逻辑,则可通过plus.key.addEventListener来注册监听"backbutton"事件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) */ backbutton?: string | undefined; @@ -4051,7 +4234,7 @@ interface PlusKeyKeyType { * 键按下事件 * 如果需要改变默认键按下的处理逻辑,则可通过plus.key.addEventListener来注册监听"keydown"事件。 * 可通过回调函数中KeyEvent对象的keyCode来获取按下的键值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) */ keydown?: string | undefined; @@ -4059,7 +4242,7 @@ interface PlusKeyKeyType { * 键松开事件 * 如果需要改变默认键松开的处理逻辑,则可通过plus.key.addEventListener来注册监听"keyup"事件。 * 可通过回调函数中KeyEvent对象的keyCode来获取松开的键值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) */ keyup?: string | undefined; @@ -4067,35 +4250,35 @@ interface PlusKeyKeyType { * 长按键事件 * 如果需要改变默认长按键的处理逻辑,则可通过plus.key.addEventListener来注册监听"longpressed"事件。 * 长按键时会多次触发回调函数,通过回调函数中KeyEvent对象的keyCode来获取长按的键值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) */ longpressed?: string | undefined; /** * 设备“菜单”按钮按键事件 * 如果需要改变默认“菜单”按钮的处理逻辑,则可通过plus.key.addEventListener来注册监听"menubutton"事件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) */ menubutton?: string | undefined; /** * 设备“搜索”按钮按键事件 * 如果需要改变默认“搜索”按钮的处理逻辑,则可通过plus.key.addEventListener来注册监听"searchbutton"事件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) */ searchbutton?: string | undefined; /** * 设备“音量+”按钮按键事件 * 如果需要改变默认“音量+”按钮的处理逻辑,则可通过plus.key.addEventListener来注册监听"volumeupbutton"事件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) */ volumeupbutton?: string | undefined; /** * 设备“音量-”按钮按键事件 * 如果需要改变默认“音量-”按钮的处理逻辑,则可通过plus.key.addEventListener来注册监听"volumedownbutton"事件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) */ volumedownbutton?: string | undefined; @@ -4103,21 +4286,21 @@ interface PlusKeyKeyType { /** * 按键事件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) */ interface PlusKeyKeyEvent { /** * 触发按键事件的键值 * 键值由各系统平台定义,一些特殊按键在不同的设备上可能存在差异。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) */ keyCode?: number | undefined; /** * 按键事件类型 * 用于表明触发此按键事件的类型,值为KeyType中定义的值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/key.html](http://www.html5plus.org/doc/zh_cn/key.html) */ keyType?: PlusKeyKeyType | undefined; @@ -4125,55 +4308,55 @@ interface PlusKeyKeyEvent { /** * Messaging模块管理设备通讯功能,可用于短信、彩信、邮件发送等。通过plus.messaging可获取设备通讯管理对象。另外也可以直接通过html中的href直接快速发送短信、拨打电话、发送邮件等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) */ interface PlusMessaging { /** * 消息对象 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) */ Message?: PlusMessagingMessage | undefined; /** * 消息体内容类型 * 用于设定消息的消息体内容。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) */ BodyType?: PlusMessagingBodyType | undefined; /** * 简单短信类型常量 * 消息类型常量,Number类型,固定值为1,用于创建并发送短信。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) */ TYPE_SMS?: number | undefined; /** * 彩信类型常量 * 消息类型常量,Number类型,固定值为2,用于创建并发送多媒体短信(彩信)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) */ TYPE_MMS?: number | undefined; /** * 邮件类型常量 * 消息类型常量,Number类型,固定值为3,用于创建并发送邮件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) */ TYPE_EMAIL?: number | undefined; /** * 创建消息对象 * 创建指定类型的消息,消息类型可取plus.messaging.TYPE_SMS、plus.messaging.TYPE_MMS、plus.messaging.TYPE_EMAIL。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) */ - createMessage(type ?: number): PlusMessagingMessage; + createMessage(type?: number): PlusMessagingMessage; /** * 发送消息 * 发送消息,发送成功回调successCB函数,发送失败回调errorCB函数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) */ sendMessage(msg?: PlusMessagingMessage, successCB?: () => void, errorCB?: (result: any) => void): void; @@ -4181,49 +4364,49 @@ interface PlusMessaging { /** * 消息对象 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) */ interface PlusMessagingMessage { /** * 收件人信息 * 字符串数组类型,输入的地址收件人信息必须符合消息类型格式。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) */ - to?: any [] | undefined; + to?: any[] | undefined; /** * 抄送人信息 * 字符串数组类型,仅发送邮件时有效,输入的地址收件人信息必须符合消息类型格式。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) */ - cc?: any [] | undefined; + cc?: any[] | undefined; /** * 暗送人信息 * 字符串数组类型,仅发送邮件时有效,输入的地址收件人信息必须符合消息类型格式。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) */ - bcc?: any [] | undefined; + bcc?: any[] | undefined; /** * 发件人信息 * 仅在监听接收到的信息时有效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) */ from?: string | undefined; /** * 发送消息主题 * 字符串类型,仅发送邮件时有效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) */ subject?: string | undefined; /** * 发送消息内容 * 字符串类型,要发送的消息体内容,其格式必须与bodyType指定的一致。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) */ body?: string | undefined; @@ -4232,21 +4415,21 @@ interface PlusMessagingMessage { * 要发送消息体内容的类型,可取值"text"表示文本内容,"html"表示为html页面,默认值为"text"。 * - text/plain: 纯文本类型消息体内容 * - text/html: 网页数据类型消息体内容(用于发送邮件) - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) */ - bodyType?: 'text/plain' | 'text/html' | undefined; + bodyType?: "text/plain" | "text/html" | undefined; /** * 是否采用静默方式发送消息 * 布尔类型,可取值为true或false,true表示静默方式发送,不弹出界面;false表示非静默方式发送。默认采用非静默方式。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) */ silent?: boolean | undefined; /** * 添加附件 * 向消息中添加附件,仅邮件类型消息支持,其它类型消息不支持。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) */ addAttachment(url?: string): void; @@ -4255,77 +4438,77 @@ interface PlusMessagingMessage { /** * 消息体内容类型 * 用于设定消息的消息体内容。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) */ interface PlusMessagingBodyType { /** * 文本类型 * 纯文本类型消息体内容,默认消息体内容类型。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) */ - 'text/plain'?: string | undefined; + "text/plain"?: string | undefined; /** * Html类型 * 网页数据类型消息体内容,可用于发送邮件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/messaging.html](http://www.html5plus.org/doc/zh_cn/messaging.html) */ - 'text/html'?: string | undefined; + "text/html"?: string | undefined; } /** * nativeObj管理系统原生对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ interface PlusNativeObj { /** * 原生动画参数 * 指定动画的类型、持续时间等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ AnimationOptions?: PlusNativeObjAnimationOptions | undefined; /** * 原生动画窗口样式 * 指定动画窗口的样式,如背景图片,绘制的文字等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ AnimationViewStyles?: PlusNativeObjAnimationViewStyles | undefined; /** * 原生图片对象 * 原生图片对象会占用较大的内存资源,在使用时需谨慎管理,当图片不再使用时应该及时调用clear方法进行销毁。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ Bitmap?: PlusNativeObjBitmap | undefined; /** * JSON对象,保存图片的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ BitmapSaveOptions?: PlusNativeObjBitmapSaveOptions | undefined; /** * 原生图片轮播控件对象 * 原生图片轮播控件对象从原生View控件(plus.nativeObj.View)继承而来,用于绘制图片轮播内容。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ ImageSlider?: PlusNativeObjImageSlider | undefined; /** * 图片轮播控件样式 * 从ViewStyles继承而来,扩展支持轮播图片等配置。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ ImageSliderStyles?: PlusNativeObjImageSliderStyles | undefined; /** * 图片轮播控件中图片项配置参数 * 用于指定图片地址等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ ImageSliderImageStyles?: PlusNativeObjImageSliderImageStyles | undefined; @@ -4333,83 +4516,83 @@ interface PlusNativeObj { * 输入框样式 * 用于定义输入框的显示样式,如字体大小,提示内容等信息。 * 输入文本内容在指定区域水平居左,垂直居中显示。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ InputStyles?: PlusNativeObjInputStyles | undefined; /** * 区域信息对象 * 包括位置、大小等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ Rect?: PlusNativeObjRect | undefined; /** * 绘制区域样式对象 * 用于定义矩形区域的显示样式,如空心/实心样式、圆角等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ RectStyles?: PlusNativeObjRectStyles | undefined; /** * 富文本样式 * 用于定义富文本使用的默认使用的字体名称、字体文件路径等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ RichTextStyles?: PlusNativeObjRichTextStyles | undefined; /** * 区域信息对象 * 包括位置、大小等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ Position?: PlusNativeObjPosition | undefined; /** * 绘制文本样式对象 * 用于定义文本的显示样式,如字体大小、字体颜色、字体粗细、字体样式、字体名称等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ TextStyles?: PlusNativeObjTextStyles | undefined; /** * 原生控件对象 * 原生控件对象可用于在屏幕上绘制图片或文本内容,当控件不再使用时需要调用close方法销毁控件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ View?: PlusNativeObjView | undefined; /** * View控件动画参数 * 指定动画的类型、持续时间等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ ViewAnimationOptions?: PlusNativeObjViewAnimationOptions | undefined; /** * View控件绘制元素参数 * 指定绘制图片、矩形区域、文本内容等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ ViewDrawTagStyles?: PlusNativeObjViewDrawTagStyles | undefined; /** * View控件事件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ ViewEvents?: PlusNativeObjViewEvents | undefined; /** * JSON对象,View控件的系统状态栏区域样式 * 仅在应用设置为沉浸式状态栏样式下有效,非沉浸式状态栏样式下忽略此属性。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ ViewStatusbarStyles?: PlusNativeObjViewStatusbarStyles | undefined; /** * View控件样式 * 包括位置、大小等信息等,其中位置信息相对于父容器控件进行计算。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ ViewStyles?: PlusNativeObjViewStyles | undefined; @@ -4418,7 +4601,7 @@ interface PlusNativeObj { /** * 原生动画参数 * 指定动画的类型、持续时间等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ interface PlusNativeObjAnimationOptions { @@ -4429,26 +4612,25 @@ interface PlusNativeObjAnimationOptions { * "pop-out" - 从右侧平移出栈动画效果(副窗口从当前屏幕区域向右侧平移出可视区域,主窗口从左侧向右平移滑出显示),如果仅出入一个View控件对象则自动降级为slide-out-right动画; * "slide-in-right" - 从右侧横向滑动效果(主窗口从当前屏幕右侧外向内横向滑动显示); * "slide-out-right - 横向向右侧滑出屏幕动画(主窗口从屏幕中横向向右侧滑动到屏幕外)。 - * - pop-in: + * - pop-in: * 从右侧平移入栈动画效果(副窗口从右侧向左平移滑出显示,主窗口从当前屏幕区域向左侧平移滑出被遮盖)。 - * - * - pop-out: + * + * - pop-out: * 从右侧平移出栈动画效果(副窗口从当前屏幕区域向右侧平移出可视区域,主窗口从左侧向右平移滑出显示)。 - * - * - slide-in-right: + * + * - slide-in-right: * 从右侧横向滑动效果(主窗口从当前屏幕右侧外向内横向滑动显示)。 - * - * - slide-out-right: + * + * - slide-out-right: * 横向向右侧滑出屏幕动画(主窗口从屏幕中横向向右侧滑动到屏幕外)。 - * - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ - type?: 'pop-in' | 'pop-out' | 'slide-in-right' | 'slide-out-right' | undefined; + type?: "pop-in" | "pop-out" | "slide-in-right" | "slide-out-right" | undefined; /** * 动画持续时间 * 单位为毫秒,默认值为200ms。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ duration?: number | undefined; @@ -4457,33 +4639,33 @@ interface PlusNativeObjAnimationOptions { /** * 原生动画窗口样式 * 指定动画窗口的样式,如背景图片,绘制的文字等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ interface PlusNativeObjAnimationViewStyles { /** * 动画窗口上绘制的背景图片 * 图片可以通过Webview对象的draw方法截图,也可以通过Bitmap的API从本地文件中加载。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ bitmap?: PlusNativeObjBitmap | undefined; /** * 动画窗口上绘制的文本内容 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ text?: string | undefined; /** * 动画窗口上绘制的文本样式 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ textStyles?: PlusNativeObjTextStyles | undefined; /** * 动画窗口上绘制的文本区域 * 默认值为{top:'0px',left:'0px',width:'100%',height:'44px'}。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ textRect?: PlusNativeObjRect | undefined; @@ -4492,36 +4674,36 @@ interface PlusNativeObjAnimationViewStyles { /** * 原生图片对象 * 原生图片对象会占用较大的内存资源,在使用时需谨慎管理,当图片不再使用时应该及时调用clear方法进行销毁。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ interface PlusNativeObjBitmap { /** * Bitmap对象的标识 * 在创建Bitmap对象时设置,如果没有设置标识,此属性值为null。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ id?: string | undefined; /** * 静态方法,获取所有Bitmap图片对象 * 获取应用运行期创建的所有Bitmap图片对象,包含所有空Bitmap对象,不包含已经销毁的Bitmap对象。返回的Bitmap对象在数组中按创建的属性排列,及数组中第一个是最先创建的Bitmap对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ - getItems(): PlusNativeObj []; + getItems(): PlusNativeObj[]; /** * 静态方法,获取指定标识的Bitmap图片对象 * 在应用中已创建的图片对象中查找指定标识的Bitmap对象并返回。 * 若存在多个相同标识的Bitmap图片,则返回第一个创建的Bitmap图片。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ getBitmapById(id?: string): PlusNativeObjBitmap; /** * 销毁Bitmap图片 * 释放Bitmap图片占用的内存资源,销毁后图片对象将不可使用,其id属性值为undefined,调用其所有方法操作都会失败。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ clear(): void; @@ -4529,7 +4711,7 @@ interface PlusNativeObjBitmap { * 加载Bitmap图片 * 从指定的路径(仅支持本地文件系统)中加载图片,此操作将覆盖之前的图片内容, * 如果加载图片失败则保留之前的图片内容。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ load(path?: string, successCallback?: () => void, errorCallback?: (result: any) => void): void; @@ -4537,7 +4719,7 @@ interface PlusNativeObjBitmap { * 加载Base64编码格式图片到Bitmap对象 * 从Base64编码格式图片数据中加载图片,此操作将覆盖之前的图片内容, * 如果加载图片失败则保留之前的图片内容。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ loadBase64Data(data?: string, successCallback?: () => void, errorCallback?: (result: any) => void): void; @@ -4545,21 +4727,26 @@ interface PlusNativeObjBitmap { * 回收Bitmap图片内存 * 释放Bitmap图片占用的内存资源,但不销毁图片对象,依然可以继续使用图片对象。 * 当图片对象再次被使用时会自动从设置的路径(构造函数或load/save方法设置)加载到内存中。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ recycle(): void; /** * 保存图片 * 将图片保存到指定的路径(仅支持本地文件系统),如果图片为空或者指定的路径文件已经存在则返回失败。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ - save(path?: string, options?: PlusNativeObjBitmapSaveOptions, successCallback?: (result: any) => void, errorCallback?: (result: any) => void): void; + save( + path?: string, + options?: PlusNativeObjBitmapSaveOptions, + successCallback?: (result: any) => void, + errorCallback?: (result: any) => void, + ): void; /** * 获取图片的Base64编码数据 * 读取图片的数据内容,并转换为Base64编码格式字符串。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ toBase64Data(): string; @@ -4567,7 +4754,7 @@ interface PlusNativeObjBitmap { /** * JSON对象,保存图片的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ interface PlusNativeObjBitmapSaveOptions { @@ -4577,7 +4764,7 @@ interface PlusNativeObjBitmapSaveOptions { * true表示覆盖存在的文件; * false表示不覆盖,如果文件存在,则返回失败。 * 默认值为false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ overwrite?: boolean | undefined; @@ -4586,22 +4773,22 @@ interface PlusNativeObjBitmapSaveOptions { * 支持"jpg"、"png",如果未指定则默认使用指定的保存路径后缀对应的文件格式,如果后缀文件格式无效则使用jpg格式。 * - jpg: JPG格式图片 * - png: PNG格式图片 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ - format?: 'jpg' | 'png' | undefined; + format?: "jpg" | "png" | undefined; /** * 保存图片的质量 * 取值范围为1-100,1表示使用最低的图片质量(保存后的图片文件最小)、100表示使用最高的图片质量(保存后的图片文件最大); * 默认值为50。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ quality?: number | undefined; /** * 指定裁剪区域保存图片 * 相对于图片的区域信息,默认值为{top:'0px',left:'0px',width:'100%',height:'100%'}。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ clip?: PlusNativeObjRect | undefined; @@ -4610,37 +4797,37 @@ interface PlusNativeObjBitmapSaveOptions { /** * 原生图片轮播控件对象 * 原生图片轮播控件对象从原生View控件(plus.nativeObj.View)继承而来,用于绘制图片轮播内容。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ interface PlusNativeObjImageSlider { /** * 添加图片轮播控件的图片 * 动态添加图片轮播控件显示的图片。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ - addImages(images?: PlusNativeObj []): void; + addImages(images?: PlusNativeObj[]): void; /** * 获取当前图片轮播控件显示的图片索引值 * 索引值从0开始,即0表示图片轮播控件当前显示第一张图片。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ currentImageIndex(): number; /** * 设置图片轮播控件的图片 * 动态更新图片轮播控件显示的图片。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ - setImages(images?: PlusNativeObj []): void; + setImages(images?: PlusNativeObj[]): void; } /** * 图片轮播控件样式 * 从ViewStyles继承而来,扩展支持轮播图片等配置。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ interface PlusNativeObjImageSliderStyles { @@ -4650,7 +4837,7 @@ interface PlusNativeObjImageSliderStyles { * "true" - 自动播放; * "false" - 不自动播放。 * 默认值为"false"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ autoplay?: boolean | undefined; @@ -4660,7 +4847,7 @@ interface PlusNativeObjImageSliderStyles { * "true" - 表示可全屏显示,用户点击轮播图片时全屏显示; * "false" - 表示不可全屏显示,用户点击轮播图片时无响应。 * 默认值为"true"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ fullscreen?: boolean | undefined; @@ -4670,21 +4857,21 @@ interface PlusNativeObjImageSliderStyles { * "true" - 支持循环轮播; * "false" - 不支持循环轮播。 * 默认值为"false"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ loop?: boolean | undefined; /** * 轮播的图片 * 至少必须设置一张图片的地址信息,否则可能导致图片轮播控件显示不正常。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ - images?: PlusNativeObj [] | undefined; + images?: PlusNativeObj[] | undefined; /** * 自动播放切换时间 * 当autoplay属性值为true时生效,单位为毫秒。默认值为3000(3秒)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ interval?: number | undefined; @@ -4693,7 +4880,7 @@ interface PlusNativeObjImageSliderStyles { /** * 图片轮播控件中图片项配置参数 * 用于指定图片地址等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ interface PlusNativeObjImageSliderImageStyles { @@ -4701,7 +4888,7 @@ interface PlusNativeObjImageSliderImageStyles { * 图片地址 * 支持本地地址(相对地址、绝对路径、RelativeURL、本地路径URL); * 也支持网络地址(http://或https://)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ src?: string | undefined; @@ -4715,17 +4902,17 @@ interface PlusNativeObjImageSliderImageStyles { * - left: 图片在轮播控件中水平居左对齐 * - center: 图片在轮播控件中水平居中对齐 * - right: 图片在轮播控件中水平居右对齐 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ - align?: 'left' | 'center' | 'right' | undefined; + align?: "left" | "center" | "right" | undefined; /** * 图片显示的高度 * 可取值: * 像素值,如"100px"; * 百分比,如"10%",现对于图片轮播控件的高度; * 自动计算"auto",如果指定图片宽度(width),则按图片实际大小等比缩放图片高度值,如果没有指定宽度(width值为"auto")则自动缩放图片至可完整显示。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ height?: string | undefined; @@ -4736,7 +4923,7 @@ interface PlusNativeObjImageSliderImageStyles { * 百分比,如"10%",相对于图片轮播控件的宽度; * 自动计算"auto",如果指定图片高度(height),则按图片实际大小等比缩放图片宽度值,如果没有指定高度(height值为"auto")则自动缩放图片至可完整显示。 * 默认值为"auto"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ width?: string | undefined; @@ -4750,17 +4937,17 @@ interface PlusNativeObjImageSliderImageStyles { * - top: 图片在轮播控件中垂直居顶对齐 * - middle: 图片在轮播控件中垂直居中对齐 * - bottom: 图片在轮播控件中垂直居底对齐 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ - verticalAlign?: 'top' | 'middle' | 'bottom' | undefined; + verticalAlign?: "top" | "middle" | "bottom" | undefined; } /** * 输入框样式 * 用于定义输入框的显示样式,如字体大小,提示内容等信息。 * 输入文本内容在指定区域水平居左,垂直居中显示。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ interface PlusNativeObjInputStyles { @@ -4780,29 +4967,29 @@ interface PlusNativeObjInputStyles { * - tel: 电话号码输入框 * - text: 普通文本输入框 * - url: URL地址输入框 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ - type?: 'email' | 'number' | 'search' | 'tel' | 'text' | 'url' | undefined; + type?: "email" | "number" | "search" | "tel" | "text" | "url" | undefined; /** * 输入框的提示文本 * 当用户未输入内容时显示在编辑框中(灰色文字)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ placeholder?: string | undefined; /** * 输入框的字体大小 - * 可取值:字体高度像素值,数字加"px"格式字符串,如"12px"。 + * 可取值:字体高度像素值,数字加"px"格式字符串,如"12px"。 * 默认值为"16px"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ fontSize?: string | undefined; /** * 输入框的边框颜色 * 可取值: "#RRGGBB"格式字符串,如"#FF0000"表示红色边框。默认值为"#000000"(黑色)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ borderColor?: string | undefined; @@ -4810,35 +4997,35 @@ interface PlusNativeObjInputStyles { * 输入框边框圆角半径 * 可取值:圆角半径像素值,数字加"px"格式字符串,如"6px"。 * 默认值为"0px"(边框无圆角)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ borderRadius?: string | undefined; /** * 输入框的边框宽度 * 可取值:像素值,数字加"px"格式字符串,如"2px"。 默认值为"1px"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ borderWidth?: string | undefined; /** * 输入框完成输入事件 * 弹出软键盘完成输入后,点击软键盘上的“完成”、“前往”按钮时触发。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ onComplete?: ((result: any) => void) | undefined; /** * 输入框获取焦点事件 * 当编辑框获取焦点时触发。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ onFocus?: ((result: any) => void) | undefined; /** * 输入框失去焦点事件 * 当编辑框失去焦点时触发。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ onBlur?: ((result: any) => void) | undefined; @@ -4847,7 +5034,7 @@ interface PlusNativeObjInputStyles { /** * 区域信息对象 * 包括位置、大小等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ interface PlusNativeObjRect { @@ -4857,7 +5044,7 @@ interface PlusNativeObjRect { * 像素值,如"100px"; * 百分比,如"10%",相对于作用对象的高度; * 自动计算,如"auto",根据height值自动计算,相对于作用对象垂直居中。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ top?: string | undefined; @@ -4867,7 +5054,7 @@ interface PlusNativeObjRect { * 像素值,如"100px"; * 百分比,如"10%",相对于作用对象的宽度; * 自动计算,如"auto",根据width值自动计算,相对于作用对象水平居中。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ left?: string | undefined; @@ -4876,7 +5063,7 @@ interface PlusNativeObjRect { * 可取值: * 像素值,如"100px"; * 百分比,如"10%",相对于作用对象的宽度。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ width?: string | undefined; @@ -4886,7 +5073,7 @@ interface PlusNativeObjRect { * 像素值,如"100px"; * 百分比,如"10%",相对于作用对象的高度。 * 内容自适应,如"wrap_content",根据内容计算高度(如调用drawText绘制文本时支持)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ height?: string | undefined; @@ -4895,7 +5082,7 @@ interface PlusNativeObjRect { /** * 绘制区域样式对象 * 用于定义矩形区域的显示样式,如空心/实心样式、圆角等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ interface PlusNativeObjRectStyles { @@ -4905,7 +5092,7 @@ interface PlusNativeObjRectStyles { * "#RRGGBB"格式字符串,如"#FF0000"表示绘制红色区域; * "rgba(R,G,B,A)",其中R/G/B分别代表红色值/绿色值/蓝色值,正整数类型,取值范围为0-255,A为透明度,浮点数类型,取值范围为0-1(0为全透明,1为不透明),如"rgba(255,0,0,0.5)",表示红色半透明。 * 默认值为"#FFFFFF"(白色)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ color?: string | undefined; @@ -4913,7 +5100,7 @@ interface PlusNativeObjRectStyles { * 矩形区域的圆角半径 * 可取值:圆角半径像素值,数字加"px"格式字符串,如"6px"。 * 默认值为"0px"(矩形无圆角)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ radius?: string | undefined; @@ -4923,7 +5110,7 @@ interface PlusNativeObjRectStyles { * "#RRGGBB"格式字符串,如"#FF0000"表示绘制红色区域; * "rgba(R,G,B,A)",其中R/G/B分别代表红色值/绿色值/蓝色值,正整数类型,取值范围为0-255,A为透明度,浮点数类型,取值范围为0-1(0为全透明,1为不透明),如"rgba(255,0,0,0.5)",表示红色半透明。 * 默认值为矩形填充区域颜色(color属性值)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ borderColor?: string | undefined; @@ -4931,7 +5118,7 @@ interface PlusNativeObjRectStyles { * 矩形边框宽度 * 可取值:像素值,数字加"px"格式字符串,如"2px"。 * 默认值为"0px"(无边框)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ borderWidth?: string | undefined; @@ -4940,7 +5127,7 @@ interface PlusNativeObjRectStyles { /** * 富文本样式 * 用于定义富文本使用的默认使用的字体名称、字体文件路径等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ interface PlusNativeObjRichTextStyles { @@ -4955,21 +5142,21 @@ interface PlusNativeObjRichTextStyles { * - left: 富文本内容水平居左对齐 * - center: 富文本内容水平居中对齐 * - right: 富文本内容水平居右对齐 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ - align?: 'left' | 'center' | 'right' | undefined; + align?: "left" | "center" | "right" | undefined; /** * 富文本默认使用的字体名称 * 例如"Times New Roman", 如果指定名称的字体不存在,则使用系统默认字体。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ family?: string | undefined; /** * 富文本默认使用的字体文件路径 * 加载字体文件路径,必须为本地路径,如果指定的文件路径无效,则使用系统默认字体。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ fontSrc?: string | undefined; @@ -4977,7 +5164,7 @@ interface PlusNativeObjRichTextStyles { * 点击事件回调函数 * 如果设置此属性,则表示拦截所有RichText上的点击事件(不透传事件)。 * 如果没有设置此属性,则仅拦截操作包含onclick属性的a/img标签的点击事件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ onClick?: ((result: any) => void) | undefined; @@ -4986,7 +5173,7 @@ interface PlusNativeObjRichTextStyles { /** * 区域信息对象 * 包括位置、大小等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ interface PlusNativeObjPosition { @@ -4994,7 +5181,7 @@ interface PlusNativeObjPosition { * 区域顶部相对于作用对象(或容器)向下的偏移量 * 可取值:像素值,如"100px";百分比,如"10%",相对于作用对象(或容器)的高度; * 自动计算,如"auto",根据height值自动计算,相对于作用对象(或容器)垂直居中。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ top?: string | undefined; @@ -5002,21 +5189,21 @@ interface PlusNativeObjPosition { * 区域左侧相对于作用对象(或容器)向右的偏移量 * 可取值:像素值,如"100px";百分比,如"10%",相对于作用对象(或容器)的宽度; * 自动计算,如"auto",根据width值自动计算,相对于作用对象(或容器)水平居中。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ left?: string | undefined; /** * 区域的宽度 * 可取值:像素值,如"100px";百分比,如"10%",相对于作用对象(或容器)的宽度。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ width?: string | undefined; /** * 区域的高度 * 可取值:像素值,如"100px";百分比,如"10%",相对于作用对象(或容器)的高度。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ height?: string | undefined; @@ -5026,7 +5213,7 @@ interface PlusNativeObjPosition { * 当设置了top和height值时,忽略此属性值; * 当未设置top值时,可通过bottom属性值来确定区域的垂直位置; * 当未设置height值时,可通过top和bottom属性值来确定区域的高度。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ bottom?: string | undefined; @@ -5036,7 +5223,7 @@ interface PlusNativeObjPosition { * 当设置了left和width值时,忽略此属性值; * 当未设置left值时,可通过right属性值来确定区域的水平位置; * 当未设置width值时,可通过left和right属性值来确定区域的宽度。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ right?: string | undefined; @@ -5045,7 +5232,7 @@ interface PlusNativeObjPosition { /** * 绘制文本样式对象 * 用于定义文本的显示样式,如字体大小、字体颜色、字体粗细、字体样式、字体名称等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ interface PlusNativeObjTextStyles { @@ -5059,17 +5246,17 @@ interface PlusNativeObjTextStyles { * - left: 字体在指定的区域中水平居左对齐 * - center: 字体在指定的区域中水平居中对齐 * - right: 字体在指定的区域中水平居右对齐 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ - align?: 'left' | 'center' | 'right' | undefined; + align?: "left" | "center" | "right" | undefined; /** * 字体颜色 * 可取值: * "#RRGGBB"格式字符串,如"#FF0000"表示绘制红色区域; * "rgba(R,G,B,A)",其中R/G/B分别代表红色值/绿色值/蓝色值,正整数类型,取值范围为0-255,A为透明度,浮点数类型,取值范围为0-1(0为全透明,1为不透明),如"rgba(255,0,0,0.5)",表示红色半透明。 * 默认值为"#000000"(黑色)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ color?: string | undefined; @@ -5080,30 +5267,29 @@ interface PlusNativeObjTextStyles { * "underline" - 文本带下划线效果; * "line-through" - 文本带贯穿线(删除线)效果。 * 默认值为"none"。 - * - none: + * - none: * 无装饰效果 - * - * - underline: + * + * - underline: * 文本带下划线效果 - * - * - line-through: + * + * - line-through: * 文本带贯穿线(删除线)效果 - * - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ - decoration?: 'none' | 'underline' | 'line-through' | undefined; + decoration?: "none" | "underline" | "line-through" | undefined; /** * 字体名称 * 例如"Times New Roman", 如果指定名称的字体不存在,则使用默认字体。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ family?: string | undefined; /** * 字体文件路径 * 加载字体文件路径。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ fontSrc?: string | undefined; @@ -5112,7 +5298,7 @@ interface PlusNativeObjTextStyles { * 可取值: * 像素值,如"100px";百分比,如"10%",相对于字体的高度(size属性); * 默认值为"20%"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ lineSpacing?: string | undefined; @@ -5120,7 +5306,7 @@ interface PlusNativeObjTextStyles { * 字体的边距 * 用于设置字体在绘制目标区域四个方向(top/right/bottom/left)的边距,可取值:像素值,如"10px";百分比,相对于绘制目标区域,如"5%"; * 默认值为"0px"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ margin?: string | undefined; @@ -5130,18 +5316,16 @@ interface PlusNativeObjTextStyles { * "clip" - 超出显示区域时内容裁剪; * "ellipsis" - 超出显示区域时尾部显示省略标记(...)。 * 默认值为"clip"。 - * - clip: - * - * - * + * - clip: + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ - overflow?: 'clip' | undefined; + overflow?: "clip" | undefined; /** * 字体大小 * 可取值:字体高度像素值,数字加"px"格式字符串,如"12px"。 * 默认值为"16px"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ size?: string | undefined; @@ -5150,10 +5334,10 @@ interface PlusNativeObjTextStyles { * 可取值:"normal" - 正常字体样式;"italic" - 斜体样式。默认值为"normal"。 * - normal: 正常字体样式 * - italic: 斜体样式 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ - style?: 'normal' | 'italic' | undefined; + style?: "normal" | "italic" | undefined; /** * 垂直对齐方式 * 文本内容在指定绘制区域中的垂直对齐方式,可取值: @@ -5161,7 +5345,7 @@ interface PlusNativeObjTextStyles { * "middle" - 垂直居中对齐; * "bottom" - 垂直居底对齐。 * 默认值为"middle"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ verticalAlign?: string | undefined; @@ -5170,53 +5354,56 @@ interface PlusNativeObjTextStyles { * 可取值:"normal" - 普通字体;"bold" - 粗字体。默认值为"normal"。 * - normal: 普通字体 * - bold: 粗字体 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ - weight?: 'normal' | 'bold' | undefined; + weight?: "normal" | "bold" | undefined; /** * 文本换行模式 * 可取值: * "nowrap" - 不换行,将所有文本在一行中绘制,忽略换行符("\n"); * "normal" - 自动换行,当指定的宽度无法绘制所有文本时自动换行绘制,碰到'\n'字符时强制换行。 * 默认值为"nowrap"。 - * - nowrap: + * - nowrap: * 不换行,将所有文本在一行中绘制,忽略换行符("\n") - * - * - normal: + * + * - normal: * 自动换行,当指定的宽度无法绘制所有文本时自动换行绘制,碰到'\n'字符时强制换行 - * - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ - whiteSpace?: 'nowrap' | 'normal' | undefined; + whiteSpace?: "nowrap" | "normal" | undefined; } /** * 原生控件对象 * 原生控件对象可用于在屏幕上绘制图片或文本内容,当控件不再使用时需要调用close方法销毁控件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ interface PlusNativeObjView { /** * View对象的标识 * 在创建原生控件View对象时设置,如果没有设置标识,此属性值为null。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ id?: string | undefined; /** * 静态方法,开始原生动画 - * - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ - startAnimation(options?: PlusNativeObjAnimationOptions, view?: PlusNativeObjAnimationViewStyles, otherview?: PlusNativeObjAnimationViewStyles, callback?: () => void): void; + startAnimation( + options?: PlusNativeObjAnimationOptions, + view?: PlusNativeObjAnimationViewStyles, + otherview?: PlusNativeObjAnimationViewStyles, + callback?: () => void, + ): void; /** * 静态方法,关闭原生动画窗口 * 通过plus.nativeObj.View.startAnimation方法开始原生动画后,不会自动关闭原生动画窗口对象,需要调用此方法关闭原生动画。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ clearAnimation(type?: string): void; @@ -5224,7 +5411,7 @@ interface PlusNativeObjView { * 静态方法,获取指定标识的View控件对象 * 如果存在多个指定id标识的View对象,则返回第一个创建的View控件对象。 * 如果不存在指定id标识的View对象,则返回null。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ getViewById(id?: string): PlusNativeObjView; @@ -5234,21 +5421,21 @@ interface PlusNativeObjView { * 可多次调用此方法向Webview添加多个监听器,当监听的事件发生时,将按照添加的先后顺序执行。 * 可通过setTouchEventRect方法指定监听触屏操作的区域。 * 注意:默认View控件拦截处理触屏事件,可调用view.interceptTouchEvent(false)改变为不拦截处理触屏事件(透传)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ addEventListener(event?: PlusNativeObjViewEvents, listener?: (result: any) => void, capture?: boolean): void; /** * View控件内容动画 * 动画后可能会导致View控件显示内容改变,可通过调用restore方法恢复。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ animate(options?: PlusNativeObjViewAnimationOptions, callback?: () => void): void; /** * 关闭View控件 * 释放View控件资源,View对象不可再操作,如果View控件已经显示则自动隐藏。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ close(): void; @@ -5256,7 +5443,7 @@ interface PlusNativeObjView { * 清空矩形区域 * 清除指定矩形区域内容,透明显示其后面的内容。 * 可多次调用设置多个区域透明。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ clearRect(position?: PlusNativeObjPosition, id?: string): void; @@ -5265,42 +5452,47 @@ interface PlusNativeObjView { * 在当前View控件之上绘制指定的内容,可一次指定绘制多个元素,绘制元素可以是图片/矩形区域/文本, * 即将多次调用drawBitmap/drawRect/drawText方法合并调用一次draw方法来实现, * 推荐使用draw方法来替换多次调用drawBitmap/drawRect/drawText。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ - draw(tags?: PlusNativeObj []): void; + draw(tags?: PlusNativeObj[]): void; /** * 绘制图片 * 在当前View控件之上绘制指定的图片,如果图片无效则不做任何操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ drawBitmap(src?: string, sprite?: PlusNativeObjPosition, position?: PlusNativeObjPosition, id?: string): void; /** * 绘制矩形区域 * 在当前View控件之上绘制指定颜色的矩形区域。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ drawRect(styles?: PlusNativeObjRectStyles, position?: PlusNativeObjPosition, id?: string): void; /** * 绘制文本 * 在当前View控件之上绘制指定的文本内容,如果文本为空则不做任何操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ drawText(text?: string, position?: PlusNativeObjPosition, styles?: PlusNativeObjTextStyles, id?: string): void; /** * 绘制富文本 * 在当前View控件之上绘制指定的文本内容,如果文本为空则不做任何操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ - drawRichText(text?: string, position?: PlusNativeObjPosition, styles?: PlusNativeObjRichTextStyles, id?: string): void; + drawRichText( + text?: string, + position?: PlusNativeObjPosition, + styles?: PlusNativeObjRichTextStyles, + id?: string, + ): void; /** * 绘制输入框 * 在当前View控件之上绘制输入框。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ drawInput(position?: PlusNativeObjPosition, styles?: PlusNativeObjInputStyles, id?: string): void; @@ -5308,7 +5500,7 @@ interface PlusNativeObjView { * 获取编辑框的焦点状态 * 通过id查找到指定的编辑框,获取其焦点状态。 * 如果指定的id无效则返回null。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ getInputFocusById(id?: string): boolean; @@ -5316,28 +5508,28 @@ interface PlusNativeObjView { * 获取编辑框的内容 * 通过id查找到指定的编辑框,获取其输入的字符串。 * 如果指定的id无效则返回null。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ getInputValueById(id?: string): string; /** * 重置view控件显示内容 * 清除调用drawBitmap、drawText方法绘制的内容,将View控件重置为空内容(透明不可见)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ reset(): void; /** * 恢复View控件显示内容 * 恢复调用animate方法改变View控件的内容,更新至动画前的内容。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ restore(): void; /** * 显示View控件 * 将View控件显示到屏幕,显示在所有Webview窗口之上。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ show(): void; @@ -5345,14 +5537,14 @@ interface PlusNativeObjView { * 设置编辑框的焦点状态 * 通过id查找到指定的编辑框,并设置编辑框的焦点状态。 * 如果指定的id无效则操作无效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ setInputFocusById(id?: string, focusable?: boolean): string; /** * 设置View控件的样式 * 动态更新View控件样式。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ setStyle(styles?: PlusNativeObjViewStyles): void; @@ -5361,14 +5553,14 @@ interface PlusNativeObjView { * 当调用addEventListener监听View控件事件时,可调用此方法限定监听事件的区域,仅当用户触屏操作在指定区域时才触发监听事件。 * 非限定监听事件的区域则不拦截,透传给其它窗口处理。 * 注意:此操作覆盖之前设置的区域。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ - setTouchEventRect(rect?: PlusNativeObj []): void; + setTouchEventRect(rect?: PlusNativeObj[]): void; /** * 隐藏View控件 * 将View控件从屏幕隐藏,如果View控件未显示则不做任何操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ hide(): void; @@ -5376,13 +5568,13 @@ interface PlusNativeObjView { * 是否拦截View控件的触屏事件 * 设置为拦截后View控件上的触屏事件不再传递(即不透传),否则触屏事件将继续传递给View控件下的其它窗口处理(即透传)。 * 注意:View控件默认拦截触屏事件(不透传)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ interceptTouchEvent(intercept?: boolean): void; /** * 获取View控件的显示状态 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ isVisible(): boolean; @@ -5391,7 +5583,7 @@ interface PlusNativeObjView { /** * View控件动画参数 * 指定动画的类型、持续时间等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ interface PlusNativeObjViewAnimationOptions { @@ -5399,21 +5591,21 @@ interface PlusNativeObjViewAnimationOptions { * 动画类型 * 可取值:"shrink" - 从上到下分块收缩清除窗口动画。 * - shrink: 从上到下分块清除动画 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ - type?: 'shrink' | undefined; + type?: "shrink" | undefined; /** * 动画持续时间 * 单位为毫秒,默认值为200ms。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ duration?: number | undefined; /** * 动画帧数 * 必须为大于0的整数,默认值为12。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ frames?: number | undefined; @@ -5425,7 +5617,7 @@ interface PlusNativeObjViewAnimationOptions { * left - 区域距离控件左侧的偏移量,属性值可取像素值(如"100px"),百分比(如"10%",相对于控件的宽度),默认值为'0px'; * right - 区域距离控件右侧的偏移量,属性值可取像素值(如"100px"),百分比(如"10%",相对于控件的宽度),默认值为'0px'。 * 如“{top:'44px',bottom:'48px'}”。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ region?: PlusNativeObjRect | undefined; @@ -5434,14 +5626,14 @@ interface PlusNativeObjViewAnimationOptions { /** * View控件绘制元素参数 * 指定绘制图片、矩形区域、文本内容等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ interface PlusNativeObjViewDrawTagStyles { /** * 绘制操作标识 * 可通过view对象的drawBitmap/drawRect/drawText/clearRect方法进行更新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ id?: string | undefined; @@ -5458,24 +5650,24 @@ interface PlusNativeObjViewDrawTagStyles { * - font: 绘制文本内容 * - richtext: 绘制富文本内容 * - input: 绘制输入框内容 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ - tag?: 'img' | 'rect' | 'font' | 'richtext' | 'input' | undefined; + tag?: "img" | "rect" | "font" | "richtext" | "input" | undefined; /** * 矩形区域颜色 * 不推荐使用(推荐使用rectStyles),可取值: * "#RRGGBB"格式字符串,如红色为"#FF0000"。 * "rgba(R,G,B,A)",其中R/G/B分别代表红色值/绿色值/蓝色值,正整数类型,取值范围为0-255,A为透明度,浮点数类型,取值范围为0-1(0为全透明,1为不透明),如"rgba(255,0,0,0.5)",表示红色半透明。 * 当tag属性值为"rect"时有效,用于指定矩形区域颜色,默认值为"#FFFFFF"(白色)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ color?: string | undefined; /** * 绘制输入框的样式 * 当tag属性值为"input"时有效,用于指定绘制输入框的样式、大小位置等信息。, - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ inputStyles?: PlusNativeObjInputStyles | undefined; @@ -5485,14 +5677,14 @@ interface PlusNativeObjViewDrawTagStyles { * 当tag属性值为"rect"时,用于指定绘制的矩形区域; * 当tag属性值为"font"时,用于指定绘制文本的目标区域,此时height属性值支持设置为"wrap_content",表示文本高度根据内容自动计算,此时通过top来定位文本绘制的起始位置。 * 相对于View控件的区域信息,默认值为{top:'0px',left:'0px',width:'100%',height:'100%'}。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ position?: PlusNativeObjPosition | undefined; /** * 绘制区域的样式 * 当tag属性值为"rect"时有效,用于指定绘制区域的样式、填充颜色、圆角大小等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ rectStyles?: PlusNativeObjRectStyles | undefined; @@ -5500,35 +5692,35 @@ interface PlusNativeObjViewDrawTagStyles { * 绘制的图片资源 * 当tag属性值为"img"时有效,可以是图片资源路径(字符串类型)或者图片对象(plus.nativeObj.Bitmap对象)。 * src路径支持gif图片,但设置的图片路径文件使用".gif"后缀时则认为是gif图片,如"_www/loading.gif"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ src?: string | undefined; /** * 图片源的绘制区域 * 当tag属性值为"img"时有效,用于指定图片源的绘制区域,相对于图片的区域信息,默认值为{top:'0px',left:'0px',width:'100%',height:'100%'}。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ sprite?: PlusNativeObjPosition | undefined; /** * 绘制的文本内容 * 当tag属性值为"font"时有效,用于保存绘制的文本内容。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ text?: string | undefined; /** * 绘制文本的样式 * 当tag属性值为"font"时有效,用于指定绘制文本内容的字体大小、字体颜色、字体类型等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ textStyles?: PlusNativeObjTextStyles | undefined; /** * 绘制富文本的样式 * 当tag属性值为"richtext"时有效,用于指定绘制富文本内容的默认字体颜色、字体类型等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ richTextStyles?: PlusNativeObjRichTextStyles | undefined; @@ -5536,7 +5728,7 @@ interface PlusNativeObjViewDrawTagStyles { /** * View控件事件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ interface PlusNativeObjViewEvents { @@ -5544,7 +5736,7 @@ interface PlusNativeObjViewEvents { * 双击事件 * 双击屏幕时触发。 * 注意:如果将View控件设置为不拦截触屏事件(view.interceptTouchEvent(false))则不会触发此事件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ doubleclick?: string | undefined; @@ -5552,7 +5744,7 @@ interface PlusNativeObjViewEvents { * 点击事件 * 当手指点击屏幕时触发。 * 注意:如果将View控件设置为不拦截触屏事件(view.interceptTouchEvent(false))则不会触发此事件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ click?: string | undefined; @@ -5560,7 +5752,7 @@ interface PlusNativeObjViewEvents { * 开始触屏事件 * 当手指触摸屏幕时候触发。 * 注意:如果将View控件设置为不拦截触屏事件(view.interceptTouchEvent(false))则不会触发此事件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ touchstart?: string | undefined; @@ -5568,7 +5760,7 @@ interface PlusNativeObjViewEvents { * 触摸滑屏事件 * 当手指在屏幕上滑动的时候连续地触发。 * 注意:如果将View控件设置为不拦截触屏事件(view.interceptTouchEvent(false))则不会触发此事件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ touchmove?: string | undefined; @@ -5576,7 +5768,7 @@ interface PlusNativeObjViewEvents { * 结束触屏事件 * 当手指从屏幕上离开的时候触发。 * 注意:如果将View控件设置为不拦截触屏事件(view.interceptTouchEvent(false))则不会触发此事件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ touchend?: string | undefined; @@ -5585,14 +5777,14 @@ interface PlusNativeObjViewEvents { /** * JSON对象,View控件的系统状态栏区域样式 * 仅在应用设置为沉浸式状态栏样式下有效,非沉浸式状态栏样式下忽略此属性。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ interface PlusNativeObjViewStatusbarStyles { /** * 系统状态栏区域背景颜色 * 颜色值格式为"#RRGGBB",如"#FF0000"表示为红色背景,默认值为应用manifest.json中plus->statusbar->background属性配置的值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ background?: string | undefined; @@ -5601,7 +5793,7 @@ interface PlusNativeObjViewStatusbarStyles { /** * View控件样式 * 包括位置、大小等信息等,其中位置信息相对于父容器控件进行计算。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ interface PlusNativeObjViewStyles { @@ -5610,7 +5802,7 @@ interface PlusNativeObjViewStyles { * 可取值: * #RRGGBB"格式字符串,如"#FF0000"表示绘制红色区域; * "rgba(R,G,B,A)",其中R/G/B分别代表红色值/绿色值/蓝色值,正整数类型,取值范围为0-255,A为透明度,浮点数类型,取值范围为0-1(0为全透明,1为不透明),如"rgba(255,0,0,0.5)",表示红色半透明。 默认值为"#FFFFFF"(白色)。 "rgba(R,G,B,A)",其中R/G/B分别代表红色值/绿色值/蓝色值,正整数类型,取值范围为0-255,A为透明度,浮点数类型,取值范围为0-1(0为全透明,1为不透明),如"rgba(255,0,0,0.5)",表示红色半透明。 默认值为"#FFFFFF"(白色)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ backgroundColor?: string | undefined; @@ -5621,7 +5813,7 @@ interface PlusNativeObjViewStyles { * 百分比,如"10%",相对于父容器的高度,如果没有父容器则相对于屏幕高度。 * 当设置了top和height值时,忽略此属性值; * 未设置height值时,可通过top和bottom属性值来确定View控件的高度。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ bottom?: string | undefined; @@ -5634,7 +5826,7 @@ interface PlusNativeObjViewStyles { * "right",控件停靠在页面右侧; * "left",控件停靠在页面左侧。 * 默认值为"top"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ dock?: string | undefined; @@ -5645,7 +5837,7 @@ interface PlusNativeObjViewStyles { * 百分比,如"10%",相对于父容器的高度,如果没有父容器则相对于屏幕高度; * 内容自适应,如"wrap_content",根据内容计算控件的高度。 * 默认值为"100%"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ height?: string | undefined; @@ -5656,14 +5848,14 @@ interface PlusNativeObjViewStyles { * 百分比,如"10%",相对于父控件的宽度; * 自动计算,如"auto",根据width值自动计算,相对于父控件水平居中。 * 默认值为"0px"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ left?: string | undefined; /** * View控件的不透明度 * 取值范围为0-1,0为全透明,1为不透明,默认值为1,即不透明。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ opacity?: number | undefined; @@ -5675,28 +5867,28 @@ interface PlusNativeObjViewStyles { * "absolute",Veiw控件在页面中绝对定位,如果页面存在滚动条不随窗口内容滚动; * "dock",View控件在页面中停靠,停靠的位置由dock属性值决定。 * 默认值为"absolute"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ position?: string | undefined; /** * View控件的状态栏样式 * 仅在应用设置为沉浸式状态栏样式下有效,设置此属性后将自动保留系统状态栏区域不被View控件占用(即View控件非沉浸式样式显示)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ statusbar?: PlusNativeObjViewStatusbarStyles | undefined; /** * View控件左上角的垂直偏移量 * 可取值:像素值,如"100px";百分比,如"10%",相对于父控件的高度;自动计算,如"auto",根据height值自动计算,相对于父控件垂直居中。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ top?: string | undefined; /** * 区域的宽度 * 可取值:像素值,如"100px";百分比,如"10%",相对于父控件的宽度。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeobj.html](http://www.html5plus.org/doc/zh_cn/nativeobj.html) */ width?: string | undefined; @@ -5704,49 +5896,49 @@ interface PlusNativeObjViewStyles { /** * nativeUI管理系统原生界面,可用于弹出系统原生提示对话框窗口、时间日期选择对话框、等待对话框等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ interface PlusNativeUI { /** * JSON对象,原生选择按钮框上按钮的样式参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ ActionButtonStyles?: PlusNativeUIActionButtonStyles | undefined; /** * JSON对象,原生选择按钮框的样式参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ ActionSheetStyles?: PlusNativeUIActionSheetStyles | undefined; /** * 确认对话框的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ ConfirmOptions?: PlusNativeUIConfirmOptions | undefined; /** * JSON对象,图片预览的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ PreviewImageOptions?: PlusNativeUIPreviewImageOptions | undefined; /** * 日期选择对话框的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ PickDateOption?: PlusNativeUIPickDateOption | undefined; /** * JSON对象,时间选择对话框的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ PickTimeOption?: PlusNativeUIPickTimeOption | undefined; /** * 系统原生界面基类对象 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ NativeUIObj?: PlusNativeUINativeUIObj | undefined; @@ -5754,25 +5946,25 @@ interface PlusNativeUI { * 系统等待对话框对象 * 从NativeUIObj对象继承而来,通过plus.nativeUI.showWaiting方法创建时返回。 * 用于控制系统样式等待对话框的操作,如关闭、设置标题内容等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ WaitingObj?: PlusNativeUIWaitingObj | undefined; /** * JSON对象,原生等待对话框的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ WaitingOptions?: PlusNativeUIWaitingOptions | undefined; /** * JSON对象,原生等待对话框上loading图标自定义样式 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ WaitingLoadingOptions?: PlusNativeUIWaitingLoadingOptions | undefined; /** * JSON对象,系统提示消息框要设置的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ ToastOptions?: PlusNativeUIToastOptions | undefined; @@ -5780,15 +5972,18 @@ interface PlusNativeUI { * 弹出系统选择按钮框 * 从底部动画弹出系统样式选择按钮框,可设置选择框的标题、按钮文字等。 * 弹出的提示框为非阻塞模式,用户点击选择框上的按钮后关闭,并通过actionsheetCallback回调函数通知用户选择的按钮。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ - actionSheet(actionsheetStyle?: PlusNativeUIActionSheetStyles, actionsheetCallback?: (result: any) => void): PlusNativeUINativeUIObj; + actionSheet( + actionsheetStyle?: PlusNativeUIActionSheetStyles, + actionsheetCallback?: (result: any) => void, + ): PlusNativeUINativeUIObj; /** * 弹出系统提示对话框 * 创建并显示系统样式提示对话框,可设置提示对话框的标题、内容、按钮文字等。 * 弹出的提示对话框为非阻塞模式,用户点击提示对话框上的按钮后关闭,并通过alertCB回调函数通知对话框已关闭。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ alert(message?: string, alertCB?: (result: any) => void, title?: string, buttonCapture?: string): void; @@ -5796,35 +5991,40 @@ interface PlusNativeUI { * 弹出系统确认对话框 * 创建并显示系统样式确认对话框,可设置确认对话框的标题、内容、按钮数目及其文字。 * 弹出的确认对话框为非阻塞模式,用户点击确认对话框上的按钮后关闭,并通过confirmCB回调函数通知用户点击的按钮索引值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ - confirm(message?: string, confirmCB?: (result: any) => void, options?: PlusNativeUIConfirmOptions, buttons?: any []): void; + confirm( + message?: string, + confirmCB?: (result: any) => void, + options?: PlusNativeUIConfirmOptions, + buttons?: any[], + ): void; /** * 关闭系统等待对话框 * 关闭已经显示的所有系统样式等待对话框,触发Waiting对象的onclose事件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ closeWaiting(): void; /** * 关闭自动消失的提示消息 * 关闭已经显示的所有自动消失的提示框。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ closeToast(): void; /** * 预览图片 * 创建并显示全屏图片预览界面,用户点击图片或返回键退出预览界面。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ - previewImage(urls?: any [], options?: PlusNativeUIPreviewImageOptions): void; + previewImage(urls?: any[], options?: PlusNativeUIPreviewImageOptions): void; /** * 显示系统等待对话框 * 创建并显示系统样式等待对话框,并返回等待对话框对象Waiting,显示后需调用其close方法进行关闭。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ showWaiting(title?: string, options?: PlusNativeUIWaitingOptions): PlusNativeUIWaitingObj; @@ -5832,31 +6032,39 @@ interface PlusNativeUI { * 弹出系统日期选择对话框 * 创建并显示系统样式日期选择对话框,可进行日期的选择。 * 用户操作确认后通过successCB回调函数返回用户选择的日期,若用户取消选择则通过errorCB回调。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ - pickDate(successCB?: (result: any) => void, errorCB?: (result: any) => void, options?: PlusNativeUIPickDateOption): void; + pickDate( + successCB?: (result: any) => void, + errorCB?: (result: any) => void, + options?: PlusNativeUIPickDateOption, + ): void; /** * 弹出系统时间选择对话框 * 创建并弹出系统样式时间选择对话框,可进行时间的选择。 * 用户操作确认后通过successCB回调函数返回用户选择的时间,若用户取消选择则通过errorCB回调。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ - pickTime(successCB?: (result: any) => void, errorCB?: (result: any) => void, options?: PlusNativeUIPickTimeOption): void; + pickTime( + successCB?: (result: any) => void, + errorCB?: (result: any) => void, + options?: PlusNativeUIPickTimeOption, + ): void; /** * 弹出系统输入对话框 * 创建并显示系统样式输入对话框,可设置输入对话框的标题、内容、提示输入信息、按钮数目及其文字。 * 弹出的输入对话框为非阻塞模式,其中包含编辑框供用户输入内容,用户点击输入对话框上的按钮后自动关闭,并通过promptCB回调函数返回用户点击的按钮及输入的内容。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ - prompt(message?: string, promptCB?: (result: any) => void, title?: string, tip?: string, buttons?: any []): void; + prompt(message?: string, promptCB?: (result: any) => void, title?: string, tip?: string, buttons?: any[]): void; /** * 显示自动消失的提示消息 * 创建并显示系统样式提示消息,弹出的提示消息为非阻塞模式,显示指定时间后自动消失。 * 提示消息显示时间可通过options的duration属性控制,长时间提示消息显示时间约为3.5s,短时间提示消息显示时间约为2s。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ toast(message?: string, options?: PlusNativeUIToastOptions): void; @@ -5864,7 +6072,7 @@ interface PlusNativeUI { /** * JSON对象,原生选择按钮框上按钮的样式参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ interface PlusNativeUIActionButtonStyles { @@ -5873,13 +6081,13 @@ interface PlusNativeUIActionButtonStyles { * 可取值: * "#RRGGBB"格式字符串,如"#FF0000"表示文字颜色为红色; * "rgba(R,G,B,A)",其中R/G/B分别代表红色值/绿色值/蓝色值,正整数类型,取值范围为0-255,A为透明度,浮点数类型,取值范围为0-1(0为全透明,1为不透明),如"rgba(255,0,0,0.5)",表示红色半透明。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ color?: string | undefined; /** * 按钮上显示的文字内容 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ title?: string | undefined; @@ -5889,65 +6097,64 @@ interface PlusNativeUIActionButtonStyles { * "destructive" - 表示警示按钮样式,默认文字颜色为红色; * "default" - 表示默认按钮样式。 * 默认值为"default"。 - * - destructive: + * - destructive: * 警示按钮样式。 - * - * - default: + * + * - default: * 默认按钮样式。 - * - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ - style?: 'destructive' | 'default' | undefined; + style?: "destructive" | "default" | undefined; } /** * JSON对象,原生选择按钮框的样式参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ interface PlusNativeUIActionSheetStyles { /** * 选择按钮框的标题 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ title?: string | undefined; /** * 取消按钮上显示的文字内容 * 不设置此属性,则不显示取消按钮。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ cancel?: string | undefined; /** * 选择框上的按钮,ActionButtonStyles对象数组 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ - buttons?: PlusNativeUI [] | undefined; + buttons?: PlusNativeUI[] | undefined; } /** * 确认对话框的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ interface PlusNativeUIConfirmOptions { /** * 确认对话框显示的标题 * 如果不设置此属性值,则不显示标题。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ title?: string | undefined; /** * 确认对话框上显示的按钮 * 字符串数组,每项对应在确认对话框上显示一个按钮,用户点击后通过confirmCB返回用户点击按钮的在数组中的索引值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ - buttons?: any [] | undefined; + buttons?: any[] | undefined; /** * 对话框在屏幕中的垂直分享对齐方式 * 可取值: @@ -5955,7 +6162,7 @@ interface PlusNativeUIConfirmOptions { * "center" - 表示垂直居中对齐; * "bottom" - 表示垂直居底对齐。 * 默认值为"center"(垂直居中对齐)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ verticalAlign?: string | undefined; @@ -5963,7 +6170,7 @@ interface PlusNativeUIConfirmOptions { /** * JSON对象,图片预览的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ interface PlusNativeUIPreviewImageOptions { @@ -5971,14 +6178,14 @@ interface PlusNativeUIPreviewImageOptions { * 图片预览的背景颜色 * 颜色值格式为"#RRGGBB",如"#FF0000"表示为红色背景。 * 默认值为黑色("#000000")。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ background?: string | undefined; /** * 默认显示图片的索引值 * 索引值从0开始,默认值为0。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ current?: number | undefined; @@ -5989,7 +6196,7 @@ interface PlusNativeUIPreviewImageOptions { * "number" - 顶部数字指示器(顶部居中显示,文字为%当前图片索引值(从1开始)%/%图片总数%); * "none" - 不显示指示器。 * 默认值为"default"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ indicator?: string | undefined; @@ -5999,7 +6206,7 @@ interface PlusNativeUIPreviewImageOptions { * "true" - 支持循环预览; * "false" - 不支持循环预览。 * 默认值为"false"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ loop?: boolean | undefined; @@ -6007,28 +6214,28 @@ interface PlusNativeUIPreviewImageOptions { /** * 日期选择对话框的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ interface PlusNativeUIPickDateOption { /** * 日期选择对话框显示的标题 * 如果未设置标题,则默认显示标题为当前选择的日期。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ title?: string | undefined; /** * 日期选择对话框默认显示的日期 * 如果未设置默认显示的日期,则显示当前的日期。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ date?: Date | undefined; /** * 日期选择对话框可选择的最小日期 * Date类型对象,如果未设置可选择的最小日期,则使用系统默认可选择的最小日期值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ minDate?: Date | undefined; @@ -6036,7 +6243,7 @@ interface PlusNativeUIPickDateOption { * 日期选择对话框可选择的最大日期 * Date类型对象,如果未设置可选择的最大日期,则使用系统默认可选择的最大日期值。 * 其值必须大于minDate设置的值,否则使用系统默认可选择的最大日期值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ maxDate?: Date | undefined; @@ -6044,7 +6251,7 @@ interface PlusNativeUIPickDateOption { * 时间选择对话框弹出指示区域 * JSON类型对象,格式如{top:10;left:10;width:200;height:200;},所有值为像素值,其值为相对于容器Webview的位置。 * 如未设置此值,默认在屏幕居中显示。仅在iPad上有效,其它设备忽略此值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ popover?: any; @@ -6052,28 +6259,28 @@ interface PlusNativeUIPickDateOption { /** * JSON对象,时间选择对话框的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ interface PlusNativeUIPickTimeOption { /** * 时间选择对话框默认显示的时间 * 如果未设置标题,则默认显示标题为当前选择的时间。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ time?: Date | undefined; /** * 时间选择对话框显示的标题 * 如果未设置标题,则默认显示标题为当前选择的时间。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ title?: string | undefined; /** * 是否24小时制模式 * true表示使用24小时制模式显示,fale表示使用12小时制模式显示,默认值为true。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ is24Hour?: boolean | undefined; @@ -6081,7 +6288,7 @@ interface PlusNativeUIPickTimeOption { * 日期选择对话框弹出指示区域 * JSON类型对象,格式如{top:10;left:10;width:200;height:200;},所有值为像素值,其值相对于容器webview的位置。 * 如未设置此值,默认在屏幕居中显示。仅在iPad上有效,其它设备忽略此值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ popover?: any; @@ -6089,7 +6296,7 @@ interface PlusNativeUIPickTimeOption { /** * 系统原生界面基类对象 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ interface PlusNativeUINativeUIObj { @@ -6098,7 +6305,7 @@ interface PlusNativeUINativeUIObj { * 调用plus.nativeUI.actionSheet方法创建并显示系统界面后,可通过其close方法将原生界面关闭。 * 此情况下触发界面关闭回调函数参数的index属性值为-1。 * 注意:一个系统原生界面只能关闭一次,多次调用将无任何作用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ close(): void; @@ -6108,20 +6315,20 @@ interface PlusNativeUINativeUIObj { * 系统等待对话框对象 * 从NativeUIObj对象继承而来,通过plus.nativeUI.showWaiting方法创建时返回。 * 用于控制系统样式等待对话框的操作,如关闭、设置标题内容等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ interface PlusNativeUIWaitingObj { /** * 等待对话框关闭事件 * 等待框关闭时触发,当调用close方法或用户点击返回按钮导致等待框关闭时触发。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ onclose?: (() => void) | undefined; /** * 设置等待对话框上显示的文字内容 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ setTitle(title?: string): void; @@ -6129,7 +6336,7 @@ interface PlusNativeUIWaitingObj { * 关闭显示的系统等待对话框 * 调用plus.nativeUI.showWaiting方法创建并显示系统等待界后,可通过其close方法将原生等待控件关闭。 * 一个系统等待对话框只能关闭一次,多次调用将无任何作用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ close(): void; @@ -6137,56 +6344,56 @@ interface PlusNativeUIWaitingObj { /** * JSON对象,原生等待对话框的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ interface PlusNativeUIWaitingOptions { /** * 等待框背景区域的宽度 * 值支持像素值("500px")或百分比("50%"),百分比相对于屏幕的宽计算,如果不设置则根据内容自动计算合适的宽度。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ width?: string | undefined; /** * 等待框背景区域的高度 * 值支持像素绝对值("500px")或百分比("50%"),如果不设置则根据内容自动计算合适的高度。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ height?: string | undefined; /** * 等待框中文字的颜色 * 颜色值支持(参考CSS颜色规范):颜色名称(参考CSS Color Names)/十六进制值/rgb值/rgba值,默认值为白色。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ color?: string | undefined; /** * 等待框中文字的字体大小 * 如"14px"表示使用14像素高的文字,未设置则使用系统默认字体大小。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ size?: string | undefined; /** * 等待对话框中标题文字的水平对齐方式 * 对齐方式可选值包括:"left":水平居左对齐显示,"center":水平居中对齐显示,"right":水平居右对齐显示。默认值为水平居中对齐显示,即"center"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ textalign?: string | undefined; /** * 等待对话框的内边距 * 值支持像素值("10px")和百分比("5%"),百分比相对于屏幕的宽计算,默认值为"3%"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ padding?: string | undefined; /** * 等待对话框显示区域的背景色 * 背景色的值支持(参考CSS颜色规范):颜色名称(参考CSS Color Names)/十六进制值/rgb值/rgba值,默认值为rgba(0,0,0,0.8)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ background?: string | undefined; @@ -6196,28 +6403,28 @@ interface PlusNativeUIWaitingOptions { * 仅在iOS平台有效,其它平台忽略此值,未设置时默认值为white。 * - black: 黑色雪花样式,适合浅色界面使用 * - white: 白色雪花样式,适合深色界面使用 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ - style?: 'black' | 'white' | undefined; + style?: "black" | "white" | undefined; /** * 等待框是否模态显示 * 模态显示时用户不可操作直到等待对话框关闭,否则用户在等待对话框显示时也可操作下面的内容,未设置时默认为true。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ modal?: boolean | undefined; /** * 等待框显示区域的圆角 * 值支持像素值("10px"),未设置时使用默认值"10px"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ round?: number | undefined; /** * 点击等待显示区域是否自动关闭 * true表示点击等待对话框显示区域时自动关闭,false则不关闭,未设置时默认值为false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ padlock?: boolean | undefined; @@ -6227,13 +6434,13 @@ interface PlusNativeUIWaitingOptions { * - none: 截获返回键,不做任何响应 * - close: 截获返回键并关闭等待框 * - transmit: 不截获返回键,继续传递给Webview窗口 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ - back?: 'none' | 'close' | 'transmit' | undefined; + back?: "none" | "close" | "transmit" | undefined; /** * 自定义等待框上loading图标样式 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ loading?: PlusNativeUIWaitingLoadingOptions | undefined; @@ -6241,7 +6448,7 @@ interface PlusNativeUIWaitingOptions { /** * JSON对象,原生等待对话框上loading图标自定义样式 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ interface PlusNativeUIWaitingLoadingOptions { @@ -6251,23 +6458,22 @@ interface PlusNativeUIWaitingLoadingOptions { * "block"表示图标与文字分开两行显示,上面显示loading图标,下面显示文字; * "inline"表示loading图标与文字在同一行显示,左边显示loading图标,右边显示文字; * "none"表示不显示loading图标; - * - block: + * - block: * loading图标与文字分开两行显示,上面显示loading图标,下面显示文字。 - * - * - inline: + * + * - inline: * loading图标与文字在同一行显示,左边显示loading图标,右边显示文字。 - * - * - none: + * + * - none: * 不显示loading图标。 - * - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ - display?: 'block' | 'inline' | 'none' | undefined; + display?: "block" | "inline" | "none" | undefined; /** * loading图标高度 * 设置loading图标的高度(宽度等比率缩放),取值类型:像素值,如"14px"表示14像素高。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ height?: string | undefined; @@ -6275,14 +6481,14 @@ interface PlusNativeUIWaitingLoadingOptions { * loading图标路径 * 自定义loading图标的路径,png格式,并且必须是本地资源地址; * loading图要求宽是高的整数倍,显示等待框时按照图片的高横向截取每帧刷新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ icon?: string | undefined; /** * loading图每帧刷新间隔 * 单位为ms(毫秒),默认值为100ms。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ interval?: number | undefined; @@ -6290,7 +6496,7 @@ interface PlusNativeUIWaitingLoadingOptions { /** * JSON对象,系统提示消息框要设置的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ interface PlusNativeUIToastOptions { @@ -6300,37 +6506,37 @@ interface PlusNativeUIToastOptions { * - left: 水平居左对齐 * - center: 水平居中对齐 * - right: 水平居左对齐 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ - align?: 'left' | 'center' | 'right' | undefined; + align?: "left" | "center" | "right" | undefined; /** * 提示消息框显示的时间 * 可选值为"long"、"short",值为"long"时显示时间约为3.5s,值为"short"时显示时间约为2s,未设置时默认值为"short"。 * - long: 长显示时间 * - short: 短显示时间 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ - duration?: 'long' | 'short' | undefined; + duration?: "long" | "short" | undefined; /** * 提示消息框上显示的图标 * 仅支持本地图片路径。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ icon?: string | undefined; /** * 图标的宽度 * 单位为px(逻辑像素值),默认值为图片的宽度。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ iconWidth?: string | undefined; /** * 图标的高度 * 单位为px(逻辑像素值),默认值为图片的高度。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ iconHeight?: string | undefined; @@ -6340,7 +6546,7 @@ interface PlusNativeUIToastOptions { * "block"表示图标与文字分两行显示,上面显示图标,下面显示文字; * "inline"表示图标与文字在同一行显示,左边显示图标,右边显示文字。 * 默认值为"block"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ style?: string | undefined; @@ -6358,14 +6564,14 @@ interface PlusNativeUIToastOptions { * 如示例“<img onclick="console.log('clicked img')" src="http://img-cdn-qiniu.dcloud.net.cn/icon2.png"/><a onclick="console.log(clicked a)">链接地址</a>”。 * - text: 文本字符串 * - richtext: 富文本内容 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ - type?: 'text' | 'richtext' | undefined; + type?: "text" | "richtext" | undefined; /** * 富文本样式 * 当type属性值为"richtext"时有效,用于定义富文本的样式,如其文本对齐方式、使用的字体等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ richTextStyle?: PlusNativeObjRichTextStyles | undefined; @@ -6375,40 +6581,40 @@ interface PlusNativeUIToastOptions { * - top: 垂直居顶对齐 * - center: 垂直居中对齐 * - bottom: 垂直居底对齐 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/nativeui.html](http://www.html5plus.org/doc/zh_cn/nativeui.html) */ - verticalAlign?: 'top' | 'center' | 'bottom' | undefined; + verticalAlign?: "top" | "center" | "bottom" | undefined; } /** * navigator用于管理浏览器运行环境信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ interface PlusNavigator { /** * 创建应用快捷方式要设置的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ ShortcutOptions?: PlusNavigatorShortcutOptions | undefined; /** * 更新应用启动界面要设置的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ SplashscreenOptions?: PlusNavigatorSplashscreenOptions | undefined; /** * 运行环境权限类型 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ PermissionNames?: PlusNavigatorPermissionNames | undefined; /** * 检查运行环境的权限 * 向系统检查当前程序的权限状态,不触发权限相对应的功能API的调用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ checkPermission(permission?: PlusNavigatorPermissionNames): string; @@ -6417,21 +6623,21 @@ interface PlusNavigator { * 很多情况下,应用启动后需要一段时间加载数据,为了避免界面显示空白内容,提高用户体验效果,这时可显示启动界面。 * 等数据加载完成后再关闭启动界面进入应用,通常可在应用首界面加载数据完成并更新显示内容后调用此方法。 * 注意:HBuilder7.1版本后启动界面不调用此方法超过6秒后会自动关闭。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ closeSplashscreen(): void; /** * 查询设备是否为刘海屏 * 刘海屏返回true,否则返回false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ hasNotchInScreen(): boolean; /** * 查询应用启动界面是否已关闭 * 如果启动界面显示返回true,否则返回false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ hasSplashscreen(): boolean; @@ -6439,20 +6645,20 @@ interface PlusNavigator { * 更新程序启动界面 * 可设置启动界面显示的图片(仅支持本地文件路径,如果是网络资源可先通过plus.downloader.*下载到本地), * 更新启动界面后程序下次启动时生效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ updateSplashscreen(options?: PlusNavigatorSplashscreenOptions): void; /** * 创建应用快捷方式 * 在系统桌面创建应用的快捷方式,点击后可直接启动应用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ createShortcut(options?: PlusNavigatorShortcutOptions, successCallback?: (result: any) => void): void; /** * 查询是否存在应用快捷方式 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ hasShortcut(options?: PlusNavigatorShortcutOptions, successCallback?: (result: any) => void): void; @@ -6460,13 +6666,13 @@ interface PlusNavigator { * 判断当前应用是否切换到后台 * 在多应用运行环境(如流应用)中,启动一个新应用时,之前运行的应用将会自动切换到后台运行,此时plus.navigator.isBackground()返回状态只为true。 * 注意:此状态不是5+应用切换到系统后台的状态,而是在同一apk中同时运行多个应用时被切换到后台的状态。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ isBackground(): boolean; /** * 判断应用当前是否全屏模式显示 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ isFullscreen(): boolean; @@ -6474,14 +6680,14 @@ interface PlusNavigator { * 判断应用当前是否输出日志 * 日志包括应用原生层内部跟踪日志(ADB、LogCat工具可获取的日志)及JS层跟踪日志(console.log输出的日志)。 * 开启日志在一定程度上会降低程序的性能,通常建议在正式发布时关闭日志输出,在调试时开启日志输出(此时可以通过工具ADB、LogCat获取分析日志)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ isLogs(): boolean; /** * 设置应用是否全屏显示 * 设置应用在全屏模式显示时,将隐藏系统状态栏,通常游戏类应用才会设置为全屏模式显示。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ setFullscreen(fullscreen?: boolean): void; @@ -6490,7 +6696,7 @@ interface PlusNavigator { * 设置应用是否输出日志信息,默认关闭输出日志功能。 * 日志包括应用原生层内部跟踪日志(ADB、LogCat工具可获取的日志)及JS层跟踪日志(console.log输出的日志)。 * 开启日志在一定程度上会降低程序的性能,通常建议在正式发布时关闭日志输出,在调试时开启日志输出(此时可以通过工具ADB、LogCat获取分析日志)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ setLogs(log?: boolean): void; @@ -6498,14 +6704,14 @@ interface PlusNavigator { * 设置系统状态栏背景颜色 * 设置应用在前台运行时系统状态栏的背景颜色,默认使用系统状态栏默认背景色(有系统状态栏样式决定)。 * 注意:为了有更好的兼容性,避免设置接近白色或黑色的颜色值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ setStatusBarBackground(color?: string): void; /** * 获取系统状态栏背景颜色 * 获取应用在前台运行时系统状态栏的背景颜色。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ getStatusBarBackground(): string; @@ -6513,21 +6719,21 @@ interface PlusNavigator { * 设置系统状态栏样式 * 设置应用在前台运行时系统状态栏的样式,默认值可通过manifest.json文件的plus->statusbar->style配置。 * 注意:此操作是应用全局配置,调用的Webview窗口关闭后仍然生效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ setStatusBarStyle(style?: string): void; /** * 获取系统状态栏样式 * 获取应用运行时系统状态栏的样式。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ getStatusBarStyle(): string; /** * 获取系统状态栏高度 * 单位为像素(px),值为Webview中的逻辑高度单位,如果要获取真实高度则必须乘以plus.screen.scale。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ getStatusbarHeight(): number; @@ -6535,7 +6741,7 @@ interface PlusNavigator { * 判断当前是否为沉浸式状态栏模式 * 如果当前应用采用沉浸式状态栏则返回true,否则返回false。 * 注意:如果当前系统版本不支持沉浸式状态栏也返回false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ isImmersedStatusbar(): boolean; @@ -6543,44 +6749,44 @@ interface PlusNavigator { * 设置userAgent值 * 设置应用通过navigator.userAgent获取的值,及所有发起Http请求时提交的userAgent值。 * 如果要设置启动页面的userAgent值则需要在manifest.json中进行配置。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ setUserAgent(useragent?: string, checkplus?: boolean): void; /** * 获取userAgent值 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ getUserAgent(): string; /** * 设置Cookie值 * 设置应用发起Http请求时提交的cookie值,调用此接口后所有的请求都生效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ setCookie(url?: string, value?: string): void; /** * 获取Cookie值 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ getCookie(url?: string): string; /** * 删除应用所有Cookie值 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ removeAllCookie(): void; /** * 删除应用Cookie - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ removeCookie(url?: string): void; /** * 删除应用所有会话期Cookie值 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ removeSessionCookie(): void; @@ -6588,42 +6794,42 @@ interface PlusNavigator { /** * 创建应用快捷方式要设置的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ interface PlusNavigatorShortcutOptions { /** * 快捷方式名称 * 如果未设置则使用应用的名称,manifest.json中name属性值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ name?: string | undefined; /** * 快捷方式的图标 * 如果未设置则优先使用应用中指定的图标(manifest.json中icon节点下对应分辨率的图标),如未区配则使用应用的图标(仅在独立打包时),否则使用runtime提供的默认图标。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ icon?: string | undefined; /** * 创建快捷方式后的提示信息 * 快捷方式创建成功后显示,默认提示内容为“"XXXX"已创建桌面快捷方式”,其中"XXXX"为程序的名称,如果不需要提示则设置此值为空字符串。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ toast?: string | undefined; /** * 快捷方式的扩展参数 * 其中key和value值都必须是字符串类型。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ extra?: any; /** * 要启动Activity类名 * 通常情况下不需要指定此值,仅在5+SDK集成时自定义Activity才用到。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ classname?: string | undefined; @@ -6631,7 +6837,7 @@ interface PlusNavigatorShortcutOptions { * 是否需要强制创建快捷方式 * true表示强制创建,false表示不强制创建,默认值为true。 * 强制创建可能会导致在无法判断快捷方式是否存在的设备上重复创建,如果需要尽可能避免出现重复创建桌面快捷方式则应该设置force属性值为false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ force?: boolean | undefined; @@ -6639,21 +6845,21 @@ interface PlusNavigatorShortcutOptions { /** * 更新应用启动界面要设置的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ interface PlusNavigatorSplashscreenOptions { /** * 启动界面的图片路径 * 仅支持本地文件路径,图片必须为png格式。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ image?: string | undefined; /** * 是否自动关闭启动界面 * true表示应用启动后自动关闭启动界面,false表示应用启动后不自动关闭启动界面,需要在应用调用plus.navigator.closeSplashscreen()方法关闭。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ autoclose?: boolean | undefined; @@ -6661,14 +6867,14 @@ interface PlusNavigatorSplashscreenOptions { * 是否自动关闭启动界面(WAP2APP应用) * 与autoclose属性值作用一致,仅在WAP2APP应用中有效。 * 不推荐设置此值,如果未设置会自动使用autoclose属性值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ autoclose_w2a?: boolean | undefined; /** * 启动界面延时关闭时间 * 仅在设置为自动关闭启动界面时有效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ delay?: number | undefined; @@ -6676,7 +6882,7 @@ interface PlusNavigatorSplashscreenOptions { * 启动界面延时关闭时间(WAP2APP应用) * 与delay属性值作用一致,仅在WAP2APP应用中有效。 * 不推荐设置此值,如果未设置会自动使用delay属性值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ delay_w2a?: number | undefined; @@ -6684,56 +6890,56 @@ interface PlusNavigatorSplashscreenOptions { /** * 运行环境权限类型 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ interface PlusNavigatorPermissionNames { /** * 访问摄像头权限 * 用于调用摄像头(plus.camera.*、plus.barcode.*)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ CAMERA?: string | undefined; /** * 访问系统联系人权限 * 用于访问(读、写)系统通讯录(plus.gallery.*)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ CONTACTS?: string | undefined; /** * 访问系统相册权限 * 用于访问(读、写)系统相册(plus.gallery.*)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ GALLERY?: string | undefined; /** * 定位权限 * 用于获取当前用户位置信息(plus.geolocation.*)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ LOCATION?: string | undefined; /** * 消息通知权限 * 用于接收系统消息通知(plus.push.*)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ NOTIFITION?: string | undefined; /** * 录音权限 * 用于进行本地录音操作(plus.audio.AudioRecorder)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ RECORD?: string | undefined; /** * 创建桌面快捷方式权限 * 用于在系统桌面创建快捷方式图标(plus.navigator.createShortcut)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/navigator.html](http://www.html5plus.org/doc/zh_cn/navigator.html) */ SHORTCUT?: string | undefined; @@ -6741,39 +6947,43 @@ interface PlusNavigatorPermissionNames { /** * Orientation模块管理设备的方向信息,包括alpha、beta、gamma三个方向信息,通过plus.orientation可获取设备方向管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) */ interface PlusOrientation { /** * JSON对象,监听设备方向感应器参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) */ OrientationOption?: PlusOrientationOrientationOption | undefined; /** * JSON对象,设备方向信息数据 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) */ Rotation?: PlusOrientationRotation | undefined; /** * 获取当前设备的方向信息,包括alpha、beta、gamma三个方向信息 * 方向信息是设备相对于水平初始方向分别以z、x、y轴为轴心旋转的角度,对应值为alpha、beta、gamma三个方向的信息。 方向信息可通过successCB回调函数返回。方向信息获取失败则调用回调函数errorCB - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) */ getCurrentOrientation(successCB?: (result: string) => void, errorCB?: (result: any) => void): void; /** * 监听设备方向信息的变化 * 方向信息是设备相对于水平初始方向分别以z、x、y轴为轴心旋转的角度,对应值为alpha、beta、gamma三个方向的信息。watchOrientation每隔固定时间就获取一次设备的方向信息,通过successCB回调函数返回。可通过option的frequency参数设定获取设备方向信息的时间间隔。方向信息获取失败则调用回调函数errorCB。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) */ - watchOrientation(successCB?: (result: string) => void, errorCB?: (result: any) => void, option?: PlusOrientationOrientationOption): number; + watchOrientation( + successCB?: (result: string) => void, + errorCB?: (result: any) => void, + option?: PlusOrientationOrientationOption, + ): number; /** * 关闭监听设备方向信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) */ clearWatch(watchId?: number): void; @@ -6781,14 +6991,14 @@ interface PlusOrientation { /** * JSON对象,监听设备方向感应器参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) */ interface PlusOrientationOrientationOption { /** * 更新方向信息的时间间隔 * 数值类型,单位为ms,默认值为500ms。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) */ frequency?: number | undefined; @@ -6796,49 +7006,49 @@ interface PlusOrientationOrientationOption { /** * JSON对象,设备方向信息数据 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) */ interface PlusOrientationRotation { /** * 以z方向为轴心的旋转角度 * 浮点数类型,只读属性,取值范围为0到360(不等于360)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) */ alpha?: number | undefined; /** * 以x方向为轴心的旋转角度 * 浮点数类型,只读属性,取值范围为-180到180(不等于180)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) */ beta?: number | undefined; /** * 以y方向为轴心的旋转角度 * 浮点数类型,只读属性,取值范围为-180到180(不等于180)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) */ gamma?: number | undefined; /** * 设备方向与地球磁场北极方向的角度 * 浮点数类型,只读属性,取值范围为0到360(不等于360)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) */ magneticHeading?: number | undefined; /** * 设备方向与地球真实北极方向的角度 * 浮点数类型,只读属性,取值范围为0到360(不等于360)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) */ trueHeading?: number | undefined; /** * 设备方向值的误差值 * 浮点数类型,只读属性,取值范围为0到360(不等于360)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/orientation.html](http://www.html5plus.org/doc/zh_cn/orientation.html) */ headingAccuracy?: number | undefined; @@ -6846,27 +7056,27 @@ interface PlusOrientationRotation { /** * Proximity模块管理设备距离传感器,可获取当前设备的接近距离信息,通过plus.proximity可获取设备距离传感管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/proximity.html](http://www.html5plus.org/doc/zh_cn/proximity.html) */ interface PlusProximity { /** * 获取当前设备的接近距离信息 * 获取当前接近设备的距离信息,距离值单位为厘米。如果感应器无法获取准确的距离值,则在接近设备时返回0,否则返回Infinity。 获取成功则调用successCB回调函数返接近回距离值。获取失败则调用errorCB回调函数错误信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/proximity.html](http://www.html5plus.org/doc/zh_cn/proximity.html) */ getCurrentProximity(successCB?: (result: number) => void, errorCB?: (result: any) => void): void; /** * 监听设备接近距离的变化 * watchProximity将监听设备的接近距离信息变化事件,当接近距离发生变化时通过changeCB回调函数返回距离值。监听距离变化事件失败则通过errorCB回调函数返回错误信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/proximity.html](http://www.html5plus.org/doc/zh_cn/proximity.html) */ watchProximity(changeCB?: (result: number) => void, errorCB?: (result: any) => void): number; /** * 关闭监听设备接近距离变化 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/proximity.html](http://www.html5plus.org/doc/zh_cn/proximity.html) */ clearWatch(watchId?: number): void; @@ -6874,45 +7084,45 @@ interface PlusProximity { /** * Runtime模块管理运行环境,可用于获取当前运行环境信息、与其它程序进行通讯等。通过plus.runtime可获取运行环境管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ interface PlusRuntime { /** * JSON对象,打开第三方程序参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ ApplicationInf?: PlusRuntimeApplicationInf | undefined; /** * JSON对象,应用角标显示需要的通知栏消息的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ BadgeOptions?: PlusRuntimeBadgeOptions | undefined; /** * JSON对象,打开文件参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ OpenFileOptions?: PlusRuntimeOpenFileOptions | undefined; /** * JSON对象,应用信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ WidgetInfo?: PlusRuntimeWidgetInfo | undefined; /** * JSON对象,应用安装参数 * 可通过对象设置安装的应用是否进行appid校验、版本号校验等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ WidgetOptions?: PlusRuntimeWidgetOptions | undefined; /** * 当前应用的APPID * 当前应用的APPID,字符串类型。注意,如果是在HBuilder真机运行获取的是固定值"HBuilder",需要提交App云端打包后运行才能获取真实的APPID值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ appid?: string | undefined; @@ -6920,7 +7130,7 @@ interface PlusRuntime { * 第三方程序调用时传递给程序的参数 * 第三方程序传递过来的参数,字符串格式类型数据。 * 不是由第三方程序调用启动,则返回空字符串。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ arguments?: string | undefined; @@ -6928,7 +7138,7 @@ interface PlusRuntime { * 应用的市场推广渠道标识 * "qihoo:browser"标识360浏览器流应用,"qihoo:appstore "表示360手机助手流应用,"dcloud:streamapps"表示DCloud流应用基座。 * 注意:仅流应用环境中可用(如果没有特殊配置默认返回运行环境的包名),非流应用环境中返回空字符串。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ channel?: string | undefined; @@ -6948,28 +7158,27 @@ interface PlusRuntime { * "search":通过流应用的应用搜索启动应用(如iOS平台的T9键盘搜索); * "speech":通过流应用的语音识别启动应用; * "miniProgram":通过微信小程序启动应用。 - * - default: + * - default: * 默认启动方式,通常表示从系统桌面图标启动 - * - * - scheme: + * + * - scheme: * 通过urlscheme方式触发启动 - * - * - push: + * + * - push: * 通过点击系统通知方式触发启动 - * - * - stream: + * + * - stream: * 通过流应用api(plus.stream.open)启动 - * - * - shortcut: + * + * - shortcut: * iOS平台表示通过3D Touch快捷方式,Android平台表示通过桌面快捷方式启动 - * - * - barcode: + * + * - barcode: * 通过二维码扫描启动 - * - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ - launcher?: 'default' | 'scheme' | 'push' | 'stream' | 'shortcut' | 'barcode' | undefined; + launcher?: "default" | "scheme" | "push" | "stream" | "shortcut" | "barcode" | undefined; /** * 应用安装来源 * 5+应用安装来源,可取以下值: @@ -6981,39 +7190,38 @@ interface PlusRuntime { * "silent":通过后台静默方式安装,仅流应用环境下支持; * "speech":通过语音识别方式触发安装,仅流应用环境下支持; * "favorite":通过收藏界面启动触发安装,仅流应用环境下支持。 - * - default: + * - default: * 默认安装来源,apk/ipa安装包内置安装 - * - * - stream: + * + * - stream: * 通过流应用api(plus.stream.open)安装 - * - * - push: + * + * - push: * 通过点击系统通知方式触发安装 - * - * - scheme: + * + * - scheme: * 通过urlscheme方式触发安装 - * - * - barcode: + * + * - barcode: * 通过二维码扫描触发安装 - * - * - silent: + * + * - silent: * 通过后台静默方式安装 - * - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ - origin?: 'default' | 'stream' | 'push' | 'scheme' | 'barcode' | 'silent' | undefined; + origin?: "default" | "stream" | "push" | "scheme" | "barcode" | "silent" | undefined; /** * 客户端的版本号 * 字符串类型,在编译环境中设置的apk/ipa版本号。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ version?: string | undefined; /** * 客户端5+运行环境的版本号 * 5+运行环境版本号,格式为:[主版本号].[次版本号].[修订版本号].[编译代号]。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ innerVersion?: string | undefined; @@ -7021,27 +7229,27 @@ interface PlusRuntime { * 获取当前应用首页加载的时间 * 应用加载首页面的总时间,从开始加载首页面到首页面加载完成,单位为ms。 * 注意,应用首页为网络地址则包括网络传输时间。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ launchLoadedTime?: number | undefined; /** * 获取当前应用的进程标识 * 当前应用所属系统进程标识。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ processId?: string | undefined; /** * 获取当前应用的启动时间 * 应用启动时间戳,距1970年1月1日之间的毫秒数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ startupTime?: number | undefined; /** * 获取指定APPID对应的应用信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ getProperty(appid?: string, getPropertyCB?: (result: PlusRuntimeWidgetInfo) => void): void; @@ -7052,43 +7260,48 @@ interface PlusRuntime { * 2. 应用资源差量升级包(wgtu),扩展名为'.wgtu'; * 3. 系统程序安装包(apk),要求使用当前平台支持的安装包格式。 * 注意:仅支持本地地址,调用此方法前需把安装包从网络地址或其他位置放置到运行时环境可以访问的本地目录。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ - install(filePath?: string, options?: PlusRuntimeWidgetOptions, installSuccessCB?: (result: PlusRuntimeWidgetInfo) => void, installErrorCB?: (result: any) => void): void; + install( + filePath?: string, + options?: PlusRuntimeWidgetOptions, + installSuccessCB?: (result: PlusRuntimeWidgetInfo) => void, + installErrorCB?: (result: any) => void, + ): void; /** * 退出客户端程序 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ quit(): void; /** * 重启当前的应用 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ restart(): void; /** * 设置程序快捷方式图标上显示的角标数字 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ setBadgeNumber(number?: number, options?: PlusRuntimeBadgeOptions): void; /** * 调用第三方程序打开指定的URL - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ openURL(url?: string, errorCB?: (result: any) => void, identity?: string): void; /** * 使用内置Webview窗口打开URL - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ openWeb(url?: string): void; /** * 调用第三方程序打开指定的文件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ openFile(filepath?: string, options?: PlusRuntimeOpenFileOptions, errorCB?: (result: any) => void): void; @@ -7098,20 +7311,20 @@ interface PlusRuntime { * 如“streamapp://m3w.cn/s/HelloH5?__direct_page=http%3a%2f%2fm.weibo.cn%2fu%2f3196963860”; * 在流应用SDK集成时也可以通过direct_page参数(原生调用Intent)设置。 * 注意:仅第一次调用此API时返回直达页面链接地址,再次调用将返回空字符串;如果应用重新被带直达页面链接参数的URL Scheme启动/激活时,可再次调用此方法获取。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ processDirectPage(): string; /** * 调用第三方程序 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ launchApplication(appInf?: PlusRuntimeApplicationInf, errorCB?: (result: any) => void): void; /** * 判断第三方程序是否已存在 * 如果第三方程序已安装则返回true,未安装则返回false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ isApplicationExist(appInf?: PlusRuntimeApplicationInf): boolean; @@ -7120,7 +7333,7 @@ interface PlusRuntime { * 通过URL Scheme启动时,可以在?后面添加__launch_path参数自定义应用启动首页加载的页面地址, * 如“streamapp://m3w.cn/s/HelloH5?__launch_path=http%3a%2f%2fm.weibo.cn%2fu%2f3196963860”; * 在流SDK集成时也可以通过launch_path参数(原生调用Intent)设置。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ isCustomLaunchPath(): boolean; @@ -7128,21 +7341,21 @@ interface PlusRuntime { /** * JSON对象,打开第三方程序参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ interface PlusRuntimeApplicationInf { /** * 第三方程序包名 * 仅Android平台支持,表示程序的包名,其它平台忽略此属性值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ pname?: string | undefined; /** * 程序的操作行为 * Android平台上与系统的action值一致;iOS平台为要调用程序的URLScheme格式字符串。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ action?: string | undefined; @@ -7153,14 +7366,14 @@ interface PlusRuntimeApplicationInf { * false-不使用新任务模式标记(FLAG_ACTIVITY_NEW_TASK)启动应用。 * 默认值为true。 * 注意:由于5+应用配置的launchMode为singleTask,所以另一个5+应用通过plus.runtime.launchApplication启动时如果应用已经在后台运行则不会触发newintent事件,为了避免此问题需要将newTask参数值设置为false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ newTask?: boolean | undefined; /** * 调用程序的参数 * 仅Android平台支持,为JSON格式,用于传递给要调用程序的参数,如extra:{url:"http://www.html5plus.org"}。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ extra?: any; @@ -7168,21 +7381,21 @@ interface PlusRuntimeApplicationInf { /** * JSON对象,应用角标显示需要的通知栏消息的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ interface PlusRuntimeBadgeOptions { /** * 消息的标题 * 默认值为应用的名称。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ title?: string | undefined; /** * 消息的内容 * 默认值为“您有x条未读消息"”,其中x未设置的角标数字值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ content?: string | undefined; @@ -7190,7 +7403,7 @@ interface PlusRuntimeBadgeOptions { /** * JSON对象,打开文件参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ interface PlusRuntimeOpenFileOptions { @@ -7198,14 +7411,14 @@ interface PlusRuntimeOpenFileOptions { * 优先使用的程序包名 * 如果指定包名的程序已经安装,则调用其打开文件,若程序不支持打开文件则触发错误回调。 * 如果指定包名的程序未安装,则弹出系统支持打开此文件的列表,由用户选择程序打开。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ pname?: string | undefined; /** * 弹出系统选择程序界面指示区域 * JSON对象,格式如{top:10;left:10;width:200;height:200;},所有值为像素值,左上坐标相对于容器webview的位置。仅在iPad设备平台有效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ popover?: any; @@ -7213,70 +7426,70 @@ interface PlusRuntimeOpenFileOptions { /** * JSON对象,应用信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ interface PlusRuntimeWidgetInfo { /** * 应用的APPID - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ appid?: string | undefined; /** * 应用的版本号 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ version?: string | undefined; /** * 应用的名称 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ name?: string | undefined; /** * 应用描述信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ description?: string | undefined; /** * 应用描述信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ author?: string | undefined; /** * 开发者邮箱地址 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ email?: string | undefined; /** * 应用授权描述信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ license?: string | undefined; /** * 应用授权说明链接地址 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ licensehref?: string | undefined; /** * 应用许可特性列表 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ - features?: string [] | undefined; + features?: string[] | undefined; } /** * JSON对象,应用安装参数 * 可通过对象设置安装的应用是否进行appid校验、版本号校验等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ interface PlusRuntimeWidgetOptions { @@ -7284,7 +7497,7 @@ interface PlusRuntimeWidgetOptions { * 是否强制安装 * true表示强制安装,不进行版本号的校验;false则需要版本号校验,如果将要安装应用的版本号不高于现有应用的版本号则终止安装,并返回安装失败。 * 仅安装wgt和wgtu时生效,默认值 false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/runtime.html](http://www.html5plus.org/doc/zh_cn/runtime.html) */ force?: boolean | undefined; @@ -7292,19 +7505,19 @@ interface PlusRuntimeWidgetOptions { /** * Storage模块管理应用本地数据存储区,用于应用数据的保存和读取。应用本地数据与localStorage、sessionStorage的区别在于数据有效域不同,前者可在应用内跨域操作,数据存储期是持久化的,并且没有容量限制。通过plus.storage可获取应用本地数据管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/storage.html](http://www.html5plus.org/doc/zh_cn/storage.html) */ interface PlusStorage { /** * 获取应用存储区中保存的键值对的个数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/storage.html](http://www.html5plus.org/doc/zh_cn/storage.html) */ getLength(): number; /** * 通过键(key)检索获取应用存储的值 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/storage.html](http://www.html5plus.org/doc/zh_cn/storage.html) */ getItem(key?: string): string; @@ -7312,25 +7525,25 @@ interface PlusStorage { * 修改或添加键值(key-value)对数据到应用数据存储中 * 如果设置的键在应用数据存储中已经存在,更新存储的键值。 * 存储的键和值没有容量限制,但过多的数据量会导致效率降低,建议单个键值数据不要超过10Kb。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/storage.html](http://www.html5plus.org/doc/zh_cn/storage.html) */ setItem(key?: string, value?: string): void; /** * 通过key值删除键值对存储的数据 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/storage.html](http://www.html5plus.org/doc/zh_cn/storage.html) */ removeItem(key?: string): void; /** * 清除应用所有的键值对存储数据 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/storage.html](http://www.html5plus.org/doc/zh_cn/storage.html) */ clear(): void; /** * 获取键值对中指定索引值的key值 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/storage.html](http://www.html5plus.org/doc/zh_cn/storage.html) */ key(index?: number): void; @@ -7338,75 +7551,79 @@ interface PlusStorage { /** * Stream模块操作流应用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ interface PlusStream { /** * JSON对象,启动流应用参数 * 指定要启动的流应用标识、名称、图标、参数等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ StreamOptions?: PlusStreamStreamOptions | undefined; /** * JSON对象,流应用恢复运行的参数 * 设置流应用恢复运行时的参数、splash、首页等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ StreamRestoreOptions?: PlusStreamStreamRestoreOptions | undefined; /** * 流应用恢复运行时启动界面配置参数 * 设置流应用恢复运行时启动界面,如是否自动关闭、延时关闭时间、超时时间等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ StreamRestoreSplashscreenOptions?: PlusStreamStreamRestoreSplashscreenOptions | undefined; /** * JSON对象,启动流应用的首页窗口属性 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ LaunchWebviewStyles?: PlusStreamLaunchWebviewStyles | undefined; /** * JSON对象,流应用信息 * 流应用标识、图标、是否下载完成等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ StreamInfo?: PlusStreamStreamInfo | undefined; /** * JSON对象,免流量操作参数 * 包含电话号码、验证码等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ FreetrafficOptions?: PlusStreamFreetrafficOptions | undefined; /** * 免流量状态变化事件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ onfreetrafficStateChange?: any; /** * 启动流应用 * 打开指定的流应用,在流应用中通过plus.runtime.launcher获取的值为"stream"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ - open(options?: PlusStreamStreamOptions, successCallback?: (result: any) => void, errorCallback?: (result: any) => void): void; + open( + options?: PlusStreamStreamOptions, + successCallback?: (result: any) => void, + errorCallback?: (result: any) => void, + ): void; /** * 流应用激活统计 * 提交统计数据到流应用服务器,表明业务系统激活成功。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ activate(): void; /** * 已下载流应用列表 * 获取当前设备上已安装的所有流应用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ list(options?: any, successCallback?: any, errorCallback?: any): void; @@ -7414,14 +7631,14 @@ interface PlusStream { * 预加载流应用 * 预加载指定的流应用资源,下载应用资源等,并不运行流应用。 * 如果应用资源已经下载,则不做任何操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ preload(appid?: string): void; /** * 删除流应用 * 删除已下载的流应用,清空应用相关运行期保存的资源(如缓存、配置文件等)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ remove(appid?: string): void; @@ -7431,38 +7648,46 @@ interface PlusStream { * 可通过此方法设置应用被自动关闭后再次被唤醒恢复运行时的参数,流应用恢复运行流程与第一次启动一致(差别是会使用StreamRestoreOptions中配置的参数)。 * 如果没有调用setRestoreState方法,则恢复运行时使用启动时(调用plus.stream.open方法)传入的参数。 * 注意:如果通过plus.stream.open方法启动应用,则忽略此方法设置的参数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ setRestoreState(options?: PlusStreamStreamRestoreOptions): void; /** * 请求免流量验证码 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ - freetrafficRequest(options?: PlusStreamFreetrafficOptions, successCallback?: () => void, errorCallback?: (result: any) => void): void; + freetrafficRequest( + options?: PlusStreamFreetrafficOptions, + successCallback?: () => void, + errorCallback?: (result: any) => void, + ): void; /** * 免流量绑定手机号 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ - freetrafficBind(options?: PlusStreamFreetrafficOptions, successCallback?: () => void, errorCallback?: (result: any) => void): void; + freetrafficBind( + options?: PlusStreamFreetrafficOptions, + successCallback?: () => void, + errorCallback?: (result: any) => void, + ): void; /** * 解除免流量绑定 * 解除当前设备绑定的手机号,如果设备未绑定则不执行操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ freetrafficRelease(): void; /** * 获取免流量状态信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ freetrafficInfo(successCallback?: (result: any) => void, errorCallback?: (result: any) => void): void; /** * 免流量是否生效 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ freetrafficIsValid(): boolean; @@ -7471,49 +7696,49 @@ interface PlusStream { /** * JSON对象,启动流应用参数 * 指定要启动的流应用标识、名称、图标、参数等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ interface PlusStreamStreamOptions { /** * 流应用运行模式 * 可取值:"test"表示测试版模式运行,其它值则为正式版本模式。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ appmode?: string | undefined; /** * 流应用标识 * 流应用唯一字符串标识。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ appid?: string | undefined; /** * 启动流应用的直达页面链接地址 * 可在应用中通过plus.runtime.processDirectPage()方法获取。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ direct_page?: string | undefined; /** * 流应用运行参数 * 启动流应用的扩展参数,可在流应用中通过plus.runtime.arguments获取。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ extras?: any; /** * 流应用图标 * 流应用显示的图标路径(仅支持本地路径),在启动提示界面中显示。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ icon?: string | undefined; /** * 流应用启动类型 * 流应用的启动类型,可在流应用中通过plus.runtime.launcher获取,默认值为“stream”。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ launcher?: string | undefined; @@ -7523,21 +7748,21 @@ interface PlusStreamStreamOptions { * "auto":自动选择启动界面,如果splash图片已经下载则显示splash图片,否则使用默认加载流应用界面; * "default":使用默认加载流应用界面(如在360浏览器环境中在标题栏下显示加载进度条)。 * 默认值为"auto"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ splash?: string | undefined; /** * 流应用首页窗口对象样式 * 如果流应用已经运行,从后台激活到前台时忽略此属性。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ styles?: PlusStreamLaunchWebviewStyles | undefined; /** * 流应用名称 * 流应用显示的标题,在启动提示界面中显示。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ title?: string | undefined; @@ -7550,7 +7775,7 @@ interface PlusStreamStreamOptions { * "query" - 弹出询问提示框(底部显示),用户点击确定后创建桌面快捷方式(检查并引导用户打开快捷方式权限); * "tipOnce" - 业务逻辑与"auto"类似,差别是只会引导用户打开快捷方式权限一次、toast提示一次。 * 默认值为"force"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ shortcut?: string | undefined; @@ -7561,7 +7786,7 @@ interface PlusStreamStreamOptions { * "queryOnce" - 仅应用第一次退出检查,检查逻辑同query; * "none" - 应用退出时不检查是否创建桌面快捷方式。 * 默认值为"none"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ shortcutQuit?: string | undefined; @@ -7570,14 +7795,14 @@ interface PlusStreamStreamOptions { /** * JSON对象,流应用恢复运行的参数 * 设置流应用恢复运行时的参数、splash、首页等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ interface PlusStreamStreamRestoreOptions { /** * 流应用运行参数 * 启动流应用的扩展参数,可在流应用中通过plus.runtime.arguments获取。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ extras?: any; @@ -7587,20 +7812,20 @@ interface PlusStreamStreamRestoreOptions { * "auto":自动选择启动界面,如果流应用自动关闭时截图成功则使用截图,如果splash图片已经下载则显示splash图片,否则使用默认加载流应用界面; * "default":使用默认加载流应用界面(如在360浏览器环境中在标题栏下显示加载进度条)。 * 默认值为"auto"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ splash?: string | undefined; /** * 流应用首页窗口对象样式 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ styles?: PlusStreamLaunchWebviewStyles | undefined; /** * 流应用恢复运行时启动界面配置参数 * 用于流应用自动关闭后恢复运行时调整启动界面配置参数,如将自动关闭splash调整为手动关闭,以便恢复上次运行状态后再进入应用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ splashscreen?: PlusStreamStreamRestoreSplashscreenOptions | undefined; @@ -7609,14 +7834,14 @@ interface PlusStreamStreamRestoreOptions { /** * 流应用恢复运行时启动界面配置参数 * 设置流应用恢复运行时启动界面,如是否自动关闭、延时关闭时间、超时时间等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ interface PlusStreamStreamRestoreSplashscreenOptions { /** * 是否自动关闭启动界面 * true表示应用启动后自动关闭启动界面,false表示应用启动后不自动关闭启动界面,需要在应用调用plus.navigator.closeSplashscreen()方法关闭。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ autoclose?: boolean | undefined; @@ -7624,7 +7849,7 @@ interface PlusStreamStreamRestoreSplashscreenOptions { * 启动界面超时时间 * 单位为毫秒(ms),当启动界面超过此时间仍然未关闭时(不管autoclose值设置true还是false),应用将自动关闭启动界面。 * 默认值为6000(即6秒)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ timeout?: number | undefined; @@ -7632,7 +7857,7 @@ interface PlusStreamStreamRestoreSplashscreenOptions { /** * JSON对象,启动流应用的首页窗口属性 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ interface PlusStreamLaunchWebviewStyles { @@ -7640,7 +7865,7 @@ interface PlusStreamLaunchWebviewStyles { * 流应用首页是否阻塞网络图片的加载 * true表示阻塞网络图片的加载,false表示不阻塞网络图片的加载。默认值为false。 * 设置后可通过Webview窗口对象的setBlockNetworkImage(false)方法修改设置来继续加载网络图片。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ blockNetworkImage?: boolean | undefined; @@ -7649,14 +7874,14 @@ interface PlusStreamLaunchWebviewStyles { * 可使用网络地址(http://或https://开头),也可使用本地地址(相对应用资源路径)。 * 也可使用特定地址: * about:blank - 使用空白首页,仅加载内置注入的脚本(如all.js、wap2app.js、config.js等)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ launch_path?: string | undefined; /** * 指定首页Webview的id * 如果未指定id,则使用应用的appid作为首页Webview的id。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ id?: string | undefined; @@ -7664,7 +7889,7 @@ interface PlusStreamLaunchWebviewStyles { * 流应用首页是否显示 * true表示显示,false表示不显示。默认值为true。 * 注意:流应用首页隐藏后,需要调用首页的setVisible方法显示,如plus.webview.getLaunchWebview().setVisible(true)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ visible?: boolean | undefined; @@ -7673,21 +7898,21 @@ interface PlusStreamLaunchWebviewStyles { /** * JSON对象,流应用信息 * 流应用标识、图标、是否下载完成等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ interface PlusStreamStreamInfo { /** * 流应用标识 * 流应用唯一字符串标识。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ id?: string | undefined; /** * 流应用的图标 * 流应用下载的图标路径(本地路径),如果未下载完成则返回空。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ icon?: string | undefined; @@ -7695,7 +7920,7 @@ interface PlusStreamStreamInfo { * 流应用是否下载完成 * true表示流应用下载完成,false表示流应用未下载完成。 * 注意,流应用未下载完成以让可以正常启动运行,启动后会自动下载。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ complete?: boolean | undefined; @@ -7704,21 +7929,21 @@ interface PlusStreamStreamInfo { /** * JSON对象,免流量操作参数 * 包含电话号码、验证码等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ interface PlusStreamFreetrafficOptions { /** * 电话号码 * 免流量请求验证码、绑定设备使用的电话号码。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ phone?: string | undefined; /** * 验证码 * 免流量绑定设备使用的验证码。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/stream.html](http://www.html5plus.org/doc/zh_cn/stream.html) */ code?: string | undefined; @@ -7726,58 +7951,62 @@ interface PlusStreamFreetrafficOptions { /** * Uploader模块管理网络上传任务,用于从本地上传各种文件到服务器,并支持跨域访问操作。通过plus.uploader可获取上传管理对象。Uploader上传使用HTTP的POST方式提交数据,数据格式符合Multipart/form-data规范,即rfc1867(Form-based File Upload in HTML)协议。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ interface PlusUploader { /** * Upload对象管理一个上传任务 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ Upload?: PlusUploaderUpload | undefined; /** * 上传任务事件类型 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ UploadEvent?: PlusUploaderUploadEvent | undefined; /** * 上传任务的状态,Number类型 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ UploadState?: PlusUploaderUploadState | undefined; /** * JSON对象,创建上传任务的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ UploadOptions?: PlusUploaderUploadOptions | undefined; /** * JSON对象,添加上传文件的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ UploadFileOptions?: PlusUploaderUploadFileOptions | undefined; /** * 新建上传任务 * 请求上传管理创建新的上传任务,创建成功则返回Upload对象,用于管理上传任务。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ - createUpload(url?: string, options?: PlusUploaderUploadOptions, completedCB?: (result0: PlusUploaderUpload, result1: number) => void): PlusUploaderUpload; + createUpload( + url?: string, + options?: PlusUploaderUploadOptions, + completedCB?: (result0: PlusUploaderUpload, result1: number) => void, + ): PlusUploaderUpload; /** * 枚举上传任务 * 枚举指定状态的上传任务列表,通过enumCB回调函数返回结果。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ - enumerate(enumCB?: (result: PlusUploader []) => void, state?: PlusUploaderUploadState): void; + enumerate(enumCB?: (result: PlusUploader[]) => void, state?: PlusUploaderUploadState): void; /** * 清除上传任务 * 清除指定状态的上传任务。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ clear(state?: PlusUploaderUploadState): void; @@ -7785,7 +8014,7 @@ interface PlusUploader { * 开始所有上传任务 * 开始所有处于未开始调度或暂停状态的上传任务。 * 若上传任务数超过可并发处理的总数,超出的任务处于调度状态(等待上传),当有任务完成时根据调度状态任务的优先级选择任务开始上传。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ startAll(): void; @@ -7793,56 +8022,56 @@ interface PlusUploader { /** * Upload对象管理一个上传任务 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ interface PlusUploaderUpload { /** * 上传任务的标识 * 在创建任务时系统自动分配,用于标识上传任务的唯一性。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ id?: string | undefined; /** * 上传文件的服务器地址 * 调用plus.uploader.createUpload()方法创建上传任务时设置的值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ url?: string | undefined; /** * 任务的状态 * 上传任务的状态,参考UploadState,在UploadCompleteCallback事件和UploadStateChangedCallback事件触发时更新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ state?: number | undefined; /** * 上传任务的参数 * 上传任务配置的参数,参考UploadOptions。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ options?: PlusUploaderUploadOptions | undefined; /** * 上传任务完成后服务器返回的数据 * 表示当前上传任务的状态,可通过addEventListener()方法监听statechanged事件监听任务状态的变化。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ responseText?: string | undefined; /** * 已完成上传数据的大小) * 整数类型,单位为字节(byte),上传任务开始传输数据时,每次触发statechanged事件或上传任务完成更新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ uploadedSize?: number | undefined; /** * 上传数据的总大小 * 整数类型,单位为字节(byte),上传任务开始传输数据时更新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ totalSize?: number | undefined; @@ -7853,7 +8082,7 @@ interface PlusUploaderUpload { * 1. options参数中指定的key在任务中已经存在,则添加失败返回false; * 2. path参数指定的文件路径不合法或文件不存在,则添加失败返回false; * 3. 上传任务已经开始调度,调用此方法则添加失败返回false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ addFile(path?: string, options?: PlusUploaderUploadFileOptions): boolean; @@ -7863,7 +8092,7 @@ interface PlusUploaderUpload { * 以下情况会导致添加上传文件失败: * 1. key参数中指定的键名在任务中已经存在,则添加失败返回false; * 2. 上传任务已经开始调度,调用此方法则添加失败返回false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ addData(key?: string, value?: string): boolean; @@ -7871,42 +8100,46 @@ interface PlusUploaderUpload { * 开始上传任务 * 开始调度上传任务,如果任务已经处于开始状态则无任何响应。 * 在创建任务或任务上传失败后调用可重新开始上传。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ start(): void; /** * 暂停上传任务 * 暂停上传任务,如果任务已经处于初始状态或暂停状态则无任何响应。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ pause(): void; /** * 恢复暂停的上传任务 * 继续暂停的上传任务,如果任务处于非暂停状态则无任何响应。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ resume(): void; /** * 取消上传任务 * 如果任务未完成,则终止上传,并从任务列表中删除。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ abort(): void; /** * 添加上传任务事件监听器 * 上传任务添加事件监听器后,当监听的事件发生时触发listener回调。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ - addEventListener(type?: string, listener?: (result0: PlusUploaderUpload, result1: number) => void, capture?: boolean): void; + addEventListener( + type?: string, + listener?: (result0: PlusUploaderUpload, result1: number) => void, + capture?: boolean, + ): void; /** * 获取上传请求HTTP响应头部信息 * HTTP响应头部全部内容作为未解析的字符串返回,如果没有接收到这个HTTP响应头数据或者上传请求未完成则为空字符串。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ getAllResponseHeaders(): string; @@ -7914,7 +8147,7 @@ interface PlusUploaderUpload { * 获取上传请求指定的HTTP响应头部的值 * 其参数是要返回的HTTP响应头部的名称,可以使用任何大小写来制定这个头部名字,和响应头部的比较是不区分大小写的。 * 如果没有接收到这个头部或者伤处请求未完成则为空字符串;如果接收到多个有指定名称的头部,这个头部的值被连接起来并返回,使用逗号和空格分隔开各个头部的值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ getResponseHeader(headerName?: string): string; @@ -7922,7 +8155,7 @@ interface PlusUploaderUpload { * 设置上传请求的HTTP头数据 * Http的Header应该包含在通过后续start()调用而发起的请求中,此方法必需在调用start()之前设置才能生效。 * 如果带有指定名称的头部已经被指定了,这个头部的新值就是:之前指定的值,加上逗号、以及这个调用指定的值(形成一个数组)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ setRequestHeader(headerName?: string, headerValue?: string): void; @@ -7930,14 +8163,14 @@ interface PlusUploaderUpload { /** * 上传任务事件类型 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ interface PlusUploaderUploadEvent { /** * 上传任务状态变化事件 * 当上传任务状态发生变化时触发此事件,事件原型参考UploadStateChangedCallback。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ statechanged?: string | undefined; @@ -7945,35 +8178,35 @@ interface PlusUploaderUploadEvent { /** * 上传任务的状态,Number类型 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ type PlusUploaderUploadState = undefined | 0 | 1 | 2 | 3 | 4 | 5 | -1; /** * JSON对象,创建上传任务的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ interface PlusUploaderUploadOptions { /** * 网络请求类型 * 仅支持http协议的“POST”请求。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ method?: string | undefined; /** * 上传任务每次上传的文件块大小(仅在支持断点续传的服务有效) * 数值类型,单位为Byte(字节),默认值为102400,若设置值小于等于0则表示不分块上传。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ blocksize?: number | undefined; /** * 上传任务的优先级 * 数值类型,数值越大优先级越高,默认优先级值为0。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ priority?: number | undefined; @@ -7981,21 +8214,21 @@ interface PlusUploaderUploadOptions { * 上传任务超时时间 * 数值类型,单位为s(秒),默认值为120s。 * 超时时间为服务器响应请求的时间(不是上传任务完成的总时间),如果设置为0则表示永远不超时。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ timeout?: number | undefined; /** * 上传任务重试次数 * 数值类型,默认为重试3次。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ retry?: number | undefined; /** * 上传任务重试间隔时间 * 数值类型,单位为s(秒),默认值为30s。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ retryInterval?: number | undefined; @@ -8003,7 +8236,7 @@ interface PlusUploaderUploadOptions { /** * JSON对象,添加上传文件的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ interface PlusUploaderUploadFileOptions { @@ -8011,21 +8244,21 @@ interface PlusUploaderUploadFileOptions { * 文件键名 * 上传文件在上传任务中的键名,默认值为为文件名称。 * 上传任务中如果已经存在相同key的上传文件或数据将导致添加文件失败。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ key?: string | undefined; /** * 文件名称 * 上传文件的名称,默认值为上传文件路径中的名称。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ name?: string | undefined; /** * 文件类型 * 上传文件的类型(如图片文件为“image/jpeg”),默认值自动根据文件后缀名称生成。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/uploader.html](http://www.html5plus.org/doc/zh_cn/uploader.html) */ mime?: string | undefined; @@ -8033,45 +8266,45 @@ interface PlusUploaderUploadFileOptions { /** * Video模块管理多媒体视频相关能力,可用创建视频播放控件,直播推流控件等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ interface PlusVideo { /** * 视频播放控件对象 * VideoPlayer对象表示视频播放控件对象,在窗口中播放视频,可支持本地视频(mp4/flv),网络视频地址(mp4/flv/m3u8)及流媒体(rtmp/hls/rtsp)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ VideoPlayer?: PlusVideoVideoPlayer | undefined; /** * 视频播放控件参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ VideoPlayerStyles?: PlusVideoVideoPlayerStyles | undefined; /** * 视频播放控件事件类型 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ VideoPlayerEvents?: PlusVideoVideoPlayerEvents | undefined; /** * 直播推流控件对象 * LivePusher对象表示直播推流控件对象,在窗口中显示捕获视频,实时推送到流媒体(RTMP)服务器。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ LivePusher?: PlusVideoLivePusher | undefined; /** * 直播推流控件配置选项 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ LivePusherStyles?: PlusVideoLivePusherStyles | undefined; /** * 直播推流控件事件类型 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ LivePusherEvents?: PlusVideoLivePusherEvents | undefined; @@ -8079,7 +8312,7 @@ interface PlusVideo { * 创建VideoPlayer对象 * 调用此方法创建后并不会显示,需要调用Webview窗口的append方法将其添加到Webview窗口后才能显示。 * 注意:此时需要通过styles参数的top/left/width/height属性设置控件的位置及大小。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ createVideoPlayer(id?: string, styles?: PlusVideoVideoPlayerStyles): PlusVideoVideoPlayer; @@ -8087,21 +8320,21 @@ interface PlusVideo { * 创建LivePusher对象 * 调用此方法创建后并不会显示,需要调用Webview窗口的append方法将其添加到Webview窗口后才能显示。 * 注意:此时需要通过styles参数的top/left/width/height属性设置控件的位置及大小。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ createLivePusher(id?: string, styles?: PlusVideoLivePusherStyles): PlusVideoLivePusher; /** * 查找已经创建的VideoPlayer对象 * 查找指定id的VideoPlayer对象,如果不存在则返回null。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ getVideoPlayerById(id?: string): PlusVideoVideoPlayer; /** * 查找已经创建的LivePusher对象 * 查找指定id的LivePusher对象,如果不存在则返回null。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ getLivePusherById(id?: string): PlusVideoLivePusher; @@ -8110,15 +8343,15 @@ interface PlusVideo { /** * 视频播放控件对象 * VideoPlayer对象表示视频播放控件对象,在窗口中播放视频,可支持本地视频(mp4/flv),网络视频地址(mp4/flv/m3u8)及流媒体(rtmp/hls/rtsp)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ interface PlusVideoVideoPlayer { /** * 监听视频播放控件事件 - * 向视频播放控件添加事件监听器,当指定的事件发生时,将触发listener函数的执行。 + * 向视频播放控件添加事件监听器,当指定的事件发生时,将触发listener函数的执行。 * 可多次调用此方法向视频播放控件添加多个监听器,当监听的事件发生时,将按照添加的先后顺序执行。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ addEventListener(event?: PlusVideoVideoPlayerEvents, listener?: (result: any) => void, capture?: boolean): void; @@ -8126,7 +8359,7 @@ interface PlusVideoVideoPlayer { * 设置视频播放控件参数 * 用于动态更新视频播放控件的配置参数。 * 注意:有些选项无法动态更新,只能创建时进行设置,详情参考VideoPlayerStyles。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ setStyles(styles?: PlusVideoVideoPlayerStyles): void; @@ -8134,47 +8367,47 @@ interface PlusVideoVideoPlayer { * 设置视频播放控件参数(将废弃,使用setStyles) * 用于动态更新视频播放控件的配置选项。 * 注意:有些选项无法动态更新,只能创建时进行设置,详情参考VideoPlayerStyles。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ setOptions(options?: PlusVideoVideoPlayerStyles): void; /** * 播放视频 * 如果视频已经处于播放状态,则操作无效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ play(): void; /** * 暂停视频 * 如果视频未处于播放状态,则操作无效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ pause(): void; /** * 跳转到指定位置 * 如果视频未处于播放状态,则操作无效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ seek(position?: number): void; /** * 切换到全屏 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ requestFullScreen(direction?: number): void; /** * 退出全屏 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ exitFullScreen(): void; /** * 停止播放视频 * 如果视频未处于播放或暂停状态,则操作无效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ stop(): void; @@ -8182,7 +8415,7 @@ interface PlusVideoVideoPlayer { * 隐藏视频播放控件 * 隐藏只是控件不可见,控件依然存在并且不改变播放状态。 * 如果控件已经隐藏,则操作无效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ hide(): void; @@ -8190,27 +8423,27 @@ interface PlusVideoVideoPlayer { * 显示视频播放控件 * 将隐藏的控件显示出来(回复到隐藏前的状态)。 * 如果控件已经显示,则操作无效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ show(): void; /** * 关闭视频播放控件 * 关闭操作将释放控件所有资源,不再可用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ close(): void; /** * 发送弹幕 * 如果视频未处于播放状态,则操作无效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ sendDanmu(danmu?: any): void; /** * 设置倍速播放 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ playbackRate(rate?: number): void; @@ -8218,14 +8451,14 @@ interface PlusVideoVideoPlayer { /** * 视频播放控件参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ interface PlusVideoVideoPlayerStyles { /** * 视频资源地址 * 支持本地地址,也支持网络地址及直播流(RTMP)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ src?: string | undefined; @@ -8233,15 +8466,15 @@ interface PlusVideoVideoPlayerStyles { * 视频初始播放位置 * 单位为秒(s)。 * 注意:仅在视频开始播放前设置有效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ - 'initial-time'?: number | undefined; + "initial-time"?: number | undefined; /** * 视频长度 * 单位为秒(s)。 * 注意:仅在视频开始播放前设置有效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ duration?: number | undefined; @@ -8249,51 +8482,51 @@ interface PlusVideoVideoPlayerStyles { * 是否显示默认播放控件 * 默认值为true。 * 包括播放/暂停按钮、播放进度、时间等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ controls?: boolean | undefined; /** * 弹幕列表 * 弹幕JSON对象包括属性:text(String类型,弹幕文本类容),color(String类型,弹幕颜色,格式为#RRGGBB),time(Number类型,弹幕出现的时间,单位为秒)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ - 'danmu-list'?: any [] | undefined; + "danmu-list"?: any[] | undefined; /** * 是否显示弹幕按钮 * 默认值为false。 * 注意:仅在控件构造时设置有效,不能动态更新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ - 'danmu-btn'?: boolean | undefined; + "danmu-btn"?: boolean | undefined; /** * 是否展示弹幕 * 默认值为false。 * 注意:仅在控件构造时设置有效,不能动态更新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ - 'enable-danmu'?: boolean | undefined; + "enable-danmu"?: boolean | undefined; /** * 是否自动播放 * 默认值为false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ autoplay?: boolean | undefined; /** * 是否循环播放 * 默认值为false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ loop?: boolean | undefined; /** * 是否静音播放 * 默认值为false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ muted?: boolean | undefined; @@ -8302,58 +8535,58 @@ interface PlusVideoVideoPlayerStyles { * 不指定则根据宽高比自动判断。 * 有效值为: 0(正常竖向), 90(屏幕逆时针90度), -90(屏幕顺时针90度)。 * 默认值为-90。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ direction?: number | undefined; /** * 是否显示播放进度 * 默认值为true。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ - 'show-progress'?: boolean | undefined; + "show-progress"?: boolean | undefined; /** * 是否显示全屏按钮 * 默认值为true。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ - 'show-fullscreen-btn'?: boolean | undefined; + "show-fullscreen-btn"?: boolean | undefined; /** * 是否显示视频底部控制栏的播放按钮 * 默认值为true。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ - 'show-play-btn'?: boolean | undefined; + "show-play-btn"?: boolean | undefined; /** * 是否显示视频中间的播放按钮 * 默认值为true。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ - 'show-center-play-btn'?: boolean | undefined; + "show-center-play-btn"?: boolean | undefined; /** * 是否开启控制进度的手势 * 默认值为true。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ - 'enable-progress-gesture'?: boolean | undefined; + "enable-progress-gesture"?: boolean | undefined; /** * 当视频大小与 video 容器大小不一致时,视频的表现形式 * 有效值为:contain(包含),fill(填充),cover(覆盖)。 * 默认值为contain。 * 仅Android平台支持。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ objectFit?: string | undefined; /** * 视频封面的图片网络资源地址 * 如果 controls 属性值为 false 则设置 poster 无效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ poster?: string | undefined; @@ -8363,7 +8596,7 @@ interface PlusVideoVideoPlayerStyles { * 像素值,如"100px"; * 百分比,如"10%",相对于父Webview窗口的高度; * 自动计算,如"auto",根据height值自动计算,相对于父Webview窗口垂直居中。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ top?: string | undefined; @@ -8374,7 +8607,7 @@ interface PlusVideoVideoPlayerStyles { * 百分比,如"10%",相对于父Webview窗口的宽度; * 自动计算,如"auto",根据width值自动计算,相对于父Webview窗口水平居中。 * 默认值为"0px"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ left?: string | undefined; @@ -8384,7 +8617,7 @@ interface PlusVideoVideoPlayerStyles { * 像素值,如"100px"; * 百分比,如"10%",相对于父Webview窗口的宽度。 * 默认值为"100%"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ width?: string | undefined; @@ -8394,7 +8627,7 @@ interface PlusVideoVideoPlayerStyles { * 像素值,如"100px"; * 百分比,如"10%",相对于父Webview窗口的高度。 * 默认值为"100%"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ height?: string | undefined; @@ -8404,7 +8637,7 @@ interface PlusVideoVideoPlayerStyles { * "static" - 静态布局模式,如果页面存在滚动条则随窗口内容滚动; * "absolute" - 绝对布局模式,如果页面存在滚动条不随窗口内容滚动; * 默认值为"static"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ position?: string | undefined; @@ -8412,7 +8645,7 @@ interface PlusVideoVideoPlayerStyles { /** * 视频播放控件事件类型 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ interface PlusVideoVideoPlayerEvents { @@ -8420,7 +8653,7 @@ interface PlusVideoVideoPlayerEvents { * 视频播放事件 * 当视频开始/继续播放时触发。 * 无事件回调函数参数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ play?: string | undefined; @@ -8428,7 +8661,7 @@ interface PlusVideoVideoPlayerEvents { * 视频暂停事件 * 当视频暂停播放时触发。 * 无事件回调函数参数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ pause?: string | undefined; @@ -8436,7 +8669,7 @@ interface PlusVideoVideoPlayerEvents { * 视频结束事件 * 当视频播放到末尾时触发。 * 无事件回调函数参数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ ended?: string | undefined; @@ -8444,7 +8677,7 @@ interface PlusVideoVideoPlayerEvents { * 视频播放进度更新事件 * 当视频播放进度变化时触发,触发频率250ms一次。 * 事件回调函数参数event.detail = {currentTime:"Number类型,当前播放时间(单位为秒)",duration:"Number类型,视频总长度(单位为秒)"}。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ timeupdate?: string | undefined; @@ -8452,7 +8685,7 @@ interface PlusVideoVideoPlayerEvents { * 视频播放全屏播放状态变化事件 * 当视频播放进入或退出全屏时触发。 * 事件回调函数参数event.detail = {fullScreen:"Boolean类型,当前状态是否为全屏", direction:"String类型,vertical或horizontal"}。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ fullscreenchange?: string | undefined; @@ -8460,7 +8693,7 @@ interface PlusVideoVideoPlayerEvents { * 视频缓冲事件 * 当视频播放出现缓冲时触发。 * 无事件回调函数参数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ waiting?: string | undefined; @@ -8468,7 +8701,7 @@ interface PlusVideoVideoPlayerEvents { * 视频错误事件 * 当视频播放出错时触发。 * 无事件回调函数参数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ error?: string | undefined; @@ -8477,15 +8710,15 @@ interface PlusVideoVideoPlayerEvents { /** * 直播推流控件对象 * LivePusher对象表示直播推流控件对象,在窗口中显示捕获视频,实时推送到流媒体(RTMP)服务器。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ interface PlusVideoLivePusher { /** * 监听直播推流控件事件 - * 向直播推流控件添加事件监听器,当指定的事件发生时,将触发listener函数的执行。 + * 向直播推流控件添加事件监听器,当指定的事件发生时,将触发listener函数的执行。 * 可多次调用此方法向直播推流控件添加多个监听器,当监听的事件发生时,将按照添加的先后顺序执行。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ addEventListener(event?: PlusVideoLivePusherEvents, listener?: (result: any) => void, capture?: boolean): void; @@ -8493,7 +8726,7 @@ interface PlusVideoLivePusher { * 设置直播推流控件参数 * 用于动态更新直播推流控件的配置参数。 * 注意:有些选项无法动态更新,只能创建时进行设置,详情参考LivePusherStyles。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ setStyles(styles?: PlusVideoLivePusherStyles): void; @@ -8501,7 +8734,7 @@ interface PlusVideoLivePusher { * 设置直播推流控件参数(将废弃,使用setStyles) * 用于动态更新直播推流控件的配置选项。 * 注意:有些选项无法动态更新,只能创建时进行设置,详情参考LivePusherStyles。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ setOptions(options?: PlusVideoLivePusherStyles): void; @@ -8509,54 +8742,54 @@ interface PlusVideoLivePusher { * 预览摄像头采集数据 * 调用摄像头采集图像数据,并在推流控件中预览(此时不会向服务器推流,需调用start方法才开始推流)。 * 注意:为了确保预览窗口大小正确,应该在创建控件后延时一定的时间(如500ms)进行预览。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ preview(): void; /** * 开始推流 * 如果已经处于推流状态,则操作无效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ start(successCB?: () => void, errorCB?: () => void): void; /** * 停止推流 * 如果未处于推流状态,则操作无效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ stop(options?: any): void; /** * 暂停推流 * 如果未处于推流状态,则操作无效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ pause(): void; /** * 恢复推流 * 如果未处于暂停状态,则操作无效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ resume(): void; /** * 切换前后摄像头 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ switchCamera(): void; /** * 快照 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ snapshot(successCB?: () => void, errorCB?: () => void): void; /** * 关闭直播推流控件 * 关闭操作将释放控件所有资源,不再可用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ close(): void; @@ -8564,50 +8797,50 @@ interface PlusVideoLivePusher { /** * 直播推流控件配置选项 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ interface PlusVideoLivePusherStyles { /** * 推流地址 * 支持RTMP协议。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ url?: string | undefined; /** * 推流视频模式 * 可取值:SD(标清), HD(高清), FHD(超清)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ mode?: string | undefined; /** * 是否静音 * 默认值为false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ muted?: boolean | undefined; /** * 开启摄像头 * 默认值为true。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ - 'enable-camera'?: boolean | undefined; + "enable-camera"?: boolean | undefined; /** * 自动聚集 * 默认值为true。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ - 'auto-focus'?: boolean | undefined; + "auto-focus"?: boolean | undefined; /** * 是否美颜 * 可取值0、1,其中0表示不使用美颜,1表示不使用美颜。 * 默认值为0(不使用美颜)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ beauty?: number | undefined; @@ -8615,14 +8848,14 @@ interface PlusVideoLivePusherStyles { * 是否美白 * 可取值0、1、2、3、4、5,其中0表示不使用美白,其余值分别表示美白的程度,值越大美白程度越大。 * 默认值为0(不使用美白)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ whiteness?: number | undefined; /** * 宽高比 * 可取值:3:4, 9:16。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ aspect?: string | undefined; @@ -8632,7 +8865,7 @@ interface PlusVideoLivePusherStyles { * 像素值,如"100px"; * 百分比,如"10%",相对于父Webview窗口的高度; * 自动计算,如"auto",根据height值自动计算,相对于父Webview窗口垂直居中。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ top?: string | undefined; @@ -8643,7 +8876,7 @@ interface PlusVideoLivePusherStyles { * 百分比,如"10%",相对于父Webview窗口的宽度; * 自动计算,如"auto",根据width值自动计算,相对于父Webview窗口水平居中。 * 默认值为"0px"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ left?: string | undefined; @@ -8653,7 +8886,7 @@ interface PlusVideoLivePusherStyles { * 像素值,如"100px"; * 百分比,如"10%",相对于父Webview窗口的宽度。 * 默认值为"100%"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ width?: string | undefined; @@ -8663,7 +8896,7 @@ interface PlusVideoLivePusherStyles { * 像素值,如"100px"; * 百分比,如"10%",相对于父Webview窗口的高度。 * 默认值为"100%"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ height?: string | undefined; @@ -8673,7 +8906,7 @@ interface PlusVideoLivePusherStyles { * "static" - 静态布局模式,如果页面存在滚动条则随窗口内容滚动; * "absolute" - 绝对布局模式,如果页面存在滚动条不随窗口内容滚动; * 默认值为"static"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ position?: string | undefined; @@ -8681,7 +8914,7 @@ interface PlusVideoLivePusherStyles { /** * 直播推流控件事件类型 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ interface PlusVideoLivePusherEvents { @@ -8721,7 +8954,7 @@ interface PlusVideoLivePusherEvents { * 3003 - RTMP服务器握手失败; * 3004 - RTMP服务器主动断开,请检查推流地址的合法性或防盗链有效期; * 3005 - RTMP 读/写失败。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ statechange?: string | undefined; @@ -8729,7 +8962,7 @@ interface PlusVideoLivePusherEvents { * 网络状态通知事件 * 当推流的网络状态发生变化时触发。 * 事件回调函数参数event={type:"事件类型,此时为netstatus",target:"触发此事件的直播推流控件对象",detail:{videoBitrate:"视频码率",audioBitrate:"音频码率",videoFPS:"视频帧率",netSpeed:"推流网速",videoWidth:"视频宽度",videoHeight:"视频高度"}}。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ netstatus?: string | undefined; @@ -8740,7 +8973,7 @@ interface PlusVideoLivePusherEvents { * 其中code错误码: * 1001 - 用户禁止使用摄像头; * 1002 - 用户禁止使用录音。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/video.html](http://www.html5plus.org/doc/zh_cn/video.html) */ error?: string | undefined; @@ -8748,109 +8981,109 @@ interface PlusVideoLivePusherEvents { /** * Webview模块管理应用窗口界面,实现多窗口的逻辑控制管理操作。通过plus.webview可获取应用界面管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebview { /** * 一组用于定义页面或控件显示动画效果 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ AnimationTypeShow?: PlusWebviewAnimationTypeShow | undefined; /** * 一组用于定义页面或控件关闭的动画效果 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ AnimationTypeClose?: PlusWebviewAnimationTypeClose | undefined; /** * Webview窗口对象,用于操作加载HTML页面的窗口 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewObject?: PlusWebviewWebviewObject | undefined; /** * Webview窗口动画参数 * 用于指定动画目标窗口,起始位置、目标位置等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewAnimationOptions?: PlusWebviewWebviewAnimationOptions | undefined; /** * Webview窗口动画样式 * 用于指定动画窗口的起始位置、目标位置等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewAnimationStyles?: PlusWebviewWebviewAnimationStyles | undefined; /** * Webview窗口回弹样式 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewBounceStyle?: PlusWebviewWebviewBounceStyle | undefined; /** * Webview窗口内容动画参数 * 指定动画的类型、持续时间等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewContentAnimationOptions?: PlusWebviewWebviewContentAnimationOptions | undefined; /** * 原生控件在窗口中停靠的方式 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewDock?: PlusWebviewWebviewDock | undefined; /** * Webview窗口滑动事件数据 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewDragEvent?: PlusWebviewWebviewDragEvent | undefined; /** * 窗口手势操作参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewDragOptions?: PlusWebviewWebviewDragOptions | undefined; /** * 手势操作关联对象参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewDragOtherViewOptions?: PlusWebviewWebviewDragOtherViewOptions | undefined; /** * 截屏绘制操作参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewDrawOptions?: PlusWebviewWebviewDrawOptions | undefined; /** * 窗口收藏参数 * 在流应用环境中调用收藏功能时使用的参数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewFavoriteOptions?: PlusWebviewWebviewFavoriteOptions | undefined; /** * 创建加载HTML数据参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewLoadDataOptions?: PlusWebviewWebviewLoadDataOptions | undefined; /** * 窗口的分享参数 * 在流应用环境中调用分享功能时使用的参数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewShareOptions?: PlusWebviewWebviewShareOptions | undefined; /** * 窗口原生子View控件样式 * 可设置原生控件的标识、大小、位置以及绘制的内容等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewSubNViewStyles?: PlusWebviewWebviewSubNViewStyles | undefined; @@ -8858,107 +9091,107 @@ interface PlusWebview { * 窗口标题栏控件样式 * 标题栏控件固定高度为44px,可通过Webview窗口对象的getTitleNView方法获取标题栏原生控件对象动态绘制内容。 * 可以通过WebviewObject对象的getTitleNView()获取标题栏的NView对象,然后调用其setStyle方法更新样式。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewTitleNViewStyles?: PlusWebviewWebviewTitleNViewStyles | undefined; /** * 窗口标题栏自定义按钮样式 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewTitleNViewButtonStyles?: PlusWebviewWebviewTitleNViewButtonStyles | undefined; /** * 标题栏控件的进度条样式 * 显示在标题栏控件底部。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewProgressStyles?: PlusWebviewWebviewProgressStyles | undefined; /** * 窗口标题栏控件的分割线样式 * 显示在标题栏控件底部。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewSplitLineStyles?: PlusWebviewWebviewSplitLineStyles | undefined; /** * Webview窗口事件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewEvent?: PlusWebviewWebviewEvent | undefined; /** * JSON对象,原生窗口扩展参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewExtraOptions?: PlusWebviewWebviewExtraOptions | undefined; /** * 原生控件在窗口中显示的位置 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewPosition?: PlusWebviewWebviewPosition | undefined; /** * Webview窗口下拉刷新样式 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewPullToRefreshStyles?: PlusWebviewWebviewPullToRefreshStyles | undefined; /** * Webview窗口rendered事件参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewRenderedEventOptions?: PlusWebviewWebviewRenderedEventOptions | undefined; /** * 替换H5标准API配置信息 * 目前仅支持替换H5标准定位接口 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewReplaceWebApiOptions?: PlusWebviewWebviewReplaceWebApiOptions | undefined; /** * JSON对象,Webview窗口的系统状态栏区域样式 * 仅在应用设置为沉浸式状态栏样式下有效,非沉浸式状态栏样式下忽略此属性。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewStatusbarStyles?: PlusWebviewWebviewStatusbarStyles | undefined; /** * JSON对象,Webview窗口对象的样式 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewStyles?: PlusWebviewWebviewStyles | undefined; /** * 一组用于定义页面或控件变形的属性 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewTransform?: PlusWebviewWebviewTransform | undefined; /** * 一组用于定义页面或控件转换效果的属性 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewTransition?: PlusWebviewWebviewTransition | undefined; /** * 拦截Webview窗口资源请求的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewOverrideResourceOptions?: PlusWebviewWebviewOverrideResourceOptions | undefined; /** * 拦截Webview窗口URL请求的属性 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewOverrideUrlOptions?: PlusWebviewWebviewOverrideUrlOptions | undefined; /** * 监听Webview窗口资源加载的属性 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ WebviewListenResourceOptions?: PlusWebviewWebviewListenResourceOptions | undefined; @@ -8966,86 +9199,93 @@ interface PlusWebview { * 获取所有Webview窗口 * 获取应用中已创建的所有Webview窗口,包括所有未显示的Webview窗口。 * 返回WebviewObject对象在数组中按创建的先后顺序排列,即数组中第一个WebviewObject对象用是加载应用的入口页面。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - all(): PlusWebview []; + all(): PlusWebview[]; /** * 关闭Webview窗口 * 关闭已经打开的Webview窗口,需先获取窗口对象或窗口id,并可指定关闭窗口的动画及动画持续时间。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ close(id_wvobj?: string, aniClose?: string, duration?: number, extras?: PlusWebviewWebviewExtraOptions): void; /** * 创建新的Webview窗口 * 创建Webview窗口,用于加载新的HTML页面,可通过styles设置Webview窗口的样式,创建完成后需要调用show方法才能将Webview窗口显示出来。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ create(url?: string, id?: string, styles?: PlusWebviewWebviewStyles, extras?: any): PlusWebviewWebviewObject; /** * 获取当前窗口的WebviewObject对象 * 获取当前页面所属的Webview窗口对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ currentWebview(): PlusWebviewWebviewObject; /** * 获取屏幕所有可视的Webview窗口 * 仅在屏幕区域显示的Webview窗口,如果Webview窗口显示了但被其它Webview窗口盖住则认为不可视。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - getDisplayWebview(): PlusWebview []; + getDisplayWebview(): PlusWebview[]; /** * 查找指定标识的WebviewObject窗口 * 在已创建的窗口列表中查找指定标识的Webview窗口并返回。 * 若没有查找到指定标识的窗口则返回null,若存在多个相同标识的Webview窗口,则返回第一个创建的Webview窗口。 * 如果要获取应用入口页面所属的Webview窗口,其标识为应用的%APPID%,可通过plus.runtime.appid获取。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ getWebviewById(id?: string): PlusWebviewWebviewObject; /** * 获取应用首页WebviewObject窗口对象 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ getLaunchWebview(): PlusWebviewWebviewObject; /** * 获取应用第二个首页WebviewObject窗口对象 * 在双首页模式下(在manifest.json的plus->secondwebview节点下配置),应用会自动创建两个首页Webview,通过getLaunchWebview()可获取第一个首页窗口对象,通过getSecondWebview()可获取第二个首页窗口对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ getSecondWebview(): PlusWebviewWebviewObject; /** * 获取应用显示栈顶的WebviewObject窗口对象 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ getTopWebview(): PlusWebviewWebviewObject; /** * 隐藏Webview窗口 * 根据指定的WebviewObject对象或id隐藏Webview窗口,使得窗口不可见。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ hide(id_wvobj?: string, aniHide?: string, duration?: number, extras?: PlusWebviewWebviewExtraOptions): void; /** * 创建并打开Webview窗口 * 创建并显示Webview窗口,用于加载新的HTML页面,可通过styles设置Webview窗口的样式,创建完成后自动将Webview窗口显示出来。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - open(url?: string, id?: string, styles?: PlusWebviewWebviewStyles, aniShow?: string, duration?: number, showedCB?: () => void): PlusWebviewWebviewObject; + open( + url?: string, + id?: string, + styles?: PlusWebviewWebviewStyles, + aniShow?: string, + duration?: number, + showedCB?: () => void, + ): PlusWebviewWebviewObject; /** * 预载网络页面 * 预载网络页面会向服务器发起http/https请求获取html页面内容, * 待Webview窗口加载此url页面时会则根据缓存机制优先使用预载的页面内容(加快页面显示速度)。 * 注意:预载网络页面仅在运行期生效,为了节省内存仅保留最后5个预载页面数据。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ prefetchURL(url?: string): void; @@ -9054,30 +9294,40 @@ interface PlusWebview { * 预载网络页面会向服务器发起http/https请求获取html页面内容, * 待Webview窗口加载此url页面时会则根据缓存机制优先使用预载的页面内容(加快页面显示速度)。 * 注意:预载网络页面仅在运行期生效,为了节省内存仅保留最后5个预载页面数据。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - prefetchURLs(urls?: any []): void; + prefetchURLs(urls?: any[]): void; /** * 显示Webview窗口 * 显示已创建或隐藏的Webview窗口,需先获取窗口对象或窗口id,并可指定显示窗口的动画及动画持续时间。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - show(id_wvobj?: string, aniShow?: string, duration?: number, showedCB?: () => void, extras?: PlusWebviewWebviewExtraOptions): PlusWebviewWebviewObject; + show( + id_wvobj?: string, + aniShow?: string, + duration?: number, + showedCB?: () => void, + extras?: PlusWebviewWebviewExtraOptions, + ): PlusWebviewWebviewObject; /** * Webview窗口组合动画 * 同步组合两个Webview窗口动画,动画完成后窗口的位置会发生变化,一次需要在动画属性参数中设置动画起始位置、结束位置等。 * 注意:此动画操作会改变窗口位置(如left值等),再次调用show方法时需要确保其位置是否在可视区域,如果不在可视区域则需要调用窗口的setStyle方法设置其位置到可视区域内,如setStyle({left:'0px'});。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - startAnimation(options?: PlusWebviewWebviewAnimationOptions, otherOptions?: PlusWebviewWebviewAnimationOptions, callback?: (result: any) => void): void; + startAnimation( + options?: PlusWebviewWebviewAnimationOptions, + otherOptions?: PlusWebviewWebviewAnimationOptions, + callback?: (result: any) => void, + ): void; /** * 获取Webview默认是否开启硬件加速 * 由于不同设备对硬件加速的支持情况存在差异,开启硬件加速能加速HTML页面的渲染,但也会消耗更多的系统资源,从而导致在部分设备上可能出现闪屏、发虚、分块渲染等问题, 因此5+ Runtime会根据设备实际支持情况自动选择是否开启硬件加速。 * 关闭硬件加速则可能会导致Webview页面无法支持Video标签播放视频等问题,如果在特定情况下需要调整修改默认开启硬件加速的行为,则可通过plus.webview.defaultHardwareAccelerated()方法获取当前设备默认是否开启硬件加速状态,从而决定是否需要显式开启或关闭指定Webview的硬件加速功能(通过WebviewStyles的hardwareAccelerated属性设置)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ defaultHardwareAccelerated(): boolean; @@ -9085,14 +9335,14 @@ interface PlusWebview { /** * 一组用于定义页面或控件显示动画效果 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewAnimationTypeShow { /** * 自动选择动画效果 * 自动选择动画效果,使用上次显示窗口设置的动画效果,如果是第一次显示则默认动画效果“none”。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ auto?: string | undefined; @@ -9101,7 +9351,7 @@ interface PlusWebviewAnimationTypeShow { * 立即显示页面,无任何动画效果,页面显示默认的动画效果。 * 此效果忽略动画时间参数,立即显示。 * 对应关闭动画"none"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ none?: string | undefined; @@ -9109,78 +9359,78 @@ interface PlusWebviewAnimationTypeShow { * 从右侧横向滑动效果 * 页面从屏幕右侧外向内横向滑动显示。 * 对应关闭动画"slide-out-right"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - 'slide-in-right'?: string | undefined; + "slide-in-right"?: string | undefined; /** * 从左侧横向滑动效果 * 页面从屏幕左侧向右横向滑动显示。 * 对应关闭动画"slide-out-left"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - 'slide-in-left'?: string | undefined; + "slide-in-left"?: string | undefined; /** * 从上侧竖向滑动效果 * 页面从屏幕上侧向下竖向滑动显示。 * 对应关闭动画"slide-out-top"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - 'slide-in-top'?: string | undefined; + "slide-in-top"?: string | undefined; /** * 从下侧竖向滑动效果 * 页面从屏幕下侧向上竖向滑动显示。 * 对应关闭动画"slide-out-bottom"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - 'slide-in-bottom'?: string | undefined; + "slide-in-bottom"?: string | undefined; /** * 从透明到不透明逐渐显示效果 * 页面从完全透明到不透明逐渐显示。 * 对应关闭动画"fade-out"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - 'fade-in'?: string | undefined; + "fade-in"?: string | undefined; /** * 从小到大逐渐放大显示效果 * 页面在屏幕中间从小到大逐渐放大显示。 * 对应关闭动画"zoom-in"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - 'zoom-out'?: string | undefined; + "zoom-out"?: string | undefined; /** * 从小到大逐渐放大并且从透明到不透明逐渐显示效果 * 页面在屏幕中间从小到大逐渐放大并且从透明到不透明逐渐显示。 * 对应关闭动画"zoom-fade-in"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - 'zoom-fade-out'?: string | undefined; + "zoom-fade-out"?: string | undefined; /** * 从右侧平移入栈动画效果 * 页面从屏幕右侧滑入显示,同时上一个页面带阴影效果从屏幕左侧滑出隐藏。 * 对应关闭动画"pop-out"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - 'pop-in'?: string | undefined; + "pop-in"?: string | undefined; } /** * 一组用于定义页面或控件关闭的动画效果 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewAnimationTypeClose { /** * 自动选择动画效果 * 自动选择显示窗口相对于的动画效果。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ auto?: string | undefined; @@ -9188,106 +9438,106 @@ interface PlusWebviewAnimationTypeClose { * 无动画 * 立即关闭页面,无任何动画效果。 * 此效果忽略动画时间参数,立即关闭。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ none?: string | undefined; /** * 横向向右侧滑出屏幕动画 * 页面从屏幕中横向向右侧滑动到屏幕外关闭。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - 'slide-out-right'?: string | undefined; + "slide-out-right"?: string | undefined; /** * 横向向左侧滑出屏幕动画 * 页面从屏幕中横向向左侧滑动到屏幕外关闭。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - 'slide-out-left'?: string | undefined; + "slide-out-left"?: string | undefined; /** * 竖向向上侧滑出屏幕动画 * 页面从屏幕中竖向向上侧滑动到屏幕外关闭。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - 'slide-out-top'?: string | undefined; + "slide-out-top"?: string | undefined; /** * 竖向向下侧滑出屏幕动画 * 页面从屏幕中竖向向下侧滑动到屏幕外关闭。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - 'slide-out-bottom'?: string | undefined; + "slide-out-bottom"?: string | undefined; /** * 从不透明到透明逐渐隐藏动画 * 页面从不透明到透明逐渐隐藏关闭。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - 'fade-out'?: string | undefined; + "fade-out"?: string | undefined; /** * 从大逐渐缩小关闭动画 * 页面逐渐向页面中心缩小关闭。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - 'zoom-in'?: string | undefined; + "zoom-in"?: string | undefined; /** * 从大逐渐缩小并且从不透明到透明逐渐隐藏关闭动画 * 页面逐渐向页面中心缩小并且从不透明到透明逐渐隐藏关闭。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - 'zoom-fade-in'?: string | undefined; + "zoom-fade-in"?: string | undefined; /** * 从右侧平移出栈动画效果 * 页面从屏幕右侧滑出消失,同时上一个页面带阴影效果从屏幕左侧滑入显示。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - 'pop-out'?: string | undefined; + "pop-out"?: string | undefined; } /** * Webview窗口对象,用于操作加载HTML页面的窗口 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewObject { /** * Webview窗口的标识 * 在打开或创建Webview窗口时设置,如果没有设置窗口标识,此属性值为undefined。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ id?: string | undefined; /** * Webview窗口关闭事件 * 当Webview窗口关闭时触发此事件,类型为EventCallback。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ onclose?: ((result: any) => void) | undefined; /** * Webview窗口错误事件 * 当Webview窗口加载错误时触发此事件,类型为EventCallback。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ onerror?: PlusWebviewWebviewEvent | undefined; /** * Webview窗口页面加载完成事件 * 当Webview窗口页面加载完成时触发此事件,类型为EventCallback。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ onloaded?: PlusWebviewWebviewEvent | undefined; /** * Webview窗口页面开始加载事件 * 当Webview窗口开始加载新页面时触发此事件,类型为EventCallback。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ onloading?: PlusWebviewWebviewEvent | undefined; @@ -9295,14 +9545,14 @@ interface PlusWebviewWebviewObject { * 添加事件监听器 * 向Webview窗口添加事件监听器,当指定的事件发生时,将触发listener函数的执行。 * 可多次调用此方法向Webview添加多个监听器,当监听的事件发生时,将按照添加的先后顺序执行。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ addEventListener(event?: PlusWebviewWebviewEvent, listener?: (result: any) => void, capture?: boolean): void; /** * 在Webview窗口中添加子窗口 * 将另一个Webview窗口作为子窗口添加到当前Webview窗口中,添加后其所有权归父Webview窗口,当父窗口关闭时子窗口自动关闭。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ append(webview?: PlusNativeObjView): void; @@ -9310,7 +9560,7 @@ interface PlusWebviewWebviewObject { * 添加Webview窗口预加载js文件 * 对于一些网络HTML页面,在无法修改HTML页面时可通过此方法自动加载本地js文件。 * 当Webview窗口跳转到新页面时也会自动加载指定的js执行,添加多个js文件将按照添加的先后顺序执行。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ appendJsFile(file?: string): void; @@ -9318,7 +9568,7 @@ interface PlusWebviewWebviewObject { * Webview窗口内容动画 * 动画后可能会导致Webview窗口显示内容改变,可通过调用restore方法恢复。 * 当Webview窗口内容动画引起内容不可见(透明),将显示此窗口后面的内容。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ animate(options?: PlusWebviewWebviewContentAnimationOptions, callback?: () => void): void; @@ -9326,7 +9576,7 @@ interface PlusWebviewWebviewObject { * 后退到上次加载的页面 * Webview窗口历史记录操作,后退到窗口上次加载的HTML页面。 * 如果窗口历史记录中没有可后退的页面则不触发任何操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ back(): void; @@ -9334,21 +9584,21 @@ interface PlusWebviewWebviewObject { * 开始Webview窗口的下拉刷新 * 开始触发下拉刷新效果,与用户操作下拉刷新行为一致(有动画效果)。 * 触发setPullTorefresh方法设置的下拉刷新事件回调。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ beginPullToRefresh(): void; /** * 查询Webview窗口是否可后退 * Webview窗口历史记录查询操作,获取Webview是否可后退到历史加载的页面,结果通过queryCallback回调方法返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ canBack(queryCallback?: (result: any) => void): void; /** * 查询Webview窗口是否可前进 * Webview窗口历史记录查询操作,获取Webview是否可前进到历史加载的页面,结果通过queryCallback回调方法返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ canForward(queryCallback?: (result: any) => void): void; @@ -9356,28 +9606,32 @@ interface PlusWebviewWebviewObject { * 检测Webview窗口是否渲染完成 * 检测方式为判断的Webview窗口内容是否为白屏,如果非白屏则认为渲染完成,否则认为渲染未完成。 * 通过successCallback回调函数返回结果,如果检测过程中发生错误则触发errorCallback回调函数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - checkRenderedContent(options?: PlusWebviewWebviewRenderedEventOptions, successCallback?: () => void, errorCallback?: (result: any) => void): void; + checkRenderedContent( + options?: PlusWebviewWebviewRenderedEventOptions, + successCallback?: () => void, + errorCallback?: (result: any) => void, + ): void; /** * 获取Webview窗口的所有子Webview窗口 * 获取添加到Webview窗口中的所有子Webview窗口,如果没有子Webview窗口则返回空数组。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - children(): PlusWebview []; + children(): PlusWebview[]; /** * 清空原生Webview窗口加载的内容 * 清除原生窗口的内容,用于重置原生窗口加载的内容,清除其加载的历史记录等内容。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ clear(): void; /** * 关闭Webview窗口 * 关闭并销毁Webview窗口,可设置关闭动画和动画持续时间。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ close(aniClose?: PlusWebviewAnimationTypeClose, duration?: number, extras?: PlusWebviewWebviewExtraOptions): void; @@ -9385,28 +9639,37 @@ interface PlusWebviewWebviewObject { * 设置Webview窗口的滑屏操作手势 * 将Webview窗口的左右滑动手势关联到其它Webview窗口,可实现滑动切换显示Webview的动画效果(如Tab页面切换效果)。 * 注意:滑屏操作会改变窗口位置(如left值等),如果不在可视区域则需要调用窗口的setStyle方法设置其位置到可视区域内,如setStyle({left:'0px'});。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - drag(options?: PlusWebviewWebviewDragOptions, otherView?: PlusWebviewWebviewDragOtherViewOptions, callback?: (result: PlusWebviewWebviewDragEvent) => void): void; + drag( + options?: PlusWebviewWebviewDragOptions, + otherView?: PlusWebviewWebviewDragOtherViewOptions, + callback?: (result: PlusWebviewWebviewDragEvent) => void, + ): void; /** * 截屏绘制 * 将Webview窗口的可视区域截屏并绘制到Bitmap图片对象中。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - draw(bitmap?: PlusNativeObjBitmap, successCallback?: () => void, errorCallback?: (result: any) => void, options?: PlusWebviewWebviewDrawOptions): void; + draw( + bitmap?: PlusNativeObjBitmap, + successCallback?: () => void, + errorCallback?: (result: any) => void, + options?: PlusWebviewWebviewDrawOptions, + ): void; /** * 结束Webview窗口的下拉刷新 * 关闭下拉刷新效果,恢复到开始下拉刷新之前的效果。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ endPullToRefresh(): void; /** * 在Webview窗口中执行JS脚本 * 将JS脚本发送到Webview窗口中运行,可用于实现Webview窗口间的数据通讯。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ evalJS(js?: string): void; @@ -9414,28 +9677,28 @@ interface PlusWebviewWebviewObject { * 前进到上次加载的页面 * Webview窗口历史记录操作,前进到窗口上次加载的HTML页面。 * 如果窗口历史记录中没有可前进的页面则不触发任何操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ forward(): void; /** * 获取Webview窗口的收藏参数 * 获取Webview窗口的收藏参数,如收藏页面的标题、图标、地址等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ getFavoriteOptions(): PlusWebviewWebviewFavoriteOptions; /** * 获取Webview窗口的分享参数 * 获取Webview窗口的分享参数,如分享的标题、图标、链接地址等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ getShareOptions(): PlusWebviewWebviewShareOptions; /** * 获取Webview窗口的样式 * 获取Webview窗口的样式属性,如窗口位置、大小等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ getStyle(): PlusWebviewWebviewStyles; @@ -9444,15 +9707,15 @@ interface PlusWebviewWebviewObject { * 创建Webview窗口的所有原生子View控件。 * 可以在创建窗口时设置其subNViews属性自动创建(应用首页可通过manfest.json中的plus->launchwebview->subNNViews节点配置创建); * 也可以通过Webview窗口的append方法将已经创建的原生View控件添加为其子。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - getSubNViews(): any []; + getSubNViews(): any[]; /** * 获取Webview窗口加载HTML页面的标题 * 标题为HTML页面head节点下title节点中的文本内容,当窗口内容发生页面内跳转时可通过窗口触发的“loaded”事件中调用此方法来获取跳转后页面的标题。 * 如果HTML页面没有使用title节点来设置标题,则返回空字符串。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ getTitle(): string; @@ -9460,28 +9723,28 @@ interface PlusWebviewWebviewObject { * 获取Webview窗口的标题栏控件对象 * 创建Webview窗口时设置其titleNView属性时则自动创建标题栏控件,应用首页可通过manfest.json中的plus->launchwebview->titleNView节点配置创建标题栏控件。 * 可通过此方法获取Webview窗口创建的标题栏控件,对象类型为plus.nativeObj.View,可通过调用其drawBitmap/drawRect/drawText方法绘制更新内容来实现自定义样式。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ getTitleNView(): PlusNativeObjView; /** * 获取Webview窗口加载HTML页面的地址 * 当窗口内容发生页面内跳转时可通过窗口触发的“loaded”事件中调用此方法来获取跳转后页面的地址。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ getURL(): string; /** * 隐藏Webview窗口 * 隐藏Webview窗口可保存已加载HTML页面的上下文数据,能降低应用使用的系统资源,通过show方法可将隐藏的Webview窗口显示出来。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ hide(aniHide?: PlusWebviewAnimationTypeClose, duration?: number, extras?: PlusWebviewWebviewExtraOptions): void; /** * 隐藏标题栏上按钮的红点 * 仅在窗口使用原生标题栏(titleNView)时生效,未显示原生标题栏时操作此接口无任何效果。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ hideTitleNViewButtonRedDot(index?: number): void; @@ -9489,21 +9752,21 @@ interface PlusWebviewWebviewObject { * 是否拦截Webview窗口的触屏事件 * 拦截后触屏事件不再传递,否则传递给View控件下的其它窗口处理。 * Webview窗口默认拦截所有触屏事件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interceptTouchEvent(intercept?: boolean): void; /** * 查询Webview窗口是否开启硬件加速 * 若Webview窗口已经开启硬件加速则返回true,否则返回false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ isHardwareAccelerated(): boolean; /** * 查询Webview窗口是否可见 * 若Webview窗口已经显示(调用过show方法,即使被其它窗口挡住了也认为已显示)则返回true,若Webview窗口被隐藏则返回false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ isVisible(): boolean; @@ -9511,21 +9774,21 @@ interface PlusWebviewWebviewObject { * 监听页面开始加载资源 * Webview加载资源时,如果满足options参数中定义的条件,则触发callback回调。 * 此方法仅触发回调事件,不会阻止资源的加载。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ listenResourceLoading(options?: PlusWebviewWebviewListenResourceOptions, callback?: (result: any) => void): void; /** * 加载新HTML数据 * 触发Webview窗口加载HTML页面数据,如果HTML数据无效将导致页面加载失败。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ loadData(data?: string, options?: PlusWebviewWebviewLoadDataOptions): void; /** * 加载新URL页面 * 触发Webview窗口从新的URL地址加载页面,如果url地址无效将导致页面显示失败。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ loadURL(url?: string, additionalHttpHeaders?: any): void; @@ -9533,21 +9796,21 @@ interface PlusWebviewWebviewObject { * 获取Webview窗口对象的原生(Native.JS)实例对象 * Android平台返回Webview窗口对象的android.webkit.Webview实例对象, * iOS平台返回Webview窗口对象的UIWebview实例对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ nativeInstanceObject(): PlusAndroidInstanceObject | PlusIosInstanceObject; /** * 获取在当前Webview窗口中创建的所有窗口 * 返回从当前Webview中调用plus.webview.open或plus.webview.create创建的所有Webview窗口数组。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - opened(): PlusWebview []; + opened(): PlusWebview[]; /** * 获取当前Webview窗口的创建者 * 创建者为调用plus.webview.open或plus.webview.create方法创建当前窗口的Webview窗口。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ opener(): PlusWebviewWebviewObject; @@ -9555,23 +9818,23 @@ interface PlusWebviewWebviewObject { * 拦截Webview窗口的资源加载 * 根据区配规则拦截Webview窗口加载资源的URL地址,重定向到其它资源地址(暂仅支持本地地址)。 * 注意:多次调用overrideResourceRequest时仅以最后一次调用设置的参数值生效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - overrideResourceRequest(options?: PlusWebview []): void; + overrideResourceRequest(options?: PlusWebview[]): void; /** * 拦截Webview窗口的URL请求 * 拦截URL请求后,Webview窗口将不会跳转到新的URL地址,此时将通过callback回调方法返回拦截的URL地址(可新开Webview窗口加载URL页面等)。 * 此方法只能拦截窗口的网络超链接跳转(包括调用loadURL方法触发的跳转),不可拦截页面请求资源请求(如加载css/js/png等资源的请求)。 * 注意:多次调用overrideUrlLoading时仅以最后一次调用设置的参数值生效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ overrideUrlLoading(options?: PlusWebviewWebviewOverrideUrlOptions, callback?: (result: any) => void): void; /** * 获取当前Webview窗口的父窗口 * Webview窗口作为子窗口添加(Webview.append)到其它Webview窗口中时有效,这时其它Webview窗口为父窗口。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ parent(): PlusWebviewWebviewObject; @@ -9579,7 +9842,7 @@ interface PlusWebviewWebviewObject { * 重新加载Webview窗口显示的HTML页面 * 触发Webview窗口重新加载当前显示的页面内容。 * 如果当前HTML页面未加载完则停止并重新加载,如果当前Webview窗口没有加载任何页面则无响应。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ reload(force?: boolean): void; @@ -9587,14 +9850,14 @@ interface PlusWebviewWebviewObject { * 重置Webview窗口的回弹位置 * 开启窗口回弹效果后,当窗口中展现的内容滚动到头(顶部或底部)时,再拖拽时窗口整体内容将跟随移动,松开后自动回弹到停靠位置。 * 这时需要调用此方法来重置窗口的回弹位置,窗口将采用动画方式回弹到其初始显示的位置。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ resetBounce(): void; /** * 恢复Webview控件显示内容 * 恢复调用animate方法改变Webview控件的内容,更新至动画前显示的内容。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ restore(): void; @@ -9602,14 +9865,14 @@ interface PlusWebviewWebviewObject { * 移除子Webview窗口 * 从当前Webview窗口移除指定的子Webview窗口,若指定的webview对象不是当前窗口的子窗口则无任何作用。 * 移除后子Webview窗口不会关闭,需要调用其close方法才能真正关闭并销毁。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ remove(webview?: PlusNativeObjView): void; /** * 移除Webview窗口事件监听器 * 从Webview窗口移除通过addEventListener方法添加的事件监听器,若没有查找到对应的事件监听器,则无任何作用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ removeEventListener(event?: PlusWebviewWebviewEvent, listener?: (result: any) => void): void; @@ -9617,14 +9880,14 @@ interface PlusWebviewWebviewObject { * 从父窗口中移除 * 从所属的父Webview窗口移除,如果没有父窗口,则无任何作用。 * 从父窗口中移除后子Webview窗口不会关闭,需要调用其close方法才能真正关闭并销毁。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ removeFromParent(): void; /** * 移除标题栏上按钮的角标 * 仅在窗口使用原生标题栏(titleNView)时生效,未显示原生标题栏时操作此接口无任何效果。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ removeTitleNViewButtonBadge(index?: number): void; @@ -9632,20 +9895,20 @@ interface PlusWebviewWebviewObject { * 设置Webview窗口的回弹效果 * 开启窗口回弹效果后,当窗口中展现的内容滚动到头(顶部或底部)时,再拖拽时窗口整体内容将跟随移动,松开后自动回弹到停靠位置(可通过style设置)。 * 拖拽窗口内容时页面显示Webview窗口的背景色,默认为透明,此时显示Webview下面的内容,利用这个特点可以实现自定下拉刷新特效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ setBounce(style?: PlusWebviewWebviewBounceStyle): void; /** * 设置Webview窗口是否阻塞加载页面中使用的网络图片 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ setBlockNetworkImage(block?: boolean): void; /** * 设置HTML内容是否可见 * 设置HTML内容不可见后,将显示Webview窗口的背景色。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ setContentVisible(visible?: boolean): void; @@ -9653,7 +9916,7 @@ interface PlusWebviewWebviewObject { * 设置预加载的CSS文件 * 预加载CSS文件不需要在HTML页面中显式引用,在Webview窗口加载HTML页面时自动加载,在页面跳转时也会自动加载。 * 设置新的CSS文件后将清空之前设置的值(包括调用setCssText设置的值)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ setCssFile(file?: string): void; @@ -9661,14 +9924,14 @@ interface PlusWebviewWebviewObject { * 设置预加载的CSS内容 * 预加载CSS内容不需要在HTML页面中显式引用,在Webview窗口加载HTML页面时自动加载,在页面跳转时也会自动加载。 * 设置新的CSS内容后将清空之前设置的值(包括调用setCssFile设置的值)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ setCssText(text?: string): void; /** * 设置Webview窗口的收藏参数 * 仅在流应用环境(流应用/5+浏览器)中有效:用户点击流应用环境的收藏按钮时使用的参数,如设置收藏页面标题,图标、页面地址等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ setFavoriteOptions(options?: PlusWebviewWebviewFavoriteOptions): void; @@ -9676,7 +9939,7 @@ interface PlusWebviewWebviewObject { * 设置Webview窗口底部修复区域高度 * 如果Webview加载页面中存在底部停靠区域(如“蘑菇街”WAP页面的底部Tab栏),在页面滚动时动态改变Webview高度可能会出现底部停靠区域抖动的现象(如360浏览器中向上滑顶部标题栏自动消失引起Webview变高)。 * 此时可以调用此方法来指定底部停靠区域(通常是底部Tab栏)进行优化修复抖动效果,高度值为底部停靠区域的高度。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ setFixBottom(height?: number): void; @@ -9684,49 +9947,49 @@ interface PlusWebviewWebviewObject { * 设置预加载的JS文件 * 预加载JS文件不需要在HTML页面中显式引用,在Webview窗口加载HTML页面时自动加载,在页面跳转时也会自动加载。 * 设置新的JS文件后将清空之前设置的值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ setJsFile(file?: string): void; /** * 设置Webview窗口的下拉刷新效果 * 开启Webview窗口的下拉刷新功能,显示窗口内置的下拉刷新控件样式。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ setPullToRefresh(style?: PlusWebviewWebviewPullToRefreshStyles, refreshCB?: () => void): void; /** * 设置Webview窗口rendered事件参数 * 可设置页面渲染完成的判断标准,如判断页面顶部区域、中间区域、或底部区域。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ setRenderedEventOptions(options?: PlusWebviewWebviewRenderedEventOptions): void; /** * 设置Webview窗口的样式 * 更新Webview窗口的样式,如窗口位置、大小、背景色等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ setStyle(styles?: PlusWebviewWebviewStyles): void; /** * 设置Webview窗口的分享参数 * 仅在流应用环境(流应用/5+浏览器)中有效:用户点击流应用环境的分享按钮时使用的参数,如设置分享的标题、链接地址等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ setShareOptions(options?: PlusWebviewWebviewShareOptions): void; /** * 设置标题栏上按钮的角标 * 仅在窗口使用原生标题栏(titleNView)时生效,未显示原生标题栏时操作此接口无任何效果。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ setTitleNViewButtonBadge(index?: number, text?: string): void; /** * 设置Webview窗口是否可见 * 修改窗口是否可见并不影响窗口的显示栈顺序,窗口显示与隐藏也不会有动画效果。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ setVisible(visible?: boolean): void; @@ -9734,15 +9997,20 @@ interface PlusWebviewWebviewObject { * 显示Webview窗口 * 当调用plus.webview.create方法创建Webview窗口后,需要调用其show方法才能显示,并可设置窗口显示动画及动画时间。 * Webview窗口被隐藏后也可调用此方法来重新显示。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - show(aniShow?: PlusWebviewAnimationTypeShow, duration?: number, showedCB?: () => void, extras?: PlusWebviewWebviewExtraOptions): void; + show( + aniShow?: PlusWebviewAnimationTypeShow, + duration?: number, + showedCB?: () => void, + extras?: PlusWebviewWebviewExtraOptions, + ): void; /** * 在指定Webview窗口后显示 * 当调用plus.webview.create方法创建Webview窗口后,可调用其showBehind方法显示在指定Webview窗口之后。 * 这种显示方式不会出现动画效果,当指定的Webview窗口关闭后,则自身窗口自动显示出来。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ showBehind(webview?: PlusWebviewWebviewObject): void; @@ -9750,14 +10018,14 @@ interface PlusWebviewWebviewObject { * 设置标题栏上按钮的红点 * 仅在窗口使用原生标题栏(titleNView)时生效,未显示原生标题栏时操作此接口无任何效果。 * 注意:设置显示按钮的角标后红点不显示。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ showTitleNViewButtonRedDot(index?: number): void; /** * 停止加载HTML页面内容 * 触发Webview窗口停止加载页面内容,如果已经加载部分内容则显示部分内容,如果加载完成则显示全部内容。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ stop(): void; @@ -9765,30 +10033,30 @@ interface PlusWebviewWebviewObject { * 更新Webview窗口的原生子View控件对象 * 通过WebviewSubNViewStyles中的id属性值匹配子View控件更新绘制内容,如果没有查找到对应id的子View控件则忽略。 * 此操作仅更新子View控件上绘制的内容,不会添加或删除原生子View控件对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - updateSubNViews(styles?: PlusWebview []): void; + updateSubNViews(styles?: PlusWebview[]): void; } /** * Webview窗口动画参数 * 用于指定动画目标窗口,起始位置、目标位置等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewAnimationOptions { /** * 执行动画的窗口对象 * 可取值Webview窗口对象、Webview窗口的id(String类型)、原生View窗口对象(plus.nativeObj.View)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ view?: PlusWebviewWebviewObject | undefined; /** * 动画样式 * 用于指定动画窗口的起始位置,目标位置等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ styles?: PlusWebviewWebviewAnimationStyles | undefined; @@ -9802,23 +10070,23 @@ interface PlusWebviewWebviewAnimationOptions { * - none: 动画完成后不做任何操作 * - hide: 动画完成后隐藏窗口 * - close: 动画完成后关闭窗口 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - action?: 'none' | 'hide' | 'close' | undefined; + action?: "none" | "hide" | "close" | undefined; } /** * Webview窗口动画样式 * 用于指定动画窗口的起始位置、目标位置等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewAnimationStyles { /** * 画窗口的起始左侧位置 * 支持百分比、像素值,默认值为当前窗口的位置。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ fromLeft?: string | undefined; @@ -9826,7 +10094,7 @@ interface PlusWebviewWebviewAnimationStyles { * 画窗口的目标左侧位置 * 持百分比、像素值。 * 注意:如果设置的位置与起始位置一直,则无动画效果。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ toLeft?: string | undefined; @@ -9834,7 +10102,7 @@ interface PlusWebviewWebviewAnimationStyles { /** * Webview窗口回弹样式 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewBounceStyle { @@ -9848,7 +10116,7 @@ interface PlusWebviewWebviewBounceStyle { * bottom:表示窗口底部支持回弹效果。 * **目前仅支持top属性** * 属性值:用于指定可拖拽的范围,可取百分比,如"10%";像素值,如"100px";自动计算值,如"auto";无回弹效果值,如"none"; - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ position?: any; @@ -9858,7 +10126,7 @@ interface PlusWebviewWebviewBounceStyle { * 支持以下属性: * top:表示窗口顶部回弹时停靠的位置。 * 属性值:用于指定窗口回弹的位置,可取百分比,如"5%";像素值,如"100px";自动计算值,如"auto",默认为可拖拽的范围值的一半; - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ changeoffset?: any; @@ -9869,7 +10137,7 @@ interface PlusWebviewWebviewBounceStyle { * left:表示窗口左侧侧滑的位置; * right:表示窗口右侧侧滑的位置。 * 属性值:用于指定滑动后停靠的距离,可取百分比(left/right相对于窗口的宽度,top/bottom相对于窗口的高度),如"30%";像素值,如"100px";自动计算值,为可拖拽范围,如"auto"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ slideoffset?: any; @@ -9882,14 +10150,14 @@ interface PlusWebviewWebviewBounceStyle { * right:表示窗口右侧偏移的位置; * bottom:表示窗口底部偏移的位置。 * 属性值:用于指定偏移的位置,可取百分比,如"5%";像素值,如"100px";有效值范围为0到position属性定义的位置。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ offset?: any; /** * Webview窗口是否阻止touch事件传递给DOM元素 * 设置为true表示阻止touch事件,设置为false表示不阻止touch事件。当开启侧滑功能(左侧滑和右侧滑)时默认值为true,否则为false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ preventTouchEvent?: boolean | undefined; @@ -9898,7 +10166,7 @@ interface PlusWebviewWebviewBounceStyle { /** * Webview窗口内容动画参数 * 指定动画的类型、持续时间等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewContentAnimationOptions { @@ -9906,21 +10174,21 @@ interface PlusWebviewWebviewContentAnimationOptions { * 动画类型 * 可取值:"shrink" - 从上到下分块收缩清除窗口动画。 * - shrink: 从上到下分块清除动画 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - type?: 'shrink' | undefined; + type?: "shrink" | undefined; /** * 动画持续时间 * 单位为毫秒,默认值为200ms。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ duration?: number | undefined; /** * 动画帧数 * 必须为大于0的整数,默认值为12。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ frames?: number | undefined; @@ -9932,7 +10200,7 @@ interface PlusWebviewWebviewContentAnimationOptions { * left - 区域距离控件左侧的偏移量,属性值可取像素值(如"100px"),百分比(如"10%",相对于控件的宽度),默认值为'0px'; * right - 区域距离控件右侧的偏移量,属性值可取像素值(如"100px"),百分比(如"10%",相对于控件的宽度),默认值为'0px'。 * 如“{top:'44px',bottom:'48px'}”。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ region?: any; @@ -9940,31 +10208,31 @@ interface PlusWebviewWebviewContentAnimationOptions { /** * 原生控件在窗口中停靠的方式 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewDock { /** * 控件停靠则页面顶部 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ top?: string | undefined; /** * 控件停靠在页面底部 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ bottom?: string | undefined; /** * 控件停靠在页面右侧 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ right?: string | undefined; /** * 控件停靠在页面左侧 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ left?: string | undefined; @@ -9972,7 +10240,7 @@ interface PlusWebviewWebviewDock { /** * Webview窗口滑动事件数据 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewDragEvent { @@ -9983,7 +10251,7 @@ interface PlusWebviewWebviewDragEvent { * "left" - 向左滑动手势,与rtl一致; * "ltr" - 从左向右滑动手势; * "right" - 向右滑动手势,与ltr一致。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ direction?: string | undefined; @@ -9993,7 +10261,7 @@ interface PlusWebviewWebviewDragEvent { * "start" - 表示开始滑动操作; * "move" - 表示正在滑动; * "end" - 表示滑动操作结束。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ type?: string | undefined; @@ -10003,7 +10271,7 @@ interface PlusWebviewWebviewDragEvent { * "true" - 表示滑动操作成功; * "false" - 表示滑动操作失败(恢复到滑动前的状态); * "undefined" - 无状态值(当type值为"end"时返回此值)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ result?: string | undefined; @@ -10011,21 +10279,21 @@ interface PlusWebviewWebviewDragEvent { * 当前操作窗口标识 * 当type值为"start"/"move"时,保存当前操作窗口(或View控件)的标识; * 当type值为"end"时保存滑动操作后显示窗口(或View控件)的标识(即result值为"true"则认为关联窗口显示,result值为false则认为主窗口显示)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ id?: string | undefined; /** * 关联窗口标识 * 滑动操作关联窗口(或View控件)的标识。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ otherId?: string | undefined; /** * 主窗口标识 * 滑动操作主窗口(或View控件)的标识。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ targetId?: string | undefined; @@ -10035,7 +10303,7 @@ interface PlusWebviewWebviewDragEvent { * 当type值为"start"时progress值为0; * 当type值为"end"时如果result为true则progress值为0,如果result为false则progress值为100; * 当type值为"move"时,保存当前滑动的进度信息(注:多次触发move事件)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ progress?: number | undefined; @@ -10043,7 +10311,7 @@ interface PlusWebviewWebviewDragEvent { /** * 窗口手势操作参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewDragOptions { @@ -10052,7 +10320,7 @@ interface PlusWebviewWebviewDragOptions { * 用于设置滑屏回调事件触发频率,取值范围为1-100,值越小触发频率越高,值越大触发频率越小,默认值为20。 * 如设置值为20,则表示滑屏操作移动距离超过可移动范围的20%则触发一次回调事件,可通过回调函数参数(WebviewDragEvent)的progress属性获取。 * 注意:触发频率过大会影响效率,开发者需谨慎设置此值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ callbackStep?: number | undefined; @@ -10068,10 +10336,10 @@ interface PlusWebviewWebviewDragOptions { * - left: 向左滑动手势,与rtl一致 * - ltr: 从左向右滑动手势 * - right: 向右滑动手势,与ltr一致 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - direction?: 'rtl' | 'left' | 'ltr' | 'right' | undefined; + direction?: "rtl" | "left" | "ltr" | "right" | undefined; /** * 滑动手势模式 * 可取值: @@ -10081,22 +10349,22 @@ interface PlusWebviewWebviewDragOptions { * - followFinger: 当前Webview窗口跟随手指滑动 * - silent: 当前Webview窗口不跟随手指滑动 * - bounce: 当前Webview窗口自动回弹 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - moveMode?: 'followFinger' | 'silent' | 'bounce' | undefined; + moveMode?: "followFinger" | "silent" | "bounce" | undefined; } /** * 手势操作关联对象参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewDragOtherViewOptions { /** * 手势关联对象 * 可取值Webview窗口的id(String类型)、Webview窗口对象、原生View窗口对象(plus.nativeObj.View)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ view?: string | undefined; @@ -10107,15 +10375,15 @@ interface PlusWebviewWebviewDragOtherViewOptions { * "silent" - 不跟随主Webview窗口滑动。 * - follow: 同步跟随主Webview窗口滑动 * - silent: 不跟随主Webview窗口滑动 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - moveMode?: 'follow' | 'silent' | undefined; + moveMode?: "follow" | "silent" | undefined; } /** * 截屏绘制操作参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewDrawOptions { @@ -10124,30 +10392,29 @@ interface PlusWebviewWebviewDrawOptions { * 可取值: * "RGB565" - RGB565彩色模式,一个像素占两个字节; * "ARGB" - ARGB彩色模式,保存透明度信息。 - * - RGB565: + * - RGB565: * RGB565彩色模式,一个像素占两个字节。 - * - * - ARGB: + * + * - ARGB: * ARGB彩色模式,保存透明度信息。 - * - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - bit?: 'RGB565' | 'ARGB' | undefined; + bit?: "RGB565" | "ARGB" | undefined; /** * 是否检测截屏图片是否为空白 * 可取值: * true - 表示检测到截屏到空白图片时认为操作失败(触发错误回调函数); * false - 表示不检测,即使为空白图片仍然返回成功。 * 默认值为false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ check?: boolean | undefined; /** * 设置截屏区域 * 相对于Webview窗口的区域信息,默认值为{top:'0px',left:'0px',width:'100%',height:'100%'}。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ clip?: PlusNativeObj | undefined; @@ -10157,7 +10424,7 @@ interface PlusWebviewWebviewDrawOptions { * true - 表示检测到弹出软键盘是认为截屏操作失败(触发错误回调函数); * false - 表示不检测软键盘状态,直接截屏。 * 默认值为false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ checkKeyboard?: boolean | undefined; @@ -10166,28 +10433,28 @@ interface PlusWebviewWebviewDrawOptions { /** * 窗口收藏参数 * 在流应用环境中调用收藏功能时使用的参数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewFavoriteOptions { /** * 收藏时显示的图标 * 在收藏列表中显示的图标,默认使用应用图标。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ icon?: string | undefined; /** * 收藏时显示的标题 * 在收藏列表中显示的标题字符串。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ title?: string | undefined; /** * 收藏的页面地址 * 必须是网络地址。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ href?: string | undefined; @@ -10195,27 +10462,27 @@ interface PlusWebviewWebviewFavoriteOptions { /** * 创建加载HTML数据参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewLoadDataOptions { /** * 页面的Base URL - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ baseURL?: string | undefined; /** * HTML数据的数据类型 * 默认值为"text/html"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ mimeType?: string | undefined; /** * HTML数据的编码类型 * 默认值为"utf-8"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ encoding?: string | undefined; @@ -10224,27 +10491,27 @@ interface PlusWebviewWebviewLoadDataOptions { /** * 窗口的分享参数 * 在流应用环境中调用分享功能时使用的参数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewShareOptions { /** * 分享时使用的图标 * 默认使用应用图标。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ icon?: string | undefined; /** * 分享时使用的标题 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ title?: string | undefined; /** * 分享时使用的链接地址 * 必须是网络地址。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ href?: string | undefined; @@ -10253,14 +10520,14 @@ interface PlusWebviewWebviewShareOptions { /** * 窗口原生子View控件样式 * 可设置原生控件的标识、大小、位置以及绘制的内容等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewSubNViewStyles { /** * 原生子View控件的标识 * 可通过plus.nativeObj.View.getViewById(id)方法传入此标识来获取子View控件对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ id?: string | undefined; @@ -10270,37 +10537,36 @@ interface PlusWebviewWebviewSubNViewStyles { * "NView" - 原生子View控件(plus.nativeObj.NView); * "ImageSlider" - 原生图片轮播控件(plus.nativeObj.ImageSlider)。 * 默认值为"NView"。 - * - NView: + * - NView: * 原生子View控件(plus.nativeObj.NView) - * - * - ImageSlider: - * 原生图片轮播控件(plus.nativeObj.ImageSlider) - * - * + * + * - ImageSlider: + * 原生图片轮播控件(plus.nativeObj.ImageSlider) + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - type?: 'NView' | 'ImageSlider' | undefined; + type?: "NView" | "ImageSlider" | undefined; /** * 原生子View控件的样式 * 可设置原生控件的位置、大小等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ styles?: PlusNativeObjViewStyles | undefined; /** * 原生子View控件初始绘制内容 * 可设置绘制图片、矩形区域、文本等内容。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - tags?: any [] | undefined; + tags?: any[] | undefined; } /** * 窗口标题栏控件样式 * 标题栏控件固定高度为44px,可通过Webview窗口对象的getTitleNView方法获取标题栏原生控件对象动态绘制内容。 * 可以通过WebviewObject对象的getTitleNView()获取标题栏的NView对象,然后调用其setStyle方法更新样式。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewTitleNViewStyles { @@ -10312,14 +10578,14 @@ interface PlusWebviewWebviewTitleNViewStyles { * 默认值为"false"。 * 返回按钮的颜色为窗口标题文字颜色,按下时颜色自动调整透明度为0.3。 * 点击返回按钮的逻辑与按下系统返回键逻辑一致。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ autoBackButton?: boolean | undefined; /** * 标题栏控件的背景颜色 * 颜色值格式为"#RRGGBB",如"#FF0000"表示为红色背景,默认值为"#F7F7F7"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ backgroundColor?: string | undefined; @@ -10327,16 +10593,16 @@ interface PlusWebviewWebviewTitleNViewStyles { * 标题栏上的自定义按钮 * 创建的自定义按钮数目不限制,实际应用中建议最多设置4个按钮(包括左侧返回按钮)。 * 注意:此属性不支持动态修改,仅在创建titleNView时设置有效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - buttons?: PlusWebview [] | undefined; + buttons?: PlusWebview[] | undefined; /** * 标题栏控件变化作用范围 * 仅在type值为transparent时有效,页面滚动时标题栏背景透明度将发生变化。 * 当页面滚动到指定偏移量时标题栏背景变为完全不透明。 * 支持百分比、像素值,默认为'132px'。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ coverage?: string | undefined; @@ -10348,7 +10614,7 @@ interface PlusWebviewWebviewTitleNViewStyles { * 默认值为"false"。 * Home按钮的颜色为窗口标题文字颜色,按下时颜色自动调整透明度为0.3。 * 点击Home按钮的逻辑为关闭所有非首页窗口,显示首页窗口。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ homeButton?: boolean | undefined; @@ -10356,7 +10622,7 @@ interface PlusWebviewWebviewTitleNViewStyles { * 内边距 * 标题栏左右的内边距,单位为px(逻辑像素值),如"10px"表示10逻辑像素值。 * 默认值为"0px"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ padding?: string | undefined; @@ -10364,25 +10630,25 @@ interface PlusWebviewWebviewTitleNViewStyles { * 右内边距 * 标题栏右侧内边距,单位为px(逻辑像素值),如"10px"表示10逻辑像素值。 * 默认值为"0px",优先级padding-right > padding。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - 'padding-right'?: string | undefined; + "padding-right"?: string | undefined; /** * 左内边距 * 标题栏左侧内边距,单位为px(逻辑像素值),如"10px"表示10逻辑像素值。 * 默认值为"0px",优先级padding-left > padding。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - 'padding-left'?: string | undefined; + "padding-left"?: string | undefined; /** * 标题栏控件的进度条样式 * 设置此属性则在标题栏控件的底部显示进度条,可配置进度条颜色值即高度。 * 设置此属性值为undefined或null则隐藏进度条。 * 默认不显示底部进度条。 * 注意:此属性将废弃,推荐使用WebviewStyles的progress。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ progress?: PlusWebviewWebviewProgressStyles | undefined; @@ -10391,7 +10657,7 @@ interface PlusWebviewWebviewTitleNViewStyles { * 设置此属性则在标题栏控件的底部显示分割线,可配置颜色值及高度。 * 设置此属性值为undefined或null则隐藏分割线。 * 默认不显示底部分割线。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ splitLine?: PlusWebviewWebviewSplitLineStyles | undefined; @@ -10399,14 +10665,14 @@ interface PlusWebviewWebviewTitleNViewStyles { * 标题栏上初始自定义绘制内容 * 可用于设置自定义绘制图片、矩形区域、文本等内容。 * 注意:此属性不支持动态修改,仅在创建titleNView时设置有效,如果需要更新绘制内容可根据tags的id调用draw方法操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - tags?: any [] | undefined; + tags?: any[] | undefined; /** * 标题栏控件的标题文字颜色 * 颜色值格式为"#RRGGBB",如"#FF0000"表示标题文字颜色为红色,默认值为"#000000"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ titleColor?: string | undefined; @@ -10416,7 +10682,7 @@ interface PlusWebviewWebviewTitleNViewStyles { * "clip" - 超出显示区域时内容裁剪; * "ellipsis" - 超出显示区域时尾部显示省略标记(...)。 * 默认值为"ellipsis"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ titleOverflow?: string | undefined; @@ -10424,14 +10690,14 @@ interface PlusWebviewWebviewTitleNViewStyles { * 标题栏控件的标题文字内容 * 在标题栏控件居中(水平和垂直)显示,左右边距为88px,如果文本过长则尾部裁剪(加三个点"...")显示。 * 当不设置titleText属性或属性值为undefined/null时,使用当前Webview窗口加载页面的标题,并自动同步更新页面的标题。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ titleText?: string | undefined; /** * 标题栏控件的标题文字字体大小 * 字体大小单位为像素,如"20px"表示字体大小为20像素,默认值为17像素。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ titleSize?: string | undefined; @@ -10442,21 +10708,20 @@ interface PlusWebviewWebviewTitleNViewStyles { * "transparent" - 透明样式,顶部沉浸式显示覆盖Webview页面内容,标题栏上内容(除按钮外)全部透明,当页面滚动时透明度逐渐变化,直到不透明显示。 * 默认值为"default"。 * 注意:此属性不支持动态更新。 - * - default: + * - default: * 默认样式,顶部停靠显示,挤压Webview页面内容显示区域 - * - * - transparent: - * 透明样式,顶部沉浸式显示覆盖Webview页面内容,标题栏上内容(除按钮外)全部透明,当页面滚动时透明度逐渐变化,直到不透明显示 - * - * + * + * - transparent: + * 透明样式,顶部沉浸式显示覆盖Webview页面内容,标题栏上内容(除按钮外)全部透明,当页面滚动时透明度逐渐变化,直到不透明显示 + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - type?: 'default' | 'transparent' | undefined; + type?: "default" | "transparent" | undefined; } /** * 窗口标题栏自定义按钮样式 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewTitleNViewButtonStyles { @@ -10480,22 +10745,22 @@ interface PlusWebviewWebviewTitleNViewButtonStyles { * - home: 主页按钮 * - menu: 菜单按钮 * - close: 关闭按钮 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - type?: 'forward' | 'back' | 'share' | 'favorite' | 'home' | 'menu' | 'close' | undefined; + type?: "forward" | "back" | "share" | "favorite" | "home" | "menu" | "close" | undefined; /** * 按钮的背景颜色 * 仅在标题栏type=transparent时生效,当标题栏透明时按钮显示的背景颜色。 * 可取值#RRGGBB和rgba格式颜色字符串,默认值为灰色半透明。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ background?: string | undefined; /** * 按钮上显示的角标文本 * 最多显示3个字符,超过则显示为...。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ badgeText?: string | undefined; @@ -10504,7 +10769,7 @@ interface PlusWebviewWebviewTitleNViewButtonStyles { * 可取值: "#RRGGBB"格式字符串,如"#FF0000"表示绘制红色返回键; * "rgba(R,G,B,A)",其中R/G/B分别代表红色值/绿色值/蓝色值,正整数类型,取值范围为0-255,A为透明度,浮点数类型,取值范围为0-1(0为全透明,1为不透明),如"rgba(255,0,0,0.5)",表示红色半透明。 * 默认值为窗口标题栏控件的标题文字颜色。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ color?: string | undefined; @@ -10513,7 +10778,7 @@ interface PlusWebviewWebviewTitleNViewButtonStyles { * 可取值: "#RRGGBB"格式字符串,如"#FF0000"表示绘制红色返回键; * "rgba(R,G,B,A)",其中R/G/B分别代表红色值/绿色值/蓝色值,正整数类型,取值范围为0-255,A为透明度,浮点数类型,取值范围为0-1(0为全透明,1为不透明),如"rgba(255,0,0,0.5)",表示红色半透明。 * 默认值为color属性值自动调整透明度为0.3。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ colorPressed?: string | undefined; @@ -10523,38 +10788,36 @@ interface PlusWebviewWebviewTitleNViewButtonStyles { * "right" - 在标题栏中靠右排列显示; * "left" - 在标题栏中靠左侧排列显示(在返回键后)。 * 默认值为"right"。 - * - right: + * - right: * 在标题栏中靠右排列显示 - * - * - left: + * + * - left: * 在标题栏中靠左侧排列显示(在返回键后) - * - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - float?: 'right' | 'left' | undefined; + float?: "right" | "left" | undefined; /** * 按钮上文字的粗细 * 可取值: * "normal" - 标准字体; * "bold" - 加粗字体。 * 默认值为"normal"。 - * - normal: + * - normal: * 标准字体 - * - * - bold: + * + * - bold: * 加粗字体 - * - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - fontWeight?: 'normal' | 'bold' | undefined; + fontWeight?: "normal" | "bold" | undefined; /** * 按钮上文字大小 - * 可取值:字体高度像素值,数字加"px"格式字符串,如"22px"。 + * 可取值:字体高度像素值,数字加"px"格式字符串,如"22px"。 * 窗口标题栏为透明样式(type="transparent")时,默认值为"22px"; * 窗口标题栏为默认样式(type="default")时,默认值为"27px"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ fontSize?: string | undefined; @@ -10565,14 +10828,14 @@ interface PlusWebviewWebviewTitleNViewButtonStyles { * 绝对路径 - 系统绝对路径,如Android平台"/sdcard/a.ttf",此类路径通常通过其它5+ API获取的; * 扩展相对路径URL(RelativeURL) - 以"_"开头的相对路径,如"_www/a.ttf"; * 本地路径URL - 以“file://”开头,后面跟随系统绝对路径。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ fontSrc?: string | undefined; /** * 按钮点击后触发的回调函数 * 回调函数中将返回此JSON对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ onclick?: ((result: any) => void) | undefined; @@ -10580,7 +10843,7 @@ interface PlusWebviewWebviewTitleNViewButtonStyles { * 按钮上是否显示红点 * 设置为true则显示红点,false则不显示红点。默认值为false。 * 注意:当设置了角标文本时红点不显示。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ redDot?: boolean | undefined; @@ -10588,14 +10851,14 @@ interface PlusWebviewWebviewTitleNViewButtonStyles { * 是否显示选择指示图标 * 设置为true则显示选择指示图标(向下箭头),颜色与文字颜色一致; * false则不显示。默认值为false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ select?: boolean | undefined; /** * 按钮上显示的文字 * 推荐使用一个字符,超过一个字符可能无法正常显示,使用字体图标时unicode字符表示必须'\u'开头,如"\ue123"(注意不能写成"\e123")。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ text?: string | undefined; @@ -10605,7 +10868,7 @@ interface PlusWebviewWebviewTitleNViewButtonStyles { * "*px" - 逻辑像素值,如"10px"表示10逻辑像素值,按钮的内容居中显示; * "auto" - 自定计算宽度,根据内容自动调整按钮宽度。 * 默认值为"44px"(适合字体图标)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ width?: string | undefined; @@ -10614,7 +10877,7 @@ interface PlusWebviewWebviewTitleNViewButtonStyles { /** * 标题栏控件的进度条样式 * 显示在标题栏控件底部。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewProgressStyles { @@ -10623,7 +10886,7 @@ interface PlusWebviewWebviewProgressStyles { * 可取值: "#RRGGBB"格式字符串,如"#FF0000"表示绘制红色分割线; * "rgba(R,G,B,A)",其中R/G/B分别代表红色值/绿色值/蓝色值,正整数类型,取值范围为0-255,A为透明度,浮点数类型,取值范围为0-1(0为全透明,1为不透明),如"rgba(255,0,0,0.5)",表示红色半透明。 * 默认值为"#00FF00"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ color?: string | undefined; @@ -10631,7 +10894,7 @@ interface PlusWebviewWebviewProgressStyles { * 进度条高度 * 可取值:像素值(逻辑像素),支持小数点,如"1px"表示1像素高;百分比,如"1%",相对于标题栏控件的高度。 * 默认值为"2px"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ height?: string | undefined; @@ -10640,7 +10903,7 @@ interface PlusWebviewWebviewProgressStyles { /** * 窗口标题栏控件的分割线样式 * 显示在标题栏控件底部。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewSplitLineStyles { @@ -10649,7 +10912,7 @@ interface PlusWebviewWebviewSplitLineStyles { * 可取值: "#RRGGBB"格式字符串,如"#FF0000"表示绘制红色分割线; * "rgba(R,G,B,A)",其中R/G/B分别代表红色值/绿色值/蓝色值,正整数类型,取值范围为0-255,A为透明度,浮点数类型,取值范围为0-1(0为全透明,1为不透明),如"rgba(255,0,0,0.5)",表示红色半透明。 * 默认值为"#CCCCCC"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ color?: string | undefined; @@ -10657,7 +10920,7 @@ interface PlusWebviewWebviewSplitLineStyles { * 底部分割线高度 * 可取值:像素值(逻辑像素),支持小数点,如"1px"表示1像素高;百分比,如"1%",相对于标题栏控件的高度。 * 默认值为"1px"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ height?: string | undefined; @@ -10665,84 +10928,84 @@ interface PlusWebviewWebviewSplitLineStyles { /** * Webview窗口事件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewEvent { /** * Webview窗口关闭事件 * 通过WebviewObject对象的addEventListener方法添加事件监听函数,当Webview窗口关闭时触发此事件,回调函数类型为EventCallback。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ close?: string | undefined; /** * Webview窗口回弹事件 * 通过WebviewObject对象的setBounce方法开启回弹效果设置顶部下拉回弹changeoffset属性后,当用户向下拖拽窗口时触发发此事件,回调函数类型为BounceEventCallback。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ dragBounce?: string | undefined; /** * Webview窗口回弹事件 * 通过WebviewObject对象的setBounce方法开启回弹效果设置左右侧侧滑slideoffset属性后,当用户向左右侧拖拽窗口侧滑时触发发此事件,回调函数类型为BounceEventCallback。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ slideBounce?: string | undefined; /** * Webview窗口加载错误事件 * 通过WebviewObject对象的addEventListener方法添加事件监听函数,当Webview窗口加载错误时触发此事件,回调函数类型为EventCallback。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ error?: string | undefined; /** * Webview窗口隐藏事件 * 通过WebviewObject对象的addEventListener方法添加事件监听函数,当Webview窗口隐藏(窗口动画完成后)时触发此事件,回调函数类型为EventCallback。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ hide?: string | undefined; /** * Webview窗口页面开始加载事件 * 通过WebviewObject对象的addEventListener方法添加事件监听函数,当Webview窗口开始加载新页面时触发此事件,回调函数类型为EventCallback。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ loading?: string | undefined; /** * Webview窗口页面加载完成事件 * 通过WebviewObject对象的addEventListener方法添加事件监听函数,当Webview窗口页面加载完成时触发此事件,回调函数类型为EventCallback。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ loaded?: string | undefined; /** * Webview窗口显示遮罩层时点击事件 * 通过WebviewObject对象的addEventListener方法添加事件监听函数,当Webview窗口通过mask属性设置显示遮罩层并且点击时触发此事件,回调函数类型为EventCallback。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ maskClick?: string | undefined; /** * Webview窗口开始渲染事件 * 通过WebviewObject对象的addEventListener方法添加事件监听函数,当Webview窗口开始渲染内容时触发此事件,回调函数类型为EventCallback。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ rendering?: string | undefined; /** * Webview窗口渲染完成事件 * 通过WebviewObject对象的addEventListener方法添加事件监听函数,当Webview窗口渲染完成时触发此事件,回调函数类型为EventCallback。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ rendered?: string | undefined; /** * Webview窗口显示事件 * 通过WebviewObject对象的addEventListener方法添加事件监听函数,当Webview窗口显示(窗口动画完成后)时触发此事件,回调函数类型为EventCallback。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ show?: string | undefined; @@ -10750,7 +11013,7 @@ interface PlusWebviewWebviewEvent { * Webview加载页面标题更新事件 * 通过WebviewObject对象的addEventListener方法添加事件监听函数,当Webview窗口加载新页面更新标题时触发此事件,回调函数类型为SuccessCallback。 * 注意:此事件会先于loaded事件触发,通常在加载网络页面时通过此事件可更快获取到页面的标题。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ titleUpdate?: string | undefined; @@ -10758,14 +11021,14 @@ interface PlusWebviewWebviewEvent { * Webview窗口接收到触屏事件 * 通过WebviewObject对象的addEventListener方法添加事件监听函数,当用户操作按下到Webview窗口时触发此事件,回调函数类型为SuccessCallback。 * 注意:每按下屏幕触发一次此事件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ touchstart?: string | undefined; /** * Webview窗口侧滑返回事件 * 通过WebviewObject对象的addEventListener方法添加事件监听函数,当Webview窗口侧滑返回时触发此事件,回调函数类型为PopGestureCallback。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ popGesture?: string | undefined; @@ -10773,7 +11036,7 @@ interface PlusWebviewWebviewEvent { * Webview窗口加载进度变化事件 * 通过WebviewObject对象的addEventListener方法添加事件监听函数,当Webview窗口加载页面进度变化时触发此事件。 * 回调函数原型为void PorgressCandedCallback(Event e),可通过e.progress获取窗口加载进度,取值范围为0-100。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ progressChanged?: string | undefined; @@ -10781,7 +11044,7 @@ interface PlusWebviewWebviewEvent { * Webview窗口下拉刷新事件 * Webview窗口打开下拉刷新功能后,用户操作下拉刷新时或调用beginPullToRefresh方法时触发,用于通知业务逻辑可以开始执行刷新操作。 * 更新操作完成后调用窗口的endPullToRefresh方法结束下拉刷新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ pullToRefresh?: string | undefined; @@ -10789,7 +11052,7 @@ interface PlusWebviewWebviewEvent { /** * JSON对象,原生窗口扩展参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewExtraOptions { @@ -10801,17 +11064,17 @@ interface PlusWebviewWebviewExtraOptions { * "none" - 关闭窗口动画加速功能; * "capture" - 使用截屏方式加速窗口动画。 * 默认值为"auto"。 - * - auto: - * + * - auto: + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - acceleration?: 'auto' | undefined; + acceleration?: "auto" | undefined; /** * 窗口动画加速时使用的图片 * 当使用截屏方式加速窗口动画时,可设置已经创建好的截屏图片,此时不会进行实时截屏操作,加速窗口动画响应时间,提升用户体验。 * 如果未指定截屏图片,则实时截取当前Webview窗口对象的图片进行动画操作。 * 如果窗口未使用截屏方式加速动画,则忽略此参数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ capture?: PlusNativeObjBitmap | undefined; @@ -10820,7 +11083,7 @@ interface PlusWebviewWebviewExtraOptions { * 当使用截屏方式加速窗口动画时,可设置已经创建好的截屏图片,此时不会进行实时截屏操作,加速关联窗口动画响应时间,提升用户体验。 * 如果未指定截屏图片,则实时截取关联Webview窗口对象的图片进行动画操作。 * 如果窗口未使用截屏方式加速动画,则忽略此参数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ otherCapture?: PlusNativeObjBitmap | undefined; @@ -10828,25 +11091,25 @@ interface PlusWebviewWebviewExtraOptions { /** * 原生控件在窗口中显示的位置 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewPosition { /** * 控件在页面中正常定位,如果页面存在滚动条则随窗口内容滚动 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ static?: string | undefined; /** * 控件在页面中绝对定位,如果页面存在滚动条不随窗口内容滚动 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ absolute?: string | undefined; /** * 控件在页面中停靠,停靠的位置通过dock属性进行定义 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ dock?: string | undefined; @@ -10854,7 +11117,7 @@ interface PlusWebviewWebviewPosition { /** * Webview窗口下拉刷新样式 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewPullToRefreshStyles { @@ -10862,14 +11125,14 @@ interface PlusWebviewWebviewPullToRefreshStyles { * 是否开启Webview窗口的下拉刷新功能 * true表示开启窗口的下拉刷新功能; * false表示关闭窗口的下拉刷新功能。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ support?: boolean | undefined; /** * 下拉刷新控件颜色 * 颜色值格式为"#RRGGBB",如"#FF0000"为设置下拉属性控件为红色,默认值为"#2BD009"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ color?: string | undefined; @@ -10879,21 +11142,21 @@ interface PlusWebviewWebviewPullToRefreshStyles { * "default" - 经典下拉刷新样式(下拉拖动时页面内容跟随); * "circle" - 圆圈样式下拉刷新控件样式(下拉拖动时仅刷新控件跟随)。 * 默认值为"default"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ style?: string | undefined; /** * 窗口的下拉刷新控件进入刷新状态的拉拽高度 * 支持百分比,如"10%";像素值,如"50px"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ height?: string | undefined; /** * 窗口可下拉拖拽的范围 * 支持百分比,如"10%";像素值,如"50px"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ range?: string | undefined; @@ -10902,7 +11165,7 @@ interface PlusWebviewWebviewPullToRefreshStyles { * 仅对"circle"样式下拉刷新控件有效,用于定义刷新控件下拉时的起始位置。 * 相对于Webview的顶部偏移量,支持百分比,如"10%";像素值,如"50px"。 * 默认值为"0px"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ offset?: string | undefined; @@ -10910,7 +11173,7 @@ interface PlusWebviewWebviewPullToRefreshStyles { * 在下拉可刷新状态时显示的内容 * 支持以下属性: * caption:在下拉可刷新状态时下拉刷新控件上显示的标题内容。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ contentdown?: any; @@ -10918,7 +11181,7 @@ interface PlusWebviewWebviewPullToRefreshStyles { * 在释放可刷新状态时显示的内容 * 支持以下属性: * caption:在释放可刷新状态时下拉刷新控件上显示的标题内容。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ contentover?: any; @@ -10926,7 +11189,7 @@ interface PlusWebviewWebviewPullToRefreshStyles { * 在正在刷新状态时显示的内容 * 支持以下属性: * caption:在正在刷新状态时下拉刷新控件上显示的标题内容。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ contentrefresh?: any; @@ -10934,7 +11197,7 @@ interface PlusWebviewWebviewPullToRefreshStyles { /** * Webview窗口rendered事件参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewRenderedEventOptions { @@ -10946,14 +11209,14 @@ interface PlusWebviewWebviewRenderedEventOptions { * "center"-从中间横线检测渲染是否完成; * "auto"为全屏检测(左、中、右三条竖线)。 * 默认值为"auto"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ type?: string | undefined; /** * 判断窗口渲染完成间隔时间 * 单位为ms(毫秒),默认值为150ms。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interval?: number | undefined; @@ -10962,7 +11225,7 @@ interface PlusWebviewWebviewRenderedEventOptions { /** * 替换H5标准API配置信息 * 目前仅支持替换H5标准定位接口 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewReplaceWebApiOptions { @@ -10974,25 +11237,24 @@ interface PlusWebviewWebviewReplaceWebApiOptions { * "none" - 不替换H5标准定位接口(navigator.geolocation.*)。 * 默认值为"none"。 * 注意:替换H5标准定位接口,会导致页面加载速度延迟100ms左右,推荐使用"auto"模式。 - * - alldevice: - * 强制替换H5标准定位接口(navigator.geolocation.*) - * - * - auto: + * - alldevice: + * 强制替换H5标准定位接口(navigator.geolocation.*) + * + * - auto: * 自动替换标准H5定位接口,仅在调用标准H5定位接口无法获取数据的设备上替换 - * - * - none: + * + * - none: * 不替换标准H5定位接口(navigator.geolocation.*) - * - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - geolocation?: 'alldevice' | 'auto' | 'none' | undefined; + geolocation?: "alldevice" | "auto" | "none" | undefined; } /** * JSON对象,Webview窗口的系统状态栏区域样式 * 仅在应用设置为沉浸式状态栏样式下有效,非沉浸式状态栏样式下忽略此属性。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewStatusbarStyles { @@ -11000,7 +11262,7 @@ interface PlusWebviewWebviewStatusbarStyles { * 系统状态栏区域背景颜色 * 颜色值格式为"#RRGGBB",如"#FF0000"表示为红色背景。 * 默认值为应用manifest.json中plus->statusbar->background属性配置的值,如果未配置此属性值,则使用系统默认状态栏的背景颜色。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ background?: string | undefined; @@ -11008,7 +11270,7 @@ interface PlusWebviewWebviewStatusbarStyles { /** * JSON对象,Webview窗口对象的样式 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewStyles { @@ -11017,7 +11279,7 @@ interface PlusWebviewWebviewStyles { * 仅在Webview窗口第一次加载页面时使用,如用户点击的触发的链接跳转则不再添加此额外请求头数据。 * 如果Webview窗口非第一次加载页面时也需要额外添加HTTP请求头数据,可通过loadURL()方法的参数设置。 * 如果HTTP请求头中已经包含需要额外添加的头数据,则添加的请求数据覆盖默认值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ additionalHttpHeaders?: any; @@ -11027,7 +11289,7 @@ interface PlusWebviewWebviewStyles { * "auto" - 如果窗口中存在titleNView或subNViews,窗口动画时真实Webview控件从动画窗口中移除加速(避免真实Webview渲染影响动画效率); * "none" - 窗口动画不使用优化。 * 默认值为"auto"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ animationOptimization?: string | undefined; @@ -11039,22 +11301,21 @@ interface PlusWebviewWebviewStyles { * "noCache" - 不使用缓存数据,全部从网络获取; * "cacheOnly" - 仅使用缓存数据,不从网络获取(注:如果没有缓存数据则会导致加载失败)。 * 默认使用"default"。 - * - default: + * - default: * 根据cache-control决定是否使用缓存数据,如果存在缓存并且没有过期则使用本地缓存资源,否则从网络获取。 - * - * - cacheElseNetwork: + * + * - cacheElseNetwork: * 只要存在缓存(即使过期)数据则使用,否则从网络获取。 - * - * - noCache: + * + * - noCache: * 不使用缓存数据,全部从网络获取。 - * - * - cacheOnly: + * + * - cacheOnly: * 仅使用缓存数据,不从网络获取(注:如果没有缓存数据则会导致加载失败)。 - * - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - cachemode?: 'default' | 'cacheElseNetwork' | 'noCache' | 'cacheOnly' | undefined; + cachemode?: "default" | "cacheElseNetwork" | "noCache" | "cacheOnly" | undefined; /** * Webview窗口自动处理返回键逻辑 * 当Webview窗口在显示栈顶,并且Webview窗口中没有调用JS监听返回键(plus.key.addEventListener('backbutton',...))时按下返回键响应行为。 @@ -11063,24 +11324,23 @@ interface PlusWebviewWebviewStyles { * "close" - 关闭Webview窗口,关闭动画与上一次调用显示时设置的动画类型相对应(如“slide-in-right”对应的关闭动画为“slid-out-right”) ; * "none" - 不做操作,将返回键传递给下一Webview窗口处理; * "quit" - 退出应用。 - * - hide: + * - hide: * 隐藏Webview窗口,隐藏动画与上一次调用显示时设置的动画类型相对应(如“slide-in-right”对应的关闭动画为“slid-out-right”)。 - * - * - close: + * + * - close: * 关闭Webview窗口,关闭动画与上一次调用显示时设置的动画类型相对应(如“slide-in-right”对应的关闭动画为“slid-out-right”)。 - * - * - none: + * + * - none: * 不做操作,将返回键传递给下一Webview窗口处理。 - * - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - backButtonAutoControl?: 'hide' | 'close' | 'none' | undefined; + backButtonAutoControl?: "hide" | "close" | "none" | undefined; /** * 窗口的背景颜色 * 窗口空白区域的背景模式,设置background为颜色值(参考CSS Color Names,可取值/十六进制值/rgb值/rgba值),窗口为独占模式显示(占整个屏幕区域); * 设置background为“transparent”,则表示窗口背景透明,为非独占模式。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ background?: string | undefined; @@ -11091,7 +11351,7 @@ interface PlusWebviewWebviewStyles { * "#RRGGBB"格式字符串,如"#FF0000"表示红色; * "rgba(R,G,B,A)",其中R/G/B分别代表红色值/绿色值/蓝色值,正整数类型,取值范围为0-255,A为透明度,浮点数类型,取值范围为0-1(0为全透明,1为不透明),如"rgba(255,0,0,0.5)",表示红色半透明。 * 默认值为透明。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ backgroundColorTop?: string | undefined; @@ -11102,7 +11362,7 @@ interface PlusWebviewWebviewStyles { * "#RRGGBB"格式字符串,如"#FF0000"表示红色; * "rgba(R,G,B,A)",其中R/G/B分别代表红色值/绿色值/蓝色值,正整数类型,取值范围为0-255,A为透明度,浮点数类型,取值范围为0-1(0为全透明,1为不透明),如"rgba(255,0,0,0.5)",表示红色半透明。 * 默认值为透明。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ backgroundColorBottom?: string | undefined; @@ -11110,7 +11370,7 @@ interface PlusWebviewWebviewStyles { * 是否阻塞网络图片的加载 * 布尔类型,true表示阻塞,false表示不阻塞,默认值为false。 * 阻塞后Webview窗口将不加载页面中使用的所有网络图片,可通过Webview窗口对象的setBlockNetWorkImage()方法动态修改此状态。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ blockNetworkImage?: boolean | undefined; @@ -11119,7 +11379,7 @@ interface PlusWebviewWebviewStyles { * 支持百分比、像素值,默认值无值(根据top和height属性值来自动计算)。 * 当同时设置了top和height值时,忽略此属性值; * 当未设置height值时,可通过top和bottom属性值来确定窗口的高度。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ bottom?: string | undefined; @@ -11135,16 +11395,16 @@ interface PlusWebviewWebviewStyles { * - vertical: 垂直方向有反弹效果 * - horizontal: 水平方向有反弹效果 * - all: 垂直和水平方向都有反弹效果 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - bounce?: 'none' | 'vertical' | 'horizontal' | 'all' | undefined; + bounce?: "none" | "vertical" | "horizontal" | "all" | undefined; /** * 窗口回弹效果区域的背景 * 窗口回弹效果区域背景可支持颜色值或图片: * 颜色值格式为"#RRGGBB",如"#FFFFFF"为设置白色背景; * 背景图为"url(%image path%)",如"url(./icon.png)"为设置icon.png为背景图,图片采用平铺模式绘制。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ bounceBackground?: string | undefined; @@ -11152,7 +11412,7 @@ interface PlusWebviewWebviewStyles { * 窗口内容停止滑动的减速度 * 当Webview加载的内容超过其高度时,可以拖拽滑动内容,decelerationRate属性控制手指松开后页面滑动的速度。 * 设置值越大手指松开后的滑动速度越快(滑动距离越长),其值域范围为0.0-1.0,默认值为0.989。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ decelerationRate?: number | undefined; @@ -11165,23 +11425,23 @@ interface PlusWebviewWebviewStyles { * - bottom: 控件停靠在页面底部 * - right: 控件停靠在页面右侧 * - left: 控件停靠在页面左侧 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - dock?: 'top' | 'bottom' | 'right' | 'left' | undefined; + dock?: "top" | "bottom" | "right" | "left" | undefined; /** * 窗口加载错误时跳转的页面地址 * 当Webview窗口无法加载指定的url地址时(如本地页面不存在,或者无法访问的网络地址),此时会自动跳转到指定的错误页面地址(仅支持本地页面地址)。 * 设置为“none”则关闭跳转到错误页面功能,此时页面显示Webview默认的错误页面内容。默认使用5+ Runtime内置的错误页面。 * - none: 关闭加载页面错误自动跳转功能 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - errorPage?: 'none' | undefined; + errorPage?: "none" | undefined; /** * 替换H5标准API * 用于解决在部分设备上调用H5标准定位接口可能无法获取定位数据的问题。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ replacewebapi?: PlusWebviewWebviewReplaceWebApiOptions | undefined; @@ -11189,7 +11449,7 @@ interface PlusWebviewWebviewStyles { * 窗口是否开启硬件加速 * 布尔类型,true表示开启硬件加速,false表示不开启硬件加速,默认情况5+ Runtime会根据设备实际支持情况自动选择是否开启硬件加速,可以通过plus.webview.defaultHardwareAccelerated()方法获取默认Webview是否开启硬件加速。 * 由于不同设备对硬件加速的支持情况存在差异,开启硬件加速能加速HTML页面的渲染,但也会消耗更多的系统资源,从而导致在部分设备上可能出现闪屏、发虚、分块渲染等问题,因此在特定设备的特定页面如果出现以上问题需要手动设置关闭硬件加速来避免。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ hardwareAccelerated?: boolean | undefined; @@ -11197,7 +11457,7 @@ interface PlusWebviewWebviewStyles { * 窗口的高度 * 支持百分比、像素值,默认为100%。 * 当未设置height属性值时,优先通过top和bottom属性值来计算窗口的高度。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ height?: string | undefined; @@ -11217,28 +11477,27 @@ interface PlusWebviewWebviewStyles { * 4. 不支持js原生混淆功能,需使用前端js混淆来替换; * 5. 内存不足时会白屏。 * 首页的Webview的kernel在manifest中配置(plus->kernel->ios)。 - * - WKWebview: + * - WKWebview: * 使用"WKWebview"内核。 - * - * - UIWebview: + * + * - UIWebview: * 使用"UIWebview"内核。 - * - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - kernel?: 'WKWebview' | 'UIWebview' | undefined; + kernel?: "WKWebview" | "UIWebview" | undefined; /** * 窗口水平向右的偏移量 * 支持百分比、像素值,默认值为0px。 * 未设置left属性值时,优先通过right和width属性值来计算窗口的left位置。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ left?: string | undefined; /** * 窗口的边距 * 用于定位窗口的位置,支持auto,auto表示居中。若设置了left、right、top、bottom则对应的边距值失效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ margin?: string | undefined; @@ -11249,14 +11508,14 @@ interface PlusWebviewWebviewStyles { * rgba格式字符串,定义纯色遮罩层样式,如"rgba(0,0,0,0.5)",表示黑色半透明; * "none",表示不使用遮罩层; * 默认值为"none",即无遮罩层。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ mask?: string | undefined; /** * 窗口的不透明度 * 0为全透明,1为不透明,默认值为1,即不透明。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ opacity?: number | undefined; @@ -11268,7 +11527,7 @@ interface PlusWebviewWebviewStyles { * "later" - 较晚在注入,在loaded事件发生后2s再注入,plusready事件同样延迟; * "none" - 不注入,页面无法调用5+ API,不触发plusready事件。 * 默认值为"normal"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ plusrequire?: string | undefined; @@ -11277,7 +11536,7 @@ interface PlusWebviewWebviewStyles { * 设置此属性则在Webview窗口的顶部显示进度条,可配置进度条颜色及高度。 * 设置此属性值为undefined或null则隐藏进度条。 * 默认不显示进度条。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ progress?: PlusWebviewWebviewProgressStyles | undefined; @@ -11290,15 +11549,15 @@ interface PlusWebviewWebviewStyles { * - none: 无侧滑返回功能 * - close: 侧滑返回关闭Webview窗口 * - hide: 侧滑返回隐藏webview窗口 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - popGesture?: 'none' | 'close' | 'hide' | undefined; + popGesture?: "none" | "close" | "hide" | undefined; /** * 窗口下拉刷新配置 * 设置窗口是否开启下拉刷新功能及样式。 * 开启下拉刷新后可通过监听窗口的"pullToRefresh"事件处理下拉刷新业务逻辑,更新操作完成后调用窗口的endPullToRefresh方法结束下拉刷新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ pullToRefresh?: PlusWebviewWebviewPullToRefreshStyles | undefined; @@ -11311,16 +11570,16 @@ interface PlusWebviewWebviewStyles { * 仅Android平台支持。 * - onscreen: Webview窗口在屏幕区可见时渲染,不可见时不进行渲染,此时能减少内存使用量 * - always: Webview在任何时候都渲染,在内存较大的设备上使用,被遮挡的窗口在此中模式下显示的时候会有更流畅的效果 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - render?: 'onscreen' | 'always' | undefined; + render?: "onscreen" | "always" | undefined; /** * 窗口水平向左的偏移量 * 支持百分比、像素值,默认无值(根据left和width属性值来自动计算)。 * 当设置了left和width值时,忽略此属性值; * 当未设置width值时,可通过left和bottom属性值来确定窗口的宽度。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ right?: string | undefined; @@ -11329,7 +11588,7 @@ interface PlusWebviewWebviewStyles { * 窗口设置为可缩放(scalable:true)时,用户可通过双指操作放大或缩小页面,此时html页面可通过meta节点设置“name="viewport" content="user-scalable=no"”来限制页面不可缩放。 * 窗口设置为不可缩放(scalable:false)时,用户不可通过双指操作放大或缩小页面,即使页面中的meta节点也无法开启可缩放功能。 * 默认值为false,即不可缩放。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ scalable?: boolean | undefined; @@ -11346,15 +11605,15 @@ interface PlusWebviewWebviewStyles { * - vertical: 仅显示垂直滚动条 * - horizontal: 仅显示水平滚动条 * - none: 垂直和水平滚动条都不显示 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - scrollIndicator?: 'all' | 'vertical' | 'horizontal' | 'none' | undefined; + scrollIndicator?: "all" | "vertical" | "horizontal" | "none" | undefined; /** * 点击设备的状态栏时是否滚动返回至顶部 * true表示点击设备的状态栏可以滚动返回至顶部,false表示点击设备的状态栏不可以,默认值为true。 * 此功能仅iOS平台支持,在iPhone上有且只有一个Webview窗口的scrollsToTop属性值为true时才生效,所以在显示和关闭Webview窗口时需动态更新所有Webview的scrollsToTop值,已确保此功能生效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ scrollsToTop?: boolean | undefined; @@ -11365,7 +11624,7 @@ interface PlusWebviewWebviewStyles { * true - 可分享窗口加载页面链接地址; * false - 不可分享窗口加载的页面链接地址,此时分享的是应用。 * 默认值值为true。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ shareable?: boolean | undefined; @@ -11375,14 +11634,14 @@ interface PlusWebviewWebviewStyles { * 默认值为“adjustPan”。 * - adjustPan: 弹出软键盘时Webview窗口自动上移,以保证当前输入框可见 * - adjustResize: 自动调整Webview窗口大小(屏幕区域减去软键盘区域),同时自动滚动Webview保证输入框可见 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - softinputMode?: 'adjustPan' | 'adjustResize' | undefined; + softinputMode?: "adjustPan" | "adjustResize" | undefined; /** * 窗口状态栏样式 * 仅在应用设置为沉浸式状态栏样式下有效,设置此属性后将自动保留系统状态栏区域不被Webview窗口占用(即Webview窗口非沉浸式样式显示)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ statusbar?: PlusWebviewWebviewStatusbarStyles | undefined; @@ -11390,15 +11649,15 @@ interface PlusWebviewWebviewStyles { * 定义窗口的原生子View控件 * 数组类型,可通过配置项设置原生子View控件,每个配置项对应添加一个原生子View控件。 * 通过Webview窗口的getSubNViews()方法可获取原生子View控件对象数组。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - subNViews?: PlusWebview [] | undefined; + subNViews?: PlusWebview[] | undefined; /** * 定义窗口的标题栏控件样式 * 设置此属性值则表明创建Webview窗口的标题栏控件,并可通过其属性值设置背景颜色、文本内容、文本颜色等。 * 通过Webview窗口的getTitleNView()方法可获取标题栏控件对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ titleNView?: PlusWebviewWebviewTitleNViewStyles | undefined; @@ -11406,19 +11665,19 @@ interface PlusWebviewWebviewStyles { * 窗口垂直向下的偏移量 * 支持百分比、像素值,默认值为0px。 * 未设置top属性值时,优先通过bottom和height属性值来计算窗口的top位置。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ top?: string | undefined; /** * 窗口定义窗口变换的动画效果 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ transition?: PlusWebviewWebviewTransition | undefined; /** * 窗口定义窗口变形效果 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ transform?: PlusWebviewWebviewTransform | undefined; @@ -11430,10 +11689,10 @@ interface PlusWebviewWebviewStyles { * - static: 控件在页面中正常定位,如果页面存在滚动条则随窗口内容滚动 * - absolute: 控件在页面中绝对定位,如果页面存在滚动条不随窗口内容滚动 * - dock: 控件在页面中停靠,停靠的位置由dock属性值决定 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - position?: 'static' | 'absolute' | 'dock' | undefined; + position?: "static" | "absolute" | "dock" | undefined; /** * 用户是否可选择内容 * 可取值: @@ -11441,7 +11700,7 @@ interface PlusWebviewWebviewStyles { * false - 表示不可选择内容,用户不可通过长按来选择页面内容。 * 默认值为true。 * 注意:在Web页面中可通过CSS的user-select对单个页面元素进行控制,前提是Webview对象的userSelect设置为true,否则CSS设置的user-select失效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ userSelect?: boolean | undefined; @@ -11449,27 +11708,27 @@ interface PlusWebviewWebviewStyles { * 视频全屏播放时的显示方向 * 可取值: * "auto": 自动适配,如果当前页面竖屏,则竖屏显示;如果当前页面横盘显示,则横屏;如果当前页面自动感应,则自动感应横竖屏切换。 - * "portrait-primary": 竖屏正方向; - * "portrait-secondary": 竖屏反方向,屏幕正方向按顺时针旋转180°; - * "landscape-primary": 横屏正方向,屏幕正方向按顺时针旋转90°; - * "landscape-secondary": 横屏方向,屏幕正方向按顺时针旋转270°; + * "portrait-primary": 竖屏正方向; + * "portrait-secondary": 竖屏反方向,屏幕正方向按顺时针旋转180°; + * "landscape-primary": 横屏正方向,屏幕正方向按顺时针旋转90°; + * "landscape-secondary": 横屏方向,屏幕正方向按顺时针旋转270°; * "landscape": 横屏正方向或反方向,根据设备重力感应器自动调整; * 默认值为“auto”。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ videoFullscreen?: string | undefined; /** * 窗口的宽度 * 支持百分比、像素值,默认为100%。未设置width属性值时,可同时设置left和right属性值改变窗口的默认宽度。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ width?: string | undefined; /** * 窗口的堆叠顺序值 * 拥有更高堆叠顺序的窗口总是会处于堆叠顺序较低的窗口的前面,拥有相同堆叠顺序的窗口后调用show方法则在前面。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ zindex?: number | undefined; @@ -11477,37 +11736,37 @@ interface PlusWebviewWebviewStyles { /** * 一组用于定义页面或控件变形的属性 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewTransform { /** * 暂不支持 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ rotate?: string | undefined; /** * 暂不支持 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ translate?: string | undefined; /** * 暂不支持 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ scale?: string | undefined; /** * 暂不支持 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ skew?: string | undefined; /** * 暂不支持 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ matrix?: string | undefined; @@ -11515,21 +11774,21 @@ interface PlusWebviewWebviewTransform { /** * 一组用于定义页面或控件转换效果的属性 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewTransition { /** * 产生变换效果的属性 * 默认值为"all",暂不支持其它值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ property?: string | undefined; /** * 变换持续的时间 * 默认值为0,即无动画效果。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ duration?: string | undefined; @@ -11541,7 +11800,7 @@ interface PlusWebviewWebviewTransition { * "ease-out":匀减速变化,逐渐变慢的动画效果; * "ease-in-out":先加速后减速变化,先变快后变慢的动画效果。 * 默认值为"ease-in-out"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ timingfunction?: string | undefined; @@ -11549,21 +11808,21 @@ interface PlusWebviewWebviewTransition { /** * 拦截Webview窗口资源请求的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewOverrideResourceOptions { /** * 区配需要拦截请求资源的URL地址 * 支持正则表达式,默认值为空字符串(即不拦截)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ match?: string | undefined; /** * 拦截重定向的资源地址 * 仅支持本地资源地址,如"_www"、"_doc"、"_downloads"、"_documents"等开头的路径。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ redirect?: string | undefined; @@ -11572,14 +11831,14 @@ interface PlusWebviewWebviewOverrideResourceOptions { * RFC2045/RFC2046/RFC2047/RFC2048/RFC2049规范中定义的数据类型。 * 如普通文本(text/plain)、PNG图像(image/png)、GIF图形(image/gif)、JPEG图形(image/jpeg)。 * 如果未指定mime类型,则根据重定向资源路径自动区配。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ mime?: string | undefined; /** * 重定向的资源数据编码 * 如未设置,则使用默认值"UTF-8"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ encoding?: string | undefined; @@ -11587,7 +11846,7 @@ interface PlusWebviewWebviewOverrideResourceOptions { * 设置重定向资源数据的http头数据 * 可设置标注http头数据(如Content-type),也可设置自定义数据。 * 通常可通过此属性来设置拦截资源的缓存策略(如Cache-control)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ header?: any; @@ -11595,7 +11854,7 @@ interface PlusWebviewWebviewOverrideResourceOptions { /** * 拦截Webview窗口URL请求的属性 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewOverrideUrlOptions { @@ -11605,37 +11864,35 @@ interface PlusWebviewWebviewOverrideUrlOptions { * "instant" - 表示立即生效,即调用overrideUrlLoading方法后立即生效; * "touchstart" - 表示用户操作Webview窗口(触发touchstart事件)后生效,如果用户没有操作Webview窗口则不对URL请求操作进行拦截处理。 * 默认值为"instant"。 - * - instant: + * - instant: * 立即生效,即调用overrideUrlLoading方法后立即生效。 - * - * - : + * + * - : * 表示用户操作Webview窗口(触发touchstart事件)后生效。 - * - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - effect?: 'instant' | '' | undefined; + effect?: "instant" | "" | undefined; /** * 拦截模式 * 可取值: * "allow"表示满足match属性定义的条件时不拦截url继续加载,不满足match属性定义的条件时拦截url跳转并触发callback回调; * "reject"表示满足match属性定义的提交时拦截url跳转并触发callback回调,不满足match属性定义的条件时不拦截url继续加载。 * 默认值为"reject"。 - * - allow: + * - allow: * 满足match属性定义的条件时不拦截url继续加载,不满足match属性定义的条件时拦截url跳转并触发callback回调。 - * - * - reject: + * + * - reject: * 满足match属性定义的提交时拦截url跳转并触发callback回调,不满足match属性定义的条件时不拦截url继续加载。 - * - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - mode?: 'allow' | 'reject' | undefined; + mode?: "allow" | "reject" | undefined; /** * 区配是否需要处理的URL请求 * 支持正则表达式,默认值为对所有URL地址生效(相当于正则表达式“.*”)。 * 如果mode值为"allow"则允许区配的URL请求跳转,mode值为"reject"则拦截区配的URL请求。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ match?: string | undefined; @@ -11646,21 +11903,20 @@ interface PlusWebviewWebviewOverrideUrlOptions { * "none"表示不排除任何URL请求(即拦截处理所有URL请求); * "redirect"表示排除拦截处理301/302跳转的请求(谨慎使用,非a标签的href触发的URL请求可能会误判断为302跳转)。 * 默认值为"none"。 - * - none: + * - none: * 不排除任何URL请求(即拦截处理所有URL请求)。 - * - * - redirect: + * + * - redirect: * 排除拦截处理301/302跳转的请求(谨慎使用,非a标签的href触发的URL请求可能会误判断为302跳转)。 - * - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ - exclude?: 'none' | 'redirect' | undefined; + exclude?: "none" | "redirect" | undefined; } /** * 监听Webview窗口资源加载的属性 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ interface PlusWebviewWebviewListenResourceOptions { @@ -11668,7 +11924,7 @@ interface PlusWebviewWebviewListenResourceOptions { * 区配是否需要处理的URL资源 * 支持正则表达式,默认值为对所有URL资源请求生效(相当于正则表达式“.*”)。 * 如果Webview加载的资源区配条件,则触发回调事件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/webview.html](http://www.html5plus.org/doc/zh_cn/webview.html) */ match?: string | undefined; @@ -11676,19 +11932,19 @@ interface PlusWebviewWebviewListenResourceOptions { /** * XMLHttpRequest模块管理网络请求,与标准HTML中的XMLHttpRequest用途一致,差别在于前者可以进行跨域访问。通过plus.net可获取网络请求管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ interface PlusNet { /** * 跨域网络请求对象 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ XMLHttpRequest?: PlusNetXMLHttpRequest | undefined; /** * HTTP请求进度事件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ ProgressEvent?: PlusNetProgressEvent | undefined; @@ -11696,7 +11952,7 @@ interface PlusNet { /** * 跨域网络请求对象 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ interface PlusNetXMLHttpRequest { @@ -11709,7 +11965,7 @@ interface PlusNetXMLHttpRequest { * 2 Sent,send()方法已调用,HTTP 请求已发送到Web服务器。未接收到响应。 * 3 Receiving,所有响应头部都已经接收到。响应体开始接收但未完成。 * 4 Loaded,HTTP响应已经完全接收。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ readyState?: number | undefined; @@ -11721,7 +11977,7 @@ interface PlusNetXMLHttpRequest { * 如果responseType设置为"document",则返回Document对象; * 如果responseType设置为"json",则返回JSON对象; * 若服务器返回的数据与设置的responseType类型不区配,则返回null。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ response?: string | undefined; @@ -11732,7 +11988,7 @@ interface PlusNetXMLHttpRequest { * 如果readyState为3,此属性值返回目前已经接收的HTTP响应部分数据值; * 如果readyState为4,此属性值保存了完整的HTTP响应数据体。 * 如果HTTP请求返回的数据头中包含了Content-Type值中指定字符编码,就使用该编码,否则,使用UTF-8字符集。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ responseText?: string | undefined; @@ -11740,7 +11996,7 @@ interface PlusNetXMLHttpRequest { * 请求响应数据response的类型 * 默认值为空字符串,即reponse为String,类型可设置:"document"表示Document对象,"json"表示JSON对象,"text"表示字符串。 * 此值必须在调用send方法之前设置,否则设置的值不生效,仍使用之前设置的值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ responseType?: string | undefined; @@ -11748,7 +12004,7 @@ interface PlusNetXMLHttpRequest { * 请求响应的Document对象 * 对请求的响应,解析为 XML 并作为 Document 对象返回。 * 如果请求未成功,或响应的数据无法被解析为XML,则返回null。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ responseXML?: string | undefined; @@ -11756,7 +12012,7 @@ interface PlusNetXMLHttpRequest { * 服务器返回的HTTP状态代码 * 服务器返回的HTTP状态代码,如200表示成功,而404表示"Not Found"错误; * 当readyState小于3的时候此属性值为0。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ status?: number | undefined; @@ -11765,7 +12021,7 @@ interface PlusNetXMLHttpRequest { * 此属性值用名称而不是数字指定了请求的HTTP的状态代码。 * 也就是说,当状态为200的时候它是"OK";当状态为404的时候它是"Not Found"。 * 和status属性类似,当readyState小于3的时候读取这一属性会返回空字符串。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ statusText?: string | undefined; @@ -11774,35 +12030,35 @@ interface PlusNetXMLHttpRequest { * 数值类型,单位为ms,其默认值为120秒。 * 超时时间为服务器响应请求的时间(不是Http请求完成的总时间),如果设置为0则表示永远不超时。 * 必须在请求发起前设置,否则当前请求将不生效,在当前请求完成后重新发起新请求时生效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ timeout?: number | undefined; /** * 是否支持跨域请求 * 此对象创建的HTTP请求都支持跨域,所以永远返回true。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ withCredentials?: boolean | undefined; /** * 网络请求状态发生变化事件 * 网络请求状态发生变化时触发,通常在函数中判断对象的state属性值来获取当前请求的状态。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ onreadystatechange?: (() => void) | undefined; /** * 网络请求开始事件 * 通常在调用send方法开始发起HTTP请求时触发。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ onloadstart?: ((result: PlusNetProgressEvent) => void) | undefined; /** * 网络请求传输数据事件 * 通常在HTTP请求链接已经建立,开始传输数据时触发,在数据传输的过程中可能多次触发,此事件与onreadystatechange事件触发状态3类似。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ onprogress?: ((result: PlusNetProgressEvent) => void) | undefined; @@ -11810,7 +12066,7 @@ interface PlusNetXMLHttpRequest { * 网络请求取消事件 * 通常在调用abort方法取消HTTP请求时触发。 * 此事件在onreadystatechange事件触发状态4事件之后。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ onabort?: ((result: PlusNetProgressEvent) => void) | undefined; @@ -11818,7 +12074,7 @@ interface PlusNetXMLHttpRequest { * 网络请求错误事件 * 通常在HTTP请求发生错误时触发,如无法连接到服务器等各种错误都触发此事件。 * 此事件在onreadystatechange事件触发状态4事件之后。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ onerror?: ((result: PlusNetProgressEvent) => void) | undefined; @@ -11826,7 +12082,7 @@ interface PlusNetXMLHttpRequest { * 网络请求成功事件 * 通常在HTTP请求成功完成时触发,如果HTTP请求发生错误则不触发此事件。 * 此事件在onreadystatechange事件触发状态4事件之后。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ onload?: ((result: PlusNetProgressEvent) => void) | undefined; @@ -11834,7 +12090,7 @@ interface PlusNetXMLHttpRequest { * 网络请求超时事件 * 通常在HTTP请求超时时触发,此时不会触发onerror事件。 * 此事件在onreadystatechange事件触发状态4事件之后。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ ontimeout?: ((result: PlusNetProgressEvent) => void) | undefined; @@ -11842,7 +12098,7 @@ interface PlusNetXMLHttpRequest { * 网络请求结束事件 * 通常在HTTP请求结束时触发,不管是HTTP请求失败、成功、或超时之后都会触发此事件。 * 此事件在onreadystatechange事件触发状态4事件之后。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ onloadend?: ((result: PlusNetProgressEvent) => void) | undefined; @@ -11851,7 +12107,7 @@ interface PlusNetXMLHttpRequest { * 此方法把XMLHttpRequest对象重置为readyState为0的状态,并且取消所有未决的网络活动。 * 调用此方法后将停止触发XMLHttpRequest对象的所有事件。 * 例如,如果请求用了太长时间,而且响应不再必要的时候,可以调用这个方法。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ abort(): void; @@ -11859,7 +12115,7 @@ interface PlusNetXMLHttpRequest { * 获取HTTP响应头部信息 * 把HTTP响应头部作为未解析的字符串返回。 如果readyState小于3,这个方法返回null。 * 否则,它返回服务器发送的所有 HTTP 响应的头部。头部作为单个的字符串返回,一行一个头部。每行用换行符"\r\n"隔开。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ getAllResponseHeaders(): string; @@ -11868,7 +12124,7 @@ interface PlusNetXMLHttpRequest { * 其参数是要返回的 HTTP 响应头部的名称。可以使用任何大小写来制定这个头部名字,和响应头部的比较是不区分大小写的。 * 该方法的返回值是指定的 HTTP 响应头部的值,如果没有接收到这个头部或者readyState小于3则为空字符串。 * 如果接收到多个有指定名称的头部,这个头部的值被连接起来并返回,使用逗号和空格分隔开各个头部的值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ getResponseHeader(headerName?: string): string; @@ -11879,7 +12135,7 @@ interface PlusNetXMLHttpRequest { * 当针对任何其他状态调用的时候,open()方法的行为是为指定的。 * 除了保存供send()方法使用的请求参数,以及重置 XMLHttpRequest 对象以便复用,open()方法没有其他的行为。 * 要特别注意,当这个方法调用的时候,实现通常不会打开一个到Web服务器的网络连接。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ open(method?: string, url?: string, username?: string, password?: string): void; @@ -11888,13 +12144,13 @@ interface PlusNetXMLHttpRequest { * 此方法覆盖HTTP请求返回数据头"Content-Type"字段值中包含的IMIE类型,如果设置的MIME类型无效则继续使用"Content-Type"字段值中包含的IMIE类型。 * 如果MIME类型中指定了字符集类型(charset),则需按照指定的字符集类型对接收到的数据体(respose)进行处理,否则默认为UTF-8字符集。 * 注意:此方法需在send方法前调用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ overrideMimeType(mime?: string): void; /** * 发送HTTP请求 - * 此方法触发HTTP请求发送,如果之前没有调用open(),或者更具体地说,如果readyState不是1,send()抛出一个异常。否则,将发送HTTP请求,该请求由以下几部分组成: + * 此方法触发HTTP请求发送,如果之前没有调用open(),或者更具体地说,如果readyState不是1,send()抛出一个异常。否则,将发送HTTP请求,该请求由以下几部分组成: * 之前调用open()时指定的HTTP方法、URL; * 之前调用setRequestHeader()时指定的请求头部(如果有的话); * 传递给这个方法的body参数。 @@ -11903,7 +12159,7 @@ interface PlusNetXMLHttpRequest { * 当所有的HTTP响应头部已经接收,send()或后台线程把readyState设置为3并触发onreadystatechange事件; * 如果响应较长,send()或后台线程可能在状态3中触发多次onreadystatechange事件; * 最后,当响应完成,send()或后台线程把readyState设置为4,并最后一次触发onreadystatechange事件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ send(body?: string): void; @@ -11913,7 +12169,7 @@ interface PlusNetXMLHttpRequest { * 此方法只有当readyState为1的时候才能调用,例如,在调用了open()之后,但在调用send()之前。 * 如果带有指定名称的头部已经被指定了,这个头部的新值就是:之前指定的值,加上逗号、以及这个调用指定的值(形成一个数组)。 * 如果Web服务器已经保存了和传递给open()的URL相关联的cookie,适当的Cookie或Cookie2头部也自动地包含到请求中,可以通过调用setRequestHeader()来把这些cookie添加到头部。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ setRequestHeader(headerName?: string, headerValue?: string): void; @@ -11921,28 +12177,28 @@ interface PlusNetXMLHttpRequest { /** * HTTP请求进度事件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ interface PlusNetProgressEvent { /** * 事件的目标对象 * 通知HTTP请求进度事件的XMLHttpRequest对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ target?: PlusNetXMLHttpRequest | undefined; /** * 进度信息是否可计算 * HTTP请求进度信息是否有效,如果HTTP请求头中包含Content-Length头信息则为true,否则为false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ lengthComputable?: number | undefined; /** * 当前已经接收到的数据长度 * HTTP请求接收到的数据长度,单位为字节。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ loaded?: number | undefined; @@ -11950,7 +12206,7 @@ interface PlusNetProgressEvent { * 总数据长度 * HTTP请求返回的总数据长度,单位为字节。 * 如果无法获取则设置为0。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/net.html](http://www.html5plus.org/doc/zh_cn/net.html) */ total?: number | undefined; @@ -11958,7 +12214,7 @@ interface PlusNetProgressEvent { /** * Zip模块管理文件压缩和解压,通过plus.zip可获取压缩管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) */ interface PlusZip { @@ -11968,35 +12224,39 @@ interface PlusZip { * 设置rotate属性则表示需对图片进行旋转转换操作; * 设置clip属性则表示需对图片进行裁剪转换操作; * 如同时设置了多个转换操作,则按缩放、旋转、裁剪顺序进行操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) */ CompressImageOptions?: PlusZipCompressImageOptions | undefined; /** * JSON对象,图片裁剪区域的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) */ ClipImageOptions?: PlusZipClipImageOptions | undefined; /** * 压缩生成Zip文件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) */ compress(src?: string, zipfile?: string, successCB?: () => void, errorCB?: (result: any) => void): void; /** * 解压缩Zip文件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) */ decompress(zipfile?: string, target?: string, successCB?: () => void, errorCB?: (result: any) => void): void; /** * 图片压缩转换 * 可用于图片的质量压缩、大小缩放、方向旋转、区域裁剪、格式转换等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) */ - compressImage(options?: PlusZipCompressImageOptions, successCB?: (result: any) => void, errorCB?: (result: any) => void): void; + compressImage( + options?: PlusZipCompressImageOptions, + successCB?: (result: any) => void, + errorCB?: (result: any) => void, + ): void; } /** @@ -12005,7 +12265,7 @@ interface PlusZip { * 设置rotate属性则表示需对图片进行旋转转换操作; * 设置clip属性则表示需对图片进行裁剪转换操作; * 如同时设置了多个转换操作,则按缩放、旋转、裁剪顺序进行操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) */ interface PlusZipCompressImageOptions { @@ -12020,10 +12280,10 @@ interface PlusZipCompressImageOptions { * - _doc/: 应用私有文档目录 * - _documents/: 共享文档目录 * - _downloads/: 共享下载目录 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) */ - src?: '_www/' | '_doc/' | '_documents/' | '_downloads/' | undefined; + src?: "_www/" | "_doc/" | "_documents/" | "_downloads/" | undefined; /** * 压缩转换目标图片的路径 * 支持以下图片路径: @@ -12034,17 +12294,17 @@ interface PlusZipCompressImageOptions { * - _doc/: 应用私有文档目录 * - _documents/: 共享文档目录 * - _downloads/: 共享下载目录 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) */ - dst?: '_doc/' | '_documents/' | '_downloads/' | undefined; + dst?: "_doc/" | "_documents/" | "_downloads/" | undefined; /** * 覆盖生成新文件 * 仅在dst制定的路径文件存在时有效: * true表示覆盖存在的文件; * false表示不覆盖,如果文件存在,则返回失败。 * 默认值为false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) */ overwrite?: boolean | undefined; @@ -12053,15 +12313,15 @@ interface PlusZipCompressImageOptions { * 支持"jpg"、"png",如果未指定则使用源图片的格式。 * - jpg: JPG格式图片 * - png: PNG格式图片 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) */ - format?: 'jpg' | 'png' | undefined; + format?: "jpg" | "png" | undefined; /** * 压缩图片的质量 * 取值范围为1-100,1表示使用最低的图片质量(转换后的图片文件最小)、100表示使用最高的图片质量(转换后的图片文件最大); * 默认值为50。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) */ quality?: number | undefined; @@ -12070,7 +12330,7 @@ interface PlusZipCompressImageOptions { * 支持像素值(如"100px")、百分比(如"50%")、自动计算(如"auto",即根据height与源图高的缩放比例计算,若未设置height则使用源图高度); * 默认值为"auto"。 * 注意:若设置了width属性值不合法(如"0px"),则不对图片进行缩放操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) */ width?: string | undefined; @@ -12079,7 +12339,7 @@ interface PlusZipCompressImageOptions { * 支持像素值(如"100px")、百分比(如"50%")、自动计算(如"auto",即根据width与源图宽的缩放比例计算,若未设置width则使用源图高度); * 默认值为"auto"。 * 注意:若设置了height属性值不合法(如"0px"),则不对图片进行缩放操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) */ height?: string | undefined; @@ -12090,14 +12350,14 @@ interface PlusZipCompressImageOptions { * - 90: 旋转90度 * - 180: 旋转180度 * - 270: 旋转270度 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) */ - rotate?: '90' | '180' | '270' | undefined; + rotate?: "90" | "180" | "270" | undefined; /** * 裁剪图片的区域 * 值参考ClipImageOptions定义,若设置clip属性值不合法,则不对图片进行裁剪操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) */ clip?: PlusZipClipImageOptions | undefined; @@ -12105,7 +12365,7 @@ interface PlusZipCompressImageOptions { /** * JSON对象,图片裁剪区域的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) */ interface PlusZipClipImageOptions { @@ -12113,7 +12373,7 @@ interface PlusZipClipImageOptions { * 图片裁剪区域与原图片上边界的偏移距离 * 支持像素值(如"10px")、百分比(如"10%");默认值为"0px"。 * 注意:如果top值超出原图片高度,则图片裁剪失败。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) */ top?: string | undefined; @@ -12121,7 +12381,7 @@ interface PlusZipClipImageOptions { * 图片裁剪区域与原图片左边界的偏移距离 * 支持像素值(如"10px")、百分比(如"10%");默认值为"0px"。 * 注意:如果left值超出原图片宽度,则图片裁剪失败。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) */ left?: string | undefined; @@ -12129,7 +12389,7 @@ interface PlusZipClipImageOptions { * 图片裁剪区域的宽度 * 支持像素值(如"100px")、百分比(如"50%")、自动计算(如"auto",即从left位置到图片右边界的宽度);默认值为"auto"。 * 注意:如果left值加width值超出原图片宽度,则使用"auto"值进行裁剪。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) */ width?: string | undefined; @@ -12137,7 +12397,7 @@ interface PlusZipClipImageOptions { * 图片裁剪区域的高度 * 支持像素值(如"100px")、百分比(如"50%")、自动计算(如"auto",即从top位置到图片下边界的高度);默认值为"auto"。 * 注意:如果top值加height值超出原图片高度,则使用"auto"值进行裁剪。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/zip.html](http://www.html5plus.org/doc/zh_cn/zip.html) */ height?: string | undefined; @@ -12145,28 +12405,28 @@ interface PlusZipClipImageOptions { /** * Barcode模块管理条码扫描,支持常见的条码(一维码及二维码)的扫描识别功能。可调用设备的摄像头对条码图片扫描进行数据输入,解码后返回码数据及码类型。通过plus.barcode可获取条码码管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ interface PlusBarcode { /** * Barcode扫码控件对象 * Barcode对象表示条码识别控件对象,在窗口中显示条码识别控件,使用此对象可自定义条码识别界面。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ Barcode?: PlusBarcodeBarcode | undefined; /** * Barcode扫码控件样式 * 设置Barcode扫码控件的样式,如扫码框、扫码条的颜色等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ BarcodeStyles?: PlusBarcodeBarcodeStyles | undefined; /** * 条码识别控件扫描参数 * 设置Barcode扫码控件的扫码识别参数,如是否保存扫码功时的截图等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ BarcodeOptions?: PlusBarcodeBarcodeOptions | undefined; @@ -12174,7 +12434,7 @@ interface PlusBarcode { * QR二维码,数值为0 * 1994年由日本Denso-Wave公司发明,QR来自英文Quick Response的缩写,即快速反应的意思,源自发明者希望QR码可让其内容快速被解码。 * 目前使用最广泛的二维码。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ QR?: number | undefined; @@ -12182,127 +12442,132 @@ interface PlusBarcode { * EAN条形码标准版,数值为1 * 国际物品编码协会在全球推广应用的商品条码,是由13位数字组成。 * 目前使用最广泛的一维条形码。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ EAN13?: number | undefined; /** * ENA条形码简版,数值为2 * 国际物品编码协会在全球推广应用的商品条码,是由8位数字组成。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ EAN8?: number | undefined; /** * Aztec二维码,数值为3 * Andrew Longacre发明于1995年,该代码是用于国际出版。最小的Aztec码符号编码13个数字或12个英文字母。最大的Aztec码符号编码3832数字或3067英文字母或1914字节的数据。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ AZTEC?: number | undefined; /** * Data Matrix二维码,数值为4 * Data Matrix原名Data code,由美国国际资料公司(International Data Matrix, 简称IDMatrix)于1989年发明。可编码字元集包括全部的ASCII字元及扩充ASCII字元,容量可包含2235个英文数字资料、1556个8位元资料,3116个数字资料。由于Data Matrix二维条码只需要读取资料的20%即可精确辨读,因此很适合应用在条码容易受损的场所。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ DATAMATRIX?: number | undefined; /** * UPC条形码标准版,数值为5 * UPC码是美国统一代码委员会制定的一种商品用条码,主要用于美国和加拿大地区,常在美国进口的商品上可以看到。UPC码标准版由12位数字构成,故其字码集为数字0~9。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ UPCA?: number | undefined; /** * UPC条形码缩短版,数值为6 * UPC码是美国统一代码委员会制定的一种商品用条码,主要用于美国和加拿大地区,常在美国进口的商品上可以看到。UPC码缩短版由8位数字构成,故其字码集为数字0~9。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ UPCE?: number | undefined; /** * Codabar条形码,数值为7 * Codabar码最初是为零售价格标签系统而研制开发的。1975年,National Retail Merchants Association(NRMA)选择了其它符号类型作为标准后,Codabar开始在多个方面用于非零售应用领域,如图书馆、货运和医药业。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ CODABAR?: number | undefined; /** * Code39条形码,数值为8 * Code 39码是Intermec公司于1975年推出的一维条码, 39码是一种可供使用者双向扫瞄的分散式条码,也就是说相临两资料码之间,39码必须包含一个不具任何意义的空白(或细白,其逻辑值为0),且 39码具有支援文数字的能力,编码规则简单、误码率低、所能表示字符个数多等特点,39码在各个领域有着极为广泛的应用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ CODE39?: number | undefined; /** * Code93条形码,数值为9 * Code 93码的条码符号是由Intermec公司于1982年设计的 提供更高的密度和数据安全增强code39 。它是一个字母,长度可变符号。代码93主要用于由加拿大邮政编码补充提供的资料。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ CODE93?: number | undefined; /** * Code128条形码,数值为10 * CODE128码是1981年引入的一种高密度条码,CODE128 码可表示从 ASCII 0 到ASCII 127 共128个字符,故称128码。CODE128码是广泛应用在企业内部管理、生产流程、物流控制系统方面的条码码制,由于其优良的特性在管理信息系统的设计中被广泛使用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ CODE128?: number | undefined; /** * ITF条形码,数值为11 * ITF条码,又称交叉二五条码,由14位数字字符代表组成。主要用于运输包装,是印刷条件较差,不允许印刷EAN-13和UPC-A条码时应选用的一种条码。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ ITF?: number | undefined; /** * MaxiCode二维码,数值为12 * 1996年时,美国自动辨识协会(AIMUSA)制定统一的符号规格,称为Maxicode二维条码,也有人称USS-Maxicode二维条码(Uniform Symbology Specification-Maxicode)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ MAXICODE?: number | undefined; /** * PDF 417二维条码,数值为13 * PDF417条码是由美国SYMBOL公司发明的,PDF(Portable Data File)意思是“便携数据文件”。组成条码的每一个条码字符由4个条和4个空共17个模块构成,故称为PDF417条码。PDF417条码最大的优势在于其庞大的数据容量和极强的纠错能力。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ PDF417?: number | undefined; /** * RSS 14条形组合码,数值为14 * RSS条码是有国际物品编码协会EAN和美国统一代码委员会UCC开发的RSS(Reduced Space Symbology)条码符号。它是一种一维码和二维码的组合码。和其它线性条码相比,RSS系列码制具有更高的密度,因为它可以表示更多的字符。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ RSS14?: number | undefined; /** * 扩展式RSS条形组合码,数值为15 * RSS条码是有国际物品编码协会EAN和美国统一代码委员会UCC开发的RSS(Reduced Space Symbology)条码符号。它是一种一维码和二维码的组合码。和其它线性条码相比,RSS系列码制具有更高的密度,因为它可以表示更多的字符。扩展式RSS码是长度可以变化的线性码制,能够对74个数字字符或41个字母字符的AI单元数据传数据进行编码。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ RSSEXPANDED?: number | undefined; /** * 通过图片扫码识别 * 直接输入图片扫码识别,成功扫描到条码数据后通过successCallback回调返回,失败则通过errorCallback回调返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ - scan(path?: string, successCB?: (result0: number, result1: string, result2: string) => void, errorCB?: (result: any) => void, filters?: any []): void; + scan( + path?: string, + successCB?: (result0: number, result1: string, result2: string) => void, + errorCB?: (result: any) => void, + filters?: any[], + ): void; /** * 创建Barcode对象 * 调用此方法创建后并不会显示,需要调用Webview窗口的append方法将其添加到Webview窗口后才能显示。 * 注意:此时需要通过styles参数的top/left/width/height属性设置控件的位置及大小。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ - create(id?: string, filters?: any [], styles?: PlusBarcodeBarcodeStyles): PlusBarcodeBarcode; + create(id?: string, filters?: any[], styles?: PlusBarcodeBarcodeStyles): PlusBarcodeBarcode; /** * 查找已经创建的Barcode对象 * 调用此方法查找指定id的Barcode对象,如果不存在则返回null。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ getBarcodeById(id?: string): PlusBarcodeBarcode; @@ -12311,28 +12576,28 @@ interface PlusBarcode { /** * Barcode扫码控件对象 * Barcode对象表示条码识别控件对象,在窗口中显示条码识别控件,使用此对象可自定义条码识别界面。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ interface PlusBarcodeBarcode { /** * 条码识别成功事件 * Barcode扫码控件识别到有效的条码数据时触发的成功事件,并返回扫码结果。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ onmarked?: ((result0: number, result1: string, result2: string) => void) | undefined; /** * 条码识别错误事件 * 描控件识别过程中发生错误时触发的失败事件,并返回错误信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ onerror?: ((result: any) => void) | undefined; /** * 开始条码识别 * 开始调用系统摄像头获取图片数据进行扫码识别,当识别出条码数据时通过onmarked回调函数返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ start(optons?: PlusBarcodeBarcodeOptions): void; @@ -12340,28 +12605,28 @@ interface PlusBarcodeBarcode { * 结束条码识别 * 结束对摄像头获取图片数据进行条码识别操作,同时关闭摄像头的视频捕获。 * 结束后可调用start方法重新开始识别。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ cancel(): void; /** * 关闭条码识别控件 * 释放控件占用系统资源,调用close方法后控件对象将不可使用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ close(): void; /** * 是否开启闪光灯 * 设置Barcode扫码控件在扫码时是否开启摄像头的闪光灯,默认值为不开启闪光灯。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ setFlash(open?: boolean): void; /** * 设置Barcode扫码控件的配置参数 * 用于动态更新Barcode扫码控件的参数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ setStyles(styles?: PlusBarcodeBarcodeStyles): void; @@ -12370,28 +12635,28 @@ interface PlusBarcodeBarcode { /** * Barcode扫码控件样式 * 设置Barcode扫码控件的样式,如扫码框、扫码条的颜色等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ interface PlusBarcodeBarcodeStyles { /** * 条码识别控件背景颜色 * 颜色值支持(参考CSS颜色规范):颜色名称(参考CSS Color Names)/十六进制值/rgb值,默认值为红色。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ background?: string | undefined; /** * 扫码框颜色 * 颜色值支持(参考CSS颜色规范):颜色名称(参考CSS Color Names)/十六进制值/rgb值/rgba值,默认值为红色。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ frameColor?: string | undefined; /** * 扫码条颜色 * 颜色值支持(参考CSS颜色规范):颜色名称(参考CSS Color Names)/十六进制值/rgb值/rgba值,默认值为红色。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ scanbarColor?: string | undefined; @@ -12401,7 +12666,7 @@ interface PlusBarcodeBarcodeStyles { * 像素值,如"100px"; * 百分比,如"10%",相对于父Webview窗口的高度; * 自动计算,如"auto",根据height值自动计算,相对于父Webview窗口垂直居中。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ top?: string | undefined; @@ -12412,7 +12677,7 @@ interface PlusBarcodeBarcodeStyles { * 百分比,如"10%",相对于父Webview窗口的宽度; * 自动计算,如"auto",根据width值自动计算,相对于父Webview窗口水平居中。 * 默认值为"0px"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ left?: string | undefined; @@ -12422,7 +12687,7 @@ interface PlusBarcodeBarcodeStyles { * 像素值,如"100px"; * 百分比,如"10%",相对于父Webview窗口的宽度。 * 默认值为"100%"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ width?: string | undefined; @@ -12432,7 +12697,7 @@ interface PlusBarcodeBarcodeStyles { * 像素值,如"100px"; * 百分比,如"10%",相对于父Webview窗口的高度。 * 默认值为"100%"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ height?: string | undefined; @@ -12442,7 +12707,7 @@ interface PlusBarcodeBarcodeStyles { * "static" - 静态布局模式,如果页面存在滚动条则随窗口内容滚动; * "absolute" - 绝对布局模式,如果页面存在滚动条不随窗口内容滚动; * 默认值为"static"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ position?: string | undefined; @@ -12451,7 +12716,7 @@ interface PlusBarcodeBarcodeStyles { /** * 条码识别控件扫描参数 * 设置Barcode扫码控件的扫码识别参数,如是否保存扫码功时的截图等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ interface PlusBarcodeBarcodeOptions { @@ -12459,14 +12724,14 @@ interface PlusBarcodeBarcodeOptions { * 是否保存扫码成功时的截图 * 如果设置为true则在扫码成功时将图片保存,并通过onmarked回调函数的file参数返回保存文件的路径。 * 默认值为false,不保存截图。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ conserve?: boolean | undefined; /** * 保存扫码成功时图片保存路径 * 可通过此参数设置保存截图的路径和名称,如果设置图片文件名称则必须指定文件的后缀名(必须是.png),否则认为是指定目录,文件名称则自动生成。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ filename?: string | undefined; @@ -12474,7 +12739,7 @@ interface PlusBarcodeBarcodeOptions { * 扫码成功时是否需要震动提醒 * 如果设置为true则在扫码成功时震动设备,false则不震动。 * 默认值为true。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ vibrate?: boolean | undefined; @@ -12486,148 +12751,148 @@ interface PlusBarcodeBarcodeOptions { * 默认值为"default"。 * - none: 扫码成功时不播放提示音 * - default: 扫码成功时播放默认提示音 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/barcode.html](http://www.html5plus.org/doc/zh_cn/barcode.html) */ - sound?: 'none' | 'default' | undefined; + sound?: "none" | "default" | undefined; } /** * Maps模块管理地图控件,用于在web页面中显示地图控件,提供各种接口操作地图控件,如添加标点、路线等。通过plus.maps可获取地图管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ interface PlusMaps { /** * 地图控件对象 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ Map?: PlusMapsMap | undefined; /** * 地图控件对象的参数 * 设置地图对象显示时使用的参数,如地图的中心位置、缩放级别等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ MapStyles?: PlusMapsMapStyles | undefined; /** * 地理编码转换的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ GeocodeOptions?: PlusMapsGeocodeOptions | undefined; /** * 地图坐标转换的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ CoordinateConvertOptions?: PlusMapsCoordinateConvertOptions | undefined; /** * Point对象用于表示地图元素的坐标 * 常用语对地图上元素进行定位时使用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ Point?: PlusMapsPoint | undefined; /** * 地理区域 * 有西南及东北坐标点数据组成的矩形区域。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ Bounds?: PlusMapsBounds | undefined; /** * 地图视图类型 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ MapType?: PlusMapsMapType | undefined; /** * 地图覆盖物基类对象 * Overlay是地图上显示元素的基类,用于抽象地图元素,不用于实例化。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ Overlay?: PlusMapsOverlay | undefined; /** * 地图上显示的标点对象 * 从Overlay对象继承而来,可通过Map对象的addOverlay()方法将对象添加地图中。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ Marker?: PlusMapsMarker | undefined; /** * 地图上显示的气泡对象 * 此对象不能直接添加到地图上显示,只可关联到地图标点覆盖物上,用户点击标点时弹出显示。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ Bubble?: PlusMapsBubble | undefined; /** * 地图上显示的圆圈对象 * 从Overlay对象继承而来,可通过Map对象的addOverlay()方法将对象添加地图中。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ Circle?: PlusMapsCircle | undefined; /** * 地图上显示的折线对象 * 从Overlay对象继承而来,可通过Map对象的addOverlay()方法将对象添加地图中。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ Polyline?: PlusMapsPolyline | undefined; /** * 地图上显示的多边形对象 * 从Overlay对象继承而来,可通过Map对象的addOverlay()方法将对象添加地图中。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ Polygon?: PlusMapsPolygon | undefined; /** * 地图检索对象 * Search对象用于管理地图上的检索功能,包括位置检索、周边检索和范围检索。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ Search?: PlusMapsSearch | undefined; /** * 检索策略类型 * 在线路检索时设置检索策略时使用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ SearchPolicy?: PlusMapsSearchPolicy | undefined; /** * 保存位置检索、周边检索和范围检索返回的结果 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ SearchPoiResult?: PlusMapsSearchPoiResult | undefined; /** * 保存位置检索、周边检索和范围检索返回的结果 * 不可通过new操作符创建SearchRouteResult对象,在触发onRouteSearchComplete()时自动创建。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ SearchRouteResult?: PlusMapsSearchRouteResult | undefined; /** * 检索结果的位置点 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ Position?: PlusMapsPosition | undefined; /** * 地图中的路线对象 * 从Overlay对象继承而来,可通过Map对象的addOverlay()方法将对象添加地图中。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ Route?: PlusMapsRoute | undefined; /** * 调用系统第三方程序进行导航 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ openSysMap(dst?: PlusMapsPoint, des?: string, src?: PlusMapsPoint): void; @@ -12635,14 +12900,14 @@ interface PlusMaps { * 创建Map对象 * 调用此方法创建后并不会显示,需要调用Webview窗口的append方法将其添加到Webview窗口后才能显示。 * 注意:此时需要通过styles参数的top/left/width/height属性设置控件的位置及大小。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ create(id?: string, styles?: PlusMapsMapStyles): PlusMapsMap; /** * 查找已经创建的Map对象 * 调用此方法查找指定id的Map对象,如果不存在则返回null。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getMapById(id?: string): PlusMapsMap; @@ -12650,20 +12915,20 @@ interface PlusMaps { /** * 地图控件对象 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ interface PlusMapsMap { /** * 用户点击地图事件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ onclick?: ((result: PlusMapsPoint) => void) | undefined; /** * 地图状态改变事件 * 用户拖动、缩放地图等操作完成后触发。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ onstatuschanged?: ((result: any) => void) | undefined; @@ -12671,48 +12936,72 @@ interface PlusMapsMap { * 静态方法,计算面积 * 计算指定地理区域的面积,单位为平方米。 * 注:此功能仅百度地图支持,高德地图暂不支持此功能。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ - calculateArea(bounds?: PlusMapsBounds, successCallback?: (result: any) => void, errorCallback?: (result: any) => void): void; + calculateArea( + bounds?: PlusMapsBounds, + successCallback?: (result: any) => void, + errorCallback?: (result: any) => void, + ): void; /** * 静态方法,计算距离 * 计算从pointStart坐标点到pointEnd坐标的实际直线距离,单位为米(m)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ - calculateDistance(pointStart?: PlusMapsPoint, pointEnd?: PlusMapsPoint, successCallback?: (result: any) => void, errorCallback?: (result: any) => void): void; + calculateDistance( + pointStart?: PlusMapsPoint, + pointEnd?: PlusMapsPoint, + successCallback?: (result: any) => void, + errorCallback?: (result: any) => void, + ): void; /** * 静态方法,坐标转换 * 将第三方坐标系坐标转换成当前地图的坐标系坐标。 * 转换成功通过successCallback返回,转换失败则通过errorCallback返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ - convertCoordinates(point?: PlusMapsPoint, options?: PlusMapsCoordinateConvertOptions, successCallback?: (result: any) => void, errorCallback?: (result: any) => void): void; + convertCoordinates( + point?: PlusMapsPoint, + options?: PlusMapsCoordinateConvertOptions, + successCallback?: (result: any) => void, + errorCallback?: (result: any) => void, + ): void; /** * 静态方法,地理编码 * 将地理位置信息转换为坐标点。 * 转换成功通过successCallback返回,转换失败则通过errorCallback返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ - geocode(address?: string, options?: PlusMapsGeocodeOptions, successCallback?: (result: any) => void, errorCallback?: (result: any) => void): void; + geocode( + address?: string, + options?: PlusMapsGeocodeOptions, + successCallback?: (result: any) => void, + errorCallback?: (result: any) => void, + ): void; /** * 静态方法,反向地理编码 * 将坐标点转换为地理位置信息。 * 转换成功通过successCallback返回,转换失败则通过errorCallback返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ - reverseGeocode(point?: PlusMapsPoint, options?: PlusMapsGeocodeOptions, successCallback?: (result: any) => void, errorCallback?: (result: any) => void): void; + reverseGeocode( + point?: PlusMapsPoint, + options?: PlusMapsGeocodeOptions, + successCallback?: (result: any) => void, + errorCallback?: (result: any) => void, + ): void; /** * 向地图中添加覆盖物 * 此方法用于向地图中添加覆盖物。 * 支持各种从maps.Overlay对象继承的各种覆盖物对象; * 如果添加不支持的对象则直接返回false; * 同一覆盖物对象只能添加到地图中一次,已在地图中的覆盖物再次添加时则返回false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ addOverlay(overlay?: PlusMapsOverlay): boolean; @@ -12722,7 +13011,7 @@ interface PlusMapsMap { * 默认中心点为天安门,默认缩放级别为12; * 该方法设置的中心点和缩放级别可通过reset()方法恢复; * 如果在地图显示后调用将改变地图的中心点和缩放级别并立即更新,并将初始值更新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ centerAndZoom(center?: PlusMapsPoint, zoom?: number): void; @@ -12730,41 +13019,41 @@ interface PlusMapsMap { * 清除地图中所有覆盖物对象 * 此方法用于清除地图中所有覆盖物对象。 * 清除地图中的覆盖物对象后会自动更新地图视图。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ clearOverlays(): void; /** * 关闭地图控件 * 关闭地图控件将会销毁地图使用的资源,不可再使用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ close(): void; /** * 获取当前地图可视范围的地理区域 * 当旋转或俯视时,是当前地图可视范围的最大外接矩形地理区域。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getBounds(): PlusMapsBounds; /** * 获取地图中心点位置 * 此方法用于获取设置的地图中心点位置(centerAndZoom/setCenter)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getCenter(): PlusMapsPoint; /** * 获取当前地图显示的地图中心点位置 * 此方法用于获取当前地图显示的地图中心点位置,获取成功后通过callback回调返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getCurrentCenter(callback?: (result0: number, result1: PlusMapsPoint) => void): boolean; /** * 获取地图的显示类型 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getMapType(): PlusMapsMapType; @@ -12772,7 +13061,7 @@ interface PlusMapsMap { * 获取用户的当前位置信息 * 此方法用于获取用户的当前位置信息,获取成功后通过callback回调返回。 * 获取用户当前位置信息将打开定位设备。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getUserLocation(callback?: (result0: number, result1: PlusMapsPoint) => void): boolean; @@ -12781,7 +13070,7 @@ interface PlusMapsMap { * 此方法用于设置地图的缩放级别,用于切换当前显示地图缩放级别。 * 该方法改变缩放级别后地图显示内容将立即更新; * 该方法不会改变地图显示区域,以当前地图显示的中心点位置来缩放地图。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getZoom(): number; @@ -12789,25 +13078,25 @@ interface PlusMapsMap { * 隐藏地图控件 * 此方法用于隐藏地图控件,通常在显示后调用此方法来隐藏。 * 如果地图已经隐藏再调用此方法将无效果。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ hide(): void; /** * 获取是否显示用户位置 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ isShowUserLocation(): boolean; /** * 获取是否显示地图内置缩放控件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ isShowZoomControls(): boolean; /** * 获取是否打开地图交通信息图层 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ isTraffic(): boolean; @@ -12815,7 +13104,7 @@ interface PlusMapsMap { * 从地图中删除覆盖物对象 * 此方法用于从地图中删除覆盖物对象。 * 支持各种从maps.Overlay对象继承的各种覆盖物对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ removeOverlay(overlay?: PlusMapsOverlay): void; @@ -12823,14 +13112,14 @@ interface PlusMapsMap { * 重置地图 * 此方法用于重新设置地图,恢复地图的初始化时的中心点和缩放级别。 * 该方法将导致显示内容将立即更新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ reset(): void; /** * 重设地图控件大小 * 此方法用于重新计算地图控件大小,保持与构造时传入DOM元素的大小及位置一致。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ resize(): void; @@ -12839,21 +13128,21 @@ interface PlusMapsMap { * 此方法用于设置地图的中心点,用于切换当前显示地图位置。 * 该方法改变中心点后地图显示内容将立即更新; * 该方法不会改变地图显示的缩放级别。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setCenter(center?: PlusMapsPoint): void; /** * 设置地图的视图类型 * 此方法用于设置地图类型,默认为普通街道视图。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setMapType(type?: PlusMapsMapType): void; /** * 设置地图控件的配置参数 * 用于动态更新地图控件的参数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setStyles(styles?: PlusMapsMapStyles): void; @@ -12861,7 +13150,7 @@ interface PlusMapsMap { * 是否打开地图交通信息图层 * 此方法用于设置是否打开地图交通信息图层,默认不显示。 * 该方法改变是否显示交通图层后地图显示内容将立即更新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setTraffic(traffic?: boolean): void; @@ -12870,7 +13159,7 @@ interface PlusMapsMap { * 此方法用于设置地图的缩放级别,用于切换当前显示地图缩放级别。 * 该方法改变缩放级别后地图显示内容将立即更新; * 该方法不会改变地图显示区域,以当前地图显示的中心点位置来缩放地图。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setZoom(zoom?: number): void; @@ -12878,7 +13167,7 @@ interface PlusMapsMap { * 显示地图控件 * 此方法用于显示地图控件,通常在隐藏后调用此方法来显示。 * 如果地图已经显示再调用此方法将无效果。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ show(): void; @@ -12886,14 +13175,14 @@ interface PlusMapsMap { * 显示用户位置 * 此方法将在地图上显示用户位置信息。 * 显示用户位置将打开定位设备。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ showUserLocation(display?: boolean): void; /** * 设置是否显示地图内置缩放控件 * 此方法将在地图上显示内置缩放控件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ showZoomControls(display?: boolean): void; @@ -12902,42 +13191,42 @@ interface PlusMapsMap { /** * 地图控件对象的参数 * 设置地图对象显示时使用的参数,如地图的中心位置、缩放级别等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ interface PlusMapsMapStyles { /** * 地图的中心位置 * 未设置则使用地图的默认中心点(由地图供应商确定)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ center?: PlusMapsPoint | undefined; /** * 地图的缩放级别 * 有效范围为1-22,默认值为12,设置无效的值则使用默认值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ zoom?: number | undefined; /** * 地图的视图类型 * 可设置普通街道视图、卫星视图,默认值为普通街道视图。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ type?: PlusMapsMapType | undefined; /** * 地图的是否显示交通信息 * true表示显示地图的交通信息图层,false则不显示,默认值为false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ traffic?: boolean | undefined; /** * 是否显示地图的内置缩放控件 * true表示显示地图的内置缩放控件,false则不显示,默认值为false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ zoomControls?: boolean | undefined; @@ -12947,7 +13236,7 @@ interface PlusMapsMapStyles { * 像素值,如"100px"; * 百分比,如"10%",相对于父Webview窗口的高度; * 自动计算,如"auto",根据height值自动计算,相对于父Webview窗口垂直居中。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ top?: string | undefined; @@ -12958,7 +13247,7 @@ interface PlusMapsMapStyles { * 百分比,如"10%",相对于父Webview窗口的宽度; * 自动计算,如"auto",根据width值自动计算,相对于父Webview窗口水平居中。 * 默认值为"0px"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ left?: string | undefined; @@ -12968,7 +13257,7 @@ interface PlusMapsMapStyles { * 像素值,如"100px"; * 百分比,如"10%",相对于父Webview窗口的宽度。 * 默认值为"100%"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ width?: string | undefined; @@ -12978,7 +13267,7 @@ interface PlusMapsMapStyles { * 像素值,如"100px"; * 百分比,如"10%",相对于父Webview窗口的高度。 * 默认值为"100%"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ height?: string | undefined; @@ -12988,7 +13277,7 @@ interface PlusMapsMapStyles { * "static" - 静态布局模式,如果页面存在滚动条则随窗口内容滚动; * "absolute" - 绝对布局模式,如果页面存在滚动条不随窗口内容滚动; * 默认值为"static"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ position?: string | undefined; @@ -12996,7 +13285,7 @@ interface PlusMapsMapStyles { /** * 地理编码转换的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ interface PlusMapsGeocodeOptions { @@ -13009,14 +13298,14 @@ interface PlusMapsGeocodeOptions { * - gcj02: 国测局经纬度坐标系,soso地图、aliyun地图、mapabc地图和amap地图所用的坐标系 * - bd09: 百度墨卡托坐标系 * - bd09ll: 百度经纬度坐标系 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ - coordType?: 'wgs84' | 'gcj02' | 'bd09' | 'bd09ll' | undefined; + coordType?: "wgs84" | "gcj02" | "bd09" | "bd09ll" | undefined; /** * 源地址所属的城市 * 仅在地理编码转换时生效,如果不指定则在全国范围内区配转换。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ city?: string | undefined; @@ -13024,7 +13313,7 @@ interface PlusMapsGeocodeOptions { /** * 地图坐标转换的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ interface PlusMapsCoordinateConvertOptions { @@ -13036,46 +13325,46 @@ interface PlusMapsCoordinateConvertOptions { * - gcj02: 国测局经纬度坐标系,soso地图、aliyun地图、mapabc地图和amap地图所用的坐标系 * - bd09: 百度墨卡托坐标系 * - bd09ll: 百度经纬度坐标系 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ - coordType?: 'wgs84' | 'gcj02' | 'bd09' | 'bd09ll' | undefined; + coordType?: "wgs84" | "gcj02" | "bd09" | "bd09ll" | undefined; } /** * Point对象用于表示地图元素的坐标 * 常用语对地图上元素进行定位时使用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ interface PlusMapsPoint { /** * 设置坐标点的经度 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setLng(lng?: number): void; /** * 获取坐标的经度 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getLng(): number; /** * 设置坐标的纬度 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setLat(): void; /** * 获取坐标的纬度 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getLat(): number; /** * 判断两个坐标点是否相等 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ equals(pt?: PlusMapsPoint): boolean; @@ -13084,49 +13373,49 @@ interface PlusMapsPoint { /** * 地理区域 * 有西南及东北坐标点数据组成的矩形区域。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ interface PlusMapsBounds { /** * 设置地理区域的东北坐标点 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setNorthEase(point?: PlusMapsPoint): void; /** * 地理区域的东北坐标点 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getNorthEase(): PlusMapsPoint; /** * 设置地理区域的西南坐标点 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setSouthWest(point?: PlusMapsPoint): void; /** * 地理区域的西南坐标点 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getSouthWest(): PlusMapsPoint; /** * 判断制定的坐标是否在地理区域中 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ contains(point?: PlusMapsPoint): boolean; /** * 判断两个地理区域是否相等 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ equals(bounds?: PlusMapsBounds): boolean; /** * 获取地理区域的中心点坐标 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getCenter(): PlusMapsPoint; @@ -13134,21 +13423,21 @@ interface PlusMapsBounds { /** * 地图视图类型 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ interface PlusMapsMapType { /** * 普通街道视图类型 * 地图视图类型常量,普通街道视图。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ MAPTYPE_NORMAL?: number | undefined; /** * 卫星视图 * 地图视图类型常量,卫星视图。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ MAPTYPE_SATELLITE?: number | undefined; @@ -13157,14 +13446,14 @@ interface PlusMapsMapType { /** * 地图覆盖物基类对象 * Overlay是地图上显示元素的基类,用于抽象地图元素,不用于实例化。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ interface PlusMapsOverlay { /** * 判断地图覆盖物是否可见 * 地图覆盖物对象默认为可见;地图覆盖物对象是否可见由其自身状态决定,不管其是否被添加到地图层中。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ isVisible(): boolean; @@ -13173,7 +13462,7 @@ interface PlusMapsOverlay { * 常用于地图覆盖物在隐藏后调用此方法来显示。 * 只有添加到地图上的覆盖物才能看到效果; * 如果覆盖物对象已经在地图上显示再调用此方法将无效果。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ show(): void; @@ -13182,7 +13471,7 @@ interface PlusMapsOverlay { * 常用于地图覆盖物在显示后调用此方法来隐藏。 * 只有添加到地图上的覆盖物才能看到效果; * 如果覆盖物对象已经在地图上隐藏再调用此方法将无效果。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ hide(): void; @@ -13191,20 +13480,20 @@ interface PlusMapsOverlay { /** * 地图上显示的标点对象 * 从Overlay对象继承而来,可通过Map对象的addOverlay()方法将对象添加地图中。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ interface PlusMapsMarker { /** * 用户点击地图标点事件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ onclick?: ((result: PlusMapsOverlay) => void) | undefined; /** * 用户拖拽标点事件 * 可调用标点对象的markObj.setDraggable(true)方法设置标点允许拖拽,当用户拖拽标点对象时触发此事件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ onDrag?: ((result: any) => void) | undefined; @@ -13213,27 +13502,27 @@ interface PlusMapsMarker { * 常用于覆盖物相互覆盖时调整覆盖物的显示顺序。 * 只有添加到地图上的覆盖物才能看到效果; * 如果覆盖物对象已经在地图上隐藏再调用此方法将无效果。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ bringToTop(): void; /** * 设置标点对象的坐标 * 标点在设置新坐标后将在地图上立即更新标点位置。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setPoint(point?: PlusMapsPoint): void; /** * 获取标点的坐标 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getPoint(): PlusMapsPoint; /** * 设置标点上显示的图标 * 若未设置则显示默认标点图标,已添加的标点在设置新值后将在地图上立即更新标点内容。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setIcon(icon?: string): void; @@ -13241,20 +13530,20 @@ interface PlusMapsMarker { * 设置标点上显示的图标数组 * 设置图标数组后则按照指定的间隔时间轮播数组中图标。 * 设置图标数组后将忽略setIcon方法设置的图标,未设置则显示setIcon设置的图标。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ - setIcons(icons?: any []): void; + setIcons(icons?: any[]): void; /** * 设置标点上显示的文本标注 * 若未设置则不显示标注(默认为空字符串),已添加的标点在设置新值后将在地图上立即更新标点内容。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setLabel(label?: string): void; /** * 获取标点上显示的文本标注 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getLabel(): string; @@ -13262,21 +13551,21 @@ interface PlusMapsMarker { * 设置标点的气泡内容 * 设置气泡内容后,用户点击标点时弹出则弹出气泡。 * 注意:用户点击标点时先弹出标点关联的气泡,再响应标点的onclick事件。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setBubble(buuble?: PlusMapsBubble, pop?: boolean): void; /** * 获取标点上显示的文本标注 * 如果没有设置关联的气泡对象则返回null。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getBubble(): PlusMapsBubble; /** * 隐藏标点上显示的气泡 * 如果没有设置关联的气泡对象或者气泡对象没有弹出显示,则不做任何操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ hideBubble(): void; @@ -13285,13 +13574,13 @@ interface PlusMapsMarker { * 设置标点可拖拽后,用户按住标点后拖动,标点会跟随手的拖拽而移动。 * 拖拽后会更新标点的坐标信息。 * 注:拖动前需要先在标点上长按。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setDraggable(draggable?: boolean): void; /** * 获取标点是否允许拖拽 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ isDraggable(): boolean; @@ -13300,46 +13589,46 @@ interface PlusMapsMarker { /** * 地图上显示的气泡对象 * 此对象不能直接添加到地图上显示,只可关联到地图标点覆盖物上,用户点击标点时弹出显示。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ interface PlusMapsBubble { /** * 用户点击气泡事件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ onclick?: ((result: PlusMapsOverlay) => void) | undefined; /** * 设置气泡上显示的图标 * 若为设置则无默认图标,已添加的显示的气泡在设置新值后将在地图上立即更新内容。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setIcon(icon?: string): void; /** * 设置气泡上显示的文字内容 * 若未设置则不显示文字(默认为空字符串),已添加的显示的气泡在设置新值后将在地图上立即更新内容。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setLabel(label?: string): void; /** * 获取气泡上显示的文字内容 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getLabel(): string; /** * 获取气泡所属的标点对象 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ belongMarker(): PlusMapsMarker; /** * 从图片加载气泡显示的内容 * 通过加载图片来自定义气泡显示的内容,加载图片后将清空气泡使用的图标及文字内容。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ loadImage(path?: string): void; @@ -13347,7 +13636,7 @@ interface PlusMapsBubble { * 从图片数据加载气泡显示的内容 * 通过加载图片数据来自定义气泡显示的内容,加载图片后将清空气泡使用的图标及文字内容。 * 图片数据可通过Canvas自定义绘制后调用toDataURL来获取。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ loadImageDataURL(data?: string): void; @@ -13356,46 +13645,46 @@ interface PlusMapsBubble { /** * 地图上显示的圆圈对象 * 从Overlay对象继承而来,可通过Map对象的addOverlay()方法将对象添加地图中。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ interface PlusMapsCircle { /** * 设置圆圈中心点的经纬度坐标 * 该方法设置将导致地图中的圆圈立即更新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setCenter(point?: PlusMapsPoint): void; /** * 获取圆圈中心点的坐标 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getCenter(): PlusMapsPoint; /** * 设置圆圈的半径,单位为米 * 该方法设置将导致地图中的圆圈立即更新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setRadius(radius?: number): void; /** * 获取圆圈的半径 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getRadius(): number; /** * 设置圆圈的边框颜色 * 圆圈默认的圆圈边框颜色为黑色"#000000",该方法设置将导致地图中的圆圈立即更新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setStrokeColor(color?: string): void; /** * 获取圆圈的边框颜色 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getStrokeColor(): string; @@ -13403,27 +13692,27 @@ interface PlusMapsCircle { * 设置圆圈的边框颜色 * 圆圈默认值为不透明。 * 如果设置的值不合法则保持原有的透明度;该方法设置将导致地图中的圆圈立即更新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setStrokeOpacity(opacity?: number): void; /** * 获取圆圈边框的透明度 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getStrokeOpacity(): number; /** * 设置圆圈的填充颜色 * 圆圈默认的圆圈填充颜色为无色,该方法设置将导致地图中的圆圈立即更新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setFillColor(color?: string): void; /** * 获取圆圈的填充颜色 * 如果填充颜色为无色,则返回空字符串。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getFillColor(): string; @@ -13431,13 +13720,13 @@ interface PlusMapsCircle { * 设置圆圈填充颜色的透明度 * 圆圈默认值为不透明。 * 如果设置的值不合法则保持原有的透明度;该方法设置将导致地图中的圆圈立即更新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setFillOpacity(opacity?: number): void; /** * 获取圆圈填充色的透明度 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getFillOpacity(): number; @@ -13445,13 +13734,13 @@ interface PlusMapsCircle { * 设置圆圈边框的线条宽度 * 圆圈边框的默认值为5。 * 如果设置的值不合法则保持原有的宽度;该方法设置将导致地图中的圆圈立即更新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setLineWidth(width?: number): void; /** * 获取圆圈边框的线条宽度 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getLineWidth(): number; @@ -13460,33 +13749,33 @@ interface PlusMapsCircle { /** * 地图上显示的折线对象 * 从Overlay对象继承而来,可通过Map对象的addOverlay()方法将对象添加地图中。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ interface PlusMapsPolyline { /** * 设置折线的顶点坐标 * 该方法设置将导致地图中的折线立即更新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ - setPath(points?: any []): void; + setPath(points?: any[]): void; /** * 获取折线的顶点坐标 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ - getPath(): any []; + getPath(): any[]; /** * 设置折线的颜色 * 折线默认的颜色为黑色"#000000",该方法设置将导致地图中的折线立即更新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setStrokeColor(color?: string): void; /** * 获取折线的颜色 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getStrokeColor(): string; @@ -13494,13 +13783,13 @@ interface PlusMapsPolyline { * 设设置折线的透明度 * 折线默认值为不透明。 * 如果设置的值不合法则保持原有的透明度;该方法设置将导致地图中的折线立即更新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setStrokeOpacity(opacity?: number): void; /** * 获取折线的透明度 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getStrokeOpacity(): number; @@ -13508,13 +13797,13 @@ interface PlusMapsPolyline { * 设置折线的线条宽度 * 折线线条的宽度默认值为5。 * 如果设置的值不合法则保持原有的宽度;该方法设置将导致地图中的折线立即更新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setLineWidth(width?: number): void; /** * 获取折线的线条宽度 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getLineWidth(): number; @@ -13523,33 +13812,33 @@ interface PlusMapsPolyline { /** * 地图上显示的多边形对象 * 从Overlay对象继承而来,可通过Map对象的addOverlay()方法将对象添加地图中。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ interface PlusMapsPolygon { /** * 设置多边形的顶点坐标 * 该方法设置将导致地图中的多边形立即更新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ - setPath(points?: any []): void; + setPath(points?: any[]): void; /** * 获取多边形的顶点坐标 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ - getPath(): any []; + getPath(): any[]; /** * 设置多边形的颜色 * 多边形边框默认的颜色为黑色"#000000",该方法设置将导致地图中的多边形立即更新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setStrokeColor(color?: string): void; /** * 获取多边形边框的颜色 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getStrokeColor(): string; @@ -13557,27 +13846,27 @@ interface PlusMapsPolygon { * 设置多边形的透明度 * 多边形边框默认值为不透明。 * 如果设置的值不合法则保持原有的透明度;该方法设置将导致地图中的多边形立即更新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setStrokeOpacity(opacity?: number): void; /** * 获取多边形边框的透明度 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getStrokeOpacity(): number; /** * 设置多边形的填充颜色 * 多边形默认填充颜色为无色,该方法设置将导致地图中的多边形立即更新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setFillColor(color?: string): void; /** * 获取多边形的填充色 * 如果填充色为无色,则返回空字符串。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getFillColor(): string; @@ -13585,13 +13874,13 @@ interface PlusMapsPolygon { * 设置多边形填充色的透明度 * 多边形填充色默认值为不透明。 * 如果设置的值不合法则保持原有的透明度;该方法设置将导致地图中的多边形立即更新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setFillOpacity(opacity?: number): void; /** * 获取多边形填充色的透明度 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getFillOpacity(): number; @@ -13599,13 +13888,13 @@ interface PlusMapsPolygon { * 设置多边形的边框宽度 * 多边形边框的宽度默认值为5。 * 如果设置的值不合法则保持原有的宽度;该方法设置将导致地图中的多边形立即更新。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setLineWidth(width?: number): void; /** * 获取多边形边框的宽度 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getLineWidth(): number; @@ -13614,32 +13903,32 @@ interface PlusMapsPolygon { /** * 地图检索对象 * Search对象用于管理地图上的检索功能,包括位置检索、周边检索和范围检索。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ interface PlusMapsSearch { /** * 兴趣点检索完成事件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ onPoiSearchComplete?: ((result0: number, result1: PlusMapsSearchPoiResult) => void) | undefined; /** * 线路检索完成事件 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ onRouteSearchComplete?: ((result0: number, result1: PlusMapsSearchRouteResult) => void) | undefined; /** * 设置检索返回结果每页的信息数目 * 地图检索结果是按页返回的,默认检索每页返回10条信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setPageCapacity(capacity?: number): void; /** * 获取检索返回结果每页的信息数目 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getPageCapacity(): number; @@ -13647,7 +13936,7 @@ interface PlusMapsSearch { * 城市兴趣点检索 * 检索结果将通过onPoiSearchComplete事件返回。 * 如果调用此方法时已经处于POI检索操作中,则终止上次检索操作,重新开始新的检索。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ poiSearchInCity(city?: string, key?: string, index?: number): boolean; @@ -13655,7 +13944,7 @@ interface PlusMapsSearch { * 周边检索 * 周边检索根据中心点、半径与检索词进行检索,检索完成后触发onPoiSearchComplete()事件。 * 若调用此方法时对象处于POI检索操作中,则终止上次检索操作,重新开始新的检索。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ poiSearchNearBy(key?: string, pt?: PlusMapsPoint, radius?: number, index?: number): boolean; @@ -13663,7 +13952,7 @@ interface PlusMapsSearch { * 指定范围检索 * 根据范围和检索词进行检索,检索完成后触发onPoiSearchComplete()事件。 * 若调用此方法时对象处于POI检索操作中,则终止上次检索操作,重新开始新的检索。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ poiSearchInbounds(): boolean; @@ -13672,7 +13961,7 @@ interface PlusMapsSearch { * 默认采用maps.SearchPolicy.TRANSIT_TIME_FIRST策略。 * 需在调用transitSearch()方法前设置的策略才生效; * 如果设置非法值则认为设置失败,采用上次设置的检索策略并返回false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setTransitPolicy(policy?: PlusMapsSearchPolicy): boolean; @@ -13680,7 +13969,7 @@ interface PlusMapsSearch { * 公交路线检索 * 检索完成后触发onRouteSearchComplete()事件。 * 若调用此方法时对象处于检索操作中,则终止上次检索操作,重新开始新的检索。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ transitSearch(start?: string, end?: string, city?: string): boolean; @@ -13688,7 +13977,7 @@ interface PlusMapsSearch { * 设置驾车路线检索策略 * 设置驾车路线检索策略,默认采用maps.SearchPolicy.DRIVING_TIME_FIRST策略。 * 如果设置非法值则认为设置失败,采用上次设置的检索策略并返回false;需在调用drivingSearch()方法前设置的策略才生效。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ setDrivingPolicy(policy?: PlusMapsSearchPolicy): boolean; @@ -13696,7 +13985,7 @@ interface PlusMapsSearch { * 驾车路线检索 * 用于驾车路线检索,检索完成后触发onRouteSearchComplete()事件。 * 调用此方法时对象处于检索操作中,则终止上次检索操作,重新开始新的检索。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ drivingSearch(start?: string, startCity?: string, end?: string, endCity?: string): boolean; @@ -13704,7 +13993,7 @@ interface PlusMapsSearch { * 步行路线检索 * 用于步行路线检索,检索完成后触发onRouteSearchComplete()事件。 * 调用此方法时对象处于检索操作中,则终止上次检索操作,重新开始新的检索。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ walkingSearch(start?: string, startCity?: string, end?: string, endCity?: string): boolean; @@ -13713,56 +14002,56 @@ interface PlusMapsSearch { /** * 检索策略类型 * 在线路检索时设置检索策略时使用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ interface PlusMapsSearchPolicy { /** * 时间优先 * 检索策略类型常量,用于公交检索策略 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ TRANSIT_TIME_FIRST?: number | undefined; /** * 最少换乘优先 * 检索策略类型常量,用于公交检索策略 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ TRANSIT_TRANSFER_FIRST?: number | undefined; /** * 最少步行距离优先 * 检索策略类型常量,用于公交检索策略 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ TRANSIT_WALK_FIRST?: number | undefined; /** * 选择车票花销最少优先 * 检索策略类型常量,用于公交检索策略 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ TRANSIT_FEE_FIRST?: number | undefined; /** * 最短距离优先 * 检索策略类型常量,用于驾车检索策略 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ DRIVING_DIS_FIRST?: number | undefined; /** * 无高速公路线路 * 检索策略类型常量,用于驾车检索策略 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ DRIVING_NO_EXPRESSWAY?: number | undefined; /** * 最少费用优先 * 检索策略类型常量,用于驾车检索策略 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ DRIVING_FEE_FIRST?: number | undefined; @@ -13770,49 +14059,49 @@ interface PlusMapsSearchPolicy { /** * 保存位置检索、周边检索和范围检索返回的结果 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ interface PlusMapsSearchPoiResult { /** * POI检索总结果数 * POI检索总结果数,若没有检索到则返回0。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ totalNumber?: number | undefined; /** * 当前页的POI检索结果数 * 当前页POI检索结果数,若没有检索到则返回0。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ currentNumber?: number | undefined; /** * 本次POI检索的总页数 * 本次POI检索的总页数,若没有检索到则返回0。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ pageNumber?: number | undefined; /** * 获取当前页的索引 * 当前页的索引值,从0开始,即0表示第一页。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ pageIndex?: number | undefined; /** * 本次POI检索结果数组 * POI检索结果数组,Array数组对象,数组内容为Position对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ - poiList?: any [] | undefined; + poiList?: any[] | undefined; /** * 获取指定索引的检索结果 * 如果index值超出范围则返回null对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getPosition(): PlusMapsPosition; @@ -13821,42 +14110,42 @@ interface PlusMapsSearchPoiResult { /** * 保存位置检索、周边检索和范围检索返回的结果 * 不可通过new操作符创建SearchRouteResult对象,在触发onRouteSearchComplete()时自动创建。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ interface PlusMapsSearchRouteResult { /** * 线路的起点位置 * 线路检索结果的起始位置点对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ startPosition?: PlusMapsPosition | undefined; /** * 线路的终点位置 * 线路检索结果的终点位置点对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ endPosition?: PlusMapsPosition | undefined; /** * 本次线路检索的总方案数 * 线路检索结果的方案数目,若未检索到有效结果则返回0。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ routeNumber?: number | undefined; /** * 线路检索结果数组 * 线路检索结果数组,Array数组对象,数组内容为Route对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ - routeList?: any [] | undefined; + routeList?: any[] | undefined; /** * 获取指定索引的线路方案 * 如果index值超出范围则返回null对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ getRoute(index?: number): PlusMapsRoute; @@ -13864,49 +14153,49 @@ interface PlusMapsSearchRouteResult { /** * 检索结果的位置点 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ interface PlusMapsPosition { /** * 位置点的经纬度坐标 * 如果没有经纬度坐标信息(如果公交、地铁路线数据等),则其值为undefined。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ point?: PlusMapsPoint | undefined; /** * 位置点的地址信息 * 如果没有位置点的地址信息则返回空字符串。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ address?: string | undefined; /** * 位置点的所属城市信息 * 如果没有位置点的所属城市信息则返回空字符串。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ city?: string | undefined; /** * 位置点的名称 * 如果没有位置点的名称则返回空字符串。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ name?: string | undefined; /** * 位置点的电话信息 * 如果没有位置点的电话信息则返回空字符串。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ phone?: string | undefined; /** * 位置点的邮编信息 * 如果没有位置点的邮编信息则返回空字符串。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ postcode?: string | undefined; @@ -13915,46 +14204,46 @@ interface PlusMapsPosition { /** * 地图中的路线对象 * 从Overlay对象继承而来,可通过Map对象的addOverlay()方法将对象添加地图中。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ interface PlusMapsRoute { /** * 路线起点地理坐标点 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ startPoint?: PlusMapsPoint | undefined; /** * 路线终点地理坐标点 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ endPoint?: PlusMapsPoint | undefined; /** * 路线坐标点段数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ pointCount?: PlusMapsPoint | undefined; /** * 路线的地理坐标点数组 * 路线的地理坐标点数组,数组中保存Point对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ - pointList?: any [] | undefined; + pointList?: any[] | undefined; /** * 路线总距离 * 路线从起始点到终点的距离,单位为米。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ distance?: number | undefined; /** * 线路的提示信息 * 线路提示信息,没有提示信息则返回空字符串。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/maps.html](http://www.html5plus.org/doc/zh_cn/maps.html) */ routeTip?: string | undefined; @@ -13962,14 +14251,14 @@ interface PlusMapsRoute { /** * OAuth模块管理客户端的用户登录授权验证功能,允许应用访问第三方平台的资源。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ interface PlusOauth { /** * 登录授权认证服务对象 * AuthService对象用于表示登录授权认证服务,在JS中为对象,用于向系统进行登录授权认证操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ AuthService?: PlusOauthAuthService | undefined; @@ -13979,7 +14268,7 @@ interface PlusOauth { * 例如“微信”,则可配置以下参数: * scope - 应用授权作用域; * state - 用于保持请求和回调的状态参数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ AuthOptions?: PlusOauthAuthOptions | undefined; @@ -13988,7 +14277,7 @@ interface PlusOauth { * 此对象仅定义标准属性,登录授权认证服务可扩展自定义数据。 * 例如“微信”登录授权服务,则包括以下数据: * unionid - 用户统一标识,针对一个微信开放平台帐号下的应用,同一用户的unionid是唯一的。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ AuthInfo?: PlusOauthAuthInfo | undefined; @@ -13999,23 +14288,23 @@ interface PlusOauth { * 例如“微信”登录授权服务,可能包括以下自定义数据: * privilege - 用户特权信息,json数组,如微信沃卡用户为(chinaunicom); * unionid - 用户统一标识,针对一个微信开放平台帐号下的应用,同一用户的unionid是唯一的。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ UserInfo?: PlusOauthUserInfo | undefined; /** * 获取登录授权认证服务列表 * 获取终端支持的权登录认证服务列表,可用于提示用户进行登录平台的选择。获取登录授权认证服务成功后通过successCB回调返回支持的所有服务列表,获取服务失败则通过errorCB回调返回失败信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ - getServices(successCB?: (result: PlusOauth []) => void, errorCB?: (result: any) => void): void; + getServices(successCB?: (result: PlusOauth[]) => void, errorCB?: (result: any) => void): void; } /** * 登录授权认证服务对象 * AuthService对象用于表示登录授权认证服务,在JS中为对象,用于向系统进行登录授权认证操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ interface PlusOauthAuthService { @@ -14026,7 +14315,7 @@ interface PlusOauthAuthService { * "qq" - 表示QQ登录授权; * "sinaweibo" - 表示新浪微博登录授权; * "qihoo" - 表示360账号登录(仅360手助流应用环境下支持)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ id?: string | undefined; @@ -14037,21 +14326,21 @@ interface PlusOauthAuthService { * "QQ" - 表示QQ登录授权; * "新浪微博" - 表示新浪微博登录授权; * "360账号" - 表示360账号登录(仅360手助流应用环境下支持)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ description?: string | undefined; /** * 授权认证结果数据 * 用于保存登录授权认证获取的认证信息,如果值为"undefined"则表示未进行授权认证或者是授权认证失败。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ authResult?: PlusOauthAuthInfo | undefined; /** * 登录授权认证用户信息 * 用于保存登录授权认证获取的用户信息,如果值为"undefined"则表示未获取过用户信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ userInfo?: PlusOauthUserInfo | undefined; @@ -14060,7 +14349,7 @@ interface PlusOauthAuthService { * 用于保存登录授权认证服务返回的扩展信息,具体内容由各登录平台决定,如果没有扩展信息则为undefined。 * 例如“微信”,则可保存以下数据: * state - 用于保持请求和回调的状态参数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ extra?: any; @@ -14069,23 +14358,31 @@ interface PlusOauthAuthService { * 向开放平台请求进行授权认证,需提供授权域(scope),用户在终端确认后通过成功回调返回授权临时票据(code)。 * 开发者可以将授权临时票据(code)提交到业务服务器,又业务服务器从微信开放平台获取授权登录等相关信息,避免将appsecret等信息保存在客户端可能引起泄露的问题。 * 注意:目前仅微信平台支持请求授权认证,其它平台调用此方法将返回错误回调。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ - authorize(successCallback?: (result: any) => void, errorCallback?: (result: any) => void, options?: PlusOauthAuthOptions): void; + authorize( + successCallback?: (result: any) => void, + errorCallback?: (result: any) => void, + options?: PlusOauthAuthOptions, + ): void; /** * 请求登录授权认证操作 * 对指定的登录授权认证服务进行登录认证操作,在登录前可通过对象的authResult属性判断是否已经登录认证过,通常只需要对没有进行过登录认证的服务进行登录认证操作。 * 授权认证操作成功后通过successCB回调函数通知,失败则通过errorCB回调函数通知。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ - login(successCallback?: (result: any) => void, errorCallback?: (result: any) => void, options?: PlusOauthAuthOptions): void; + login( + successCallback?: (result: any) => void, + errorCallback?: (result: any) => void, + options?: PlusOauthAuthOptions, + ): void; /** * 注销登录授权认证 * 对指定的登录授权认证服务注销登录认证操作,注销授权认证后,再次操作时需重新进行登录认证操作。 * 如果第三方平台不需要注销操作,则情况保存的相关登录认证等信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ logout(successCallback?: (result: any) => void, errorCallback?: (result: any) => void): void; @@ -14093,14 +14390,14 @@ interface PlusOauthAuthService { * 获取登录授权用户信息 * 获取登录授权认证的用户信息,在获取前可通过对象的userInfo属性判断是否已经获取过,通常只需要对没有获取过用户信息的服务进行操作。 * 获取用户信息操作成功后通过successCallback回调函数通知,失败则通过errorCallback回调函数通知。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ getUserInfo(successCallback?: (result: any) => void, errorCallback?: (result: any) => void): void; /** * 添加用户手机号信息 * 打开登录授权服务的添加用户手机号界面进行操作,添加用户手机号操作成功后通过successCallback回调函数通知,否则通过errorCallback回调函数通知。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ addPhoneNumber(successCallback?: (result: any) => void, errorCallback?: (result: any) => void): void; @@ -14112,20 +14409,20 @@ interface PlusOauthAuthService { * 例如“微信”,则可配置以下参数: * scope - 应用授权作用域; * state - 用于保持请求和回调的状态参数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ interface PlusOauthAuthOptions { /** * 申请的权限作用范围 * 如果存在多个权限,则以","符号分割。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ scope?: string | undefined; /** * 客户端的当前状态,可以指定任意值,登录认证后原封不动的返回保存到AuthService对象的extra中 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ state?: string | undefined; @@ -14133,7 +14430,7 @@ interface PlusOauthAuthOptions { * 登录授权认证服务平台申请的appid * 动态设置登录授权服务中需要使用的appid,仅需要此参数的登录授权服务(如“微信登录”、“QQ登录”)支持。 * 如果未设置则使用运行环境中内置的appid值(如在HBuilder中可在manifest.json的SDK配置项中进行设置)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ appid?: string | undefined; @@ -14141,7 +14438,7 @@ interface PlusOauthAuthOptions { * 登录授权认证服务平台申请的appkey * 动态设置登录授权服务中需要使用的appkey,仅需要此参数的登录授权服务(如“新浪微博登录”、“360登录”)支持。 * 如果未设置则使用运行环境中内置的appkey值(如在HBuilder中可在manifest.json的SDK配置项中进行设置)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ appkey?: string | undefined; @@ -14149,7 +14446,7 @@ interface PlusOauthAuthOptions { * 登录授权认证服务平台申请的appsecret * 动态设置登录授权服务中需要使用的appsecret,仅需要此参数的登录授权服务(如“微信登录”、“新浪微博登录”)支持。 * 如果未设置则使用运行环境中内置的appkey值(如在HBuilder中可在manifest.json的SDK配置项中进行设置);当开放平台申请的appsecret值涉及到安全问题时,可在应用运行时从服务器获取,然后通过此api动态设置。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ appsecret?: string | undefined; @@ -14157,7 +14454,7 @@ interface PlusOauthAuthOptions { * 登录授权认证服务平台申请的redirect_url * 动态设置登录授权服务中需要使用的redirect_url,仅需要此参数的登录授权服务(如“新浪微博登录”)支持。 * 如果未设置则使用运行环境中内置的redirect_url值(如在HBuilder中可在manifest.json的SDK配置项中进行设置)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ redirect_url?: string | undefined; @@ -14168,42 +14465,42 @@ interface PlusOauthAuthOptions { * 此对象仅定义标准属性,登录授权认证服务可扩展自定义数据。 * 例如“微信”登录授权服务,则包括以下数据: * unionid - 用户统一标识,针对一个微信开放平台帐号下的应用,同一用户的unionid是唯一的。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ interface PlusOauthAuthInfo { /** * 登录授权的访问令牌 * 如果登录授权服务不支持此属性,则返回"undefined"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ access_token?: string | undefined; /** * 登录授权用户的唯一标识 * 如果登录授权服务不支持此属性,则返回"undefined"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ openid?: string | undefined; /** * 登录授权访问令牌过期时间 * 单位为秒,如果登录授权服务不支持此属性,则返回"undefined"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ expires_in?: string | undefined; /** * 登录授权的更新令牌 * 用来获取下一次的访问令牌,如果登录授权服务不支持此属性,则返回"undefined"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ refresh_token?: string | undefined; /** * 登录授权的权限范围 * 如果存在多个权限,则以","符号分割。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ scope?: string | undefined; @@ -14216,42 +14513,42 @@ interface PlusOauthAuthInfo { * 例如“微信”登录授权服务,可能包括以下自定义数据: * privilege - 用户特权信息,json数组,如微信沃卡用户为(chinaunicom); * unionid - 用户统一标识,针对一个微信开放平台帐号下的应用,同一用户的unionid是唯一的。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ interface PlusOauthUserInfo { /** * 登录授权用户的唯一标识 * 如果登录授权服务不支持此属性,则返回"undefined"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ openid?: string | undefined; /** * 登录授权用户的头像图片地址 * 要求为"http://"或"https://"开头的地址,如果登录授权服务不支持此属性,则返回"undefined"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ headimgurl?: string | undefined; /** * 登录授权用户的昵称 * 如果登录授权服务不支持此属性,则返回"undefined"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ nickname?: string | undefined; /** * 登录授权用户的邮箱地址 * 如果登录授权服务不支持此属性,则返回"undefined"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ email?: string | undefined; /** * 登录授权用户的电话号码 * 如果登录授权服务不支持此属性,则返回"undefined"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ phonenumber?: string | undefined; @@ -14259,28 +14556,28 @@ interface PlusOauthUserInfo { * 登录授权用户的性别 * 1为男性,2为女性。 * 如果登录授权服务不支持此属性,则返回"undefined"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ sex?: string | undefined; /** * 登录授权用户注册的省份信息 * 如果登录授权服务不支持此属性,则返回"undefined"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ province?: string | undefined; /** * 登录授权用户注册的城市信息 * 如果登录授权服务不支持此属性,则返回"undefined"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ city?: string | undefined; /** * 登录授权用户注册的国家信息 * 如果登录授权服务不支持此属性,则返回"undefined"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/oauth.html](http://www.html5plus.org/doc/zh_cn/oauth.html) */ country?: string | undefined; @@ -14288,49 +14585,49 @@ interface PlusOauthUserInfo { /** * Payment模块管理支付功能,用于提供网页安全支付能力,支持通过Web接口进行支付操作。通过plus.payment可获取支付管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ interface PlusPayment { /** * 支付通道对象 * PaymentChannel对象表示特定的支付通道,用于向系统请求支付操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ PaymentChannel?: PlusPaymentPaymentChannel | undefined; /** * IAP订单数据对象 * 描述IAP商品订单信息,如标识、数量等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ OrderStatementIAP?: PlusPaymentOrderStatementIAP | undefined; /** * 支付操作结果对象 * PaymentResult对象表示支付操作返回结果,用于确认支付操作成功。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ PaymentResult?: PlusPaymentPaymentResult | undefined; /** * IAP商品对象 * 描述IAP商品详细信息,如标识、价格、标题、描述信息等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ IAPProduct?: PlusPaymentIAPProduct | undefined; /** * 购买IAP商品对象 * 描述购买的IAP商品详细信息,如标识、数量等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ IAPProductInfo?: PlusPaymentIAPProductInfo | undefined; /** * 购买IAP商品交易信息对象 * 描述购买的IAP商品交易详细信息,如购买商品信息、交易日期、订单标识等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ IAPTransaction?: PlusPaymentIAPTransaction | undefined; @@ -14338,24 +14635,29 @@ interface PlusPayment { * 获取支付通道 * 在进行支付操作前需获取终端支持的支付通道列表,用于提示用户进行选择。 * 获取支付通道成功后通过successCB回调返回支持的所有通道列表,获取支付通道列表失败则通过errorCB回调返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ - getChannels(successCB?: (result: PlusPayment []) => void, errorCB?: (result: any) => void): void; + getChannels(successCB?: (result: PlusPayment[]) => void, errorCB?: (result: any) => void): void; /** * 请求支付操作 * 调用指定的支付通道进行支付操作,其中statement包含支付操作的相关信息,支付模块将弹出支付界面供用户进行支付信息的输入确认操作。 * 用户支付操作成功后通过successCB回调返回支付操作结果,支付操作失败则通过errorCB回调返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ - request(channel?: PlusPaymentPaymentChannel, statement?: string, successCB?: (result: PlusPaymentPaymentResult) => void, errorCB?: (result: any) => void): void; + request( + channel?: PlusPaymentPaymentChannel, + statement?: string, + successCB?: (result: PlusPaymentPaymentResult) => void, + errorCB?: (result: any) => void, + ): void; } /** * 支付通道对象 * PaymentChannel对象表示特定的支付通道,用于向系统请求支付操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ interface PlusPaymentPaymentChannel { @@ -14366,14 +14668,14 @@ interface PlusPaymentPaymentChannel { * "wxpay" - 表示微信支付; * "appleiap" - 表示苹果应用内支付; * "qhpay" - 表示360聚合支付(仅360手助流应用环境下支持)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ id?: string | undefined; /** * 支付通道描述 * 支付通道的描述信息,如“支付宝”、“微信”、“In-App Purchase”。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ description?: string | undefined; @@ -14383,7 +14685,7 @@ interface PlusPaymentPaymentChannel { * 若系统环境中没有安装相关的服务,则可能导致调用支付操作失败,这时可以调用installService方法进行安装。 * 注意:如果支付通道不需要依赖系统安装服务,则永远返回true。例如支付宝,如果设备上未安装支付宝客户端则调用Wap页面进行支付,因此值固定返回true; * 而微信支付则依赖微信客户端,如果设备上未安装微信客户端则serviceReady值为false,此时应该提示用户安装微信客户端才能进行支付操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ serviceReady?: boolean | undefined; @@ -14391,48 +14693,48 @@ interface PlusPaymentPaymentChannel { * 安装支付通道依赖的服务 * 对于某些支付通道,通常特定的支付通道依赖系统安装相关的服务,调用此方法将安装其依赖的支付服务。 * 如支付宝,则在系统中安装支付宝客户端程序。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ installService(): void; /** * 向IAP服务器请求支付订单 * IAP支付在调用plus.payment.request方法支付前须先向服务器请求获取商品的详细信息,否则会支付失败。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ - requestOrder(ids?: any [], successCB?: (result: PlusPayment []) => void, errorCB?: (result: any) => void): void; + requestOrder(ids?: any[], successCB?: (result: PlusPayment[]) => void, errorCB?: (result: any) => void): void; /** * 向IAP服务器请求已经购买的非消耗性商品和订阅商品 * 注意:不能获取已购买的消耗性商品。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ - restoreComplateRequest(options?: any, successCB?: (result: PlusPayment []) => void): void; + restoreComplateRequest(options?: any, successCB?: (result: PlusPayment[]) => void): void; } /** * IAP订单数据对象 * 描述IAP商品订单信息,如标识、数量等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ interface PlusPaymentOrderStatementIAP { /** * 商品的标识 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ productid?: string | undefined; /** * 购买用户名称 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ username?: string | undefined; /** * 商品数量 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ quantity?: string | undefined; @@ -14441,49 +14743,49 @@ interface PlusPaymentOrderStatementIAP { /** * 支付操作结果对象 * PaymentResult对象表示支付操作返回结果,用于确认支付操作成功。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ interface PlusPaymentPaymentResult { /** * 支付通道对象 * 用于发起支付操作的支付通道对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ channel?: PlusPaymentPaymentChannel | undefined; /** * 交易编号信息 * 如果支付平台不支持此数据则返回undefined。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ tradeno?: string | undefined; /** * 交易描述信息 * 如果支付平台不支持此数据则返回undefined。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ description?: boolean | undefined; /** * 查找支付交易信息地址 * 用于向支付平台查询交易信息,如果支付平台不支持此数据则返回undefined。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ url?: boolean | undefined; /** * 支付操作指纹信息 * 用于向支付平台查询支付订单信息,如果支付平台不支持此数据则返回undefined。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ signature?: string | undefined; /** * 支付平台返回的原始数据 * 如果支付平台返回key-value类型字符串,则组合成符合JSON格式的字符串。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ rawdata?: string | undefined; @@ -14492,31 +14794,31 @@ interface PlusPaymentPaymentResult { /** * IAP商品对象 * 描述IAP商品详细信息,如标识、价格、标题、描述信息等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ interface PlusPaymentIAPProduct { /** * 商品的标识 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ productid?: string | undefined; /** * 商品的价格 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ price?: string | undefined; /** * 商品标题 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ title?: string | undefined; /** * 商品的描述信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ description?: string | undefined; @@ -14525,19 +14827,19 @@ interface PlusPaymentIAPProduct { /** * 购买IAP商品对象 * 描述购买的IAP商品详细信息,如标识、数量等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ interface PlusPaymentIAPProductInfo { /** * 商品的标识 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ productIdentifier?: string | undefined; /** * 商品的数量 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ quantity?: string | undefined; @@ -14546,39 +14848,39 @@ interface PlusPaymentIAPProductInfo { /** * 购买IAP商品交易信息对象 * 描述购买的IAP商品交易详细信息,如购买商品信息、交易日期、订单标识等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ interface PlusPaymentIAPTransaction { /** * 购买商品的信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ payment?: string | undefined; /** * 购买商品的交易日期 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ transactionDate?: string | undefined; /** * 购买商品的交易订单标识 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ transactionIdentifier?: string | undefined; /** * 购买商品的交易收据 * base64编码格式字符串数据。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ transactionReceipt?: string | undefined; /** * 购买商品的交易状态 * 可取值:"1"为支付成功;"2"为支付失败;"3"为支付已恢复。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/payment.html](http://www.html5plus.org/doc/zh_cn/payment.html) */ transactionState?: string | undefined; @@ -14586,46 +14888,46 @@ interface PlusPaymentIAPTransaction { /** * Push模块管理推送消息功能,可以实现在线、离线的消息推送,通过plus.push可获取推送消息管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ interface PlusPush { /** * JSON对象,获取的客户端标识信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ ClientInfo?: PlusPushClientInfo | undefined; /** * JSON对象,推送消息对象 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ PushMessage?: PlusPushPushMessage | undefined; /** * JSON对象,获客户端创建本地消息的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ MessageOptions?: PlusPushMessageOptions | undefined; /** * 添加推送消息事件监听器 * 添加推送消息事件监听器,当指定推送事件发出时触发。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ addEventListener(type?: string, listener?: (result: string) => void, capture?: boolean): void; /** * 清空所有推送消息 * 清空系统消息中心所有的推送消息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ clear(): void; /** * 创建本地消息 * 在本地直接创建推送消息,并添加到系统消息中心。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ createMessage(content?: string, payload?: string, options?: PlusPushMessageOptions): void; @@ -14633,14 +14935,14 @@ interface PlusPush { * 获取所有推送消息 * 获取客户端接收到的所有推送消息。 * 仅包括在系统消息中心显示的推送消息,不包括调用setAutoNotification(false)方法设置不显示推送消息后接收到的消息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ getAllMessage(): PlusPushPushMessage; /** * 获取客户端推送标识信息 * 客户端标识信息用于业务服务器下发推送消息时提交给推送服务器的数据,用于说明下发推送消息的接收者(客户端)。需要客户端在第一次运行时提交到业务服务器保存。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ getClientInfo(): PlusPushClientInfo; @@ -14648,14 +14950,14 @@ interface PlusPush { * 设置程序是否将消息显示在系统消息中心 * 默认情况下程序在接收到推送消息后将会在系统消息中心显示,通过此方法可关闭默认行为,接收到推送消息后不在系统消息中心显示,通过addEventListener方法的“receive”事件监听处理接收到的消息。 * 在这种模式下可通过createMessage方法创建在系统消息中心显示的消息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ setAutoNotification(notify?: boolean): void; /** * 删除推送消息 * 删除系统消息中心指定的推送消息,可通过getAllMessage方法获取所有的消息后进行操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ remove(message?: PlusPushPushMessage): void; @@ -14663,13 +14965,13 @@ interface PlusPush { /** * JSON对象,获取的客户端标识信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ interface PlusPushClientInfo { /** * 设备令牌(iOS设备唯一标识),用于APNS服务推送中标识设备的身份 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ token?: string | undefined; @@ -14677,21 +14979,21 @@ interface PlusPushClientInfo { * 推送服务令牌(设备唯一标识),用于标识推送信息接收者身份 * 第三方推送服务器管理的设备唯一标识,在iOS平台此值通常与token不同;在其它平台此值通常与token值一致。 * 此值与设备及应用都相关,即不同的apk/ipa安装到同一台设备上的值都不相同。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ clientid?: string | undefined; /** * 第三方推送服务的应用标识 * 第三方推送服务器管理的应用标识,通常需要在第三方推送服务器平台进行注册获取。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ appid?: string | undefined; /** * 第三方推送服务器的应用键值 * 第三方推送服务器管理的应用键值,通常需要在第三方推送服务器平台进行注册获取。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ appkey?: string | undefined; @@ -14699,32 +15001,32 @@ interface PlusPushClientInfo { /** * JSON对象,推送消息对象 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ interface PlusPushPushMessage { /** * 推送消息显示的标题 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ title?: string | undefined; /** * 推送消息显示的内容 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ content?: string | undefined; /** * 推送消息承载的数据 * 如果推送消息中传输的数据不符合JSON格式,则作为String类型数据保存。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ payload?: any; /** * Apple APNS推送协议数据 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ aps?: any; @@ -14732,35 +15034,35 @@ interface PlusPushPushMessage { /** * JSON对象,获客户端创建本地消息的参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ interface PlusPushMessageOptions { /** * 要启动流应用的appid * 默认值为当前流应用的appid。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ appid?: string | undefined; /** * 是否覆盖上一次提示的消息 * 可取值true或false,true为覆盖,false不覆盖,默认为permission中设置的cover值。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ cover?: boolean | undefined; /** * 提示消息延迟显示的时间 * 当设备接收到推送消息后,可不立即显示,而是延迟一段时间显示,延迟时间单位为s,默认为0s,立即显示。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ delay?: number | undefined; /** * 推送消息的图标 * 本地图片地址,相对路径 - 相对于当前页面的host位置,如"a.jpg",注意当前页面为网络地址则不支持; 绝对路径 - 系统绝对路径,如Android平台"/sdcard/logo.png",此类路径通常通过其它5+ API获取的; 扩展相对路径URL(RelativeURL) - 以"_"开头的相对路径,如"_www/a.jpg"; 本地路径URL - 以“file://”开头,后面跟随系统绝对路径。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ icon?: string | undefined; @@ -14772,21 +15074,21 @@ interface PlusPushMessageOptions { * 默认值为“system”。 * - system: 使用系统通知提示音 * - none: 不使用提示音 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ - sound?: 'system' | 'none' | undefined; + sound?: "system" | "none" | undefined; /** * 推送消息的标题 * 在系统消息中心显示的通知消息标题,默认值为程序的名称。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ title?: string | undefined; /** * 消息上显示的提示时间 * 默认为当前时间,如果延迟显示则使用延时后显示消息的时间。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/push.html](http://www.html5plus.org/doc/zh_cn/push.html) */ when?: Date | undefined; @@ -14794,55 +15096,55 @@ interface PlusPushMessageOptions { /** * Share模块管理客户端的社交分享功能,提供调用终端社交软件的分享能力。通过plus.share可获取社交分享管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ interface PlusShare { /** * JSON对象,分享授权认证参数选项 * 此对象支持的属性值由分享服务的授权认证模块定义。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ AuthOptions?: PlusShareAuthOptions | undefined; /** * 分享授权控件对象 * Authorize对象表示分享控件对象,用于在窗口中显示分享控件,使用此对象可自定义分享授权界面。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ Authorize?: PlusShareAuthorize | undefined; /** * JSON对象,用户位置信息 * GeoPosition对象用于表示用户分享消息时的位置信息。用于标识分享操作时用户的位置信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ GeoPosition?: PlusShareGeoPosition | undefined; /** * 分享服务对象 * ShareService对象用于表示分享服务,在JS中为对象,用于向系统请求分享操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ ShareService?: PlusShareShareService | undefined; /** * 分享服务标识 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ ShareServerIdentity?: PlusShareShareServerIdentity | undefined; /** * JSON对象,分享消息对象 * ShareMessage对象用于表示分享消息内容,在JS中为JSON对象,用于向系统发送分享信息操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ ShareMessage?: PlusShareShareMessage | undefined; /** * JSON对象,保存分享消息扩展信息 * ShareMessageExtra对象用于保存各分享平台扩展的参数,用于自定义分享功能。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ ShareMessageExtra?: PlusShareShareMessageExtra | undefined; @@ -14850,22 +15152,22 @@ interface PlusShare { * JSON对象,微信小程序信息 * 用于配置分享小程序的参数,如小程序标识、页面路径等。 * 注意:分享的小程序需要在微信开放平台关联的开发者账号下,否则会分享失败。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ WeixinMiniProgramOptions?: PlusShareWeixinMiniProgramOptions | undefined; /** * 获取分享服务 * 获取终端支持的分享通道列表,可用于提示用户进行分享服务器的选择。获取分享服务成功后通过successCB回调返回支持的所有服务列表,获取服务失败则通过errorCB回调返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ - getServices(successCB?: (result: PlusShare []) => void, errorCB?: (result: any) => void): void; + getServices(successCB?: (result: PlusShare[]) => void, errorCB?: (result: any) => void): void; /** * 使用系统组件发送分享 * 调用系统分享组件分享消息,通过msg参数设置分享内容。 * 发送成功后通过successCB回调函数通知操作完成,发送失败则通过errorCB回调返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ sendWithSystem(msg?: PlusShareShareMessage, successCB?: () => void, errorCB?: (result: any) => void): void; @@ -14874,7 +15176,7 @@ interface PlusShare { /** * JSON对象,分享授权认证参数选项 * 此对象支持的属性值由分享服务的授权认证模块定义。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ interface PlusShareAuthOptions { @@ -14882,7 +15184,7 @@ interface PlusShareAuthOptions { * 分享服务平台申请的appid * 动态设置分享服务授权认证时需要使用的appid,仅需要此参数的分享服务(如“微信”、“QQ”)支持。 * 如果未设置则使用运行环境中内置的appid值(如在HBuilder中可在manifest.json的“SDK配置”项中进行设置)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ appid?: string | undefined; @@ -14890,7 +15192,7 @@ interface PlusShareAuthOptions { * 分享服务平台申请的appkey * 动态设置分享服务授权认证时需要使用的appkey,仅需要此参数的分享服务(如“新浪微博”)支持。 * 如果未设置则使用运行环境中内置的appkey值(如在HBuilder中可在manifest.json的“SDK配置”项中进行设置)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ appkey?: string | undefined; @@ -14898,7 +15200,7 @@ interface PlusShareAuthOptions { * 分享服务平台申请的appsecret * 动态设置分享服务中需要使用的appsecret,仅需要此参数的分享服务(如“微信”、“新浪微博”)支持。 * 如果未设置则使用运行环境中内置的appsecret值(如在HBuilder中可在manifest.json的“SDK配置”项中进行设置);当开放平台申请的appsecret值涉及到安全问题时,可在应用运行时从服务器获取,然后通过此api动态设置。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ appsecret?: string | undefined; @@ -14906,7 +15208,7 @@ interface PlusShareAuthOptions { * 分享服务平台申请的redirect_url * 动态设置分享服务中需要使用的redirect_url,仅需要此参数的登录授权服务(如“新浪微博登录”)支持。 * 如果未设置则使用运行环境中内置的redirect_url值(如在HBuilder中可在manifest.json的SDK配置项中进行设置)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ redirect_url?: string | undefined; @@ -14915,42 +15217,42 @@ interface PlusShareAuthOptions { /** * 分享授权控件对象 * Authorize对象表示分享控件对象,用于在窗口中显示分享控件,使用此对象可自定义分享授权界面。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ interface PlusShareAuthorize { /** * 分享控件加载完成事件 * 分享授权控件内容加载完成事件,通过调用load方法加载分享授权控件内容,当内容加载完成时触发。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ onloaded?: ((result: any) => void) | undefined; /** * 分享授权认证成功事件 * 用户在分享授权控件上输入操作授权成功时触发,事件方法格式参考ShareSuccessCallback回调函数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ onauthenticated?: (() => void) | undefined; /** * 分享授权认证失败事件 * 用户在分享授权控件上输入操作授权认证错误时触发,事件方法格式参考ShareErrorCallback回调函数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ onerror?: ((result: any) => void) | undefined; /** * 加载分享授权页面 * 创建分享授权页面后,需要调用此方法指定分享服务标识来加载授权页面数据,此标识可使用ShareService对象的id属性。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ load(id?: string): void; /** * 设置分享授权控件是否可见 * 创建分享授权页面后,调用此方法设置分享授权控件在页面中是否可见。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ setVisible(visible?: boolean): void; @@ -14959,19 +15261,19 @@ interface PlusShareAuthorize { /** * JSON对象,用户位置信息 * GeoPosition对象用于表示用户分享消息时的位置信息。用于标识分享操作时用户的位置信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ interface PlusShareGeoPosition { /** * 用户位置的纬度坐标信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ latitude?: number | undefined; /** * 用户位置的经度坐标信息 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ longitude?: number | undefined; @@ -14980,7 +15282,7 @@ interface PlusShareGeoPosition { /** * 分享服务对象 * ShareService对象用于表示分享服务,在JS中为对象,用于向系统请求分享操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ interface PlusShareShareService { @@ -14991,7 +15293,7 @@ interface PlusShareShareService { * "tencentweibo" - 表示腾讯微博; * "weixin" - 表示微信; * "qq" - 表示腾讯QQ。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ id?: PlusShareShareServerIdentity | undefined; @@ -14999,28 +15301,28 @@ interface PlusShareShareService { * 分享服务描述 * 用于描述分享服务的信息: * 如“新浪微博”、“腾讯微博”、“微信”、“QQ”。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ description?: string | undefined; /** * 是否授权认证 * 用于标识此分享是否已经授权认证过,true表示已完成授权认证;false表示未完成授权认证。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ authenticated?: boolean | undefined; /** * 授权认证信息 * 仅在authenticated为true时有效,标识客户认证标识信息,用于发送分享信息。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ accessToken?: string | undefined; /** * 是否存在对应的分享客户端 * 对于某些分享服务,可直接调用本地客户端程序进行授权认证,此属性即可提供此相关信息,若没有安装本地客户端则可能调用其它方式进行分享操作,如WAP方式等。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ nativeClient?: boolean | undefined; @@ -15028,14 +15330,18 @@ interface PlusShareShareService { * 授权认证操作 * 对指定的分享服务进行授权认证操作,在授权前可通过ShareService.authenticated属性判断是否已经授权过,通常只需要对没有进行过授权认证的服务进行授权认证操作。 * 授权认证操作成功后通过successCB回调函数通知操作完成,操作失败则通过errorCB回调返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ - authorize(successCallback?: (result: PlusShareShareService) => void, errorCallback?: (result: any) => void, options?: PlusShareAuthOptions): void; + authorize( + successCallback?: (result: PlusShareShareService) => void, + errorCallback?: (result: any) => void, + options?: PlusShareAuthOptions, + ): void; /** * 取消授权认证 * 对指定的分享服务取消授权认证操作,取消授权认证后,再次分享时需重新进行授权操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ forbid(): void; @@ -15043,14 +15349,14 @@ interface PlusShareShareService { * 发送分享 * 发送分享消息,分享消息的内容通过msg设置。 * 发送成功后通过successCB回调函数通知操作完成,发送失败则通过errorCB回调返回。若分享服务没有进行授权认证或授权认证失效则触发失败回调函数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ send(msg?: PlusShareShareMessage, successCB?: () => void, errorCB?: (result: any) => void): void; /** * 调用微信小程序 * 注意:需在微信开放平台将应用关联小程序才能正常调用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ launchMiniProgram(options?: PlusShareWeixinMiniProgramOptions): void; @@ -15058,25 +15364,25 @@ interface PlusShareShareService { /** * 分享服务标识 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ interface PlusShareShareServerIdentity { /** * 新浪微博 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ sinaweibo?: string | undefined; /** * 腾讯微博 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ tencentweibo?: string | undefined; /** * 微信 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ weixin?: string | undefined; @@ -15085,20 +15391,19 @@ interface PlusShareShareServerIdentity { /** * JSON对象,分享消息对象 * ShareMessage对象用于表示分享消息内容,在JS中为JSON对象,用于向系统发送分享信息操作。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ interface PlusShareShareMessage { /** * 分享消息的类型 - * - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ type?: string | undefined; /** * 分享消息的文字内容 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ content?: string | undefined; @@ -15107,20 +15412,20 @@ interface PlusShareShareMessage { * 分享消息中包含的图片路径,仅支持本地路径。 * 若分享平台仅支持提交一张图片,传入多张图片则仅提交第一张图片。 * 如果未指定type类型,优先级顺序为:pictures>content(即设置了pictures则认为分享图片类型)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ - pictures?: any [] | undefined; + pictures?: any[] | undefined; /** * 分享消息的缩略图 * 分享消息中包含的缩略图路径,支持本地路径及网络路径。 * 若分享平台仅支持提交一张图片,传入多张图片则仅提交第一张图片。 * 如果分享平台的信息不支持缩略图,若没有设置消息的图片(pictures)则使用缩略图,否则忽略其属性值。 * 注意:图片有大小限制,推荐图片小于20Kb。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ - thumbs?: any [] | undefined; + thumbs?: any[] | undefined; /** * 分享的多媒体资源 * 分享的多媒体资源地址,当type值为"music"、"video"时有效。 @@ -15128,7 +15433,7 @@ interface PlusShareShareMessage { * 微信分享平台支持音乐、视频类型,仅支持网络地址(以http://或https://开头); * QQ分享平台支持音乐类型,仅支持网络路径(以http://或https://开头); * 新浪微博分享平台支持视频类型,仅支持本地文件路径。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ media?: string | undefined; @@ -15136,33 +15441,33 @@ interface PlusShareShareMessage { * 分享独立的链接 * 分享资源地址,仅支持网络地址(以http://或https://开头)。 * 如果未指定type类型,优先级顺序为:href>pictures>content(即设置了href则认为分享网页类型)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ href?: string | undefined; /** * 分享消息的标题 * 仅微信分享网页、音频、视频、小程序类型时支持。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ title?: string | undefined; /** * 分享消息中包含的用户地理信息数据 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ geo?: PlusShareGeoPosition | undefined; /** * 分享消息扩展参数 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ extra?: PlusShareShareMessageExtra | undefined; /** * 分享微信小程序参数 * 仅微信分享小程序类型时支持。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ miniProgram?: PlusShareWeixinMiniProgramOptions | undefined; @@ -15174,25 +15479,24 @@ interface PlusShareShareMessage { * "editable" - 进入编辑界面,用户确认分享内容后发送,如果当前未安装微博客户端则触发错误回调。 * 默认值为"auto"。 * (仅新浪微博分享时生效) - * - auto: + * - auto: * 自动选择,如果已经安装微博客户端则采用编辑界面进行分享,否则采用无界面分享 - * - * - slient: + * + * - slient: * 静默分享,采用无界面模式进行分享 - * - * - editable: + * + * - editable: * 进入编辑界面,用户确认分享内容后发送,如果当前未安装微博客户端则触发错误回调 - * - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ - interface?: 'auto' | 'slient' | 'editable' | undefined; + interface?: "auto" | "slient" | "editable" | undefined; } /** * JSON对象,保存分享消息扩展信息 * ShareMessageExtra对象用于保存各分享平台扩展的参数,用于自定义分享功能。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ interface PlusShareShareMessageExtra { @@ -15203,7 +15507,7 @@ interface PlusShareShareMessageExtra { * "WXSceneTimeline"分享到微信的“朋友圈”中; * "WXSceneFavorite"分享到微信的“我的收藏”中。 * 默认值为"WXSceneSession"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ scene?: string | undefined; @@ -15213,20 +15517,20 @@ interface PlusShareShareMessageExtra { * JSON对象,微信小程序信息 * 用于配置分享小程序的参数,如小程序标识、页面路径等。 * 注意:分享的小程序需要在微信开放平台关联的开发者账号下,否则会分享失败。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ interface PlusShareWeixinMiniProgramOptions { /** * 微信小程序ID * 注意:是微信小程序的原始ID("g_"开头的字符串)。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ id?: string | undefined; /** * 微信小程序打开的页面路径 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ path?: string | undefined; @@ -15237,13 +15541,13 @@ interface PlusShareWeixinMiniProgramOptions { * 1-测试版; * 2-体验版。 * 默认值为0。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ type?: number | undefined; /** * 兼容低版本的网页链接 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/share.html](http://www.html5plus.org/doc/zh_cn/share.html) */ webUrl?: string | undefined; @@ -15251,59 +15555,67 @@ interface PlusShareWeixinMiniProgramOptions { /** * Speech模块管理语音输入功能,提供语音识别功能,可支持用户通过麦克风设备进行语音输入内容。通过plus.speech可获取语音输入管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) */ interface PlusSpeech { /** * JSON对象,语音识别参数 * 控制语音识别引擎内部参数,在JS中为JSON对象,在启动语音识别时使用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) */ SpeechRecognizeOptions?: PlusSpeechSpeechRecognizeOptions | undefined; /** * 语音识别事件类型 * 描述语音过程的触发事件列表,可以通过调用plus.sppech.addEventListener方法进行注册监听。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) */ SpeechRecoginzeEvents?: PlusSpeechSpeechRecoginzeEvents | undefined; /** * 启动语音识别 * 启动语音识别时调用,当语音识别成功后通过successCallback回调返回识别出文本内容,调用语音识别失败则通过errorCallback回调返回。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) */ - startRecognize(options?: PlusSpeechSpeechRecognizeOptions, successCB?: (result: string) => void, errorCB?: (result: any) => void): void; + startRecognize( + options?: PlusSpeechSpeechRecognizeOptions, + successCB?: (result: string) => void, + errorCB?: (result: any) => void, + ): void; /** * 停止语音识别 * 当语音识别完成时或用户取消语音识别时调用,调用此方法将导致errorCallback回调函数的调用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) */ stopRecognize(): void; /** * 监听语音识别事件 - * 向语音识别模块添加事件监听器,当指定的事件发生时,将触发listener函数的执行。 + * 向语音识别模块添加事件监听器,当指定的事件发生时,将触发listener函数的执行。 * 可多次调用此方法添加多个监听器,当监听的事件发生时,将按照添加的先后顺序触发执行。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) */ - addEventListener(event?: PlusSpeechSpeechRecoginzeEvents, listener?: (result: any) => void, capture?: boolean): void; + addEventListener( + event?: PlusSpeechSpeechRecoginzeEvents, + listener?: (result: any) => void, + capture?: boolean, + ): void; } /** * JSON对象,语音识别参数 * 控制语音识别引擎内部参数,在JS中为JSON对象,在启动语音识别时使用。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) */ interface PlusSpeechSpeechRecognizeOptions { /** * 语音识别是否采用持续模式 * 设置为true表示语音引擎不会根据语音输入自动结束,识别到文本内容将多次调用successCallback函数返回,如果需要结束语音识别则必须调用stopRecognize接口,默认值为false。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) */ continue?: boolean | undefined; @@ -15313,7 +15625,7 @@ interface PlusSpeechSpeechRecognizeOptions { * 支持以下语音识别引擎: * "baidu"-百度语音识别; * "iFly"-讯飞语音识别。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) */ engine?: string | undefined; @@ -15326,14 +15638,14 @@ interface PlusSpeechSpeechRecognizeOptions { * "zh-cantonese"-中文,粤语; * "zh-henanese"-中文,河南话(百度语音识别不支持此语言)。 * 默认值为"zh-cn"。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) */ lang?: string | undefined; /** * 指定识别结果识别包括多候选结果 * 用于指定识别结果识别包括多候选结果。如nbest:3,识别返回3个候选结果,默认值为1。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) */ nbest?: number | undefined; @@ -15341,7 +15653,7 @@ interface PlusSpeechSpeechRecognizeOptions { * 识别结果中是否包含标点符号 * true表示识别结果文本中包含标点符号,false表示识别结果文本中不包含标点符号。 * 默认值为true。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) */ punctuation?: boolean | undefined; @@ -15349,14 +15661,14 @@ interface PlusSpeechSpeechRecognizeOptions { * 语音识别超时时间 * 语音识别超时的时间,单位为ms,默认值为1000(即10秒)。 * 注:百度语音识别不支持此参数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) */ timeout?: number | undefined; /** * 识别时是否显示用户界面 * 用于指定识别时是否显示用户界面,设置为true表示显示浏览器内置语音识别界面;设置为false表示不显示浏览器内置语音识别界面。默认值为true。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) */ userInterface?: boolean | undefined; @@ -15364,7 +15676,7 @@ interface PlusSpeechSpeechRecognizeOptions { * 语音识别开始事件(已废弃,使用start事件) * 事件函数,语音识别开始启动,在调用startRecognize方法后触发,与onend事件成对触发。 * 注:iOS平台未支持 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) */ onstart?: ((result: any) => void) | undefined; @@ -15372,7 +15684,7 @@ interface PlusSpeechSpeechRecognizeOptions { * 语音识别结束事件(已废弃,使用end事件) * 事件函数,语音识别结束,在调用stopRecognize方法后触发,或者在引擎内部自动完成语音识别后触发,与onstart事件成对触发。 * 注:iOS平台未支持 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) */ onend?: ((result: any) => void) | undefined; @@ -15381,7 +15693,7 @@ interface PlusSpeechSpeechRecognizeOptions { /** * 语音识别事件类型 * 描述语音过程的触发事件列表,可以通过调用plus.sppech.addEventListener方法进行注册监听。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) */ interface PlusSpeechSpeechRecoginzeEvents { @@ -15389,7 +15701,7 @@ interface PlusSpeechSpeechRecoginzeEvents { * 开始语音识别 * 调用plus.speech.startRecognize方法开始语音识别时触发。 * 无回调函数参数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) */ start?: string | undefined; @@ -15397,7 +15709,7 @@ interface PlusSpeechSpeechRecoginzeEvents { * 音量变化 * 开始语音识别后,麦克风录制到的语音音量变化时触发。 * 回调函数参数event={volume:"Number类型,取值范围0-1"}。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) */ volumeChange?: string | undefined; @@ -15405,7 +15717,7 @@ interface PlusSpeechSpeechRecoginzeEvents { * 临时语音识别结果 * 返回临时语音识别结果时触发。 * 回调函数参数event={partialResult:"String类型,临时识别结果"}。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) */ recognizing?: string | undefined; @@ -15413,7 +15725,7 @@ interface PlusSpeechSpeechRecoginzeEvents { * 最终语音识别 * 返回最终语音识别结果。 * 回调函数参数event={result:"String类型,最佳识别结果",results:"String数组类型,所有候选结果"}。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) */ recognition?: string | undefined; @@ -15421,7 +15733,7 @@ interface PlusSpeechSpeechRecoginzeEvents { * 结束语音识别 * 调用plus.speech.stopRecognize方法结束语音识别或语音识别完成后自动结束时触发。 * 无回调函数参数。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) */ end?: string | undefined; @@ -15429,7 +15741,7 @@ interface PlusSpeechSpeechRecoginzeEvents { * 语音识别错误 * 语音识别发生错误时触发。 * 回调函数参数event={code:"Number类型,错误编码",message:"String类型,错误描述信息"}。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/speech.html](http://www.html5plus.org/doc/zh_cn/speech.html) */ error?: string | undefined; @@ -15437,35 +15749,35 @@ interface PlusSpeechSpeechRecoginzeEvents { /** * Statistic模块管理统计功能,用于提供应用内统计的能力,支持统计和分析用户属性和用户行为数据。通过plus.statistic可获取统计管理对象。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/statistic.html](http://www.html5plus.org/doc/zh_cn/statistic.html) */ interface PlusStatistic { /** * 触发事件 * 触发指定的统计事件,触发的事件必须要先在统计网站上注册事件ID。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/statistic.html](http://www.html5plus.org/doc/zh_cn/statistic.html) */ eventTrig(id?: string, value?: any): void; /** * 精确持续事件 * 精确时长的持续事件统计,触发的事件必须要先在统计网站上注册事件ID。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/statistic.html](http://www.html5plus.org/doc/zh_cn/statistic.html) */ eventDuration(id?: string, duration?: number, value?: any): void; /** * 开始持续事件(过期API,不推荐使用) * 开始指定的持续事件统计,当事件结束时调用eventEnd方法,,触发的事件必须要先在统计网站上注册事件ID。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/statistic.html](http://www.html5plus.org/doc/zh_cn/statistic.html) */ eventStart(id?: string, value?: string): void; /** * 结束持续事件(过期API,不推荐使用) * 结束指定的持续事件统计,需先调用eventStart方法开始持续事件统计,触发的事件必须要先在统计网站上注册事件ID。 - * + * * 参考: [http://www.html5plus.org/doc/zh_cn/statistic.html](http://www.html5plus.org/doc/zh_cn/statistic.html) */ eventEnd(id?: string, label?: string): void; diff --git a/types/html_codesniffer/html_codesniffer-tests.ts b/types/html_codesniffer/html_codesniffer-tests.ts index 130f5adf29f8bf..e7689ff5afa48a 100644 --- a/types/html_codesniffer/html_codesniffer-tests.ts +++ b/types/html_codesniffer/html_codesniffer-tests.ts @@ -2,18 +2,18 @@ HTMLCS.ERROR; // $ExpectType 1 HTMLCS.NOTICE; // $ExpectType 3 HTMLCS.WARNING; // $ExpectType 2 -const container = document.getElementById('#container')!; +const container = document.getElementById("#container")!; -HTMLCS.addMessage(HTMLCS.ERROR, container, 'Test message', '34443'); +HTMLCS.addMessage(HTMLCS.ERROR, container, "Test message", "34443"); HTMLCS.getMessages(); // $ExpectType Message[] -HTMLCS.getTranslation('Hello World!'); // $ExpectType string +HTMLCS.getTranslation("Hello World!"); // $ExpectType string HTMLCS.isFullDoc(container); // $ExpectType boolean HTMLCS.lang; // $ExpectType string -HTMLCS.loadStandard('Section508', () => { +HTMLCS.loadStandard("Section508", () => { // }); HTMLCS.process( - 'Section508', + "Section508", container, () => { // done diff --git a/types/html_codesniffer/index.d.ts b/types/html_codesniffer/index.d.ts index c1e065c98b0069..bca911e4ceffe9 100644 --- a/types/html_codesniffer/index.d.ts +++ b/types/html_codesniffer/index.d.ts @@ -488,5 +488,5 @@ export namespace Util { headers: string; } - type DocumentType = 'html5' | 'xhtml5' | 'xhtml11' | 'xhtml10' | 'html401' | 'html40' | ''; + type DocumentType = "html5" | "xhtml5" | "xhtml11" | "xhtml10" | "html401" | "html40" | ""; } diff --git a/types/htmlbars-inline-precompile/htmlbars-inline-precompile-tests.ts b/types/htmlbars-inline-precompile/htmlbars-inline-precompile-tests.ts index 972800fee71c66..eb607e626c8dc2 100644 --- a/types/htmlbars-inline-precompile/htmlbars-inline-precompile-tests.ts +++ b/types/htmlbars-inline-precompile/htmlbars-inline-precompile-tests.ts @@ -1,4 +1,4 @@ -import hbs, { TemplateFactory } from 'htmlbars-inline-precompile'; +import hbs, { TemplateFactory } from "htmlbars-inline-precompile"; const likeThisDotRender = (s: TemplateFactory) => {}; diff --git a/types/htmlhint/htmlhint-tests.ts b/types/htmlhint/htmlhint-tests.ts index f1c69d1297d4b4..45f7bbf40abb59 100644 --- a/types/htmlhint/htmlhint-tests.ts +++ b/types/htmlhint/htmlhint-tests.ts @@ -1,24 +1,24 @@ -import { HTMLHint } from 'htmlhint'; -import { Rule, Ruleset } from 'htmlhint/types'; +import { HTMLHint } from "htmlhint"; +import { Rule, Ruleset } from "htmlhint/types"; const htmlHintRules: Ruleset = { - 'tagname-lowercase': true, - 'attr-lowercase': true, - 'attr-value-double-quotes': true, - 'doctype-first': true, - 'tag-pair': true, - 'spec-char-escape': true, - 'id-unique': true, - 'src-not-empty': true, - 'attr-no-duplication': true, - 'title-require': true, - 'space-tab-mixed-disabled': 'tab', + "tagname-lowercase": true, + "attr-lowercase": true, + "attr-value-double-quotes": true, + "doctype-first": true, + "tag-pair": true, + "spec-char-escape": true, + "id-unique": true, + "src-not-empty": true, + "attr-no-duplication": true, + "title-require": true, + "space-tab-mixed-disabled": "tab", }; const rule: Rule = { - id: 'custom-rule', - description: 'Custom rule', - link: '../custom-rule', + id: "custom-rule", + description: "Custom rule", + link: "../custom-rule", init(parser, reporter) { parser; // $ExpectType HTMLParser reporter; // $ExpectType Reporter @@ -28,7 +28,7 @@ const rule: Rule = { HTMLHint.addRule(rule); // $ExpectType void // $ExpectType Hint[] -const result = HTMLHint.verify('<span></span>', htmlHintRules); +const result = HTMLHint.verify("<span></span>", htmlHintRules); // $ExpectType string[] const formatted = HTMLHint.format(result, { indent: 2 }); diff --git a/types/htmlhint/index.d.ts b/types/htmlhint/index.d.ts index 7edc9a1c52132a..b0d90f3a4a9d49 100644 --- a/types/htmlhint/index.d.ts +++ b/types/htmlhint/index.d.ts @@ -4,10 +4,10 @@ // Martin Badin <https://github.com/martin-badin/> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import HTMLParser from './htmlparser'; -import Reporter from './reporter'; -import * as HTMLRules from './rules'; -import { Hint, Rule, Ruleset } from './types'; +import HTMLParser from "./htmlparser"; +import Reporter from "./reporter"; +import * as HTMLRules from "./rules"; +import { Hint, Rule, Ruleset } from "./types"; export as namespace HTMLHint; @@ -27,4 +27,4 @@ declare class HTMLHintCore { export const HTMLHint: HTMLHintCore; -export { HTMLRules, Reporter, HTMLParser }; +export { HTMLParser, HTMLRules, Reporter }; diff --git a/types/htmlhint/reporter.d.ts b/types/htmlhint/reporter.d.ts index 66ff2d1caa3ea1..91c2b7aeda817f 100644 --- a/types/htmlhint/reporter.d.ts +++ b/types/htmlhint/reporter.d.ts @@ -1,4 +1,4 @@ -import { Hint, Rule, Ruleset, ReportType } from './types'; +import { Hint, ReportType, Rule, Ruleset } from "./types"; export default class Reporter { html: string; diff --git a/types/htmlhint/rules.d.ts b/types/htmlhint/rules.d.ts index 65427448d0f937..46b7fea30ccb38 100644 --- a/types/htmlhint/rules.d.ts +++ b/types/htmlhint/rules.d.ts @@ -1,4 +1,4 @@ -import { Rule } from './types'; +import { Rule } from "./types"; declare const Rules: Rule[]; diff --git a/types/htmlhint/types.d.ts b/types/htmlhint/types.d.ts index 7a09650b9610b5..fa84333ef6017a 100644 --- a/types/htmlhint/types.d.ts +++ b/types/htmlhint/types.d.ts @@ -1,4 +1,4 @@ -import { HTMLParser, Reporter } from './'; +import { HTMLParser, Reporter } from "./"; export interface Rule { id: string; @@ -8,57 +8,57 @@ export interface Rule { } export interface Ruleset { - 'alt-require'?: boolean; - 'attr-lowercase'?: boolean | Array<string | RegExp>; - 'attr-no-duplication'?: boolean; - 'attr-no-unnecessary-whitespace'?: boolean; - 'attr-sorted'?: boolean; - 'attr-unsafe-chars'?: boolean; - 'attr-value-double-quotes'?: boolean; - 'attr-value-not-empty'?: boolean; - 'attr-value-single-quotes'?: boolean; - 'attr-whitespace'?: boolean; - 'doctype-first'?: boolean; - 'doctype-html5'?: boolean; - 'empty-tag-not-self-closed'?: boolean; - 'head-script-disabled'?: boolean; - 'href-abs-or-rel'?: 'abs' | 'rel'; - 'id-class-ad-disabled'?: boolean; - 'id-class-value'?: 'underline' | 'dash' | 'hump' | { regId: RegExp; message: string }; - 'id-unique'?: boolean; - 'inline-script-disabled'?: boolean; - 'inline-style-disabled'?: boolean; - 'input-requires-label'?: boolean; - 'script-disabled'?: boolean; - 'space-tab-mixed-disabled'?: + "alt-require"?: boolean; + "attr-lowercase"?: boolean | Array<string | RegExp>; + "attr-no-duplication"?: boolean; + "attr-no-unnecessary-whitespace"?: boolean; + "attr-sorted"?: boolean; + "attr-unsafe-chars"?: boolean; + "attr-value-double-quotes"?: boolean; + "attr-value-not-empty"?: boolean; + "attr-value-single-quotes"?: boolean; + "attr-whitespace"?: boolean; + "doctype-first"?: boolean; + "doctype-html5"?: boolean; + "empty-tag-not-self-closed"?: boolean; + "head-script-disabled"?: boolean; + "href-abs-or-rel"?: "abs" | "rel"; + "id-class-ad-disabled"?: boolean; + "id-class-value"?: "underline" | "dash" | "hump" | { regId: RegExp; message: string }; + "id-unique"?: boolean; + "inline-script-disabled"?: boolean; + "inline-style-disabled"?: boolean; + "input-requires-label"?: boolean; + "script-disabled"?: boolean; + "space-tab-mixed-disabled"?: | boolean - | 'space' - | 'space1' - | 'space2' - | 'space3' - | 'space4' - | 'space5' - | 'space6' - | 'space7' - | 'space8' - | 'tab'; - 'spec-char-escape'?: boolean; - 'src-not-empty'?: boolean; - 'style-disabled'?: boolean; - 'tag-pair'?: boolean; - 'tag-self-close'?: boolean; - 'tagname-lowercase'?: boolean; - 'tagname-specialchars'?: boolean; - 'tags-check'?: { [tagName: string]: Record<string, unknown> }; - 'title-require'?: boolean; + | "space" + | "space1" + | "space2" + | "space3" + | "space4" + | "space5" + | "space6" + | "space7" + | "space8" + | "tab"; + "spec-char-escape"?: boolean; + "src-not-empty"?: boolean; + "style-disabled"?: boolean; + "tag-pair"?: boolean; + "tag-self-close"?: boolean; + "tagname-lowercase"?: boolean; + "tagname-specialchars"?: boolean; + "tags-check"?: { [tagName: string]: Record<string, unknown> }; + "title-require"?: boolean; // There may be other unknown rules [ruleId: string]: unknown; } export enum ReportType { - error = 'error', - warning = 'warning', - info = 'info', + error = "error", + warning = "warning", + info = "info", } export interface Hint { diff --git a/types/htmlparser2/htmlparser2-tests.ts b/types/htmlparser2/htmlparser2-tests.ts index 807f2fe904489e..bf3ae7bb00403d 100644 --- a/types/htmlparser2/htmlparser2-tests.ts +++ b/types/htmlparser2/htmlparser2-tests.ts @@ -1,19 +1,19 @@ /** * Created by staticfunction on 8/4/14. */ -import htmlparser = require('htmlparser2'); +import htmlparser = require("htmlparser2"); -const options: htmlparser.DomHandlerOptions = { withEndIndices: false, withDomLvl1: true } +const options: htmlparser.DomHandlerOptions = { withEndIndices: false, withDomLvl1: true }; const dh = new htmlparser.DomHandler((err: Error, dom: htmlparser.DomElement[]) => { - if(err) { + if (err) { throw err; } // Use DomUtils to get name of first element in dom console.log(htmlparser.DomUtils.getName(dom[0])); }, options); -dh.onopentag = (name:string, attribs:{[s:string]:string}) => { - if(name === "script" && attribs['type'] === "text/javascript"){ +dh.onopentag = (name: string, attribs: { [s: string]: string }) => { + if (name === "script" && attribs["type"] === "text/javascript") { console.log("JS! Hooray!"); } }; diff --git a/types/htmlparser2/index.d.ts b/types/htmlparser2/index.d.ts index b4bc8df4ba86f6..f18f5932bd8fcd 100644 --- a/types/htmlparser2/index.d.ts +++ b/types/htmlparser2/index.d.ts @@ -7,17 +7,16 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 -///<reference types="node"/> -///<reference types="domhandler"/> -///<reference types="domutils"/> +/// <reference types="node"/> +/// <reference types="domhandler"/> +/// <reference types="domutils"/> -import { Writable } from 'stream' -import { DomHandler } from 'domhandler'; -import * as DomUtils from 'domutils'; -export { DomElement, DomHandlerOptions, DomHandler, Element, Node } from 'domhandler'; +import { DomHandler } from "domhandler"; +import * as DomUtils from "domutils"; +import { Writable } from "stream"; +export { DomElement, DomHandler, DomHandlerOptions, Element, Node } from "domhandler"; export interface ParserOptions { - /*** * Indicates whether special tags (<script> and <style>) should get special treatment * and if "empty" tags (eg. <br>) can have children. If false, the content of special tags @@ -53,10 +52,10 @@ export interface ParserOptions { */ recognizeSelfClosing?: boolean | undefined; } -/** +/** * @deprecated */ -export type Options = ParserOptions +export type Options = ParserOptions; export declare class WritableStream extends Writable { constructor(handler: DomHandler, options?: ParserOptions); @@ -127,4 +126,4 @@ export declare class Parser { onend(): void; } -export { DomUtils } +export { DomUtils }; diff --git a/types/htmltojsx/htmltojsx-tests.ts b/types/htmltojsx/htmltojsx-tests.ts index 5f13815f6d2694..624f6fb7aaaded 100644 --- a/types/htmltojsx/htmltojsx-tests.ts +++ b/types/htmltojsx/htmltojsx-tests.ts @@ -1,6 +1,6 @@ import HTMLtoJSX = require("htmltojsx"); var converter = new HTMLtoJSX({ - createClass: true, - outputClassName: 'AwesomeComponent' + createClass: true, + outputClassName: "AwesomeComponent", }); -var output = converter.convert('<div>Hello world!</div>'); +var output = converter.convert("<div>Hello world!</div>"); diff --git a/types/htmltojsx/index.d.ts b/types/htmltojsx/index.d.ts index 80284546fbbad8..24fd70d36ac995 100644 --- a/types/htmltojsx/index.d.ts +++ b/types/htmltojsx/index.d.ts @@ -3,7 +3,6 @@ // Definitions by: Basarat Ali Syed <https://github.com/basarat> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - declare class HTMLtoJSX { constructor(options?: { createClass?: boolean | undefined; diff --git a/types/http-agent/http-agent-tests.ts b/types/http-agent/http-agent-tests.ts index fd599c8f8451b5..bbddc7ecdd7c8f 100644 --- a/types/http-agent/http-agent-tests.ts +++ b/types/http-agent/http-agent-tests.ts @@ -1,20 +1,20 @@ -import httpAgent = require('http-agent'); +import httpAgent = require("http-agent"); -let agent = new httpAgent.HttpAgent('api.github.com/octocat?test=1'); -agent.addListener('next', () => {}); +let agent = new httpAgent.HttpAgent("api.github.com/octocat?test=1"); +agent.addListener("next", () => {}); agent.url; // $ExpectType string agent.body; // $ExpectType string agent.port; // $ExpectType number agent.host; // $ExpectType string agent.options; // $ExpectType OptionsWithUri -agent = new httpAgent.HttpAgent('api.github.com', ['octocat?test=1']); -agent = new httpAgent.HttpAgent('https://api.github.com', [{ method: 'GET', uri: 'octocat?test=1' }]); -agent = new httpAgent.HttpAgent('example.com', ['/', 'page', 'another']); -agent = new httpAgent.HttpAgent('example.com', ['/', 'page', 'another'], { encoding: 'utf8' }); -agent = new httpAgent.HttpAgent({ host: 'example.com', urls: ['/', 'page', 'another'], encoding: 'utf8' }); -agent = new httpAgent.HttpAgent({ host: 'example.com', encoding: 'utf8' }, ['/', 'page', 'another']); -agent = httpAgent.create('https://api.github.com', [{ method: 'GET', uri: 'octocat?test=1' }]); -agent = httpAgent.create({ host: 'example.com', encoding: 'utf8' }, ['/', 'page', 'another']); +agent = new httpAgent.HttpAgent("api.github.com", ["octocat?test=1"]); +agent = new httpAgent.HttpAgent("https://api.github.com", [{ method: "GET", uri: "octocat?test=1" }]); +agent = new httpAgent.HttpAgent("example.com", ["/", "page", "another"]); +agent = new httpAgent.HttpAgent("example.com", ["/", "page", "another"], { encoding: "utf8" }); +agent = new httpAgent.HttpAgent({ host: "example.com", urls: ["/", "page", "another"], encoding: "utf8" }); +agent = new httpAgent.HttpAgent({ host: "example.com", encoding: "utf8" }, ["/", "page", "another"]); +agent = httpAgent.create("https://api.github.com", [{ method: "GET", uri: "octocat?test=1" }]); +agent = httpAgent.create({ host: "example.com", encoding: "utf8" }, ["/", "page", "another"]); agent.prevUrls; // $ExpectType string[] agent.nextUrls; // $ExpectType string[] -agent.addUrl('test'); // $ExpectType void +agent.addUrl("test"); // $ExpectType void diff --git a/types/http-agent/index.d.ts b/types/http-agent/index.d.ts index 6d48fca135c80c..a7b038b9c2adaf 100644 --- a/types/http-agent/index.d.ts +++ b/types/http-agent/index.d.ts @@ -3,8 +3,8 @@ // Definitions by: Ivan Ergunov <https://github.com/hozblok> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import EventEmitter = require('events'); -import request = require('request'); +import EventEmitter = require("events"); +import request = require("request"); export type HttpAgentUrl = string | request.OptionsWithUri; diff --git a/types/http-assert/http-assert-tests.ts b/types/http-assert/http-assert-tests.ts index 06175dd4574fa2..afd35a1df29e5d 100644 --- a/types/http-assert/http-assert-tests.ts +++ b/types/http-assert/http-assert-tests.ts @@ -1,10 +1,10 @@ -import httpAssert = require('http-assert'); +import httpAssert = require("http-assert"); declare function unknown(): unknown; (() => { const value = unknown(); - httpAssert(typeof value === 'string'); + httpAssert(typeof value === "string"); // $ExpectType string value; @@ -20,7 +20,7 @@ declare function unknown(): unknown; (() => { const value = unknown(); - httpAssert(typeof value === 'number', 400); + httpAssert(typeof value === "number", 400); // $ExpectType number value; @@ -28,7 +28,7 @@ declare function unknown(): unknown; (() => { const value = unknown(); - httpAssert(typeof value === 'boolean', 400, 'message'); + httpAssert(typeof value === "boolean", 400, "message"); // $ExpectType boolean value; @@ -36,7 +36,7 @@ declare function unknown(): unknown; (() => { const value = unknown(); - httpAssert(value === undefined, 400, { foo: 'bar' }); + httpAssert(value === undefined, 400, { foo: "bar" }); // $ExpectType undefined value; @@ -44,7 +44,7 @@ declare function unknown(): unknown; (() => { const value = unknown(); - httpAssert(value === null, 400, 'message', { foo: 'bar' }); + httpAssert(value === null, 400, "message", { foo: "bar" }); // $ExpectType null value; @@ -52,7 +52,7 @@ declare function unknown(): unknown; (() => { const value = unknown(); - httpAssert.ok(typeof value === 'string'); + httpAssert.ok(typeof value === "string"); // $ExpectType string value; @@ -68,7 +68,7 @@ declare function unknown(): unknown; (() => { const value = unknown(); - httpAssert.ok(typeof value === 'number', 400); + httpAssert.ok(typeof value === "number", 400); // $ExpectType number value; @@ -76,7 +76,7 @@ declare function unknown(): unknown; (() => { const value = unknown(); - httpAssert.ok(typeof value === 'boolean', 400, 'message'); + httpAssert.ok(typeof value === "boolean", 400, "message"); // $ExpectType boolean value; @@ -84,26 +84,26 @@ declare function unknown(): unknown; (() => { const value = unknown(); - httpAssert.ok(value === null, 400, 'message', { foo: 'bar' }); + httpAssert.ok(value === null, 400, "message", { foo: "bar" }); // $ExpectType null value; })(); const status = 401; -const message = 'some error message'; +const message = "some error message"; const options = {}; -httpAssert.equal('hello', 'hello'); -httpAssert.notEqual('hello', 'hello', status, message); +httpAssert.equal("hello", "hello"); +httpAssert.notEqual("hello", "hello", status, message); httpAssert.ok(true); httpAssert.ok(true, status, message, options); -httpAssert.strictEqual(3, '3'); -httpAssert.strictEqual(3, '3', status, message, options); -httpAssert.notStrictEqual(3, '3'); -httpAssert.notStrictEqual(3, '3', status, message, options); -httpAssert.deepEqual({ foo: 'foo' }, { bar: 'bar' }); -httpAssert.deepEqual({ foo: 'foo' }, { bar: 'bar' }, status, message, options); -httpAssert.notDeepEqual({ foo: 'foo' }, { bar: 'bar' }); -httpAssert.notDeepEqual({ foo: 'foo' }, { bar: 'bar' }, status, message, options); +httpAssert.strictEqual(3, "3"); +httpAssert.strictEqual(3, "3", status, message, options); +httpAssert.notStrictEqual(3, "3"); +httpAssert.notStrictEqual(3, "3", status, message, options); +httpAssert.deepEqual({ foo: "foo" }, { bar: "bar" }); +httpAssert.deepEqual({ foo: "foo" }, { bar: "bar" }, status, message, options); +httpAssert.notDeepEqual({ foo: "foo" }, { bar: "bar" }); +httpAssert.notDeepEqual({ foo: "foo" }, { bar: "bar" }, status, message, options); httpAssert(false, status, message, options); diff --git a/types/http-auth/index.d.ts b/types/http-auth/index.d.ts index d7d41e0a0dc6d4..eae609b0fe32da 100644 --- a/types/http-auth/index.d.ts +++ b/types/http-auth/index.d.ts @@ -6,13 +6,16 @@ /// <reference types="node" /> -import * as http from 'http'; -import { EventEmitter } from 'events'; +import { EventEmitter } from "events"; +import * as http from "http"; -type Qop = 'auth' | 'none'; -type Algorithm = 'MD5' | 'MD5-sess'; +type Qop = "auth" | "none"; +type Algorithm = "MD5" | "MD5-sess"; -type CheckedRequestListener = (req: http.IncomingMessage & { user?: string | undefined }, res: http.ServerResponse) => void; +type CheckedRequestListener = ( + req: http.IncomingMessage & { user?: string | undefined }, + res: http.ServerResponse, +) => void; type BasicChecker = (username: string, password: string, callback: (isAuthorized: boolean) => void) => void; type DigestChecker = (username: string, callback: (hash?: string) => void) => void; @@ -34,7 +37,7 @@ interface ClientOptions { uri: string; algorithm: Algorithm; response: string; - qop?: 'auth' | undefined; + qop?: "auth" | undefined; nc?: string | undefined; cnonce?: string | undefined; } @@ -103,9 +106,9 @@ type DigestOptions = BasicOptions & { declare abstract class Base extends EventEmitter { constructor(options: BasicOptions, checker?: BasicChecker | DigestChecker); - on(event: 'success', callback: (result: BasicResult<true> | DigestResult<true>) => void): this; - on(event: 'fail', callback: (result: BasicResult<false> | DigestResult<false>) => void): this; - on(event: 'error', callback: (err: Error) => void): this; + on(event: "success", callback: (result: BasicResult<true> | DigestResult<true>) => void): this; + on(event: "fail", callback: (result: BasicResult<false> | DigestResult<false>) => void): this; + on(event: "error", callback: (err: Error) => void): this; check(callback?: CheckedRequestListener): CheckedRequestListener; abstract processLine(userLine: string): void; @@ -150,4 +153,4 @@ declare class Digest extends Base { declare function basic(options: BasicOptions, checker?: BasicChecker): Basic; declare function digest(options: DigestOptions, checker?: DigestChecker): Digest; -export { basic, digest, BasicOptions, DigestOptions, BasicChecker, DigestChecker }; +export { basic, BasicChecker, BasicOptions, digest, DigestChecker, DigestOptions }; diff --git a/types/http-auth/test/http-auth-tests.basic.ts b/types/http-auth/test/http-auth-tests.basic.ts index 45b5713cb2c1fa..ac4fb935581b6e 100644 --- a/types/http-auth/test/http-auth-tests.basic.ts +++ b/types/http-auth/test/http-auth-tests.basic.ts @@ -1,9 +1,9 @@ -import * as http from 'http'; -import * as auth from 'http-auth'; +import * as http from "http"; +import * as auth from "http-auth"; const basic = auth.basic({ - realm: 'Simon Area.', - file: __dirname + '/../data/users.htpasswd', // gevorg:gpass, Sarah:testpass + realm: "Simon Area.", + file: __dirname + "/../data/users.htpasswd", // gevorg:gpass, Sarah:testpass }); const server = http.createServer(); @@ -16,5 +16,5 @@ http.createServer( }), ).listen(1337, () => { // Log URL. - console.log('Server running at http://127.0.0.1:1337/'); + console.log("Server running at http://127.0.0.1:1337/"); }); diff --git a/types/http-auth/test/http-auth-tests.basic_nofile.ts b/types/http-auth/test/http-auth-tests.basic_nofile.ts index 0a493033ed5b87..4fa92a25da8674 100644 --- a/types/http-auth/test/http-auth-tests.basic_nofile.ts +++ b/types/http-auth/test/http-auth-tests.basic_nofile.ts @@ -1,13 +1,13 @@ -import * as http from 'http'; -import * as auth from 'http-auth'; +import * as http from "http"; +import * as auth from "http-auth"; const basic = auth.basic( { - realm: 'Simon Area.', + realm: "Simon Area.", }, (username, password, callback) => { // Custom authentication method. - callback(username === 'Tina' && password === 'Bullock'); + callback(username === "Tina" && password === "Bullock"); }, ); @@ -18,5 +18,5 @@ http.createServer( }), ).listen(1337, () => { // Log URL. - console.log('Server running at http://127.0.0.1:1337/'); + console.log("Server running at http://127.0.0.1:1337/"); }); diff --git a/types/http-auth/test/http-auth-tests.digest.ts b/types/http-auth/test/http-auth-tests.digest.ts index cfd55fb176b3fa..40b3f02c2c2b35 100644 --- a/types/http-auth/test/http-auth-tests.digest.ts +++ b/types/http-auth/test/http-auth-tests.digest.ts @@ -1,23 +1,23 @@ -import * as http from 'http'; -import * as auth from 'http-auth'; -import * as crypto from 'crypto'; +import * as crypto from "crypto"; +import * as http from "http"; +import * as auth from "http-auth"; const md5 = (input: string) => { - const hash = crypto.createHash('MD5'); + const hash = crypto.createHash("MD5"); hash.update(input); - return hash.digest('hex'); + return hash.digest("hex"); }; const digest = auth.digest( { - realm: 'Simon Area.', + realm: "Simon Area.", }, (username, callback) => { // Expecting md5(username:realm:password) in callback. - if (username === 'simon') { - callback(md5('simon:Simon Area.:smart')); - } else if (username === 'tigran') { - callback(md5('tigran:Simon Area.:great')); + if (username === "simon") { + callback(md5("simon:Simon Area.:smart")); + } else if (username === "tigran") { + callback(md5("tigran:Simon Area.:great")); } else { callback(); } @@ -31,5 +31,5 @@ http.createServer( }), ).listen(1337, () => { // Log URL. - console.log('Server running at http://127.0.0.1:1337/'); + console.log("Server running at http://127.0.0.1:1337/"); }); diff --git a/types/http-auth/test/http-auth-tests.digest_nofile.ts b/types/http-auth/test/http-auth-tests.digest_nofile.ts index e08473e857a289..ce641c39b2047c 100644 --- a/types/http-auth/test/http-auth-tests.digest_nofile.ts +++ b/types/http-auth/test/http-auth-tests.digest_nofile.ts @@ -1,9 +1,9 @@ -import * as http from 'http'; -import * as auth from 'http-auth'; +import * as http from "http"; +import * as auth from "http-auth"; const digest = auth.digest({ - realm: 'Simon Area.', - file: __dirname + '/../data/users.htdigest', // vivi:anna, sona:testpass + realm: "Simon Area.", + file: __dirname + "/../data/users.htdigest", // vivi:anna, sona:testpass }); // Creating new HTTP server. @@ -13,5 +13,5 @@ http.createServer( }), ).listen(1337, () => { // Log URL. - console.log('Server running at http://127.0.0.1:1337/'); + console.log("Server running at http://127.0.0.1:1337/"); }); diff --git a/types/http-auth/test/http-auth-tests.events.ts b/types/http-auth/test/http-auth-tests.events.ts index 923e8ebd67b7e7..c65b01aadd52ea 100644 --- a/types/http-auth/test/http-auth-tests.events.ts +++ b/types/http-auth/test/http-auth-tests.events.ts @@ -1,21 +1,21 @@ -import * as http from 'http'; -import * as auth from 'http-auth'; +import * as http from "http"; +import * as auth from "http-auth"; const basic = auth.basic({ - realm: 'Simon Area.', - file: __dirname + '/../data/users.htpasswd', // gevorg:gpass, Sarah:testpass + realm: "Simon Area.", + file: __dirname + "/../data/users.htpasswd", // gevorg:gpass, Sarah:testpass }); // Adding event listeners. -basic.on('success', result => { +basic.on("success", result => { console.log(`User authenticated: ${result.user}`); }); -basic.on('fail', result => { +basic.on("fail", result => { console.log(`User authentication failed: ${result.user}`); }); -basic.on('error', error => { +basic.on("error", error => { console.log(`Authentication error: ${error.message}`); }); @@ -26,5 +26,5 @@ http.createServer( }), ).listen(1337, () => { // Log URL. - console.log('Server running at http://127.0.0.1:1337/'); + console.log("Server running at http://127.0.0.1:1337/"); }); diff --git a/types/http-auth/test/http-auth-tests.https.ts b/types/http-auth/test/http-auth-tests.https.ts index b8cc5f96cce89b..9970283061fd9f 100644 --- a/types/http-auth/test/http-auth-tests.https.ts +++ b/types/http-auth/test/http-auth-tests.https.ts @@ -1,16 +1,16 @@ -import * as https from 'https'; -import * as fs from 'fs'; -import * as auth from 'http-auth'; +import * as fs from "fs"; +import * as auth from "http-auth"; +import * as https from "https"; const basic = auth.basic({ - realm: 'Simon Area.', - file: __dirname + '/../data/users.htpasswd', // gevorg:gpass, Sarah:testpass + realm: "Simon Area.", + file: __dirname + "/../data/users.htpasswd", // gevorg:gpass, Sarah:testpass }); // HTTPS server options. const options = { - key: fs.readFileSync(__dirname + '/../data/server.key'), - cert: fs.readFileSync(__dirname + '/../data/server.crt'), + key: fs.readFileSync(__dirname + "/../data/server.key"), + cert: fs.readFileSync(__dirname + "/../data/server.crt"), }; // Starting server. @@ -23,5 +23,5 @@ https ) .listen(1337, () => { // Log URL. - console.log('Server running at https://127.0.0.1:1337/'); + console.log("Server running at https://127.0.0.1:1337/"); }); diff --git a/types/http-auth/test/http-auth-tests.proxy.ts b/types/http-auth/test/http-auth-tests.proxy.ts index e209b7a6f9ea98..5f8da8eed56694 100644 --- a/types/http-auth/test/http-auth-tests.proxy.ts +++ b/types/http-auth/test/http-auth-tests.proxy.ts @@ -1,11 +1,11 @@ -import * as http from 'http'; -import * as fs from 'fs'; -import * as auth from 'http-auth'; -import * as httpProxy from 'http-proxy'; +import * as fs from "fs"; +import * as http from "http"; +import * as auth from "http-auth"; +import * as httpProxy from "http-proxy"; const basic = auth.basic({ - realm: 'Simon Area.', - file: __dirname + '/../data/users.htpasswd', // gevorg:gpass, Sarah:testpass + realm: "Simon Area.", + file: __dirname + "/../data/users.htpasswd", // gevorg:gpass, Sarah:testpass proxy: true, }); @@ -13,16 +13,16 @@ const basic = auth.basic({ const proxy = httpProxy.createProxyServer({}); http.createServer( basic.check((req, res) => { - proxy.web(req, res, { target: 'http://127.0.0.1:1338' }); + proxy.web(req, res, { target: "http://127.0.0.1:1338" }); }), ).listen(1337); // Create your target server. http.createServer((req, res) => { - res.end('Request successfully proxied!'); + res.end("Request successfully proxied!"); }).listen(1338, () => { // Log URL. - console.log('Server running at http://127.0.0.1:1338/'); + console.log("Server running at http://127.0.0.1:1338/"); }); // You can test proxy authentication using curl. diff --git a/types/http-aws-es/index.d.ts b/types/http-aws-es/index.d.ts index 262e2a860ebe59..6e3bf6ab12659b 100644 --- a/types/http-aws-es/index.d.ts +++ b/types/http-aws-es/index.d.ts @@ -6,8 +6,8 @@ /// <reference types="node" /> -import * as e from "elasticsearch"; import * as AWS from "aws-sdk2-types"; +import * as e from "elasticsearch"; declare module "elasticsearch" { interface ConfigOptions { diff --git a/types/http-build-query/http-build-query-tests.ts b/types/http-build-query/http-build-query-tests.ts index 157f684601923f..f4adaaf8080e6c 100644 --- a/types/http-build-query/http-build-query-tests.ts +++ b/types/http-build-query/http-build-query-tests.ts @@ -1,6 +1,6 @@ -import httpBuildQuery from 'http-build-query'; +import httpBuildQuery from "http-build-query"; const queryString = httpBuildQuery({ - foo: 2, - bar: "bar", - null: null, + foo: 2, + bar: "bar", + null: null, }); diff --git a/types/http-cache-semantics/http-cache-semantics-tests.ts b/types/http-cache-semantics/http-cache-semantics-tests.ts index 73de43b370261d..cbc77479dad90e 100644 --- a/types/http-cache-semantics/http-cache-semantics-tests.ts +++ b/types/http-cache-semantics/http-cache-semantics-tests.ts @@ -1,7 +1,7 @@ -const req = { url: 'https://foo.bar', method: 'GET', headers: { foo: 'bar' } }; -const res = { status: 200, headers: { foo: 'bar' } }; +const req = { url: "https://foo.bar", method: "GET", headers: { foo: "bar" } }; +const res = { status: 200, headers: { foo: "bar" } }; -import CachePolicy = require('http-cache-semantics'); +import CachePolicy = require("http-cache-semantics"); const policy = new CachePolicy(req, res); new CachePolicy(req, res, { shared: true }); diff --git a/types/http-cache-semantics/index.d.ts b/types/http-cache-semantics/index.d.ts index 54c151344d00df..7272167033eb40 100644 --- a/types/http-cache-semantics/index.d.ts +++ b/types/http-cache-semantics/index.d.ts @@ -74,7 +74,7 @@ declare class CachePolicy { */ revalidatedPolicy( revalidationRequest: CachePolicy.Request, - revalidationResponse: CachePolicy.Response + revalidationResponse: CachePolicy.Response, ): CachePolicy.RevalidationPolicy; } diff --git a/types/http-codes/http-codes-tests.ts b/types/http-codes/http-codes-tests.ts index d3090881a71ffe..1e82c77b5bdc4e 100644 --- a/types/http-codes/http-codes-tests.ts +++ b/types/http-codes/http-codes-tests.ts @@ -1,4 +1,4 @@ -import { TOO_EARLY } from 'http-codes'; +import { TOO_EARLY } from "http-codes"; const _tooEarly = TOO_EARLY; // $ExpectType number _tooEarly + 5; diff --git a/types/http-context/http-context-tests.ts b/types/http-context/http-context-tests.ts index 629f09ece35149..aca8bcb153b75f 100644 --- a/types/http-context/http-context-tests.ts +++ b/types/http-context/http-context-tests.ts @@ -1,5 +1,5 @@ -import http = require('http'); -import httpContext = require('http-context'); +import http = require("http"); +import httpContext = require("http-context"); const context: httpContext.Context = httpContext(); const request: httpContext.Request = context.request; @@ -9,11 +9,11 @@ let header: http.IncomingHttpHeaders = context.header; header = context.headers; header = request.header; header = request.headers; -const headerString: string | string[] | undefined = header['Content-Type']; +const headerString: string | string[] | undefined = header["Content-Type"]; let url: string = context.url; url = request.url; -context.accepts('html'); +context.accepts("html"); let href: string = context.href; href = request.href; @@ -24,9 +24,9 @@ method = request.method; let path: string = context.path; path = request.path; -let query: {[param: string]: string | string[]} = context.query; +let query: { [param: string]: string | string[] } = context.query; query = request.query; -const querySearch: string | string[] = query['search']; +const querySearch: string | string[] = query["search"]; let queryString: string = context.querystring; queryString = request.querystring; @@ -55,10 +55,10 @@ secure = request.secure; let subdomains: string[] = context.subdomains; subdomains = request.subdomains; -let accepts: string[] | string | false = context.accepts('text/html'); -accepts = request.accepts('text/html'); -accepts = request.accepts('text/html', 'text/txt'); -accepts = request.accepts(['text/html', 'text/txt']); +let accepts: string[] | string | false = context.accepts("text/html"); +accepts = request.accepts("text/html"); +accepts = request.accepts("text/html", "text/txt"); +accepts = request.accepts(["text/html", "text/txt"]); let status: number = context.status; status = response.status; diff --git a/types/http-context/index.d.ts b/types/http-context/index.d.ts index 30aae4c99ba4d1..bc58506c269afe 100644 --- a/types/http-context/index.d.ts +++ b/types/http-context/index.d.ts @@ -5,8 +5,8 @@ /// <reference types="node" /> -import accepts = require('accepts'); -import http = require('http'); +import accepts = require("accepts"); +import http = require("http"); export = HttpContext; @@ -26,7 +26,7 @@ declare namespace HttpContext { href: string; method: string; path: string; - query: {[param: string]: string | string[]}; + query: { [param: string]: string | string[] }; querystring: string; search: string; host: string; diff --git a/types/http-errors/http-errors-tests.ts b/types/http-errors/http-errors-tests.ts index 37a3ae195ad9ad..8b9c69789f3022 100644 --- a/types/http-errors/http-errors-tests.ts +++ b/types/http-errors/http-errors-tests.ts @@ -1,12 +1,12 @@ -import create = require('http-errors'); -import express = require('express'); -import * as util from 'util'; +import create = require("http-errors"); +import express = require("express"); +import * as util from "util"; const app = express(); app.use((req, res, next) => { if (!req) { - next(create(401, 'Please login to view this page.')); + next(create(401, "Please login to view this page.")); return; } next(); @@ -26,83 +26,83 @@ err.headers; // $ExpectType { [key: string]: string; } | undefined // create(status, msg) // $ExpectType HttpError<404> -create(404, 'LOL'); +create(404, "LOL"); // create(status, props) // $ExpectType HttpError<404> -create(404, {id: 1}); +create(404, { id: 1 }); // create(status, props) with status prop // $ExpectType HttpError<404> create(404, { id: 1, - status: 500 + status: 500, }); // create(status, props) with statusCode prop // $ExpectType HttpError<404> create(404, { id: 1, - statusCode: 500 + statusCode: 500, }); // create(props) // $ExpectType HttpError<number> -create({id: 1}); +create({ id: 1 }); // $ExpectType any err.id; // create(msg, status) // @ts-expect-error Since 2.0, number arguments can only be the first argument -create('LOL', 404); +create("LOL", 404); // create(msg) // $ExpectType HttpError<number> -create('LOL'); +create("LOL"); // create(msg, props) // $ExpectType HttpError<number> -create('LOL', {id: 1}); +create("LOL", { id: 1 }); // create(err) // $ExpectType HttpError<number> -create(new Error('LOL')); +create(new Error("LOL")); // create(err, props) // $ExpectType HttpError<number> -create(new Error('LOL'), {id: 1}); +create(new Error("LOL"), { id: 1 }); // create(status, err, props) // $ExpectType HttpError<404> -create(404, new Error('LOL'), {id: 1}); +create(404, new Error("LOL"), { id: 1 }); // create(status, msg, props) // $ExpectType HttpError<404> -create(404, 'LOL', {id: 1}); +create(404, "LOL", { id: 1 }); // create(status, msg, { expose: false }) // $ExpectType HttpError<404> -create(404, 'LOL', {expose: false}); +create(404, "LOL", { expose: false }); new create.NotFound(); // $ExpectType HttpError<404> new create.InternalServerError(); // $ExpectType HttpError<500> new create[404](); // $ExpectType HttpError<404> -new create['404'](); // $ExpectType HttpError<404> +new create["404"](); // $ExpectType HttpError<404> -create['404'](); // $ExpectType HttpError<404> -create(404, 'Not Found'); // $ExpectType HttpError<404> +create["404"](); // $ExpectType HttpError<404> +create(404, "Not Found"); // $ExpectType HttpError<404> create(); // $ExpectType HttpError<number> // @ts-expect-error new create(); // Error messages can have custom messages -new create.NotFound('This might be a problem'); // $ExpectType HttpError<404> -new create[404]('This might be a problem'); // $ExpectType HttpError<404> +new create.NotFound("This might be a problem"); // $ExpectType HttpError<404> +new create[404]("This might be a problem"); // $ExpectType HttpError<404> // 1.5.0 supports 421 - Misdirected Request new create.MisdirectedRequest(); // $ExpectType HttpError<421> -new create.MisdirectedRequest('Where should this go?'); // $ExpectType HttpError<421> +new create.MisdirectedRequest("Where should this go?"); // $ExpectType HttpError<421> // $ExpectType HttpError<number> new create.HttpError(); @@ -116,27 +116,27 @@ if (err instanceof create.HttpError) { // should support err instanceof Error create(404) instanceof Error; -(new create['404']()) instanceof Error; -(new create['500']()) instanceof Error; +(new create["404"]()) instanceof Error; +(new create["500"]()) instanceof Error; // should support err instanceof exposed constructor create(404) instanceof create.NotFound; create(500) instanceof create.InternalServerError; -(new create['404']()) instanceof create.NotFound; -(new create['500']()) instanceof create.InternalServerError; +(new create["404"]()) instanceof create.NotFound; +(new create["500"]()) instanceof create.InternalServerError; (new create.NotFound()) instanceof create.NotFound; (new create.InternalServerError()) instanceof create.InternalServerError; // should support err instanceof HttpError create(404) instanceof create.HttpError; -(new create['404']()) instanceof create.HttpError; -(new create['500']()) instanceof create.HttpError; +(new create["404"]()) instanceof create.HttpError; +(new create["500"]()) instanceof create.HttpError; // should support util.isError() util.isError(create(404)); -util.isError(new create['404']()); -util.isError(new create['500']()); +util.isError(new create["404"]()); +util.isError(new create["500"]()); // should support isHttpError create.isHttpError(1); // non-http-error type -create.isHttpError(new create['404']()); // http error type +create.isHttpError(new create["404"]()); // http error type diff --git a/types/http-errors/index.d.ts b/types/http-errors/index.d.ts index 6b5a3d58b19461..434a7e2069c82d 100644 --- a/types/http-errors/index.d.ts +++ b/types/http-errors/index.d.ts @@ -7,7 +7,7 @@ export = createHttpError; declare const createHttpError: createHttpError.CreateHttpError & createHttpError.NamedConstructors & { - isHttpError: createHttpError.IsHttpError + isHttpError: createHttpError.IsHttpError; }; declare namespace createHttpError { @@ -25,7 +25,7 @@ declare namespace createHttpError { interface HttpErrorConstructor<N extends number = number> { (msg?: string): HttpError<N>; - new (msg?: string): HttpError<N>; + new(msg?: string): HttpError<N>; } interface CreateHttpError { @@ -35,49 +35,49 @@ declare namespace createHttpError { type IsHttpError = (error: unknown) => error is HttpError; - type NamedConstructors = { - HttpError: HttpErrorConstructor; - } - & Record<'BadRequest' | '400', HttpErrorConstructor<400>> - & Record<'Unauthorized' | '401', HttpErrorConstructor<401>> - & Record<'PaymentRequired' | '402', HttpErrorConstructor<402>> - & Record<'Forbidden' | '403', HttpErrorConstructor<403>> - & Record<'NotFound' | '404', HttpErrorConstructor<404>> - & Record<'MethodNotAllowed' | '405', HttpErrorConstructor<405>> - & Record<'NotAcceptable' | '406', HttpErrorConstructor<406>> - & Record<'ProxyAuthenticationRequired' | '407', HttpErrorConstructor<407>> - & Record<'RequestTimeout' | '408', HttpErrorConstructor<408>> - & Record<'Conflict' | '409', HttpErrorConstructor<409>> - & Record<'Gone' | '410', HttpErrorConstructor<410>> - & Record<'LengthRequired' | '411', HttpErrorConstructor<411>> - & Record<'PreconditionFailed' | '412', HttpErrorConstructor<412>> - & Record<'PayloadTooLarge' | '413', HttpErrorConstructor<413>> - & Record<'URITooLong' | '414', HttpErrorConstructor<414>> - & Record<'UnsupportedMediaType' | '415', HttpErrorConstructor<415>> - & Record<'RangeNotSatisfiable' | '416', HttpErrorConstructor<416>> - & Record<'ExpectationFailed' | '417', HttpErrorConstructor<417>> - & Record<'ImATeapot' | '418', HttpErrorConstructor<418>> - & Record<'MisdirectedRequest' | '421', HttpErrorConstructor<421>> - & Record<'UnprocessableEntity' | '422', HttpErrorConstructor<422>> - & Record<'Locked' | '423', HttpErrorConstructor<423>> - & Record<'FailedDependency' | '424', HttpErrorConstructor<424>> - & Record<'TooEarly' | '425', HttpErrorConstructor<425>> - & Record<'UpgradeRequired' | '426', HttpErrorConstructor<426>> - & Record<'PreconditionRequired' | '428', HttpErrorConstructor<428>> - & Record<'TooManyRequests' | '429', HttpErrorConstructor<429>> - & Record<'RequestHeaderFieldsTooLarge' | '431', HttpErrorConstructor<431>> - & Record<'UnavailableForLegalReasons' | '451', HttpErrorConstructor<451>> - & Record<'InternalServerError' | '500', HttpErrorConstructor<500>> - & Record<'NotImplemented' | '501', HttpErrorConstructor<501>> - & Record<'BadGateway' | '502', HttpErrorConstructor<502>> - & Record<'ServiceUnavailable' | '503', HttpErrorConstructor<503>> - & Record<'GatewayTimeout' | '504', HttpErrorConstructor<504>> - & Record<'HTTPVersionNotSupported' | '505', HttpErrorConstructor<505>> - & Record<'VariantAlsoNegotiates' | '506', HttpErrorConstructor<506>> - & Record<'InsufficientStorage' | '507', HttpErrorConstructor<507>> - & Record<'LoopDetected' | '508', HttpErrorConstructor<508>> - & Record<'BandwidthLimitExceeded' | '509', HttpErrorConstructor<509>> - & Record<'NotExtended' | '510', HttpErrorConstructor<510>> - & Record<'NetworkAuthenticationRequire' | '511', HttpErrorConstructor<511>> - ; + type NamedConstructors = + & { + HttpError: HttpErrorConstructor; + } + & Record<"BadRequest" | "400", HttpErrorConstructor<400>> + & Record<"Unauthorized" | "401", HttpErrorConstructor<401>> + & Record<"PaymentRequired" | "402", HttpErrorConstructor<402>> + & Record<"Forbidden" | "403", HttpErrorConstructor<403>> + & Record<"NotFound" | "404", HttpErrorConstructor<404>> + & Record<"MethodNotAllowed" | "405", HttpErrorConstructor<405>> + & Record<"NotAcceptable" | "406", HttpErrorConstructor<406>> + & Record<"ProxyAuthenticationRequired" | "407", HttpErrorConstructor<407>> + & Record<"RequestTimeout" | "408", HttpErrorConstructor<408>> + & Record<"Conflict" | "409", HttpErrorConstructor<409>> + & Record<"Gone" | "410", HttpErrorConstructor<410>> + & Record<"LengthRequired" | "411", HttpErrorConstructor<411>> + & Record<"PreconditionFailed" | "412", HttpErrorConstructor<412>> + & Record<"PayloadTooLarge" | "413", HttpErrorConstructor<413>> + & Record<"URITooLong" | "414", HttpErrorConstructor<414>> + & Record<"UnsupportedMediaType" | "415", HttpErrorConstructor<415>> + & Record<"RangeNotSatisfiable" | "416", HttpErrorConstructor<416>> + & Record<"ExpectationFailed" | "417", HttpErrorConstructor<417>> + & Record<"ImATeapot" | "418", HttpErrorConstructor<418>> + & Record<"MisdirectedRequest" | "421", HttpErrorConstructor<421>> + & Record<"UnprocessableEntity" | "422", HttpErrorConstructor<422>> + & Record<"Locked" | "423", HttpErrorConstructor<423>> + & Record<"FailedDependency" | "424", HttpErrorConstructor<424>> + & Record<"TooEarly" | "425", HttpErrorConstructor<425>> + & Record<"UpgradeRequired" | "426", HttpErrorConstructor<426>> + & Record<"PreconditionRequired" | "428", HttpErrorConstructor<428>> + & Record<"TooManyRequests" | "429", HttpErrorConstructor<429>> + & Record<"RequestHeaderFieldsTooLarge" | "431", HttpErrorConstructor<431>> + & Record<"UnavailableForLegalReasons" | "451", HttpErrorConstructor<451>> + & Record<"InternalServerError" | "500", HttpErrorConstructor<500>> + & Record<"NotImplemented" | "501", HttpErrorConstructor<501>> + & Record<"BadGateway" | "502", HttpErrorConstructor<502>> + & Record<"ServiceUnavailable" | "503", HttpErrorConstructor<503>> + & Record<"GatewayTimeout" | "504", HttpErrorConstructor<504>> + & Record<"HTTPVersionNotSupported" | "505", HttpErrorConstructor<505>> + & Record<"VariantAlsoNegotiates" | "506", HttpErrorConstructor<506>> + & Record<"InsufficientStorage" | "507", HttpErrorConstructor<507>> + & Record<"LoopDetected" | "508", HttpErrorConstructor<508>> + & Record<"BandwidthLimitExceeded" | "509", HttpErrorConstructor<509>> + & Record<"NotExtended" | "510", HttpErrorConstructor<510>> + & Record<"NetworkAuthenticationRequire" | "511", HttpErrorConstructor<511>>; } diff --git a/types/http-headers/http-headers-tests.ts b/types/http-headers/http-headers-tests.ts index 232a29af9d0e4e..694c0d466aa962 100644 --- a/types/http-headers/http-headers-tests.ts +++ b/types/http-headers/http-headers-tests.ts @@ -1,6 +1,6 @@ -import { ServerResponse } from 'http'; -import { Headers, RequestData, ResponseData } from 'http-headers'; -import httpHeaders = require('http-headers'); +import { ServerResponse } from "http"; +import { Headers, RequestData, ResponseData } from "http-headers"; +import httpHeaders = require("http-headers"); // test type exports type Req = RequestData; @@ -18,16 +18,16 @@ const h2: RequestData | ResponseData = httpHeaders(res); // @ts-expect-error const h3: RequestData | Headers = httpHeaders(res); httpHeaders(Buffer.alloc(1)); -httpHeaders('foo'); +httpHeaders("foo"); -if ('method' in h) { +if ("method" in h) { const req = h as RequestData; req.headers; // $ExpectType Headers req.method; // $ExpectType string req.version; // $ExpectType HttpVersion req.version.major; // $ExpectType number req.version.minor; // $ExpectType number -} else if ('statusCode' in h) { +} else if ("statusCode" in h) { const res = h as ResponseData; res.headers; // $ExpectType Headers res.statusCode; // $ExpectType number @@ -36,6 +36,6 @@ if ('method' in h) { res.version.major; // $ExpectType number res.version.minor; // $ExpectType number } else { - h['set-cookie']; // $ExpectType string[] | undefined + h["set-cookie"]; // $ExpectType string[] | undefined h.foo; // $ExpectType string | undefined } diff --git a/types/http-headers/index.d.ts b/types/http-headers/index.d.ts index c8b1bc50357839..81c49f1ec9ee54 100644 --- a/types/http-headers/index.d.ts +++ b/types/http-headers/index.d.ts @@ -5,7 +5,7 @@ /// <reference types="node" /> -import { ServerResponse } from 'http'; +import { ServerResponse } from "http"; export = httpHeaders; @@ -74,6 +74,6 @@ declare namespace httpHeaders { } type Headers = { - 'set-cookie'?: string[] | undefined; + "set-cookie"?: string[] | undefined; } & { [key in string]?: string | undefined }; } diff --git a/types/http-link-header/http-link-header-tests.ts b/types/http-link-header/http-link-header-tests.ts index 98ffbff803985f..773609ca0971af 100644 --- a/types/http-link-header/http-link-header-tests.ts +++ b/types/http-link-header/http-link-header-tests.ts @@ -1,4 +1,4 @@ -import LinkHeader = require('http-link-header'); +import LinkHeader = require("http-link-header"); function isLinkHeader(l: LinkHeader): null { return null; @@ -17,37 +17,37 @@ function isString(str: string): null { } const link = LinkHeader.parse( - '<example.com>; rel="example"; title="Example Website", ' + - '<example-twice.com>; rel="example"; title="Example Website Twice", ' + - '<example-01.com>; rel="alternate"; title="Alternate Example Domain"' + "<example.com>; rel=\"example\"; title=\"Example Website\", " + + "<example-twice.com>; rel=\"example\"; title=\"Example Website Twice\", " + + "<example-01.com>; rel=\"alternate\"; title=\"Alternate Example Domain\"", ); isReferenceArray(link.refs); -const offsetLink = LinkHeader.parse(' <example.com>; rel="example"', 1); +const offsetLink = LinkHeader.parse(" <example.com>; rel=\"example\"", 1); -const has = link.has('rel', 'alternate'); +const has = link.has("rel", "alternate"); isBool(has); -const get = link.get('title', 'Example Website'); +const get = link.get("title", "Example Website"); isReferenceArray(get); -const rel = link.rel('alternate'); -rel[0]['title'] !== 'bar'; +const rel = link.rel("alternate"); +rel[0]["title"] !== "bar"; isReferenceArray(rel); -isLinkHeader(link.set({ rel: 'next', uri: 'http://example.com/next' })); +isLinkHeader(link.set({ rel: "next", uri: "http://example.com/next" })); const str = link.toString(); isString(str); const constructedLink = new LinkHeader(); -LinkHeader.isCompatibleEncoding('utf-8'); // $ExpectType boolean -LinkHeader.isSingleOccurenceAttr('src'); // $ExpectType boolean -LinkHeader.isTokenAttr('rel'); // $ExpectType boolean -LinkHeader.escapeQuotes('"Quote text"'); // $ExpectType string -LinkHeader.formatExtendedAttribute('title', { - value: Buffer.from('Unicode value'), - encoding: 'utf-8', - language: 'en', +LinkHeader.isCompatibleEncoding("utf-8"); // $ExpectType boolean +LinkHeader.isSingleOccurenceAttr("src"); // $ExpectType boolean +LinkHeader.isTokenAttr("rel"); // $ExpectType boolean +LinkHeader.escapeQuotes("\"Quote text\""); // $ExpectType string +LinkHeader.formatExtendedAttribute("title", { + value: Buffer.from("Unicode value"), + encoding: "utf-8", + language: "en", }); diff --git a/types/http-proxy/http-proxy-tests.ts b/types/http-proxy/http-proxy-tests.ts index cc3409f06a5749..c540e4362d7bf4 100644 --- a/types/http-proxy/http-proxy-tests.ts +++ b/types/http-proxy/http-proxy-tests.ts @@ -1,6 +1,6 @@ +import * as express from "express"; import * as http from "http"; import * as HttpProxy from "http-proxy"; -import * as express from "express"; const proxy = new HttpProxy({ changeOrigin: true, @@ -16,10 +16,9 @@ proxy.on("error", err => { proxy.on("start", (req, res, target) => { const headers = req.headers; // defined; const status = res.statusCode; // defined; - const partial = - typeof target === "string" - ? target.substr(0) // defined; - : target.protocol; // defined; + const partial = typeof target === "string" + ? target.substr(0) // defined; + : target.protocol; // defined; }); http.createServer((req, res) => { @@ -77,7 +76,12 @@ const proxyReq: HttpProxy.ProxyReqCallback = (proxyReq, req, res, options) => { res.status(200); }; -const proxyReqExpress: HttpProxy.ProxyReqCallback<http.ClientRequest, express.Request, express.Response> = (proxyReq, req, res, options) => { +const proxyReqExpress: HttpProxy.ProxyReqCallback<http.ClientRequest, express.Request, express.Response> = ( + proxyReq, + req, + res, + options, +) => { req.params; res.status(200); }; @@ -99,7 +103,13 @@ const proxyReqWsCallback: HttpProxy.ProxyReqWsCallback = (proxyReq, req, socket, req.params; }; -const proxyReqWsCallbackExpress: HttpProxy.ProxyReqWsCallback<http.ClientRequest, express.Request> = (proxyReq, req, socket, options, head) => { +const proxyReqWsCallbackExpress: HttpProxy.ProxyReqWsCallback<http.ClientRequest, express.Request> = ( + proxyReq, + req, + socket, + options, + head, +) => { req.params; }; @@ -110,7 +120,12 @@ const econnresetCallback: HttpProxy.EconnresetCallback = (err, req, res, target) res.status(200); }; -const econnresetCallbackExpress: HttpProxy.EconnresetCallback<Error, express.Request, express.Response> = (err, req, res, target) => { +const econnresetCallbackExpress: HttpProxy.EconnresetCallback<Error, express.Request, express.Response> = ( + err, + req, + res, + target, +) => { req.params; res.status(200); }; @@ -146,7 +161,12 @@ const errorCallback: HttpProxy.ErrorCallback = (err, req, res, target) => { res.status(200); }; -const errorCallbackExpress: HttpProxy.ErrorCallback<Error, express.Request, express.Response> = (err, req, res, target) => { +const errorCallbackExpress: HttpProxy.ErrorCallback<Error, express.Request, express.Response> = ( + err, + req, + res, + target, +) => { req.params; ("status" in res) && res.status(200); }; @@ -158,23 +178,55 @@ const instance = new HttpProxy<express.Request, express.Response>({ target: "http://localhost:9015", }); -instance.on("error", (error, req, res, target) => { req.params && "status" in res && res.status(200).send("OK"); }); -instance.on("start", (req, res, target) => { req.params && res.status(200).send("OK"); }); -instance.on("proxyReq", (proxyReq, req, res, options) => { req.params && res.status(200).send("OK"); }); -instance.on("proxyRes", (proxyRes, req, res) => { req.params && res.status(200).send("OK"); }); -instance.on("proxyReqWs", (proxyReq, req, socket, options, head) => { req.params; }); -instance.on("econnreset", (error, req, res, target) => { req.params && res.status(200).send("OK"); }); -instance.on("end", (req, res, proxyRes) => { req.params && proxyRes.params && res.status(200).send("OK"); }); -instance.on("close", (proxyRes, proxySocket, proxyHead) => { proxyRes.params; }); - -instance.once("error", (error, req, res, target) => { req.params && "status" in res && res.status(200).send("OK"); }); -instance.once("start", (req, res, target) => { req.params && res.status(200).send("OK"); }); -instance.once("proxyReq", (proxyReq, req, res, options) => { req.params && res.status(200).send("OK"); }); -instance.once("proxyRes", (proxyRes, req, res) => { req.params && res.status(200).send("OK"); }); -instance.once("proxyReqWs", (proxyReq, req, socket, options, head) => { req.params; }); -instance.once("econnreset", (error, req, res, target) => { req.params && res.status(200).send("OK"); }); -instance.once("end", (req, res, proxyRes) => { req.params && proxyRes.params && res.status(200).send("OK"); }); -instance.once("close", (proxyRes, proxySocket, proxyHead) => { proxyRes.params; }); +instance.on("error", (error, req, res, target) => { + req.params && "status" in res && res.status(200).send("OK"); +}); +instance.on("start", (req, res, target) => { + req.params && res.status(200).send("OK"); +}); +instance.on("proxyReq", (proxyReq, req, res, options) => { + req.params && res.status(200).send("OK"); +}); +instance.on("proxyRes", (proxyRes, req, res) => { + req.params && res.status(200).send("OK"); +}); +instance.on("proxyReqWs", (proxyReq, req, socket, options, head) => { + req.params; +}); +instance.on("econnreset", (error, req, res, target) => { + req.params && res.status(200).send("OK"); +}); +instance.on("end", (req, res, proxyRes) => { + req.params && proxyRes.params && res.status(200).send("OK"); +}); +instance.on("close", (proxyRes, proxySocket, proxyHead) => { + proxyRes.params; +}); + +instance.once("error", (error, req, res, target) => { + req.params && "status" in res && res.status(200).send("OK"); +}); +instance.once("start", (req, res, target) => { + req.params && res.status(200).send("OK"); +}); +instance.once("proxyReq", (proxyReq, req, res, options) => { + req.params && res.status(200).send("OK"); +}); +instance.once("proxyRes", (proxyRes, req, res) => { + req.params && res.status(200).send("OK"); +}); +instance.once("proxyReqWs", (proxyReq, req, socket, options, head) => { + req.params; +}); +instance.once("econnreset", (error, req, res, target) => { + req.params && res.status(200).send("OK"); +}); +instance.once("end", (req, res, proxyRes) => { + req.params && proxyRes.params && res.status(200).send("OK"); +}); +instance.once("close", (proxyRes, proxySocket, proxyHead) => { + proxyRes.params; +}); /** * Test createProxyServer() generics: @@ -183,23 +235,55 @@ const proxyServerInstance = HttpProxy.createProxyServer<express.Request, express target: "http://localhost:9015", }); -proxyServerInstance.on("error", (error, req, res, target) => { req.params && "status" in res && res.status(200).send("OK"); }); -proxyServerInstance.on("start", (req, res, target) => { req.params && res.status(200).send("OK"); }); -proxyServerInstance.on("proxyReq", (proxyReq, req, res, options) => { req.params && res.status(200).send("OK"); }); -proxyServerInstance.on("proxyRes", (proxyRes, req, res) => { req.params && res.status(200).send("OK"); }); -proxyServerInstance.on("proxyReqWs", (proxyReq, req, socket, options, head) => { req.params; }); -proxyServerInstance.on("econnreset", (error, req, res, target) => { req.params && res.status(200).send("OK"); }); -proxyServerInstance.on("end", (req, res, proxyRes) => { req.params && proxyRes.params && res.status(200).send("OK"); }); -proxyServerInstance.on("close", (proxyRes, proxySocket, proxyHead) => { proxyRes.params; }); - -proxyServerInstance.once("error", (error, req, res, target) => { req.params && "status" in res && res.status(200).send("OK"); }); -proxyServerInstance.once("start", (req, res, target) => { req.params && res.status(200).send("OK"); }); -proxyServerInstance.once("proxyReq", (proxyReq, req, res, options) => { req.params && res.status(200).send("OK"); }); -proxyServerInstance.once("proxyRes", (proxyRes, req, res) => { req.params && res.status(200).send("OK"); }); -proxyServerInstance.once("proxyReqWs", (proxyReq, req, socket, options, head) => { req.params; }); -proxyServerInstance.once("econnreset", (error, req, res, target) => { req.params && res.status(200).send("OK"); }); -proxyServerInstance.once("end", (req, res, proxyRes) => { req.params && proxyRes.params && res.status(200).send("OK"); }); -proxyServerInstance.once("close", (proxyRes, proxySocket, proxyHead) => { proxyRes.params; }); +proxyServerInstance.on("error", (error, req, res, target) => { + req.params && "status" in res && res.status(200).send("OK"); +}); +proxyServerInstance.on("start", (req, res, target) => { + req.params && res.status(200).send("OK"); +}); +proxyServerInstance.on("proxyReq", (proxyReq, req, res, options) => { + req.params && res.status(200).send("OK"); +}); +proxyServerInstance.on("proxyRes", (proxyRes, req, res) => { + req.params && res.status(200).send("OK"); +}); +proxyServerInstance.on("proxyReqWs", (proxyReq, req, socket, options, head) => { + req.params; +}); +proxyServerInstance.on("econnreset", (error, req, res, target) => { + req.params && res.status(200).send("OK"); +}); +proxyServerInstance.on("end", (req, res, proxyRes) => { + req.params && proxyRes.params && res.status(200).send("OK"); +}); +proxyServerInstance.on("close", (proxyRes, proxySocket, proxyHead) => { + proxyRes.params; +}); + +proxyServerInstance.once("error", (error, req, res, target) => { + req.params && "status" in res && res.status(200).send("OK"); +}); +proxyServerInstance.once("start", (req, res, target) => { + req.params && res.status(200).send("OK"); +}); +proxyServerInstance.once("proxyReq", (proxyReq, req, res, options) => { + req.params && res.status(200).send("OK"); +}); +proxyServerInstance.once("proxyRes", (proxyRes, req, res) => { + req.params && res.status(200).send("OK"); +}); +proxyServerInstance.once("proxyReqWs", (proxyReq, req, socket, options, head) => { + req.params; +}); +proxyServerInstance.once("econnreset", (error, req, res, target) => { + req.params && res.status(200).send("OK"); +}); +proxyServerInstance.once("end", (req, res, proxyRes) => { + req.params && proxyRes.params && res.status(200).send("OK"); +}); +proxyServerInstance.once("close", (proxyRes, proxySocket, proxyHead) => { + proxyRes.params; +}); /** * Test createServer() generics: @@ -208,23 +292,55 @@ const serverInstance = HttpProxy.createServer<express.Request, express.Response> target: "http://localhost:9015", }); -serverInstance.on("error", (error, req, res, target) => { req.params && "status" in res && res.status(200).send("OK"); }); -serverInstance.on("start", (req, res, target) => { req.params && res.status(200).send("OK"); }); -serverInstance.on("proxyReq", (proxyReq, req, res, options) => { req.params && res.status(200).send("OK"); }); -serverInstance.on("proxyRes", (proxyRes, req, res) => { req.params && res.status(200).send("OK"); }); -serverInstance.on("proxyReqWs", (proxyReq, req, socket, options, head) => { req.params; }); -serverInstance.on("econnreset", (error, req, res, target) => { req.params && res.status(200).send("OK"); }); -serverInstance.on("end", (req, res, proxyRes) => { req.params && proxyRes.params && res.status(200).send("OK"); }); -serverInstance.on("close", (proxyRes, proxySocket, proxyHead) => { proxyRes.params; }); - -serverInstance.once("error", (error, req, res, target) => { req.params && "status" in res && res.status(200).send("OK"); }); -serverInstance.once("start", (req, res, target) => { req.params && res.status(200).send("OK"); }); -serverInstance.once("proxyReq", (proxyReq, req, res, options) => { req.params && res.status(200).send("OK"); }); -serverInstance.once("proxyRes", (proxyRes, req, res) => { req.params && res.status(200).send("OK"); }); -serverInstance.once("proxyReqWs", (proxyReq, req, socket, options, head) => { req.params; }); -serverInstance.once("econnreset", (error, req, res, target) => { req.params && res.status(200).send("OK"); }); -serverInstance.once("end", (req, res, proxyRes) => { req.params && proxyRes.params && res.status(200).send("OK"); }); -serverInstance.once("close", (proxyRes, proxySocket, proxyHead) => { proxyRes.params; }); +serverInstance.on("error", (error, req, res, target) => { + req.params && "status" in res && res.status(200).send("OK"); +}); +serverInstance.on("start", (req, res, target) => { + req.params && res.status(200).send("OK"); +}); +serverInstance.on("proxyReq", (proxyReq, req, res, options) => { + req.params && res.status(200).send("OK"); +}); +serverInstance.on("proxyRes", (proxyRes, req, res) => { + req.params && res.status(200).send("OK"); +}); +serverInstance.on("proxyReqWs", (proxyReq, req, socket, options, head) => { + req.params; +}); +serverInstance.on("econnreset", (error, req, res, target) => { + req.params && res.status(200).send("OK"); +}); +serverInstance.on("end", (req, res, proxyRes) => { + req.params && proxyRes.params && res.status(200).send("OK"); +}); +serverInstance.on("close", (proxyRes, proxySocket, proxyHead) => { + proxyRes.params; +}); + +serverInstance.once("error", (error, req, res, target) => { + req.params && "status" in res && res.status(200).send("OK"); +}); +serverInstance.once("start", (req, res, target) => { + req.params && res.status(200).send("OK"); +}); +serverInstance.once("proxyReq", (proxyReq, req, res, options) => { + req.params && res.status(200).send("OK"); +}); +serverInstance.once("proxyRes", (proxyRes, req, res) => { + req.params && res.status(200).send("OK"); +}); +serverInstance.once("proxyReqWs", (proxyReq, req, socket, options, head) => { + req.params; +}); +serverInstance.once("econnreset", (error, req, res, target) => { + req.params && res.status(200).send("OK"); +}); +serverInstance.once("end", (req, res, proxyRes) => { + req.params && proxyRes.params && res.status(200).send("OK"); +}); +serverInstance.once("close", (proxyRes, proxySocket, proxyHead) => { + proxyRes.params; +}); /** * Test createProxy() generics: @@ -233,30 +349,70 @@ const proxyInstance = HttpProxy.createProxy<express.Request, express.Response>({ target: "http://localhost:9015", }); -proxyInstance.on("error", (error, req, res, target) => { req.params && "status" in res && res.status(200).send("OK"); }); -proxyInstance.on("start", (req, res, target) => { req.params && res.status(200).send("OK"); }); -proxyInstance.on("proxyReq", (proxyReq, req, res, options) => { req.params && res.status(200).send("OK"); }); -proxyInstance.on("proxyRes", (proxyRes, req, res) => { req.params && res.status(200).send("OK"); }); -proxyInstance.on("proxyReqWs", (proxyReq, req, socket, options, head) => { req.params; }); -proxyInstance.on("econnreset", (error, req, res, target) => { req.params && res.status(200).send("OK"); }); -proxyInstance.on("end", (req, res, proxyRes) => { req.params && proxyRes.params && res.status(200).send("OK"); }); -proxyInstance.on("close", (proxyRes, proxySocket, proxyHead) => { proxyRes.params; }); - -proxyInstance.once("error", (error, req, res, target) => { req.params && "status" in res && res.status(200).send("OK"); }); -proxyInstance.once("start", (req, res, target) => { req.params && res.status(200).send("OK"); }); -proxyInstance.once("proxyReq", (proxyReq, req, res, options) => { req.params && res.status(200).send("OK"); }); -proxyInstance.once("proxyRes", (proxyRes, req, res) => { req.params && res.status(200).send("OK"); }); -proxyInstance.once("proxyReqWs", (proxyReq, req, socket, options, head) => { req.params; }); -proxyInstance.once("econnreset", (error, req, res, target) => { req.params && res.status(200).send("OK"); }); -proxyInstance.once("end", (req, res, proxyRes) => { req.params && proxyRes.params && res.status(200).send("OK"); }); -proxyInstance.once("close", (proxyRes, proxySocket, proxyHead) => { proxyRes.params; }); +proxyInstance.on("error", (error, req, res, target) => { + req.params && "status" in res && res.status(200).send("OK"); +}); +proxyInstance.on("start", (req, res, target) => { + req.params && res.status(200).send("OK"); +}); +proxyInstance.on("proxyReq", (proxyReq, req, res, options) => { + req.params && res.status(200).send("OK"); +}); +proxyInstance.on("proxyRes", (proxyRes, req, res) => { + req.params && res.status(200).send("OK"); +}); +proxyInstance.on("proxyReqWs", (proxyReq, req, socket, options, head) => { + req.params; +}); +proxyInstance.on("econnreset", (error, req, res, target) => { + req.params && res.status(200).send("OK"); +}); +proxyInstance.on("end", (req, res, proxyRes) => { + req.params && proxyRes.params && res.status(200).send("OK"); +}); +proxyInstance.on("close", (proxyRes, proxySocket, proxyHead) => { + proxyRes.params; +}); + +proxyInstance.once("error", (error, req, res, target) => { + req.params && "status" in res && res.status(200).send("OK"); +}); +proxyInstance.once("start", (req, res, target) => { + req.params && res.status(200).send("OK"); +}); +proxyInstance.once("proxyReq", (proxyReq, req, res, options) => { + req.params && res.status(200).send("OK"); +}); +proxyInstance.once("proxyRes", (proxyRes, req, res) => { + req.params && res.status(200).send("OK"); +}); +proxyInstance.once("proxyReqWs", (proxyReq, req, socket, options, head) => { + req.params; +}); +proxyInstance.once("econnreset", (error, req, res, target) => { + req.params && res.status(200).send("OK"); +}); +proxyInstance.once("end", (req, res, proxyRes) => { + req.params && proxyRes.params && res.status(200).send("OK"); +}); +proxyInstance.once("close", (proxyRes, proxySocket, proxyHead) => { + proxyRes.params; +}); /** * Generics in listen() Server */ -instance.listen(0).on('proxyReq', (proxyReq, req, res, options) => { req.params && res.status(200).send("OK"); }); -proxyServerInstance.listen(0).on('proxyReq', (proxyReq, req, res, options) => { req.params && res.status(200).send("OK"); }); -serverInstance.listen(0).on('proxyReq', (proxyReq, req, res, options) => { req.params && res.status(200).send("OK"); }); -proxyInstance.listen(0).on('proxyReq', (proxyReq, req, res, options) => { req.params && res.status(200).send("OK"); }); +instance.listen(0).on("proxyReq", (proxyReq, req, res, options) => { + req.params && res.status(200).send("OK"); +}); +proxyServerInstance.listen(0).on("proxyReq", (proxyReq, req, res, options) => { + req.params && res.status(200).send("OK"); +}); +serverInstance.listen(0).on("proxyReq", (proxyReq, req, res, options) => { + req.params && res.status(200).send("OK"); +}); +proxyInstance.listen(0).on("proxyReq", (proxyReq, req, res, options) => { + req.params && res.status(200).send("OK"); +}); // Passing a hostname to listen -instance.listen(0, '0.0.0.0'); +instance.listen(0, "0.0.0.0"); diff --git a/types/http-proxy/index.d.ts b/types/http-proxy/index.d.ts index 1e97897ee81aea..3ad4d46c0f6478 100644 --- a/types/http-proxy/index.d.ts +++ b/types/http-proxy/index.d.ts @@ -10,12 +10,12 @@ /// <reference types="node" /> -import * as net from "net"; +import * as events from "events"; import * as http from "http"; import * as https from "https"; -import * as events from "events"; -import * as url from "url"; +import * as net from "net"; import * as stream from "stream"; +import * as url from "url"; interface ProxyTargetDetailed { host: string; @@ -32,7 +32,9 @@ interface ProxyTargetDetailed { secureProtocol?: string | undefined; } -declare class Server<TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse> extends events.EventEmitter { +declare class Server<TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse> + extends events.EventEmitter +{ /** * Creates the proxy server with specified options. * @param options - Config object passed to the proxy @@ -85,7 +87,9 @@ declare class Server<TIncomingMessage = http.IncomingMessage, TServerResponse = * @returns Proxy object with handlers for `ws` and `web` requests */ // tslint:disable:no-unnecessary-generics - static createProxyServer<TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse>(options?: Server.ServerOptions): Server<TIncomingMessage, TServerResponse>; + static createProxyServer<TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse>( + options?: Server.ServerOptions, + ): Server<TIncomingMessage, TServerResponse>; /** * Creates the proxy server with specified options. @@ -93,7 +97,9 @@ declare class Server<TIncomingMessage = http.IncomingMessage, TServerResponse = * @returns Proxy object with handlers for `ws` and `web` requests */ // tslint:disable:no-unnecessary-generics - static createServer<TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse>(options?: Server.ServerOptions): Server<TIncomingMessage, TServerResponse>; + static createServer<TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse>( + options?: Server.ServerOptions, + ): Server<TIncomingMessage, TServerResponse>; /** * Creates the proxy server with specified options. @@ -101,13 +107,18 @@ declare class Server<TIncomingMessage = http.IncomingMessage, TServerResponse = * @returns Proxy object with handlers for `ws` and `web` requests */ // tslint:disable:no-unnecessary-generics - static createProxy<TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse>(options?: Server.ServerOptions): Server<TIncomingMessage, TServerResponse>; + static createProxy<TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse>( + options?: Server.ServerOptions, + ): Server<TIncomingMessage, TServerResponse>; addListener(event: string, listener: () => void): this; on(event: string, listener: () => void): this; on(event: "error", listener: Server.ErrorCallback<Error, TIncomingMessage, TServerResponse>): this; on(event: "start", listener: Server.StartCallback<TIncomingMessage, TServerResponse>): this; - on(event: "proxyReq", listener: Server.ProxyReqCallback<http.ClientRequest, TIncomingMessage, TServerResponse>): this; + on( + event: "proxyReq", + listener: Server.ProxyReqCallback<http.ClientRequest, TIncomingMessage, TServerResponse>, + ): this; on(event: "proxyRes", listener: Server.ProxyResCallback<TIncomingMessage, TServerResponse>): this; on(event: "proxyReqWs", listener: Server.ProxyReqWsCallback<http.ClientRequest, TIncomingMessage>): this; on(event: "econnreset", listener: Server.EconnresetCallback<Error, TIncomingMessage, TServerResponse>): this; @@ -118,7 +129,10 @@ declare class Server<TIncomingMessage = http.IncomingMessage, TServerResponse = once(event: string, listener: () => void): this; once(event: "error", listener: Server.ErrorCallback<Error, TIncomingMessage, TServerResponse>): this; once(event: "start", listener: Server.StartCallback<TIncomingMessage, TServerResponse>): this; - once(event: "proxyReq", listener: Server.ProxyReqCallback<http.ClientRequest, TIncomingMessage, TServerResponse>): this; + once( + event: "proxyReq", + listener: Server.ProxyReqCallback<http.ClientRequest, TIncomingMessage, TServerResponse>, + ): this; once(event: "proxyRes", listener: Server.ProxyResCallback<TIncomingMessage, TServerResponse>): this; once(event: "proxyReqWs", listener: Server.ProxyReqWsCallback<http.ClientRequest, TIncomingMessage>): this; once(event: "econnreset", listener: Server.EconnresetCallback<Error, TIncomingMessage, TServerResponse>): this; @@ -200,7 +214,7 @@ declare namespace Server { TClientRequest = http.ClientRequest, TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse, - > = (proxyReq: TClientRequest, req: TIncomingMessage, res: TServerResponse, options: ServerOptions) => void; + > = (proxyReq: TClientRequest, req: TIncomingMessage, res: TServerResponse, options: ServerOptions) => void; type ProxyResCallback<TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse> = ( proxyRes: TIncomingMessage, req: TIncomingMessage, @@ -213,7 +227,11 @@ declare namespace Server { options: ServerOptions, head: any, ) => void; - type EconnresetCallback<TError = Error, TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse> = ( + type EconnresetCallback< + TError = Error, + TIncomingMessage = http.IncomingMessage, + TServerResponse = http.ServerResponse, + > = ( err: TError, req: TIncomingMessage, res: TServerResponse, @@ -222,16 +240,21 @@ declare namespace Server { type EndCallback<TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse> = ( req: TIncomingMessage, res: TServerResponse, - proxyRes: TIncomingMessage + proxyRes: TIncomingMessage, ) => void; type OpenCallback = (proxySocket: net.Socket) => void; - type CloseCallback<TIncomingMessage = http.IncomingMessage> = (proxyRes: TIncomingMessage, proxySocket: net.Socket, proxyHead: any) => void; - type ErrorCallback<TError = Error, TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse> = ( - err: TError, - req: TIncomingMessage, - res: TServerResponse | net.Socket, - target?: ProxyTargetUrl, + type CloseCallback<TIncomingMessage = http.IncomingMessage> = ( + proxyRes: TIncomingMessage, + proxySocket: net.Socket, + proxyHead: any, ) => void; + type ErrorCallback<TError = Error, TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse> = + ( + err: TError, + req: TIncomingMessage, + res: TServerResponse | net.Socket, + target?: ProxyTargetUrl, + ) => void; } export = Server; diff --git a/types/http-rx/http-rx-tests.ts b/types/http-rx/http-rx-tests.ts index b76ba6783234d3..f590e2c81f11c4 100644 --- a/types/http-rx/http-rx-tests.ts +++ b/types/http-rx/http-rx-tests.ts @@ -1,15 +1,15 @@ -import { Observable } from 'rxjs'; -import httpRx = require('http-rx'); -import request = require('request'); +import { Observable } from "rxjs"; +import httpRx = require("http-rx"); +import request = require("request"); -const httpGet: Observable<{response: request.Response}> = httpRx.get(''); +const httpGet: Observable<{ response: request.Response }> = httpRx.get(""); -const httpHead: Observable<{body: any}> = httpRx.head(''); +const httpHead: Observable<{ body: any }> = httpRx.head(""); -const httpPatch: Observable<{response: request.Response, body: any}> = httpRx.patch(''); +const httpPatch: Observable<{ response: request.Response; body: any }> = httpRx.patch(""); -const httpPost: Observable<{response: request.Response, body: any}> = httpRx.post('', {json: true}); +const httpPost: Observable<{ response: request.Response; body: any }> = httpRx.post("", { json: true }); -const httpPut: Observable<{}> = httpRx.put(''); +const httpPut: Observable<{}> = httpRx.put(""); -const httpDelete: Observable<object> = httpRx.delete(''); +const httpDelete: Observable<object> = httpRx.delete(""); diff --git a/types/http-rx/index.d.ts b/types/http-rx/index.d.ts index c752427b8aa5d0..442ecb68e5c7d2 100644 --- a/types/http-rx/index.d.ts +++ b/types/http-rx/index.d.ts @@ -4,8 +4,8 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -import { Observable } from 'rxjs'; -import request = require('request'); +import { Observable } from "rxjs"; +import request = require("request"); interface ResponseWrapper { response: request.Response; diff --git a/types/http-server/http-server-tests.ts b/types/http-server/http-server-tests.ts index 408b3c4241eb0e..9e8ff5ec4b581d 100644 --- a/types/http-server/http-server-tests.ts +++ b/types/http-server/http-server-tests.ts @@ -1,8 +1,8 @@ import { createServer } from "http-server"; const server = createServer({ - username: "admin", - password: "admin" + username: "admin", + password: "admin", }); server.listen(8000); diff --git a/types/http-server/index.d.ts b/types/http-server/index.d.ts index 9c5047a3381f0c..7fdd0e81207e8e 100644 --- a/types/http-server/index.d.ts +++ b/types/http-server/index.d.ts @@ -3,9 +3,9 @@ // Definitions by: York Yao <https://github.com/plantain-00> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +import { HandleFunction } from "connect"; import * as http from "http"; import * as https from "https"; -import { HandleFunction } from "connect"; export function createServer(options?: Options): http.Server | https.Server; diff --git a/types/http-string-parser/http-string-parser-tests.ts b/types/http-string-parser/http-string-parser-tests.ts index 7ae594777549a8..8fbbabd407aefd 100644 --- a/types/http-string-parser/http-string-parser-tests.ts +++ b/types/http-string-parser/http-string-parser-tests.ts @@ -35,6 +35,8 @@ function test_statusLine(): void { } function test_headers(): void { - var result: { [key: string]: string } = - parser.parseHeaders(["Content-Type: text/html; charset=utf-8", "Content-Length: 256"]); + var result: { [key: string]: string } = parser.parseHeaders([ + "Content-Type: text/html; charset=utf-8", + "Content-Length: 256", + ]); } diff --git a/types/http-string-parser/index.d.ts b/types/http-string-parser/index.d.ts index 02d04f0f6ac992..901c864cc62858 100644 --- a/types/http-string-parser/index.d.ts +++ b/types/http-string-parser/index.d.ts @@ -3,7 +3,6 @@ // Definitions by: DefinitelyTyped <https://github.com/DefinitelyTyped> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - interface ParseRequestResult { method: string; uri: string; diff --git a/types/http-terminator/http-terminator-tests.ts b/types/http-terminator/http-terminator-tests.ts index 36864cba4429ed..4d1a642f7a9d0b 100644 --- a/types/http-terminator/http-terminator-tests.ts +++ b/types/http-terminator/http-terminator-tests.ts @@ -1,6 +1,6 @@ -import { createServer as createHttpServer } from 'http'; -import { createServer as createHttpsServer } from 'https'; -import { createHttpTerminator } from 'http-terminator'; +import { createServer as createHttpServer } from "http"; +import { createHttpTerminator } from "http-terminator"; +import { createServer as createHttpsServer } from "https"; const httpServer = createHttpServer(); const httpTerminator = createHttpTerminator({ server: httpServer }); diff --git a/types/http-terminator/index.d.ts b/types/http-terminator/index.d.ts index f36e6f2d058a52..168ae4cbc9e46d 100644 --- a/types/http-terminator/index.d.ts +++ b/types/http-terminator/index.d.ts @@ -5,8 +5,8 @@ /// <reference types="node" /> -import { Server as HttpServer } from 'http'; -import { Server as HttpsServer } from 'https'; +import { Server as HttpServer } from "http"; +import { Server as HttpsServer } from "https"; /** * Terminator configuration interface. diff --git a/types/httperr/httperr-tests.ts b/types/httperr/httperr-tests.ts index db58b1a4873877..7885cbb0307012 100644 --- a/types/httperr/httperr-tests.ts +++ b/types/httperr/httperr-tests.ts @@ -1,8 +1,8 @@ -import httperr = require('httperr'); +import httperr = require("httperr"); // ---------------------------------------- // Basic usage example from: https://github.com/pluma/httperr/blob/1.0.0/README.md -var err = httperr[404]('The path "/example" could not be resolved'); +var err = httperr[404]("The path \"/example\" could not be resolved"); console.log(err); /* { [NotFound: The path "/example" could not be resolved] @@ -18,7 +18,7 @@ NotFound: The path "/example" could not be resolved at ... */ -console.log(httperr.methodNotAllowed({allowed: ['GET', 'POST']})); +console.log(httperr.methodNotAllowed({ allowed: ["GET", "POST"] })); /* { [MethodNotAllowed] title: 'Method Not Allowed', @@ -44,27 +44,25 @@ console.log(err); console.log(err instanceof httperr.NotFound); // true console.log(err instanceof httperr.notFound); // true -console.log(err instanceof httperr['404']); // true +console.log(err instanceof httperr["404"]); // true console.log(err instanceof httperr.MethodNotAllowed); // false console.log(err instanceof httperr.HttpError); // true console.log(err instanceof Error); // true - // ---------------------------------------- // Advanced usage: creating custom Error subclasses -var Custom404Error = httperr.createHttpError(404, 'Not Found', function (config) { - this.message = 'The resource was not found'; - this['some custom property'] = config.parameters['some custom parameter']; +var Custom404Error = httperr.createHttpError(404, "Not Found", function(config) { + this.message = "The resource was not found"; + this["some custom property"] = config.parameters["some custom parameter"]; }); err = new Custom404Error(); -var Custom500Error = httperr.createHttpError(500, 'Something went wrong'); +var Custom500Error = httperr.createHttpError(500, "Something went wrong"); err = new Custom500Error(); - // ---------------------------------------- // Advanced usage: returning a JSON serializable representation of an error -var err = httperr.notFound('File Not Found'); +var err = httperr.notFound("File Not Found"); console.log(err.toObject()); /* { @@ -76,7 +74,7 @@ console.log(err.toObject()); stack: '…' } */ -console.log(err.toObject('stack', /^title$/)); +console.log(err.toObject("stack", /^title$/)); /* { name: 'NotFound', diff --git a/types/httperr/index.d.ts b/types/httperr/index.d.ts index 66faf345701b5d..19f271d3655912 100644 --- a/types/httperr/index.d.ts +++ b/types/httperr/index.d.ts @@ -3,11 +3,8 @@ // Definitions by: Troy Gerwien <https://github.com/yortus> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - - /** Overall module shape, expressed as an interface. */ interface HttpErr { - /** The base type for all httperr error types. You probably don't want to use this directly. */ HttpError: HttpErrorStatic; @@ -206,13 +203,11 @@ interface HttpErr { /** Constructor function for the HttpError class. */ interface HttpErrorStatic { - new (config?: string | Error | Config, extra?: {}): HttpError; + new(config?: string | Error | Config, extra?: {}): HttpError; } - /** An instance of the HttpError class. */ interface HttpError extends Error { - /** A human-readable title for the HTTP error. */ title: string; @@ -224,10 +219,8 @@ interface HttpError extends Error { toObject(...skip: (string | RegExp)[]): any; } - /** Configuration object for constructing HttpErrors. */ interface Config { - /** A descriptive human-readable title describing the error's cause. */ message?: string | undefined; @@ -266,10 +259,8 @@ interface Config { location?: any; } - /** Factory function for creating an Error object. */ interface ErrorBuilder { - /** * Creates an Error object. The new keyword is optional. * @param {string | Error | Config} config - If config is a string, it will be treated as config.message. @@ -282,10 +273,9 @@ interface ErrorBuilder { * @param {string | Error | Config} config - If config is a string, it will be treated as config.message. * If config is an Error object, it will be treated as config.cause. */ - new (config?: string | Error | Config): HttpError; + new(config?: string | Error | Config): HttpError; } - // The module value satisfies the HttpErr interface. declare var _: HttpErr; export = _; diff --git a/types/httpsnippet/httpsnippet-tests.ts b/types/httpsnippet/httpsnippet-tests.ts index ae52e507f11e02..14940ed6111206 100644 --- a/types/httpsnippet/httpsnippet-tests.ts +++ b/types/httpsnippet/httpsnippet-tests.ts @@ -1,9 +1,9 @@ -import HTTPSnippet = require('httpsnippet'); +import HTTPSnippet = require("httpsnippet"); const snippet = new HTTPSnippet({ - method: 'POST', - url: 'https://asd', - httpVersion: '2.0', + method: "POST", + url: "https://asd", + httpVersion: "2.0", cookies: [], headers: [], bodySize: 0, @@ -12,4 +12,4 @@ const snippet = new HTTPSnippet({ }); // $ExpectType string | false -snippet.convert('c', 'libcurl'); +snippet.convert("c", "libcurl"); diff --git a/types/httpsnippet/index.d.ts b/types/httpsnippet/index.d.ts index 4226e4a35a029b..43984b68e74336 100644 --- a/types/httpsnippet/index.d.ts +++ b/types/httpsnippet/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Marcell Toth <https://github.com/marcelltoth> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import { Har, Request } from 'har-format'; +import { Har, Request } from "har-format"; /*~ This declaration specifies that the class constructor function *~ is the exported object from the file diff --git a/types/hubot/hubot-tests.ts b/types/hubot/hubot-tests.ts index ffdaa54f2ab568..eab5e622983371 100644 --- a/types/hubot/hubot-tests.ts +++ b/types/hubot/hubot-tests.ts @@ -1,20 +1,20 @@ -import { Robot, Adapter, Brain, Message, User } from 'hubot'; +import { Adapter, Brain, Message, Robot, User } from "hubot"; -const user = new User('123'); +const user = new User("123"); const message = new Message(user); -const robot = new Robot<Adapter>('src/adapters', 'slack', false, 'hubot'); +const robot = new Robot<Adapter>("src/adapters", "slack", false, "hubot"); robot; // $ExpectType Robot<Adapter> robot.adapter; // $ExpectType Adapter robot.name; // $ExpectType string robot.brain; // $ExpectType Brain<Adapter> robot.catchAll(() => null); // $ExpectType void -robot.emit('test', 'arg'); // $ExpectType void +robot.emit("test", "arg"); // $ExpectType void robot.enter(() => null); // $ExpectType void robot.error(err => null); // $ExpectType void robot.hear(/hello/, () => null); // $ExpectType void robot.helpCommands(); // $ExpectType string[] -robot.http('https://google.com'); // $ExpectType ScopedClient +robot.http("https://google.com"); // $ExpectType ScopedClient robot.leave(() => null); // $ExpectType void // $ExpectType void robot.listen( @@ -25,8 +25,8 @@ robot.listen( robot.listenerMiddleware((context, next, done) => { next(done); }); -robot.messageRoom('general', 'Hello friends'); // $ExpectType void -robot.on('test', () => null); // $ExpectType Robot<Adapter> +robot.messageRoom("general", "Hello friends"); // $ExpectType void +robot.on("test", () => null); // $ExpectType Robot<Adapter> robot.receive(message, () => null); // $ExpectType void // $ExpectType void robot.receiveMiddleware((context, next, done) => { @@ -37,9 +37,9 @@ robot.reply( { message, user, - room: 'general', + room: "general", }, - 'Replying to friends', + "Replying to friends", ); robot.respond(/hello/, () => null); // $ExpectType void robot.respondPattern(/hello/); // $ExpectType RegExp @@ -53,26 +53,26 @@ robot.send( { message, user, - room: 'general', + room: "general", }, - 'Replying to friends', + "Replying to friends", ); robot.shutdown(); // $ExpectType void robot.topic(message => null); // $ExpectType void const brain = new Brain(robot); brain; // $ExpectType Brain<Adapter> -brain.userForName('someone'); // $ExpectType User | null -brain.get('test'); // $ExpectType any -brain.set('test', 'test'); // $ExpectType Brain<Adapter> -brain.remove('test'); // $ExpectType Brain<Adapter> +brain.userForName("someone"); // $ExpectType User | null +brain.get("test"); // $ExpectType any +brain.set("test", "test"); // $ExpectType Brain<Adapter> +brain.remove("test"); // $ExpectType Brain<Adapter> brain.setAutoSave(false); // $ExpectType void brain.resetSaveInterval(15); // $ExpectType void -brain.mergeData({ foo: 'bar' }); // $ExpectType void +brain.mergeData({ foo: "bar" }); // $ExpectType void brain.users(); // $ExpectType User[] -brain.userForId('123'); // $ExpectType User -brain.userForName('jon'); // $ExpectType User | null -brain.usersForRawFuzzyName('fuzzy'); // $ExpectType User[] -brain.usersForFuzzyName('fuzzy'); // $ExpectType User[] +brain.userForId("123"); // $ExpectType User +brain.userForName("jon"); // $ExpectType User | null +brain.usersForRawFuzzyName("fuzzy"); // $ExpectType User[] +brain.usersForFuzzyName("fuzzy"); // $ExpectType User[] brain.save(); // $ExpectType void brain.close(); // $ExpectType void diff --git a/types/hubot/index.d.ts b/types/hubot/index.d.ts index d4b378e7ae6667..69a42326243492 100644 --- a/types/hubot/index.d.ts +++ b/types/hubot/index.d.ts @@ -7,10 +7,10 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.0 -import { EventEmitter } from 'events'; -import { Options as HttpOptions, ScopedClient } from 'scoped-http-client'; -import { Server } from 'http'; -import { Express } from 'express'; +import { EventEmitter } from "events"; +import { Express } from "express"; +import { Server } from "http"; +import { Options as HttpOptions, ScopedClient } from "scoped-http-client"; declare namespace Hubot { class Adapter extends EventEmitter { diff --git a/types/hubspot-pace/hubspot-pace-tests.ts b/types/hubspot-pace/hubspot-pace-tests.ts index 034a1e4cc9465b..19810389bcd430 100644 --- a/types/hubspot-pace/hubspot-pace-tests.ts +++ b/types/hubspot-pace/hubspot-pace-tests.ts @@ -1,7 +1,5 @@ - - pace.start({ - document: false + document: false, }); pace.start(); @@ -18,44 +16,44 @@ paceOptions = { // Only show the progress on regular and ajax-y page navigation, // not every request - restartOnRequestAfter: false -} + restartOnRequestAfter: false, +}; paceOptions = { ajax: false, // disabled document: false, // disabled eventLag: false, // disabled elements: { - selectors: ['.my-page'] - } + selectors: [".my-page"], + }, }; paceOptions = { elements: { - selectors: ['.timeline,.timeline-error', '.user-profile,.profile-error'] - } -} + selectors: [".timeline,.timeline-error", ".user-profile,.profile-error"], + }, +}; paceOptions = { - restartOnPushState: false -} + restartOnPushState: false, +}; paceOptions = { - restartOnRequestAfter: false -} + restartOnRequestAfter: false, +}; pace.options = { - restartOnRequestAfter: false -} + restartOnRequestAfter: false, +}; -pace.ignore(function(){ +pace.ignore(function() { }); -pace.track(function(){ +pace.track(function() { }); pace.options = { - ajax: { - ignoreURLs: ['some-substring', /some-regexp/] - } + ajax: { + ignoreURLs: ["some-substring", /some-regexp/], + }, }; diff --git a/types/hubspot-pace/index.d.ts b/types/hubspot-pace/index.d.ts index 50a9b29e33c00c..22f431dcfa5cfb 100644 --- a/types/hubspot-pace/index.d.ts +++ b/types/hubspot-pace/index.d.ts @@ -106,7 +106,13 @@ declare namespace HubSpotPaceInterfaces { once(event: string, handler: (...args: any[]) => void, context?: any): void; } - enum PaceEvent { start, stop, restart, done, hide } + enum PaceEvent { + start, + stop, + restart, + done, + hide, + } } declare var pace: HubSpotPaceInterfaces.Pace; diff --git a/types/hull.js/hull.js-tests.ts b/types/hull.js/hull.js-tests.ts index 0737368fcc43a6..212dae75270f0b 100644 --- a/types/hull.js/hull.js-tests.ts +++ b/types/hull.js/hull.js-tests.ts @@ -1,4 +1,4 @@ -import hull = require('hull.js'); +import hull = require("hull.js"); const numberPointSet = [ [236, 126], @@ -99,6 +99,6 @@ hull(numberPointSet); hull(numberPointSet, 50); -hull(objectPointSet, 50, ['.lng', '.lat']); +hull(objectPointSet, 50, [".lng", ".lat"]); hull(biggerNumberPointSet); diff --git a/types/human-crypto-keys/human-crypto-keys-tests.ts b/types/human-crypto-keys/human-crypto-keys-tests.ts index 94881a1158e7c6..4fb2eb11b30a85 100644 --- a/types/human-crypto-keys/human-crypto-keys-tests.ts +++ b/types/human-crypto-keys/human-crypto-keys-tests.ts @@ -1,4 +1,4 @@ -import { generateKeyPair, getKeyPairFromMnemonic, getKeyPairFromSeed } from 'human-crypto-keys'; +import { generateKeyPair, getKeyPairFromMnemonic, getKeyPairFromSeed } from "human-crypto-keys"; -generateKeyPair('rsa').then(keypair => getKeyPairFromMnemonic(keypair.mnemonic, keypair.algorithm)); -getKeyPairFromSeed('jackhedaya', 'rsa'); +generateKeyPair("rsa").then(keypair => getKeyPairFromMnemonic(keypair.mnemonic, keypair.algorithm)); +getKeyPairFromSeed("jackhedaya", "rsa"); diff --git a/types/human-crypto-keys/index.d.ts b/types/human-crypto-keys/index.d.ts index fed72ee5548f1a..46cfacb7a98d9a 100644 --- a/types/human-crypto-keys/index.d.ts +++ b/types/human-crypto-keys/index.d.ts @@ -8,7 +8,6 @@ export function generateKeyPair( * The algorithm identifier and the respective parameters to generate a key pair */ algorithm: Algorithm, - /** * Options to be used while composing keys */ @@ -20,12 +19,10 @@ export function getKeyPairFromMnemonic( * The mnemonic provided as one of the recovery methods for a key pair */ mnemonic: string, - /** * The algorithm identifier and the respective parameters to generate a key pair */ algorithm: Algorithm, - /** * Options to be used while composing keys */ @@ -37,26 +34,24 @@ export function getKeyPairFromSeed( * The seed provided as one of the recovery methods for a key pair */ seed: string, - /** * The algorithm identifier and the respective parameters to generate a key pair */ algorithm: Algorithm, - /** * Options to be used while composing keys */ options?: Options, ): Promise<SimpleKeyPair>; -type Algorithm = ED25519Algorithm | RSAAlgorithm | ED25519Algorithm['id'] | RSAAlgorithm['id']; +type Algorithm = ED25519Algorithm | RSAAlgorithm | ED25519Algorithm["id"] | RSAAlgorithm["id"]; interface ED25519Algorithm { - id: 'ed25519'; + id: "ed25519"; } interface RSAAlgorithm { - id: 'rsa'; + id: "rsa"; /** * @default 2048 @@ -100,7 +95,7 @@ interface FullKeyPair { publicKey: string; } -type SimpleKeyPair = Pick<FullKeyPair, 'privateKey' | 'publicKey'>; +type SimpleKeyPair = Pick<FullKeyPair, "privateKey" | "publicKey">; interface Options { /** diff --git a/types/human-date/human-date-tests.ts b/types/human-date/human-date-tests.ts index 0e637e781f4ee0..b1f166f4e183c7 100644 --- a/types/human-date/human-date-tests.ts +++ b/types/human-date/human-date-tests.ts @@ -1,15 +1,15 @@ -import hdate = require('human-date'); +import hdate = require("human-date"); // .prertyPrint method hdate.prettyPrint(); // $ExpectType string -hdate.prettyPrint('8-16-1987'); -hdate.prettyPrint(new Date('8-16-1987')); +hdate.prettyPrint("8-16-1987"); +hdate.prettyPrint(new Date("8-16-1987")); hdate.prettyPrint(-6400); hdate.prettyPrint(new Date(1416448704578), { showTime: true }); // .relativeTime method hdate.relativeTime(4); -hdate.relativeTime(4, {futureSuffix: "in the future"}); +hdate.relativeTime(4, { futureSuffix: "in the future" }); hdate.relativeTime("8-16-1987"); hdate.relativeTime(new Date("8-16-1987")); hdate.relativeTime(new Date("8-16-1987"), { returnObject: true }); diff --git a/types/human-date/index.d.ts b/types/human-date/index.d.ts index 7bf87e309a721a..e6b500dd848d87 100644 --- a/types/human-date/index.d.ts +++ b/types/human-date/index.d.ts @@ -26,18 +26,18 @@ export interface RelativeTimeReturns { // prettyPrint export function prettyPrint( arg?: string | Date | number, - options?: PrettyPrintOptions + options?: PrettyPrintOptions, ): string; // relativeTime export function relativeTime( arg: string | Date | number, - options?: RelativeTimeOptions & { returnObject?: false } + options?: RelativeTimeOptions & { returnObject?: false }, ): string; export function relativeTime( arg: string | Date | number, - options: RelativeTimeOptions & { returnObject: true } + options: RelativeTimeOptions & { returnObject: true }, ): RelativeTimeReturns; // monthName diff --git a/types/human-format/human-format-tests.ts b/types/human-format/human-format-tests.ts index d91ac3df5d5b25..44a9030c0c509c 100644 --- a/types/human-format/human-format-tests.ts +++ b/types/human-format/human-format-tests.ts @@ -10,7 +10,7 @@ humanFormat(1337, { // $ExpectType string humanFormat(13337, { - maxDecimals: 'auto', + maxDecimals: "auto", }); // $ExpectType string @@ -23,7 +23,7 @@ humanFormat.bytes(65536); // $ExpectType string humanFormat(1337, { - separator: ' - ', + separator: " - ", }); const timeScale = new humanFormat.Scale({ @@ -38,16 +38,16 @@ humanFormat(26729235, { scale: timeScale }); // $ExpectType ScaleOptions timeScale.findPrefix(100); // $ExpectType ParseResult -timeScale.parse('10 months'); +timeScale.parse("10 months"); // $ExpectType string -humanFormat.raw(100, { prefix: 'k' }); +humanFormat.raw(100, { prefix: "k" }); // $ExpectType string -humanFormat(100, { unit: 'm', prefix: 'k' }); +humanFormat(100, { unit: "m", prefix: "k" }); // $ExpectType number -humanFormat.parse('1.34 kiB', { scale: 'binary' }); +humanFormat.parse("1.34 kiB", { scale: "binary" }); // $ExpectType ParseResult -humanFormat.parse.raw('1.34 kB'); +humanFormat.parse.raw("1.34 kB"); diff --git a/types/human-format/index.d.ts b/types/human-format/index.d.ts index 25f893acf6814b..f049eade1b6ee2 100644 --- a/types/human-format/index.d.ts +++ b/types/human-format/index.d.ts @@ -7,10 +7,10 @@ * Options for formatting and parsing */ interface FormatOptions { - maxDecimals?: number | 'auto'; + maxDecimals?: number | "auto"; separator?: string; unit?: string; - scale?: 'SI' | 'binary' | humanFormat.Scale; + scale?: "SI" | "binary" | humanFormat.Scale; strict?: boolean; decimals?: number; prefix?: string; diff --git a/types/humane-js/humane-js-tests.ts b/types/humane-js/humane-js-tests.ts index 77292fcfe8140e..25449ce1445d47 100644 --- a/types/humane-js/humane-js-tests.ts +++ b/types/humane-js/humane-js-tests.ts @@ -1,27 +1,29 @@ -import humane = require('humane-js'); +import humane = require("humane-js"); humane.log("Welcome Back"); humane.log(["List", "of", "Items"]); -humane.log("Callback when finished", () => { document.body.style.backgroundColor = "#a66000"; }); -humane.log("Options can be passed", { timeout: 4000, clickToClose: true, addnCls: 'humane-error' }); +humane.log("Callback when finished", () => { + document.body.style.backgroundColor = "#a66000"; +}); +humane.log("Options can be passed", { timeout: 4000, clickToClose: true, addnCls: "humane-error" }); humane.timeout = 5000; humane.waitForMove = true; humane.clickToClose = true; -humane.addnCls = 'humane-info'; +humane.addnCls = "humane-info"; -humane.info = humane.spawn({ addnCls: 'humane-libnotify-info', timeout: 1000 }); -humane.info('Info Themed Notifier'); -humane.error = humane.spawn({ addnCls: 'humane-libnotify-error', timeout: 1000 }); -humane.error('Error Themed Notifier'); -humane.remove(() => alert('removed')); +humane.info = humane.spawn({ addnCls: "humane-libnotify-info", timeout: 1000 }); +humane.info("Info Themed Notifier"); +humane.error = humane.spawn({ addnCls: "humane-libnotify-error", timeout: 1000 }); +humane.error("Error Themed Notifier"); +humane.remove(() => alert("removed")); -const bigbox = humane.create({baseCls: 'humane-bigbox', timeout: 1000}); -bigbox.error = bigbox.spawn({addnCls: 'humane-bigbox-error'}); -bigbox.log('Oh!').error('No!'); +const bigbox = humane.create({ baseCls: "humane-bigbox", timeout: 1000 }); +bigbox.error = bigbox.spawn({ addnCls: "humane-bigbox-error" }); +bigbox.log("Oh!").error("No!"); -const libnotify = humane.create({baseCls: 'humane-libnotify', addnCls: 'humane-libnotify-info'}); -libnotify.log('Notified'); +const libnotify = humane.create({ baseCls: "humane-libnotify", addnCls: "humane-libnotify-info" }); +libnotify.log("Notified"); -const jacked = humane.create({baseCls: 'humane-jackedup', addnCls: 'humane-jackedup-success'}); +const jacked = humane.create({ baseCls: "humane-jackedup", addnCls: "humane-jackedup-success" }); jacked.log("What's up here!"); diff --git a/types/humanize-ms/humanize-ms-tests.ts b/types/humanize-ms/humanize-ms-tests.ts index 3719582f2b0568..45f8cbc42398d9 100644 --- a/types/humanize-ms/humanize-ms-tests.ts +++ b/types/humanize-ms/humanize-ms-tests.ts @@ -1,7 +1,7 @@ import HumanizeMs = require("humanize-ms"); -HumanizeMs('1s'); // $ExpectType number | undefined +HumanizeMs("1s"); // $ExpectType number | undefined HumanizeMs(1000); // $ExpectType number | undefined -HumanizeMs('incorrect-string'); // $ExpectType number | undefined +HumanizeMs("incorrect-string"); // $ExpectType number | undefined diff --git a/types/humanize-ms/index.d.ts b/types/humanize-ms/index.d.ts index 363041a9629fac..777738dea90a59 100644 --- a/types/humanize-ms/index.d.ts +++ b/types/humanize-ms/index.d.ts @@ -3,6 +3,6 @@ // Definitions by: DefinitelyTyped <https://github.com/DefinitelyTyped> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare function HumanizeMS(input: string|number): number | undefined; +declare function HumanizeMS(input: string | number): number | undefined; export = HumanizeMS; diff --git a/types/humanize-plus/humanize-plus-tests.ts b/types/humanize-plus/humanize-plus-tests.ts index 4e66ff6c266ca1..e34ed92cacd9c4 100644 --- a/types/humanize-plus/humanize-plus-tests.ts +++ b/types/humanize-plus/humanize-plus-tests.ts @@ -1,4 +1,4 @@ -import * as Humanize from 'humanize-plus'; +import * as Humanize from "humanize-plus"; ///////////// // Numbers // @@ -47,11 +47,11 @@ Humanize.ordinal(22); /** * times */ -for (let i = 0; i < 5; i ++) { - Humanize.times(i, {4: 'too many'}); - if (i === 1) { - Humanize.times(1.1); - } +for (let i = 0; i < 5; i++) { + Humanize.times(i, { 4: "too many" }); + if (i === 1) { + Humanize.times(1.1); + } } // never // once @@ -107,19 +107,19 @@ Humanize.pluralize(3, "duck", "duckies"); /** * truncate */ -Humanize.truncate('long text is good for you'); +Humanize.truncate("long text is good for you"); // "long text is good for you" -Humanize.truncate('long text is good for you', 19); +Humanize.truncate("long text is good for you", 19); // "long text is goo..." -Humanize.truncate('long text is good for you', 19, '... etc'); +Humanize.truncate("long text is good for you", 19, "... etc"); // "long text is... etc" /** * truncateWords */ -Humanize.truncateWords('long text is good for you', 5); +Humanize.truncateWords("long text is good for you", 5); // "long text is good for ..." /** @@ -156,7 +156,7 @@ Humanize.titleCase("cool the iTunes cake, O'Malley!"); /** * oxford */ -const items = ['apple', 'orange', 'banana', 'pear', 'pineapple']; +const items = ["apple", "orange", "banana", "pear", "pineapple"]; Humanize.oxford(items); // "apple, orange, banana, pear, and pineapple" @@ -175,9 +175,9 @@ Humanize.oxford(items, 3, "and some other fruits"); * frequency */ const aznPics = [ - 'http://24.media.tumblr.com/77082543cb69af56ede38a0cdb2511d0/tumblr_mh96olWPLv1r8k4ywo1_1280.jpg', - 'http://25.media.tumblr.com/3e2d318be34d5ef8f86a612cd1d795ff/tumblr_mhbhb96t3z1r8k4ywo1_1280.jpg', - 'http://24.media.tumblr.com/8c5a052e33c27c784514e1b124b383a1/tumblr_mhexaqrk0w1r8k4ywo1_1280.jpg' + "http://24.media.tumblr.com/77082543cb69af56ede38a0cdb2511d0/tumblr_mh96olWPLv1r8k4ywo1_1280.jpg", + "http://25.media.tumblr.com/3e2d318be34d5ef8f86a612cd1d795ff/tumblr_mhbhb96t3z1r8k4ywo1_1280.jpg", + "http://24.media.tumblr.com/8c5a052e33c27c784514e1b124b383a1/tumblr_mhexaqrk0w1r8k4ywo1_1280.jpg", ]; const bigfootPics: string[] = []; diff --git a/types/humanparser/humanparser-tests.ts b/types/humanparser/humanparser-tests.ts index 6e4579daaa2fc1..c247e3adbc447f 100644 --- a/types/humanparser/humanparser-tests.ts +++ b/types/humanparser/humanparser-tests.ts @@ -1,4 +1,4 @@ -import human = require('humanparser'); +import human = require("humanparser"); let parsedName = human.parseName("Mr. William R. Hearst, III"); // $ExpectType string | undefined @@ -14,7 +14,7 @@ parsedName.middleName; // $ExpectType string | undefined parsedName.salutation; -let parsedNameWithSuffixIgnored = human.parseName("Mr. William R. Hearst, III", ['III']); +let parsedNameWithSuffixIgnored = human.parseName("Mr. William R. Hearst, III", ["III"]); // $ExpectType string | undefined parsedNameWithSuffixIgnored.firstName; // $ExpectType string @@ -28,7 +28,7 @@ parsedNameWithSuffixIgnored.middleName; // $ExpectType string | undefined parsedNameWithSuffixIgnored.salutation; -let parsedNameWithParseOptions = human.parseName("Mr. William R. Hearst, III", { ignoreSuffix: ['III'] }); +let parsedNameWithParseOptions = human.parseName("Mr. William R. Hearst, III", { ignoreSuffix: ["III"] }); // $ExpectType string | undefined parsedNameWithParseOptions.firstName; // $ExpectType string diff --git a/types/humanparser/index.d.ts b/types/humanparser/index.d.ts index 7c4982cece5167..cffeb734a61f15 100644 --- a/types/humanparser/index.d.ts +++ b/types/humanparser/index.d.ts @@ -35,11 +35,10 @@ declare namespace humanparser { } interface HumanparserStatic { - parseName (name: string, options?: string[] | ParseNameOptions): NameOutput; - getFullestName (name: string): FullerNameOutput; - parseAddress (address: string): AddressOutput; + parseName(name: string, options?: string[] | ParseNameOptions): NameOutput; + getFullestName(name: string): FullerNameOutput; + parseAddress(address: string): AddressOutput; } - } declare const humanparser: humanparser.HumanparserStatic; diff --git a/types/humblebee__styled-components-breakpoint/humblebee__styled-components-breakpoint-tests.ts b/types/humblebee__styled-components-breakpoint/humblebee__styled-components-breakpoint-tests.ts index aa402b4c21b284..1f34d56ea4a71a 100644 --- a/types/humblebee__styled-components-breakpoint/humblebee__styled-components-breakpoint-tests.ts +++ b/types/humblebee__styled-components-breakpoint/humblebee__styled-components-breakpoint-tests.ts @@ -5,7 +5,7 @@ const breakpoint = getMedia({ medium: 640, large: 1023, xlarge: 1200, - xxlarge: 1440 + xxlarge: 1440, }); breakpoint.down("small"); diff --git a/types/humblebee__styled-components-breakpoint/index.d.ts b/types/humblebee__styled-components-breakpoint/index.d.ts index c34ae8a5b9b068..fb74b8e62729f4 100644 --- a/types/humblebee__styled-components-breakpoint/index.d.ts +++ b/types/humblebee__styled-components-breakpoint/index.d.ts @@ -9,7 +9,7 @@ declare module "@humblebee/styled-components-breakpoint" { import { CSSObject, SimpleInterpolation } from "styled-components"; type Rule = "up" | "down" | "only"; - interface Breakpoints { + interface Breakpoints { [key: string]: number; } @@ -38,13 +38,23 @@ declare module "@humblebee/styled-components-breakpoint" { * @example "@media only screen and (min-width: ____px)" * @param widthKey min width */ - up: (widthKey: string) => (first: TemplateStringsArray | CSSObject, ...interpolations: SimpleInterpolation[]) => import("styled-components").FlattenSimpleInterpolation; + up: ( + widthKey: string, + ) => ( + first: TemplateStringsArray | CSSObject, + ...interpolations: SimpleInterpolation[] + ) => import("styled-components").FlattenSimpleInterpolation; /** * Will return a media query with a max-width of the defined breakpoint * @example "@media only screen and (max-width: ____px)" * @param widthKey max width */ - down: (widthKey: string) => (first: TemplateStringsArray | CSSObject, ...interpolations: SimpleInterpolation[]) => import("styled-components").FlattenSimpleInterpolation; + down: ( + widthKey: string, + ) => ( + first: TemplateStringsArray | CSSObject, + ...interpolations: SimpleInterpolation[] + ) => import("styled-components").FlattenSimpleInterpolation; /** * For one parameter: @@ -58,9 +68,13 @@ declare module "@humblebee/styled-components-breakpoint" { * @param widthKey min width * @param boundKey max width, optional (if missing, next higher than min width) */ - only: (widthKey: string, boundKey?: string) - => (first: TemplateStringsArray | CSSObject, ...interpolations: SimpleInterpolation[]) - => import("styled-components").FlattenSimpleInterpolation; + only: ( + widthKey: string, + boundKey?: string, + ) => ( + first: TemplateStringsArray | CSSObject, + ...interpolations: SimpleInterpolation[] + ) => import("styled-components").FlattenSimpleInterpolation; list: string[]; }; diff --git a/types/hummer-env/components/BaseComponent.d.ts b/types/hummer-env/components/BaseComponent.d.ts index 9e97e44abe5e5e..dbcc2368a24b6d 100644 --- a/types/hummer-env/components/BaseComponent.d.ts +++ b/types/hummer-env/components/BaseComponent.d.ts @@ -22,24 +22,24 @@ interface HummerComponent { * @param rect.windowTop number 控件上边框相对于屏幕上边缘的坐标 * @param rect.windowBottom number 控件下边框相对于屏幕上边缘的坐标 */ - getRect: (cb: (rect: import('../interface/info').viewRect) => void) => void; + getRect: (cb: (rect: import("../interface/info").viewRect) => void) => void; /** * @summary 为组件绑定事件 * @param type 事件类型 * @param listener 触发事件后的回调 */ - addEventListener<K extends keyof import('../interface/event').EventHandlersEventMap>( + addEventListener<K extends keyof import("../interface/event").EventHandlersEventMap>( type: K, - listener: (ev: import('../interface/event').EventHandlersEventMap[K]) => void, + listener: (ev: import("../interface/event").EventHandlersEventMap[K]) => void, ): void; /** * @summary 移除组件事件 * @param type 事件类型 * @param listener 移除的事件 */ - removeEventListener<K extends keyof import('../interface/event').EventHandlersEventMap>( + removeEventListener<K extends keyof import("../interface/event").EventHandlersEventMap>( type: K, - listener: (ev: import('../interface/event').EventHandlersEventMap[K]) => void, + listener: (ev: import("../interface/event").EventHandlersEventMap[K]) => void, ): void; /** * @summary 为组件添加动画 diff --git a/types/hummer-env/components/Button.d.ts b/types/hummer-env/components/Button.d.ts index bd9ed5a79d5caa..ff1b32799680ac 100644 --- a/types/hummer-env/components/Button.d.ts +++ b/types/hummer-env/components/Button.d.ts @@ -24,5 +24,5 @@ declare const Button: { /** * 按钮控件 */ - new (): Button; + new(): Button; }; diff --git a/types/hummer-env/components/CanvasView.d.ts b/types/hummer-env/components/CanvasView.d.ts index eedba4ca7fe2d4..234d6515ad2e26 100644 --- a/types/hummer-env/components/CanvasView.d.ts +++ b/types/hummer-env/components/CanvasView.d.ts @@ -120,5 +120,5 @@ declare const CanvasView: { /** * 画布组件,可用于绘制一些自定义图形,如:线段、矩形、圆形、椭圆、图片、文本等,从而实现复杂图形的展示。 */ - new (id?: string): CanvasView; + new(id?: string): CanvasView; }; diff --git a/types/hummer-env/components/HorizontalScroller.d.ts b/types/hummer-env/components/HorizontalScroller.d.ts index f7de6b999d15d4..40af0ade94fe4d 100644 --- a/types/hummer-env/components/HorizontalScroller.d.ts +++ b/types/hummer-env/components/HorizontalScroller.d.ts @@ -37,5 +37,5 @@ declare const HorizontalScroller: { /** * 水平滚动组件。 */ - new (): HorizontalScroller; + new(): HorizontalScroller; }; diff --git a/types/hummer-env/components/Image.d.ts b/types/hummer-env/components/Image.d.ts index e9ded7348bbc99..2e846adc9ccd3e 100644 --- a/types/hummer-env/components/Image.d.ts +++ b/types/hummer-env/components/Image.d.ts @@ -32,12 +32,12 @@ interface Image extends HummerComponent { * gifRepeatCount: number // Gif图重复次数 * } */ - load(src: string | import('../interface/info').imageStyle, cb: (srcType: number, isSuccess: boolean) => void): void; + load(src: string | import("../interface/info").imageStyle, cb: (srcType: number, isSuccess: boolean) => void): void; } declare const Image: { prototype: Image; /** * 图片组件。 */ - new (): Image; + new(): Image; }; diff --git a/types/hummer-env/components/Input.d.ts b/types/hummer-env/components/Input.d.ts index b2bf4cbba37f0a..a870842084cc33 100644 --- a/types/hummer-env/components/Input.d.ts +++ b/types/hummer-env/components/Input.d.ts @@ -18,5 +18,5 @@ declare const Input: { /** * 单行文本输入组件。 */ - new (): Input; + new(): Input; }; diff --git a/types/hummer-env/components/List.d.ts b/types/hummer-env/components/List.d.ts index 284255577928dd..7a0f418a342948 100644 --- a/types/hummer-env/components/List.d.ts +++ b/types/hummer-env/components/List.d.ts @@ -79,5 +79,5 @@ declare const List: { /** * 列表组件。 */ - new (): List; + new(): List; }; diff --git a/types/hummer-env/components/Scroller.d.ts b/types/hummer-env/components/Scroller.d.ts index 4a3e78bfdd534a..6681491aa030ba 100644 --- a/types/hummer-env/components/Scroller.d.ts +++ b/types/hummer-env/components/Scroller.d.ts @@ -62,5 +62,5 @@ declare const Scroller: { /** * 垂直滚动组件。 */ - new (): Scroller; + new(): Scroller; }; diff --git a/types/hummer-env/components/Switch.d.ts b/types/hummer-env/components/Switch.d.ts index f5994470bb3af9..1f428137d28b35 100644 --- a/types/hummer-env/components/Switch.d.ts +++ b/types/hummer-env/components/Switch.d.ts @@ -10,5 +10,5 @@ declare const Switch: { /** * 开关组件。 */ - new (): Switch; + new(): Switch; }; diff --git a/types/hummer-env/components/Text.d.ts b/types/hummer-env/components/Text.d.ts index 3f104c30e55838..b512e5058b2e84 100644 --- a/types/hummer-env/components/Text.d.ts +++ b/types/hummer-env/components/Text.d.ts @@ -7,7 +7,7 @@ interface Text extends HummerComponent { /** * 富文本内容 */ - rickText: import('../interface/info').rickTextType; + rickText: import("../interface/info").rickTextType; /** * 是否支持长按复制功能 默认 false */ @@ -18,5 +18,5 @@ declare const Text: { /** * 文本展示控件。 */ - new (): Text; + new(): Text; }; diff --git a/types/hummer-env/components/TextArea.d.ts b/types/hummer-env/components/TextArea.d.ts index d3d999858f897e..1cf34af13f76e7 100644 --- a/types/hummer-env/components/TextArea.d.ts +++ b/types/hummer-env/components/TextArea.d.ts @@ -18,5 +18,5 @@ declare const TextArea: { /** * 多行文本输入组件。 */ - new (): TextArea; + new(): TextArea; }; diff --git a/types/hummer-env/components/View.d.ts b/types/hummer-env/components/View.d.ts index 49294c31caff07..459cee106a74f9 100644 --- a/types/hummer-env/components/View.d.ts +++ b/types/hummer-env/components/View.d.ts @@ -6,5 +6,5 @@ declare const View: { /** * 容器视图,类似于web端的div标签,内部可以放入其他子视图。 */ - new (id?: string): View; + new(id?: string): View; }; diff --git a/types/hummer-env/components/ViewPager.d.ts b/types/hummer-env/components/ViewPager.d.ts index 7a0cfde4a85c5f..cae7d16edf0e4b 100644 --- a/types/hummer-env/components/ViewPager.d.ts +++ b/types/hummer-env/components/ViewPager.d.ts @@ -34,5 +34,5 @@ declare const ViewPager: { /** * 可自动轮播滚动的翻页组件。 */ - new (): ViewPager; + new(): ViewPager; }; diff --git a/types/hummer-env/hummer-env-tests.ts b/types/hummer-env/hummer-env-tests.ts index 30b95f85005cb0..f042b71760f3df 100644 --- a/types/hummer-env/hummer-env-tests.ts +++ b/types/hummer-env/hummer-env-tests.ts @@ -15,7 +15,7 @@ Hummer.pageInfo.closeSelf; // $ExpectType boolean Hummer.pageInfo.sourcePath; // $ExpectType string Hummer.pageInfo.url; // $ExpectType string -const msg = 'message to print'; +const msg = "message to print"; console.log(msg); // $ExpectType void console.debug(msg); // $ExpectType void console.info(msg); // $ExpectType void @@ -27,59 +27,59 @@ clearTimeout(timer1); // $ExpectType void const timer2 = setInterval(() => {}, 1000); // $ExpectType number clearInterval(timer2); // $ExpectType void -const positionAnimation = new BasicAnimation('position'); +const positionAnimation = new BasicAnimation("position"); positionAnimation.value = { x: 100, - y: '100hm', + y: "100hm", }; positionAnimation.duration = 1000; -positionAnimation.on('start', () => { - console.log('the animation is on'); +positionAnimation.on("start", () => { + console.log("the animation is on"); }); -positionAnimation.on('end', () => { - console.log('the animation is off'); +positionAnimation.on("end", () => { + console.log("the animation is off"); }); const dialog = new Dialog(); dialog.cancelable = false; dialog.lowLayer = true; -dialog.alert('this is a alert dialog', 'OK Button Text', () => { - console.log('You clicked the OK button'); +dialog.alert("this is a alert dialog", "OK Button Text", () => { + console.log("You clicked the OK button"); }); dialog.confirm( - 'Dialog Title', - 'confirm content', - 'Ok Button text', - 'Cancel button text', + "Dialog Title", + "confirm content", + "Ok Button text", + "Cancel button text", () => { - console.log('you clicked OK button'); + console.log("you clicked OK button"); }, () => { - console.log('you clicked cancel button'); + console.log("you clicked cancel button"); }, ); -dialog.loading('this is a loding msg'); +dialog.loading("this is a loding msg"); dialog.dismiss(); dialog.custom(new View()); const request = new Request(); -request.url = 'https://github.com'; -request.method = 'GET'; +request.url = "https://github.com"; +request.method = "GET"; request.timeout = 10000; request.header = { - customHeader: 'i am a header', + customHeader: "i am a header", }; request.param = { - param1: 'a', - param2: 'b', + param1: "a", + param2: "b", }; request.send(response => { console.log(response.data); }); -const ws = new WebSocket('https://websoket.net'); +const ws = new WebSocket("https://websoket.net"); ws.onopen(() => { - console.log('the websokect has connected'); + console.log("the websokect has connected"); }); ws.onmessage(ev => { console.log(ev.data); @@ -89,14 +89,14 @@ ws.onclose(ev => { console.log(ev.reason); }); ws.onerror(() => { - console.log('websocket connection error'); + console.log("websocket connection error"); }); -Storage.set('key1', 'value1'); -Storage.get('key1'); // $ExpectType string -Storage.remove('key1'); +Storage.set("key1", "value1"); +Storage.get("key1"); // $ExpectType string +Storage.remove("key1"); Storage.removeAll(); -Storage.exist('key1'); // $ExpectType boolean +Storage.exist("key1"); // $ExpectType boolean const location = new Location(); location.getLastLocation(locationInfo => { diff --git a/types/hummer-env/index.d.ts b/types/hummer-env/index.d.ts index ccca2551b58a6c..7b611149b58c8c 100644 --- a/types/hummer-env/index.d.ts +++ b/types/hummer-env/index.d.ts @@ -98,7 +98,6 @@ declare function setTimeout(cb: () => void, timeout: number): number; declare function clearTimeout(timer: number): void; declare const Navigator: { /** - * * @param pageInfo 页面信息 * @param pageInfo.url 跳转页面url * @param pageInfo.params 页面间传递的参数 @@ -107,29 +106,29 @@ declare const Navigator: { * @param pageInfo.closeSelf 打开页面时是否关闭自身 (默认是false) * @param cb 回调函数 */ - openPage(pageInfo: import('./interface/info').JumpPageInfo, cb?: (obj: unknown) => void): void; + openPage(pageInfo: import("./interface/info").JumpPageInfo, cb?: (obj: unknown) => void): void; /** * @summary 关闭当前页面 * @param pageInfo.animated 是否需要转场动画(默认是true) */ - popPage(pageInfo?: Partial<import('./interface/info').JumpPageInfo>): void; + popPage(pageInfo?: Partial<import("./interface/info").JumpPageInfo>): void; /** * 回退到指定页面 * @param pageInfo 页面信息 * @param pageInfo.id 指定页面的id, 通过openPage打开页面时设置的id */ - popToPage(pageInfo?: Partial<import('./interface/info').JumpPageInfo>): void; + popToPage(pageInfo?: Partial<import("./interface/info").JumpPageInfo>): void; /** * @summary 回退到首页 * @param pageInfo.animated 是否需要转场动画(默认是true) */ - popToRootPage(pageInfo?: Partial<import('./interface/info').JumpPageInfo>): void; + popToRootPage(pageInfo?: Partial<import("./interface/info").JumpPageInfo>): void; /** * @summary 回退指定数量的页面 * @param count 回退的页面数量 * @param pageInfo.animated 是否需要转场动画(默认是true) */ - popBack(count: number, pageInfo?: Partial<import('./interface/info').JumpPageInfo>): void; + popBack(count: number, pageInfo?: Partial<import("./interface/info").JumpPageInfo>): void; }; interface BasicAnimation<V = unknown> { @@ -152,14 +151,14 @@ interface BasicAnimation<V = unknown> { /** * @summary 动画运动速率曲线 */ - easing: import('./interface/info').animationEasing; + easing: import("./interface/info").animationEasing; /** * 动画执行开始或结束时的回调 * * @param event 事件类型('start' 或 'end') * @param callback 事件回调 */ - on(event: 'start' | 'end', cb: () => void): void; + on(event: "start" | "end", cb: () => void): void; } declare const BasicAnimation: { @@ -178,8 +177,8 @@ declare const BasicAnimation: { * @param animationType = width - 宽度动画 * @param animationType = height - 高度动画 */ - new <T extends keyof import('./interface/info').animationTypeMap>(animationType: T): BasicAnimation< - import('./interface/info').animationTypeMap[T] + new<T extends keyof import("./interface/info").animationTypeMap>(animationType: T): BasicAnimation< + import("./interface/info").animationTypeMap[T] >; }; @@ -190,7 +189,7 @@ interface KeyframeAnimation<V = unknown> { keyframes: Array<{ percent: number; value: V; - easing?: import('./interface/info').animationEasing; + easing?: import("./interface/info").animationEasing; }>; /** * @summary 动画持续时间(单位:秒) @@ -207,14 +206,14 @@ interface KeyframeAnimation<V = unknown> { /** * @summary 动画运动速率曲线 */ - easing: import('./interface/info').animationEasing; + easing: import("./interface/info").animationEasing; /** * 动画执行开始或结束时的回调 * * @param event 事件类型('start' 或 'end') * @param callback 事件回调 */ - on(event: 'start' | 'end', cb: () => void): void; + on(event: "start" | "end", cb: () => void): void; } declare const KeyframeAnimation: { @@ -233,8 +232,8 @@ declare const KeyframeAnimation: { * @param animationType = width - 宽度动画 * @param animationType = height - 高度动画 */ - new <T extends keyof import('./interface/info').animationTypeMap>(animationType: T): KeyframeAnimation< - import('./interface/info').animationTypeMap[T] + new<T extends keyof import("./interface/info").animationTypeMap>(animationType: T): KeyframeAnimation< + import("./interface/info").animationTypeMap[T] >; }; @@ -306,7 +305,7 @@ interface Dialog { } declare const Dialog: { prototype: Dialog; - new (): Dialog; + new(): Dialog; }; interface Request { @@ -338,12 +337,12 @@ interface Request { * 发起网络请求 * @param cb 请求返回触发的回调 */ - send(cb: (response: import('./interface/info').RequestResponse) => void): void; + send(cb: (response: import("./interface/info").RequestResponse) => void): void; } declare const Request: { prototype: Request; - new (): Request; + new(): Request; }; interface WebSocket { @@ -356,12 +355,12 @@ interface WebSocket { * @summary 接收消息的回调 * @param cb 回调函数 , 回调参数 event : {data: 消息文本(string)} */ - onmessage(cb: (ev: import('./interface/info').WebSocketMessageEvent) => void): void; + onmessage(cb: (ev: import("./interface/info").WebSocketMessageEvent) => void): void; /** * @summary 链接关闭时的回调 * @param cb 回调函数, 回调参数 event: {code:错误码(number), reason: 错误原因(string)} */ - onclose(cb: (ev: import('./interface/info').WebSocketCloseEvent) => void): void; + onclose(cb: (ev: import("./interface/info").WebSocketCloseEvent) => void): void; /** * @summary 链接出错时的回调 * @param cb 回调函数 @@ -375,7 +374,7 @@ interface WebSocket { */ declare const WebSocket: { prototype: WebSocket; - new (url: string): WebSocket; + new(url: string): WebSocket; }; declare const Storage: { @@ -449,7 +448,7 @@ interface Location { * 获取上一次缓存的位置信息 * @param cb 位置信息回调, (locationInfo : LocationInfo) => void */ - getLastLocation(cb: (locationInfo: import('./interface/info').LocationInfo) => void): void; + getLastLocation(cb: (locationInfo: import("./interface/info").LocationInfo) => void): void; /** * 开启位置定位 * @param cb 位置信息回调, (locationInfo : LocationInfo) => void @@ -457,7 +456,7 @@ interface Location { * @param intervalDistance 位置变化的距离改变范围(单位:米),默认0米 */ startLocation( - cb: (locationInfo: import('./interface/info').LocationInfo) => void, + cb: (locationInfo: import("./interface/info").LocationInfo) => void, intervalTime?: number, intervalDistance?: number, ): void; @@ -474,5 +473,5 @@ interface Location { declare const Location: { prototype: Location; - new (): Location; + new(): Location; }; diff --git a/types/hummer-env/interface/event.ts b/types/hummer-env/interface/event.ts index 531c057386786d..5250a158120ebf 100644 --- a/types/hummer-env/interface/event.ts +++ b/types/hummer-env/interface/event.ts @@ -10,42 +10,42 @@ interface CommonEvent { }; } export interface TouchEvent extends CommonEvent { - type: 'touch'; + type: "touch"; } export interface TapEvent extends CommonEvent { - type: 'tap'; + type: "tap"; } export interface LongPressEvent extends CommonEvent { - type: 'longPress'; + type: "longPress"; } -export interface PanEvent extends Omit<CommonEvent, 'position'> { - type: 'pan'; +export interface PanEvent extends Omit<CommonEvent, "position"> { + type: "pan"; translation: { deltaX: number; deltaY: number; }; } -export interface SwipeEvent extends Omit<CommonEvent, 'position'> { - type: 'swiper'; +export interface SwipeEvent extends Omit<CommonEvent, "position"> { + type: "swiper"; /** * @summary 1:right, 2:left, 4:up, 8:down */ direction: number; } -export interface PinchEvent extends Omit<CommonEvent, 'position'> { - type: 'pinch'; +export interface PinchEvent extends Omit<CommonEvent, "position"> { + type: "pinch"; scale: number; } -export interface InputEvent extends Omit<CommonEvent, 'position'> { - type: 'input'; +export interface InputEvent extends Omit<CommonEvent, "position"> { + type: "input"; text: string; } -export interface ScrollEvent extends Omit<CommonEvent, 'position'> { - type: 'scroll'; +export interface ScrollEvent extends Omit<CommonEvent, "position"> { + type: "scroll"; /** * @summary x方向实际滚动偏移量 */ @@ -64,17 +64,17 @@ export interface ScrollEvent extends Omit<CommonEvent, 'position'> { dy: number; } -export interface SwitchEvent extends Omit<CommonEvent, 'position' | 'state'> { - type: 'switch'; +export interface SwitchEvent extends Omit<CommonEvent, "position" | "state"> { + type: "switch"; state: 0 | 1; } // TODO 为各事件设置专属的事件池 -export type EventInView = 'touch' | 'tap' | 'longPress' | 'pan' | 'swipe' | 'pinch'; -export type EventInText = 'touch' | 'tap' | 'longPress' | 'pan' | 'pinch'; -export type EventInImage = 'touch' | 'tap' | 'longPress' | 'pan' | 'pinch'; -export type EventInScroller = 'scroll'; -export type EventInInput = 'input'; +export type EventInView = "touch" | "tap" | "longPress" | "pan" | "swipe" | "pinch"; +export type EventInText = "touch" | "tap" | "longPress" | "pan" | "pinch"; +export type EventInImage = "touch" | "tap" | "longPress" | "pan" | "pinch"; +export type EventInScroller = "scroll"; +export type EventInInput = "input"; export interface EventHandlersEventMap { touch: TouchEvent; diff --git a/types/hummer-env/interface/info.ts b/types/hummer-env/interface/info.ts index 5efb467b53ab91..f5127b18af7750 100644 --- a/types/hummer-env/interface/info.ts +++ b/types/hummer-env/interface/info.ts @@ -1,4 +1,4 @@ -export type fingerEvent = 'touch' | 'tab' | 'longPress' | 'pan' | 'swiper' | 'pinch' | 'input' | 'scroll' | 'switch'; +export type fingerEvent = "touch" | "tab" | "longPress" | "pan" | "swiper" | "pinch" | "input" | "scroll" | "switch"; export interface viewRect { /** @@ -178,19 +178,19 @@ export interface RequestResponse { } export type animationType = - | 'position' - | 'scale' - | 'scaleX' - | 'scaleY' - | 'rotationX' - | 'rotationY' - | 'rotationZ' - | 'opacity' - | 'backgroundColor' - | 'width' - | 'height'; + | "position" + | "scale" + | "scaleX" + | "scaleY" + | "rotationX" + | "rotationY" + | "rotationZ" + | "opacity" + | "backgroundColor" + | "width" + | "height"; -export type animationEasing = 'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out'; +export type animationEasing = "linear" | "ease" | "ease-in" | "ease-out" | "ease-in-out"; export interface animationTypeMap { position: { diff --git a/types/hummer-env/interface/style.d.ts b/types/hummer-env/interface/style.d.ts index 7dc1aae9960d80..eb97eac3fe8301 100644 --- a/types/hummer-env/interface/style.d.ts +++ b/types/hummer-env/interface/style.d.ts @@ -2,27 +2,27 @@ interface HummerCommonStyle { /** * @summary position: 'relative' | 'absolute' | 'fixed' */ - position?: 'relative' | 'absolute' | 'fixed'; + position?: "relative" | "absolute" | "fixed"; /** * @summary flexDirection:'column' | 'row' */ - flexDirection?: 'column' | 'row'; + flexDirection?: "column" | "row"; /** * @summary flexWrap: 'nowrap' | 'wrap' | 'wrap-reverse' */ - flexWrap?: 'nowrap' | 'wrap' | 'wrap-reverse'; + flexWrap?: "nowrap" | "wrap" | "wrap-reverse"; /** * @summary justifyContent: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'space-evenly' */ - justifyContent?: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'space-evenly'; + justifyContent?: "flex-start" | "flex-end" | "center" | "space-between" | "space-around" | "space-evenly"; /** * @summary alignItems: 'flex-start' | 'flex-end' | 'center' | 'baseline' | 'stretch' */ - alignItems?: 'flex-start' | 'flex-end' | 'center' | 'baseline' | 'stretch'; + alignItems?: "flex-start" | "flex-end" | "center" | "baseline" | "stretch"; /** * @summary alignContent: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'stretch'; */ - alignContent?: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'stretch'; + alignContent?: "flex-start" | "flex-end" | "center" | "space-between" | "space-around" | "stretch"; /** * @summary flexGrow: 1 */ @@ -38,7 +38,7 @@ interface HummerCommonStyle { /** * @summary alignSelf: 'flex-start' | 'flex-end' | 'center' | 'baseline' | 'stretch'; */ - alignSelf?: 'flex-start' | 'flex-end' | 'center' | 'baseline' | 'stretch'; + alignSelf?: "flex-start" | "flex-end" | "center" | "baseline" | "stretch"; /** * @summary width: 10 | '10px' */ @@ -158,27 +158,27 @@ interface HummerCommonStyle { /** * @summary boxSizing: 'none' | 'border-box' */ - boxSizing?: 'none' | 'border-box'; + boxSizing?: "none" | "border-box"; /** * @summary borderStyle: 'none' | 'solid' | 'dashed' | 'dotted' */ - borderStyle?: 'none' | 'solid' | 'dashed' | 'dotted'; + borderStyle?: "none" | "solid" | "dashed" | "dotted"; /** * @summary borderLeftStyle: 'none' | 'solid' | 'dashed' | 'dotted' */ - borderLeftStyle?: 'none' | 'solid' | 'dashed' | 'dotted'; + borderLeftStyle?: "none" | "solid" | "dashed" | "dotted"; /** * @summary borderTopStyle: 'none' | 'solid' | 'dashed' | 'dotted'; */ - borderTopStyle?: 'none' | 'solid' | 'dashed' | 'dotted'; + borderTopStyle?: "none" | "solid" | "dashed" | "dotted"; /** * @summary borderRightStyle: 'none' | 'solid' | 'dashed' | 'dotted' */ - borderRightStyle?: 'none' | 'solid' | 'dashed' | 'dotted'; + borderRightStyle?: "none" | "solid" | "dashed" | "dotted"; /** * @summary borderBottomStyle: 'none' | 'solid' | 'dashed' | 'dotted' */ - borderBottomStyle?: 'none' | 'solid' | 'dashed' | 'dotted'; + borderBottomStyle?: "none" | "solid" | "dashed" | "dotted"; /** * @summary borderColor: '#000000' */ @@ -250,7 +250,7 @@ interface HummerCommonStyle { /** * @summary visibility: 'hidden' | 'visible' */ - visibility?: 'hidden' | 'visible'; + visibility?: "hidden" | "visible"; /** * @summary zIndex: 1 */ @@ -262,7 +262,7 @@ interface HummerCommonStyle { } interface ViewStyle extends HummerCommonStyle { - overflow?: 'visible' | 'hidden'; + overflow?: "visible" | "hidden"; } interface TextStyle extends HummerCommonStyle { @@ -282,23 +282,23 @@ interface TextStyle extends HummerCommonStyle { /** * @summary fontStyle: 'normal' | 'italic' */ - fontStyle?: 'normal' | 'italic'; + fontStyle?: "normal" | "italic"; /** * @summary textAlign: 'left' | 'center' | 'right' */ - textAlign?: 'left' | 'center' | 'right'; + textAlign?: "left" | "center" | "right"; /** * @summary textVerticalAlign: 'top' | 'center' | 'bottom' */ - textVerticalAlign?: 'top' | 'center' | 'bottom'; + textVerticalAlign?: "top" | "center" | "bottom"; /** * @summary textDecoration: 'none' | 'underline' | 'line-through' */ - textDecoration?: 'none' | 'underline' | 'line-through'; + textDecoration?: "none" | "underline" | "line-through"; /** * @summary textOverflow: 'clip' | 'ellipsis' */ - textOverflow?: 'clip' | 'ellipsis'; + textOverflow?: "clip" | "ellipsis"; /** * @summary textLineClamp: 1 */ @@ -329,14 +329,14 @@ interface ButtonStyle extends HummerCommonStyle { /** * @summary textAlign: 'left' | 'center' | 'right' */ - textAlign?: 'left' | 'center' | 'right'; + textAlign?: "left" | "center" | "right"; } interface InputStyle extends HummerCommonStyle { /** * @summary type: 'default' | 'number' | 'tel' | 'email' | 'password' */ - type?: 'default' | 'number' | 'tel' | 'email' | 'password'; + type?: "default" | "number" | "tel" | "email" | "password"; /** * @summary color: '#000000' */ @@ -352,7 +352,7 @@ interface InputStyle extends HummerCommonStyle { /** * @summary textAlign: 'left' | 'center' | 'right' */ - textAlign?: 'left' | 'center' | 'right'; + textAlign?: "left" | "center" | "right"; /** * @summary fontFamily: "New Times Roma" */ @@ -368,11 +368,11 @@ interface InputStyle extends HummerCommonStyle { /** * @summary returnKeyType: 'done' | 'go' | 'next' | 'search' | 'send' */ - returnKeyType?: 'done' | 'go' | 'next' | 'search' | 'send'; + returnKeyType?: "done" | "go" | "next" | "search" | "send"; } interface ImageStyle extends HummerCommonStyle { - resize?: 'origin' | 'contain' | 'cover' | 'stretch'; + resize?: "origin" | "contain" | "cover" | "stretch"; } interface TextAreaStyle extends InputStyle { @@ -389,11 +389,11 @@ interface ListStyle extends HummerCommonStyle { /** * @summary mode: 'list' | 'grid' | 'waterfall' */ - mode?: 'list' | 'grid' | 'waterfall'; + mode?: "list" | "grid" | "waterfall"; /** * @summary scrollDirection: 'vertical' | 'horizontal' */ - scrollDirection?: 'vertical' | 'horizontal'; + scrollDirection?: "vertical" | "horizontal"; /** * @summary column: 3 */ diff --git a/types/hummus-recipe/hummus-recipe-tests.ts b/types/hummus-recipe/hummus-recipe-tests.ts index db6dad7504f8cc..18ac1a9e8b127b 100644 --- a/types/hummus-recipe/hummus-recipe-tests.ts +++ b/types/hummus-recipe/hummus-recipe-tests.ts @@ -1,42 +1,42 @@ -import Recipe = require('hummus-recipe'); +import Recipe = require("hummus-recipe"); -import fs = require('fs'); +import fs = require("fs"); // $ExpectType Recipe -const newDoc = new Recipe('new', 'test.pdf', { +const newDoc = new Recipe("new", "test.pdf", { version: 1.6, - author: 'John Doe', - title: 'Hummus Recipe', - subject: 'A brand new PDF', - colorspace: 'rgb', - keywords: ['hummus', 'recipe'], - password: 'password', - userPassword: 'userPassword', - ownerPassword: 'ownerPassword', - userProtectionFlag: 'print', - fontSrcPath: 'path/to/fonts', + author: "John Doe", + title: "Hummus Recipe", + subject: "A brand new PDF", + colorspace: "rgb", + keywords: ["hummus", "recipe"], + password: "password", + userPassword: "userPassword", + ownerPassword: "ownerPassword", + userProtectionFlag: "print", + fontSrcPath: "path/to/fonts", }); // $ExpectType Recipe newDoc .createPage(595, 842) - .text('Memento Mori', 100, 100) + .text("Memento Mori", 100, 100) .endPage() .endPDF(); // @ts-expect-error -newDoc.createPage('A5') - .text('Memento Mori', 100, 100) +newDoc.createPage("A5") + .text("Memento Mori", 100, 100) .endPage() .endPDF(); -const inBuffer: Buffer = fs.readFileSync('test.pdf'); +const inBuffer: Buffer = fs.readFileSync("test.pdf"); const bufferDoc = new Recipe(inBuffer); bufferDoc .createPage(595, 842) - .text('Memento Mori', 100, 100) + .text("Memento Mori", 100, 100) .endPage() .endPDF( (outBuffer: Buffer) => diff --git a/types/hummus-recipe/index.d.ts b/types/hummus-recipe/index.d.ts index 3808c04b1c8393..2eb820bc7f3f7f 100644 --- a/types/hummus-recipe/index.d.ts +++ b/types/hummus-recipe/index.d.ts @@ -9,53 +9,53 @@ declare namespace Recipe { type CommentOptionsFlag = - | 'invisible' - | 'hidden' - | 'print' - | 'nozoom' - | 'norotate' - | 'noview' - | 'readonly' - | 'locked' - | 'togglenoview'; + | "invisible" + | "hidden" + | "print" + | "nozoom" + | "norotate" + | "noview" + | "readonly" + | "locked" + | "togglenoview"; type AnnotSubtype = - | 'Text' - | 'FreeText' - | 'Line' - | 'Square' - | 'Circle' - | 'Polygon' - | 'PolyLine' - | 'Highlight' - | 'Underline' - | 'Squiggly' - | 'StrikeOut' - | 'Stamp' - | 'Caret' - | 'Ink' - | 'FileAttachment' - | 'Sound'; + | "Text" + | "FreeText" + | "Line" + | "Square" + | "Circle" + | "Polygon" + | "PolyLine" + | "Highlight" + | "Underline" + | "Squiggly" + | "StrikeOut" + | "Stamp" + | "Caret" + | "Ink" + | "FileAttachment" + | "Sound"; type AnnotOptionsFlag = - | 'invisible' - | 'hidden' - | 'print' - | 'nozoom' - | 'norotate' - | 'noview' - | 'readonly' - | 'locked' - | 'togglenoview'; - - type AnnotOptionsIcon = 'Comment' | 'Key' | 'Note' | 'Help' | 'NewParagraph' | 'Paragraph' | 'Insert'; + | "invisible" + | "hidden" + | "print" + | "nozoom" + | "norotate" + | "noview" + | "readonly" + | "locked" + | "togglenoview"; + + type AnnotOptionsIcon = "Comment" | "Key" | "Note" | "Help" | "NewParagraph" | "Paragraph" | "Insert"; interface RecipeOptions { version?: number | undefined; author?: string | undefined; title?: string | undefined; subject?: string | undefined; - colorspace?: 'rgb' | 'cmyk' | 'grey' | undefined; + colorspace?: "rgb" | "cmyk" | "grey" | undefined; keywords?: string[] | undefined; password?: string | undefined; userPassword?: string | undefined; diff --git a/types/humps/index.d.ts b/types/humps/index.d.ts index 2d26440c32db8f..225378a0030ae2 100644 --- a/types/humps/index.d.ts +++ b/types/humps/index.d.ts @@ -10,14 +10,10 @@ export type SnakeToCamelCase<S extends string> = S extends `${infer P1}_${infer ? `${P1}${Uppercase<P2>}${SnakeToCamelCase<P3>}` : S; -export type CamelizedProperty<T> = T extends any - ? T extends Array<infer U> - ? U extends {} - ? Array<Camelized<U>> - : T - : T extends {} - ? Camelized<T> +export type CamelizedProperty<T> = T extends any ? T extends Array<infer U> ? U extends {} ? Array<Camelized<U>> : T + : T extends {} ? Camelized<T> + : T : never; export type Camelized<T> = { @@ -28,14 +24,10 @@ export type SnakeToPascalCase<S extends string> = S extends `${infer P1}_${infer ? `${Capitalize<P1>}${Uppercase<P2>}${SnakeToPascalCase<P3>}` : S; -export type PascalizedProperty<T> = T extends any - ? T extends Array<infer U> - ? U extends {} - ? Array<Pascalized<U>> - : T - : T extends {} - ? Pascalized<T> +export type PascalizedProperty<T> = T extends any ? T extends Array<infer U> ? U extends {} ? Array<Pascalized<U>> : T + : T extends {} ? Pascalized<T> + : T : never; export type Pascalized<T> = { @@ -43,17 +35,13 @@ export type Pascalized<T> = { }; export type CamelToSnakeCase<S extends string> = S extends `${infer T}${infer U}` - ? `${T extends Capitalize<T> ? '_' : ''}${Lowercase<T>}${CamelToSnakeCase<U>}` + ? `${T extends Capitalize<T> ? "_" : ""}${Lowercase<T>}${CamelToSnakeCase<U>}` : S; -export type DecamelizedProperty<T> = T extends any - ? T extends Array<infer U> - ? U extends {} - ? Array<Decamelized<U>> - : T - : T extends {} - ? Decamelized<T> +export type DecamelizedProperty<T> = T extends any ? T extends Array<infer U> ? U extends {} ? Array<Decamelized<U>> : T + : T extends {} ? Decamelized<T> + : T : never; export type Decamelized<T> = { @@ -61,17 +49,13 @@ export type Decamelized<T> = { }; export type PascalToSnakeCase<S extends string> = S extends `${infer T1}${infer T2}${infer U}` - ? `${T2 extends Capitalize<T2> ? '_' : ''}${Lowercase<T1>}${Lowercase<T2>}${CamelToSnakeCase<U>}` + ? `${T2 extends Capitalize<T2> ? "_" : ""}${Lowercase<T1>}${Lowercase<T2>}${CamelToSnakeCase<U>}` : S; -export type DepascalizedProperty<T> = T extends any - ? T extends Array<infer U> - ? U extends {} - ? Array<Decamelized<U>> - : T - : T extends {} - ? Decamelized<T> +export type DepascalizedProperty<T> = T extends any ? T extends Array<infer U> ? U extends {} ? Array<Decamelized<U>> : T + : T extends {} ? Decamelized<T> + : T : never; export type Depascalized<T> = { diff --git a/types/humps/test/humps-tests.cjs.ts b/types/humps/test/humps-tests.cjs.ts index e086ef4e13821a..b413787f37de5e 100644 --- a/types/humps/test/humps-tests.cjs.ts +++ b/types/humps/test/humps-tests.cjs.ts @@ -1,30 +1,30 @@ -import humps = require('humps'); +import humps = require("humps"); -const someSnakeObject = { attr_one: 'foo', attr_two: 'bar' }; -const someCamelObject = { attrOne: 'foo', attrTwo: 'bar' }; -const somePascalObject = { AttrOne: 'foo', AttrTwo: 'bar' }; +const someSnakeObject = { attr_one: "foo", attr_two: "bar" }; +const someCamelObject = { attrOne: "foo", attrTwo: "bar" }; +const somePascalObject = { AttrOne: "foo", AttrTwo: "bar" }; -const someSnakeArray = [{ attr_one: 'foo' }, { attr_two: 'bar' }]; -const someCamelArray = [{ attrOne: 'foo' }, { attrTwo: 'bar' }]; -const somePascalArray = [{ AttrOne: 'foo' }, { AttrTwo: 'bar' }]; +const someSnakeArray = [{ attr_one: "foo" }, { attr_two: "bar" }]; +const someCamelArray = [{ attrOne: "foo" }, { attrTwo: "bar" }]; +const somePascalArray = [{ AttrOne: "foo" }, { AttrTwo: "bar" }]; const someOptions: humps.HumpsOptions = { - separator: '-', + separator: "-", }; const someOptions2: humps.HumpsOptions = { split: /^[A-Z0-9_]+$/, }; const someOptions3: humps.HumpsOptions = { - separator: '-', + separator: "-", process(key: string, convert: humps.HumpsProcessorParameter, options?: humps.HumpsOptions) { return /^[A-Z0-9_]+$/.test(key) ? key : convert(key, options); }, }; -humps.camelize('hello_world'); +humps.camelize("hello_world"); -humps.decamelize('fooBar'); -humps.decamelize('fooBarBaz', someOptions); +humps.decamelize("fooBar"); +humps.decamelize("fooBarBaz", someOptions); humps.camelizeKeys(someSnakeObject); @@ -40,15 +40,15 @@ humps.decamelizeKeys(someCamelObject, (key, convert, options) => { return /^[A-Z0-9_]+$/.test(key) ? key : convert(key, options); }); -humps.camelize('hello_world-foo bar'); +humps.camelize("hello_world-foo bar"); -humps.pascalize('hello_world-foo bar'); +humps.pascalize("hello_world-foo bar"); -humps.decamelize('helloWorldFooBar'); -humps.decamelize('helloWorldFooBar', someOptions); -humps.decamelize('helloWorld1', { split: /(?=[A-Z0-9])/ }); +humps.decamelize("helloWorldFooBar"); +humps.decamelize("helloWorldFooBar", someOptions); +humps.decamelize("helloWorld1", { split: /(?=[A-Z0-9])/ }); -humps.depascalize('helloWorldFooBar'); +humps.depascalize("helloWorldFooBar"); humps.camelizeKeys(someSnakeObject); humps.pascalizeKeys(someSnakeObject); @@ -70,17 +70,17 @@ humps.pascalizeKeys(someSnakeObject, someOptions3); humps.decamelizeKeys(someCamelObject, someOptions3); humps.depascalizeKeys(somePascalObject, someOptions3); -humps.camelizeKeys<{ attr_one: string, attr_two: string }>(someSnakeObject); // $ExpectType Camelized<{ attr_one: string; attr_two: string; }> -humps.pascalizeKeys<{ attr_one: string, attr_two: string }>(someSnakeObject); // $ExpectType Pascalized<{ attr_one: string; attr_two: string; }> -humps.decamelizeKeys<{ attrOne: string, attrTwo: string }>(someCamelObject); // $ExpectType Decamelized<{ attrOne: string; attrTwo: string; }> -humps.depascalizeKeys<{ AttrOne: string, AttrTwo: string }>(somePascalObject); // $ExpectType Depascalized<{ AttrOne: string; AttrTwo: string; }> +humps.camelizeKeys<{ attr_one: string; attr_two: string }>(someSnakeObject); // $ExpectType Camelized<{ attr_one: string; attr_two: string; }> +humps.pascalizeKeys<{ attr_one: string; attr_two: string }>(someSnakeObject); // $ExpectType Pascalized<{ attr_one: string; attr_two: string; }> +humps.decamelizeKeys<{ attrOne: string; attrTwo: string }>(someCamelObject); // $ExpectType Decamelized<{ attrOne: string; attrTwo: string; }> +humps.depascalizeKeys<{ AttrOne: string; AttrTwo: string }>(somePascalObject); // $ExpectType Depascalized<{ AttrOne: string; AttrTwo: string; }> [...humps.camelizeKeys(someSnakeArray)]; [...humps.pascalizeKeys(someSnakeArray)]; [...humps.decamelizeKeys(someCamelArray)]; [...humps.depascalizeKeys(somePascalArray)]; -const snakeObjectWithUnion = { a_o: 'foo', a_tw: [{ a_th: 'bar' }] }; +const snakeObjectWithUnion = { a_o: "foo", a_tw: [{ a_th: "bar" }] }; humps.camelizeKeys<{ a_o: string; a_tw: Array<{ a_th: string }> | null }>(snakeObjectWithUnion); // $ExpectType Camelized<{ a_o: string; a_tw: { a_th: string; }[] | null; }> humps.pascalizeKeys<{ a_o: string; a_tw: Array<{ a_th: string }> | null }>(snakeObjectWithUnion); // $ExpectType Pascalized<{ a_o: string; a_tw: { a_th: string; }[] | null; }> diff --git a/types/humps/test/humps-tests.global.ts b/types/humps/test/humps-tests.global.ts index 10d0fb409ed9f8..d40a33acd0e879 100644 --- a/types/humps/test/humps-tests.global.ts +++ b/types/humps/test/humps-tests.global.ts @@ -1,28 +1,28 @@ -const someSnakeObject = { attr_one: 'foo', attr_two: 'bar' }; -const someCamelObject = { attrOne: 'foo', attrTwo: 'bar' }; -const somePascalObject = { AttrOne: 'foo', AttrTwo: 'bar' }; +const someSnakeObject = { attr_one: "foo", attr_two: "bar" }; +const someCamelObject = { attrOne: "foo", attrTwo: "bar" }; +const somePascalObject = { AttrOne: "foo", AttrTwo: "bar" }; -const someSnakeArray = [{ attr_one: 'foo' }, { attr_two: 'bar' }]; -const someCamelArray = [{ attrOne: 'foo' }, { attrTwo: 'bar' }]; -const somePascalArray = [{ AttrOne: 'foo' }, { AttrTwo: 'bar' }]; +const someSnakeArray = [{ attr_one: "foo" }, { attr_two: "bar" }]; +const someCamelArray = [{ attrOne: "foo" }, { attrTwo: "bar" }]; +const somePascalArray = [{ AttrOne: "foo" }, { AttrTwo: "bar" }]; const someOptions: humps.HumpsOptions = { - separator: '-', + separator: "-", }; const someOptions2: humps.HumpsOptions = { split: /^[A-Z0-9_]+$/, }; const someOptions3: humps.HumpsOptions = { - separator: '-', + separator: "-", process(key: string, convert: humps.HumpsProcessorParameter, options?: humps.HumpsOptions) { return /^[A-Z0-9_]+$/.test(key) ? key : convert(key, options); }, }; -humps.camelize('hello_world'); +humps.camelize("hello_world"); -humps.decamelize('fooBar'); -humps.decamelize('fooBarBaz', someOptions); +humps.decamelize("fooBar"); +humps.decamelize("fooBarBaz", someOptions); humps.camelizeKeys(someSnakeObject); @@ -38,15 +38,15 @@ humps.decamelizeKeys(someCamelObject, (key, convert, options) => { return /^[A-Z0-9_]+$/.test(key) ? key : convert(key, options); }); -humps.camelize('hello_world-foo bar'); +humps.camelize("hello_world-foo bar"); -humps.pascalize('hello_world-foo bar'); +humps.pascalize("hello_world-foo bar"); -humps.decamelize('helloWorldFooBar'); -humps.decamelize('helloWorldFooBar', someOptions); -humps.decamelize('helloWorld1', { split: /(?=[A-Z0-9])/ }); +humps.decamelize("helloWorldFooBar"); +humps.decamelize("helloWorldFooBar", someOptions); +humps.decamelize("helloWorld1", { split: /(?=[A-Z0-9])/ }); -humps.depascalize('helloWorldFooBar'); +humps.depascalize("helloWorldFooBar"); humps.camelizeKeys(someSnakeObject); humps.pascalizeKeys(someSnakeObject); @@ -68,10 +68,10 @@ humps.pascalizeKeys(someSnakeObject, someOptions3); humps.decamelizeKeys(someCamelObject, someOptions3); humps.depascalizeKeys(somePascalObject, someOptions3); -humps.camelizeKeys<{ attr_one: string, attr_two: string }>(someSnakeObject); // $ExpectType Camelized<{ attr_one: string; attr_two: string; }> -humps.pascalizeKeys<{ attr_one: string, attr_two: string }>(someSnakeObject); // $ExpectType Pascalized<{ attr_one: string; attr_two: string; }> -humps.decamelizeKeys<{ attrOne: string, attrTwo: string }>(someCamelObject); // $ExpectType Decamelized<{ attrOne: string; attrTwo: string; }> -humps.depascalizeKeys<{ AttrOne: string, AttrTwo: string }>(somePascalObject); // $ExpectType Depascalized<{ AttrOne: string; AttrTwo: string; }> +humps.camelizeKeys<{ attr_one: string; attr_two: string }>(someSnakeObject); // $ExpectType Camelized<{ attr_one: string; attr_two: string; }> +humps.pascalizeKeys<{ attr_one: string; attr_two: string }>(someSnakeObject); // $ExpectType Pascalized<{ attr_one: string; attr_two: string; }> +humps.decamelizeKeys<{ attrOne: string; attrTwo: string }>(someCamelObject); // $ExpectType Decamelized<{ attrOne: string; attrTwo: string; }> +humps.depascalizeKeys<{ AttrOne: string; AttrTwo: string }>(somePascalObject); // $ExpectType Depascalized<{ AttrOne: string; AttrTwo: string; }> [...humps.camelizeKeys(someSnakeArray)]; [...humps.pascalizeKeys(someSnakeArray)]; diff --git a/types/hunspell-spellchecker/hunspell-spellchecker-tests.ts b/types/hunspell-spellchecker/hunspell-spellchecker-tests.ts index a9efe637e78c07..f81a2cb168d6fe 100644 --- a/types/hunspell-spellchecker/hunspell-spellchecker-tests.ts +++ b/types/hunspell-spellchecker/hunspell-spellchecker-tests.ts @@ -1,20 +1,20 @@ -import { readFileSync } from 'fs'; -import * as Spellchecker from 'hunspell-spellchecker'; +import { readFileSync } from "fs"; +import * as Spellchecker from "hunspell-spellchecker"; const spellchecker = new Spellchecker(); const DICT: Spellchecker.Dictionary = spellchecker.parse({ - aff: readFileSync('./en_EN.aff'), - dic: readFileSync('./en_EN.dic'), + aff: readFileSync("./en_EN.aff"), + dic: readFileSync("./en_EN.dic"), }); spellchecker.use(DICT); // $ExpectType boolean -const isRight = spellchecker.check('defienitely typed'); +const isRight = spellchecker.check("defienitely typed"); // $ExpectType string -spellchecker.suggest('oof', 10)[0]; +spellchecker.suggest("oof", 10)[0]; // $ExpectType boolean -spellchecker.hasFlag('dooor', 'F'); +spellchecker.hasFlag("dooor", "F"); diff --git a/types/hyco-ws/hyco-ws-tests.ts b/types/hyco-ws/hyco-ws-tests.ts index e08890b3b1f9b3..14fb32e05b4ef7 100644 --- a/types/hyco-ws/hyco-ws-tests.ts +++ b/types/hyco-ws/hyco-ws-tests.ts @@ -1,21 +1,23 @@ -import * as WebSocket from 'ws'; -import * as AzureRelay from 'hyco-ws'; +import * as AzureRelay from "hyco-ws"; +import * as WebSocket from "ws"; const wss = AzureRelay.createRelayedServer( { - server: AzureRelay.createRelayListenUri('uri_namespace', 'uri_path'), + server: AzureRelay.createRelayListenUri("uri_namespace", "uri_path"), token: AzureRelay.createRelayToken( - 'http://exampleurl.com}', - 'key_rule', - 'key') + "http://exampleurl.com}", + "key_rule", + "key", + ), }, (ws: WebSocket) => { - console.log('New connection accepted'); + console.log("New connection accepted"); ws.onmessage = (event: any) => { - console.log('New message!!'); + console.log("New message!!"); }; - }); + }, +); -wss.on('error', (err: any) => { - console.log('error' + err); +wss.on("error", (err: any) => { + console.log("error" + err); }); diff --git a/types/hyco-ws/index.d.ts b/types/hyco-ws/index.d.ts index 49dd2219d967fe..330efd42eac1a4 100644 --- a/types/hyco-ws/index.d.ts +++ b/types/hyco-ws/index.d.ts @@ -5,8 +5,8 @@ /// <reference types="node" /> -import * as WebSocket from 'ws'; -import { EventEmitter } from 'events'; +import { EventEmitter } from "events"; +import * as WebSocket from "ws"; export class HybridConnectionWebSocketServer extends EventEmitter { constructor(options: any); diff --git a/types/hydra-box/Api.d.ts b/types/hydra-box/Api.d.ts index ee1990b984d3a4..7d5b9dfa9fbb47 100644 --- a/types/hydra-box/Api.d.ts +++ b/types/hydra-box/Api.d.ts @@ -1,5 +1,5 @@ -import { Term, DatasetCore, NamedNode } from '@rdfjs/types'; -import { LoaderRegistry } from 'rdf-loaders-registry'; +import { DatasetCore, NamedNode, Term } from "@rdfjs/types"; +import { LoaderRegistry } from "rdf-loaders-registry"; declare namespace Api { interface ApiInit<D extends DatasetCore = DatasetCore> { @@ -22,7 +22,7 @@ declare namespace Api { } } -interface Api<D extends DatasetCore = DatasetCore> extends Api.Api<D> { } +interface Api<D extends DatasetCore = DatasetCore> extends Api.Api<D> {} // tslint:disable-next-line no-unnecessary-class declare class Api<D extends DatasetCore = DatasetCore> { diff --git a/types/hydra-box/StoreResourceLoader.d.ts b/types/hydra-box/StoreResourceLoader.d.ts index 356893fdcb3929..a667ee2c78a7d7 100644 --- a/types/hydra-box/StoreResourceLoader.d.ts +++ b/types/hydra-box/StoreResourceLoader.d.ts @@ -1,5 +1,5 @@ -import { Term, Store } from '@rdfjs/types'; -import { ResourceLoader, Resource } from '.'; +import { Store, Term } from "@rdfjs/types"; +import { Resource, ResourceLoader } from "."; // tslint:disable-next-line no-empty-interface interface StoreResourceLoader extends ResourceLoader { diff --git a/types/hydra-box/hydra-box-tests.ts b/types/hydra-box/hydra-box-tests.ts index 4ef85181d43802..b084025ea327b8 100644 --- a/types/hydra-box/hydra-box-tests.ts +++ b/types/hydra-box/hydra-box-tests.ts @@ -1,27 +1,27 @@ -import express = require('express'); -import hydraBox = require('hydra-box'); -import ApiImpl = require('hydra-box/Api'); -import { Api } from 'hydra-box/Api'; -import StoreResourceLoader = require('hydra-box/StoreResourceLoader'); -import { Dataset, DatasetCore, NamedNode, Store, Stream } from '@rdfjs/types'; -import { GraphPointer } from 'clownface'; -import DatasetExt from 'rdf-ext/lib/Dataset'; -import { Readable } from 'stream'; -import { Loader } from 'rdf-loaders-registry'; - -const codePath = ''; -const path = ''; +import express = require("express"); +import hydraBox = require("hydra-box"); +import ApiImpl = require("hydra-box/Api"); +import { Api } from "hydra-box/Api"; +import StoreResourceLoader = require("hydra-box/StoreResourceLoader"); +import { Dataset, DatasetCore, NamedNode, Store, Stream } from "@rdfjs/types"; +import { GraphPointer } from "clownface"; +import DatasetExt from "rdf-ext/lib/Dataset"; +import { Loader } from "rdf-loaders-registry"; +import { Readable } from "stream"; + +const codePath = ""; +const path = ""; const dataset: Dataset = <any> {}; const graph: NamedNode = <any> {}; const term: NamedNode = <any> {}; function createApi(): Api<Dataset> { // no options - let api: Api = ApiImpl.fromFile('foo').fromFile('bar'); - api = new ApiImpl().fromFile('foo'); + let api: Api = ApiImpl.fromFile("foo").fromFile("bar"); + api = new ApiImpl().fromFile("foo"); // with options - let withOptions: Api<Dataset> = ApiImpl.fromFile('foo', { + let withOptions: Api<Dataset> = ApiImpl.fromFile("foo", { codePath, dataset, graph, @@ -54,27 +54,33 @@ function appCustomConfig() { const store: Store = <any> {}; const handler: express.RequestHandler = <any> {}; - app.use('empty-options', hydraBox.middleware(api, {})); - - app.use('single-middleware', hydraBox.middleware(api, { - baseIriFromRequest: true, - loader, - store, - middleware: { - resource: handler, - operations: handler - } - })); - - app.use('multi-middleware', hydraBox.middleware(api, { - baseIriFromRequest: true, - loader, - store, - middleware: { - resource: [handler, handler], - operations: [handler, handler] - } - })); + app.use("empty-options", hydraBox.middleware(api, {})); + + app.use( + "single-middleware", + hydraBox.middleware(api, { + baseIriFromRequest: true, + loader, + store, + middleware: { + resource: handler, + operations: handler, + }, + }), + ); + + app.use( + "multi-middleware", + hydraBox.middleware(api, { + baseIriFromRequest: true, + loader, + store, + middleware: { + resource: [handler, handler], + operations: [handler, handler], + }, + }), + ); } async function testStoreResourceLoader() { diff --git a/types/hydra-box/index.d.ts b/types/hydra-box/index.d.ts index adb073822a202b..26e15e3aaff4bd 100644 --- a/types/hydra-box/index.d.ts +++ b/types/hydra-box/index.d.ts @@ -7,13 +7,13 @@ /// <reference types="absolute-url" /> /// <reference types="set-link" /> -import { Readable } from 'stream'; -import express = require('express'); -import * as RDF from '@rdfjs/types'; -import DatasetExt from 'rdf-ext/lib/Dataset'; -import { GraphPointer } from 'clownface'; -import middleware = require('./middleware'); -import { Api } from './Api'; +import { Readable } from "stream"; +import express = require("express"); +import * as RDF from "@rdfjs/types"; +import { GraphPointer } from "clownface"; +import DatasetExt from "rdf-ext/lib/Dataset"; +import middleware = require("./middleware"); +import { Api } from "./Api"; declare namespace HydraBox { interface PotentialOperation { @@ -48,7 +48,7 @@ declare namespace HydraBox { } } -declare module 'express-serve-static-core' { +declare module "express-serve-static-core" { interface Request { hydra: HydraBox.HydraBox; } diff --git a/types/hydra-box/middleware.d.ts b/types/hydra-box/middleware.d.ts index 0ec953200ffd53..bfb66ffc622afd 100644 --- a/types/hydra-box/middleware.d.ts +++ b/types/hydra-box/middleware.d.ts @@ -1,10 +1,10 @@ -import express = require('express'); -import { Store } from '@rdfjs/types'; -import '@rdfjs/express-handler'; -import 'set-link'; -import 'absolute-url'; -import { Api } from './Api'; -import { ResourceLoader } from '.'; +import express = require("express"); +import { Store } from "@rdfjs/types"; +import "@rdfjs/express-handler"; +import "set-link"; +import "absolute-url"; +import { ResourceLoader } from "."; +import { Api } from "./Api"; declare namespace middleware { interface HydraBoxMiddleware { diff --git a/types/hyggedyne__scrabbleify/hyggedyne__scrabbleify-tests.ts b/types/hyggedyne__scrabbleify/hyggedyne__scrabbleify-tests.ts index ab8d254da6dcae..a45f84782c2448 100644 --- a/types/hyggedyne__scrabbleify/hyggedyne__scrabbleify-tests.ts +++ b/types/hyggedyne__scrabbleify/hyggedyne__scrabbleify-tests.ts @@ -1,11 +1,11 @@ -import { numbers, punctuation, scrabbleify, symbols } from '@hyggedyne/scrabbleify'; +import { numbers, punctuation, scrabbleify, symbols } from "@hyggedyne/scrabbleify"; const loremIpsum = `Lorem Ipsum is simply .... of Lorem Ipsum.`; scrabbleify(loremIpsum); // $ExpectType string -scrabbleify(loremIpsum, [' ', 'L', 'I']); // $ExpectType string -scrabbleify(loremIpsum, ' ', true); // $ExpectType string -scrabbleify(loremIpsum, [' '], ['L']); // $ExpectType string +scrabbleify(loremIpsum, [" ", "L", "I"]); // $ExpectType string +scrabbleify(loremIpsum, " ", true); // $ExpectType string +scrabbleify(loremIpsum, [" "], ["L"]); // $ExpectType string numbers; // $ExpectType string[] punctuation; // $ExpectType string[] diff --git a/types/hyper-aws4/hyper-aws4-tests.ts b/types/hyper-aws4/hyper-aws4-tests.ts index 14caa34a9fde2d..85eda5f2c1fd74 100644 --- a/types/hyper-aws4/hyper-aws4-tests.ts +++ b/types/hyper-aws4/hyper-aws4-tests.ts @@ -1,12 +1,12 @@ -import { sign, Request } from "hyper-aws4"; +import { Request, sign } from "hyper-aws4"; const signOption: Request = { url: "https://us-west-1.hyper.sh/version", method: "GET", credential: { accessKey: "6DPLADBPWYXDUVXLX34EJXBL", - secretKey: "2ldD1Yz0nzATl9vvagBwYTjglXBjVOWU8gV8aMm5" - } + secretKey: "2ldD1Yz0nzATl9vvagBwYTjglXBjVOWU8gV8aMm5", + }, }; sign(signOption); diff --git a/types/hyper-function-component/index.d.ts b/types/hyper-function-component/index.d.ts index 886ec6efbdd414..98a2d3b81ddcf3 100644 --- a/types/hyper-function-component/index.d.ts +++ b/types/hyper-function-component/index.d.ts @@ -3,19 +3,21 @@ // Definitions by: terry-fei <https://github.com/terry-fei> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -type HyperFunctionComponent = (( - container: Element, - props: HfcProps -) => { - changed: (props: HfcProps) => void; - disconnected: () => void; -}) & { - tag: string; - hfc: string; - ver: string; - // [AttrNames, EventNames, SlotNames] - names: [string[], string[], string[]]; -}; +type HyperFunctionComponent = + & (( + container: Element, + props: HfcProps, + ) => { + changed: (props: HfcProps) => void; + disconnected: () => void; + }) + & { + tag: string; + hfc: string; + ver: string; + // [AttrNames, EventNames, SlotNames] + names: [string[], string[], string[]]; + }; interface HfcProps { attrs: { [k: string]: any }; @@ -23,7 +25,7 @@ interface HfcProps { slots: { [k: string]: ( container: Element, - args?: { key?: string; [k: string]: any } + args?: { key?: string; [k: string]: any }, ) => void; }; others: { [k: string]: any }; diff --git a/types/hyperdeck-js-lib/hyperdeck-js-lib-tests.ts b/types/hyperdeck-js-lib/hyperdeck-js-lib-tests.ts index 35932660ddcef0..db2333f7809668 100644 --- a/types/hyperdeck-js-lib/hyperdeck-js-lib-tests.ts +++ b/types/hyperdeck-js-lib/hyperdeck-js-lib-tests.ts @@ -1,6 +1,6 @@ -import { Hyperdeck, Logger } from 'hyperdeck-js-lib'; +import { Hyperdeck, Logger } from "hyperdeck-js-lib"; -const hyperdeck = new Hyperdeck('192.168.1.12'); +const hyperdeck = new Hyperdeck("192.168.1.12"); hyperdeck .onConnected() .then(() => { @@ -9,43 +9,43 @@ hyperdeck // Requests are buffered until the connection completes. If the connection fails, any // buffered requests will be rejected. hyperdeck - .makeRequest<Hyperdeck.DeviceInfo>('device info') + .makeRequest<Hyperdeck.DeviceInfo>("device info") .then(response => { - console.log('Got response with code', response.code); - console.log('Hyperdeck unique id:', response.params['unique id']); + console.log("Got response with code", response.code); + console.log("Hyperdeck unique id:", response.params["unique id"]); }) .catch(error => { if (!error) { - console.error('The request failed because the hyperdeck connection was lost.'); + console.error("The request failed because the hyperdeck connection was lost."); } else { console.error(`The hyperdeck returned an error with status code ${error.code}.`); } }); - hyperdeck.getNotifier().on('asynchronousEvent', response => { + hyperdeck.getNotifier().on("asynchronousEvent", response => { console.log(`Got an asynchronous event with code ${response.code}.`); // @ts-expect-error invalid property response.asdasdasf; }); - hyperdeck.getNotifier().once('connectionLost', () => { - console.error('Connection lost.'); + hyperdeck.getNotifier().once("connectionLost", () => { + console.error("Connection lost."); }); }) .catch(() => { - console.error('Failed to connect to hyperdeck.'); + console.error("Failed to connect to hyperdeck."); }); hyperdeck.play(); hyperdeck.play(35); // play at 35% hyperdeck.stop(); hyperdeck.record(); -hyperdeck.goTo('00:13:03:55'); // goes to timecode in format hh:mm:ss:ff +hyperdeck.goTo("00:13:03:55"); // goes to timecode in format hh:mm:ss:ff // @ts-expect-error invalid timecode string -hyperdeck.goTo('00:13:03'); +hyperdeck.goTo("00:13:03"); // @ts-expect-error invalid timecode string -hyperdeck.goTo('00:1x:03:44'); +hyperdeck.goTo("00:1x:03:44"); hyperdeck.slotSelect(2); hyperdeck.slotInfo(); // Gives info on currently selected slot hyperdeck.slotInfo(1); @@ -53,7 +53,7 @@ hyperdeck.clipsGet(); hyperdeck.nextClip(); hyperdeck.prevClip(); hyperdeck.transportInfo(); -hyperdeck.format('asdasd'); +hyperdeck.format("asdasd"); Logger.setLevel(Logger.DEBUG); Logger.setLevel(Logger.INFO); @@ -68,17 +68,17 @@ async function main() { // $ExpectType string response.text; - const format = response.params['video format']; - if (format === '1080i60') { + const format = response.params["video format"]; + if (format === "1080i60") { // } // @ts-expect-error invalid format - format === '1080i30'; + format === "1080i30"; const clips = await hyperdeck.clipsGet(); // $ExpectType string[] - clips.params.clip_one.split(' '); + clips.params.clip_one.split(" "); } main(); diff --git a/types/hyperdeck-js-lib/index.d.ts b/types/hyperdeck-js-lib/index.d.ts index a9db369fa5f26e..ba1e8e000dca85 100644 --- a/types/hyperdeck-js-lib/index.d.ts +++ b/types/hyperdeck-js-lib/index.d.ts @@ -6,8 +6,8 @@ /// <reference types="node" /> -import { GlobalLogger } from 'js-logger'; -import { EventEmitter } from 'events'; +import { EventEmitter } from "events"; +import { GlobalLogger } from "js-logger"; export const Logger: GlobalLogger; @@ -24,75 +24,75 @@ export namespace Hyperdeck { } interface Notifier { - on(event: 'asynchronousEvent', callback: (response: Response<unknown>) => void): this; - on(event: 'connectionStateChange', callback: (response: { connected: boolean }) => void): this; - on(event: 'connectionLost', callback: () => void): this; + on(event: "asynchronousEvent", callback: (response: Response<unknown>) => void): this; + on(event: "connectionStateChange", callback: (response: { connected: boolean }) => void): this; + on(event: "connectionLost", callback: () => void): this; - once(event: 'asynchronousEvent', callback: (response: Response<unknown>) => void): this; - once(event: 'connectionStateChange', callback: (response: { connected: boolean }) => void): this; - once(event: 'connectionLost', callback: () => void): this; + once(event: "asynchronousEvent", callback: (response: Response<unknown>) => void): this; + once(event: "connectionStateChange", callback: (response: { connected: boolean }) => void): this; + once(event: "connectionLost", callback: () => void): this; } class Notifier extends EventEmitter {} type VideoFormat = - | 'NTSC' - | 'PAL' - | 'NTSCp' - | 'PALp' - | '720p50' - | '720p5994' - | '720p60' - | '1080p23976' - | '1080p24' - | '1080p25' - | '1080p2997' - | '1080p30' - | '1080i50' - | '1080i5994' - | '1080i60' - | '4Kp23976' - | '4Kp24' - | '4Kp25' - | '4Kp2997' - | '4Kp30' - | '4Kp50' - | '4Kp5994' - | '4Kp60'; + | "NTSC" + | "PAL" + | "NTSCp" + | "PALp" + | "720p50" + | "720p5994" + | "720p60" + | "1080p23976" + | "1080p24" + | "1080p25" + | "1080p2997" + | "1080p30" + | "1080i50" + | "1080i5994" + | "1080i60" + | "4Kp23976" + | "4Kp24" + | "4Kp25" + | "4Kp2997" + | "4Kp30" + | "4Kp50" + | "4Kp5994" + | "4Kp60"; type FileFormat = - | 'QuickTimeUncompressed' - | 'QuickTimeProResHQ' - | 'QuickTimeProRes' - | 'QuickTimeProResLT' - | 'QuickTimeProResProxy' - | 'QuickTimeDNxHD220' - | 'DNxHD220' - | 'QuickTimeDNxHR_HQX' - | 'DNxHR_HQX' - | 'H.264Low' - | 'H.264Medium' - | 'H.264High ' - | 'QuickTimeDNxHD45 ' - | 'DNxHD45' - | 'QuickTimeDNxHD145' - | 'DNxHD145' - | 'QuickTimeDNxHR_SQ ' - | 'DNxHR_SQ' - | 'QuicktimeDNxHR_LB' - | 'DNxHR_LB'; + | "QuickTimeUncompressed" + | "QuickTimeProResHQ" + | "QuickTimeProRes" + | "QuickTimeProResLT" + | "QuickTimeProResProxy" + | "QuickTimeDNxHD220" + | "DNxHD220" + | "QuickTimeDNxHR_HQX" + | "DNxHR_HQX" + | "H.264Low" + | "H.264Medium" + | "H.264High " + | "QuickTimeDNxHD45 " + | "DNxHD45" + | "QuickTimeDNxHD145" + | "DNxHD145" + | "QuickTimeDNxHR_SQ " + | "DNxHR_SQ" + | "QuicktimeDNxHR_LB" + | "DNxHR_LB"; interface DeviceInfo { - 'unique id': string; + "unique id": string; model: string; - 'protocol version': string; + "protocol version": string; } interface SlotInfo { - 'slot id': string; - status: 'empty' | 'mounting' | 'mounted' | 'error'; - 'volume name': string; - 'recording time': string; - 'video format': VideoFormat; + "slot id": string; + status: "empty" | "mounting" | "mounted" | "error"; + "volume name": string; + "recording time": string; + "video format": VideoFormat; } interface ClipList { @@ -100,16 +100,16 @@ export namespace Hyperdeck { } interface TransportInfo { - status: 'preview' | 'stopped' | 'play' | 'forward' | 'rewind' | 'jog' | 'shuttle' | 'record'; + status: "preview" | "stopped" | "play" | "forward" | "rewind" | "jog" | "shuttle" | "record"; speed: string; /** could be "none" */ - 'slot id': string; - 'display timecode': Timecode; + "slot id": string; + "display timecode": Timecode; timecode: Timecode; /** could be "none" */ - 'clip id': string; - 'video format': VideoFormat; - loop: 'true' | 'false'; + "clip id": string; + "video format": VideoFormat; + loop: "true" | "false"; } } diff --git a/types/hyperscript/hyperscript-tests.ts b/types/hyperscript/hyperscript-tests.ts index fe005ba08c3df4..1dab2cc48d0207 100644 --- a/types/hyperscript/hyperscript-tests.ts +++ b/types/hyperscript/hyperscript-tests.ts @@ -1,83 +1,76 @@ - -import * as h from 'hyperscript' +import * as h from "hyperscript"; // Test/example code adapted from https://github.com/dominictarr/hyperscript/blob/master/README.md // example -h('div#page', - h('div#header', - h('h1.classy', 'h', { style: {'background-color': '#22f'} })), - h('div#menu', { style: {'background-color': '#2f2'} }, - h('ul', - h('li', 'one'), - h('li', 'two'), - h('li', 'three'))), - h('h2', 'content title', { style: {'background-color': '#f22'} }), - h('p', - "so it's just like a templating engine,\n", - "but easy to use inline with javascript\n"), - h('p', - "the intension is for this to be used to create\n", - "reusable, interactive html widgets. ")) +h( + "div#page", + h("div#header", h("h1.classy", "h", { style: { "background-color": "#22f" } })), + h("div#menu", { style: { "background-color": "#2f2" } }, h("ul", h("li", "one"), h("li", "two"), h("li", "three"))), + h("h2", "content title", { style: { "background-color": "#f22" } }), + h("p", "so it's just like a templating engine,\n", "but easy to use inline with javascript\n"), + h("p", "the intension is for this to be used to create\n", "reusable, interactive html widgets. "), +); // event -h('a', {href: '#', - onclick: function (e: Event) { - alert('you are 1,000,000th visitor!') - e.preventDefault() - } -}, 'click here to win a prize') +h("a", { + href: "#", + onclick: function(e: Event) { + alert("you are 1,000,000th visitor!"); + e.preventDefault(); + }, +}, "click here to win a prize"); // array of children -const obj: {[id: string]: string} = { - a: 'Apple', - b: 'Banana', - c: 'Cherry', - d: 'Durian', - e: 'Elder Berry' -} -h('table', - h('tr', h('th', 'letter'), h('th', 'fruit')), - Object.keys(obj).map(function (k) { - return h('tr', - h('th', k), - h('td', obj[k]) - ) - }) -) +const obj: { [id: string]: string } = { + a: "Apple", + b: "Banana", + c: "Cherry", + d: "Durian", + e: "Elder Berry", +}; +h( + "table", + h("tr", h("th", "letter"), h("th", "fruit")), + Object.keys(obj).map(function(k) { + return h("tr", h("th", k), h("td", obj[k])); + }), +); // new context -const h2 = h.context() -h2('a', {href: '#', - onclick: function (e: Event) { - alert('you are 1,000,000th visitor!') - e.preventDefault() - } -}, "Click this") +const h2 = h.context(); +h2("a", { + href: "#", + onclick: function(e: Event) { + alert("you are 1,000,000th visitor!"); + e.preventDefault(); + }, +}, "Click this"); -h2.cleanup() +h2.cleanup(); /* Polymorphic type tests */ // fall back to Element when in doubt -let fallbackTest = h('canvas#test3'); +let fallbackTest = h("canvas#test3"); // determine proper Element type from tagName -let htmlTest1: HTMLCanvasElement = h('canvas'); +let htmlTest1: HTMLCanvasElement = h("canvas"); // allow coercion of decorated tagName to proper type -let htmlTest2: HTMLCanvasElement = h<HTMLCanvasElement>('canvas#test2'); +let htmlTest2: HTMLCanvasElement = h<HTMLCanvasElement>("canvas#test2"); // if you need it to be an HTMLElement, you must coerce -let htmlTest3 = h<HTMLElement>('canvas#test3'); +let htmlTest3 = h<HTMLElement>("canvas#test3"); // support SVG elements -let svgTest1 = h('svg'); +let svgTest1 = h("svg"); // allow coercions on SVG elements -let svgTest2 = h<SVGSVGElement>('svg#test5'); +let svgTest2 = h<SVGSVGElement>("svg#test5"); // inline coercion if you were feeling pedantic -h<HTMLDivElement>('div#page', - h<HTMLDivElement>('div#header', - h<HTMLHeadingElement>('h1.classy', 'h', { style: {'background-color': '#22f'} }))); +h<HTMLDivElement>( + "div#page", + h<HTMLDivElement>("div#header", h<HTMLHeadingElement>("h1.classy", "h", { style: { "background-color": "#22f" } })), +); diff --git a/types/hyperscript/index.d.ts b/types/hyperscript/index.d.ts index c03b12d7d28f2c..139ef9903e406b 100644 --- a/types/hyperscript/index.d.ts +++ b/types/hyperscript/index.d.ts @@ -4,8 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 -declare module 'hyperscript' { - +declare module "hyperscript" { interface HyperScript { /** Creates an Element */ <T extends keyof ElementTagNameMap>(tagName: T, attrs?: Object, ...children: any[]): ElementTagNameMap[T]; diff --git a/types/hypertext-application-language/hypertext-application-language-tests.ts b/types/hypertext-application-language/hypertext-application-language-tests.ts index 509facb82f8e21..53e44a1ced64e0 100644 --- a/types/hypertext-application-language/hypertext-application-language-tests.ts +++ b/types/hypertext-application-language/hypertext-application-language-tests.ts @@ -1,7 +1,7 @@ // Link object // Fields format: -var link:Hal.Link = { +var link: Hal.Link = { "deprecation": "", "href": "", "hreflang": "", @@ -13,6 +13,6 @@ var link:Hal.Link = { }; // Required fields: -var link:Hal.Link = { +var link: Hal.Link = { "href": "", }; diff --git a/types/hyphen/hyphen-tests.ts b/types/hyphen/hyphen-tests.ts index 3e3bbf791c2c8b..4f95c007db57ca 100644 --- a/types/hyphen/hyphen-tests.ts +++ b/types/hyphen/hyphen-tests.ts @@ -1,41 +1,41 @@ -import createHyphenator, { HyphenationFunctionSync } from 'hyphen'; -import hyphenationPatternsDe1996 from 'hyphen/patterns/de-1996'; -import hyphenationPatternsHu from 'hyphen/patterns/hu'; -import hyphenationPatternsEnGb from 'hyphen/patterns/en-gb'; -import { hyphenate as hyphenateEnGbAsync } from 'hyphen/en-gb'; +import createHyphenator, { HyphenationFunctionSync } from "hyphen"; +import { hyphenate as hyphenateEnGbAsync } from "hyphen/en-gb"; +import hyphenationPatternsDe1996 from "hyphen/patterns/de-1996"; +import hyphenationPatternsEnGb from "hyphen/patterns/en-gb"; +import hyphenationPatternsHu from "hyphen/patterns/hu"; // Test with HTML const hyphenateDe1996 = createHyphenator(hyphenationPatternsDe1996, { - hyphenChar: '-', + hyphenChar: "-", html: true, }) as HyphenationFunctionSync; -if (hyphenateDe1996('<section>Silbentrennung</section>') !== '<section>Sil-ben-tren-nung</section>') { - throw new Error('Test failed'); +if (hyphenateDe1996("<section>Silbentrennung</section>") !== "<section>Sil-ben-tren-nung</section>") { + throw new Error("Test failed"); } // Test with debug output const hyphenateHu = createHyphenator(hyphenationPatternsHu, { debug: true }) as HyphenationFunctionSync; -if (hyphenateHu('szóelválasztás', { hyphenChar: '|' }) !== 'szó|el|vá|lasz|tás') { - throw new Error('Test failed'); +if (hyphenateHu("szóelválasztás", { hyphenChar: "|" }) !== "szó|el|vá|lasz|tás") { + throw new Error("Test failed"); } // Test with async function returning a Promise -hyphenateEnGbAsync('hyphenation', { hyphenChar: '#' }).then(result => { - if (result !== 'hy#phen#a#tion') { - throw new Error('Test failed'); +hyphenateEnGbAsync("hyphenation", { hyphenChar: "#" }).then(result => { + if (result !== "hy#phen#a#tion") { + throw new Error("Test failed"); } }); // Test with minWordLength (new option in version 1.6) const hyphenateEnUsSyncWithMinWordLength = createHyphenator(hyphenationPatternsEnGb, { - hyphenChar: '-', + hyphenChar: "-", minWordLength: 11, }) as HyphenationFunctionSync; -if (hyphenateEnUsSyncWithMinWordLength('hyphenation') !== 'hy-phen-a-tion') { +if (hyphenateEnUsSyncWithMinWordLength("hyphenation") !== "hy-phen-a-tion") { // hyphenation has 11 chars => hyphenate - throw new Error('Test failed'); + throw new Error("Test failed"); } -if (hyphenateEnUsSyncWithMinWordLength('sabotaging') !== 'sabotaging') { +if (hyphenateEnUsSyncWithMinWordLength("sabotaging") !== "sabotaging") { // sabotaging has 10 chars => don't hyphenate - throw new Error('Test failed'); + throw new Error("Test failed"); } diff --git a/types/hyphenate-style-name/hyphenate-style-name-tests.ts b/types/hyphenate-style-name/hyphenate-style-name-tests.ts index 374314eb4128c8..52965ea1f6cd41 100644 --- a/types/hyphenate-style-name/hyphenate-style-name-tests.ts +++ b/types/hyphenate-style-name/hyphenate-style-name-tests.ts @@ -1,3 +1,3 @@ -import hyphenateStyleName = require('hyphenate-style-name'); +import hyphenateStyleName = require("hyphenate-style-name"); -hyphenateStyleName('MozTransition'); // $ExpectType string +hyphenateStyleName("MozTransition"); // $ExpectType string diff --git a/types/hystrixjs/hystrixjs-tests.ts b/types/hystrixjs/hystrixjs-tests.ts index 72c709068dee10..2d2408618d2273 100644 --- a/types/hystrixjs/hystrixjs-tests.ts +++ b/types/hystrixjs/hystrixjs-tests.ts @@ -1,10 +1,10 @@ -import hystrixjs = require('hystrixjs'); -import q = require('q'); +import hystrixjs = require("hystrixjs"); +import q = require("q"); const commandFactory = hystrixjs.commandFactory; const command = commandFactory - .getOrCreate<string, string>('testCommand', 'testGroup') + .getOrCreate<string, string>("testCommand", "testGroup") .circuitBreakerSleepWindowInMilliseconds(5000) .errorHandler((error) => { return false; @@ -20,14 +20,14 @@ const command = commandFactory .percentileWindowLength(60) .circuitBreakerErrorThresholdPercentage(30) .fallbackTo((error) => { - return q.resolve('fallback'); + return q.resolve("fallback"); }) .run((args) => { return q.resolve(args); }) .build(); -command.execute('something').then((result) => { +command.execute("something").then((result) => { console.log(result); }); @@ -36,8 +36,8 @@ commandFactory.resetCache(); const metricsFactory = hystrixjs.metricsFactory; const metrics = metricsFactory.getOrCreate({ - commandKey: 'metricsKey', - commandGroup: 'metricsGroup' + commandKey: "metricsKey", + commandGroup: "metricsGroup", }); metrics.markSuccess(); metrics.markFailure(); diff --git a/types/hystrixjs/index.d.ts b/types/hystrixjs/index.d.ts index 09cce60afa1758..083be7167e4b61 100644 --- a/types/hystrixjs/index.d.ts +++ b/types/hystrixjs/index.d.ts @@ -95,7 +95,7 @@ export interface CommandBuilder { circuitBreakerErrorThresholdPercentage(value: number): CommandBuilder; context(value: any): CommandBuilder; run(value: (...args: any[]) => PromiseLike<any>): CommandBuilder; - fallbackTo(value: (error: Error, args ?: any[]) => PromiseLike<any>): CommandBuilder; + fallbackTo(value: (error: Error, args?: any[]) => PromiseLike<any>): CommandBuilder; build(): Command; } @@ -228,7 +228,9 @@ export interface CommandBuilderA6<R, T, U, V, W, X, Y> { circuitBreakerErrorThresholdPercentage(value: number): CommandBuilderA6<R, T, U, V, W, X, Y>; context(value: any): CommandBuilderA6<R, T, U, V, W, X, Y>; run(value: (t: T, u: U, v: V, w: W, x: X, y: Y) => PromiseLike<R>): CommandBuilderA6<R, T, U, V, W, X, Y>; - fallbackTo(value: (error: Error, args: [T, U, V, W, X, Y]) => PromiseLike<R>): CommandBuilderA6<R, T, U, V, W, X, Y>; + fallbackTo( + value: (error: Error, args: [T, U, V, W, X, Y]) => PromiseLike<R>, + ): CommandBuilderA6<R, T, U, V, W, X, Y>; build(): CommandA6<R, T, U, V, W, X, Y>; } @@ -247,7 +249,9 @@ export interface CommandBuilderA7<R, T, U, V, W, X, Y, Z> { circuitBreakerErrorThresholdPercentage(value: number): CommandBuilderA7<R, T, U, V, W, X, Y, Z>; context(value: any): CommandBuilderA7<R, T, U, V, W, X, Y, Z>; run(value: (t: T, u: U, v: V, w: W, x: X, y: Y, z: Z) => PromiseLike<R>): CommandBuilderA7<R, T, U, V, W, X, Y, Z>; - fallbackTo(value: (error: Error, args: [T, U, V, W, X, Y, Z]) => PromiseLike<R>): CommandBuilderA7<R, T, U, V, W, X, Y, Z>; + fallbackTo( + value: (error: Error, args: [T, U, V, W, X, Y, Z]) => PromiseLike<R>, + ): CommandBuilderA7<R, T, U, V, W, X, Y, Z>; build(): CommandA7<R, T, U, V, W, X, Y, Z>; } @@ -260,7 +264,10 @@ export interface CommandFactory { getOrCreate<R, T, U, V, W>(commandKey: string, commandGroup?: string): CommandBuilderA4<R, T, U, V, W>; getOrCreate<R, T, U, V, W, X>(commandKey: string, commandGroup?: string): CommandBuilderA5<R, T, U, V, W, X>; getOrCreate<R, T, U, V, W, X, Y>(commandKey: string, commandGroup?: string): CommandBuilderA6<R, T, U, V, W, X, Y>; - getOrCreate<R, T, U, V, W, X, Y, Z>(commandKey: string, commandGroup?: string): CommandBuilderA7<R, T, U, V, W, X, Y, Z>; + getOrCreate<R, T, U, V, W, X, Y, Z>( + commandKey: string, + commandGroup?: string, + ): CommandBuilderA7<R, T, U, V, W, X, Y, Z>; resetCache(): void; }