@dxos/rpc-tunnel 0.8.4-main.ae835ea → 0.8.4-main.bc2380dfbc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +102 -5
- package/dist/lib/{browser → neutral}/index.mjs +8 -43
- package/dist/lib/{browser → neutral}/index.mjs.map +3 -3
- package/dist/lib/{browser → neutral}/meta.json +1 -1
- package/dist/types/src/port-muxer.d.ts.map +1 -1
- package/dist/types/src/ports/iframe.d.ts.map +1 -1
- package/dist/types/src/ports/worker.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/src/ports/worker.ts +1 -1
- package/dist/lib/node-esm/index.mjs +0 -224
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
package/LICENSE
CHANGED
|
@@ -1,8 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
Copyright (c) 2022 DXOS
|
|
1
|
+
# Functional Source License, Version 1.1, ALv2 Future License
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
## Abbreviation
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
FSL-1.1-Apache-2.0
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 DXOS
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
|
@@ -13,12 +13,7 @@ var sendToIFrame = (iframe, origin, message) => {
|
|
|
13
13
|
if (!iframe.contentWindow) {
|
|
14
14
|
log("IFrame content window missing", {
|
|
15
15
|
origin
|
|
16
|
-
}, {
|
|
17
|
-
F: __dxlog_file,
|
|
18
|
-
L: 24,
|
|
19
|
-
S: void 0,
|
|
20
|
-
C: (f, a) => f(...a)
|
|
21
|
-
});
|
|
16
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 16, S: void 0 });
|
|
22
17
|
return;
|
|
23
18
|
}
|
|
24
19
|
if (browser === "Chrome" && os === "iOS") {
|
|
@@ -44,23 +39,13 @@ var createIFramePort = ({ channel, iframe, origin, onOrigin }) => {
|
|
|
44
39
|
if (!origin) {
|
|
45
40
|
log("no origin set", {
|
|
46
41
|
channel
|
|
47
|
-
}, {
|
|
48
|
-
F: __dxlog_file,
|
|
49
|
-
L: 62,
|
|
50
|
-
S: void 0,
|
|
51
|
-
C: (f, a) => f(...a)
|
|
52
|
-
});
|
|
42
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 49, S: void 0 });
|
|
53
43
|
return;
|
|
54
44
|
}
|
|
55
45
|
log("sending", {
|
|
56
46
|
channel,
|
|
57
47
|
data: data.length
|
|
58
|
-
}, {
|
|
59
|
-
F: __dxlog_file,
|
|
60
|
-
L: 66,
|
|
61
|
-
S: void 0,
|
|
62
|
-
C: (f, a) => f(...a)
|
|
63
|
-
});
|
|
48
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 54, S: void 0 });
|
|
64
49
|
const payload = data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
65
50
|
const message = {
|
|
66
51
|
channel,
|
|
@@ -88,12 +73,7 @@ var createIFramePort = ({ channel, iframe, origin, onOrigin }) => {
|
|
|
88
73
|
origin = event.origin;
|
|
89
74
|
onOrigin?.(origin);
|
|
90
75
|
}
|
|
91
|
-
log("received", message, {
|
|
92
|
-
F: __dxlog_file,
|
|
93
|
-
L: 98,
|
|
94
|
-
S: void 0,
|
|
95
|
-
C: (f, a) => f(...a)
|
|
96
|
-
});
|
|
76
|
+
log("received", message, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 87, S: void 0 });
|
|
97
77
|
callback(new Uint8Array(message.payload));
|
|
98
78
|
};
|
|
99
79
|
window.addEventListener("message", handler);
|
|
@@ -133,14 +113,9 @@ var createWorkerPort = ({ port, channel, subscribe }) => ({
|
|
|
133
113
|
if (channel && message.channel !== channel) {
|
|
134
114
|
return;
|
|
135
115
|
}
|
|
136
|
-
log2.
|
|
116
|
+
log2.trace("received", {
|
|
137
117
|
message
|
|
138
|
-
}, {
|
|
139
|
-
F: __dxlog_file2,
|
|
140
|
-
L: 46,
|
|
141
|
-
S: void 0,
|
|
142
|
-
C: (f, a) => f(...a)
|
|
143
|
-
});
|
|
118
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 29, S: void 0 });
|
|
144
119
|
callback(new Uint8Array(message.payload));
|
|
145
120
|
};
|
|
146
121
|
port.onmessage = handler;
|
|
@@ -191,12 +166,7 @@ var PortMuxer = class {
|
|
|
191
166
|
log3.debug("Recieved message from worker port", {
|
|
192
167
|
channel: message.channel,
|
|
193
168
|
payload: message.payload
|
|
194
|
-
}, {
|
|
195
|
-
F: __dxlog_file3,
|
|
196
|
-
L: 56,
|
|
197
|
-
S: this,
|
|
198
|
-
C: (f, a) => f(...a)
|
|
199
|
-
});
|
|
169
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 43, S: this });
|
|
200
170
|
const callback = this._activeChannels.get(message.channel);
|
|
201
171
|
callback?.(new Uint8Array(message.payload));
|
|
202
172
|
}
|
|
@@ -205,12 +175,7 @@ var PortMuxer = class {
|
|
|
205
175
|
log3.debug("Recieved message from window", {
|
|
206
176
|
channel: message.channel,
|
|
207
177
|
payload: message.payload
|
|
208
|
-
}, {
|
|
209
|
-
F: __dxlog_file3,
|
|
210
|
-
L: 67,
|
|
211
|
-
S: this,
|
|
212
|
-
C: (f, a) => f(...a)
|
|
213
|
-
});
|
|
178
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 52, S: this });
|
|
214
179
|
}
|
|
215
180
|
};
|
|
216
181
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/ports/iframe.ts", "../../../src/ports/worker.ts", "../../../src/port-muxer.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport UAParser from 'ua-parser-js';\n\nimport { log } from '@dxos/log';\nimport { type RpcPort } from '@dxos/rpc';\n\nimport { type MessageData } from '../message';\n\nlet browser: string | undefined;\nlet os: string | undefined;\n\nif (typeof navigator !== 'undefined') {\n // TODO(wittjosiah): Stop user agent parsing.\n const parser = new UAParser(navigator.userAgent);\n browser = parser.getBrowser().name;\n os = parser.getOS().name;\n}\n\nconst sendToIFrame = (iframe: HTMLIFrameElement, origin: string, message: MessageData) => {\n if (!iframe.contentWindow) {\n log('IFrame content window missing', { origin });\n return;\n }\n\n if (browser === 'Chrome' && os === 'iOS') {\n iframe.contentWindow.postMessage(message, origin);\n } else {\n iframe.contentWindow.postMessage(message, origin, [message.payload]);\n }\n};\n\nconst sendToParentWindow = (origin: string, message: MessageData) => {\n if (browser === 'Chrome' && os === 'iOS') {\n window.parent.postMessage(message, origin);\n } else {\n window.parent.postMessage(message, origin, [message.payload]);\n }\n};\n\nexport type IFramePortOptions = {\n channel: string;\n iframe?: HTMLIFrameElement;\n origin?: string;\n onOrigin?: (origin: string) => void;\n};\n\n/**\n * Create a RPC port with an iframe over window messaging.\n * @param options.channel Identifier for sent/recieved messages.\n * @param options.iframe Instance of the iframe if sending to child.\n * @param options.origin Origin of the destination window.\n * @param options.onOrigin Callback triggered when origin of destination window is verified.\n * @returns RPC port for messaging.\n */\nexport const createIFramePort = ({ channel, iframe, origin, onOrigin }: IFramePortOptions): RpcPort => {\n return {\n send: async (data) => {\n if (!origin) {\n log('no origin set', { channel });\n return;\n }\n\n log('sending', { channel, data: data.length });\n const payload = data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);\n const message = { channel, payload };\n if (iframe) {\n sendToIFrame(iframe, origin, message);\n } else {\n sendToParentWindow(origin, message);\n }\n },\n\n subscribe: (callback) => {\n const handler = (event: MessageEvent<unknown>) => {\n if (!iframe && event.source !== window.parent) {\n // Not from parent window.\n return;\n } else if (iframe && event.source !== iframe.contentWindow) {\n // Not from child window.\n return;\n }\n\n const isMessageData =\n event.data && typeof event.data === 'object' && 'channel' in event.data && 'payload' in event.data;\n const message = isMessageData ? (event.data as MessageData) : undefined;\n if (message?.channel !== channel) {\n return;\n }\n\n if (!origin) {\n origin = event.origin;\n onOrigin?.(origin);\n }\n\n log('received', message);\n callback(new Uint8Array(message.payload));\n };\n\n window.addEventListener('message', handler);\n return () => window.removeEventListener('message', handler);\n },\n };\n};\n\nexport type CreateIFrameOptions = {\n hidden?: boolean;\n allow?: string;\n};\n\n/**\n * Create a hidden iframe and insert it into the DOM.\n * If an element with the same id already exists it will be returned instead.\n * @param source Source of the iframe.\n * @param id DOM id of the iframe.\n * @returns The created iframe.\n */\nexport const createIFrame = (source: string, id: string, { hidden = true, allow }: CreateIFrameOptions = {}) => {\n const create = () => {\n const iframe = document.createElement('iframe') as HTMLIFrameElement;\n iframe.id = id;\n iframe.src = source;\n hidden && iframe.setAttribute('style', 'display: none;');\n allow && iframe.setAttribute('allow', allow);\n document.body.appendChild(iframe);\n return iframe;\n };\n\n return (document.getElementById(id) as HTMLIFrameElement) ?? create();\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { log } from '@dxos/log';\nimport { type RpcPort } from '@dxos/rpc';\n\nimport { type MessageData } from '../message';\n\nexport type WorkerPortOptions = {\n port: MessagePort;\n channel?: string;\n subscribe?: RpcPort['subscribe'];\n};\n\n/**\n * Create a RPC port for a worker.\n * @param options.port Message port to send message on.\n * @param options.channel Identifier for sent/recieved messages.\n * @param options.subscribe\n * @returns RPC port for messaging.\n */\n// TODO(wittjosiah): Rename for more general purpose MessagePort.\nexport const createWorkerPort = ({ port, channel, subscribe }: WorkerPortOptions): RpcPort => ({\n send: async (message) => {\n // Based on https://stackoverflow.com/a/54646864/2804332.\n const payload = message.buffer.slice(message.byteOffset, message.byteOffset + message.byteLength);\n port.postMessage(\n {\n channel,\n payload,\n },\n [payload],\n );\n },\n\n subscribe:\n subscribe ??\n ((callback) => {\n const handler = (event: MessageEvent<MessageData>) => {\n const message = event.data;\n if (channel && message.channel !== channel) {\n return;\n }\n\n log.
|
|
5
|
-
"mappings": ";AAIA,OAAOA,cAAc;AAErB,SAASC,WAAW
|
|
6
|
-
"names": ["UAParser", "log", "browser", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport UAParser from 'ua-parser-js';\n\nimport { log } from '@dxos/log';\nimport { type RpcPort } from '@dxos/rpc';\n\nimport { type MessageData } from '../message';\n\nlet browser: string | undefined;\nlet os: string | undefined;\n\nif (typeof navigator !== 'undefined') {\n // TODO(wittjosiah): Stop user agent parsing.\n const parser = new UAParser(navigator.userAgent);\n browser = parser.getBrowser().name;\n os = parser.getOS().name;\n}\n\nconst sendToIFrame = (iframe: HTMLIFrameElement, origin: string, message: MessageData) => {\n if (!iframe.contentWindow) {\n log('IFrame content window missing', { origin });\n return;\n }\n\n if (browser === 'Chrome' && os === 'iOS') {\n iframe.contentWindow.postMessage(message, origin);\n } else {\n iframe.contentWindow.postMessage(message, origin, [message.payload]);\n }\n};\n\nconst sendToParentWindow = (origin: string, message: MessageData) => {\n if (browser === 'Chrome' && os === 'iOS') {\n window.parent.postMessage(message, origin);\n } else {\n window.parent.postMessage(message, origin, [message.payload]);\n }\n};\n\nexport type IFramePortOptions = {\n channel: string;\n iframe?: HTMLIFrameElement;\n origin?: string;\n onOrigin?: (origin: string) => void;\n};\n\n/**\n * Create a RPC port with an iframe over window messaging.\n * @param options.channel Identifier for sent/recieved messages.\n * @param options.iframe Instance of the iframe if sending to child.\n * @param options.origin Origin of the destination window.\n * @param options.onOrigin Callback triggered when origin of destination window is verified.\n * @returns RPC port for messaging.\n */\nexport const createIFramePort = ({ channel, iframe, origin, onOrigin }: IFramePortOptions): RpcPort => {\n return {\n send: async (data) => {\n if (!origin) {\n log('no origin set', { channel });\n return;\n }\n\n log('sending', { channel, data: data.length });\n const payload = data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);\n const message = { channel, payload };\n if (iframe) {\n sendToIFrame(iframe, origin, message);\n } else {\n sendToParentWindow(origin, message);\n }\n },\n\n subscribe: (callback) => {\n const handler = (event: MessageEvent<unknown>) => {\n if (!iframe && event.source !== window.parent) {\n // Not from parent window.\n return;\n } else if (iframe && event.source !== iframe.contentWindow) {\n // Not from child window.\n return;\n }\n\n const isMessageData =\n event.data && typeof event.data === 'object' && 'channel' in event.data && 'payload' in event.data;\n const message = isMessageData ? (event.data as MessageData) : undefined;\n if (message?.channel !== channel) {\n return;\n }\n\n if (!origin) {\n origin = event.origin;\n onOrigin?.(origin);\n }\n\n log('received', message);\n callback(new Uint8Array(message.payload));\n };\n\n window.addEventListener('message', handler);\n return () => window.removeEventListener('message', handler);\n },\n };\n};\n\nexport type CreateIFrameOptions = {\n hidden?: boolean;\n allow?: string;\n};\n\n/**\n * Create a hidden iframe and insert it into the DOM.\n * If an element with the same id already exists it will be returned instead.\n * @param source Source of the iframe.\n * @param id DOM id of the iframe.\n * @returns The created iframe.\n */\nexport const createIFrame = (source: string, id: string, { hidden = true, allow }: CreateIFrameOptions = {}) => {\n const create = () => {\n const iframe = document.createElement('iframe') as HTMLIFrameElement;\n iframe.id = id;\n iframe.src = source;\n hidden && iframe.setAttribute('style', 'display: none;');\n allow && iframe.setAttribute('allow', allow);\n document.body.appendChild(iframe);\n return iframe;\n };\n\n return (document.getElementById(id) as HTMLIFrameElement) ?? create();\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { log } from '@dxos/log';\nimport { type RpcPort } from '@dxos/rpc';\n\nimport { type MessageData } from '../message';\n\nexport type WorkerPortOptions = {\n port: MessagePort;\n channel?: string;\n subscribe?: RpcPort['subscribe'];\n};\n\n/**\n * Create a RPC port for a worker.\n * @param options.port Message port to send message on.\n * @param options.channel Identifier for sent/recieved messages.\n * @param options.subscribe\n * @returns RPC port for messaging.\n */\n// TODO(wittjosiah): Rename for more general purpose MessagePort.\nexport const createWorkerPort = ({ port, channel, subscribe }: WorkerPortOptions): RpcPort => ({\n send: async (message) => {\n // Based on https://stackoverflow.com/a/54646864/2804332.\n const payload = message.buffer.slice(message.byteOffset, message.byteOffset + message.byteLength);\n port.postMessage(\n {\n channel,\n payload,\n },\n [payload],\n );\n },\n\n subscribe:\n subscribe ??\n ((callback) => {\n const handler = (event: MessageEvent<MessageData>) => {\n const message = event.data;\n if (channel && message.channel !== channel) {\n return;\n }\n\n log.trace('received', { message });\n callback(new Uint8Array(message.payload));\n };\n\n port.onmessage = handler;\n return () => {\n port.onmessage = null;\n };\n }),\n});\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { log } from '@dxos/log';\nimport { type RpcPort } from '@dxos/rpc';\n\nimport { type MessageData } from './message';\nimport { type IFramePortOptions, type WorkerPortOptions, createIFramePort, createWorkerPort } from './ports';\n\n/**\n * Facilitates the multiplexing of multiple RpcPorts over a single MessagePort.\n */\nexport class PortMuxer {\n private readonly _activeChannels = new Map<string, (msg: Uint8Array) => void>();\n\n private readonly _rpcPorts = new Map<string, RpcPort>();\n\n constructor(private readonly _messagePort?: MessagePort) {\n if (this._messagePort) {\n this._messagePort.onmessage = (event) => this.onWorkerMessage(event);\n }\n\n if (typeof window !== 'undefined') {\n window.addEventListener('message', (event) => this.onWindowMessage(event));\n }\n }\n\n createWorkerPort(options: Omit<WorkerPortOptions, 'port' | 'subscribe' | 'channel'> & { channel: string }): RpcPort {\n if (!this._messagePort) {\n throw new Error('Message port is required to create worker ports');\n }\n\n const port = createWorkerPort({\n ...options,\n port: this._messagePort,\n subscribe: (callback) => {\n this._activeChannels.set(options.channel, callback);\n return () => this._activeChannels.delete(options.channel);\n },\n });\n this._rpcPorts.set(options.channel, port);\n\n return port;\n }\n\n createIFramePort(options: IFramePortOptions): RpcPort {\n const port = createIFramePort(options);\n this._rpcPorts.set(options.channel, port);\n\n return port;\n }\n\n private onWorkerMessage(event: MessageEvent<MessageData>): void {\n const message = event.data;\n log.debug('Recieved message from worker port', {\n channel: message.channel,\n payload: message.payload,\n });\n\n const callback = this._activeChannels.get(message.channel);\n callback?.(new Uint8Array(message.payload));\n }\n\n private onWindowMessage(event: MessageEvent<MessageData>): void {\n const message = event.data;\n log.debug('Recieved message from window', {\n channel: message.channel,\n payload: message.payload,\n });\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAIA,OAAOA,cAAc;AAErB,SAASC,WAAW;AAKpB,IAAIC,eAAAA;AAGJ,IAAI;IACF;IACA,OAAMC,cAAaH,aAASI;AAE5BC,QAAKF,SAAOG,IAAK,SAAO,UAAA,SAAA;AAC1B,YAAA,OAAA,WAAA,EAAA;AAEA,OAAMC,OAAAA,MAAgBC,EAAAA;;mBAEd,CAAA,QAAA,QAAA,YAAiC;cAAEC,eAAAA;AAAO,QAAA,iCAAA;MAC9C;IACF,GAAA,EAAA,YAAA,YAAA,GAAA,cAAA,GAAA,IAAA,GAAA,OAAA,CAAA;AAEIP;;AAEJ,MAAA,YAAO,YAAA,OAAA,OAAA;AACLM,WAAOE,cAAcC,YAAYC,SAASH,MAAAA;;WAAyB,cAAA,YAAA,SAAA,QAAA;MACrE,QAAA;IACF,CAAA;EAEA;;yBAEkBE,CAAAA,QAAYC,YAASH;AACrC,MAAA,YAAO,YAAA,OAAA,OAAA;AACLI,WAAOC,OAAOH,YAAYC,SAASH,MAAAA;;WAAyB,OAAA,YAAA,SAAA,QAAA;MAC9D,QAAA;IACF,CAAA;EASA;;AAUIM,IAAM,mBAAOC,CAAAA,EAAAA,SAAAA,QAAAA,QAAAA,SAAAA,MAAAA;;iBAEL,SAAA;mBAAmBC;AAAQ,YAAA,iBAAA;UAC/B;QACF,GAAA,EAAA,YAAA,YAAA,GAAA,cAAA,GAAA,IAAA,GAAA,OAAA,CAAA;AAEI;;UAAsB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A,SAAA,IAAA;AAEAO,WAAAA;;mBAEOL,SAAcM;AAEnB,UAAA,OAAOH,iBAAAA,OAAAA;AACT,SAAA,UAAA,IAAA,QAAA,SAAA,IAAA;AAEQI,WAAAA;;kBAEI,OAAA;UACRC,UAASC,MAAQD;SACjBE,MAAAA,qCAAwB;MAC1B,SAAA,QAAA;MAEA,SAAMC,QAAe;IACrBA,GAAAA,EAAAA,YAAW,YAAIC,GAAWH,eAAQC,GAAO,IAAA,GAAA,KAAA,CAAA;AAC3C,UAAA,WAAA,KAAA,gBAAA,IAAA,QAAA,OAAA;AAEQG,eAAAA,IAAgBC,WAAwC,QAAA,OAAA,CAAA;;kBAEpD,OAAA;UACRN,UAASC,MAAQD;SACjBE,MAAAA,gCAAwB;MAC1B,SAAA,QAAA;MACF,SAAA,QAAA;IACF,GAAA,EAAA,YAAA,YAAA,GAAAb,eAAA,GAAA,IAAA,GAAA,KAAA,CAAA;;;",
|
|
6
|
+
"names": ["UAParser", "log", "browser", "parser", "navigator", "os", "getOS", "sendToIFrame", "iframe", "origin", "contentWindow", "postMessage", "message", "window", "parent", "send", "data", "channel", "length", "payload", "sendToParentWindow", "subscribe", "event", "onOrigin", "callback", "addEventListener", "handler", "createElement", "id", "source", "hidden", "allow", "document", "body", "appendChild", "log", "__dxlog_file", "payload", "message", "channel", "subscribe", "event", "trace", "callback", "port", "onmessage", "handler", "log", "__dxlog_file", "_activeChannels", "Map", "_rpcPorts", "_messagePort", "createWorkerPort", "port", "subscribe", "createIFramePort", "options", "onWorkerMessage", "channel", "message", "payload", "callback", "Uint8Array", "onWindowMessage", "event"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/ports/iframe.ts":{"bytes":
|
|
1
|
+
{"inputs":{"src/ports/iframe.ts":{"bytes":13590,"imports":[{"path":"ua-parser-js","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"src/ports/worker.ts":{"bytes":4721,"imports":[{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"src/ports/index.ts":{"bytes":456,"imports":[{"path":"src/ports/iframe.ts","kind":"import-statement","original":"./iframe"},{"path":"src/ports/worker.ts","kind":"import-statement","original":"./worker"}],"format":"esm"},"src/port-muxer.ts":{"bytes":7397,"imports":[{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"src/ports/index.ts","kind":"import-statement","original":"./ports"}],"format":"esm"},"src/index.ts":{"bytes":507,"imports":[{"path":"src/ports/index.ts","kind":"import-statement","original":"./ports"},{"path":"src/port-muxer.ts","kind":"import-statement","original":"./port-muxer"}],"format":"esm"}},"outputs":{"dist/lib/neutral/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":12121},"dist/lib/neutral/index.mjs":{"imports":[{"path":"ua-parser-js","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"exports":["PortMuxer","createIFrame","createIFramePort","createWorkerPort"],"entryPoint":"src/index.ts","inputs":{"src/ports/iframe.ts":{"bytesInOutput":3028},"src/ports/index.ts":{"bytesInOutput":0},"src/ports/worker.ts":{"bytesInOutput":866},"src/index.ts":{"bytesInOutput":0},"src/port-muxer.ts":{"bytesInOutput":1790}},"bytes":5868}}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"port-muxer.d.ts","sourceRoot":"","sources":["../../../src/port-muxer.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,iBAAiB,EAAsC,MAAM,SAAS,CAAC;AAE7G;;GAEG;AACH,qBAAa,SAAS;IAKR,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;IAJ1C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAgD;IAEhF,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA8B;
|
|
1
|
+
{"version":3,"file":"port-muxer.d.ts","sourceRoot":"","sources":["../../../src/port-muxer.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,iBAAiB,EAAsC,MAAM,SAAS,CAAC;AAE7G;;GAEG;AACH,qBAAa,SAAS;IAKR,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;IAJ1C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAgD;IAEhF,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA8B;IAExD,YAA6B,YAAY,CAAC,EAAE,WAAW,YAAA,EAQtD;IAED,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,iBAAiB,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAAC,GAAG;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAgBlH;IAED,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAKpD;IAED,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,eAAe;CAOxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iframe.d.ts","sourceRoot":"","sources":["../../../../src/ports/iframe.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAmCzC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"iframe.d.ts","sourceRoot":"","sources":["../../../../src/ports/iframe.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAmCzC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,0CAA2C,iBAAiB,KAAG,OAgD3F,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,WAAY,MAAM,MAAM,MAAM,sBAA4B,mBAAmB,sBAYrG,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../../src/ports/worker.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CAClC,CAAC;AAEF;;;;;;GAMG;AAEH,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../../src/ports/worker.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CAClC,CAAC;AAEF;;;;;;GAMG;AAEH,eAAO,MAAM,gBAAgB,iCAAkC,iBAAiB,KAAG,OA+BjF,CAAC"}
|