2
0

first commit

This commit is contained in:
2024-08-09 00:39:27 +02:00
commit 79688abe2e
5698 changed files with 497838 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
# @calcom/embed-snippet
## 1.3.0
### Minor Changes
- Added namespacing support throughout
### Patch Changes
- Updated dependencies
- @calcom/embed-core@1.5.0
## 1.2.0
### Minor Changes
- Added a few more events
### Patch Changes
- Updated dependencies
- @calcom/embed-core@1.4.0
## 1.1.2
### Patch Changes
- Improve UI instruction layout typings
- Updated dependencies
- @calcom/embed-core@1.3.2
## 1.1.1
### Patch Changes
- layout type fix as zod-utils can't be used in npm package
- Updated dependencies
- @calcom/embed-core@1.3.1
## 1.1.0
### Minor Changes
- Supports new booker layout
### Patch Changes
- Updated dependencies
- @calcom/embed-core@1.3.0
## 1.0.9
### Patch Changes
- Fix the build for embed-react
- Updated dependencies
- @calcom/embed-core@1.2.1
## 1.0.8
### Patch Changes
- Updated dependencies
- @calcom/embed-core@1.2.0
## 1.0.7
### Patch Changes
- Add changesets. Use prepack instead of prePublish and prepublish only as that works with both yarn and npm
- Updated dependencies
- @calcom/embed-core@1.1.5

View File

@@ -0,0 +1,42 @@
The Cal.com Commercial License (EE) license (the “EE License”)
Copyright (c) 2020-present Cal.com, Inc
With regard to the Cal.com Software:
This software and associated documentation files (the "Software") may only be
used in production, if you (and any entity that you represent) have agreed to,
and are in compliance with, the Cal.com Subscription Terms available
at https://cal.com/terms (the “EE Terms”), or other agreements governing
the use of the Software, as mutually agreed by you and Cal.com, Inc ("Cal.com"),
and otherwise have a valid Cal.com Commercial License subscription ("EE Subscription")
for the correct number of hosts as defined in the EE Terms ("Hosts"). Subject to the foregoing sentence,
you are free to modify this Software and publish patches to the Software. You agree
that Cal.com and/or its licensors (as applicable) retain all right, title and interest in
and to all such modifications and/or patches, and all such modifications and/or
patches may only be used, copied, modified, displayed, distributed, or otherwise
exploited with a valid EE Subscription for the correct number of hosts.
Notwithstanding the foregoing, you may copy and modify the Software for development
and testing purposes, without requiring a subscription. You agree that Cal.com and/or
its licensors (as applicable) retain all right, title and interest in and to all such
modifications. You are not granted any other rights beyond what is expressly stated herein.
Subject to the foregoing, it is forbidden to copy, merge, publish, distribute, sublicense,
and/or sell the Software.
This EE License applies only to the part of this Software that is not distributed under
the AGPLv3 license. Any part of this Software distributed under the AGPLv3 license or which
is served client-side as an image, font, cascading stylesheet (CSS), file which produces
or is compiled, arranged, augmented, or combined into client-side JavaScript, in whole or
in part, is copyrighted under the AGPLv3 license. The full text of this EE License shall
be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
For all third party components incorporated into the Cal.com Software, those
components are licensed under the original license provided by the owner of the
applicable component.

View File

@@ -0,0 +1,10 @@
# embed-snippet
Vanilla JS embed snippet that is responsible to fetch @calcom/embed-core and thus show Cal Link as an embed on a page.
## Development
`yarn build` will generate dist/snippet.es.js. If you are going to test react embeds, make sure that you have built it so that they get the upto-date snippet
- which can be used as `<script type="module" src=...`
- You can also copy the appropriate portion of the code and install it directly as `<script>CODE_SUGGESTED_TO_BE_COPIED</script>`

View File

@@ -0,0 +1 @@
/// <reference types="vite/client" />

View File

