@digitalsamba/embedded-sdk 0.0.1 → 0.0.3

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.
Files changed (174) hide show
  1. package/dist/cjs/index.d.ts +66 -0
  2. package/dist/cjs/index.js +214 -0
  3. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -0
  4. package/dist/cjs/umd.d.ts +1 -0
  5. package/dist/cjs/umd.js +5 -0
  6. package/dist/cjs/utils/errors.d.ts +10 -0
  7. package/dist/cjs/utils/errors.js +44 -0
  8. package/dist/esm/index.d.ts +66 -0
  9. package/dist/esm/index.js +211 -0
  10. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -0
  11. package/dist/esm/umd.d.ts +1 -0
  12. package/dist/esm/umd.js +3 -0
  13. package/dist/esm/utils/errors.d.ts +10 -0
  14. package/dist/esm/utils/errors.js +41 -0
  15. package/dist/index.d.ts +67 -0
  16. package/dist/index.html +83 -0
  17. package/dist/index.js +194 -0
  18. package/dist/tsconfig.tsbuildinfo +1 -0
  19. package/dist/types/index.d.ts +66 -0
  20. package/dist/types/tsconfig.types.tsbuildinfo +1 -0
  21. package/dist/types/umd.d.ts +1 -0
  22. package/dist/types/utils/errors.d.ts +10 -0
  23. package/dist/umd/index.js +1 -0
  24. package/dist/utils/errors.d.ts +1 -0
  25. package/dist/utils/errors.js +4 -0
  26. package/package.json +3 -1
  27. package/.editorconfig +0 -10
  28. package/.github/workflows/main.yml +0 -32
  29. package/.yarn/cache/@discoveryjs-json-ext-npm-0.5.7-fe04af1f31-2176d301cc.zip +0 -0
  30. package/.yarn/cache/@jridgewell-gen-mapping-npm-0.3.2-c64eeb4a4e-1832707a1c.zip +0 -0
  31. package/.yarn/cache/@jridgewell-resolve-uri-npm-3.1.0-6ff2351e61-b5ceaaf9a1.zip +0 -0
  32. package/.yarn/cache/@jridgewell-set-array-npm-1.1.2-45b82d7fb6-69a84d5980.zip +0 -0
  33. package/.yarn/cache/@jridgewell-source-map-npm-0.3.2-6fd1f37b22-1b83f0eb94.zip +0 -0
  34. package/.yarn/cache/@jridgewell-sourcemap-codec-npm-1.4.14-f5f0630788-61100637b6.zip +0 -0
  35. package/.yarn/cache/@jridgewell-trace-mapping-npm-0.3.17-57578fd48c-9d703b859c.zip +0 -0
  36. package/.yarn/cache/@types-eslint-npm-8.4.8-f5b6d330b4-5b4708a56a.zip +0 -0
  37. package/.yarn/cache/@types-eslint-scope-npm-3.7.4-c11d226d71-ea6a9363e9.zip +0 -0
  38. package/.yarn/cache/@types-estree-npm-0.0.51-bc20719267-e56a3bcf75.zip +0 -0
  39. package/.yarn/cache/@types-estree-npm-1.0.0-eddde5b631-910d97fb70.zip +0 -0
  40. package/.yarn/cache/@types-json-schema-npm-7.0.11-79462ae5ca-527bddfe62.zip +0 -0
  41. package/.yarn/cache/@types-node-npm-18.11.7-0cf2ce3a09-69d630825c.zip +0 -0
  42. package/.yarn/cache/@webassemblyjs-ast-npm-1.11.1-623d3d973e-1eee1534ad.zip +0 -0
  43. package/.yarn/cache/@webassemblyjs-floating-point-hex-parser-npm-1.11.1-f8af5c0037-b8efc6fa08.zip +0 -0
  44. package/.yarn/cache/@webassemblyjs-helper-api-error-npm-1.11.1-b839d59053-0792813f0e.zip +0 -0
  45. package/.yarn/cache/@webassemblyjs-helper-buffer-npm-1.11.1-6afb1ef4aa-a337ee44b4.zip +0 -0
  46. package/.yarn/cache/@webassemblyjs-helper-numbers-npm-1.11.1-a41f7439eb-44d2905dac.zip +0 -0
  47. package/.yarn/cache/@webassemblyjs-helper-wasm-bytecode-npm-1.11.1-84f0ee4c30-eac4001131.zip +0 -0
  48. package/.yarn/cache/@webassemblyjs-helper-wasm-section-npm-1.11.1-e4e8450b9d-617696cfe8.zip +0 -0
  49. package/.yarn/cache/@webassemblyjs-ieee754-npm-1.11.1-897eb85879-23a0ac02a5.zip +0 -0
  50. package/.yarn/cache/@webassemblyjs-leb128-npm-1.11.1-fd9f27673d-33ccc4ade2.zip +0 -0
  51. package/.yarn/cache/@webassemblyjs-utf8-npm-1.11.1-583036e767-972c5cfc76.zip +0 -0
  52. package/.yarn/cache/@webassemblyjs-wasm-edit-npm-1.11.1-34565c1e92-6d7d9efaec.zip +0 -0
  53. package/.yarn/cache/@webassemblyjs-wasm-gen-npm-1.11.1-a6d0b4d37d-1f6921e640.zip +0 -0
  54. package/.yarn/cache/@webassemblyjs-wasm-opt-npm-1.11.1-0bb73c20b9-21586883a2.zip +0 -0
  55. package/.yarn/cache/@webassemblyjs-wasm-parser-npm-1.11.1-cd49c51fdc-1521644065.zip +0 -0
  56. package/.yarn/cache/@webassemblyjs-wast-printer-npm-1.11.1-f1213430d6-f15ae4c244.zip +0 -0
  57. package/.yarn/cache/@webpack-cli-configtest-npm-1.2.0-728a6bf8bd-a2726cd9ec.zip +0 -0
  58. package/.yarn/cache/@webpack-cli-info-npm-1.5.0-9d9627ae19-7f56fe037c.zip +0 -0
  59. package/.yarn/cache/@webpack-cli-serve-npm-1.7.0-2869abfdb4-d475e8effa.zip +0 -0
  60. package/.yarn/cache/@xtuc-ieee754-npm-1.2.0-ec0ce4e025-ac56d4ca6e.zip +0 -0
  61. package/.yarn/cache/@xtuc-long-npm-4.2.2-37236e6d72-8ed0d477ce.zip +0 -0
  62. package/.yarn/cache/acorn-import-assertions-npm-1.8.0-e9a9d57e27-5c4cf7c850.zip +0 -0
  63. package/.yarn/cache/acorn-npm-8.8.1-20e4aea981-4079b67283.zip +0 -0
  64. package/.yarn/cache/ajv-keywords-npm-3.5.2-0e391b70e2-7dc5e59316.zip +0 -0
  65. package/.yarn/cache/ajv-npm-6.12.6-4b5105e2b2-874972efe5.zip +0 -0
  66. package/.yarn/cache/ansi-styles-npm-4.3.0-245c7d42c7-513b44c3b2.zip +0 -0
  67. package/.yarn/cache/braces-npm-3.0.2-782240b28a-e2a8e769a8.zip +0 -0
  68. package/.yarn/cache/browserslist-npm-4.21.4-7d64a96afc-4af3793704.zip +0 -0
  69. package/.yarn/cache/buffer-from-npm-1.1.2-03d2f20d7e-0448524a56.zip +0 -0
  70. package/.yarn/cache/caniuse-lite-npm-1.0.30001426-f6186ea145-e8b9c14ee3.zip +0 -0
  71. package/.yarn/cache/chalk-npm-4.1.2-ba8b67ab80-fe75c9d5c7.zip +0 -0
  72. package/.yarn/cache/chrome-trace-event-npm-1.0.3-e0ae3dcd60-cb8b1fc7e8.zip +0 -0
  73. package/.yarn/cache/clone-deep-npm-4.0.1-70adab92c8-770f912fe4.zip +0 -0
  74. package/.yarn/cache/color-convert-npm-2.0.1-79730e935b-79e6bdb9fd.zip +0 -0
  75. package/.yarn/cache/color-name-npm-1.1.4-025792b0ea-b044585952.zip +0 -0
  76. package/.yarn/cache/colorette-npm-2.0.19-f73dfe6a4e-888cf5493f.zip +0 -0
  77. package/.yarn/cache/commander-npm-2.20.3-d8dcbaa39b-ab8c07884e.zip +0 -0
  78. package/.yarn/cache/commander-npm-7.2.0-19178180f8-53501cbeee.zip +0 -0
  79. package/.yarn/cache/cross-spawn-npm-7.0.3-e4ff3e65b3-671cc7c728.zip +0 -0
  80. package/.yarn/cache/electron-to-chromium-npm-1.4.284-2fb881a7ac-be496e9dca.zip +0 -0
  81. package/.yarn/cache/enhanced-resolve-npm-5.10.0-7941304306-0bb9830704.zip +0 -0
  82. package/.yarn/cache/envinfo-npm-7.8.1-f320033691-de736c98d6.zip +0 -0
  83. package/.yarn/cache/es-module-lexer-npm-0.9.3-ff6236dadb-84bbab23c3.zip +0 -0
  84. package/.yarn/cache/escalade-npm-3.1.1-e02da076aa-a3e2a99f07.zip +0 -0
  85. package/.yarn/cache/eslint-scope-npm-5.1.1-71fe59b18a-47e4b6a3f0.zip +0 -0
  86. package/.yarn/cache/esrecurse-npm-4.3.0-10b86a887a-ebc17b1a33.zip +0 -0
  87. package/.yarn/cache/estraverse-npm-4.3.0-920a32f3c6-a6299491f9.zip +0 -0
  88. package/.yarn/cache/estraverse-npm-5.3.0-03284f8f63-072780882d.zip +0 -0
  89. package/.yarn/cache/events-npm-3.3.0-c280bc7e48-f6f487ad21.zip +0 -0
  90. package/.yarn/cache/fast-deep-equal-npm-3.1.3-790edcfcf5-e21a9d8d84.zip +0 -0
  91. package/.yarn/cache/fast-json-stable-stringify-npm-2.1.0-02e8905fda-b191531e36.zip +0 -0
  92. package/.yarn/cache/fastest-levenshtein-npm-1.0.16-192d328856-a78d44285c.zip +0 -0
  93. package/.yarn/cache/fill-range-npm-7.0.1-b8b1817caa-cc283f4e65.zip +0 -0
  94. package/.yarn/cache/find-up-npm-4.1.0-c3ccf8d855-4c172680e8.zip +0 -0
  95. package/.yarn/cache/function-bind-npm-1.1.1-b56b322ae9-b32fbaebb3.zip +0 -0
  96. package/.yarn/cache/glob-to-regexp-npm-0.4.1-cd697e0fc7-e795f4e8f0.zip +0 -0
  97. package/.yarn/cache/graceful-fs-npm-4.2.10-79c70989ca-3f109d70ae.zip +0 -0
  98. package/.yarn/cache/has-flag-npm-4.0.0-32af9f0536-261a135703.zip +0 -0
  99. package/.yarn/cache/has-npm-1.0.3-b7f00631c1-b9ad53d53b.zip +0 -0
  100. package/.yarn/cache/import-local-npm-3.1.0-8960af5e51-bfcdb63b5e.zip +0 -0
  101. package/.yarn/cache/interpret-npm-2.2.0-3603a544e1-f51efef7cb.zip +0 -0
  102. package/.yarn/cache/is-core-module-npm-2.11.0-70061e141a-f96fd490c6.zip +0 -0
  103. package/.yarn/cache/is-number-npm-7.0.0-060086935c-456ac6f8e0.zip +0 -0
  104. package/.yarn/cache/is-plain-object-npm-2.0.4-da3265d804-2a401140cf.zip +0 -0
  105. package/.yarn/cache/isexe-npm-2.0.0-b58870bd2e-26bf6c5480.zip +0 -0
  106. package/.yarn/cache/isobject-npm-3.0.1-8145901fd2-db85c4c970.zip +0 -0
  107. package/.yarn/cache/jest-worker-npm-27.5.1-1c110b5894-98cd68b696.zip +0 -0
  108. package/.yarn/cache/json-parse-even-better-errors-npm-2.3.1-144d62256e-798ed4cf33.zip +0 -0
  109. package/.yarn/cache/json-schema-traverse-npm-0.4.1-4759091693-7486074d3b.zip +0 -0
  110. package/.yarn/cache/kind-of-npm-6.0.3-ab15f36220-3ab01e7b1d.zip +0 -0
  111. package/.yarn/cache/loader-runner-npm-4.3.0-9ca67df372-a90e00dee9.zip +0 -0
  112. package/.yarn/cache/locate-path-npm-5.0.0-46580c43e4-83e51725e6.zip +0 -0
  113. package/.yarn/cache/lru-cache-npm-6.0.0-b4c8668fe1-f97f499f89.zip +0 -0
  114. package/.yarn/cache/merge-stream-npm-2.0.0-2ac83efea5-6fa4dcc8d8.zip +0 -0
  115. package/.yarn/cache/micromatch-npm-4.0.5-cfab5d7669-02a17b671c.zip +0 -0
  116. package/.yarn/cache/mime-db-npm-1.52.0-b5371d6fd2-0d99a03585.zip +0 -0
  117. package/.yarn/cache/mime-types-npm-2.1.35-dd9ea9f3e2-89a5b7f1de.zip +0 -0
  118. package/.yarn/cache/neo-async-npm-2.6.2-75d6902586-deac9f8d00.zip +0 -0
  119. package/.yarn/cache/node-releases-npm-2.0.6-8accb3fefb-e86a926dc9.zip +0 -0
  120. package/.yarn/cache/p-limit-npm-2.3.0-94a0310039-84ff17f1a3.zip +0 -0
  121. package/.yarn/cache/p-locate-npm-4.1.0-eec6872537-513bd14a45.zip +0 -0
  122. package/.yarn/cache/p-try-npm-2.2.0-e0390dbaf8-f8a8e9a769.zip +0 -0
  123. package/.yarn/cache/path-exists-npm-4.0.0-e9e4f63eb0-505807199d.zip +0 -0
  124. package/.yarn/cache/path-key-npm-3.1.1-0e66ea8321-55cd7a9dd4.zip +0 -0
  125. package/.yarn/cache/path-parse-npm-1.0.7-09564527b7-49abf3d811.zip +0 -0
  126. package/.yarn/cache/picocolors-npm-1.0.0-d81e0b1927-a2e8092dd8.zip +0 -0
  127. package/.yarn/cache/picomatch-npm-2.3.1-c782cfd986-050c865ce8.zip +0 -0
  128. package/.yarn/cache/pkg-dir-npm-4.2.0-2b5d0a8d32-9863e3f351.zip +0 -0
  129. package/.yarn/cache/punycode-npm-2.1.1-26eb3e15cf-823bf443c6.zip +0 -0
  130. package/.yarn/cache/randombytes-npm-2.1.0-e3da76bccf-d779499376.zip +0 -0
  131. package/.yarn/cache/rechoir-npm-0.7.1-0c7e5c1201-2a04aab4e2.zip +0 -0
  132. package/.yarn/cache/resolve-cwd-npm-3.0.0-e6f4e296bf-546e081601.zip +0 -0
  133. package/.yarn/cache/resolve-from-npm-5.0.0-15c9db4d33-4ceeb9113e.zip +0 -0
  134. package/.yarn/cache/resolve-npm-1.22.1-3980488690-07af5fc1e8.zip +0 -0
  135. package/.yarn/cache/resolve-patch-46f9469d0d-5656f4d0be.zip +0 -0
  136. package/.yarn/cache/safe-buffer-npm-5.2.1-3481c8aa9b-b99c4b41fd.zip +0 -0
  137. package/.yarn/cache/schema-utils-npm-3.1.1-8704647575-fb73f3d759.zip +0 -0
  138. package/.yarn/cache/semver-npm-7.3.8-25a996cb4f-ba9c7cbbf2.zip +0 -0
  139. package/.yarn/cache/serialize-javascript-npm-6.0.0-0bb8a3c88d-56f90b562a.zip +0 -0
  140. package/.yarn/cache/shallow-clone-npm-3.0.1-dab5873d0d-39b3dd9630.zip +0 -0
  141. package/.yarn/cache/shebang-command-npm-2.0.0-eb2b01921d-6b52fe8727.zip +0 -0
  142. package/.yarn/cache/shebang-regex-npm-3.0.0-899a0cd65e-1a2bcae50d.zip +0 -0
  143. package/.yarn/cache/source-map-npm-0.6.1-1a3621db16-59ce8640cf.zip +0 -0
  144. package/.yarn/cache/source-map-support-npm-0.5.21-09ca99e250-43e98d700d.zip +0 -0
  145. package/.yarn/cache/supports-color-npm-7.2.0-606bfcf7da-3dda818de0.zip +0 -0
  146. package/.yarn/cache/supports-color-npm-8.1.1-289e937149-c052193a7e.zip +0 -0
  147. package/.yarn/cache/supports-preserve-symlinks-flag-npm-1.0.0-f17c4d0028-53b1e247e6.zip +0 -0
  148. package/.yarn/cache/tapable-npm-2.2.1-8cf5ff3039-3b7a1b4d86.zip +0 -0
  149. package/.yarn/cache/terser-npm-5.15.1-63dec1247d-9880a1e095.zip +0 -0
  150. package/.yarn/cache/terser-webpack-plugin-npm-5.3.6-27ed5132ff-8f3448d7fd.zip +0 -0
  151. package/.yarn/cache/to-regex-range-npm-5.0.1-f1e8263b00-f76fa01b3d.zip +0 -0
  152. package/.yarn/cache/ts-loader-npm-9.4.1-379dc021ff-b8947f6d39.zip +0 -0
  153. package/.yarn/cache/typescript-npm-4.8.4-9c0a335511-3e4f061658.zip +0 -0
  154. package/.yarn/cache/typescript-patch-74ec80b1de-563a0ef47a.zip +0 -0
  155. package/.yarn/cache/update-browserslist-db-npm-1.0.10-676baf0b9f-12db73b4f6.zip +0 -0
  156. package/.yarn/cache/uri-js-npm-4.4.1-66d11cbcaf-7167432de6.zip +0 -0
  157. package/.yarn/cache/watchpack-npm-2.4.0-7ec4b9cc65-23d4bc5863.zip +0 -0
  158. package/.yarn/cache/webpack-cli-npm-4.10.0-09cee8c457-2ff5355ac3.zip +0 -0
  159. package/.yarn/cache/webpack-merge-npm-5.8.0-e3c95fdc3c-88786ab910.zip +0 -0
  160. package/.yarn/cache/webpack-npm-5.74.0-f5b838a00d-320c41369a.zip +0 -0
  161. package/.yarn/cache/webpack-sources-npm-3.2.3-6bfb5d9563-989e401b9f.zip +0 -0
  162. package/.yarn/cache/which-npm-2.0.2-320ddf72f7-1a5c563d3c.zip +0 -0
  163. package/.yarn/cache/wildcard-npm-2.0.0-baedca033a-1f4fe4c03d.zip +0 -0
  164. package/.yarn/cache/yallist-npm-4.0.0-b493d9e907-343617202a.zip +0 -0
  165. package/config/tsconfig.cjs.json +0 -7
  166. package/config/tsconfig.esm.json +0 -7
  167. package/config/tsconfig.types.json +0 -8
  168. package/config/tsconfig.umd.json +0 -7
  169. package/config/webpack.config.js +0 -30
  170. package/src/index.ts +0 -307
  171. package/src/umd.ts +0 -4
  172. package/src/utils/errors.ts +0 -30
  173. package/tools/cleanup.js +0 -29
  174. package/tsconfig.json +0 -21
