@plasmicpkgs/react-youtube 7.13.95 → 7.13.97

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.
@@ -9,61 +9,20 @@ var React = _interopDefault(require('react'));
9
9
  var YouTubeImpl = _interopDefault(require('react-youtube'));
10
10
 
11
11
  function _extends() {
12
- _extends = Object.assign || function (target) {
12
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
13
13
  for (var i = 1; i < arguments.length; i++) {
14
14
  var source = arguments[i];
15
-
16
15
  for (var key in source) {
17
16
  if (Object.prototype.hasOwnProperty.call(source, key)) {
18
17
  target[key] = source[key];
19
18
  }
20
19
  }
21
20
  }
22
-
23
21
  return target;
24
22
  };
25
-
26
23
  return _extends.apply(this, arguments);
27
24
  }
28
25
 
29
- function _unsupportedIterableToArray(o, minLen) {
30
- if (!o) return;
31
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
32
- var n = Object.prototype.toString.call(o).slice(8, -1);
33
- if (n === "Object" && o.constructor) n = o.constructor.name;
34
- if (n === "Map" || n === "Set") return Array.from(o);
35
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
36
- }
37
-
38
- function _arrayLikeToArray(arr, len) {
39
- if (len == null || len > arr.length) len = arr.length;
40
-
41
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
42
-
43
- return arr2;
44
- }
45
-
46
- function _createForOfIteratorHelperLoose(o, allowArrayLike) {
47
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
48
- if (it) return (it = it.call(o)).next.bind(it);
49
-
50
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
51
- if (it) o = it;
52
- var i = 0;
53
- return function () {
54
- if (i >= o.length) return {
55
- done: true
56
- };
57
- return {
58
- done: false,
59
- value: o[i++]
60
- };
61
- };
62
- }
63
-
64
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
65
- }
66
-
67
26
  var playerParams = ["autoplay", "cc_load_policy", "color", "controls", "disablekb", "enablejsapi", "end", "fs", "hl", "iv_load_policy", "list", "listType", "loop", "modestbranding", "origin", "playlist", "playsinline", "rel", "start"];
68
27
  var booleanParams = ["autoplay", "cc_load_policy", "controls", "disablekb", "fs", "loop", "modestbranding", "playsinline", "rel"];
69
28
  var booleanParamsSet = /*#__PURE__*/new Set(booleanParams);
