@player-ui/beacon-plugin-react 0.8.0--canary.307.9645 → 0.8.0-next.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.
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/beacon/react/src/index.tsx
32
+ var src_exports = {};
33
+ __export(src_exports, {
34
+ BeaconContext: () => BeaconContext,
35
+ BeaconPlugin: () => BeaconPlugin,
36
+ useBeacon: () => useBeacon
37
+ });
38
+ module.exports = __toCommonJS(src_exports);
39
+ var import_react = __toESM(require("react"));
40
+ var import_beacon_plugin = require("@player-ui/beacon-plugin");
41
+ __reExport(src_exports, require("@player-ui/beacon-plugin"), module.exports);
42
+ var BeaconContext = import_react.default.createContext({
43
+ handler: () => void 0
44
+ });
45
+ function useBeacon(initialArgs) {
46
+ const { handler } = import_react.default.useContext(BeaconContext);
47
+ return (options) => {
48
+ handler({
49
+ ...initialArgs,
50
+ ...options ?? {}
51
+ });
52
+ };
53
+ }
54
+ var BeaconPlugin = class extends import_beacon_plugin.BeaconPlugin {
55
+ constructor() {
56
+ super(...arguments);
57
+ this.name = "beacon-web-plugin";
58
+ }
59
+ applyReact(reactPlayer) {
60
+ const handler = this.beacon.bind(this);
61
+ reactPlayer.hooks.webComponent.tap(this.name, (Comp) => {
62
+ function BeaconContextComponent() {
63
+ return /* @__PURE__ */ import_react.default.createElement(BeaconContext.Provider, { value: { handler } }, /* @__PURE__ */ import_react.default.createElement(Comp, null));
64
+ }
65
+ return BeaconContextComponent;
66
+ });
67
+ }
68
+ };
69
+ // Annotate the CommonJS export names for ESM import in node:
70
+ 0 && (module.exports = {
71
+ BeaconContext,
72
+ BeaconPlugin,
73
+ useBeacon,
74
+ ...require("@player-ui/beacon-plugin")
75
+ });
76
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/beacon/react/src/index.tsx"],"sourcesContent":["import React from \"react\";\nimport type { ReactPlayer, ReactPlayerPlugin } from \"@player-ui/react\";\nimport type { BeaconArgs } from \"@player-ui/beacon-plugin\";\nimport { BeaconPlugin as BeaconCorePlugin } from \"@player-ui/beacon-plugin\";\n\nexport * from \"@player-ui/beacon-plugin\";\n\nexport type BeaconHandler = (options: BeaconArgs) => void;\n\nexport interface BeaconContextType {\n /** A callback for when assets beacon data */\n handler: BeaconHandler;\n}\n\nexport const BeaconContext = React.createContext<BeaconContextType>({\n handler: () => undefined,\n});\n\nexport type BeaconCallbackArgs = Omit<BeaconArgs, \"view\">;\n\nexport type BeaconCallbackFn<T extends Partial<BeaconCallbackArgs>> = (\n options?: T,\n) => void;\n\n/** A hook for creating a beacon handler */\nexport function useBeacon<T extends Partial<BeaconCallbackArgs>>(\n initialArgs: T,\n): BeaconCallbackFn<Omit<BeaconCallbackArgs, keyof T>> {\n const { handler } = React.useContext(BeaconContext);\n\n return (options?: Omit<BeaconCallbackArgs, keyof T>) => {\n handler({\n ...initialArgs,\n ...(options ?? {}),\n } as BeaconCallbackArgs);\n };\n}\n\n/**\n * A plugin for adding beacon support to a web-player\n */\nexport class BeaconPlugin\n extends BeaconCorePlugin\n implements ReactPlayerPlugin\n{\n name = \"beacon-web-plugin\";\n\n applyReact(reactPlayer: ReactPlayer) {\n const handler = this.beacon.bind(this);\n\n reactPlayer.hooks.webComponent.tap(this.name, (Comp) => {\n function BeaconContextComponent() {\n return (\n <BeaconContext.Provider value={{ handler }}>\n <Comp />\n </BeaconContext.Provider>\n );\n }\n\n return BeaconContextComponent;\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAGlB,2BAAiD;AAEjD,wBAAc,qCALd;AAcO,IAAM,gBAAgB,aAAAA,QAAM,cAAiC;AAAA,EAClE,SAAS,MAAM;AACjB,CAAC;AASM,SAAS,UACd,aACqD;AACrD,QAAM,EAAE,QAAQ,IAAI,aAAAA,QAAM,WAAW,aAAa;AAElD,SAAO,CAAC,YAAgD;AACtD,YAAQ;AAAA,MACN,GAAG;AAAA,MACH,GAAI,WAAW,CAAC;AAAA,IAClB,CAAuB;AAAA,EACzB;AACF;AAKO,IAAM,eAAN,cACG,qBAAAC,aAEV;AAAA,EAHO;AAAA;AAIL,gBAAO;AAAA;AAAA,EAEP,WAAW,aAA0B;AACnC,UAAM,UAAU,KAAK,OAAO,KAAK,IAAI;AAErC,gBAAY,MAAM,aAAa,IAAI,KAAK,MAAM,CAAC,SAAS;AACtD,eAAS,yBAAyB;AAChC,eACE,6BAAAD,QAAA,cAAC,cAAc,UAAd,EAAuB,OAAO,EAAE,QAAQ,KACvC,6BAAAA,QAAA,cAAC,UAAK,CACR;AAAA,MAEJ;AAEA,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AACF;","names":["React","BeaconCorePlugin"]}
@@ -0,0 +1,37 @@
1
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/beacon/react/src/index.tsx
2
+ import React from "react";
3
+ import { BeaconPlugin as BeaconCorePlugin } from "@player-ui/beacon-plugin";
4
+ export * from "@player-ui/beacon-plugin";
5
+ var BeaconContext = React.createContext({
6
+ handler: () => void 0
7
+ });
8
+ function useBeacon(initialArgs) {
9
+ const { handler } = React.useContext(BeaconContext);
10
+ return (options) => {
11
+ handler({
12
+ ...initialArgs,
13
+ ...options ?? {}
14
+ });
15
+ };
16
+ }
17
+ var BeaconPlugin = class extends BeaconCorePlugin {
18
+ constructor() {
19
+ super(...arguments);
20
+ this.name = "beacon-web-plugin";
21
+ }
22
+ applyReact(reactPlayer) {
23
+ const handler = this.beacon.bind(this);
24
+ reactPlayer.hooks.webComponent.tap(this.name, (Comp) => {
25
+ function BeaconContextComponent() {
26
+ return /* @__PURE__ */ React.createElement(BeaconContext.Provider, { value: { handler } }, /* @__PURE__ */ React.createElement(Comp, null));
27
+ }
28
+ return BeaconContextComponent;
29
+ });
30
+ }
31
+ };
32
+ export {
33
+ BeaconContext,
34
+ BeaconPlugin,
35
+ useBeacon
36
+ };
37
+ //# sourceMappingURL=index.mjs.map
package/dist/index.mjs ADDED
@@ -0,0 +1,37 @@
1
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/beacon/react/src/index.tsx
2
+ import React from "react";
3
+ import { BeaconPlugin as BeaconCorePlugin } from "@player-ui/beacon-plugin";
4
+ export * from "@player-ui/beacon-plugin";
5
+ var BeaconContext = React.createContext({
6
+ handler: () => void 0
7
+ });
8
+ function useBeacon(initialArgs) {
9
+ const { handler } = React.useContext(BeaconContext);
10
+ return (options) => {
11
+ handler({
12
+ ...initialArgs,
13
+ ...options ?? {}
14
+ });
15
+ };
16
+ }
17
+ var BeaconPlugin = class extends BeaconCorePlugin {
18
+ constructor() {
19
+ super(...arguments);
20
+ this.name = "beacon-web-plugin";
21
+ }
22
+ applyReact(reactPlayer) {
23
+ const handler = this.beacon.bind(this);
24
+ reactPlayer.hooks.webComponent.tap(this.name, (Comp) => {
25
+ function BeaconContextComponent() {
26
+ return /* @__PURE__ */ React.createElement(BeaconContext.Provider, { value: { handler } }, /* @__PURE__ */ React.createElement(Comp, null));
27
+ }
28
+ return BeaconContextComponent;
29
+ });
30
+ }
31
+ };
32
+ export {
33
+ BeaconContext,
34
+ BeaconPlugin,
35
+ useBeacon
36
+ };
37
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/beacon/react/src/index.tsx"],"sourcesContent":["import React from \"react\";\nimport type { ReactPlayer, ReactPlayerPlugin } from \"@player-ui/react\";\nimport type { BeaconArgs } from \"@player-ui/beacon-plugin\";\nimport { BeaconPlugin as BeaconCorePlugin } from \"@player-ui/beacon-plugin\";\n\nexport * from \"@player-ui/beacon-plugin\";\n\nexport type BeaconHandler = (options: BeaconArgs) => void;\n\nexport interface BeaconContextType {\n /** A callback for when assets beacon data */\n handler: BeaconHandler;\n}\n\nexport const BeaconContext = React.createContext<BeaconContextType>({\n handler: () => undefined,\n});\n\nexport type BeaconCallbackArgs = Omit<BeaconArgs, \"view\">;\n\nexport type BeaconCallbackFn<T extends Partial<BeaconCallbackArgs>> = (\n options?: T,\n) => void;\n\n/** A hook for creating a beacon handler */\nexport function useBeacon<T extends Partial<BeaconCallbackArgs>>(\n initialArgs: T,\n): BeaconCallbackFn<Omit<BeaconCallbackArgs, keyof T>> {\n const { handler } = React.useContext(BeaconContext);\n\n return (options?: Omit<BeaconCallbackArgs, keyof T>) => {\n handler({\n ...initialArgs,\n ...(options ?? {}),\n } as BeaconCallbackArgs);\n };\n}\n\n/**\n * A plugin for adding beacon support to a web-player\n */\nexport class BeaconPlugin\n extends BeaconCorePlugin\n implements ReactPlayerPlugin\n{\n name = \"beacon-web-plugin\";\n\n applyReact(reactPlayer: ReactPlayer) {\n const handler = this.beacon.bind(this);\n\n reactPlayer.hooks.webComponent.tap(this.name, (Comp) => {\n function BeaconContextComponent() {\n return (\n <BeaconContext.Provider value={{ handler }}>\n <Comp />\n </BeaconContext.Provider>\n );\n }\n\n return BeaconContextComponent;\n });\n }\n}\n"],"mappings":";AAAA,OAAO,WAAW;AAGlB,SAAS,gBAAgB,wBAAwB;AAEjD,cAAc;AASP,IAAM,gBAAgB,MAAM,cAAiC;AAAA,EAClE,SAAS,MAAM;AACjB,CAAC;AASM,SAAS,UACd,aACqD;AACrD,QAAM,EAAE,QAAQ,IAAI,MAAM,WAAW,aAAa;AAElD,SAAO,CAAC,YAAgD;AACtD,YAAQ;AAAA,MACN,GAAG;AAAA,MACH,GAAI,WAAW,CAAC;AAAA,IAClB,CAAuB;AAAA,EACzB;AACF;AAKO,IAAM,eAAN,cACG,iBAEV;AAAA,EAHO;AAAA;AAIL,gBAAO;AAAA;AAAA,EAEP,WAAW,aAA0B;AACnC,UAAM,UAAU,KAAK,OAAO,KAAK,IAAI;AAErC,gBAAY,MAAM,aAAa,IAAI,KAAK,MAAM,CAAC,SAAS;AACtD,eAAS,yBAAyB;AAChC,eACE,oCAAC,cAAc,UAAd,EAAuB,OAAO,EAAE,QAAQ,KACvC,oCAAC,UAAK,CACR;AAAA,MAEJ;AAEA,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AACF;","names":[]}
package/package.json CHANGED
@@ -1,67 +1,35 @@
1
1
  {
2
2
  "name": "@player-ui/beacon-plugin-react",
3
- "version": "0.8.0--canary.307.9645",
4
- "private": false,
5
- "publishConfig": {
6
- "registry": "https://registry.npmjs.org"
7
- },
3
+ "version": "0.8.0-next.0",
4
+ "main": "dist/cjs/index.cjs",
8
5
  "peerDependencies": {
9
- "@player-ui/player": "0.8.0--canary.307.9645",
10
- "@player-ui/react": "0.8.0--canary.307.9645"
6
+ "@player-ui/player": "0.8.0-next.0",
7
+ "@player-ui/react": "0.8.0-next.0",
8
+ "react": "^18.2.0",
9
+ "@types/react": "^18.2.39"
10
+ },
11
+ "devDependencies": {
12
+ "@player-ui/make-flow": "workspace:*"
11
13
  },
12
14
  "dependencies": {
13
- "@player-ui/beacon-plugin": "0.8.0--canary.307.9645",
14
- "@babel/runtime": "7.15.4"
15
+ "@player-ui/beacon-plugin": "0.8.0-next.0",
16
+ "tslib": "^2.6.2"
15
17
  },
16
- "main": "dist/index.cjs.js",
17
- "module": "dist/index.esm.js",
18
- "typings": "dist/index.d.ts",
18
+ "module": "dist/index.legacy-esm.js",
19
+ "types": "types/index.d.ts",
19
20
  "sideEffects": false,
20
- "license": "MIT",
21
- "repository": {
22
- "type": "git",
23
- "url": "https://github.com/player-ui/player-ui"
24
- },
25
- "bugs": {
26
- "url": "https://github.com/player-ui/player-ui/issues"
27
- },
28
- "homepage": "https://player-ui.github.io",
29
- "contributors": [
30
- {
31
- "name": "Adam Dierkens",
32
- "url": "https://github.com/adierkens"
33
- },
34
- {
35
- "name": "Spencer Hamm",
36
- "url": "https://github.com/spentacular"
37
- },
38
- {
39
- "name": "Harris Borawski",
40
- "url": "https://github.com/hborawski"
41
- },
42
- {
43
- "name": "Jeremiah Zucker",
44
- "url": "https://github.com/sugarmanz"
45
- },
46
- {
47
- "name": "Ketan Reddy",
48
- "url": "https://github.com/KetanReddy"
49
- },
50
- {
51
- "name": "Brocollie08",
52
- "url": "https://github.com/brocollie08"
53
- },
54
- {
55
- "name": "Kelly Harrop",
56
- "url": "https://github.com/kharrop"
57
- },
58
- {
59
- "name": "Alejandro Fimbres",
60
- "url": "https://github.com/lexfm"
61
- },
62
- {
63
- "name": "Rafael Campos",
64
- "url": "https://github.com/rafbcampos"
21
+ "exports": {
22
+ "./package.json": "./package.json",
23
+ "./dist/index.css": "./dist/index.css",
24
+ ".": {
25
+ "types": "./types/index.d.ts",
26
+ "import": "./dist/index.mjs",
27
+ "default": "./dist/cjs/index.cjs"
65
28
  }
29
+ },
30
+ "files": [
31
+ "dist",
32
+ "src",
33
+ "types"
66
34
  ]
67
35
  }
@@ -0,0 +1,53 @@
1
+ import { describe, test, vitest, expect } from "vitest";
2
+ import React from "react";
3
+ import { ReactPlayer } from "@player-ui/react";
4
+ import { findByTestId, render } from "@testing-library/react";
5
+ import { makeFlow } from "@player-ui/make-flow";
6
+ import { BeaconPlugin, useBeacon } from "..";
7
+
8
+ describe("beacon web plugin", () => {
9
+ test("loads in a player", async () => {
10
+ const beaconCallback = vitest.fn();
11
+
12
+ const rp = new ReactPlayer({
13
+ plugins: [
14
+ new BeaconPlugin({
15
+ callback: beaconCallback,
16
+ }),
17
+ ],
18
+ });
19
+
20
+ const flow = makeFlow({
21
+ id: "action",
22
+ type: "action",
23
+ value: "Next",
24
+ });
25
+
26
+ rp.assetRegistry.set({ type: "action" }, (props: any) => {
27
+ const beacon = useBeacon({ element: "button" });
28
+
29
+ beacon();
30
+
31
+ return <div data-testid={props.id}>{props.value}</div>;
32
+ });
33
+ rp.start(flow);
34
+
35
+ const { container } = render(
36
+ <div>
37
+ <React.Suspense fallback="loading...">
38
+ <rp.Component />
39
+ </React.Suspense>
40
+ </div>,
41
+ );
42
+
43
+ await findByTestId(container, "action");
44
+
45
+ expect(rp.player.getState().status).toBe("in-progress");
46
+
47
+ await vitest.waitFor(() => {
48
+ expect(beaconCallback).toHaveBeenCalledWith(
49
+ expect.objectContaining({ element: "button" }),
50
+ );
51
+ });
52
+ });
53
+ });
package/src/index.tsx CHANGED
@@ -1,9 +1,9 @@
1
- import React from 'react';
2
- import type { ReactPlayer, ReactPlayerPlugin } from '@player-ui/react';
3
- import type { BeaconArgs } from '@player-ui/beacon-plugin';
4
- import { BeaconPlugin as BeaconCorePlugin } from '@player-ui/beacon-plugin';
1
+ import React from "react";
2
+ import type { ReactPlayer, ReactPlayerPlugin } from "@player-ui/react";
3
+ import type { BeaconArgs } from "@player-ui/beacon-plugin";
4
+ import { BeaconPlugin as BeaconCorePlugin } from "@player-ui/beacon-plugin";
5
5
 
6
- export * from '@player-ui/beacon-plugin';
6
+ export * from "@player-ui/beacon-plugin";
7
7
 
8
8
  export type BeaconHandler = (options: BeaconArgs) => void;
9
9
 
@@ -16,15 +16,15 @@ export const BeaconContext = React.createContext<BeaconContextType>({
16
16
  handler: () => undefined,
17
17
  });
18
18
 
19
- export type BeaconCallbackArgs = Omit<BeaconArgs, 'view'>;
19
+ export type BeaconCallbackArgs = Omit<BeaconArgs, "view">;
20
20
 
21
21
  export type BeaconCallbackFn<T extends Partial<BeaconCallbackArgs>> = (
22
- options?: T
22
+ options?: T,
23
23
  ) => void;
24
24
 
25
25
  /** A hook for creating a beacon handler */
26
26
  export function useBeacon<T extends Partial<BeaconCallbackArgs>>(
27
- initialArgs: T
27
+ initialArgs: T,
28
28
  ): BeaconCallbackFn<Omit<BeaconCallbackArgs, keyof T>> {
29
29
  const { handler } = React.useContext(BeaconContext);
30
30
 
@@ -43,15 +43,21 @@ export class BeaconPlugin
43
43
  extends BeaconCorePlugin
44
44
  implements ReactPlayerPlugin
45
45
  {
46
- name = 'beacon-web-plugin';
46
+ name = "beacon-web-plugin";
47
47
 
48
48
  applyReact(reactPlayer: ReactPlayer) {
49
49
  const handler = this.beacon.bind(this);
50
50
 
51
- reactPlayer.hooks.webComponent.tap(this.name, (Comp) => () => (
52
- <BeaconContext.Provider value={{ handler }}>
53
- <Comp />
54
- </BeaconContext.Provider>
55
- ));
51
+ reactPlayer.hooks.webComponent.tap(this.name, (Comp) => {
52
+ function BeaconContextComponent() {
53
+ return (
54
+ <BeaconContext.Provider value={{ handler }}>
55
+ <Comp />
56
+ </BeaconContext.Provider>
57
+ );
58
+ }
59
+
60
+ return BeaconContextComponent;
61
+ });
56
62
  }
57
63
  }
@@ -0,0 +1,23 @@
1
+ import React from "react";
2
+ import type { ReactPlayer, ReactPlayerPlugin } from "@player-ui/react";
3
+ import type { BeaconArgs } from "@player-ui/beacon-plugin";
4
+ import { BeaconPlugin as BeaconCorePlugin } from "@player-ui/beacon-plugin";
5
+ export * from "@player-ui/beacon-plugin";
6
+ export type BeaconHandler = (options: BeaconArgs) => void;
7
+ export interface BeaconContextType {
8
+ /** A callback for when assets beacon data */
9
+ handler: BeaconHandler;
10
+ }
11
+ export declare const BeaconContext: React.Context<BeaconContextType>;
12
+ export type BeaconCallbackArgs = Omit<BeaconArgs, "view">;
13
+ export type BeaconCallbackFn<T extends Partial<BeaconCallbackArgs>> = (options?: T) => void;
14
+ /** A hook for creating a beacon handler */
15
+ export declare function useBeacon<T extends Partial<BeaconCallbackArgs>>(initialArgs: T): BeaconCallbackFn<Omit<BeaconCallbackArgs, keyof T>>;
16
+ /**
17
+ * A plugin for adding beacon support to a web-player
18
+ */
19
+ export declare class BeaconPlugin extends BeaconCorePlugin implements ReactPlayerPlugin {
20
+ name: string;
21
+ applyReact(reactPlayer: ReactPlayer): void;
22
+ }
23
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.cjs.js DELETED
@@ -1,59 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var React = require('react');
6
- var beaconPlugin = require('@player-ui/beacon-plugin');
7
-
8
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
-
10
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
11
-
12
- var __defProp = Object.defineProperty;
13
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
14
- var __hasOwnProp = Object.prototype.hasOwnProperty;
15
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
16
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
17
- var __spreadValues = (a, b) => {
18
- for (var prop in b || (b = {}))
19
- if (__hasOwnProp.call(b, prop))
20
- __defNormalProp(a, prop, b[prop]);
21
- if (__getOwnPropSymbols)
22
- for (var prop of __getOwnPropSymbols(b)) {
23
- if (__propIsEnum.call(b, prop))
24
- __defNormalProp(a, prop, b[prop]);
25
- }
26
- return a;
27
- };
28
- const BeaconContext = React__default["default"].createContext({
29
- handler: () => void 0
30
- });
31
- function useBeacon(initialArgs) {
32
- const { handler } = React__default["default"].useContext(BeaconContext);
33
- return (options) => {
34
- handler(__spreadValues(__spreadValues({}, initialArgs), options != null ? options : {}));
35
- };
36
- }
37
- class BeaconPlugin extends beaconPlugin.BeaconPlugin {
38
- constructor() {
39
- super(...arguments);
40
- this.name = "beacon-web-plugin";
41
- }
42
- applyReact(reactPlayer) {
43
- const handler = this.beacon.bind(this);
44
- reactPlayer.hooks.webComponent.tap(this.name, (Comp) => () => /* @__PURE__ */ React__default["default"].createElement(BeaconContext.Provider, {
45
- value: { handler }
46
- }, /* @__PURE__ */ React__default["default"].createElement(Comp, null)));
47
- }
48
- }
49
-
50
- exports.BeaconContext = BeaconContext;
51
- exports.BeaconPlugin = BeaconPlugin;
52
- exports.useBeacon = useBeacon;
53
- Object.keys(beaconPlugin).forEach(function (k) {
54
- if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
55
- enumerable: true,
56
- get: function () { return beaconPlugin[k]; }
57
- });
58
- });
59
- //# sourceMappingURL=index.cjs.js.map
package/dist/index.d.ts DELETED
@@ -1,24 +0,0 @@
1
- import React from 'react';
2
- import { ReactPlayerPlugin, ReactPlayer } from '@player-ui/react';
3
- import { BeaconArgs, BeaconPlugin as BeaconPlugin$1 } from '@player-ui/beacon-plugin';
4
- export * from '@player-ui/beacon-plugin';
5
-
6
- declare type BeaconHandler = (options: BeaconArgs) => void;
7
- interface BeaconContextType {
8
- /** A callback for when assets beacon data */
9
- handler: BeaconHandler;
10
- }
11
- declare const BeaconContext: React.Context<BeaconContextType>;
12
- declare type BeaconCallbackArgs = Omit<BeaconArgs, 'view'>;
13
- declare type BeaconCallbackFn<T extends Partial<BeaconCallbackArgs>> = (options?: T) => void;
14
- /** A hook for creating a beacon handler */
15
- declare function useBeacon<T extends Partial<BeaconCallbackArgs>>(initialArgs: T): BeaconCallbackFn<Omit<BeaconCallbackArgs, keyof T>>;
16
- /**
17
- * A plugin for adding beacon support to a web-player
18
- */
19
- declare class BeaconPlugin extends BeaconPlugin$1 implements ReactPlayerPlugin {
20
- name: string;
21
- applyReact(reactPlayer: ReactPlayer): void;
22
- }
23
-
24
- export { BeaconCallbackArgs, BeaconCallbackFn, BeaconContext, BeaconContextType, BeaconHandler, BeaconPlugin, useBeacon };
package/dist/index.esm.js DELETED
@@ -1,44 +0,0 @@
1
- import React from 'react';
2
- import { BeaconPlugin as BeaconPlugin$1 } from '@player-ui/beacon-plugin';
3
- export * from '@player-ui/beacon-plugin';
4
-
5
- var __defProp = Object.defineProperty;
6
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
- var __spreadValues = (a, b) => {
11
- for (var prop in b || (b = {}))
12
- if (__hasOwnProp.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- if (__getOwnPropSymbols)
15
- for (var prop of __getOwnPropSymbols(b)) {
16
- if (__propIsEnum.call(b, prop))
17
- __defNormalProp(a, prop, b[prop]);
18
- }
19
- return a;
20
- };
21
- const BeaconContext = React.createContext({
22
- handler: () => void 0
23
- });
24
- function useBeacon(initialArgs) {
25
- const { handler } = React.useContext(BeaconContext);
26
- return (options) => {
27
- handler(__spreadValues(__spreadValues({}, initialArgs), options != null ? options : {}));
28
- };
29
- }
30
- class BeaconPlugin extends BeaconPlugin$1 {
31
- constructor() {
32
- super(...arguments);
33
- this.name = "beacon-web-plugin";
34
- }
35
- applyReact(reactPlayer) {
36
- const handler = this.beacon.bind(this);
37
- reactPlayer.hooks.webComponent.tap(this.name, (Comp) => () => /* @__PURE__ */ React.createElement(BeaconContext.Provider, {
38
- value: { handler }
39
- }, /* @__PURE__ */ React.createElement(Comp, null)));
40
- }
41
- }
42
-
43
- export { BeaconContext, BeaconPlugin, useBeacon };
44
- //# sourceMappingURL=index.esm.js.map