@@ -1,7 +0,0 @@
1
- {
2
- "extends": "../tsconfig",
3
- "compilerOptions": {
4
- "module": "commonjs",
5
- "outDir": "../dist/cjs"
6
- }
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "extends": "../tsconfig",
3
- "compilerOptions": {
4
- "module": "ESNext",
5
- "outDir": "../dist/esm"
6
- }
7
- }
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "../tsconfig",
3
- "compilerOptions": {
4
- "declaration": true,
5
- "emitDeclarationOnly": true,
6
- "outDir": "../dist/types"
7
- }
8
- }
@@ -1,7 +0,0 @@
1
- {
2
- "extends": "../tsconfig",
3
- "compilerOptions": {
4
- "module": "commonjs",
5
- "declaration": false
6
- }
7
- }
@@ -1,30 +0,0 @@
1
- const path = require("path");
2
-
3
- module.exports = {
4
- mode: "production",
5
- entry: "./src/umd.ts",
6
- output: {
7
- path: path.resolve(__dirname, "../dist/umd"),
8
- filename: "index.js",
9
- library: "DigitalSambaEmbedded",
10
- libraryTarget: "umd",
11
- globalObject: "this",
12
- },
13
- module: {
14
- rules: [
15
- {
16
- test: /\.ts(x*)?$/,
17
- exclude: /node_modules/,
18
- use: {
19
- loader: "ts-loader",
20
- options: {
21
- configFile: "config/tsconfig.umd.json",
22
- },
23
- },
24
- },
25
- ],
26
- },
27
- resolve: {
28
- extensions: [".ts", ".js", ".tsx", ".jsx"],
29
- },
30
- };
package/src/index.ts DELETED
@@ -1,307 +0,0 @@
1
- import {
2
- ALLOW_ATTRIBUTE_MISSING,
3
- INVALID_CONFIG,
4
- INVALID_URL,
5
- RichError,
6
- UNKNOWN_TARGET,
7
- } from "./utils/errors";
8
-
9
- export interface InitOptions {
10
- root: HTMLElement;
11
- frame: HTMLIFrameElement;
12
-
13
- url: string;
14
- team: string;
15
- room: string;
16
- token?: string;
17
- }
18
-
19
- export type FrameAttributes = {
20
- align: string;
21
- allow: string;
22
- allowFullscreen: boolean;
23
- frameBorder: string;
24
- height: string;
25
- longDesc: string;
26
- marginHeight: string;
27
- marginWidth: string;
28
- name: string;
29
- referrerPolicy: ReferrerPolicy;
30
- scrolling: string;
31
- src: string;
32
- srcdoc: string;
33
- width: string;
34
- } & HTMLElement;
35
-
36
- export interface InstanceProperties {
37
- frameAttributes?: Partial<FrameAttributes>;
38
- reportErrors?: boolean;
39
- }
40
-
41
- const CONNECT_TIMEOUT = 5000;
42
-
43
- export type SendMessageType =
44
- | "connect"
45
- | "enableVideo"
46
- | "enableAudio"
47
- | "disableVideo"
48
- | "disableAudio"
49
- | "toggleVideo"
50
- | "toggleAudio"
51
- | "startScreenshare"
52
- | "stopScreenshare";
53
-
54
- export type ReceiveMessageType =
55
- | "connected"
56
- | "userJoined"
57
- | "userLeft"
58
- | "videoEnabled"
59
- | "videoDisabled"
60
- | "audioEnabled"
61
- | "audioDisabled"
62
- | "screenshareStarted"
63
- | "screenshareStopped";
64
-
65
- export interface SendMessage<P> {
66
- type: SendMessageType;
67
- payload?: P;
68
- }
69
-
70
- export interface ReceiveMessage {
71
- type: ReceiveMessageType;
72
- payload: unknown;
73
- }
74
-
75
- function isFunction(func: any): func is (payload: any) => void {
76
- return func instanceof Function;
77
- }
78
-
79
- export class DigitalSambaEmbedded {
80
- initOptions: Partial<InitOptions>;
81
-
82
- savedIframeSrc: string = "";
83
-
84
- allowedOrigin: string = "*";
85
-
86
- connected: boolean = false;
87
-
88
- frame: HTMLIFrameElement = document.createElement("iframe");
89
-
90
- eventHandlers: Partial<
91
- Record<ReceiveMessageType | "*", (payload: any) => void>
92
- > = {};
93
-
94
- reportErrors: boolean = false;
95
-
96
- constructor(
97
- options: Partial<InitOptions> = {},
98
- instanceProperties: Partial<InstanceProperties> = {},
99
- loadImmediately = true
100
- ) {
101
- this.initOptions = options;
102
-
103
- this.frame.allow = "camera; microphone; display-capture; autoplay;";
104
- this.frame.setAttribute("allowFullscreen", "true");
105
-
106
- this.mountFrame(loadImmediately);
107
-
108
- if (loadImmediately) {
109
- this.load(instanceProperties);
110
- } else {
111
- this.frame.style.display = "none";
112
- }
113
-
114
- window.addEventListener("message", this.onMessage);
115
- }
116
-
117
- static createControl = (initOptions: InitOptions) => {
118
- return new this(initOptions, {}, false);
119
- };
120
-
121
- private mountFrame = (loadImmediately: boolean) => {
122
- const { url, frame, root } = this.initOptions;
123
-
124
- if (root) {
125
- root.appendChild(this.frame);
126
- } else if (frame) {
127
- this.frame = frame;
128
-
129
- if (!frame.allow) {
130
- this.logError(ALLOW_ATTRIBUTE_MISSING);
131
- }
132
- } else {
133
- document.body.appendChild(this.frame);
134
- }
135
-
136
- if (url) {
137
- try {
138
- const frameSrc = new URL(url).toString();
139
-
140
- this.frame.src = frameSrc;
141
- this.savedIframeSrc = frameSrc;
142
- } catch {
143
- this.logError(INVALID_URL);
144
- }
145
- }
146
-
147
- if (!loadImmediately) {
148
- this.savedIframeSrc = this.frame.src;
149
- this.frame.src = "";
150
- }
151
- };
152
-
153
- load = (instanceProperties: InstanceProperties = {}) => {
154
- this.reportErrors = instanceProperties.reportErrors || false;
155
-
156
- this.setFrameSrc();
157
-
158
- this.applyFrameProperties(instanceProperties);
159
-
160
- this.frame.style.display = "block";
161
- };
162
-
163
- on = (type: ReceiveMessageType, handler: (payload: any) => void) => {
164
- this.eventHandlers[type] = handler;
165
- };
166
-
167
- private onMessage = (event: MessageEvent<ReceiveMessage>) => {
168
- // if (event.origin !== this.allowedOrigin) {
169
- // // ignore messages from other sources;
170
- // return;
171
- // }
172
-
173
- if (typeof this.eventHandlers["*"] === "function") {
174
- this.eventHandlers["*"](event.data);
175
- }
176
-
177
- if (event.data.type) {
178
- const callback = this.eventHandlers[event.data.type];
179
-
180
- if (isFunction(callback)) {
181
- callback(event.data);
182
- }
183
- }
184
- };
185
-
186
- private setFrameSrc = () => {
187
- let url = this.savedIframeSrc;
188
- const { team, room, token } = this.initOptions;
189
-
190
- if (team && room) {
191
- url = `https://${team}.digitalsamba.com/${room}`;
192
- if (token) {
193
- const params = new URLSearchParams({ token });
194
-
195
- url = `${url}?${params}`;
196
- }
197
-
198
- this.frame.src = url;
199
- } else {
200
- this.logError(INVALID_CONFIG);
201
- return;
202
- }
203
-
204
- const allowedURL = new URL(this.frame.src);
205
-
206
- this.allowedOrigin = allowedURL.origin;
207
-
208
- this.frame.onload = () => this.checkTarget();
209
- };
210
-
211
- private checkTarget() {
212
- this.sendMessage({ type: "connect" });
213
-
214
- const confirmationTimeout = window.setTimeout(() => {
215
- this.logError(UNKNOWN_TARGET);
216
- }, CONNECT_TIMEOUT);
217
-
218
- this.on("connected", () => {
219
- this.connected = true;
220
- clearTimeout(confirmationTimeout);
221
- });
222
- }
223
-
224
- private sendMessage<G>(message: SendMessage<G>) {
225
- if (this.frame.contentWindow) {
226
- this.frame.contentWindow.postMessage(message, {
227
- targetOrigin: this.allowedOrigin,
228
- });
229
- }
230
- }
231
-
232
- private logError = (error: RichError) => {
233
- if (this.reportErrors) {
234
- throw error;
235
- }
236
- };
237
-
238
- private applyFrameProperties = (
239
- instanceProperties: Partial<InstanceProperties>
240
- ) => {
241
- if (instanceProperties.frameAttributes) {
242
- // TODO: only allow specific attrs here; This is a heck to support
243
- Object.entries(instanceProperties.frameAttributes).forEach(
244
- ([attr, value]) => {
245
- if (value !== null && typeof value !== "undefined") {
246
- this.frame.setAttribute(attr, value.toString());
247
- } else {
248
- this.frame.removeAttribute(attr);
249
- }
250
- }
251
- );
252
- }
253
-
254
- if (instanceProperties.reportErrors) {
255
- this.reportErrors = true;
256
- }
257
- };
258
-
259
- // commands
260
- enableVideo = () => {
261
- this.sendMessage({ type: "enableVideo" });
262
- };
263
-
264
- disableVideo = () => {
265
- this.sendMessage({ type: "disableVideo" });
266
- };
267
-
268
- toggleVideo = (enable?: boolean) => {
269
- if (typeof enable === "undefined") {
270
- this.sendMessage({ type: "toggleVideo" });
271
- } else {
272
- if (enable) {
273
- this.enableVideo();
274
- } else {
275
- this.disableVideo();
276
- }
277
- }
278
- };
279
-
280
- enableAudio = () => {
281
- this.sendMessage({ type: "enableAudio" });
282
- };
283
-
284
- disableAudio = () => {
285
- this.sendMessage({ type: "disableAudio" });
286
- };
287
-
288
- toggleAudio = (enable?: boolean) => {
289
- if (typeof enable === "undefined") {
290
- this.sendMessage({ type: "toggleAudio" });
291
- } else {
292
- if (enable) {
293
- this.enableAudio();
294
- } else {
295
- this.disableAudio();
296
- }
297
- }
298
- };
299
-
300
- startScreenshare = () => {
301
- this.sendMessage({ type: "startScreenshare" });
302
- };
303
-
304
- stopScreenshare = () => {
305
- this.sendMessage({ type: "stopScreenshare" });
306
- };
307
- }
package/src/umd.ts DELETED
@@ -1,4 +0,0 @@
1
- import {DigitalSambaEmbedded} from './index';
2
-
3
- // compatibility with script tag
4
- module.exports = DigitalSambaEmbedded
@@ -1,30 +0,0 @@
1
- export class RichError extends Error {
2
- constructor(error: { name: string; message: string }) {
3
- super(error.message);
4
-
5
- this.name = error.name;
6
- }
7
- }
8
-
9
- export const UNKNOWN_TARGET = new RichError({
10
- name: "UNKNOWN_TARGET",
11
- message:
12
- "Could not verify the identity of target frame. Commands may not work",
13
- });
14
-
15
- export const INVALID_CONFIG = new RichError({
16
- name: "INVALID_INIT_CONFIG",
17
- message: "Initializations options are invalid. Missing team name or room ID",
18
- });
19
-
20
- export const ALLOW_ATTRIBUTE_MISSING = new RichError({
21
- name: "ALLOW_ATTRIBUTE_MISSING",
22
- message:
23
- "You've provided a frame that is mising 'allow' attribute. Some functionality may not work.",
24
- });
25
-
26
-
27
- export const INVALID_URL = new RichError({
28
- name: "INVALID_URL",
29
- message: "Invalid frame url specified"
30
- })
package/tools/cleanup.js DELETED
@@ -1,29 +0,0 @@
1
- /* eslint-disable */
2
- const fs = require("fs");
3
- const Path = require("path");
4
- /* eslint-enable */
5
-
6
- const deleteFolderRecursive = (path) => {
7
- if (fs.existsSync(path)) {
8
- fs.readdirSync(path).forEach((file) => {
9
- const curPath = Path.join(path, file);
10
- if (fs.lstatSync(curPath).isDirectory()) {
11
- deleteFolderRecursive(curPath);
12
- } else {
13
- fs.unlinkSync(curPath);
14
- }
15
- });
16
- fs.rmdirSync(path);
17
- }
18
- };
19
-
20
- const folder = process.argv.slice(2)[0];
21
-
22
- if (folder) {
23
- deleteFolderRecursive(Path.join(__dirname, "../dist", folder));
24
- } else {
25
- deleteFolderRecursive(Path.join(__dirname, "../dist/cjs"));
26
- deleteFolderRecursive(Path.join(__dirname, "../dist/esm"));
27
- deleteFolderRecursive(Path.join(__dirname, "../dist/umd"));
28
- deleteFolderRecursive(Path.join(__dirname, "../dist/types"));
29
- }
package/tsconfig.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es5",
4
- "declaration": true,
5
- "allowJs": true,
6
- "incremental": true,
7
- "downlevelIteration": true,
8
- "strict": true,
9
- "forceConsistentCasingInFileNames": true,
10
- "module": "commonjs",
11
- "resolveJsonModule": true,
12
- "isolatedModules": false,
13
- "jsx": "react-jsx",
14
- "noImplicitAny": true,
15
- "outDir": "./dist",
16
- "esModuleInterop": true,
17
- "moduleResolution": "node",
18
- },
19
- "include": ["./src/**/*"],
20
- "exclude": ["node_modules"]
21
- }