@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
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
var _a, _b, _c, _d;
|
|
2
|
+
const SETTERS = {
|
|
3
|
+
input: (_a = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')) === null || _a === void 0 ? void 0 : _a.set,
|
|
4
|
+
textarea: (_b = Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, 'value')) === null || _b === void 0 ? void 0 : _b.set,
|
|
5
|
+
select: (_c = Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype, 'value')) === null || _c === void 0 ? void 0 : _c.set,
|
|
6
|
+
checked: (_d = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'checked')) === null || _d === void 0 ? void 0 : _d.set,
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* The sandbox's side of the copies (docs/design/ta-extension-access.md 3.4): the DOM under each root watched and sent
|
|
10
|
+
* as operations in batches, a frame at a time; the values of fields, which no mutation tells of, compared as it sends;
|
|
11
|
+
* `<style>` sent as written (the page scopes it); what the user did to a copy done again here, so that the extension's own React
|
|
12
|
+
* hears it as it would in the page. It knows nothing of the API.
|
|
13
|
+
*/
|
|
14
|
+
export class RemoteMirror {
|
|
15
|
+
constructor(sink) {
|
|
16
|
+
this.sink = sink;
|
|
17
|
+
this.nextId = 1;
|
|
18
|
+
this.ids = new WeakMap();
|
|
19
|
+
this.nodes = new Map();
|
|
20
|
+
this.roots = new Map();
|
|
21
|
+
this.fields = new Map();
|
|
22
|
+
this.blobs = new Map();
|
|
23
|
+
this.scheduled = false;
|
|
24
|
+
this.submitting = false;
|
|
25
|
+
// A form submits by what the page tells (submit): the sandbox's own submission of a click is not the user's.
|
|
26
|
+
addEventListener('submit', event => {
|
|
27
|
+
if (!this.submitting) {
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
event.stopImmediatePropagation();
|
|
30
|
+
}
|
|
31
|
+
}, true);
|
|
32
|
+
addEventListener('click', event => {
|
|
33
|
+
const link = event.target instanceof Element ? event.target.closest('a[href]') : null;
|
|
34
|
+
if (!event.defaultPrevented && link) {
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
this.sink.link(link.href);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/** The styles of the head (an extension that adds its own `<style>`, as in the page), sent whole as they change. */
|
|
41
|
+
observeHead() {
|
|
42
|
+
const send = () => this.sink.styles(Array.from(document.head.querySelectorAll('style'))
|
|
43
|
+
.map(style => { var _a; return (_a = style.textContent) !== null && _a !== void 0 ? _a : ''; })
|
|
44
|
+
.join('\n'));
|
|
45
|
+
new MutationObserver(send).observe(document.head, { childList: true, subtree: true, characterData: true });
|
|
46
|
+
send();
|
|
47
|
+
}
|
|
48
|
+
/** Watches `container` as the root `root`: what is in it now is sent at once. */
|
|
49
|
+
observe(root, container) {
|
|
50
|
+
const observer = new MutationObserver(records => this.changed(root, records));
|
|
51
|
+
observer.observe(container, { childList: true, subtree: true, attributes: true, characterData: true });
|
|
52
|
+
this.roots.set(root, { container, observer, pending: [] });
|
|
53
|
+
this.ids.set(container, 0);
|
|
54
|
+
for (const child of Array.from(container.childNodes)) {
|
|
55
|
+
this.queue(root, this.inserted(root, child, 0));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
stop(root) {
|
|
59
|
+
const found = this.roots.get(root);
|
|
60
|
+
if (!found) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
found.observer.disconnect();
|
|
64
|
+
this.roots.delete(root);
|
|
65
|
+
for (const child of Array.from(found.container.childNodes))
|
|
66
|
+
this.forget(child);
|
|
67
|
+
for (const [field, kept] of this.fields) {
|
|
68
|
+
if (kept.root === root) {
|
|
69
|
+
this.fields.delete(field);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/** Does again what the user did to the copy of a node. */
|
|
74
|
+
dispatch(event) {
|
|
75
|
+
var _a, _b, _c, _d;
|
|
76
|
+
const node = this.nodes.get(event.i);
|
|
77
|
+
if (!(node instanceof Element)) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const field = this.fields.get(node);
|
|
81
|
+
if (event.files && node instanceof HTMLInputElement && node.type === 'file' && typeof DataTransfer !== 'undefined') {
|
|
82
|
+
const files = new DataTransfer();
|
|
83
|
+
for (const file of event.files)
|
|
84
|
+
files.items.add(file);
|
|
85
|
+
node.files = files.files;
|
|
86
|
+
}
|
|
87
|
+
// A click toggles a box there as here; only what was typed or chosen sets a value.
|
|
88
|
+
if (field && (event.type === 'input' || event.type === 'change') && event.value !== undefined) {
|
|
89
|
+
this.setValue(node, event.value, event.checked);
|
|
90
|
+
field.value = event.value;
|
|
91
|
+
field.checked = event.checked === true;
|
|
92
|
+
field.seq = Math.max(field.seq, (_a = event.seq) !== null && _a !== void 0 ? _a : 0);
|
|
93
|
+
}
|
|
94
|
+
const init = { bubbles: true, cancelable: true, composed: true };
|
|
95
|
+
const keys = { altKey: event.alt, ctrlKey: event.ctrl, metaKey: event.meta, shiftKey: event.shift };
|
|
96
|
+
const box = node.getBoundingClientRect();
|
|
97
|
+
const mouse = { ...init, ...keys, button: (_b = event.button) !== null && _b !== void 0 ? _b : 0, clientX: box.left + ((_c = event.x) !== null && _c !== void 0 ? _c : 0), clientY: box.top + ((_d = event.y) !== null && _d !== void 0 ? _d : 0) };
|
|
98
|
+
switch (event.type) {
|
|
99
|
+
case 'click':
|
|
100
|
+
case 'dblclick':
|
|
101
|
+
node.dispatchEvent(new MouseEvent(event.type, mouse));
|
|
102
|
+
break;
|
|
103
|
+
case 'pointerdown':
|
|
104
|
+
case 'pointerup':
|
|
105
|
+
case 'pointermove':
|
|
106
|
+
node.dispatchEvent(new PointerEvent(event.type, { ...mouse, pointerId: 1, isPrimary: true }));
|
|
107
|
+
break;
|
|
108
|
+
case 'keydown':
|
|
109
|
+
case 'keyup':
|
|
110
|
+
node.dispatchEvent(new KeyboardEvent(event.type, { ...init, ...keys, key: event.key, code: event.code }));
|
|
111
|
+
break;
|
|
112
|
+
case 'focusin':
|
|
113
|
+
case 'focusout':
|
|
114
|
+
node.dispatchEvent(new FocusEvent(event.type, { bubbles: true, composed: true }));
|
|
115
|
+
break;
|
|
116
|
+
case 'submit':
|
|
117
|
+
this.submitting = true;
|
|
118
|
+
try {
|
|
119
|
+
node.dispatchEvent(new SubmitEvent('submit', init));
|
|
120
|
+
}
|
|
121
|
+
finally {
|
|
122
|
+
this.submitting = false;
|
|
123
|
+
}
|
|
124
|
+
break;
|
|
125
|
+
default:
|
|
126
|
+
node.dispatchEvent(new Event(event.type, init));
|
|
127
|
+
}
|
|
128
|
+
this.schedule();
|
|
129
|
+
}
|
|
130
|
+
setValue(field, value, checked) {
|
|
131
|
+
var _a;
|
|
132
|
+
if (field instanceof HTMLInputElement && (field.type === 'checkbox' || field.type === 'radio')) {
|
|
133
|
+
(_a = SETTERS.checked) === null || _a === void 0 ? void 0 : _a.call(field, checked === true);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
// The setter of the prototype: React's tracker of the value sees it changed, and its onChange runs.
|
|
137
|
+
const setter = field instanceof HTMLTextAreaElement ? SETTERS.textarea : field instanceof HTMLSelectElement ? SETTERS.select : SETTERS.input;
|
|
138
|
+
if (!(field instanceof HTMLInputElement && field.type === 'file')) {
|
|
139
|
+
setter === null || setter === void 0 ? void 0 : setter.call(field, value);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
changed(root, records) {
|
|
143
|
+
for (const record of records) {
|
|
144
|
+
const target = record.target;
|
|
145
|
+
if (record.type === 'characterData') {
|
|
146
|
+
const parent = target.parentNode;
|
|
147
|
+
if (parent instanceof HTMLStyleElement) {
|
|
148
|
+
this.styleText(root, parent);
|
|
149
|
+
}
|
|
150
|
+
else if (this.ids.has(target)) {
|
|
151
|
+
this.queue(root, [{ o: 'text', i: this.ids.get(target), t: target.data }]);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
else if (record.type === 'attributes' && target instanceof Element && this.ids.has(target)) {
|
|
155
|
+
const name = record.attributeName;
|
|
156
|
+
this.queue(root, this.attribute(target, name));
|
|
157
|
+
}
|
|
158
|
+
else if (record.type === 'childList') {
|
|
159
|
+
if (target instanceof HTMLStyleElement) {
|
|
160
|
+
this.styleText(root, target);
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
for (const node of Array.from(record.removedNodes)) {
|
|
164
|
+
const id = this.ids.get(node);
|
|
165
|
+
if (id !== undefined) {
|
|
166
|
+
this.forget(node);
|
|
167
|
+
this.queue(root, [{ o: 'rm', i: id }]);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
const parent = this.ids.get(target);
|
|
171
|
+
if (parent === undefined) {
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
for (const node of Array.from(record.addedNodes)) {
|
|
175
|
+
if (node.parentNode !== target || this.ids.has(node)) {
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
let next = node.nextSibling;
|
|
179
|
+
while (next && !this.ids.has(next))
|
|
180
|
+
next = next.nextSibling;
|
|
181
|
+
this.queue(root, this.inserted(root, node, parent, next ? this.ids.get(next) : 0));
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
inserted(root, node, parent, before = 0) {
|
|
187
|
+
const blobs = [];
|
|
188
|
+
const made = this.describe(root, node, blobs);
|
|
189
|
+
return made ? [{ o: 'ins', p: parent, b: before, node: made }, ...blobs] : [];
|
|
190
|
+
}
|
|
191
|
+
describe(root, node, blobs) {
|
|
192
|
+
var _a;
|
|
193
|
+
if (node instanceof Text) {
|
|
194
|
+
const i = this.keep(node);
|
|
195
|
+
return { i, n: '#text', t: node.data };
|
|
196
|
+
}
|
|
197
|
+
if (!(node instanceof Element)) {
|
|
198
|
+
return undefined;
|
|
199
|
+
}
|
|
200
|
+
const i = this.keep(node);
|
|
201
|
+
const n = node.namespaceURI === 'http://www.w3.org/2000/svg' ? node.localName : node.localName.toLowerCase();
|
|
202
|
+
const remote = { i, n };
|
|
203
|
+
if (node instanceof SVGElement) {
|
|
204
|
+
remote.s = 1;
|
|
205
|
+
}
|
|
206
|
+
if (node instanceof HTMLStyleElement) {
|
|
207
|
+
remote.t = (_a = node.textContent) !== null && _a !== void 0 ? _a : '';
|
|
208
|
+
return remote;
|
|
209
|
+
}
|
|
210
|
+
const attributes = {};
|
|
211
|
+
for (const attribute of Array.from(node.attributes)) {
|
|
212
|
+
if (attribute.value.startsWith('blob:')) {
|
|
213
|
+
this.blob(i, attribute.name, attribute.value);
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
attributes[attribute.name] = attribute.value;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if (Object.keys(attributes).length) {
|
|
220
|
+
remote.a = attributes;
|
|
221
|
+
}
|
|
222
|
+
if (node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement || node instanceof HTMLSelectElement) {
|
|
223
|
+
this.fields.set(node, { root, value: node.value, checked: node instanceof HTMLInputElement && node.checked, seq: 0 });
|
|
224
|
+
this.watchFields();
|
|
225
|
+
if (node.value) {
|
|
226
|
+
blobs.push({ o: 'prop', i, k: 'value', v: node.value });
|
|
227
|
+
}
|
|
228
|
+
if (node instanceof HTMLInputElement && node.checked) {
|
|
229
|
+
blobs.push({ o: 'prop', i, k: 'checked', v: true });
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
const children = [];
|
|
233
|
+
for (const child of Array.from(node.childNodes)) {
|
|
234
|
+
const made = this.describe(root, child, blobs);
|
|
235
|
+
if (made) {
|
|
236
|
+
children.push(made);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
if (children.length) {
|
|
240
|
+
remote.c = children;
|
|
241
|
+
}
|
|
242
|
+
return remote;
|
|
243
|
+
}
|
|
244
|
+
attribute(element, name) {
|
|
245
|
+
const i = this.ids.get(element);
|
|
246
|
+
const value = element.getAttribute(name);
|
|
247
|
+
if (value === null || value === void 0 ? void 0 : value.startsWith('blob:')) {
|
|
248
|
+
this.blob(i, name, value);
|
|
249
|
+
return [];
|
|
250
|
+
}
|
|
251
|
+
return [{ o: 'attr', i, k: name, v: value }];
|
|
252
|
+
}
|
|
253
|
+
/** A `blob:` address of the sandbox, which the page cannot load: its Blob, sent when read. */
|
|
254
|
+
blob(i, name, url) {
|
|
255
|
+
let blob = this.blobs.get(url);
|
|
256
|
+
if (!blob) {
|
|
257
|
+
blob = fetch(url).then(response => response.blob(), () => undefined);
|
|
258
|
+
this.blobs.set(url, blob);
|
|
259
|
+
}
|
|
260
|
+
const node = this.nodes.get(i);
|
|
261
|
+
void blob.then(found => {
|
|
262
|
+
const root = this.rootOf(node);
|
|
263
|
+
if (found && root !== undefined && this.nodes.get(i) === node) {
|
|
264
|
+
this.queue(root, [{ o: 'blob', i, k: name, v: found }]);
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
rootOf(node) {
|
|
269
|
+
for (const [root, { container }] of this.roots) {
|
|
270
|
+
if (node && container.contains(node)) {
|
|
271
|
+
return root;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return undefined;
|
|
275
|
+
}
|
|
276
|
+
styleText(root, style) {
|
|
277
|
+
var _a;
|
|
278
|
+
const id = this.ids.get(style);
|
|
279
|
+
if (id !== undefined) {
|
|
280
|
+
this.queue(root, [{ o: 'text', i: id, t: (_a = style.textContent) !== null && _a !== void 0 ? _a : '' }]);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
keep(node) {
|
|
284
|
+
const id = this.nextId++;
|
|
285
|
+
this.ids.set(node, id);
|
|
286
|
+
this.nodes.set(id, node);
|
|
287
|
+
return id;
|
|
288
|
+
}
|
|
289
|
+
forget(node) {
|
|
290
|
+
const id = this.ids.get(node);
|
|
291
|
+
if (id !== undefined) {
|
|
292
|
+
this.ids.delete(node);
|
|
293
|
+
this.nodes.delete(id);
|
|
294
|
+
}
|
|
295
|
+
this.fields.delete(node);
|
|
296
|
+
for (const child of Array.from(node.childNodes))
|
|
297
|
+
this.forget(child);
|
|
298
|
+
}
|
|
299
|
+
queue(root, ops) {
|
|
300
|
+
const found = this.roots.get(root);
|
|
301
|
+
if (found && ops.length) {
|
|
302
|
+
found.pending.push(...ops);
|
|
303
|
+
this.schedule();
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
schedule() {
|
|
307
|
+
if (!this.scheduled) {
|
|
308
|
+
this.scheduled = true;
|
|
309
|
+
queueMicrotask(() => this.flush());
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
/** Fields whose value the extension set (React clears a box after it sent) tell no mutation: compared as it sends. */
|
|
313
|
+
watchFields() {
|
|
314
|
+
var _a;
|
|
315
|
+
(_a = this.poll) !== null && _a !== void 0 ? _a : (this.poll = setInterval(() => (this.fields.size ? this.schedule() : undefined), 250));
|
|
316
|
+
}
|
|
317
|
+
flush() {
|
|
318
|
+
var _a, _b;
|
|
319
|
+
this.scheduled = false;
|
|
320
|
+
for (const [field, kept] of this.fields) {
|
|
321
|
+
const i = this.ids.get(field);
|
|
322
|
+
if (i === undefined) {
|
|
323
|
+
continue;
|
|
324
|
+
}
|
|
325
|
+
if (field.value !== kept.value) {
|
|
326
|
+
kept.value = field.value;
|
|
327
|
+
(_a = this.roots.get(kept.root)) === null || _a === void 0 ? void 0 : _a.pending.push({ o: 'prop', i, k: 'value', v: field.value, q: kept.seq });
|
|
328
|
+
}
|
|
329
|
+
if (field instanceof HTMLInputElement && field.checked !== kept.checked) {
|
|
330
|
+
kept.checked = field.checked;
|
|
331
|
+
(_b = this.roots.get(kept.root)) === null || _b === void 0 ? void 0 : _b.pending.push({ o: 'prop', i, k: 'checked', v: field.checked, q: kept.seq });
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
for (const [root, found] of this.roots) {
|
|
335
|
+
if (found.pending.length) {
|
|
336
|
+
this.sink.ops(root, found.pending.splice(0));
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
//# sourceMappingURL=remote-mirror.js.map
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The DOM of a sandbox as it crosses to the page (docs/design/ta-extension-access.md 3.4): what the sandbox drew, as
|
|
3
|
+
* operations on nodes of ids of its own, and what the user did to the copy, as events. Data only.
|
|
4
|
+
*/
|
|
5
|
+
/** A node and what is under it. `n`: the tag (`#text` for text), `s` of SVG, `a` its attributes, `t` its text. */
|
|
6
|
+
export interface RemoteNode {
|
|
7
|
+
i: number;
|
|
8
|
+
n: string;
|
|
9
|
+
s?: 1;
|
|
10
|
+
a?: Record<string, string>;
|
|
11
|
+
t?: string;
|
|
12
|
+
c?: RemoteNode[];
|
|
13
|
+
}
|
|
14
|
+
/** The container of a root is the node 0 of its ids. `b`: the node it goes before, 0 at the end. */
|
|
15
|
+
export type RemoteOp = {
|
|
16
|
+
o: 'ins';
|
|
17
|
+
p: number;
|
|
18
|
+
b: number;
|
|
19
|
+
node: RemoteNode;
|
|
20
|
+
} | {
|
|
21
|
+
o: 'rm';
|
|
22
|
+
i: number;
|
|
23
|
+
} | {
|
|
24
|
+
o: 'attr';
|
|
25
|
+
i: number;
|
|
26
|
+
k: string;
|
|
27
|
+
v: string | null;
|
|
28
|
+
} | {
|
|
29
|
+
o: 'blob';
|
|
30
|
+
i: number;
|
|
31
|
+
k: string;
|
|
32
|
+
v: Blob;
|
|
33
|
+
} | {
|
|
34
|
+
o: 'text';
|
|
35
|
+
i: number;
|
|
36
|
+
t: string;
|
|
37
|
+
}
|
|
38
|
+
/** `q`: the last input of the user to the node the sandbox had heard: older than the copy's, it is left out. */
|
|
39
|
+
| {
|
|
40
|
+
o: 'prop';
|
|
41
|
+
i: number;
|
|
42
|
+
k: 'value' | 'checked';
|
|
43
|
+
v: string | boolean;
|
|
44
|
+
q?: number;
|
|
45
|
+
};
|
|
46
|
+
/** What the user did to a node of the copy, done again to the node in the sandbox. */
|
|
47
|
+
export interface RemoteEvent {
|
|
48
|
+
root: number;
|
|
49
|
+
i: number;
|
|
50
|
+
type: RemoteEventType;
|
|
51
|
+
value?: string;
|
|
52
|
+
checked?: boolean;
|
|
53
|
+
files?: File[];
|
|
54
|
+
/** Of an input: counted by the copy, so that a value the sandbox sets back late does not undo what was typed since. */
|
|
55
|
+
seq?: number;
|
|
56
|
+
key?: string;
|
|
57
|
+
code?: string;
|
|
58
|
+
button?: number;
|
|
59
|
+
x?: number;
|
|
60
|
+
y?: number;
|
|
61
|
+
alt?: boolean;
|
|
62
|
+
ctrl?: boolean;
|
|
63
|
+
meta?: boolean;
|
|
64
|
+
shift?: boolean;
|
|
65
|
+
}
|
|
66
|
+
export declare const REMOTE_EVENTS: readonly ['click', 'dblclick', 'input', 'change', 'keydown', 'keyup', 'submit', 'pointerdown', 'pointerup', 'pointermove', 'focusin', 'focusout'];
|
|
67
|
+
export type RemoteEventType = (typeof REMOTE_EVENTS)[number];
|
|
68
|
+
/** The tag of the place where a component of Ta is drawn: its key is `k`, its children are those of the extension. */
|
|
69
|
+
export declare const PART_TAG = "ta-part";
|
|
70
|
+
/** Where what the extension gives a part of Ta to draw (its children, a ReactNode prop) is, by the name of the prop `n`. */
|
|
71
|
+
export declare const SLOT_TAG = "ta-slot";
|
|
72
|
+
export declare namespace RemoteRules {
|
|
73
|
+
/** What the copy may have of HTML; the rest is left out with what is under it. */
|
|
74
|
+
const HTML: Set<string>;
|
|
75
|
+
/** And of SVG, by their names as written. */
|
|
76
|
+
const SVG: Set<string>;
|
|
77
|
+
/** Whether the copy keeps an attribute as it is: none that runs code, no address that is not of the web. */
|
|
78
|
+
function attribute(tag: string, name: string, value: string): boolean;
|
|
79
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The DOM of a sandbox as it crosses to the page (docs/design/ta-extension-access.md 3.4): what the sandbox drew, as
|
|
3
|
+
* operations on nodes of ids of its own, and what the user did to the copy, as events. Data only.
|
|
4
|
+
*/
|
|
5
|
+
export const REMOTE_EVENTS = [
|
|
6
|
+
'click',
|
|
7
|
+
'dblclick',
|
|
8
|
+
'input',
|
|
9
|
+
'change',
|
|
10
|
+
'keydown',
|
|
11
|
+
'keyup',
|
|
12
|
+
'submit',
|
|
13
|
+
'pointerdown',
|
|
14
|
+
'pointerup',
|
|
15
|
+
'pointermove',
|
|
16
|
+
'focusin',
|
|
17
|
+
'focusout',
|
|
18
|
+
];
|
|
19
|
+
/** The tag of the place where a component of Ta is drawn: its key is `k`, its children are those of the extension. */
|
|
20
|
+
export const PART_TAG = 'ta-part';
|
|
21
|
+
/** Where what the extension gives a part of Ta to draw (its children, a ReactNode prop) is, by the name of the prop `n`. */
|
|
22
|
+
export const SLOT_TAG = 'ta-slot';
|
|
23
|
+
export var RemoteRules;
|
|
24
|
+
(function (RemoteRules) {
|
|
25
|
+
/** What the copy may have of HTML; the rest is left out with what is under it. */
|
|
26
|
+
RemoteRules.HTML = new Set(('a abbr address article aside audio b bdi bdo blockquote br button caption cite code col colgroup data dd del details dfn div dl dt em ' +
|
|
27
|
+
'fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 header hr i img input ins kbd label legend li main mark menu meter nav ol ' +
|
|
28
|
+
'optgroup option output p picture pre progress q rp rt ruby s samp section select small source span strong style sub summary sup table ' +
|
|
29
|
+
`tbody td textarea tfoot th thead time tr track u ul var video wbr ${PART_TAG} ${SLOT_TAG}`).split(' '));
|
|
30
|
+
/** And of SVG, by their names as written. */
|
|
31
|
+
RemoteRules.SVG = new Set(('svg g path circle ellipse line polyline polygon rect text tspan textPath defs linearGradient radialGradient stop clipPath mask pattern ' +
|
|
32
|
+
'symbol use title desc marker filter feGaussianBlur feOffset feBlend feColorMatrix feMerge feMergeNode feFlood feComposite feDropShadow ' +
|
|
33
|
+
'animate animateTransform').split(' '));
|
|
34
|
+
const NAME = /^[a-zA-Z_][\w:.-]*$/;
|
|
35
|
+
const DROPPED = new Set(['srcdoc', 'formaction', 'action', 'target', 'ping', 'srcset', 'is', 'nonce', 'http-equiv']);
|
|
36
|
+
const URLS = new Set(['href', 'src', 'xlink:href', 'poster', 'cite', 'background']);
|
|
37
|
+
const SAFE_URL = /^(https?:|mailto:|#|data:image\/(png|jpeg|gif|webp|avif|svg\+xml)[;,])/i;
|
|
38
|
+
/** Whether the copy keeps an attribute as it is: none that runs code, no address that is not of the web. */
|
|
39
|
+
function attribute(tag, name, value) {
|
|
40
|
+
const lower = name.toLowerCase();
|
|
41
|
+
if (!NAME.test(name) || lower.startsWith('on') || DROPPED.has(lower)) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
if (tag === 'use' && (lower === 'href' || lower === 'xlink:href')) {
|
|
45
|
+
return value.trim().startsWith('#');
|
|
46
|
+
}
|
|
47
|
+
if ((tag === 'animate' || tag === 'animateTransform') && lower === 'attributename') {
|
|
48
|
+
return !/href/i.test(value);
|
|
49
|
+
}
|
|
50
|
+
return !URLS.has(lower) || SAFE_URL.test(value.trim());
|
|
51
|
+
}
|
|
52
|
+
RemoteRules.attribute = attribute;
|
|
53
|
+
})(RemoteRules || (RemoteRules = {}));
|
|
54
|
+
//# sourceMappingURL=remote-protocol.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The styles of a sandbox scoped to where its copy is (docs/design/ta-extension-access.md 3.4), on the page's side, for
|
|
3
|
+
* the sandbox may send anything: each selector under `scope`, `:root`, `html` and `body` the scope itself; its
|
|
4
|
+
* `@keyframes` renamed with `suffix` (they are global); no `@import`, no `@font-face`. Parsed by the browser, never
|
|
5
|
+
* by hand.
|
|
6
|
+
*/
|
|
7
|
+
export declare namespace RemoteStyles {
|
|
8
|
+
function supported(): boolean;
|
|
9
|
+
function scope(css: string, scope: string, suffix: string): string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The styles of a sandbox scoped to where its copy is (docs/design/ta-extension-access.md 3.4), on the page's side, for
|
|
3
|
+
* the sandbox may send anything: each selector under `scope`, `:root`, `html` and `body` the scope itself; its
|
|
4
|
+
* `@keyframes` renamed with `suffix` (they are global); no `@import`, no `@font-face`. Parsed by the browser, never
|
|
5
|
+
* by hand.
|
|
6
|
+
*/
|
|
7
|
+
export var RemoteStyles;
|
|
8
|
+
(function (RemoteStyles) {
|
|
9
|
+
function supported() {
|
|
10
|
+
try {
|
|
11
|
+
new CSSStyleSheet().replaceSync('a{}');
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
catch (_a) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
RemoteStyles.supported = supported;
|
|
19
|
+
function scope(css, scope, suffix) {
|
|
20
|
+
const sheet = new CSSStyleSheet();
|
|
21
|
+
try {
|
|
22
|
+
sheet.replaceSync(css);
|
|
23
|
+
}
|
|
24
|
+
catch (_a) {
|
|
25
|
+
return '';
|
|
26
|
+
}
|
|
27
|
+
const names = new Set();
|
|
28
|
+
collect(sheet.cssRules, names);
|
|
29
|
+
return rules(sheet.cssRules, scope, suffix, names);
|
|
30
|
+
}
|
|
31
|
+
RemoteStyles.scope = scope;
|
|
32
|
+
function collect(list, names) {
|
|
33
|
+
for (const rule of Array.from(list)) {
|
|
34
|
+
if (rule instanceof CSSKeyframesRule) {
|
|
35
|
+
names.add(rule.name);
|
|
36
|
+
}
|
|
37
|
+
else if ('cssRules' in rule && !(rule instanceof CSSStyleRule)) {
|
|
38
|
+
collect(rule.cssRules, names);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function rules(list, scope, suffix, names) {
|
|
43
|
+
let out = '';
|
|
44
|
+
for (const rule of Array.from(list)) {
|
|
45
|
+
if (rule instanceof CSSStyleRule) {
|
|
46
|
+
out += `${selectors(rule.selectorText, scope)}{${animations(rule.style, suffix, names)}}`;
|
|
47
|
+
}
|
|
48
|
+
else if (rule instanceof CSSKeyframesRule) {
|
|
49
|
+
const text = rule.cssText;
|
|
50
|
+
out += `@keyframes ${rule.name}-${suffix}${text.slice(text.indexOf('{'))}`;
|
|
51
|
+
}
|
|
52
|
+
else if ('cssRules' in rule && !(rule instanceof CSSImportRule) && !(rule instanceof CSSFontFaceRule)) {
|
|
53
|
+
// @media, @supports, @container, @layer: their condition, the rules inside scoped too.
|
|
54
|
+
const text = rule.cssText;
|
|
55
|
+
out += `${text.slice(0, text.indexOf('{'))}{${rules(rule.cssRules, scope, suffix, names)}}`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
/** Its declarations, the names of its own keyframes renamed as they are. */
|
|
61
|
+
function animations(style, suffix, names) {
|
|
62
|
+
let text = style.cssText;
|
|
63
|
+
if (!names.size) {
|
|
64
|
+
return text;
|
|
65
|
+
}
|
|
66
|
+
for (const property of ['animation', 'animation-name']) {
|
|
67
|
+
const value = style.getPropertyValue(property);
|
|
68
|
+
if (value) {
|
|
69
|
+
const renamed = value.replace(/[\w-]+/g, word => (names.has(word) ? `${word}-${suffix}` : word));
|
|
70
|
+
text = text.replace(`${property}: ${value}`, `${property}: ${renamed}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return text;
|
|
74
|
+
}
|
|
75
|
+
function selectors(text, scope) {
|
|
76
|
+
return split(text)
|
|
77
|
+
.map(one => {
|
|
78
|
+
const trimmed = one.trim();
|
|
79
|
+
const root = /^(:root|html|body)(?![\w-])/.exec(trimmed);
|
|
80
|
+
return root ? scope + trimmed.slice(root[0].length) : `${scope} ${trimmed}`;
|
|
81
|
+
})
|
|
82
|
+
.join(',');
|
|
83
|
+
}
|
|
84
|
+
/** By the commas outside of brackets and quotes. */
|
|
85
|
+
function split(text) {
|
|
86
|
+
const parts = [];
|
|
87
|
+
let depth = 0;
|
|
88
|
+
let quote = '';
|
|
89
|
+
let start = 0;
|
|
90
|
+
for (let index = 0; index < text.length; index++) {
|
|
91
|
+
const char = text[index];
|
|
92
|
+
if (quote) {
|
|
93
|
+
quote = char === quote && text[index - 1] !== '\\' ? '' : quote;
|
|
94
|
+
}
|
|
95
|
+
else if (char === '"' || char === "'") {
|
|
96
|
+
quote = char;
|
|
97
|
+
}
|
|
98
|
+
else if (char === '(' || char === '[') {
|
|
99
|
+
depth++;
|
|
100
|
+
}
|
|
101
|
+
else if (char === ')' || char === ']') {
|
|
102
|
+
depth--;
|
|
103
|
+
}
|
|
104
|
+
else if (char === ',' && depth === 0) {
|
|
105
|
+
parts.push(text.slice(start, index));
|
|
106
|
+
start = index + 1;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
parts.push(text.slice(start));
|
|
110
|
+
return parts;
|
|
111
|
+
}
|
|
112
|
+
})(RemoteStyles || (RemoteStyles = {}));
|
|
113
|
+
//# sourceMappingURL=remote-styles.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { IsolatedHost } from './isolated-host.js';
|
|
3
|
+
/**
|
|
4
|
+
* A component of an extension in a sandbox, where the page shows it (docs/design/ta-extension-access.md 3.4): a root
|
|
5
|
+
* of its own in the sandbox, copied here into real DOM, with Ta's components drawn in it by the page itself.
|
|
6
|
+
*/
|
|
7
|
+
export declare function RemoteRoot({ host, component, props }: {
|
|
8
|
+
host: IsolatedHost;
|
|
9
|
+
component: number;
|
|
10
|
+
props: Record<string, unknown>;
|
|
11
|
+
}): React.JSX.Element;
|