react-chromecast-caf 0.0.4 → 0.0.5
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/index.d.ts +2 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/receiver-capture.d.ts +1 -0
- package/dist/sender-capture.d.ts +1 -0
- package/dist/useChromecastCafReceiver.d.ts +3 -4
- package/dist/useChromecastCafSender.d.ts +4 -6
- package/dist/verify-isolation.test.d.ts +1 -0
- package/package.json +9 -7
- package/dist/types/cast-shim.d.ts +0 -10
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ const load$1 = (() => {
|
|
|
12
12
|
const loop = () => {
|
|
13
13
|
if ('cast' in window && 'framework' in cast) {
|
|
14
14
|
resolve({
|
|
15
|
-
cast,
|
|
15
|
+
cast: cast,
|
|
16
16
|
});
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
@@ -49,7 +49,6 @@ const load = (() => {
|
|
|
49
49
|
window.__onGCastApiAvailable = (isAvailable) => {
|
|
50
50
|
if (isAvailable) {
|
|
51
51
|
resolve({
|
|
52
|
-
chrome,
|
|
53
52
|
cast,
|
|
54
53
|
});
|
|
55
54
|
}
|
|
@@ -62,7 +61,6 @@ const load = (() => {
|
|
|
62
61
|
})();
|
|
63
62
|
const useChromecastCafSender = () => {
|
|
64
63
|
const [sender, setSender] = useState({
|
|
65
|
-
chrome: null,
|
|
66
64
|
cast: null,
|
|
67
65
|
});
|
|
68
66
|
useEffect(() => {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/useChromecastCafReceiver.ts","../src/useChromecastCafSender.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/useChromecastCafReceiver.ts","../src/useChromecastCafSender.ts"],"sourcesContent":["import { useEffect, useState } from 'react'\nimport type { ReceiverCast } from './receiver-capture'\n\nexport type Receiver = {\n\tcast: ReceiverCast\n\t// @TODO: Add framework and debug\n}\n\nconst load = (() => {\n\tlet promise: Promise<Receiver> | null = null\n\n\treturn () => {\n\t\tif (promise === null) {\n\t\t\tpromise = new Promise((resolve) => {\n\t\t\t\tconst script = document.createElement('script')\n\t\t\t\tscript.src =\n\t\t\t\t\t'https://www.gstatic.com/cast/sdk/libs/caf_receiver/v3/cast_receiver_framework.js'\n\t\t\t\tdocument.body.appendChild(script)\n\n\t\t\t\tconst loop = () => {\n\t\t\t\t\tif ('cast' in window && 'framework' in cast) {\n\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\tcast: cast as unknown as ReceiverCast,\n\t\t\t\t\t\t})\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tloop()\n\t\t\t\t\t}, 100)\n\t\t\t\t}\n\t\t\t\tloop()\n\t\t\t})\n\t\t}\n\t\treturn promise\n\t}\n})()\n\nexport const useChromecastCafReceiver = () => {\n\tconst [receiver, setReceiver] = useState<Receiver | { cast: null }>({\n\t\tcast: null,\n\t})\n\n\tuseEffect(() => {\n\t\tload().then((sender) => {\n\t\t\tsetReceiver(sender)\n\t\t})\n\t}, [])\n\n\treturn receiver\n}\n","import { useEffect, useState } from 'react'\nimport type { SenderCast } from './sender-capture'\nexport { SenderCast }\n\nexport type Sender = {\n\tcast: SenderCast\n\t// @TODO: Add chrome\n}\n\nconst load = (() => {\n\tlet promise: Promise<Sender> | null = null\n\n\treturn () => {\n\t\tif (promise === null) {\n\t\t\tpromise = new Promise((resolve) => {\n\t\t\t\tconst script = document.createElement('script')\n\t\t\t\tscript.src =\n\t\t\t\t\t'https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1'\n\t\t\t\twindow.__onGCastApiAvailable = (isAvailable) => {\n\t\t\t\t\tif (isAvailable) {\n\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\tcast,\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tdocument.body.appendChild(script)\n\t\t\t})\n\t\t}\n\t\treturn promise\n\t}\n})()\n\nexport const useChromecastCafSender = () => {\n\tconst [sender, setSender] = useState<\n\t\t| Sender\n\t\t| {\n\t\t\t\tcast: null\n\t\t }\n\t>({\n\t\tcast: null,\n\t})\n\n\tuseEffect(() => {\n\t\tload().then((sender) => {\n\t\t\tsetSender(sender)\n\t\t})\n\t}, [])\n\n\treturn sender\n}\n"],"names":["load"],"mappings":";;AAQA,MAAMA,MAAI,GAAG,CAAC,MAAK;IAClB,IAAI,OAAO,GAA6B,IAAI;AAE5C,IAAA,OAAO,MAAK;AACX,QAAA,IAAI,OAAO,KAAK,IAAI,EAAE;AACrB,YAAA,OAAO,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,KAAI;gBACjC,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC;AAC/C,gBAAA,MAAM,CAAC,GAAG;AACT,oBAAA,kFAAkF;AACnF,gBAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;gBAEjC,MAAM,IAAI,GAAG,MAAK;oBACjB,IAAI,MAAM,IAAI,MAAM,IAAI,WAAW,IAAI,IAAI,EAAE;AAC5C,wBAAA,OAAO,CAAC;AACP,4BAAA,IAAI,EAAE,IAA+B;AACrC,yBAAA,CAAC;wBACF;oBACD;oBACA,UAAU,CAAC,MAAK;AACf,wBAAA,IAAI,EAAE;oBACP,CAAC,EAAE,GAAG,CAAC;AACR,gBAAA,CAAC;AACD,gBAAA,IAAI,EAAE;AACP,YAAA,CAAC,CAAC;QACH;AACA,QAAA,OAAO,OAAO;AACf,IAAA,CAAC;AACF,CAAC,GAAG;AAEG,MAAM,wBAAwB,GAAG,MAAK;AAC5C,IAAA,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAA4B;AACnE,QAAA,IAAI,EAAE,IAAI;AACV,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ast = typeof import('chromecast-caf-receiver').cast;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type SenderCast = Window['cast'];
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type Receiver = {
|
|
3
|
-
cast:
|
|
1
|
+
import type { ReceiverCast } from './receiver-capture';
|
|
2
|
+
export type Receiver = {
|
|
3
|
+
cast: ReceiverCast;
|
|
4
4
|
};
|
|
5
5
|
export declare const useChromecastCafReceiver: () => Receiver | {
|
|
6
6
|
cast: null;
|
|
7
7
|
};
|
|
8
|
-
export {};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
cast:
|
|
1
|
+
import type { SenderCast } from './sender-capture';
|
|
2
|
+
export { SenderCast };
|
|
3
|
+
export type Sender = {
|
|
4
|
+
cast: SenderCast;
|
|
5
5
|
};
|
|
6
6
|
export declare const useChromecastCafSender: () => Sender | {
|
|
7
|
-
chrome: null;
|
|
8
7
|
cast: null;
|
|
9
8
|
};
|
|
10
|
-
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-chromecast-caf",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "React hooks to use the Chromecast sender and receiver SDK in your project.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"start": "rollup -c -w",
|
|
16
16
|
"dev": "npm start",
|
|
17
17
|
"build": "rollup -c",
|
|
18
|
-
"prepare": "npm run build"
|
|
18
|
+
"prepare": "npm run build",
|
|
19
|
+
"test": "vitest typecheck"
|
|
19
20
|
},
|
|
20
21
|
"repository": {
|
|
21
22
|
"type": "git",
|
|
@@ -40,6 +41,10 @@
|
|
|
40
41
|
"files": [
|
|
41
42
|
"/dist/"
|
|
42
43
|
],
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@types/chromecast-caf-receiver": "^6.0.25",
|
|
46
|
+
"@types/chromecast-caf-sender": "^1.0.11"
|
|
47
|
+
},
|
|
43
48
|
"devDependencies": {
|
|
44
49
|
"@rollup/plugin-commonjs": "^25.0.8",
|
|
45
50
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
@@ -50,11 +55,8 @@
|
|
|
50
55
|
"rollup-plugin-delete": "^3.0.2",
|
|
51
56
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
52
57
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
58
|
+
"tslib": "^2.8.1",
|
|
53
59
|
"typescript": "^5.9.3",
|
|
54
|
-
"
|
|
55
|
-
},
|
|
56
|
-
"dependencies": {
|
|
57
|
-
"@types/chromecast-caf-receiver": "^6.0.25",
|
|
58
|
-
"@types/chromecast-caf-sender": "^1.0.11"
|
|
60
|
+
"vitest": "^4.0.18"
|
|
59
61
|
}
|
|
60
62
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
declare module 'chromecast-caf-receiver-module' {
|
|
2
|
-
import '@types/chromecast-caf-receiver'
|
|
3
|
-
export type Cast = typeof window.cast
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
declare module 'chromecast-caf-sender-module' {
|
|
7
|
-
import '@types/chromecast-caf-sender'
|
|
8
|
-
export type Cast = typeof window.cast
|
|
9
|
-
export type Chrome = typeof window.chrome
|
|
10
|
-
}
|