@adobe/uix-core 0.6.5 → 0.7.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/dist/__helpers__/jest.messagechannel.d.cts +2 -0
- package/dist/__helpers__/jest.messagechannel.d.cts.map +1 -0
- package/dist/__mocks__/mock-finalization-registry.d.ts +11 -0
- package/dist/__mocks__/mock-finalization-registry.d.ts.map +1 -0
- package/dist/__mocks__/mock-weak-ref.d.ts +7 -0
- package/dist/__mocks__/mock-weak-ref.d.ts.map +1 -0
- package/dist/constants.d.ts +7 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/cross-realm-object.d.ts +44 -0
- package/dist/cross-realm-object.d.ts.map +1 -0
- package/dist/debuglog.d.ts +11 -0
- package/dist/debuglog.d.ts.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +817 -7
- package/dist/index.js.map +1 -1
- package/dist/message-wrapper.d.ts +9 -0
- package/dist/message-wrapper.d.ts.map +1 -0
- package/dist/object-simulator.d.ts +28 -0
- package/dist/object-simulator.d.ts.map +1 -0
- package/dist/object-simulator.test.d.ts +2 -0
- package/dist/object-simulator.test.d.ts.map +1 -0
- package/dist/object-walker.d.ts +29 -0
- package/dist/object-walker.d.ts.map +1 -0
- package/dist/promises/index.d.ts +3 -0
- package/dist/promises/index.d.ts.map +1 -0
- package/dist/promises/promise-wrappers.test.d.ts +2 -0
- package/dist/promises/promise-wrappers.test.d.ts.map +1 -0
- package/dist/promises/timed.d.ts +15 -0
- package/dist/promises/timed.d.ts.map +1 -0
- package/dist/promises/wait.d.ts +7 -0
- package/dist/promises/wait.d.ts.map +1 -0
- package/dist/remote-subject.d.ts +70 -0
- package/dist/remote-subject.d.ts.map +1 -0
- package/dist/rpc/call-receiver.d.ts +4 -0
- package/dist/rpc/call-receiver.d.ts.map +1 -0
- package/dist/rpc/call-receiver.test.d.ts +2 -0
- package/dist/rpc/call-receiver.test.d.ts.map +1 -0
- package/dist/rpc/call-sender.d.ts +4 -0
- package/dist/rpc/call-sender.d.ts.map +1 -0
- package/dist/rpc/call-sender.test.d.ts +2 -0
- package/dist/rpc/call-sender.test.d.ts.map +1 -0
- package/dist/rpc/index.d.ts +3 -0
- package/dist/rpc/index.d.ts.map +1 -0
- package/dist/tickets.d.ts +34 -0
- package/dist/tickets.d.ts.map +1 -0
- package/dist/tunnel/index.d.ts +2 -0
- package/dist/tunnel/index.d.ts.map +1 -0
- package/dist/tunnel/tunnel-message.d.ts +19 -0
- package/dist/tunnel/tunnel-message.d.ts.map +1 -0
- package/dist/tunnel/tunnel.d.ts +58 -0
- package/dist/tunnel/tunnel.d.ts.map +1 -0
- package/dist/tunnel/tunnel.test.d.ts +2 -0
- package/dist/tunnel/tunnel.test.d.ts.map +1 -0
- package/dist/types.d.ts +1 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/value-assertions.d.ts +10 -0
- package/dist/value-assertions.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/__helpers__/jest.messagechannel.cjs +3 -0
- package/src/__mocks__/mock-finalization-registry.ts +13 -0
- package/src/__mocks__/mock-weak-ref.ts +10 -0
- package/src/constants.ts +6 -0
- package/src/cross-realm-object.ts +117 -0
- package/src/debuglog.ts +1 -1
- package/src/index.ts +4 -1
- package/src/message-wrapper.ts +35 -0
- package/src/object-simulator.test.ts +135 -0
- package/src/object-simulator.ts +136 -0
- package/src/object-walker.ts +92 -0
- package/src/promises/index.ts +2 -0
- package/src/promises/promise-wrappers.test.ts +63 -0
- package/src/promises/timed.ts +41 -0
- package/src/promises/wait.ts +10 -0
- package/src/remote-subject.ts +185 -0
- package/src/rpc/call-receiver.test.ts +90 -0
- package/src/rpc/call-receiver.ts +29 -0
- package/src/rpc/call-sender.test.ts +73 -0
- package/src/rpc/call-sender.ts +72 -0
- package/src/rpc/index.ts +2 -0
- package/src/tickets.ts +71 -0
- package/src/tunnel/index.ts +1 -0
- package/src/tunnel/tunnel-message.ts +75 -0
- package/src/tunnel/tunnel.test.ts +196 -0
- package/src/tunnel/tunnel.ts +311 -0
- package/src/types.ts +3 -5
- package/src/value-assertions.ts +48 -0
- package/tsconfig.json +2 -6
- package/dist/timeout-promise.d.ts +0 -12
- package/dist/timeout-promise.d.ts.map +0 -1
- package/src/timeout-promise.ts +0 -36
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** @internal */
|
|
2
|
+
export type Primitive = string | number | boolean;
|
|
3
|
+
|
|
4
|
+
export function isPlainObject<T>(value: unknown): value is T & object {
|
|
5
|
+
if (!value || typeof value !== "object") {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
const proto = Reflect.getPrototypeOf(value);
|
|
9
|
+
return proto === null || proto === Object.prototype;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function isPrimitive(value: unknown): value is Primitive {
|
|
13
|
+
if (!value) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
const theType = typeof value;
|
|
17
|
+
return theType === "string" || theType === "number" || theType === "boolean";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function isIterable<T>(value: unknown): value is T[] {
|
|
21
|
+
return Array.isArray(value);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function isFunction(value: unknown): value is CallableFunction {
|
|
25
|
+
return typeof value === "function";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function hasProp(value: unknown, prop: string) {
|
|
29
|
+
return !isPrimitive(value) && Reflect.has(value as object, prop);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function isTunnelSource(
|
|
33
|
+
value: unknown
|
|
34
|
+
): value is Window | ServiceWorker {
|
|
35
|
+
return (
|
|
36
|
+
value instanceof Window ||
|
|
37
|
+
value instanceof ServiceWorker ||
|
|
38
|
+
hasProp(value, "onmessage")
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function isIframe(value: unknown): value is HTMLIFrameElement {
|
|
43
|
+
if (!value || isPrimitive(value)) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
const { nodeName } = value as HTMLIFrameElement;
|
|
47
|
+
return typeof nodeName === "string" && nodeName.toLowerCase() === "iframe";
|
|
48
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Add a timeout to a Promise. The returned Promise will resolve to the value of
|
|
3
|
-
* the original Promise, but if it doesn't resolve within the timeout interval,
|
|
4
|
-
* it will reject with a timeout error.
|
|
5
|
-
* @internal
|
|
6
|
-
*
|
|
7
|
-
* @param timeoutMs - Time to wait (ms) before rejecting
|
|
8
|
-
* @param promise - Original promise to set a timeout for
|
|
9
|
-
* @returns - Promise that rejects after X milliseconds have passed
|
|
10
|
-
*/
|
|
11
|
-
export declare function timeoutPromise<T>(timeoutMs: number, promise: Promise<T>): Promise<unknown>;
|
|
12
|
-
//# sourceMappingURL=timeout-promise.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timeout-promise.d.ts","sourceRoot":"","sources":["../src/timeout-promise.ts"],"names":[],"mappings":"AAYA;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,oBAavE"}
|
package/src/timeout-promise.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2022 Adobe. All rights reserved.
|
|
3
|
-
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
|
|
7
|
-
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Add a timeout to a Promise. The returned Promise will resolve to the value of
|
|
15
|
-
* the original Promise, but if it doesn't resolve within the timeout interval,
|
|
16
|
-
* it will reject with a timeout error.
|
|
17
|
-
* @internal
|
|
18
|
-
*
|
|
19
|
-
* @param timeoutMs - Time to wait (ms) before rejecting
|
|
20
|
-
* @param promise - Original promise to set a timeout for
|
|
21
|
-
* @returns - Promise that rejects after X milliseconds have passed
|
|
22
|
-
*/
|
|
23
|
-
export function timeoutPromise<T>(timeoutMs: number, promise: Promise<T>) {
|
|
24
|
-
return new Promise((resolve, reject) => {
|
|
25
|
-
const timeout = setTimeout(
|
|
26
|
-
() => reject(new Error(`Timed out after ${timeoutMs}ms`)),
|
|
27
|
-
timeoutMs
|
|
28
|
-
);
|
|
29
|
-
promise
|
|
30
|
-
.then((result) => {
|
|
31
|
-
clearTimeout(timeout);
|
|
32
|
-
resolve(result);
|
|
33
|
-
})
|
|
34
|
-
.catch(reject);
|
|
35
|
-
});
|
|
36
|
-
}
|