@celljs/ta-web 4.34.0 → 4.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +1 -1
- package/README.md +1 -1
- package/esm/browser/apps/app-icon.d.ts +23 -0
- package/esm/browser/apps/app-icon.js +98 -0
- package/esm/browser/apps/app-settings.d.ts +6 -0
- package/esm/browser/apps/app-settings.js +67 -0
- package/esm/browser/apps/app-window-util.d.ts +23 -0
- package/esm/browser/apps/app-window-util.js +27 -0
- package/esm/browser/apps/app-window.d.ts +9 -0
- package/esm/browser/apps/app-window.js +90 -0
- package/esm/browser/apps/web-apps.d.ts +29 -0
- package/esm/browser/apps/web-apps.js +57 -0
- package/esm/browser/assistant/assistant-thread.js +2 -2
- package/esm/browser/assistant/call-keeper.d.ts +2 -5
- package/esm/browser/assistant/call-keeper.js +7 -11
- package/esm/browser/assistant/mic-capture.d.ts +34 -0
- package/esm/browser/assistant/mic-capture.js +87 -0
- package/esm/browser/assistant/realtime-voice.d.ts +2 -2
- package/esm/browser/assistant/realtime-voice.js +6 -15
- package/esm/browser/components/access-settings.d.ts +6 -0
- package/esm/browser/components/access-settings.js +52 -0
- package/esm/browser/components/app-root.d.ts +6 -0
- package/esm/browser/components/app-root.js +34 -0
- package/esm/browser/components/app-view.d.ts +8 -2
- package/esm/browser/components/app-view.js +1 -25
- package/esm/browser/components/board.d.ts +2 -2
- package/esm/browser/components/board.js +2 -2
- package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
- package/esm/browser/components/composer-box-hooks.d.ts +12 -0
- package/esm/browser/components/composer-box-hooks.js +12 -0
- package/esm/browser/components/composer-box-protocol.d.ts +12 -1
- package/esm/browser/components/composer-box.js +14 -11
- package/esm/browser/components/composer.js +69 -3
- package/esm/browser/components/extension-settings.d.ts +7 -0
- package/esm/browser/components/extension-settings.js +32 -0
- package/esm/browser/components/host-view.d.ts +1 -1
- package/esm/browser/components/message-list.js +3 -3
- package/esm/browser/components/message-steps.js +3 -3
- package/esm/browser/components/phone-shell.d.ts +2 -2
- package/esm/browser/components/request-error.d.ts +9 -0
- package/esm/browser/components/request-error.js +21 -0
- package/esm/browser/components/settings-more.js +13 -24
- package/esm/browser/components/storage-settings.d.ts +17 -0
- package/esm/browser/components/storage-settings.js +145 -0
- package/esm/browser/device/screen-awake.d.ts +16 -0
- package/esm/browser/device/screen-awake.js +37 -0
- package/esm/browser/device/sheet-swipe.js +4 -0
- package/esm/browser/extension/icons.js +2 -1
- package/esm/browser/extension/web-access.d.ts +16 -0
- package/esm/browser/extension/web-access.js +75 -0
- package/esm/browser/extension/web-api-contributions.d.ts +6 -7
- package/esm/browser/extension/web-api-desktop.d.ts +23 -0
- package/esm/browser/extension/web-api-spec.d.ts +70 -0
- package/esm/browser/extension/web-api-spec.js +225 -0
- package/esm/browser/extension/web-api-targets.d.ts +11 -0
- package/esm/browser/extension/web-api-targets.js +2 -0
- package/esm/browser/extension/web-extension-api.d.ts +11 -1
- package/esm/browser/extension/web-extension-context.d.ts +3 -2
- package/esm/browser/extension/web-extension-context.js +22 -17
- package/esm/browser/extension/web-extension-run.d.ts +8 -1
- package/esm/browser/extension/web-extension-run.js +37 -0
- package/esm/browser/extension/web-extensions-running.d.ts +20 -1
- package/esm/browser/extension/web-extensions-running.js +107 -9
- package/esm/browser/extension/web-extensions.js +1 -0
- package/esm/browser/extension/web-pages.d.ts +5 -0
- package/esm/browser/extension/web-pages.js +3 -0
- package/esm/browser/game/game-control.d.ts +6 -0
- package/esm/browser/game/game-control.js +28 -0
- package/esm/browser/game/game-host.d.ts +9 -2
- package/esm/browser/game/game-host.js +5 -1
- package/esm/browser/game/game-protocol.d.ts +8 -0
- package/esm/browser/game/game-runner.d.ts +7 -1
- package/esm/browser/game/game-runner.js +24 -2
- package/esm/browser/game/game-target.d.ts +22 -0
- package/esm/browser/game/game-target.js +84 -0
- package/esm/browser/game/game-util.d.ts +2 -0
- package/esm/browser/game/game-util.js +2 -0
- package/esm/browser/game/game-view.d.ts +5 -2
- package/esm/browser/game/game-view.js +4 -4
- package/esm/browser/game/game3d-protocol.d.ts +3 -1
- package/esm/browser/game/game3d-runner.d.ts +6 -1
- package/esm/browser/game/game3d-runner.js +26 -2
- package/esm/browser/i18n/en/chat.d.ts +4 -0
- package/esm/browser/i18n/en/chat.js +4 -0
- package/esm/browser/i18n/en/common.d.ts +1 -0
- package/esm/browser/i18n/en/common.js +1 -0
- package/esm/browser/i18n/en/discover.d.ts +11 -0
- package/esm/browser/i18n/en/discover.js +11 -0
- package/esm/browser/i18n/en/settings.d.ts +43 -0
- package/esm/browser/i18n/en/settings.js +43 -0
- package/esm/browser/i18n/ja/chat.js +4 -0
- package/esm/browser/i18n/ja/common.js +1 -0
- package/esm/browser/i18n/ja/discover.js +11 -0
- package/esm/browser/i18n/ja/settings.js +43 -0
- package/esm/browser/i18n/locales.d.ts +60 -3
- package/esm/browser/i18n/messages.d.ts +59 -2
- package/esm/browser/i18n/zh/chat.js +4 -0
- package/esm/browser/i18n/zh/common.js +1 -0
- package/esm/browser/i18n/zh/discover.js +11 -0
- package/esm/browser/i18n/zh/settings.js +43 -0
- package/esm/browser/i18n/zh-tw/chat.js +4 -0
- package/esm/browser/i18n/zh-tw/common.js +1 -0
- package/esm/browser/i18n/zh-tw/discover.js +11 -0
- package/esm/browser/i18n/zh-tw/settings.js +43 -0
- package/esm/browser/index.d.ts +3 -0
- package/esm/browser/index.js +3 -0
- package/esm/browser/notices/notices.js +1 -0
- package/esm/browser/sandbox/channel/channel.d.ts +56 -0
- package/esm/browser/sandbox/channel/channel.js +124 -0
- package/esm/browser/sandbox/channel/codec.d.ts +80 -0
- package/esm/browser/sandbox/channel/codec.js +251 -0
- package/esm/browser/sandbox/hook-host.d.ts +23 -0
- package/esm/browser/sandbox/hook-host.js +61 -0
- package/esm/browser/sandbox/isolated-host.d.ts +105 -0
- package/esm/browser/sandbox/isolated-host.js +395 -0
- package/esm/browser/sandbox/remote/remote-copy.d.ts +57 -0
- package/esm/browser/sandbox/remote/remote-copy.js +318 -0
- package/esm/browser/sandbox/remote/remote-mirror.d.ts +61 -0
- package/esm/browser/sandbox/remote/remote-mirror.js +341 -0
- package/esm/browser/sandbox/remote/remote-protocol.d.ts +79 -0
- package/esm/browser/sandbox/remote/remote-protocol.js +54 -0
- package/esm/browser/sandbox/remote/remote-styles.d.ts +10 -0
- package/esm/browser/sandbox/remote/remote-styles.js +113 -0
- package/esm/browser/sandbox/remote-root.d.ts +11 -0
- package/esm/browser/sandbox/remote-root.js +81 -0
- package/esm/browser/sandbox/runtime/frame-api.d.ts +28 -0
- package/esm/browser/sandbox/runtime/frame-api.js +147 -0
- package/esm/browser/sandbox/runtime/frame-features.d.ts +6 -0
- package/esm/browser/sandbox/runtime/frame-features.js +50 -0
- package/esm/browser/sandbox/runtime/frame-parts.d.ts +36 -0
- package/esm/browser/sandbox/runtime/frame-parts.js +69 -0
- package/esm/browser/sandbox/runtime/frame-roots.d.ts +26 -0
- package/esm/browser/sandbox/runtime/frame-roots.js +76 -0
- package/esm/browser/sandbox/runtime/frame-store.d.ts +9 -0
- package/esm/browser/sandbox/runtime/frame-store.js +18 -0
- package/esm/browser/sandbox/runtime/sandbox-runtime.d.ts +11 -0
- package/esm/browser/sandbox/runtime/sandbox-runtime.js +45 -0
- package/esm/browser/sandbox/sandbox-features.d.ts +25 -0
- package/esm/browser/sandbox/sandbox-features.js +32 -0
- package/esm/browser/sandbox/sandbox-frame.d.ts +21 -0
- package/esm/browser/sandbox/sandbox-frame.js +75 -0
- package/esm/browser/sandbox/sandbox-guards.d.ts +19 -0
- package/esm/browser/sandbox/sandbox-guards.js +74 -0
- package/esm/browser/sandbox/sandbox-protocol.d.ts +57 -0
- package/esm/browser/sandbox/sandbox-protocol.js +49 -0
- package/esm/browser/sandbox/sandbox-runtime-code.d.ts +1 -0
- package/esm/browser/sandbox/sandbox-runtime-code.js +3 -0
- package/esm/browser/sandbox/web-sandbox.d.ts +28 -0
- package/esm/browser/sandbox/web-sandbox.js +44 -0
- package/esm/browser/settings/agent-settings.js +5 -1
- package/esm/browser/settings/settings-protocol.d.ts +2 -0
- package/esm/browser/settings/settings-protocol.js +2 -0
- package/esm/browser/style/pages.d.ts +1 -1
- package/esm/browser/style/pages.js +2 -0
- package/esm/browser/style/surfaces.d.ts +1 -1
- package/esm/browser/style/surfaces.js +4 -0
- package/esm/browser/style/tints.d.ts +2 -0
- package/esm/browser/style/tints.js +10 -0
- package/esm/browser/targets/targets-protocol.d.ts +54 -0
- package/esm/browser/targets/targets-protocol.js +34 -0
- package/esm/browser/targets/targets.d.ts +13 -0
- package/esm/browser/targets/targets.js +64 -0
- package/esm/browser/util/composer.d.ts +4 -2
- package/esm/browser/util/composer.js +7 -1
- package/esm/browser/util/desktop.d.ts +31 -1
- package/esm/browser/util/desktop.js +20 -0
- package/esm/browser/util/message.d.ts +6 -0
- package/esm/browser/util/message.js +21 -0
- package/esm/browser/util/process.d.ts +1 -0
- package/esm/browser/util/process.js +6 -1
- package/esm/browser/util/progress.d.ts +2 -1
- package/esm/browser/util/progress.js +2 -11
- package/esm/browser/view.js +1 -1
- package/lib/browser/apps/app-icon.d.ts +24 -0
- package/lib/browser/apps/app-icon.js +134 -0
- package/lib/browser/apps/app-settings.d.ts +7 -0
- package/lib/browser/apps/app-settings.js +103 -0
- package/lib/browser/apps/app-window-util.d.ts +24 -0
- package/lib/browser/apps/app-window-util.js +30 -0
- package/lib/browser/apps/app-window.d.ts +10 -0
- package/lib/browser/apps/app-window.js +126 -0
- package/lib/browser/apps/web-apps.d.ts +30 -0
- package/lib/browser/apps/web-apps.js +61 -0
- package/lib/browser/assistant/assistant-thread.js +2 -2
- package/lib/browser/assistant/call-keeper.d.ts +2 -5
- package/lib/browser/assistant/call-keeper.js +6 -10
- package/lib/browser/assistant/mic-capture.d.ts +35 -0
- package/lib/browser/assistant/mic-capture.js +91 -0
- package/lib/browser/assistant/realtime-voice.d.ts +2 -2
- package/lib/browser/assistant/realtime-voice.js +6 -15
- package/lib/browser/components/access-settings.d.ts +7 -0
- package/lib/browser/components/access-settings.js +88 -0
- package/lib/browser/components/app-root.d.ts +7 -0
- package/lib/browser/components/app-root.js +70 -0
- package/lib/browser/components/app-view.d.ts +8 -2
- package/lib/browser/components/app-view.js +1 -25
- package/lib/browser/components/board.d.ts +2 -2
- package/lib/browser/components/board.js +2 -2
- package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
- package/lib/browser/components/composer-box-hooks.d.ts +12 -0
- package/lib/browser/components/composer-box-hooks.js +13 -0
- package/lib/browser/components/composer-box-protocol.d.ts +12 -1
- package/lib/browser/components/composer-box.js +13 -10
- package/lib/browser/components/composer.js +69 -3
- package/lib/browser/components/extension-settings.d.ts +8 -0
- package/lib/browser/components/extension-settings.js +69 -0
- package/lib/browser/components/host-view.d.ts +1 -1
- package/lib/browser/components/message-list.js +3 -3
- package/lib/browser/components/message-steps.js +3 -3
- package/lib/browser/components/phone-shell.d.ts +2 -2
- package/lib/browser/components/request-error.d.ts +10 -0
- package/lib/browser/components/request-error.js +57 -0
- package/lib/browser/components/settings-more.js +12 -23
- package/lib/browser/components/storage-settings.d.ts +18 -0
- package/lib/browser/components/storage-settings.js +182 -0
- package/lib/browser/device/screen-awake.d.ts +16 -0
- package/lib/browser/device/screen-awake.js +39 -1
- package/lib/browser/device/sheet-swipe.js +4 -0
- package/lib/browser/extension/icons.js +1 -0
- package/lib/browser/extension/web-access.d.ts +17 -0
- package/lib/browser/extension/web-access.js +78 -0
- package/lib/browser/extension/web-api-contributions.d.ts +6 -7
- package/lib/browser/extension/web-api-desktop.d.ts +23 -0
- package/lib/browser/extension/web-api-spec.d.ts +71 -0
- package/lib/browser/extension/web-api-spec.js +228 -0
- package/lib/browser/extension/web-api-targets.d.ts +12 -0
- package/lib/browser/extension/web-api-targets.js +3 -0
- package/lib/browser/extension/web-extension-api.d.ts +11 -1
- package/lib/browser/extension/web-extension-context.d.ts +3 -2
- package/lib/browser/extension/web-extension-context.js +22 -17
- package/lib/browser/extension/web-extension-run.d.ts +8 -1
- package/lib/browser/extension/web-extension-run.js +37 -0
- package/lib/browser/extension/web-extensions-running.d.ts +20 -1
- package/lib/browser/extension/web-extensions-running.js +107 -9
- package/lib/browser/extension/web-extensions.js +1 -0
- package/lib/browser/extension/web-pages.d.ts +5 -0
- package/lib/browser/extension/web-pages.js +3 -0
- package/lib/browser/game/game-control.d.ts +6 -0
- package/lib/browser/game/game-control.js +28 -0
- package/lib/browser/game/game-host.d.ts +9 -2
- package/lib/browser/game/game-host.js +5 -1
- package/lib/browser/game/game-protocol.d.ts +8 -0
- package/lib/browser/game/game-runner.d.ts +7 -1
- package/lib/browser/game/game-runner.js +24 -2
- package/lib/browser/game/game-target.d.ts +23 -0
- package/lib/browser/game/game-target.js +87 -0
- package/lib/browser/game/game-util.d.ts +2 -0
- package/lib/browser/game/game-util.js +2 -0
- package/lib/browser/game/game-view.d.ts +5 -2
- package/lib/browser/game/game-view.js +4 -4
- package/lib/browser/game/game3d-protocol.d.ts +3 -1
- package/lib/browser/game/game3d-runner.d.ts +6 -1
- package/lib/browser/game/game3d-runner.js +26 -2
- package/lib/browser/i18n/en/chat.d.ts +4 -0
- package/lib/browser/i18n/en/chat.js +4 -0
- package/lib/browser/i18n/en/common.d.ts +1 -0
- package/lib/browser/i18n/en/common.js +1 -0
- package/lib/browser/i18n/en/discover.d.ts +11 -0
- package/lib/browser/i18n/en/discover.js +11 -0
- package/lib/browser/i18n/en/settings.d.ts +43 -0
- package/lib/browser/i18n/en/settings.js +43 -0
- package/lib/browser/i18n/ja/chat.js +4 -0
- package/lib/browser/i18n/ja/common.js +1 -0
- package/lib/browser/i18n/ja/discover.js +11 -0
- package/lib/browser/i18n/ja/settings.js +43 -0
- package/lib/browser/i18n/locales.d.ts +60 -3
- package/lib/browser/i18n/messages.d.ts +59 -2
- package/lib/browser/i18n/zh/chat.js +4 -0
- package/lib/browser/i18n/zh/common.js +1 -0
- package/lib/browser/i18n/zh/discover.js +11 -0
- package/lib/browser/i18n/zh/settings.js +43 -0
- package/lib/browser/i18n/zh-tw/chat.js +4 -0
- package/lib/browser/i18n/zh-tw/common.js +1 -0
- package/lib/browser/i18n/zh-tw/discover.js +11 -0
- package/lib/browser/i18n/zh-tw/settings.js +43 -0
- package/lib/browser/index.d.ts +3 -0
- package/lib/browser/index.js +3 -0
- package/lib/browser/notices/notices.js +1 -0
- package/lib/browser/sandbox/channel/channel.d.ts +57 -0
- package/lib/browser/sandbox/channel/channel.js +128 -0
- package/lib/browser/sandbox/channel/codec.d.ts +81 -0
- package/lib/browser/sandbox/channel/codec.js +256 -0
- package/lib/browser/sandbox/hook-host.d.ts +24 -0
- package/lib/browser/sandbox/hook-host.js +98 -0
- package/lib/browser/sandbox/isolated-host.d.ts +106 -0
- package/lib/browser/sandbox/isolated-host.js +432 -0
- package/lib/browser/sandbox/remote/remote-copy.d.ts +58 -0
- package/lib/browser/sandbox/remote/remote-copy.js +322 -0
- package/lib/browser/sandbox/remote/remote-mirror.d.ts +62 -0
- package/lib/browser/sandbox/remote/remote-mirror.js +345 -0
- package/lib/browser/sandbox/remote/remote-protocol.d.ts +80 -0
- package/lib/browser/sandbox/remote/remote-protocol.js +57 -0
- package/lib/browser/sandbox/remote/remote-styles.d.ts +11 -0
- package/lib/browser/sandbox/remote/remote-styles.js +116 -0
- package/lib/browser/sandbox/remote-root.d.ts +12 -0
- package/lib/browser/sandbox/remote-root.js +117 -0
- package/lib/browser/sandbox/runtime/frame-api.d.ts +29 -0
- package/lib/browser/sandbox/runtime/frame-api.js +183 -0
- package/lib/browser/sandbox/runtime/frame-features.d.ts +7 -0
- package/lib/browser/sandbox/runtime/frame-features.js +53 -0
- package/lib/browser/sandbox/runtime/frame-parts.d.ts +37 -0
- package/lib/browser/sandbox/runtime/frame-parts.js +106 -0
- package/lib/browser/sandbox/runtime/frame-roots.d.ts +27 -0
- package/lib/browser/sandbox/runtime/frame-roots.js +113 -0
- package/lib/browser/sandbox/runtime/frame-store.d.ts +10 -0
- package/lib/browser/sandbox/runtime/frame-store.js +22 -0
- package/lib/browser/sandbox/runtime/sandbox-runtime.d.ts +12 -0
- package/lib/browser/sandbox/runtime/sandbox-runtime.js +47 -0
- package/lib/browser/sandbox/sandbox-features.d.ts +26 -0
- package/lib/browser/sandbox/sandbox-features.js +35 -0
- package/lib/browser/sandbox/sandbox-frame.d.ts +22 -0
- package/lib/browser/sandbox/sandbox-frame.js +79 -0
- package/lib/browser/sandbox/sandbox-guards.d.ts +20 -0
- package/lib/browser/sandbox/sandbox-guards.js +77 -0
- package/lib/browser/sandbox/sandbox-protocol.d.ts +58 -0
- package/lib/browser/sandbox/sandbox-protocol.js +52 -0
- package/lib/browser/sandbox/sandbox-runtime-code.d.ts +2 -0
- package/lib/browser/sandbox/sandbox-runtime-code.js +6 -0
- package/lib/browser/sandbox/web-sandbox.d.ts +29 -0
- package/lib/browser/sandbox/web-sandbox.js +47 -0
- package/lib/browser/settings/agent-settings.js +5 -1
- package/lib/browser/settings/settings-protocol.d.ts +2 -0
- package/lib/browser/settings/settings-protocol.js +2 -0
- package/lib/browser/style/pages.d.ts +1 -1
- package/lib/browser/style/pages.js +2 -0
- package/lib/browser/style/surfaces.d.ts +1 -1
- package/lib/browser/style/surfaces.js +4 -0
- package/lib/browser/style/tints.d.ts +2 -0
- package/lib/browser/style/tints.js +10 -0
- package/lib/browser/targets/targets-protocol.d.ts +55 -0
- package/lib/browser/targets/targets-protocol.js +37 -0
- package/lib/browser/targets/targets.d.ts +14 -0
- package/lib/browser/targets/targets.js +67 -0
- package/lib/browser/util/composer.d.ts +4 -2
- package/lib/browser/util/composer.js +7 -1
- package/lib/browser/util/desktop.d.ts +31 -1
- package/lib/browser/util/desktop.js +20 -0
- package/lib/browser/util/message.d.ts +6 -0
- package/lib/browser/util/message.js +21 -0
- package/lib/browser/util/process.d.ts +1 -0
- package/lib/browser/util/process.js +6 -1
- package/lib/browser/util/progress.d.ts +2 -1
- package/lib/browser/util/progress.js +2 -11
- package/lib/browser/view.js +2 -2
- package/package.json +8 -8
|
@@ -12,14 +12,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.WebExtensionsRunning = void 0;
|
|
13
13
|
const core_1 = require("@celljs/core");
|
|
14
14
|
const files_protocol_1 = require("../files/files-protocol");
|
|
15
|
+
const messages_1 = require("../i18n/messages");
|
|
15
16
|
const links_protocol_1 = require("../links/links-protocol");
|
|
16
17
|
const notices_protocol_1 = require("../notices/notices-protocol");
|
|
17
18
|
const session_notices_1 = require("../notices/session-notices");
|
|
18
19
|
const device_values_1 = require("../offline/device-values");
|
|
20
|
+
const sandbox_protocol_1 = require("../sandbox/sandbox-protocol");
|
|
21
|
+
const web_sandbox_1 = require("../sandbox/web-sandbox");
|
|
19
22
|
const screen_protocol_1 = require("../screen/screen-protocol");
|
|
20
23
|
const settings_protocol_1 = require("../settings/settings-protocol");
|
|
21
24
|
const state_protocol_1 = require("../state/state-protocol");
|
|
25
|
+
const targets_protocol_1 = require("../targets/targets-protocol");
|
|
22
26
|
const workbench_protocol_1 = require("../workbench-protocol");
|
|
27
|
+
const web_access_1 = require("./web-access");
|
|
23
28
|
const web_editor_tabs_1 = require("./web-editor-tabs");
|
|
24
29
|
const web_extension_code_1 = require("./web-extension-code");
|
|
25
30
|
const web_extension_protocol_1 = require("./web-extension-protocol");
|
|
@@ -67,6 +72,9 @@ class WebExtensionsRunning {
|
|
|
67
72
|
/** The extensions of the list of the last time have started (startKept), once. */
|
|
68
73
|
this.keptStarted = false;
|
|
69
74
|
this.pageList = new web_page_list_1.WebPageList();
|
|
75
|
+
/** Versions the user did not allow in this page (`<id>:<hash>`): not asked again until it loads again or they change. */
|
|
76
|
+
this.refused = new Set();
|
|
77
|
+
this.asking = new Map();
|
|
70
78
|
}
|
|
71
79
|
get state() {
|
|
72
80
|
return this.current;
|
|
@@ -97,13 +105,19 @@ class WebExtensionsRunning {
|
|
|
97
105
|
return web_pages_1.WebPagesUtil.listedKinds([...this.current.onOpen.map(entry => entry.info), ...[...this.running.values()].map(run => run.loaded.info)]);
|
|
98
106
|
}
|
|
99
107
|
/** Loads and starts an extension started on open, as reconcile starts the others. */
|
|
100
|
-
async launch(
|
|
101
|
-
var _a;
|
|
108
|
+
async launch(asked) {
|
|
109
|
+
var _a, _b;
|
|
110
|
+
const info = await this.allow(asked);
|
|
111
|
+
if (!info) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
102
114
|
const load = await this.loadPackage(info);
|
|
103
115
|
// Gone or changed meanwhile: the next refresh has it.
|
|
104
116
|
if (((_a = this.onDemand.get(info.id)) === null || _a === void 0 ? void 0 : _a.hash) === info.hash && !this.running.has(info.id)) {
|
|
105
117
|
this.startPackage(info, load);
|
|
106
118
|
this.publish();
|
|
119
|
+
// One in a sandbox registers its pages as it starts: they are there to show once it did.
|
|
120
|
+
await ('factory' in load ? (_b = load.factory.ready) === null || _b === void 0 ? void 0 : _b.catch(() => undefined) : undefined);
|
|
107
121
|
}
|
|
108
122
|
}
|
|
109
123
|
/** Stops one started on open: it is still listed, to start again; its page, if shown, gives way to the conversation. */
|
|
@@ -153,8 +167,13 @@ class WebExtensionsRunning {
|
|
|
153
167
|
void this.code.keepOnly(infos.map(info => info.hash));
|
|
154
168
|
// Those started on open wait to be opened (ta-launcher.md).
|
|
155
169
|
this.onDemand.set(infos.filter(info => info.activation === 'open'));
|
|
156
|
-
// Fetched together, started in the order of the list: the order of their views stays the same.
|
|
157
|
-
|
|
170
|
+
// Fetched together, started in the order of the list: the order of their views stays the same. One the user
|
|
171
|
+
// has not allowed (docs/design/ta-extension-access.md) waits to be asked; allowed, the list has it next time.
|
|
172
|
+
const differ = infos.filter(info => !this.same(this.running.get(info.id), info) && info.activation !== 'open');
|
|
173
|
+
const starting = differ.filter(info => web_access_1.WebAccessUtil.granted(info) !== undefined);
|
|
174
|
+
for (const info of differ.filter(waiting => web_access_1.WebAccessUtil.granted(waiting) === undefined)) {
|
|
175
|
+
void this.allow(info).then(allowed => allowed && this.refresh());
|
|
176
|
+
}
|
|
158
177
|
const loads = await Promise.all(starting.map(info => this.loadPackage(info)));
|
|
159
178
|
// Stopped only now, just before the new code starts: the views of the old one stay drawn until the next
|
|
160
179
|
// publish, and stopped while the new code is read (after an update, over the relay) they would show
|
|
@@ -164,7 +183,7 @@ class WebExtensionsRunning {
|
|
|
164
183
|
return true;
|
|
165
184
|
}
|
|
166
185
|
const info = fresh.get(run.loaded.id);
|
|
167
|
-
if (info &&
|
|
186
|
+
if (info && this.same(run, info)) {
|
|
168
187
|
// Started from the list of the last time: what else it says is of now.
|
|
169
188
|
run.loaded = { ...run.loaded, info };
|
|
170
189
|
return true;
|
|
@@ -193,10 +212,12 @@ class WebExtensionsRunning {
|
|
|
193
212
|
return false;
|
|
194
213
|
}
|
|
195
214
|
this.keptStarted = true;
|
|
196
|
-
const infos = this.code
|
|
215
|
+
const infos = this.code
|
|
216
|
+
.list(host)
|
|
217
|
+
.filter(info => info.enabled !== false && info.activation !== 'open' && !this.running.has(info.id) && web_access_1.WebAccessUtil.granted(info) !== undefined);
|
|
197
218
|
const loads = await Promise.all(infos.map(async (info) => {
|
|
198
219
|
const code = await this.code.get(info.hash);
|
|
199
|
-
return code === undefined ? undefined :
|
|
220
|
+
return code === undefined ? undefined : this.factoryOf(info, code).catch(() => undefined);
|
|
200
221
|
}));
|
|
201
222
|
let started = false;
|
|
202
223
|
for (const [index, info] of infos.entries()) {
|
|
@@ -211,6 +232,55 @@ class WebExtensionsRunning {
|
|
|
211
232
|
}
|
|
212
233
|
return started;
|
|
213
234
|
}
|
|
235
|
+
/** Whether what runs is that of the list: the same code, allowed as much. */
|
|
236
|
+
same(run, info) {
|
|
237
|
+
return !!run && run.hash === info.hash && web_access_1.WebAccessUtil.granted(run.loaded.info) === web_access_1.WebAccessUtil.granted(info);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* It as it may start: allowed already, or allowed by the user now (docs/design/ta-extension-access.md); undefined
|
|
241
|
+
* when they did not allow it. Asked once at a time, and not again in this page once refused.
|
|
242
|
+
*/
|
|
243
|
+
async allow(info) {
|
|
244
|
+
var _a;
|
|
245
|
+
if (web_access_1.WebAccessUtil.granted(info) !== undefined) {
|
|
246
|
+
return info;
|
|
247
|
+
}
|
|
248
|
+
const key = `${info.id}:${info.hash}`;
|
|
249
|
+
// Trusted only as far as a web page (3.6): not asked, its row in the list says why.
|
|
250
|
+
if (info.held || this.refused.has(key)) {
|
|
251
|
+
return undefined;
|
|
252
|
+
}
|
|
253
|
+
const asked = (_a = this.asking.get(key)) !== null && _a !== void 0 ? _a : this.askAccess(info).finally(() => this.asking.delete(key));
|
|
254
|
+
this.asking.set(key, asked);
|
|
255
|
+
return (await asked) ? { ...info, granted: info.access } : undefined;
|
|
256
|
+
}
|
|
257
|
+
async askAccess(info) {
|
|
258
|
+
var _a;
|
|
259
|
+
const language = this.settings.state.language;
|
|
260
|
+
const say = (id) => (0, messages_1.message)(language, id);
|
|
261
|
+
const access = (_a = info.access) !== null && _a !== void 0 ? _a : 'full';
|
|
262
|
+
const yes = await this.notices.confirm({
|
|
263
|
+
title: say('ta.access.ask').replace('{name}', web_pages_1.WebPagesUtil.title(info, language)),
|
|
264
|
+
message: [
|
|
265
|
+
say(info.regrant ? 'ta.access.updated' : 'ta.access.new'),
|
|
266
|
+
say(`ta.access.${access}`),
|
|
267
|
+
say('ta.access.from').replace('{source}', web_access_1.WebAccessUtil.source(info, say)),
|
|
268
|
+
].join('\n'),
|
|
269
|
+
confirmLabel: say('ta.access.allow'),
|
|
270
|
+
});
|
|
271
|
+
if (!yes) {
|
|
272
|
+
this.refused.add(`${info.id}:${info.hash}`);
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
try {
|
|
276
|
+
await this.workbench.packages.grantAccess(info.id, access);
|
|
277
|
+
return true;
|
|
278
|
+
}
|
|
279
|
+
catch (error) {
|
|
280
|
+
this.notices.notify(say('ta.access.failed'), { level: 'error', detail: error instanceof Error ? error.message : String(error) });
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
214
284
|
/** Stops and forgets the extensions running that `keep` does not keep; whether there were any. */
|
|
215
285
|
stopUnless(keep) {
|
|
216
286
|
let stopped = false;
|
|
@@ -228,11 +298,11 @@ class WebExtensionsRunning {
|
|
|
228
298
|
try {
|
|
229
299
|
const kept = await this.code.get(info.hash);
|
|
230
300
|
if (kept !== undefined) {
|
|
231
|
-
return { factory: await
|
|
301
|
+
return { factory: await this.factoryOf(info, kept), hash: info.hash };
|
|
232
302
|
}
|
|
233
303
|
const { code, hash } = await this.workbench.packages.readWebExtension(info.id);
|
|
234
304
|
void this.code.set(hash, code);
|
|
235
|
-
const factory = await
|
|
305
|
+
const factory = await this.factoryOf(info, code);
|
|
236
306
|
// Read from the computer: what the user waits for the first time (kept code is quick).
|
|
237
307
|
this.metrics.record(info.name, 'web:load', false, performance.now() - start);
|
|
238
308
|
return { factory, hash };
|
|
@@ -242,6 +312,20 @@ class WebExtensionsRunning {
|
|
|
242
312
|
return { error: web_view_util_1.WebExtensionUtil.message(error) };
|
|
243
313
|
}
|
|
244
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* What starts an extension: its module, imported into the page; or, for one the user allowed less than all, its code
|
|
317
|
+
* to run in a sandbox, never imported here (docs/design/ta-extension-access.md 3).
|
|
318
|
+
*/
|
|
319
|
+
async factoryOf(info, code) {
|
|
320
|
+
const granted = web_access_1.WebAccessUtil.granted(info);
|
|
321
|
+
if (!web_sandbox_1.WebSandbox.applies(info, granted)) {
|
|
322
|
+
return web_view_util_1.WebExtensionUtil.load(code);
|
|
323
|
+
}
|
|
324
|
+
return web_sandbox_1.WebSandbox.factory(code, info, granted, {
|
|
325
|
+
options: this.persisted.get(sandbox_protocol_1.SandboxOptionsUtil.SPEC),
|
|
326
|
+
changes: listener => this.settings.subscribe(() => listener()),
|
|
327
|
+
});
|
|
328
|
+
}
|
|
245
329
|
startPackage(info, load) {
|
|
246
330
|
const loaded = { id: info.id, name: info.name, info };
|
|
247
331
|
if ('error' in load) {
|
|
@@ -252,6 +336,7 @@ class WebExtensionsRunning {
|
|
|
252
336
|
}
|
|
253
337
|
}
|
|
254
338
|
start(loaded, factory, hash) {
|
|
339
|
+
var _a;
|
|
255
340
|
const run = web_extension_run_1.WebExtensionRunUtil.create(loaded, hash);
|
|
256
341
|
this.running.set(loaded.id, run);
|
|
257
342
|
try {
|
|
@@ -259,6 +344,15 @@ class WebExtensionsRunning {
|
|
|
259
344
|
run.dispose = typeof dispose === 'function' ? dispose : undefined;
|
|
260
345
|
run.started = true;
|
|
261
346
|
this.metrics.record(loaded.id, 'web:start');
|
|
347
|
+
// One in a sandbox that could not start says why where it is listed, as one that threw (3.7).
|
|
348
|
+
(_a = factory.ready) === null || _a === void 0 ? void 0 : _a.catch(error => {
|
|
349
|
+
if (this.running.get(loaded.id) === run && !run.stopped) {
|
|
350
|
+
this.metrics.record(loaded.id, 'web:start', true);
|
|
351
|
+
this.stop(run);
|
|
352
|
+
run.loaded = { ...loaded, error: web_view_util_1.WebExtensionUtil.message(error) };
|
|
353
|
+
this.publish();
|
|
354
|
+
}
|
|
355
|
+
});
|
|
262
356
|
}
|
|
263
357
|
catch (error) {
|
|
264
358
|
this.metrics.record(loaded.id, 'web:start', true);
|
|
@@ -345,6 +439,10 @@ __decorate([
|
|
|
345
439
|
(0, core_1.Autowired)(screen_protocol_1.TaScreen),
|
|
346
440
|
__metadata("design:type", Object)
|
|
347
441
|
], WebExtensionsRunning.prototype, "screen", void 0);
|
|
442
|
+
__decorate([
|
|
443
|
+
(0, core_1.Autowired)(targets_protocol_1.TaTargets),
|
|
444
|
+
__metadata("design:type", Object)
|
|
445
|
+
], WebExtensionsRunning.prototype, "targets", void 0);
|
|
348
446
|
__decorate([
|
|
349
447
|
(0, core_1.Autowired)(web_extension_protocol_1.BuiltinWebExtension),
|
|
350
448
|
(0, core_1.Optional)(),
|
|
@@ -17,6 +17,11 @@ export interface WebPageInfo {
|
|
|
17
17
|
extension: string;
|
|
18
18
|
title: string;
|
|
19
19
|
icon?: WebIcon;
|
|
20
|
+
/**
|
|
21
|
+
* The colour of its tile, `--ta-tint-<tint>` and `--ta-tint-ink-<tint>` of the theme, the same for every page of its
|
|
22
|
+
* extension: the launcher's tile and the icon of its app (docs/design/ta-install-as-app.md). Newer than some Ta apps.
|
|
23
|
+
*/
|
|
24
|
+
tint?: number;
|
|
20
25
|
state: WebPageState;
|
|
21
26
|
/** Its extension starts when it opens (`pi.webActivation`, or temporary): it is never in the navigation. */
|
|
22
27
|
onOpen: boolean;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WebPagesUtil = void 0;
|
|
4
4
|
const ta_protocol_1 = require("@celljs/ta-protocol");
|
|
5
|
+
const tints_1 = require("../style/tints");
|
|
5
6
|
const icons_1 = require("./icons");
|
|
6
7
|
const web_extension_protocol_1 = require("./web-extension-protocol");
|
|
7
8
|
var WebPagesUtil;
|
|
@@ -71,6 +72,7 @@ var WebPagesUtil;
|
|
|
71
72
|
extension: view.id.slice(0, view.id.lastIndexOf('/')),
|
|
72
73
|
title: web_extension_protocol_1.WebLabelUtil.text(view.title),
|
|
73
74
|
icon: view.icon,
|
|
75
|
+
tint: tints_1.TintUtil.of(view.id.slice(0, view.id.lastIndexOf('/'))),
|
|
74
76
|
state: view.id === shown ? 'shown' : 'running',
|
|
75
77
|
onOpen: false,
|
|
76
78
|
place: placeOf(view),
|
|
@@ -86,6 +88,7 @@ var WebPagesUtil;
|
|
|
86
88
|
extension: info.name,
|
|
87
89
|
title: title(info, language, first ? web_extension_protocol_1.WebLabelUtil.text(first.title) : undefined),
|
|
88
90
|
icon: (_a = (info.icon ? icons_1.WEB_ICONS[info.icon] : undefined)) !== null && _a !== void 0 ? _a : first === null || first === void 0 ? void 0 : first.icon,
|
|
91
|
+
tint: tints_1.TintUtil.of(info.name),
|
|
89
92
|
state: isShown ? 'shown' : background ? 'background' : running ? 'running' : 'stopped',
|
|
90
93
|
onOpen: true,
|
|
91
94
|
place: info.temporary ? 'launcher' : listed(info, kinds) ? 'list' : 'discover',
|
|
@@ -93,6 +93,12 @@ export declare class GameControl {
|
|
|
93
93
|
press(at: GamePoint, ms: number): Promise<void>;
|
|
94
94
|
/** Presses a key for `ms`, on the game's element. */
|
|
95
95
|
key(key: GameKey, ms?: number): Promise<void>;
|
|
96
|
+
/** Half a tap, the pointer pressed (`down`) or let go there: for a program that times its own presses. */
|
|
97
|
+
pointerPress(at: GamePoint, down: boolean): void;
|
|
98
|
+
/** The pointer moved by `dx`, `dy` CSS pixels where it is, as a locked pointer turns a view (`movementX`, `movementY`). */
|
|
99
|
+
nudge(dx: number, dy: number): void;
|
|
100
|
+
/** Half a key press, down or up, on the game's element. */
|
|
101
|
+
keyPress(key: GameKey, down: boolean): void;
|
|
96
102
|
/** Where Ta's pointer is on the canvas, once it was there. */
|
|
97
103
|
get at(): GamePoint | undefined;
|
|
98
104
|
/**
|
|
@@ -188,6 +188,34 @@ class GameControl {
|
|
|
188
188
|
this.keyEvent('keyup', key);
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
+
/** Half a tap, the pointer pressed (`down`) or let go there: for a program that times its own presses. */
|
|
192
|
+
pointerPress(at, down) {
|
|
193
|
+
if (down) {
|
|
194
|
+
this.down(at);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
this.up(at, true);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/** The pointer moved by `dx`, `dy` CSS pixels where it is, as a locked pointer turns a view (`movementX`, `movementY`). */
|
|
201
|
+
nudge(dx, dy) {
|
|
202
|
+
var _a, _b;
|
|
203
|
+
const at = (_a = this.last) !== null && _a !== void 0 ? _a : { x: 0.5, y: 0.5 };
|
|
204
|
+
const canvas = this.canvas();
|
|
205
|
+
const view = this.view();
|
|
206
|
+
const init = { ...this.init(canvas, at, 0), movementX: dx, movementY: dy };
|
|
207
|
+
canvas.dispatchEvent(new ((_b = view.PointerEvent) !== null && _b !== void 0 ? _b : view.MouseEvent)('pointermove', {
|
|
208
|
+
...init,
|
|
209
|
+
pointerId: GameControlUtil.POINTER_ID,
|
|
210
|
+
pointerType: 'mouse',
|
|
211
|
+
isPrimary: true,
|
|
212
|
+
}));
|
|
213
|
+
canvas.dispatchEvent(new view.MouseEvent('mousemove', init));
|
|
214
|
+
}
|
|
215
|
+
/** Half a key press, down or up, on the game's element. */
|
|
216
|
+
keyPress(key, down) {
|
|
217
|
+
this.keyEvent(down ? 'keydown' : 'keyup', key);
|
|
218
|
+
}
|
|
191
219
|
/** Where Ta's pointer is on the canvas, once it was there. */
|
|
192
220
|
get at() {
|
|
193
221
|
return this.last;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type TaScreen } from '../screen/screen-protocol';
|
|
3
3
|
import type { TaSettings } from '../settings/settings-protocol';
|
|
4
|
-
import type {
|
|
4
|
+
import type { TaTargets } from '../targets/targets-protocol';
|
|
5
|
+
import type { GameObservation, GamePage, GameState } from './game-protocol';
|
|
5
6
|
/** What GameHost drives of a game of either engine (GameRunner, Game3DRunner). */
|
|
6
7
|
export interface GameHostRunner {
|
|
7
8
|
setPage(page: GamePage): void;
|
|
@@ -12,6 +13,10 @@ export interface GameHostRunner {
|
|
|
12
13
|
readonly sleeping?: boolean;
|
|
13
14
|
/** What the game says of its round (GameState). */
|
|
14
15
|
state?(): GameState | undefined;
|
|
16
|
+
/** What is in it now, for a program that plays it (GameObservation). */
|
|
17
|
+
observe?(): GameObservation | undefined;
|
|
18
|
+
/** Waits for a slow player, and goes on. */
|
|
19
|
+
setPaused?(paused: boolean): void;
|
|
15
20
|
dispose(): void;
|
|
16
21
|
}
|
|
17
22
|
/** Starts the game in `element` once its engine is loaded; `fail` for what goes wrong after it started. */
|
|
@@ -23,6 +28,8 @@ export interface GameHostProps {
|
|
|
23
28
|
title?: string;
|
|
24
29
|
/** The screen it is a part of, for Ta to see and play it; none on a page Ta does not work (a shared page). */
|
|
25
30
|
screen?: TaScreen;
|
|
31
|
+
/** The targets of the page, for a program to play it frame by frame (docs/design/ta-reflex.md); none where none plays. */
|
|
32
|
+
targets?: TaTargets;
|
|
26
33
|
className?: string;
|
|
27
34
|
style?: React.CSSProperties;
|
|
28
35
|
}
|
|
@@ -36,5 +43,5 @@ export interface GameHostProps {
|
|
|
36
43
|
* It is a part of the screen (`game`, GameControl): Ta sees how it stands and taps, moves, presses keys and holds on it
|
|
37
44
|
* for the user, by events on its canvas that no gesture of the shell starts from.
|
|
38
45
|
*/
|
|
39
|
-
export declare function GameHost({ settings: store, start, title, screen, className, style }: GameHostProps): React.JSX.Element;
|
|
46
|
+
export declare function GameHost({ settings: store, start, title, screen, targets, className, style }: GameHostProps): React.JSX.Element;
|
|
40
47
|
//# sourceMappingURL=game-host.d.ts.map
|
|
@@ -42,6 +42,7 @@ const own_gestures_1 = require("../device/own-gestures");
|
|
|
42
42
|
const use_t_1 = require("../i18n/use-t");
|
|
43
43
|
const screen_protocol_1 = require("../screen/screen-protocol");
|
|
44
44
|
const game_control_1 = require("./game-control");
|
|
45
|
+
const game_target_1 = require("./game-target");
|
|
45
46
|
const game_util_1 = require("./game-util");
|
|
46
47
|
/**
|
|
47
48
|
* The element of a game of a web extension (`ui.Game`, `ui.Game3D`): it fills its parent, starts the game
|
|
@@ -53,7 +54,7 @@ const game_util_1 = require("./game-util");
|
|
|
53
54
|
* It is a part of the screen (`game`, GameControl): Ta sees how it stands and taps, moves, presses keys and holds on it
|
|
54
55
|
* for the user, by events on its canvas that no gesture of the shell starts from.
|
|
55
56
|
*/
|
|
56
|
-
function GameHost({ settings: store, start, title, screen, className, style }) {
|
|
57
|
+
function GameHost({ settings: store, start, title, screen, targets, className, style }) {
|
|
57
58
|
var _a;
|
|
58
59
|
const t = (0, use_t_1.useT)();
|
|
59
60
|
const settings = React.useSyncExternalStore(listener => store.subscribe(listener), () => store.state);
|
|
@@ -76,6 +77,9 @@ function GameHost({ settings: store, start, title, screen, className, style }) {
|
|
|
76
77
|
(_a = partId.current) !== null && _a !== void 0 ? _a : (partId.current = game_control_1.GameControlUtil.partId());
|
|
77
78
|
part.current = game_control_1.GameControl.spec(partId.current, title || t('ta.game.label'), { point: t('ta.game.point'), move: t('ta.game.move'), key: t('ta.game.key'), hold: t('ta.game.hold') }, () => { var _a, _b, _c; return ({ started: !!runner.current, sleeping: (_a = runner.current) === null || _a === void 0 ? void 0 : _a.sleeping, error: errorOf.current, state: (_c = (_b = runner.current) === null || _b === void 0 ? void 0 : _b.state) === null || _c === void 0 ? void 0 : _c.call(_b) }); }, () => control.current);
|
|
78
79
|
React.useEffect(() => screen === null || screen === void 0 ? void 0 : screen.register(() => part.current), [screen]);
|
|
80
|
+
const named = React.useRef(title);
|
|
81
|
+
named.current = title || t('ta.game.label');
|
|
82
|
+
React.useEffect(() => targets === null || targets === void 0 ? void 0 : targets.register(game_target_1.GameTarget.spec(partId.current, () => named.current, () => runner.current, () => control.current)), [targets]);
|
|
79
83
|
React.useEffect(() => {
|
|
80
84
|
const element = host.current;
|
|
81
85
|
if (!element) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TargetObservation } from '@celljs/ta-protocol';
|
|
1
2
|
import type * as PhaserModule from 'phaser';
|
|
2
3
|
import type { Theme } from '../settings/settings-protocol';
|
|
3
4
|
/**
|
|
@@ -43,6 +44,13 @@ export interface GameState {
|
|
|
43
44
|
score?: number;
|
|
44
45
|
over?: boolean;
|
|
45
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* What is in a game now, for a program to play it frame by frame (docs/design/ta-reflex.md 4): its things as entities
|
|
49
|
+
* (`{ id, type, box }`, a box from 0 to 1 across and down the canvas, as the player sees it) and what else it says
|
|
50
|
+
* (`data`: the score, the round). A Phaser game sets a function giving it in its registry (GameUtil.OBSERVE_KEY), a
|
|
51
|
+
* 3D one returns it from `observe` of its loop. Read every frame while a program plays: cheap, no allocation it can spare.
|
|
52
|
+
*/
|
|
53
|
+
export type GameObservation = Omit<TargetObservation, 't'>;
|
|
46
54
|
/** A point of the canvas: `x` 0 at its left and 1 at its right, `y` 0 at its top and 1 at its bottom (GameControl). */
|
|
47
55
|
export interface GamePoint {
|
|
48
56
|
x: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GameConfig, GameEngine, GameInstance, GamePage, GameState } from './game-protocol';
|
|
1
|
+
import type { GameConfig, GameEngine, GameInstance, GameObservation, GamePage, GameState } from './game-protocol';
|
|
2
2
|
/**
|
|
3
3
|
* One game in an element of the page, from its start to its end: Phaser's Game made with the config of the
|
|
4
4
|
* extension (GameUtil.config), asleep while the element is out of sight, destroyed with it.
|
|
@@ -12,15 +12,21 @@ export declare class GameRunner {
|
|
|
12
12
|
readonly game: GameInstance;
|
|
13
13
|
protected page?: GamePage;
|
|
14
14
|
protected asleep: boolean;
|
|
15
|
+
protected paused: boolean;
|
|
15
16
|
protected disposed: boolean;
|
|
16
17
|
constructor(engine: GameEngine, config: GameConfig, element: HTMLElement, page: GamePage, fail?: (error: unknown) => void);
|
|
17
18
|
/** Sets the page in the game's registry when it changed: scenes hear `changedata-page`. */
|
|
18
19
|
setPage(page: GamePage): void;
|
|
19
20
|
/** What the game set of its round in its registry (GameUtil.SCORE_KEY, GameUtil.OVER_KEY). */
|
|
20
21
|
state(): GameState | undefined;
|
|
22
|
+
/** What the game says is in it now (GameUtil.OBSERVE_KEY); nothing when it says nothing or that throws. */
|
|
23
|
+
observe(): GameObservation | undefined;
|
|
21
24
|
get sleeping(): boolean;
|
|
22
25
|
/** Whether the element can be seen: the game sleeps while not. */
|
|
23
26
|
setVisible(visible: boolean): void;
|
|
27
|
+
/** Waits for a slow player (a program's commander thinking): asleep as out of sight, till it goes on. */
|
|
28
|
+
setPaused(paused: boolean): void;
|
|
29
|
+
protected apply(): void;
|
|
24
30
|
/**
|
|
25
31
|
* Destroys the game and takes its canvas out. Phaser destroys it at the end of its next frame: a loop
|
|
26
32
|
* asleep is woken for it, and a game not booted yet is destroyed as it boots.
|
|
@@ -15,6 +15,7 @@ class GameRunner {
|
|
|
15
15
|
constructor(engine, config, element, page, fail) {
|
|
16
16
|
this.element = element;
|
|
17
17
|
this.asleep = false;
|
|
18
|
+
this.paused = false;
|
|
18
19
|
this.disposed = false;
|
|
19
20
|
this.game = new engine.Game(game_util_1.GameUtil.config(engine, config, element, fail));
|
|
20
21
|
this.setPage(page);
|
|
@@ -32,6 +33,16 @@ class GameRunner {
|
|
|
32
33
|
const { registry } = this.game;
|
|
33
34
|
return this.disposed ? undefined : game_control_1.GameControlUtil.state({ score: registry.get(game_util_1.GameUtil.SCORE_KEY), over: registry.get(game_util_1.GameUtil.OVER_KEY) });
|
|
34
35
|
}
|
|
36
|
+
/** What the game says is in it now (GameUtil.OBSERVE_KEY); nothing when it says nothing or that throws. */
|
|
37
|
+
observe() {
|
|
38
|
+
const observe = this.disposed ? undefined : this.game.registry.get(game_util_1.GameUtil.OBSERVE_KEY);
|
|
39
|
+
try {
|
|
40
|
+
return typeof observe === 'function' ? observe() : undefined;
|
|
41
|
+
}
|
|
42
|
+
catch (_a) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
35
46
|
get sleeping() {
|
|
36
47
|
return this.asleep;
|
|
37
48
|
}
|
|
@@ -41,8 +52,19 @@ class GameRunner {
|
|
|
41
52
|
return;
|
|
42
53
|
}
|
|
43
54
|
this.asleep = !visible;
|
|
55
|
+
this.apply();
|
|
56
|
+
}
|
|
57
|
+
/** Waits for a slow player (a program's commander thinking): asleep as out of sight, till it goes on. */
|
|
58
|
+
setPaused(paused) {
|
|
59
|
+
if (this.disposed || paused === this.paused) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
this.paused = paused;
|
|
63
|
+
this.apply();
|
|
64
|
+
}
|
|
65
|
+
apply() {
|
|
44
66
|
const { loop, sound } = this.game;
|
|
45
|
-
if (this.asleep) {
|
|
67
|
+
if (this.asleep || this.paused) {
|
|
46
68
|
loop.sleep();
|
|
47
69
|
sound === null || sound === void 0 ? void 0 : sound.pauseAll();
|
|
48
70
|
}
|
|
@@ -61,7 +83,7 @@ class GameRunner {
|
|
|
61
83
|
}
|
|
62
84
|
this.disposed = true;
|
|
63
85
|
this.game.destroy(true);
|
|
64
|
-
if (this.asleep && this.game.isRunning) {
|
|
86
|
+
if ((this.asleep || this.paused) && this.game.isRunning) {
|
|
65
87
|
this.game.loop.wake();
|
|
66
88
|
}
|
|
67
89
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { TargetAction } from '@celljs/ta-protocol';
|
|
2
|
+
import type { TargetSpec } from '../targets/targets-protocol';
|
|
3
|
+
import { type GameControl } from './game-control';
|
|
4
|
+
import type { GameObservation, GameState } from './game-protocol';
|
|
5
|
+
/** What GameTarget reads of a game while it runs: none before it started or after it ended. */
|
|
6
|
+
export interface GameTargetRunner {
|
|
7
|
+
observe?(): GameObservation | undefined;
|
|
8
|
+
state?(): GameState | undefined;
|
|
9
|
+
setPaused?(paused: boolean): void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A game as a target (docs/design/ta-reflex.md 4): what it says is in it (GameObservation, its score and round besides),
|
|
13
|
+
* and the actions of every target done by its hands (GameControl), at once: a tap's release and a key's come after,
|
|
14
|
+
* by a timer, so that a program never waits on them.
|
|
15
|
+
*/
|
|
16
|
+
export declare namespace GameTarget {
|
|
17
|
+
const HZ = 60;
|
|
18
|
+
function spec(id: string, title: () => string, runner: () => GameTargetRunner | undefined, control: () => GameControl | undefined): TargetSpec;
|
|
19
|
+
function observation(runner: GameTargetRunner | undefined): GameObservation;
|
|
20
|
+
/** One action of the vocabulary of targets on the game; throws for one it cannot take, as its part does. */
|
|
21
|
+
function act(hands: GameControl, action: TargetAction, later?: (run: () => void, ms: number) => void): void;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=game-target.d.ts.map
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GameTarget = void 0;
|
|
4
|
+
const game_control_1 = require("./game-control");
|
|
5
|
+
const clamp = (value) => Math.min(1, Math.max(0, value));
|
|
6
|
+
/**
|
|
7
|
+
* A game as a target (docs/design/ta-reflex.md 4): what it says is in it (GameObservation, its score and round besides),
|
|
8
|
+
* and the actions of every target done by its hands (GameControl), at once: a tap's release and a key's come after,
|
|
9
|
+
* by a timer, so that a program never waits on them.
|
|
10
|
+
*/
|
|
11
|
+
var GameTarget;
|
|
12
|
+
(function (GameTarget) {
|
|
13
|
+
GameTarget.HZ = 60;
|
|
14
|
+
function spec(id, title, runner, control) {
|
|
15
|
+
return {
|
|
16
|
+
id,
|
|
17
|
+
kind: 'game',
|
|
18
|
+
title,
|
|
19
|
+
tier: 'state',
|
|
20
|
+
actions: ['pointer', 'key'],
|
|
21
|
+
hz: GameTarget.HZ,
|
|
22
|
+
describe: 'entities: what the game shows, each {id, type, box: {x, y, w, h} from 0 to 1 across and down the canvas}; data: its score, its round, what else it says',
|
|
23
|
+
observe: () => observation(runner()),
|
|
24
|
+
act: actions => {
|
|
25
|
+
const hands = control();
|
|
26
|
+
if (hands && runner()) {
|
|
27
|
+
for (const action of actions) {
|
|
28
|
+
act(hands, action);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
pause: () => { var _a, _b; return (_b = (_a = runner()) === null || _a === void 0 ? void 0 : _a.setPaused) === null || _b === void 0 ? void 0 : _b.call(_a, true); },
|
|
33
|
+
resume: () => { var _a, _b; return (_b = (_a = runner()) === null || _a === void 0 ? void 0 : _a.setPaused) === null || _b === void 0 ? void 0 : _b.call(_a, false); },
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
GameTarget.spec = spec;
|
|
37
|
+
function observation(runner) {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
var _c;
|
|
40
|
+
const seen = (_a = runner === null || runner === void 0 ? void 0 : runner.observe) === null || _a === void 0 ? void 0 : _a.call(runner);
|
|
41
|
+
const state = (_b = runner === null || runner === void 0 ? void 0 : runner.state) === null || _b === void 0 ? void 0 : _b.call(runner);
|
|
42
|
+
const data = { ...(state !== null && state !== void 0 ? state : {}), ...((_c = seen === null || seen === void 0 ? void 0 : seen.data) !== null && _c !== void 0 ? _c : {}) };
|
|
43
|
+
return { ...((seen === null || seen === void 0 ? void 0 : seen.entities) ? { entities: seen.entities } : {}), ...(Object.keys(data).length ? { data } : {}) };
|
|
44
|
+
}
|
|
45
|
+
GameTarget.observation = observation;
|
|
46
|
+
/** One action of the vocabulary of targets on the game; throws for one it cannot take, as its part does. */
|
|
47
|
+
function act(hands, action, later = (run, ms) => setTimeout(run, ms)) {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
50
|
+
if (action.kind === 'pointer') {
|
|
51
|
+
if (action.dx !== undefined || action.dy !== undefined) {
|
|
52
|
+
hands.nudge((_c = action.dx) !== null && _c !== void 0 ? _c : 0, (_d = action.dy) !== null && _d !== void 0 ? _d : 0);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const at = action.x === undefined && action.y === undefined
|
|
56
|
+
? ((_e = hands.at) !== null && _e !== void 0 ? _e : { x: 0.5, y: 0.5 })
|
|
57
|
+
: { x: clamp((_g = (_f = action.x) !== null && _f !== void 0 ? _f : (_a = hands.at) === null || _a === void 0 ? void 0 : _a.x) !== null && _g !== void 0 ? _g : 0.5), y: clamp((_j = (_h = action.y) !== null && _h !== void 0 ? _h : (_b = hands.at) === null || _b === void 0 ? void 0 : _b.y) !== null && _j !== void 0 ? _j : 0.5) };
|
|
58
|
+
const press = (_k = action.press) !== null && _k !== void 0 ? _k : 'click';
|
|
59
|
+
if (press === 'move') {
|
|
60
|
+
void hands.move(at);
|
|
61
|
+
}
|
|
62
|
+
else if (press === 'click') {
|
|
63
|
+
hands.pointerPress(at, true);
|
|
64
|
+
later(() => hands.pointerPress(at, false), game_control_1.GameControlUtil.TAP_MS);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
hands.pointerPress(at, press === 'down');
|
|
68
|
+
}
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (action.kind === 'key') {
|
|
72
|
+
const key = game_control_1.GameControlUtil.key(action.key);
|
|
73
|
+
const press = (_l = action.press) !== null && _l !== void 0 ? _l : 'tap';
|
|
74
|
+
if (press === 'tap') {
|
|
75
|
+
hands.keyPress(key, true);
|
|
76
|
+
later(() => hands.keyPress(key, false), (_m = action.ms) !== null && _m !== void 0 ? _m : game_control_1.GameControlUtil.TAP_MS);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
hands.keyPress(key, press === 'down');
|
|
80
|
+
}
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
throw new Error(`A game takes pointer and key actions, not ${action.kind}.`);
|
|
84
|
+
}
|
|
85
|
+
GameTarget.act = act;
|
|
86
|
+
})(GameTarget || (exports.GameTarget = GameTarget = {}));
|
|
87
|
+
//# sourceMappingURL=game-target.js.map
|
|
@@ -6,6 +6,8 @@ export declare namespace GameUtil {
|
|
|
6
6
|
/** The keys of the registry where a game says its score and whether its round is over (GameState): Ta tells the agent. */
|
|
7
7
|
const SCORE_KEY = "score";
|
|
8
8
|
const OVER_KEY = "over";
|
|
9
|
+
/** The key of the registry where a game sets a function giving what is in it now (GameObservation). */
|
|
10
|
+
const OBSERVE_KEY = "observe";
|
|
9
11
|
/**
|
|
10
12
|
* Phaser's config of a game drawn in `parent`: what the extension gave, over what a game in a page of Ta
|
|
11
13
|
* needs. It fills `parent` unless sized; its background is the page's unless it has one; it hears the
|
|
@@ -34,6 +34,8 @@ var GameUtil;
|
|
|
34
34
|
/** The keys of the registry where a game says its score and whether its round is over (GameState): Ta tells the agent. */
|
|
35
35
|
GameUtil.SCORE_KEY = 'score';
|
|
36
36
|
GameUtil.OVER_KEY = 'over';
|
|
37
|
+
/** The key of the registry where a game sets a function giving what is in it now (GameObservation). */
|
|
38
|
+
GameUtil.OBSERVE_KEY = 'observe';
|
|
37
39
|
/**
|
|
38
40
|
* Phaser's config of a game drawn in `parent`: what the extension gave, over what a game in a page of Ta
|
|
39
41
|
* needs. It fills `parent` unless sized; its background is the page's unless it has one; it hears the
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { TaScreen } from '../screen/screen-protocol';
|
|
3
3
|
import type { TaSettings } from '../settings/settings-protocol';
|
|
4
|
+
import type { TaTargets } from '../targets/targets-protocol';
|
|
4
5
|
import type { GameProps } from './game-protocol';
|
|
5
6
|
import type { Game3DProps } from './game3d-protocol';
|
|
6
7
|
/** A game of a web extension on Phaser (`ui.Game`): GameRunner in a GameHost. */
|
|
7
|
-
export declare function GameView({ settings, screen, config, onReady, title, className, style }: GameProps & {
|
|
8
|
+
export declare function GameView({ settings, screen, targets, config, onReady, title, className, style, }: GameProps & {
|
|
8
9
|
settings: TaSettings;
|
|
9
10
|
screen?: TaScreen;
|
|
11
|
+
targets?: TaTargets;
|
|
10
12
|
}): React.JSX.Element;
|
|
11
13
|
/** A 3D game of a web extension on Three.js (`ui.Game3D`): Game3DRunner in a GameHost. */
|
|
12
|
-
export declare function Game3DView({ settings, screen, setup, onReady, title, className, style }: Game3DProps & {
|
|
14
|
+
export declare function Game3DView({ settings, screen, targets, setup, onReady, title, className, style, }: Game3DProps & {
|
|
13
15
|
settings: TaSettings;
|
|
14
16
|
screen?: TaScreen;
|
|
17
|
+
targets?: TaTargets;
|
|
15
18
|
}): React.JSX.Element;
|
|
16
19
|
//# sourceMappingURL=game-view.d.ts.map
|