@@ -0,0 +1,34 @@
{
"name": "@calcom/embed-snippet",
"sideEffects": false,
"version": "1.3.0",
"main": "./dist/snippet.umd.js",
"module": "./dist/snippet.es.js",
"description": "Vanilla JS embed snippet that is responsible to fetch @calcom/embed-core and thus show Cal Link as an embed on a page.",
"license": "SEE LICENSE IN LICENSE",
"repository": {
"type": "git",
"url": "https://github.com/calcom/cal.com",
"directory": "packages/embeds/embed-snippet"
},
"scripts": {
"build": "rm -rf dist && vite build && tsc --emitDeclarationOnly --declarationDir dist",
"type-check": "tsc --pretty --noEmit",
"type-check:ci": "tsc-absolute --pretty --noEmit",
"lint": "eslint --ext .ts,.js src",
"withEmbedPublishEnv": "NEXT_PUBLIC_EMBED_LIB_URL='https://app.cal.com/embed/embed.js' NEXT_PUBLIC_WEBAPP_URL='https://app.cal.com' yarn",
"prepack": "yarn ../../../ lint --filter='@calcom/embed-snippet' && yarn withEmbedPublishEnv build",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
},
"files": [
"dist"
],
"types": "./dist/index.d.ts",
"devDependencies": {
"typescript": "^4.9.4",
"vite": "^4.1.2"
},
"dependencies": {
"@calcom/embed-core": "workspace:*"
}
}

View File

@@ -0,0 +1,82 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable @typescript-eslint/ban-ts-comment,prefer-rest-params,prefer-const */
import type { GlobalCal, GlobalCalWithoutNs, Queue } from "@calcom/embed-core";
// FIXME: embed-snippet is a published package and shouldn't import from @calcom/types which is unpublished
// This isn't a problem at the moment because embed-snippet isn't directly imported and embed-react which uses it doesn't depend on this
// eslint-disable-next-line no-restricted-imports
import type { Optional } from "@calcom/types/utils";
/**
* As we want to keep control on the size of this snippet but we want some portion of it to be still readable.
* So, write the code that you need directly but keep it short.
*/
const WEBAPP_URL =
import.meta.env.EMBED_PUBLIC_WEBAPP_URL || `https://${import.meta.env.EMBED_PUBLIC_VERCEL_URL}`;
const EMBED_LIB_URL = import.meta.env.EMBED_PUBLIC_EMBED_LIB_URL || `${WEBAPP_URL}/embed/embed.js`;
type QueuePushArg = {
[k: number]: Queue[number];
};
/**
* When modifying this snippet, make sure to keep the snippets in following places in sync
* 1. EmbedTabs.tsx
* 2. embed-core/index.html
* 3. app-store/wordpress/plugin.php
*/
export default function EmbedSnippet(url = EMBED_LIB_URL) {
(function (C, A, L) {
let p = function (a: GlobalCalWithoutNs, ar: QueuePushArg) {
a.q.push(ar);
};
let d = C.document;
C.Cal =
C.Cal ||
function () {
let cal = C.Cal;
let ar = arguments;
if (!cal.loaded) {
// 'ns' and 'q' are now definitely set with the following 2 lines, so you can safely assert in TypeScript that it's GlobalCal now.
cal.ns = {};
cal.q = cal.q || [];
//@ts-ignore
d.head.appendChild(d.createElement("script")).src = A;
cal.loaded = true;
}
if (ar[0] === L) {
const api: GlobalCalWithoutNs = function () {
p(api, arguments);
};
const namespace = ar[1];
api.q = api.q || [];
if (typeof namespace === "string") {
// Make sure that even after re-execution of the snippet, the namespace is not overridden
cal.ns![namespace] = cal.ns![namespace] || api;
p(cal.ns![namespace], ar);
// Inform the default namespace queue to initialize this namespace
p(cal as GlobalCal, ["initNamespace", namespace]);
} else p(cal as GlobalCal, ar);
return;
}
p(cal as GlobalCal, ar);
};
})(
window as Omit<Window, "Cal"> & {
// Make 'ns' and 'q' optional as they are set through the snippet above
Cal: Optional<GlobalCal, "ns" | "q">;
},
//! Replace it with "https://cal.com/embed.js" or the URL where you have embed.js installed
url,
"init"
);
/*! Copying ends here. */
return window.Cal;
}
export const EmbedSnippetString = EmbedSnippet.toString();

View File

@@ -0,0 +1,17 @@
{
"extends": "@calcom/tsconfig/base.json",
"compilerOptions": {
"jsx": "react",
"target": "ES2015",
"baseUrl": ".",
"module": "ESNext",
"declaration": true,
"outDir": "dist",
"paths": {
"@calcom/embed-core": ["../embed-core/src"],
"@calcom/embed-react": ["../embed-react/src"]
}
},
"include": ["."],
"exclude": ["dist", "build", "node_modules"]
}

View File

@@ -0,0 +1,15 @@
import viteBaseConfig from "../vite.config";
const path = require("path");
const { defineConfig } = require("vite");
module.exports = defineConfig({
...viteBaseConfig,
build: {
lib: {
entry: path.resolve(__dirname, "src", "index.ts"),
name: "snippet",
fileName: (format) => `snippet.${format}.js`,
},
},
});