@@ -71,7 +30,6 @@ var YouTube = /*#__PURE__*/React.forwardRef(function (props, ref) {
71
30
  var internalRef = React.useRef(null);
72
31
  var onRef = React.useCallback(function (player) {
73
32
  internalRef.current = player;
74
-
75
33
  if (ref) {
76
34
  if (typeof ref === "function") {
77
35
  ref(player);
@@ -84,33 +42,25 @@ var YouTube = /*#__PURE__*/React.forwardRef(function (props, ref) {
84
42
  if (props.mute !== undefined) {
85
43
  if (props.mute) {
86
44
  var _internalRef$current, _internalRef$current$;
87
-
88
45
  (_internalRef$current = internalRef.current) == null ? void 0 : (_internalRef$current$ = _internalRef$current.getInternalPlayer()) == null ? void 0 : _internalRef$current$.mute();
89
46
  } else {
90
47
  var _internalRef$current2, _internalRef$current3;
91
-
92
48
  (_internalRef$current2 = internalRef.current) == null ? void 0 : (_internalRef$current3 = _internalRef$current2.getInternalPlayer()) == null ? void 0 : _internalRef$current3.unMute();
93
49
  }
94
50
  }
95
51
  }, [props.mute, internalRef]);
96
-
97
52
  var finalProps = _extends({}, props);
98
-
99
- for (var _iterator = _createForOfIteratorHelperLoose(playerParams), _step; !(_step = _iterator()).done;) {
100
- var prop = _step.value;
101
-
53
+ for (var _i = 0, _playerParams = playerParams; _i < _playerParams.length; _i++) {
54
+ var prop = _playerParams[_i];
102
55
  if (prop in finalProps) {
103
56
  var value = finalProps[prop];
104
57
  delete finalProps[prop];
105
-
106
58
  if (!finalProps.opts) {
107
59
  finalProps.opts = {};
108
60
  }
109
-
110
61
  if (!finalProps.opts.playerVars) {
111
62
  finalProps.opts.playerVars = {};
112
63
  }
113
-
114
64
  if (booleanParamsSet.has(prop)) {
115
65
  if (prop === "cc_load_policy" || prop === "modestbranding") {
116
66
  // undefined or 1
@@ -128,7 +78,6 @@ var YouTube = /*#__PURE__*/React.forwardRef(function (props, ref) {
128
78
  }
129
79
  }
130
80
  }
131
-
132
81
  return React.createElement(YouTubeImpl, Object.assign({
133
82
  ref: onRef
134
83
  }, finalProps, {
@@ -1 +1 @@
1
- {"version":3,"file":"react-youtube.cjs.development.js","sources":["../src/index.tsx"],"sourcesContent":["import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport React from \"react\";\nimport YouTubeImpl, { YouTubeProps as YouTubeImplProps } from \"react-youtube\";\nimport type { Options } from \"youtube-player/dist/types\";\n\ntype PlayerVars = Exclude<Options[\"playerVars\"], undefined>;\nexport type YouTubeProps = YouTubeImplProps &\n {\n [prop in keyof PlayerVars]:\n | PlayerVars[prop]\n | (prop extends typeof booleanParams[number] ? boolean : never);\n } & { mute?: boolean };\nconst playerParams = [\n \"autoplay\",\n \"cc_load_policy\",\n \"color\",\n \"controls\",\n \"disablekb\",\n \"enablejsapi\",\n \"end\",\n \"fs\",\n \"hl\",\n \"iv_load_policy\",\n \"list\",\n \"listType\",\n \"loop\",\n \"modestbranding\",\n \"origin\",\n \"playlist\",\n \"playsinline\",\n \"rel\",\n \"start\",\n] as const;\n\nconst booleanParams = [\n \"autoplay\",\n \"cc_load_policy\",\n \"controls\",\n \"disablekb\",\n \"fs\",\n \"loop\",\n \"modestbranding\",\n \"playsinline\",\n \"rel\",\n] as const;\n\nconst booleanParamsSet = new Set<string>(booleanParams);\n\nconst YouTube = React.forwardRef<YouTubeImpl, YouTubeProps>(\n (props: YouTubeProps, ref) => {\n const internalRef = React.useRef<YouTubeImpl | null>(null);\n\n const onRef = React.useCallback(\n (player: YouTubeImpl | null) => {\n internalRef.current = player;\n if (ref) {\n if (typeof ref === \"function\") {\n ref(player);\n } else {\n ref.current = player;\n }\n }\n },\n [ref]\n );\n\n React.useEffect(() => {\n if (props.mute !== undefined) {\n if (props.mute) {\n internalRef.current?.getInternalPlayer()?.mute();\n } else {\n internalRef.current?.getInternalPlayer()?.unMute();\n }\n }\n }, [props.mute, internalRef]);\n\n const finalProps = { ...props };\n for (const prop of playerParams) {\n if (prop in finalProps) {\n const value = finalProps[prop];\n delete finalProps[prop];\n if (!finalProps.opts) {\n finalProps.opts = {};\n }\n if (!finalProps.opts.playerVars) {\n finalProps.opts.playerVars = {};\n }\n if (booleanParamsSet.has(prop)) {\n if (prop === \"cc_load_policy\" || prop === \"modestbranding\") {\n // undefined or 1\n if (value) {\n finalProps.opts.playerVars[prop] = 1;\n } else {\n delete finalProps.opts.playerVars[prop];\n }\n } else {\n // 0 or 1\n finalProps.opts.playerVars[prop] = (value ? 1 : 0) as any;\n }\n } else {\n finalProps.opts.playerVars[prop] = value as any;\n }\n }\n }\n return (\n <YouTubeImpl\n ref={onRef}\n {...finalProps}\n iframeClassName={props.className}\n />\n );\n }\n);\n\nexport const youtubeMeta: ComponentMeta<YouTubeProps> = {\n name: \"hostless-youtube\",\n displayName: \"YouTube\",\n importName: \"YouTube\",\n importPath: \"@plasmicpkgs/react-youtube\",\n props: {\n videoId: {\n type: \"string\",\n defaultValue: \"R6MeLqRQzYw\",\n displayName: \"Video ID\",\n description: \"The ID for the YouTube video\",\n },\n autoplay: {\n type: \"boolean\",\n displayName: \"Auto Play\",\n description:\n \"Whether the video should automatically start playing when the player loads\",\n defaultValueHint: false,\n hidden: (props) => !props.mute,\n },\n cc_load_policy: {\n type: \"boolean\",\n displayName: \"Show Captions\",\n description:\n \"Whether the captions should be shown by default, even if the user has turned captions off\",\n defaultValueHint: false,\n },\n start: {\n type: \"number\",\n displayName: \"Start\",\n description:\n \"The video should begin at this amount of seconds from the start of the video\",\n defaultValueHint: 0,\n },\n end: {\n type: \"number\",\n displayName: \"End\",\n description:\n \"Stop playing the video after this amount of seconds (measured from the start of the video)\",\n },\n color: {\n type: \"choice\",\n displayName: \"Color\",\n options: [\"red\", \"white\"],\n description:\n \"The color used in the display bar to highlight how much of the video the viewer has already seen\",\n defaultValueHint: \"red\",\n },\n controls: {\n type: \"boolean\",\n displayName: \"Show Controls\",\n description:\n \"Whether the YouTube video player controls should be displayed\",\n defaultValueHint: true,\n },\n disablekb: {\n type: \"boolean\",\n displayName: \"Disable Keyboard\",\n description: \"Whether the keyboard controls should be disabled\",\n defaultValueHint: false,\n },\n fs: {\n type: \"boolean\",\n displayName: \"FullScreen Button\",\n description: \"Whether the fullscreen button should be displayed\",\n defaultValueHint: true,\n },\n loop: {\n type: \"boolean\",\n displayName: \"Loop\",\n description: \"Whether the video should be played again after it finishes\",\n defaultValueHint: false,\n },\n modestbranding: {\n type: \"boolean\",\n displayName: \"Hide Logo\",\n description: \"Hide the YouTube logo in the control bar\",\n defaultValueHint: false,\n },\n mute: {\n type: \"boolean\",\n displayName: \"Mute\",\n description: \"Whether the video should be muted\",\n defaultValueHint: false,\n },\n playsinline: {\n type: \"boolean\",\n displayName: \"Play Inline\",\n description:\n \"Whether the video should be played inline or fullscreen on iOS\",\n defaultValueHint: false,\n },\n rel: {\n type: \"boolean\",\n displayName: \"Related Videos\",\n description:\n \"Whether it should show related videos when the video ends (if false, it shows other videos from the same channel)\",\n defaultValueHint: true,\n },\n },\n isDefaultExport: true,\n defaultStyles: {\n height: \"390px\",\n width: \"640px\",\n maxHeight: \"100%\",\n maxWidth: \"100%\",\n },\n};\n\nexport function registerYouTube(\n loader?: { registerComponent: typeof registerComponent },\n customYouTubeMeta?: ComponentMeta<YouTubeProps>\n) {\n if (loader) {\n loader.registerComponent(YouTube, customYouTubeMeta ?? youtubeMeta);\n } else {\n registerComponent(YouTube, customYouTubeMeta ?? youtubeMeta);\n }\n}\n\nexport default YouTube;\n"],"names":["playerParams","booleanParams","booleanParamsSet","Set","YouTube","React","forwardRef","props","ref","internalRef","useRef","onRef","useCallback","player","current","useEffect","mute","undefined","getInternalPlayer","unMute","finalProps","prop","value","opts","playerVars","has","YouTubeImpl","iframeClassName","className","youtubeMeta","name","displayName","importName","importPath","videoId","type","defaultValue","description","autoplay","defaultValueHint","hidden","cc_load_policy","start","end","color","options","controls","disablekb","fs","loop","modestbranding","playsinline","rel","isDefaultExport","defaultStyles","height","width","maxHeight","maxWidth","registerYouTube","loader","customYouTubeMeta","registerComponent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,IAAMA,YAAY,GAAG,CACnB,UADmB,EAEnB,gBAFmB,EAGnB,OAHmB,EAInB,UAJmB,EAKnB,WALmB,EAMnB,aANmB,EAOnB,KAPmB,EAQnB,IARmB,EASnB,IATmB,EAUnB,gBAVmB,EAWnB,MAXmB,EAYnB,UAZmB,EAanB,MAbmB,EAcnB,gBAdmB,EAenB,QAfmB,EAgBnB,UAhBmB,EAiBnB,aAjBmB,EAkBnB,KAlBmB,EAmBnB,OAnBmB,CAArB;AAsBA,IAAMC,aAAa,GAAG,CACpB,UADoB,EAEpB,gBAFoB,EAGpB,UAHoB,EAIpB,WAJoB,EAKpB,IALoB,EAMpB,MANoB,EAOpB,gBAPoB,EAQpB,aARoB,EASpB,KAToB,CAAtB;AAYA,IAAMC,gBAAgB,gBAAG,IAAIC,GAAJ,CAAgBF,aAAhB,CAAzB;AAEA,IAAMG,OAAO,gBAAGC,KAAK,CAACC,UAAN,CACd,UAACC,KAAD,EAAsBC,GAAtB;AACE,MAAMC,WAAW,GAAGJ,KAAK,CAACK,MAAN,CAAiC,IAAjC,CAApB;AAEA,MAAMC,KAAK,GAAGN,KAAK,CAACO,WAAN,CACZ,UAACC,MAAD;AACEJ,IAAAA,WAAW,CAACK,OAAZ,GAAsBD,MAAtB;;AACA,QAAIL,GAAJ,EAAS;AACP,UAAI,OAAOA,GAAP,KAAe,UAAnB,E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Q;AAEdJ,MAAAA,WAAW,EAAE,WAFC;AAGdM,MAAAA,WAAW,EAAE,0CAHC;AAIdE,MAAAA,gBAAgB,EAAE;AAJJ,KApEX;AA0ELvB,IAAAA,IAAI,EAAE;AACJmB,MAAAA,IAAI,EAAE,SADF;AAEJJ,MAAAA,WAAW,EAAE,MAFT;AAGJM,MAAAA,WAAW,EAAE,mCAHT;AAIJE,MAAAA,gBAAgB,EAAE;AAJd,KA1ED;AAgFLY,IAAAA,WAAW,EAAE;AACXhB,MAAAA,IAAI,EAAE,SADK;AAEXJ,MAAAA,WAAW,EAAE,aAFF;AAGXM,MAAAA,WAAW,EACT,gEAJS;AAKXE,MAAAA,gBAAgB,EAAE;AALP,KAhFR;AAuFLa,IAAAA,GAAG,EAAE;AACHjB,MAAAA,IAAI,EAAE,SADH;AAEHJ,MAAAA,WAAW,EAAE,gBAFV;AAGHM,MAAAA,WAAW,EACT,mHAJC;AAKHE,MAAAA,gBAAgB,EAAE;AALf;AAvFA,GAL+C;AAoGtDc,EAAAA,eAAe,EAAE,IApGqC;AAqGtDC,EAAAA,aAAa,EAAE;AACbC,IAAAA,MAAM,EAAE,OADK;AAEbC,IAAAA,KAAK,EAAE,OAFM;AAGbC,IAAAA,SAAS,EAAE,MAHE;AAIbC,IAAAA,QAAQ,EAAE;AAJG;AArGuC;SA6GxCC,gBACdC,QACAC;AAEA,MAAID,MAAJ,EAAY;AACVA,IAAAA,MAAM,CAACE,iBAAP,CAAyB1D,OAAzB,EAAkCyD,iBAAlC,WAAkCA,iBAAlC,GAAuDhC,WAAvD;AACD,GAFD,MAEO;AACLiC,IAAAA,iBAAiB,CAAC1D,OAAD,EAAUyD,iBAAV,WAAUA,iBAAV,GAA+BhC,WAA/B,CAAjB;AACD;AACF;;;;;;"}
1
+ {"version":3,"file":"react-youtube.cjs.development.js","sources":["../src/index.tsx"],"sourcesContent":["import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport React from \"react\";\nimport YouTubeImpl, { YouTubeProps as YouTubeImplProps } from \"react-youtube\";\nimport type { Options } from \"youtube-player/dist/types\";\n\ntype PlayerVars = Exclude<Options[\"playerVars\"], undefined>;\nexport type YouTubeProps = YouTubeImplProps &\n {\n [prop in keyof PlayerVars]:\n | PlayerVars[prop]\n | (prop extends typeof booleanParams[number] ? boolean : never);\n } & { mute?: boolean };\nconst playerParams = [\n \"autoplay\",\n \"cc_load_policy\",\n \"color\",\n \"controls\",\n \"disablekb\",\n \"enablejsapi\",\n \"end\",\n \"fs\",\n \"hl\",\n \"iv_load_policy\",\n \"list\",\n \"listType\",\n \"loop\",\n \"modestbranding\",\n \"origin\",\n \"playlist\",\n \"playsinline\",\n \"rel\",\n \"start\",\n] as const;\n\nconst booleanParams = [\n \"autoplay\",\n \"cc_load_policy\",\n \"controls\",\n \"disablekb\",\n \"fs\",\n \"loop\",\n \"modestbranding\",\n \"playsinline\",\n \"rel\",\n] as const;\n\nconst booleanParamsSet = new Set<string>(booleanParams);\n\nconst YouTube = React.forwardRef<YouTubeImpl, YouTubeProps>(\n (props: YouTubeProps, ref) => {\n const internalRef = React.useRef<YouTubeImpl | null>(null);\n\n const onRef = React.useCallback(\n (player: YouTubeImpl | null) => {\n internalRef.current = player;\n if (ref) {\n if (typeof ref === \"function\") {\n ref(player);\n } else {\n ref.current = player;\n }\n }\n },\n [ref]\n );\n\n React.useEffect(() => {\n if (props.mute !== undefined) {\n if (props.mute) {\n internalRef.current?.getInternalPlayer()?.mute();\n } else {\n internalRef.current?.getInternalPlayer()?.unMute();\n }\n }\n }, [props.mute, internalRef]);\n\n const finalProps = { ...props };\n for (const prop of playerParams) {\n if (prop in finalProps) {\n const value = finalProps[prop];\n delete finalProps[prop];\n if (!finalProps.opts) {\n finalProps.opts = {};\n }\n if (!finalProps.opts.playerVars) {\n finalProps.opts.playerVars = {};\n }\n if (booleanParamsSet.has(prop)) {\n if (prop === \"cc_load_policy\" || prop === \"modestbranding\") {\n // undefined or 1\n if (value) {\n finalProps.opts.playerVars[prop] = 1;\n } else {\n delete finalProps.opts.playerVars[prop];\n }\n } else {\n // 0 or 1\n finalProps.opts.playerVars[prop] = (value ? 1 : 0) as any;\n }\n } else {\n finalProps.opts.playerVars[prop] = value as any;\n }\n }\n }\n return (\n <YouTubeImpl\n ref={onRef}\n {...finalProps}\n iframeClassName={props.className}\n />\n );\n }\n);\n\nexport const youtubeMeta: ComponentMeta<YouTubeProps> = {\n name: \"hostless-youtube\",\n displayName: \"YouTube\",\n importName: \"YouTube\",\n importPath: \"@plasmicpkgs/react-youtube\",\n props: {\n videoId: {\n type: \"string\",\n defaultValue: \"R6MeLqRQzYw\",\n displayName: \"Video ID\",\n description: \"The ID for the YouTube video\",\n },\n autoplay: {\n type: \"boolean\",\n displayName: \"Auto Play\",\n description:\n \"Whether the video should automatically start playing when the player loads\",\n defaultValueHint: false,\n hidden: (props) => !props.mute,\n },\n cc_load_policy: {\n type: \"boolean\",\n displayName: \"Show Captions\",\n description:\n \"Whether the captions should be shown by default, even if the user has turned captions off\",\n defaultValueHint: false,\n },\n start: {\n type: \"number\",\n displayName: \"Start\",\n description:\n \"The video should begin at this amount of seconds from the start of the video\",\n defaultValueHint: 0,\n },\n end: {\n type: \"number\",\n displayName: \"End\",\n description:\n \"Stop playing the video after this amount of seconds (measured from the start of the video)\",\n },\n color: {\n type: \"choice\",\n displayName: \"Color\",\n options: [\"red\", \"white\"],\n description:\n \"The color used in the display bar to highlight how much of the video the viewer has already seen\",\n defaultValueHint: \"red\",\n },\n controls: {\n type: \"boolean\",\n displayName: \"Show Controls\",\n description:\n \"Whether the YouTube video player controls should be displayed\",\n defaultValueHint: true,\n },\n disablekb: {\n type: \"boolean\",\n displayName: \"Disable Keyboard\",\n description: \"Whether the keyboard controls should be disabled\",\n defaultValueHint: false,\n },\n fs: {\n type: \"boolean\",\n displayName: \"FullScreen Button\",\n description: \"Whether the fullscreen button should be displayed\",\n defaultValueHint: true,\n },\n loop: {\n type: \"boolean\",\n displayName: \"Loop\",\n description: \"Whether the video should be played again after it finishes\",\n defaultValueHint: false,\n },\n modestbranding: {\n type: \"boolean\",\n displayName: \"Hide Logo\",\n description: \"Hide the YouTube logo in the control bar\",\n defaultValueHint: false,\n },\n mute: {\n type: \"boolean\",\n displayName: \"Mute\",\n description: \"Whether the video should be muted\",\n defaultValueHint: false,\n },\n playsinline: {\n type: \"boolean\",\n displayName: \"Play Inline\",\n description:\n \"Whether the video should be played inline or fullscreen on iOS\",\n defaultValueHint: false,\n },\n rel: {\n type: \"boolean\",\n displayName: \"Related Videos\",\n description:\n \"Whether it should show related videos when the video ends (if false, it shows other videos from the same channel)\",\n defaultValueHint: true,\n },\n },\n isDefaultExport: true,\n defaultStyles: {\n height: \"390px\",\n width: \"640px\",\n maxHeight: \"100%\",\n maxWidth: \"100%\",\n },\n};\n\nexport function registerYouTube(\n loader?: { registerComponent: typeof registerComponent },\n customYouTubeMeta?: ComponentMeta<YouTubeProps>\n) {\n if (loader) {\n loader.registerComponent(YouTube, customYouTubeMeta ?? youtubeMeta);\n } else {\n registerComponent(YouTube, customYouTubeMeta ?? youtubeMeta);\n }\n}\n\nexport default YouTube;\n"],"names":["playerParams","booleanParams","booleanParamsSet","Set","YouTube","React","forwardRef","props","ref","internalRef","useRef","onRef","useCallback","player","current","useEffect","mute","undefined","getInternalPlayer","unMute","finalProps","prop","value","opts","playerVars","has","YouTubeImpl","iframeClassName","className","youtubeMeta","name","displayName","importName","importPath","videoId","type","defaultValue","description","autoplay","defaultValueHint","hidden","cc_load_policy","start","end","color","options","controls","disablekb","fs","loop","modestbranding","playsinline","rel","isDefaultExport","defaultStyles","height","width","maxHeight","maxWidth","registerYouTube","loader","customYouTubeMeta","registerComponent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAcA,IAAMA,YAAY,GAAG,CACnB,UAAU,EACV,gBAAgB,EAChB,OAAO,EACP,UAAU,EACV,WAAW,EACX,aAAa,EACb,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,gB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EAAE,WAAW;MACxBM,WAAW,EAAE,0CAA0C;MACvDE,gBAAgB,EAAE;KACnB;IACDvB,IAAI,EAAE;MACJmB,IAAI,EAAE,SAAS;MACfJ,WAAW,EAAE,MAAM;MACnBM,WAAW,EAAE,mCAAmC;MAChDE,gBAAgB,EAAE;KACnB;IACDY,WAAW,EAAE;MACXhB,IAAI,EAAE,SAAS;MACfJ,WAAW,EAAE,aAAa;MAC1BM,WAAW,EACT,gEAAgE;MAClEE,gBAAgB,EAAE;KACnB;IACDa,GAAG,EAAE;MACHjB,IAAI,EAAE,SAAS;MACfJ,WAAW,EAAE,gBAAgB;MAC7BM,WAAW,EACT,mHAAmH;MACrHE,gBAAgB,EAAE;;GAErB;EACDc,eAAe,EAAE,IAAI;EACrBC,aAAa,EAAE;IACbC,MAAM,EAAE,OAAO;IACfC,KAAK,EAAE,OAAO;IACdC,SAAS,EAAE,MAAM;IACjBC,QAAQ,EAAE;;;SAIEC,eAAe,CAC7BC,MAAwD,EACxDC,iBAA+C;EAE/C,IAAID,MAAM,EAAE;IACVA,MAAM,CAACE,iBAAiB,CAAC1D,OAAO,EAAEyD,iBAAiB,WAAjBA,iBAAiB,GAAIhC,WAAW,CAAC;GACpE,MAAM;IACLiC,iBAAiB,CAAC1D,OAAO,EAAEyD,iBAAiB,WAAjBA,iBAAiB,GAAIhC,WAAW,CAAC;;AAEhE;;;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("@plasmicapp/host/registerComponent")),o=e(require("react")),a=e(require("react-youtube"));function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&(e[a]=o[a])}return e}).apply(this,arguments)}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,a=new Array(t);o<t;o++)a[o]=e[o];return a}var n=["autoplay","cc_load_policy","color","controls","disablekb","enablejsapi","end","fs","hl","iv_load_policy","list","listType","loop","modestbranding","origin","playlist","playsinline","rel","start"],i=new Set(["autoplay","cc_load_policy","controls","disablekb","fs","loop","modestbranding","playsinline","rel"]),s=o.forwardRef((function(e,t){var s=o.useRef(null),d=o.useCallback((function(e){s.current=e,t&&("function"==typeof t?t(e):t.current=e)}),[t]);o.useEffect((function(){var t,o,a,r;void 0!==e.mute&&(e.mute?null==(t=s.current)||null==(o=t.getInternalPlayer())||o.mute():null==(a=s.current)||null==(r=a.getInternalPlayer())||r.unMute())}),[e.mute,s]);for(var u,p=r({},e),h=function(e,t){var o="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(o)return(o=o.call(e)).next.bind(o);if(Array.isArray(e)||(o=function(e,t){if(e){if("string"==typeof e)return l(e,void 0);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?l(e,void 0):void 0}}(e))){o&&(e=o);var a=0;return function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(n);!(u=h()).done;){var c=u.value;if(c in p){var y=p[c];delete p[c],p.opts||(p.opts={}),p.opts.playerVars||(p.opts.playerVars={}),i.has(c)?"cc_load_policy"===c||"modestbranding"===c?y?p.opts.playerVars[c]=1:delete p.opts.playerVars[c]:p.opts.playerVars[c]=y?1:0:p.opts.playerVars[c]=y}}return o.createElement(a,Object.assign({ref:d},p,{iframeClassName:e.className}))})),d={name:"hostless-youtube",displayName:"YouTube",importName:"YouTube",importPath:"@plasmicpkgs/react-youtube",props:{videoId:{type:"string",defaultValue:"R6MeLqRQzYw",displayName:"Video ID",description:"The ID for the YouTube video"},autoplay:{type:"boolean",displayName:"Auto Play",description:"Whether the video should automatically start playing when the player loads",defaultValueHint:!1,hidden:function(e){return!e.mute}},cc_load_policy:{type:"boolean",displayName:"Show Captions",description:"Whether the captions should be shown by default, even if the user has turned captions off",defaultValueHint:!1},start:{type:"number",displayName:"Start",description:"The video should begin at this amount of seconds from the start of the video",defaultValueHint:0},end:{type:"number",displayName:"End",description:"Stop playing the video after this amount of seconds (measured from the start of the video)"},color:{type:"choice",displayName:"Color",options:["red","white"],description:"The color used in the display bar to highlight how much of the video the viewer has already seen",defaultValueHint:"red"},controls:{type:"boolean",displayName:"Show Controls",description:"Whether the YouTube video player controls should be displayed",defaultValueHint:!0},disablekb:{type:"boolean",displayName:"Disable Keyboard",description:"Whether the keyboard controls should be disabled",defaultValueHint:!1},fs:{type:"boolean",displayName:"FullScreen Button",description:"Whether the fullscreen button should be displayed",defaultValueHint:!0},loop:{type:"boolean",displayName:"Loop",description:"Whether the video should be played again after it finishes",defaultValueHint:!1},modestbranding:{type:"boolean",displayName:"Hide Logo",description:"Hide the YouTube logo in the control bar",defaultValueHint:!1},mute:{type:"boolean",displayName:"Mute",description:"Whether the video should be muted",defaultValueHint:!1},playsinline:{type:"boolean",displayName:"Play Inline",description:"Whether the video should be played inline or fullscreen on iOS",defaultValueHint:!1},rel:{type:"boolean",displayName:"Related Videos",description:"Whether it should show related videos when the video ends (if false, it shows other videos from the same channel)",defaultValueHint:!0}},isDefaultExport:!0,defaultStyles:{height:"390px",width:"640px",maxHeight:"100%",maxWidth:"100%"}};exports.default=s,exports.registerYouTube=function(e,o){e?e.registerComponent(s,null!=o?o:d):t(s,null!=o?o:d)},exports.youtubeMeta=d;
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("@plasmicapp/host/registerComponent")),o=e(require("react")),a=e(require("react-youtube"));function l(){return(l=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&(e[a]=o[a])}return e}).apply(this,arguments)}var i=["autoplay","cc_load_policy","color","controls","disablekb","enablejsapi","end","fs","hl","iv_load_policy","list","listType","loop","modestbranding","origin","playlist","playsinline","rel","start"],n=new Set(["autoplay","cc_load_policy","controls","disablekb","fs","loop","modestbranding","playsinline","rel"]),r=o.forwardRef((function(e,t){var r=o.useRef(null),s=o.useCallback((function(e){r.current=e,t&&("function"==typeof t?t(e):t.current=e)}),[t]);o.useEffect((function(){var t,o,a,l;void 0!==e.mute&&(e.mute?null==(t=r.current)||null==(o=t.getInternalPlayer())||o.mute():null==(a=r.current)||null==(l=a.getInternalPlayer())||l.unMute())}),[e.mute,r]);for(var d=l({},e),u=0,p=i;u<p.length;u++){var h=p[u];if(h in d){var c=d[h];delete d[h],d.opts||(d.opts={}),d.opts.playerVars||(d.opts.playerVars={}),n.has(h)?"cc_load_policy"===h||"modestbranding"===h?c?d.opts.playerVars[h]=1:delete d.opts.playerVars[h]:d.opts.playerVars[h]=c?1:0:d.opts.playerVars[h]=c}}return o.createElement(a,Object.assign({ref:s},d,{iframeClassName:e.className}))})),s={name:"hostless-youtube",displayName:"YouTube",importName:"YouTube",importPath:"@plasmicpkgs/react-youtube",props:{videoId:{type:"string",defaultValue:"R6MeLqRQzYw",displayName:"Video ID",description:"The ID for the YouTube video"},autoplay:{type:"boolean",displayName:"Auto Play",description:"Whether the video should automatically start playing when the player loads",defaultValueHint:!1,hidden:function(e){return!e.mute}},cc_load_policy:{type:"boolean",displayName:"Show Captions",description:"Whether the captions should be shown by default, even if the user has turned captions off",defaultValueHint:!1},start:{type:"number",displayName:"Start",description:"The video should begin at this amount of seconds from the start of the video",defaultValueHint:0},end:{type:"number",displayName:"End",description:"Stop playing the video after this amount of seconds (measured from the start of the video)"},color:{type:"choice",displayName:"Color",options:["red","white"],description:"The color used in the display bar to highlight how much of the video the viewer has already seen",defaultValueHint:"red"},controls:{type:"boolean",displayName:"Show Controls",description:"Whether the YouTube video player controls should be displayed",defaultValueHint:!0},disablekb:{type:"boolean",displayName:"Disable Keyboard",description:"Whether the keyboard controls should be disabled",defaultValueHint:!1},fs:{type:"boolean",displayName:"FullScreen Button",description:"Whether the fullscreen button should be displayed",defaultValueHint:!0},loop:{type:"boolean",displayName:"Loop",description:"Whether the video should be played again after it finishes",defaultValueHint:!1},modestbranding:{type:"boolean",displayName:"Hide Logo",description:"Hide the YouTube logo in the control bar",defaultValueHint:!1},mute:{type:"boolean",displayName:"Mute",description:"Whether the video should be muted",defaultValueHint:!1},playsinline:{type:"boolean",displayName:"Play Inline",description:"Whether the video should be played inline or fullscreen on iOS",defaultValueHint:!1},rel:{type:"boolean",displayName:"Related Videos",description:"Whether it should show related videos when the video ends (if false, it shows other videos from the same channel)",defaultValueHint:!0}},isDefaultExport:!0,defaultStyles:{height:"390px",width:"640px",maxHeight:"100%",maxWidth:"100%"}};exports.default=r,exports.registerYouTube=function(e,o){e?e.registerComponent(r,null!=o?o:s):t(r,null!=o?o:s)},exports.youtubeMeta=s;
2
2
  //# sourceMappingURL=react-youtube.cjs.production.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-youtube.cjs.production.min.js","sources":["../src/index.tsx"],"sourcesContent":["import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport React from \"react\";\nimport YouTubeImpl, { YouTubeProps as YouTubeImplProps } from \"react-youtube\";\nimport type { Options } from \"youtube-player/dist/types\";\n\ntype PlayerVars = Exclude<Options[\"playerVars\"], undefined>;\nexport type YouTubeProps = YouTubeImplProps &\n {\n [prop in keyof PlayerVars]:\n | PlayerVars[prop]\n | (prop extends typeof booleanParams[number] ? boolean : never);\n } & { mute?: boolean };\nconst playerParams = [\n \"autoplay\",\n \"cc_load_policy\",\n \"color\",\n \"controls\",\n \"disablekb\",\n \"enablejsapi\",\n \"end\",\n \"fs\",\n \"hl\",\n \"iv_load_policy\",\n \"list\",\n \"listType\",\n \"loop\",\n \"modestbranding\",\n \"origin\",\n \"playlist\",\n \"playsinline\",\n \"rel\",\n \"start\",\n] as const;\n\nconst booleanParams = [\n \"autoplay\",\n \"cc_load_policy\",\n \"controls\",\n \"disablekb\",\n \"fs\",\n \"loop\",\n \"modestbranding\",\n \"playsinline\",\n \"rel\",\n] as const;\n\nconst booleanParamsSet = new Set<string>(booleanParams);\n\nconst YouTube = React.forwardRef<YouTubeImpl, YouTubeProps>(\n (props: YouTubeProps, ref) => {\n const internalRef = React.useRef<YouTubeImpl | null>(null);\n\n const onRef = React.useCallback(\n (player: YouTubeImpl | null) => {\n internalRef.current = player;\n if (ref) {\n if (typeof ref === \"function\") {\n ref(player);\n } else {\n ref.current = player;\n }\n }\n },\n [ref]\n );\n\n React.useEffect(() => {\n if (props.mute !== undefined) {\n if (props.mute) {\n internalRef.current?.getInternalPlayer()?.mute();\n } else {\n internalRef.current?.getInternalPlayer()?.unMute();\n }\n }\n }, [props.mute, internalRef]);\n\n const finalProps = { ...props };\n for (const prop of playerParams) {\n if (prop in finalProps) {\n const value = finalProps[prop];\n delete finalProps[prop];\n if (!finalProps.opts) {\n finalProps.opts = {};\n }\n if (!finalProps.opts.playerVars) {\n finalProps.opts.playerVars = {};\n }\n if (booleanParamsSet.has(prop)) {\n if (prop === \"cc_load_policy\" || prop === \"modestbranding\") {\n // undefined or 1\n if (value) {\n finalProps.opts.playerVars[prop] = 1;\n } else {\n delete finalProps.opts.playerVars[prop];\n }\n } else {\n // 0 or 1\n finalProps.opts.playerVars[prop] = (value ? 1 : 0) as any;\n }\n } else {\n finalProps.opts.playerVars[prop] = value as any;\n }\n }\n }\n return (\n <YouTubeImpl\n ref={onRef}\n {...finalProps}\n iframeClassName={props.className}\n />\n );\n }\n);\n\nexport const youtubeMeta: ComponentMeta<YouTubeProps> = {\n name: \"hostless-youtube\",\n displayName: \"YouTube\",\n importName: \"YouTube\",\n importPath: \"@plasmicpkgs/react-youtube\",\n props: {\n videoId: {\n type: \"string\",\n defaultValue: \"R6MeLqRQzYw\",\n displayName: \"Video ID\",\n description: \"The ID for the YouTube video\",\n },\n autoplay: {\n type: \"boolean\",\n displayName: \"Auto Play\",\n description:\n \"Whether the video should automatically start playing when the player loads\",\n defaultValueHint: false,\n hidden: (props) => !props.mute,\n },\n cc_load_policy: {\n type: \"boolean\",\n displayName: \"Show Captions\",\n description:\n \"Whether the captions should be shown by default, even if the user has turned captions off\",\n defaultValueHint: false,\n },\n start: {\n type: \"number\",\n displayName: \"Start\",\n description:\n \"The video should begin at this amount of seconds from the start of the video\",\n defaultValueHint: 0,\n },\n end: {\n type: \"number\",\n displayName: \"End\",\n description:\n \"Stop playing the video after this amount of seconds (measured from the start of the video)\",\n },\n color: {\n type: \"choice\",\n displayName: \"Color\",\n options: [\"red\", \"white\"],\n description:\n \"The color used in the display bar to highlight how much of the video the viewer has already seen\",\n defaultValueHint: \"red\",\n },\n controls: {\n type: \"boolean\",\n displayName: \"Show Controls\",\n description:\n \"Whether the YouTube video player controls should be displayed\",\n defaultValueHint: true,\n },\n disablekb: {\n type: \"boolean\",\n displayName: \"Disable Keyboard\",\n description: \"Whether the keyboard controls should be disabled\",\n defaultValueHint: false,\n },\n fs: {\n type: \"boolean\",\n displayName: \"FullScreen Button\",\n description: \"Whether the fullscreen button should be displayed\",\n defaultValueHint: true,\n },\n loop: {\n type: \"boolean\",\n displayName: \"Loop\",\n description: \"Whether the video should be played again after it finishes\",\n defaultValueHint: false,\n },\n modestbranding: {\n type: \"boolean\",\n displayName: \"Hide Logo\",\n description: \"Hide the YouTube logo in the control bar\",\n defaultValueHint: false,\n },\n mute: {\n type: \"boolean\",\n displayName: \"Mute\",\n description: \"Whether the video should be muted\",\n defaultValueHint: false,\n },\n playsinline: {\n type: \"boolean\",\n displayName: \"Play Inline\",\n description:\n \"Whether the video should be played inline or fullscreen on iOS\",\n defaultValueHint: false,\n },\n rel: {\n type: \"boolean\",\n displayName: \"Related Videos\",\n description:\n \"Whether it should show related videos when the video ends (if false, it shows other videos from the same channel)\",\n defaultValueHint: true,\n },\n },\n isDefaultExport: true,\n defaultStyles: {\n height: \"390px\",\n width: \"640px\",\n maxHeight: \"100%\",\n maxWidth: \"100%\",\n },\n};\n\nexport function registerYouTube(\n loader?: { registerComponent: typeof registerComponent },\n customYouTubeMeta?: ComponentMeta<YouTubeProps>\n) {\n if (loader) {\n loader.registerComponent(YouTube, customYouTubeMeta ?? youtubeMeta);\n } else {\n registerComponent(YouTube, customYouTubeMeta ?? youtubeMeta);\n }\n}\n\nexport default YouTube;\n"],"names":["playerParams","booleanParamsSet","Set","YouTube","React","forwardRef","props","ref","internalRef","useRef","onRef","useCallback","player","current","useEffect","undefined","mute","getInternalPlayer","unMute","finalProps","prop","value","opts","playerVars","has","YouTubeImpl","iframeClassName","className","youtubeMeta","name","displayName","importName","importPath","videoId","type","defaultValue","description","autoplay","defaultValueHint","hidden","cc_load_policy","start","end","color","options","controls","disablekb","fs","loop","modestbranding","playsinline","rel","isDefaultExport","defaultStyles","height","width","maxHeight","maxWidth","loader","customYouTubeMeta","registerComponent"],"mappings":"8iBAcA,IAAMA,EAAe,CACnB,WACA,iBACA,QACA,WACA,YACA,cACA,MACA,KACA,KACA,iBACA,OACA,WACA,OACA,iBACA,SACA,WACA,cACA,MACA,SAeIC,EAAmB,IAAIC,IAZP,CACpB,WACA,iBACA,WACA,YACA,KACA,OACA,iBACA,cACA,QAKIC,EAAUC,EAAMC,YACpB,SAACC,EAAqBC,OACdC,EAAcJ,EAAMK,OAA2B,MAE/CC,EAAQN,EAAMO,aAClB,SAACC,GACCJ,EAAYK,QAAUD,EAClBL,IACiB,mBAARA,EACTA,EAAIK,GAEJL,EAAIM,QAAUD,KAIpB,CAACL,IAGHH,EAAMU,WAAU,4BACKC,IAAfT,EAAMU,OACJV,EAAMU,cACRR,EAAYK,qBAASI,wBAAqBD,gBAE1CR,EAAYK,qBAASI,wBAAqBC,YAG7C,CAACZ,EAAMU,KAAMR,cAEVW,OAAkBb,yrBACLN,kBAAc,KAAtBoB,aACLA,KAAQD,EAAY,KAChBE,EAAQ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AAa,2CACbE,kBAAkB,GAEpBtB,KAAM,CACJkB,KAAM,UACNJ,YAAa,OACbM,YAAa,oCACbE,kBAAkB,GAEpBY,YAAa,CACXhB,KAAM,UACNJ,YAAa,cACbM,YACE,iEACFE,kBAAkB,GAEpBa,IAAK,CACHjB,KAAM,UACNJ,YAAa,iBACbM,YACE,oHACFE,kBAAkB,IAGtBc,iBAAiB,EACjBC,cAAe,CACbC,OAAQ,QACRC,MAAO,QACPC,UAAW,OACXC,SAAU,4DAKZC,EACAC,GAEID,EACFA,EAAOE,kBAAkBzD,QAASwD,EAAAA,EAAqB/B,GAEvDgC,EAAkBzD,QAASwD,EAAAA,EAAqB/B"}
1
+ {"version":3,"file":"react-youtube.cjs.production.min.js","sources":["../src/index.tsx"],"sourcesContent":["import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport React from \"react\";\nimport YouTubeImpl, { YouTubeProps as YouTubeImplProps } from \"react-youtube\";\nimport type { Options } from \"youtube-player/dist/types\";\n\ntype PlayerVars = Exclude<Options[\"playerVars\"], undefined>;\nexport type YouTubeProps = YouTubeImplProps &\n {\n [prop in keyof PlayerVars]:\n | PlayerVars[prop]\n | (prop extends typeof booleanParams[number] ? boolean : never);\n } & { mute?: boolean };\nconst playerParams = [\n \"autoplay\",\n \"cc_load_policy\",\n \"color\",\n \"controls\",\n \"disablekb\",\n \"enablejsapi\",\n \"end\",\n \"fs\",\n \"hl\",\n \"iv_load_policy\",\n \"list\",\n \"listType\",\n \"loop\",\n \"modestbranding\",\n \"origin\",\n \"playlist\",\n \"playsinline\",\n \"rel\",\n \"start\",\n] as const;\n\nconst booleanParams = [\n \"autoplay\",\n \"cc_load_policy\",\n \"controls\",\n \"disablekb\",\n \"fs\",\n \"loop\",\n \"modestbranding\",\n \"playsinline\",\n \"rel\",\n] as const;\n\nconst booleanParamsSet = new Set<string>(booleanParams);\n\nconst YouTube = React.forwardRef<YouTubeImpl, YouTubeProps>(\n (props: YouTubeProps, ref) => {\n const internalRef = React.useRef<YouTubeImpl | null>(null);\n\n const onRef = React.useCallback(\n (player: YouTubeImpl | null) => {\n internalRef.current = player;\n if (ref) {\n if (typeof ref === \"function\") {\n ref(player);\n } else {\n ref.current = player;\n }\n }\n },\n [ref]\n );\n\n React.useEffect(() => {\n if (props.mute !== undefined) {\n if (props.mute) {\n internalRef.current?.getInternalPlayer()?.mute();\n } else {\n internalRef.current?.getInternalPlayer()?.unMute();\n }\n }\n }, [props.mute, internalRef]);\n\n const finalProps = { ...props };\n for (const prop of playerParams) {\n if (prop in finalProps) {\n const value = finalProps[prop];\n delete finalProps[prop];\n if (!finalProps.opts) {\n finalProps.opts = {};\n }\n if (!finalProps.opts.playerVars) {\n finalProps.opts.playerVars = {};\n }\n if (booleanParamsSet.has(prop)) {\n if (prop === \"cc_load_policy\" || prop === \"modestbranding\") {\n // undefined or 1\n if (value) {\n finalProps.opts.playerVars[prop] = 1;\n } else {\n delete finalProps.opts.playerVars[prop];\n }\n } else {\n // 0 or 1\n finalProps.opts.playerVars[prop] = (value ? 1 : 0) as any;\n }\n } else {\n finalProps.opts.playerVars[prop] = value as any;\n }\n }\n }\n return (\n <YouTubeImpl\n ref={onRef}\n {...finalProps}\n iframeClassName={props.className}\n />\n );\n }\n);\n\nexport const youtubeMeta: ComponentMeta<YouTubeProps> = {\n name: \"hostless-youtube\",\n displayName: \"YouTube\",\n importName: \"YouTube\",\n importPath: \"@plasmicpkgs/react-youtube\",\n props: {\n videoId: {\n type: \"string\",\n defaultValue: \"R6MeLqRQzYw\",\n displayName: \"Video ID\",\n description: \"The ID for the YouTube video\",\n },\n autoplay: {\n type: \"boolean\",\n displayName: \"Auto Play\",\n description:\n \"Whether the video should automatically start playing when the player loads\",\n defaultValueHint: false,\n hidden: (props) => !props.mute,\n },\n cc_load_policy: {\n type: \"boolean\",\n displayName: \"Show Captions\",\n description:\n \"Whether the captions should be shown by default, even if the user has turned captions off\",\n defaultValueHint: false,\n },\n start: {\n type: \"number\",\n displayName: \"Start\",\n description:\n \"The video should begin at this amount of seconds from the start of the video\",\n defaultValueHint: 0,\n },\n end: {\n type: \"number\",\n displayName: \"End\",\n description:\n \"Stop playing the video after this amount of seconds (measured from the start of the video)\",\n },\n color: {\n type: \"choice\",\n displayName: \"Color\",\n options: [\"red\", \"white\"],\n description:\n \"The color used in the display bar to highlight how much of the video the viewer has already seen\",\n defaultValueHint: \"red\",\n },\n controls: {\n type: \"boolean\",\n displayName: \"Show Controls\",\n description:\n \"Whether the YouTube video player controls should be displayed\",\n defaultValueHint: true,\n },\n disablekb: {\n type: \"boolean\",\n displayName: \"Disable Keyboard\",\n description: \"Whether the keyboard controls should be disabled\",\n defaultValueHint: false,\n },\n fs: {\n type: \"boolean\",\n displayName: \"FullScreen Button\",\n description: \"Whether the fullscreen button should be displayed\",\n defaultValueHint: true,\n },\n loop: {\n type: \"boolean\",\n displayName: \"Loop\",\n description: \"Whether the video should be played again after it finishes\",\n defaultValueHint: false,\n },\n modestbranding: {\n type: \"boolean\",\n displayName: \"Hide Logo\",\n description: \"Hide the YouTube logo in the control bar\",\n defaultValueHint: false,\n },\n mute: {\n type: \"boolean\",\n displayName: \"Mute\",\n description: \"Whether the video should be muted\",\n defaultValueHint: false,\n },\n playsinline: {\n type: \"boolean\",\n displayName: \"Play Inline\",\n description:\n \"Whether the video should be played inline or fullscreen on iOS\",\n defaultValueHint: false,\n },\n rel: {\n type: \"boolean\",\n displayName: \"Related Videos\",\n description:\n \"Whether it should show related videos when the video ends (if false, it shows other videos from the same channel)\",\n defaultValueHint: true,\n },\n },\n isDefaultExport: true,\n defaultStyles: {\n height: \"390px\",\n width: \"640px\",\n maxHeight: \"100%\",\n maxWidth: \"100%\",\n },\n};\n\nexport function registerYouTube(\n loader?: { registerComponent: typeof registerComponent },\n customYouTubeMeta?: ComponentMeta<YouTubeProps>\n) {\n if (loader) {\n loader.registerComponent(YouTube, customYouTubeMeta ?? youtubeMeta);\n } else {\n registerComponent(YouTube, customYouTubeMeta ?? youtubeMeta);\n }\n}\n\nexport default YouTube;\n"],"names":["playerParams","booleanParamsSet","Set","YouTube","React","forwardRef","props","ref","internalRef","useRef","onRef","useCallback","player","current","useEffect","undefined","mute","_internalRef$current","getInternalPlayer","_internalRef$current$","_internalRef$current2","_internalRef$current3","unMute","finalProps","prop","value","opts","playerVars","has","YouTubeImpl","iframeClassName","className","youtubeMeta","name","displayName","importName","importPath","videoId","type","defaultValue","description","autoplay","defaultValueHint","hidden","cc_load_policy","start","end","color","options","controls","disablekb","fs","loop","modestbranding","playsinline","rel","isDefaultExport","defaultStyles","height","width","maxHeight","maxWidth","loader","customYouTubeMeta","registerComponent"],"mappings":"wdAcA,IAAMA,EAAe,CACnB,WACA,iBACA,QACA,WACA,YACA,cACA,MACA,KACA,KACA,iBACA,OACA,WACA,OACA,iBACA,SACA,WACA,cACA,MACA,SAeIC,EAAmB,IAAIC,IAZP,CACpB,WACA,iBACA,WACA,YACA,KACA,OACA,iBACA,cACA,QAKIC,EAAUC,EAAMC,YACpB,SAACC,EAAqBC,GACpB,IAAMC,EAAcJ,EAAMK,OAA2B,MAE/CC,EAAQN,EAAMO,aAClB,SAACC,GACCJ,EAAYK,QAAUD,EAClBL,IACiB,mBAARA,EACTA,EAAIK,GAEJL,EAAIM,QAAUD,KAIpB,CAACL,IAGHH,EAAMU,WAAU,WAEI,iBADCC,IAAfT,EAAMU,OACJV,EAAMU,cACRR,EAAYK,mBAAZI,EAAqBC,sBAArBC,EAA0CH,gBAE1CR,EAAYK,mBAAZO,EAAqBF,sBAArBG,EAA0CC,YAG7C,CAAChB,EAAMU,KAAMR,IAGhB,IADA,IAAMe,OAAkBjB,SACLN,iBAAc,CAA5B,IAAMwB,OACT,GAAIA,KAAQD,EAAY,CACtB,IAAME,EAAQF,EAAWC,UAClBD,EAAWC,GACbD,EAAWG,OACdH,EAAWG,KAAO,IAEfH,EAAWG,KAAKC,aACnBJ,EAAWG,KAAKC,WAAa,IAE3B1B,EAAiB2B,IAAIJ,G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YAAa,cACbM,YACE,iEACFE,kBAAkB,GAEpBa,IAAK,CACHjB,KAAM,UACNJ,YAAa,iBACbM,YACE,oHACFE,kBAAkB,IAGtBc,iBAAiB,EACjBC,cAAe,CACbC,OAAQ,QACRC,MAAO,QACPC,UAAW,OACXC,SAAU,4DAKZC,EACAC,GAEID,EACFA,EAAOE,kBAAkB7D,QAAS4D,EAAAA,EAAqB/B,GAEvDgC,EAAkB7D,QAAS4D,EAAAA,EAAqB/B"}
@@ -3,61 +3,20 @@ import React from 'react';
3
3
  import YouTubeImpl from 'react-youtube';
4
4
 
5
5
  function _extends() {
6
- _extends = Object.assign || function (target) {
6
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
7
7
  for (var i = 1; i < arguments.length; i++) {
8
8
  var source = arguments[i];
9
-
10
9
  for (var key in source) {
11
10
  if (Object.prototype.hasOwnProperty.call(source, key)) {
12
11
  target[key] = source[key];
13
12
  }
14
13
  }
15
14
  }
16
-
17
15
  return target;
18
16
  };
19
-
20
17
  return _extends.apply(this, arguments);
21
18
  }
22
19
 
23
- function _unsupportedIterableToArray(o, minLen) {
24
- if (!o) return;
25
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
26
- var n = Object.prototype.toString.call(o).slice(8, -1);
27
- if (n === "Object" && o.constructor) n = o.constructor.name;
28
- if (n === "Map" || n === "Set") return Array.from(o);
29
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
30
- }
31
-
32
- function _arrayLikeToArray(arr, len) {
33
- if (len == null || len > arr.length) len = arr.length;
34
-
35
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
36
-
37
- return arr2;
38
- }
39
-
40
- function _createForOfIteratorHelperLoose(o, allowArrayLike) {
41
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
42
- if (it) return (it = it.call(o)).next.bind(it);
43
-
44
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
45
- if (it) o = it;
46
- var i = 0;
47
- return function () {
48
- if (i >= o.length) return {
49
- done: true
50
- };
51
- return {
52
- done: false,
53
- value: o[i++]
54
- };
55
- };
56
- }
57
-
58
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
59
- }
60
-
61
20
  var playerParams = ["autoplay", "cc_load_policy", "color", "controls", "disablekb", "enablejsapi", "end", "fs", "hl", "iv_load_policy", "list", "listType", "loop", "modestbranding", "origin", "playlist", "playsinline", "rel", "start"];
62
21
  var booleanParams = ["autoplay", "cc_load_policy", "controls", "disablekb", "fs", "loop", "modestbranding", "playsinline", "rel"];
63
22
  var booleanParamsSet = /*#__PURE__*/new Set(booleanParams);
@@ -65,7 +24,6 @@ var YouTube = /*#__PURE__*/React.forwardRef(function (props, ref) {
65
24
  var internalRef = React.useRef(null);
66
25
  var onRef = React.useCallback(function (player) {
67
26
  internalRef.current = player;
68
-
69
27
  if (ref) {
70
28
  if (typeof ref === "function") {
71
29
  ref(player);
@@ -78,33 +36,25 @@ var YouTube = /*#__PURE__*/React.forwardRef(function (props, ref) {
78
36
  if (props.mute !== undefined) {
79
37
  if (props.mute) {
80
38
  var _internalRef$current, _internalRef$current$;
81
-
82
39
  (_internalRef$current = internalRef.current) == null ? void 0 : (_internalRef$current$ = _internalRef$current.getInternalPlayer()) == null ? void 0 : _internalRef$current$.mute();
83
40
  } else {
84
41
  var _internalRef$current2, _internalRef$current3;
85
-
86
42
  (_internalRef$current2 = internalRef.current) == null ? void 0 : (_internalRef$current3 = _internalRef$current2.getInternalPlayer()) == null ? void 0 : _internalRef$current3.unMute();
87
43
  }
88
44
  }
89
45
  }, [props.mute, internalRef]);
90
-
91
46
  var finalProps = _extends({}, props);
92
-
93
- for (var _iterator = _createForOfIteratorHelperLoose(playerParams), _step; !(_step = _iterator()).done;) {
94
- var prop = _step.value;
95
-
47
+ for (var _i = 0, _playerParams = playerParams; _i < _playerParams.length; _i++) {
48
+ var prop = _playerParams[_i];
96
49
  if (prop in finalProps) {
97
50
  var value = finalProps[prop];
98
51
  delete finalProps[prop];
99
-
100
52
  if (!finalProps.opts) {
101
53
  finalProps.opts = {};
102
54
  }
103
-
104
55
  if (!finalProps.opts.playerVars) {
105
56
  finalProps.opts.playerVars = {};
106
57
  }
107
-
108
58
  if (booleanParamsSet.has(prop)) {
109
59
  if (prop === "cc_load_policy" || prop === "modestbranding") {
110
60
  // undefined or 1
@@ -122,7 +72,6 @@ var YouTube = /*#__PURE__*/React.forwardRef(function (props, ref) {
122
72
  }
123
73
  }
124
74
  }
125
-
126
75
  return React.createElement(YouTubeImpl, Object.assign({
127
76
  ref: onRef
128
77
  }, finalProps, {
@@ -1 +1 @@
1
- {"version":3,"file":"react-youtube.esm.js","sources":["../src/index.tsx"],"sourcesContent":["import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport React from \"react\";\nimport YouTubeImpl, { YouTubeProps as YouTubeImplProps } from \"react-youtube\";\nimport type { Options } from \"youtube-player/dist/types\";\n\ntype PlayerVars = Exclude<Options[\"playerVars\"], undefined>;\nexport type YouTubeProps = YouTubeImplProps &\n {\n [prop in keyof PlayerVars]:\n | PlayerVars[prop]\n | (prop extends typeof booleanParams[number] ? boolean : never);\n } & { mute?: boolean };\nconst playerParams = [\n \"autoplay\",\n \"cc_load_policy\",\n \"color\",\n \"controls\",\n \"disablekb\",\n \"enablejsapi\",\n \"end\",\n \"fs\",\n \"hl\",\n \"iv_load_policy\",\n \"list\",\n \"listType\",\n \"loop\",\n \"modestbranding\",\n \"origin\",\n \"playlist\",\n \"playsinline\",\n \"rel\",\n \"start\",\n] as const;\n\nconst booleanParams = [\n \"autoplay\",\n \"cc_load_policy\",\n \"controls\",\n \"disablekb\",\n \"fs\",\n \"loop\",\n \"modestbranding\",\n \"playsinline\",\n \"rel\",\n] as const;\n\nconst booleanParamsSet = new Set<string>(booleanParams);\n\nconst YouTube = React.forwardRef<YouTubeImpl, YouTubeProps>(\n (props: YouTubeProps, ref) => {\n const internalRef = React.useRef<YouTubeImpl | null>(null);\n\n const onRef = React.useCallback(\n (player: YouTubeImpl | null) => {\n internalRef.current = player;\n if (ref) {\n if (typeof ref === \"function\") {\n ref(player);\n } else {\n ref.current = player;\n }\n }\n },\n [ref]\n );\n\n React.useEffect(() => {\n if (props.mute !== undefined) {\n if (props.mute) {\n internalRef.current?.getInternalPlayer()?.mute();\n } else {\n internalRef.current?.getInternalPlayer()?.unMute();\n }\n }\n }, [props.mute, internalRef]);\n\n const finalProps = { ...props };\n for (const prop of playerParams) {\n if (prop in finalProps) {\n const value = finalProps[prop];\n delete finalProps[prop];\n if (!finalProps.opts) {\n finalProps.opts = {};\n }\n if (!finalProps.opts.playerVars) {\n finalProps.opts.playerVars = {};\n }\n if (booleanParamsSet.has(prop)) {\n if (prop === \"cc_load_policy\" || prop === \"modestbranding\") {\n // undefined or 1\n if (value) {\n finalProps.opts.playerVars[prop] = 1;\n } else {\n delete finalProps.opts.playerVars[prop];\n }\n } else {\n // 0 or 1\n finalProps.opts.playerVars[prop] = (value ? 1 : 0) as any;\n }\n } else {\n finalProps.opts.playerVars[prop] = value as any;\n }\n }\n }\n return (\n <YouTubeImpl\n ref={onRef}\n {...finalProps}\n iframeClassName={props.className}\n />\n );\n }\n);\n\nexport const youtubeMeta: ComponentMeta<YouTubeProps> = {\n name: \"hostless-youtube\",\n displayName: \"YouTube\",\n importName: \"YouTube\",\n importPath: \"@plasmicpkgs/react-youtube\",\n props: {\n videoId: {\n type: \"string\",\n defaultValue: \"R6MeLqRQzYw\",\n displayName: \"Video ID\",\n description: \"The ID for the YouTube video\",\n },\n autoplay: {\n type: \"boolean\",\n displayName: \"Auto Play\",\n description:\n \"Whether the video should automatically start playing when the player loads\",\n defaultValueHint: false,\n hidden: (props) => !props.mute,\n },\n cc_load_policy: {\n type: \"boolean\",\n displayName: \"Show Captions\",\n description:\n \"Whether the captions should be shown by default, even if the user has turned captions off\",\n defaultValueHint: false,\n },\n start: {\n type: \"number\",\n displayName: \"Start\",\n description:\n \"The video should begin at this amount of seconds from the start of the video\",\n defaultValueHint: 0,\n },\n end: {\n type: \"number\",\n displayName: \"End\",\n description:\n \"Stop playing the video after this amount of seconds (measured from the start of the video)\",\n },\n color: {\n type: \"choice\",\n displayName: \"Color\",\n options: [\"red\", \"white\"],\n description:\n \"The color used in the display bar to highlight how much of the video the viewer has already seen\",\n defaultValueHint: \"red\",\n },\n controls: {\n type: \"boolean\",\n displayName: \"Show Controls\",\n description:\n \"Whether the YouTube video player controls should be displayed\",\n defaultValueHint: true,\n },\n disablekb: {\n type: \"boolean\",\n displayName: \"Disable Keyboard\",\n description: \"Whether the keyboard controls should be disabled\",\n defaultValueHint: false,\n },\n fs: {\n type: \"boolean\",\n displayName: \"FullScreen Button\",\n description: \"Whether the fullscreen button should be displayed\",\n defaultValueHint: true,\n },\n loop: {\n type: \"boolean\",\n displayName: \"Loop\",\n description: \"Whether the video should be played again after it finishes\",\n defaultValueHint: false,\n },\n modestbranding: {\n type: \"boolean\",\n displayName: \"Hide Logo\",\n description: \"Hide the YouTube logo in the control bar\",\n defaultValueHint: false,\n },\n mute: {\n type: \"boolean\",\n displayName: \"Mute\",\n description: \"Whether the video should be muted\",\n defaultValueHint: false,\n },\n playsinline: {\n type: \"boolean\",\n displayName: \"Play Inline\",\n description:\n \"Whether the video should be played inline or fullscreen on iOS\",\n defaultValueHint: false,\n },\n rel: {\n type: \"boolean\",\n displayName: \"Related Videos\",\n description:\n \"Whether it should show related videos when the video ends (if false, it shows other videos from the same channel)\",\n defaultValueHint: true,\n },\n },\n isDefaultExport: true,\n defaultStyles: {\n height: \"390px\",\n width: \"640px\",\n maxHeight: \"100%\",\n maxWidth: \"100%\",\n },\n};\n\nexport function registerYouTube(\n loader?: { registerComponent: typeof registerComponent },\n customYouTubeMeta?: ComponentMeta<YouTubeProps>\n) {\n if (loader) {\n loader.registerComponent(YouTube, customYouTubeMeta ?? youtubeMeta);\n } else {\n registerComponent(YouTube, customYouTubeMeta ?? youtubeMeta);\n }\n}\n\nexport default YouTube;\n"],"names":["playerParams","booleanParams","booleanParamsSet","Set","YouTube","React","forwardRef","props","ref","internalRef","useRef","onRef","useCallback","player","current","useEffect","mute","undefined","getInternalPlayer","unMute","finalProps","prop","value","opts","playerVars","has","YouTubeImpl","iframeClassName","className","youtubeMeta","name","displayName","importName","importPath","videoId","type","defaultValue","description","autoplay","defaultValueHint","hidden","cc_load_policy","start","end","color","options","controls","disablekb","fs","loop","modestbranding","playsinline","rel","isDefaultExport","defaultStyles","height","width","maxHeight","maxWidth","registerYouTube","loader","customYouTubeMeta","registerComponent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,IAAMA,YAAY,GAAG,CACnB,UADmB,EAEnB,gBAFmB,EAGnB,OAHmB,EAInB,UAJmB,EAKnB,WALmB,EAMnB,aANmB,EAOnB,KAPmB,EAQnB,IARmB,EASnB,IATmB,EAUnB,gBAVmB,EAWnB,MAXmB,EAYnB,UAZmB,EAanB,MAbmB,EAcnB,gBAdmB,EAenB,QAfmB,EAgBnB,UAhBmB,EAiBnB,aAjBmB,EAkBnB,KAlBmB,EAmBnB,OAnBmB,CAArB;AAsBA,IAAMC,aAAa,GAAG,CACpB,UADoB,EAEpB,gBAFoB,EAGpB,UAHoB,EAIpB,WAJoB,EAKpB,IALoB,EAMpB,MANoB,EAOpB,gBAPoB,EAQpB,aARoB,EASpB,KAToB,CAAtB;AAYA,IAAMC,gBAAgB,gBAAG,IAAIC,GAAJ,CAAgBF,aAAhB,CAAzB;AAEA,IAAMG,OAAO,gBAAGC,KAAK,CAACC,UAAN,CACd,UAACC,KAAD,EAAsBC,GAAtB;AACE,MAAMC,WAAW,GAAGJ,KAAK,CAACK,MAAN,CAAiC,IAAjC,CAApB;AAEA,MAAMC,KAAK,GAAGN,KA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D;AACF;;;;;"}
1
+ {"version":3,"file":"react-youtube.esm.js","sources":["../src/index.tsx"],"sourcesContent":["import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport React from \"react\";\nimport YouTubeImpl, { YouTubeProps as YouTubeImplProps } from \"react-youtube\";\nimport type { Options } from \"youtube-player/dist/types\";\n\ntype PlayerVars = Exclude<Options[\"playerVars\"], undefined>;\nexport type YouTubeProps = YouTubeImplProps &\n {\n [prop in keyof PlayerVars]:\n | PlayerVars[prop]\n | (prop extends typeof booleanParams[number] ? boolean : never);\n } & { mute?: boolean };\nconst playerParams = [\n \"autoplay\",\n \"cc_load_policy\",\n \"color\",\n \"controls\",\n \"disablekb\",\n \"enablejsapi\",\n \"end\",\n \"fs\",\n \"hl\",\n \"iv_load_policy\",\n \"list\",\n \"listType\",\n \"loop\",\n \"modestbranding\",\n \"origin\",\n \"playlist\",\n \"playsinline\",\n \"rel\",\n \"start\",\n] as const;\n\nconst booleanParams = [\n \"autoplay\",\n \"cc_load_policy\",\n \"controls\",\n \"disablekb\",\n \"fs\",\n \"loop\",\n \"modestbranding\",\n \"playsinline\",\n \"rel\",\n] as const;\n\nconst booleanParamsSet = new Set<string>(booleanParams);\n\nconst YouTube = React.forwardRef<YouTubeImpl, YouTubeProps>(\n (props: YouTubeProps, ref) => {\n const internalRef = React.useRef<YouTubeImpl | null>(null);\n\n const onRef = React.useCallback(\n (player: YouTubeImpl | null) => {\n internalRef.current = player;\n if (ref) {\n if (typeof ref === \"function\") {\n ref(player);\n } else {\n ref.current = player;\n }\n }\n },\n [ref]\n );\n\n React.useEffect(() => {\n if (props.mute !== undefined) {\n if (props.mute) {\n internalRef.current?.getInternalPlayer()?.mute();\n } else {\n internalRef.current?.getInternalPlayer()?.unMute();\n }\n }\n }, [props.mute, internalRef]);\n\n const finalProps = { ...props };\n for (const prop of playerParams) {\n if (prop in finalProps) {\n const value = finalProps[prop];\n delete finalProps[prop];\n if (!finalProps.opts) {\n finalProps.opts = {};\n }\n if (!finalProps.opts.playerVars) {\n finalProps.opts.playerVars = {};\n }\n if (booleanParamsSet.has(prop)) {\n if (prop === \"cc_load_policy\" || prop === \"modestbranding\") {\n // undefined or 1\n if (value) {\n finalProps.opts.playerVars[prop] = 1;\n } else {\n delete finalProps.opts.playerVars[prop];\n }\n } else {\n // 0 or 1\n finalProps.opts.playerVars[prop] = (value ? 1 : 0) as any;\n }\n } else {\n finalProps.opts.playerVars[prop] = value as any;\n }\n }\n }\n return (\n <YouTubeImpl\n ref={onRef}\n {...finalProps}\n iframeClassName={props.className}\n />\n );\n }\n);\n\nexport const youtubeMeta: ComponentMeta<YouTubeProps> = {\n name: \"hostless-youtube\",\n displayName: \"YouTube\",\n importName: \"YouTube\",\n importPath: \"@plasmicpkgs/react-youtube\",\n props: {\n videoId: {\n type: \"string\",\n defaultValue: \"R6MeLqRQzYw\",\n displayName: \"Video ID\",\n description: \"The ID for the YouTube video\",\n },\n autoplay: {\n type: \"boolean\",\n displayName: \"Auto Play\",\n description:\n \"Whether the video should automatically start playing when the player loads\",\n defaultValueHint: false,\n hidden: (props) => !props.mute,\n },\n cc_load_policy: {\n type: \"boolean\",\n displayName: \"Show Captions\",\n description:\n \"Whether the captions should be shown by default, even if the user has turned captions off\",\n defaultValueHint: false,\n },\n start: {\n type: \"number\",\n displayName: \"Start\",\n description:\n \"The video should begin at this amount of seconds from the start of the video\",\n defaultValueHint: 0,\n },\n end: {\n type: \"number\",\n displayName: \"End\",\n description:\n \"Stop playing the video after this amount of seconds (measured from the start of the video)\",\n },\n color: {\n type: \"choice\",\n displayName: \"Color\",\n options: [\"red\", \"white\"],\n description:\n \"The color used in the display bar to highlight how much of the video the viewer has already seen\",\n defaultValueHint: \"red\",\n },\n controls: {\n type: \"boolean\",\n displayName: \"Show Controls\",\n description:\n \"Whether the YouTube video player controls should be displayed\",\n defaultValueHint: true,\n },\n disablekb: {\n type: \"boolean\",\n displayName: \"Disable Keyboard\",\n description: \"Whether the keyboard controls should be disabled\",\n defaultValueHint: false,\n },\n fs: {\n type: \"boolean\",\n displayName: \"FullScreen Button\",\n description: \"Whether the fullscreen button should be displayed\",\n defaultValueHint: true,\n },\n loop: {\n type: \"boolean\",\n displayName: \"Loop\",\n description: \"Whether the video should be played again after it finishes\",\n defaultValueHint: false,\n },\n modestbranding: {\n type: \"boolean\",\n displayName: \"Hide Logo\",\n description: \"Hide the YouTube logo in the control bar\",\n defaultValueHint: false,\n },\n mute: {\n type: \"boolean\",\n displayName: \"Mute\",\n description: \"Whether the video should be muted\",\n defaultValueHint: false,\n },\n playsinline: {\n type: \"boolean\",\n displayName: \"Play Inline\",\n description:\n \"Whether the video should be played inline or fullscreen on iOS\",\n defaultValueHint: false,\n },\n rel: {\n type: \"boolean\",\n displayName: \"Related Videos\",\n description:\n \"Whether it should show related videos when the video ends (if false, it shows other videos from the same channel)\",\n defaultValueHint: true,\n },\n },\n isDefaultExport: true,\n defaultStyles: {\n height: \"390px\",\n width: \"640px\",\n maxHeight: \"100%\",\n maxWidth: \"100%\",\n },\n};\n\nexport function registerYouTube(\n loader?: { registerComponent: typeof registerComponent },\n customYouTubeMeta?: ComponentMeta<YouTubeProps>\n) {\n if (loader) {\n loader.registerComponent(YouTube, customYouTubeMeta ?? youtubeMeta);\n } else {\n registerComponent(YouTube, customYouTubeMeta ?? youtubeMeta);\n }\n}\n\nexport default YouTube;\n"],"names":["playerParams","booleanParams","booleanParamsSet","Set","YouTube","React","forwardRef","props","ref","internalRef","useRef","onRef","useCallback","player","current","useEffect","mute","undefined","getInternalPlayer","unMute","finalProps","prop","value","opts","playerVars","has","YouTubeImpl","iframeClassName","className","youtubeMeta","name","displayName","importName","importPath","videoId","type","defaultValue","description","autoplay","defaultValueHint","hidden","cc_load_policy","start","end","color","options","controls","disablekb","fs","loop","modestbranding","playsinline","rel","isDefaultExport","defaultStyles","height","width","maxHeight","maxWidth","registerYouTube","loader","customYouTubeMeta","registerComponent"],"mappings":";;;;;;;;;;;;;;;;;;;A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MACfJ,WAAW,EAAE,MAAM;MACnBM,WAAW,EAAE,4DAA4D;MACzEE,gBAAgB,EAAE;KACnB;IACDW,cAAc,EAAE;MACdf,IAAI,EAAE,SAAS;MACfJ,WAAW,EAAE,WAAW;MACxBM,WAAW,EAAE,0CAA0C;MACvDE,gBAAgB,EAAE;KACnB;IACDvB,IAAI,EAAE;MACJmB,IAAI,EAAE,SAAS;MACfJ,WAAW,EAAE,MAAM;MACnBM,WAAW,EAAE,mCAAmC;MAChDE,gBAAgB,EAAE;KACnB;IACDY,WAAW,EAAE;MACXhB,IAAI,EAAE,SAAS;MACfJ,WAAW,EAAE,aAAa;MAC1BM,WAAW,EACT,gEAAgE;MAClEE,gBAAgB,EAAE;KACnB;IACDa,GAAG,EAAE;MACHjB,IAAI,EAAE,SAAS;MACfJ,WAAW,EAAE,gBAAgB;MAC7BM,WAAW,EACT,mHAAmH;MACrHE,gBAAgB,EAAE;;GAErB;EACDc,eAAe,EAAE,IAAI;EACrBC,aAAa,EAAE;IACbC,MAAM,EAAE,OAAO;IACfC,KAAK,EAAE,OAAO;IACdC,SAAS,EAAE,MAAM;IACjBC,QAAQ,EAAE;;;SAIEC,eAAe,CAC7BC,MAAwD,EACxDC,iBAA+C;EAE/C,IAAID,MAAM,EAAE;IACVA,MAAM,CAACE,iBAAiB,CAAC1D,OAAO,EAAEyD,iBAAiB,WAAjBA,iBAAiB,GAAIhC,WAAW,CAAC;GACpE,MAAM;IACLiC,iBAAiB,CAAC1D,OAAO,EAAEyD,iBAAiB,WAAjBA,iBAAiB,GAAIhC,WAAW,CAAC;;AAEhE;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicpkgs/react-youtube",
3
- "version": "7.13.95",
3
+ "version": "7.13.97",
4
4
  "description": "Plasmic registration call for react-youtube",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "analyze": "size-limit --why"
29
29
  },
30
30
  "devDependencies": {
31
- "@plasmicapp/host": "1.0.92",
31
+ "@plasmicapp/host": "1.0.94",
32
32
  "@size-limit/preset-small-lib": "^4.11.0",
33
33
  "@types/node": "^14.0.26",
34
34
  "@types/youtube-player": "^5.5.6",
@@ -45,5 +45,5 @@
45
45
  "react": ">=16.8.0",
46
46
  "react-dom": ">=16.8.0"
47
47
  },
48
- "gitHead": "79d47b209f2166dc80c5bb5f24491e0b8cbc02a4"
48
+ "gitHead": "2ddf7320f54e314e4f44d3df3c50468d2740ddbf"
49
49
  }