@zsviczian/excalidraw 0.17.6-1 → 0.17.6-2

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.
@@ -3080,7 +3080,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
3080
3080
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3081
3081
 
3082
3082
  "use strict";
3083
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ExcalidrawFontFace\": () => (/* binding */ ExcalidrawFontFace)\n/* harmony export */ });\n/* harmony import */ var _data_encode__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../data/encode */ \"./data/encode.ts\");\n/* harmony import */ var _obsidianUtils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../obsidianUtils */ \"./obsidianUtils.ts\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils */ \"./utils.ts\");\n/* harmony import */ var _metadata__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./metadata */ \"./fonts/metadata.ts\");\n/* harmony import */ var _subset_subset_main__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./subset/subset-main */ \"./fonts/subset/subset-main.ts\");\n\n\n\n\n\nclass ExcalidrawFontFace {\n constructor(family, uri, descriptors) {\n this.urls = ExcalidrawFontFace.createUrls(uri);\n const sources = this.urls.map(url => `url(${url}) ${ExcalidrawFontFace.getFormat(url)}`).join(\", \");\n this.fontFace = new FontFace(family, sources, Object.assign({\n display: \"swap\",\n style: \"normal\",\n weight: \"400\"\n }, descriptors));\n }\n /**\r\n * Generates CSS `@font-face` definition with the (subsetted) font source as a data url for the characters within the unicode range.\r\n *\r\n * Retrieves `undefined` otherwise.\r\n */\n\n\n toCSS(characters, codePoints) {\n // quick exit in case the characters are not within this font face's unicode range\n if (!this.getUnicodeRangeRegex().test(characters)) {\n return;\n } //zsviczian - only woffs are chopped into glyphs other fonts are returned as is\n\n\n if (typeof this.urls[0] === \"string\" && !this.urls[0].startsWith(\"data:font/woff2\")) {\n return Promise.resolve(`@font-face { font-family: ${this.fontFace.family}; src: url(${this.urls[0]}); }`);\n }\n\n return this.getContent(codePoints).then(content => `@font-face { font-family: ${this.fontFace.family}; src: url(${content}); }`);\n }\n /**\r\n * Tries to fetch woff2 content, based on the registered urls (from first to last, treated as fallbacks).\r\n *\r\n * @returns base64 with subsetted glyphs based on the passed codepoint, last defined url otherwise\r\n */\n\n\n async getContent(codePoints) {\n let i = 0;\n const errorMessages = [];\n\n while (i < this.urls.length) {\n const url = this.urls[i];\n\n try {\n const arrayBuffer = await this.fetchFont(url);\n const base64 = await (0,_subset_subset_main__WEBPACK_IMPORTED_MODULE_4__.subsetWoff2GlyphsByCodepoints)(arrayBuffer, codePoints);\n return base64;\n } catch (e) {\n errorMessages.push(`\"${url.toString()}\" returned error \"${e}\"`);\n }\n\n i++;\n }\n\n console.error(`Failed to fetch font family \"${this.fontFace.family}\"`, JSON.stringify(errorMessages, undefined, 2)); // in case of issues, at least return the last url as a content\n // defaults to unpkg for bundled fonts (so that we don't have to host them forever) and http url for others\n\n return this.urls.length ? this.urls[this.urls.length - 1].toString() : \"\";\n }\n\n fetchFont(url) {\n return (0,_utils__WEBPACK_IMPORTED_MODULE_2__.promiseTry)(async () => {\n const result = await (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_1__.fetchFontFromVault)(url); //zsviczian\n\n if (result) {\n if (typeof result === \"string\") {\n url = result;\n } else {\n return result;\n }\n }\n\n const response = await fetch(url, {\n headers: {\n Accept: \"font/woff2\"\n }\n });\n\n if (!response.ok) {\n const urlString = url instanceof URL ? url.toString() : \"dataurl\";\n throw new Error(`Failed to fetch \"${urlString}\": ${response.statusText}`);\n }\n\n const arrayBuffer = await response.arrayBuffer();\n return arrayBuffer;\n });\n }\n\n getUnicodeRangeRegex() {\n // using \\u{h} or \\u{hhhhh} to match any number of hex digits,\n // otherwise we would get an \"Invalid Unicode escape\" error\n // e.g. U+0-1007F -> \\u{0}-\\u{1007F}\n const unicodeRangeRegex = this.fontFace.unicodeRange.split(/,\\s*/).map(range => {\n const [start, end] = range.replace(\"U+\", \"\").split(\"-\");\n\n if (end) {\n return `\\\\u{${start}}-\\\\u{${end}}`;\n }\n\n return `\\\\u{${start}}`;\n }).join(\"\");\n return new RegExp(`[${unicodeRangeRegex}]`, \"u\");\n }\n\n static createUrls(uri) {\n if (uri.startsWith(\"data\")) {\n // don't create the URL instance, as parsing the huge dataurl string is expensive\n return [uri];\n }\n\n if (uri.startsWith(_metadata__WEBPACK_IMPORTED_MODULE_3__.LOCAL_FONT_PROTOCOL)) {\n // no url for local fonts\n return [];\n }\n\n if (uri.startsWith(\"http\")) {\n // one url for http imports or data url\n return [new URL(uri)];\n } // absolute assets paths, which are found in tests and excalidraw-app build, won't work with base url, so we are stripping initial slash away\n\n\n const assetUrl = uri.replace(/^\\/+/, \"\");\n const urls = [];\n\n if (typeof window.EXCALIDRAW_ASSET_PATH === \"string\") {\n const normalizedBaseUrl = this.normalizeBaseUrl(window.EXCALIDRAW_ASSET_PATH);\n urls.push(new URL(assetUrl, normalizedBaseUrl));\n } else if (Array.isArray(window.EXCALIDRAW_ASSET_PATH)) {\n window.EXCALIDRAW_ASSET_PATH.forEach(path => {\n const normalizedBaseUrl = this.normalizeBaseUrl(path);\n urls.push(new URL(assetUrl, normalizedBaseUrl));\n });\n } // fallback url for bundled fonts\n\n\n urls.push(new URL(assetUrl, ExcalidrawFontFace.UNPKG_FALLBACK_URL));\n return urls;\n }\n\n static getFormat(url) {\n if (!(url instanceof URL)) {\n // format is irrelevant for data url\n return \"\";\n }\n\n try {\n const parts = new URL(url).pathname.split(\".\");\n\n if (parts.length === 1) {\n return \"\";\n }\n\n return `format('${parts.pop()}')`;\n } catch (error) {\n return \"\";\n }\n }\n\n static normalizeBaseUrl(baseUrl) {\n var _a;\n\n let result = baseUrl; // in case user passed a root-relative url (~absolute path),\n // like \"/\" or \"/some/path\", or relative (starts with \"./\"),\n // prepend it with `location.origin`\n\n if (/^\\.?\\//.test(result)) {\n result = new URL(result.replace(/^\\.?\\/+/, \"\"), (_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.origin).toString();\n } // ensure there is a trailing slash, otherwise url won't be correctly concatenated\n\n\n result = `${result.replace(/\\/+$/, \"\")}/`;\n return result;\n }\n /**\r\n * zsviczian https://github.com/zsviczian/excalidraw/commit/b4cfaaa4b4f46ca01f94e27fb7bf651a9da99daa\r\n */\n\n\n async getContentLegacy() {\n let i = 0;\n const errorMessages = [];\n\n while (i < this.urls.length) {\n let url = this.urls[i];\n\n if (typeof url === \"string\" && url.startsWith(\"data:\")) {\n // it's dataurl, the font is inlined as base64, no need to fetch\n return url;\n }\n\n try {\n const result = await (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_1__.fetchFontFromVault)(url); //zsviczian\n\n if (result) {\n if (typeof result === \"string\") {\n url = result;\n } else {\n return `data:font/woff2;base64,${await (0,_data_encode__WEBPACK_IMPORTED_MODULE_0__.stringToBase64)(await (0,_data_encode__WEBPACK_IMPORTED_MODULE_0__.toByteString)(result), true)}`;\n }\n }\n\n const response = await fetch(url, {\n headers: {\n Accept: \"font/woff2\"\n }\n });\n\n if (response.ok) {\n const mimeType = response.headers.get(\"Content-Type\");\n const buffer = await response.arrayBuffer();\n return `data:${mimeType};base64,${await (0,_data_encode__WEBPACK_IMPORTED_MODULE_0__.stringToBase64)(await (0,_data_encode__WEBPACK_IMPORTED_MODULE_0__.toByteString)(buffer), true)}`;\n } // response not ok, try to continue\n\n\n errorMessages.push(`\"${url.toString()}\" returned status \"${response.status}\"`);\n } catch (e) {\n errorMessages.push(`\"${url.toString()}\" returned error \"${e}\"`);\n }\n\n i++;\n }\n\n console.error(`Failed to fetch font \"${this.fontFace.family}\" from urls \"${this.urls.toString()}`, JSON.stringify(errorMessages, undefined, 2)); // in case of issues, at least return the last url as a content\n // defaults to unpkg for bundled fonts (so that we don't have to host them forever) and http url for others\n\n return this.urls.length ? this.urls[this.urls.length - 1].toString() : \"\";\n }\n\n}\nExcalidrawFontFace.UNPKG_FALLBACK_URL = `https://unpkg.com/${ true ? `${\"@zsviczian/excalidraw\"}@${({\"VITE_APP_BACKEND_V2_GET_URL\":\"https://json-dev.excalidraw.com/api/v2/\",\"VITE_APP_BACKEND_V2_POST_URL\":\"https://json-dev.excalidraw.com/api/v2/post/\",\"VITE_APP_LIBRARY_URL\":\"https://libraries.excalidraw.com\",\"VITE_APP_LIBRARY_BACKEND\":\"https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries\",\"VITE_APP_WS_SERVER_URL\":\"http://localhost:3002\",\"VITE_APP_PLUS_LP\":\"https://plus.excalidraw.com\",\"VITE_APP_PLUS_APP\":\"https://app.excalidraw.com\",\"VITE_APP_AI_BACKEND\":\"http://localhost:3015\",\"VITE_APP_FIREBASE_CONFIG\":\"{\\\"apiKey\\\":\\\"AIzaSyCMkxA60XIW8KbqMYL7edC4qT5l4qHX2h8\\\",\\\"authDomain\\\":\\\"excalidraw-oss-dev.firebaseapp.com\\\",\\\"projectId\\\":\\\"excalidraw-oss-dev\\\",\\\"storageBucket\\\":\\\"excalidraw-oss-dev.appspot.com\\\",\\\"messagingSenderId\\\":\\\"664559512677\\\",\\\"appId\\\":\\\"1:664559512677:web:a385181f2928d328a7aa8c\\\"}\",\"VITE_APP_DEV_DISABLE_LIVE_RELOAD\":\"\",\"VITE_APP_ENABLE_TRACKING\":\"true\",\"FAST_REFRESH\":\"false\",\"VITE_APP_PORT\":\"3000\",\"VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX\":\"\",\"VITE_APP_COLLAPSE_OVERLAY\":\"true\",\"VITE_APP_ENABLE_ESLINT\":\"true\",\"VITE_PKG_NAME\":\"@zsviczian/excalidraw\",\"VITE_PKG_VERSION\":\"0.17.6-1\",\"VITE_IS_EXCALIDRAW_NPM_PACKAGE\":true}).PKG_VERSION}` // should be provided by vite during package build\n: 0 // fallback to latest package version (i.e. for app)\n}/dist/prod/`;\n\n//# sourceURL=webpack://ExcalidrawLib/./fonts/ExcalidrawFontFace.ts?");
3083
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ExcalidrawFontFace\": () => (/* binding */ ExcalidrawFontFace)\n/* harmony export */ });\n/* harmony import */ var _data_encode__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../data/encode */ \"./data/encode.ts\");\n/* harmony import */ var _obsidianUtils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../obsidianUtils */ \"./obsidianUtils.ts\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils */ \"./utils.ts\");\n/* harmony import */ var _metadata__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./metadata */ \"./fonts/metadata.ts\");\n/* harmony import */ var _subset_subset_main__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./subset/subset-main */ \"./fonts/subset/subset-main.ts\");\n\n\n\n\n\nclass ExcalidrawFontFace {\n constructor(family, uri, descriptors) {\n this.urls = ExcalidrawFontFace.createUrls(uri);\n const sources = this.urls.map(url => `url(${url}) ${ExcalidrawFontFace.getFormat(url)}`).join(\", \");\n this.fontFace = new FontFace(family, sources, Object.assign({\n display: \"swap\",\n style: \"normal\",\n weight: \"400\"\n }, descriptors));\n }\n /**\r\n * Generates CSS `@font-face` definition with the (subsetted) font source as a data url for the characters within the unicode range.\r\n *\r\n * Retrieves `undefined` otherwise.\r\n */\n\n\n toCSS(characters, codePoints) {\n // quick exit in case the characters are not within this font face's unicode range\n if (!this.getUnicodeRangeRegex().test(characters)) {\n return;\n } //zsviczian - only woffs are chopped into glyphs other fonts are returned as is\n\n\n if (typeof this.urls[0] === \"string\" && !this.urls[0].startsWith(\"data:font/woff2\")) {\n return Promise.resolve(`@font-face { font-family: ${this.fontFace.family}; src: url(${this.urls[0]}); }`);\n }\n\n return this.getContent(codePoints).then(content => `@font-face { font-family: ${this.fontFace.family}; src: url(${content}); }`);\n }\n /**\r\n * Tries to fetch woff2 content, based on the registered urls (from first to last, treated as fallbacks).\r\n *\r\n * @returns base64 with subsetted glyphs based on the passed codepoint, last defined url otherwise\r\n */\n\n\n async getContent(codePoints) {\n let i = 0;\n const errorMessages = [];\n\n while (i < this.urls.length) {\n const url = this.urls[i];\n\n try {\n const arrayBuffer = await this.fetchFont(url);\n const base64 = await (0,_subset_subset_main__WEBPACK_IMPORTED_MODULE_4__.subsetWoff2GlyphsByCodepoints)(arrayBuffer, codePoints);\n return base64;\n } catch (e) {\n errorMessages.push(`\"${url.toString()}\" returned error \"${e}\"`);\n }\n\n i++;\n }\n\n console.error(`Failed to fetch font family \"${this.fontFace.family}\"`, JSON.stringify(errorMessages, undefined, 2)); // in case of issues, at least return the last url as a content\n // defaults to unpkg for bundled fonts (so that we don't have to host them forever) and http url for others\n\n return this.urls.length ? this.urls[this.urls.length - 1].toString() : \"\";\n }\n\n fetchFont(url) {\n return (0,_utils__WEBPACK_IMPORTED_MODULE_2__.promiseTry)(async () => {\n const result = await (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_1__.fetchFontFromVault)(url); //zsviczian\n\n if (result) {\n return result;\n }\n\n const response = await fetch(url, {\n headers: {\n Accept: \"font/woff2\"\n }\n });\n\n if (!response.ok) {\n const urlString = url instanceof URL ? url.toString() : \"dataurl\";\n throw new Error(`Failed to fetch \"${urlString}\": ${response.statusText}`);\n }\n\n const arrayBuffer = await response.arrayBuffer();\n return arrayBuffer;\n });\n }\n\n getUnicodeRangeRegex() {\n // using \\u{h} or \\u{hhhhh} to match any number of hex digits,\n // otherwise we would get an \"Invalid Unicode escape\" error\n // e.g. U+0-1007F -> \\u{0}-\\u{1007F}\n const unicodeRangeRegex = this.fontFace.unicodeRange.split(/,\\s*/).map(range => {\n const [start, end] = range.replace(\"U+\", \"\").split(\"-\");\n\n if (end) {\n return `\\\\u{${start}}-\\\\u{${end}}`;\n }\n\n return `\\\\u{${start}}`;\n }).join(\"\");\n return new RegExp(`[${unicodeRangeRegex}]`, \"u\");\n }\n\n static createUrls(uri) {\n if (uri.startsWith(\"data\")) {\n // don't create the URL instance, as parsing the huge dataurl string is expensive\n return [uri];\n }\n\n if (uri.startsWith(_metadata__WEBPACK_IMPORTED_MODULE_3__.LOCAL_FONT_PROTOCOL)) {\n // no url for local fonts\n return [];\n }\n\n if (uri.startsWith(\"http\")) {\n // one url for http imports or data url\n return [new URL(uri)];\n } // absolute assets paths, which are found in tests and excalidraw-app build, won't work with base url, so we are stripping initial slash away\n\n\n const assetUrl = uri.replace(/^\\/+/, \"\");\n const urls = [];\n\n if (typeof window.EXCALIDRAW_ASSET_PATH === \"string\") {\n const normalizedBaseUrl = this.normalizeBaseUrl(window.EXCALIDRAW_ASSET_PATH);\n urls.push(new URL(assetUrl, normalizedBaseUrl));\n } else if (Array.isArray(window.EXCALIDRAW_ASSET_PATH)) {\n window.EXCALIDRAW_ASSET_PATH.forEach(path => {\n const normalizedBaseUrl = this.normalizeBaseUrl(path);\n urls.push(new URL(assetUrl, normalizedBaseUrl));\n });\n } // fallback url for bundled fonts\n\n\n urls.push(new URL(assetUrl, ExcalidrawFontFace.UNPKG_FALLBACK_URL));\n return urls;\n }\n\n static getFormat(url) {\n if (!(url instanceof URL)) {\n // format is irrelevant for data url\n return \"\";\n }\n\n try {\n const parts = new URL(url).pathname.split(\".\");\n\n if (parts.length === 1) {\n return \"\";\n }\n\n return `format('${parts.pop()}')`;\n } catch (error) {\n return \"\";\n }\n }\n\n static normalizeBaseUrl(baseUrl) {\n var _a;\n\n let result = baseUrl; // in case user passed a root-relative url (~absolute path),\n // like \"/\" or \"/some/path\", or relative (starts with \"./\"),\n // prepend it with `location.origin`\n\n if (/^\\.?\\//.test(result)) {\n result = new URL(result.replace(/^\\.?\\/+/, \"\"), (_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.origin).toString();\n } // ensure there is a trailing slash, otherwise url won't be correctly concatenated\n\n\n result = `${result.replace(/\\/+$/, \"\")}/`;\n return result;\n }\n /**\r\n * zsviczian https://github.com/zsviczian/excalidraw/commit/b4cfaaa4b4f46ca01f94e27fb7bf651a9da99daa\r\n */\n\n\n async getContentLegacy() {\n let i = 0;\n const errorMessages = [];\n\n while (i < this.urls.length) {\n const url = this.urls[i];\n\n if (typeof url === \"string\" && url.startsWith(\"data:\")) {\n // it's dataurl, the font is inlined as base64, no need to fetch\n return url;\n }\n\n try {\n const result = await (0,_obsidianUtils__WEBPACK_IMPORTED_MODULE_1__.fetchFontFromVault)(url); //zsviczian\n\n if (result) {\n return `data:font/woff2;base64,${await (0,_data_encode__WEBPACK_IMPORTED_MODULE_0__.stringToBase64)(await (0,_data_encode__WEBPACK_IMPORTED_MODULE_0__.toByteString)(result), true)}`;\n }\n\n const response = await fetch(url, {\n headers: {\n Accept: \"font/woff2\"\n }\n });\n\n if (response.ok) {\n const mimeType = response.headers.get(\"Content-Type\");\n const buffer = await response.arrayBuffer();\n return `data:${mimeType};base64,${await (0,_data_encode__WEBPACK_IMPORTED_MODULE_0__.stringToBase64)(await (0,_data_encode__WEBPACK_IMPORTED_MODULE_0__.toByteString)(buffer), true)}`;\n } // response not ok, try to continue\n\n\n errorMessages.push(`\"${url.toString()}\" returned status \"${response.status}\"`);\n } catch (e) {\n errorMessages.push(`\"${url.toString()}\" returned error \"${e}\"`);\n }\n\n i++;\n }\n\n console.error(`Failed to fetch font \"${this.fontFace.family}\" from urls \"${this.urls.toString()}`, JSON.stringify(errorMessages, undefined, 2)); // in case of issues, at least return the last url as a content\n // defaults to unpkg for bundled fonts (so that we don't have to host them forever) and http url for others\n\n return this.urls.length ? this.urls[this.urls.length - 1].toString() : \"\";\n }\n\n}\nExcalidrawFontFace.UNPKG_FALLBACK_URL = `https://unpkg.com/${ true ? `${\"@zsviczian/excalidraw\"}@${({\"VITE_APP_BACKEND_V2_GET_URL\":\"https://json-dev.excalidraw.com/api/v2/\",\"VITE_APP_BACKEND_V2_POST_URL\":\"https://json-dev.excalidraw.com/api/v2/post/\",\"VITE_APP_LIBRARY_URL\":\"https://libraries.excalidraw.com\",\"VITE_APP_LIBRARY_BACKEND\":\"https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries\",\"VITE_APP_WS_SERVER_URL\":\"http://localhost:3002\",\"VITE_APP_PLUS_LP\":\"https://plus.excalidraw.com\",\"VITE_APP_PLUS_APP\":\"https://app.excalidraw.com\",\"VITE_APP_AI_BACKEND\":\"http://localhost:3015\",\"VITE_APP_FIREBASE_CONFIG\":\"{\\\"apiKey\\\":\\\"AIzaSyCMkxA60XIW8KbqMYL7edC4qT5l4qHX2h8\\\",\\\"authDomain\\\":\\\"excalidraw-oss-dev.firebaseapp.com\\\",\\\"projectId\\\":\\\"excalidraw-oss-dev\\\",\\\"storageBucket\\\":\\\"excalidraw-oss-dev.appspot.com\\\",\\\"messagingSenderId\\\":\\\"664559512677\\\",\\\"appId\\\":\\\"1:664559512677:web:a385181f2928d328a7aa8c\\\"}\",\"VITE_APP_DEV_DISABLE_LIVE_RELOAD\":\"\",\"VITE_APP_ENABLE_TRACKING\":\"true\",\"FAST_REFRESH\":\"false\",\"VITE_APP_PORT\":\"3000\",\"VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX\":\"\",\"VITE_APP_COLLAPSE_OVERLAY\":\"true\",\"VITE_APP_ENABLE_ESLINT\":\"true\",\"VITE_PKG_NAME\":\"@zsviczian/excalidraw\",\"VITE_PKG_VERSION\":\"0.17.6-1\",\"VITE_IS_EXCALIDRAW_NPM_PACKAGE\":true}).PKG_VERSION}` // should be provided by vite during package build\n: 0 // fallback to latest package version (i.e. for app)\n}/dist/prod/`;\n\n//# sourceURL=webpack://ExcalidrawLib/./fonts/ExcalidrawFontFace.ts?");
3084
3084
 
3085
3085
  /***/ }),
3086
3086
 
@@ -3553,7 +3553,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
3553
3553
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3554
3554
 
3555
3555
  "use strict";
3556
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"allowDoubleTapEraser\": () => (/* binding */ allowDoubleTapEraser),\n/* harmony export */ \"destroyObsidianUtils\": () => (/* binding */ destroyObsidianUtils),\n/* harmony export */ \"fetchFontFromVault\": () => (/* binding */ fetchFontFromVault),\n/* harmony export */ \"getAreaLimit\": () => (/* binding */ getAreaLimit),\n/* harmony export */ \"getCSSFontDefinition\": () => (/* binding */ getCSSFontDefinition),\n/* harmony export */ \"getExcalidrawContentEl\": () => (/* binding */ getExcalidrawContentEl),\n/* harmony export */ \"getFontFamilies\": () => (/* binding */ getFontFamilies),\n/* harmony export */ \"getMaxZoom\": () => (/* binding */ getMaxZoom),\n/* harmony export */ \"getOpenAIDefaultVisionModel\": () => (/* binding */ getOpenAIDefaultVisionModel),\n/* harmony export */ \"getWidthHeightLimit\": () => (/* binding */ getWidthHeightLimit),\n/* harmony export */ \"hideFreedrawPenmodeCursor\": () => (/* binding */ hideFreedrawPenmodeCursor),\n/* harmony export */ \"hostPlugin\": () => (/* binding */ hostPlugin),\n/* harmony export */ \"initializeObsidianUtils\": () => (/* binding */ initializeObsidianUtils),\n/* harmony export */ \"isExcaliBrainView\": () => (/* binding */ isExcaliBrainView),\n/* harmony export */ \"loadSceneFonts\": () => (/* binding */ loadSceneFonts),\n/* harmony export */ \"registerFontsInCSS\": () => (/* binding */ registerFontsInCSS),\n/* harmony export */ \"registerLocalFont\": () => (/* binding */ registerLocalFont)\n/* harmony export */ });\n/* harmony import */ var _components_icons__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./components/icons */ \"./components/icons.tsx\");\n/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants */ \"./constants.ts\");\n/* harmony import */ var _fonts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./fonts */ \"./fonts/index.ts\");\n/* harmony import */ var _fonts_metadata__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fonts/metadata */ \"./fonts/metadata.ts\");\n\n\n\n //zsviczian, my dirty little secrets. These are hacks I am not proud of...\n\nlet hostPlugin = null;\nfunction destroyObsidianUtils() {\n hostPlugin = null;\n}\nfunction initializeObsidianUtils(obsidianPlugin) {\n hostPlugin = obsidianPlugin;\n}\nfunction getAreaLimit() {\n var _a;\n\n return (_a = hostPlugin.excalidrawConfig.areaLimit) !== null && _a !== void 0 ? _a : 16777216;\n}\nfunction getWidthHeightLimit() {\n var _a;\n\n return (_a = hostPlugin.excalidrawConfig.widthHeightLimit) !== null && _a !== void 0 ? _a : 32767;\n}\nfunction allowDoubleTapEraser() {\n return hostPlugin.settings.penModeDoubleTapEraser;\n}\nfunction getMaxZoom() {\n var _a;\n\n return (_a = hostPlugin.settings.zoomToFitMaxLevel) !== null && _a !== void 0 ? _a : 1;\n}\nfunction isExcaliBrainView() {\n const excalidrawView = hostPlugin.activeExcalidrawView;\n\n if (!excalidrawView) {\n return false;\n }\n\n return excalidrawView.linksAlwaysOpenInANewPane && excalidrawView.allowFrameButtonsInViewMode;\n}\nfunction getExcalidrawContentEl() {\n const excalidrawView = hostPlugin.activeExcalidrawView;\n\n if (!excalidrawView) {\n return document.body;\n }\n\n return excalidrawView.contentEl;\n}\nfunction hideFreedrawPenmodeCursor() {\n return !hostPlugin.settings.penModeCrosshairVisible;\n}\nfunction getOpenAIDefaultVisionModel() {\n return hostPlugin.settings.openAIDefaultVisionModel;\n}\nfunction registerLocalFont(fontMetrics, uri) {\n const _register = _fonts__WEBPACK_IMPORTED_MODULE_2__.register.bind({\n registered: _fonts__WEBPACK_IMPORTED_MODULE_2__.Fonts.registered\n });\n\n _fonts_metadata__WEBPACK_IMPORTED_MODULE_3__.FONT_METADATA[_constants__WEBPACK_IMPORTED_MODULE_1__.FONT_FAMILY[\"Local Font\"]] = {\n metrics: fontMetrics.metrics,\n icon: _components_icons__WEBPACK_IMPORTED_MODULE_0__.FreedrawIcon\n };\n\n _register(\"Local Font\", fontMetrics, {\n uri\n });\n}\nfunction getFontFamilies() {\n const fontFamilies = new Set();\n\n for (const fontFaces of _fonts__WEBPACK_IMPORTED_MODULE_2__.Fonts.registered.values()) {\n if (fontFaces.metadata.local) {\n continue;\n }\n\n for (const font of fontFaces.fontFaces) {\n if (font.fontFace.family === \"Local Font\") {\n continue;\n }\n\n fontFamilies.add(font.fontFace.family);\n }\n }\n\n return Array.from(fontFamilies);\n}\nasync function registerFontsInCSS() {\n const styleId = \"ExcalidrawFonts\";\n let styleElement = document.getElementById(styleId);\n\n if (!styleElement) {\n styleElement = document.createElement(\"style\");\n styleElement.id = styleId;\n document.head.appendChild(styleElement);\n } else {\n styleElement.textContent = \"\";\n }\n\n let cssContent = \"\";\n\n for (const fontFaces of _fonts__WEBPACK_IMPORTED_MODULE_2__.Fonts.registered.values()) {\n if (fontFaces.metadata.local) {\n continue;\n }\n\n for (const font of fontFaces.fontFaces) {\n try {\n const content = await font.getContentLegacy();\n cssContent += `@font-face {font-family: ${font.fontFace.family}; src: url(${content});}\\n`;\n } catch (e) {\n console.error(`Skipped inlining font \"${font.toString()}\"`, e);\n }\n }\n }\n\n styleElement.textContent = cssContent;\n}\nasync function getCSSFontDefinition(fontFamily) {\n var _a;\n\n const fontFaces = (_a = _fonts__WEBPACK_IMPORTED_MODULE_2__.Fonts.registered.get(fontFamily)) === null || _a === void 0 ? void 0 : _a.fontFaces;\n\n if (!fontFaces) {\n return \"\";\n }\n\n const fontFace = fontFaces[0];\n\n if (!fontFace) {\n return \"\";\n }\n\n const content = await fontFace.getContentLegacy();\n return `@font-face {font-family: ${fontFaces[0].fontFace.family}; src: url(${content});}`;\n}\nasync function loadSceneFonts(elements) {\n const fontFamilies = _fonts__WEBPACK_IMPORTED_MODULE_2__.Fonts.getElementsFamilies(elements);\n await _fonts__WEBPACK_IMPORTED_MODULE_2__.Fonts.loadFontFaces(fontFamilies);\n}\nasync function fetchFontFromVault(url) {\n if (typeof url === \"string\" && !url.startsWith(\"data\") && url.endsWith(\".woff2\")) {\n const filename = decodeURIComponent(url.substring(url.lastIndexOf(\"/\") + 1));\n const arrayBuffer = hostPlugin.loadFontFromFile(filename);\n\n if (arrayBuffer) {\n return arrayBuffer;\n }\n\n if ([\"Assistant-Regular.woff2\", \"Assistant-Medium.woff2\", \"Assistant-SemiBold.woff2\", \"Assistant-Bold.woff2\"].includes(filename)) {\n return \"https://unpkg.com/@zsviczian/excalidraw@0.17.6-1/dist/excalidraw-assets/\" + filename;\n }\n }\n\n return;\n}\n\n//# sourceURL=webpack://ExcalidrawLib/./obsidianUtils.ts?");
3556
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"allowDoubleTapEraser\": () => (/* binding */ allowDoubleTapEraser),\n/* harmony export */ \"destroyObsidianUtils\": () => (/* binding */ destroyObsidianUtils),\n/* harmony export */ \"fetchFontFromVault\": () => (/* binding */ fetchFontFromVault),\n/* harmony export */ \"getAreaLimit\": () => (/* binding */ getAreaLimit),\n/* harmony export */ \"getCSSFontDefinition\": () => (/* binding */ getCSSFontDefinition),\n/* harmony export */ \"getExcalidrawContentEl\": () => (/* binding */ getExcalidrawContentEl),\n/* harmony export */ \"getFontFamilies\": () => (/* binding */ getFontFamilies),\n/* harmony export */ \"getMaxZoom\": () => (/* binding */ getMaxZoom),\n/* harmony export */ \"getOpenAIDefaultVisionModel\": () => (/* binding */ getOpenAIDefaultVisionModel),\n/* harmony export */ \"getWidthHeightLimit\": () => (/* binding */ getWidthHeightLimit),\n/* harmony export */ \"hideFreedrawPenmodeCursor\": () => (/* binding */ hideFreedrawPenmodeCursor),\n/* harmony export */ \"hostPlugin\": () => (/* binding */ hostPlugin),\n/* harmony export */ \"initializeObsidianUtils\": () => (/* binding */ initializeObsidianUtils),\n/* harmony export */ \"isExcaliBrainView\": () => (/* binding */ isExcaliBrainView),\n/* harmony export */ \"loadSceneFonts\": () => (/* binding */ loadSceneFonts),\n/* harmony export */ \"registerFontsInCSS\": () => (/* binding */ registerFontsInCSS),\n/* harmony export */ \"registerLocalFont\": () => (/* binding */ registerLocalFont)\n/* harmony export */ });\n/* harmony import */ var _components_icons__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./components/icons */ \"./components/icons.tsx\");\n/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants */ \"./constants.ts\");\n/* harmony import */ var _fonts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./fonts */ \"./fonts/index.ts\");\n/* harmony import */ var _fonts_metadata__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fonts/metadata */ \"./fonts/metadata.ts\");\n\n\n\n //zsviczian, my dirty little secrets. These are hacks I am not proud of...\n\nlet hostPlugin = null;\nfunction destroyObsidianUtils() {\n hostPlugin = null;\n}\nfunction initializeObsidianUtils(obsidianPlugin) {\n hostPlugin = obsidianPlugin;\n}\nfunction getAreaLimit() {\n var _a;\n\n return (_a = hostPlugin.excalidrawConfig.areaLimit) !== null && _a !== void 0 ? _a : 16777216;\n}\nfunction getWidthHeightLimit() {\n var _a;\n\n return (_a = hostPlugin.excalidrawConfig.widthHeightLimit) !== null && _a !== void 0 ? _a : 32767;\n}\nfunction allowDoubleTapEraser() {\n return hostPlugin.settings.penModeDoubleTapEraser;\n}\nfunction getMaxZoom() {\n var _a;\n\n return (_a = hostPlugin.settings.zoomToFitMaxLevel) !== null && _a !== void 0 ? _a : 1;\n}\nfunction isExcaliBrainView() {\n const excalidrawView = hostPlugin.activeExcalidrawView;\n\n if (!excalidrawView) {\n return false;\n }\n\n return excalidrawView.linksAlwaysOpenInANewPane && excalidrawView.allowFrameButtonsInViewMode;\n}\nfunction getExcalidrawContentEl() {\n const excalidrawView = hostPlugin.activeExcalidrawView;\n\n if (!excalidrawView) {\n return document.body;\n }\n\n return excalidrawView.contentEl;\n}\nfunction hideFreedrawPenmodeCursor() {\n return !hostPlugin.settings.penModeCrosshairVisible;\n}\nfunction getOpenAIDefaultVisionModel() {\n return hostPlugin.settings.openAIDefaultVisionModel;\n}\nfunction registerLocalFont(fontMetrics, uri) {\n const _register = _fonts__WEBPACK_IMPORTED_MODULE_2__.register.bind({\n registered: _fonts__WEBPACK_IMPORTED_MODULE_2__.Fonts.registered\n });\n\n _fonts_metadata__WEBPACK_IMPORTED_MODULE_3__.FONT_METADATA[_constants__WEBPACK_IMPORTED_MODULE_1__.FONT_FAMILY[\"Local Font\"]] = {\n metrics: fontMetrics.metrics,\n icon: _components_icons__WEBPACK_IMPORTED_MODULE_0__.FreedrawIcon\n };\n\n _register(\"Local Font\", fontMetrics, {\n uri\n });\n}\nfunction getFontFamilies() {\n const fontFamilies = new Set();\n\n for (const fontFaces of _fonts__WEBPACK_IMPORTED_MODULE_2__.Fonts.registered.values()) {\n if (fontFaces.metadata.local) {\n continue;\n }\n\n for (const font of fontFaces.fontFaces) {\n if (font.fontFace.family === \"Local Font\") {\n continue;\n }\n\n fontFamilies.add(font.fontFace.family);\n }\n }\n\n return Array.from(fontFamilies);\n}\nasync function registerFontsInCSS() {\n const styleId = \"ExcalidrawFonts\";\n let styleElement = document.getElementById(styleId);\n\n if (!styleElement) {\n styleElement = document.createElement(\"style\");\n styleElement.id = styleId;\n document.head.appendChild(styleElement);\n } else {\n styleElement.textContent = \"\";\n }\n\n let cssContent = \"\";\n\n for (const fontFaces of _fonts__WEBPACK_IMPORTED_MODULE_2__.Fonts.registered.values()) {\n if (fontFaces.metadata.local) {\n continue;\n }\n\n for (const font of fontFaces.fontFaces) {\n try {\n const content = await font.getContentLegacy();\n cssContent += `@font-face {font-family: ${font.fontFace.family}; src: url(${content});}\\n`;\n } catch (e) {\n console.error(`Skipped inlining font \"${font.toString()}\"`, e);\n }\n }\n }\n\n styleElement.textContent = cssContent;\n}\nasync function getCSSFontDefinition(fontFamily) {\n var _a;\n\n const fontFaces = (_a = _fonts__WEBPACK_IMPORTED_MODULE_2__.Fonts.registered.get(fontFamily)) === null || _a === void 0 ? void 0 : _a.fontFaces;\n\n if (!fontFaces) {\n return \"\";\n }\n\n const fontFace = fontFaces[0];\n\n if (!fontFace) {\n return \"\";\n }\n\n const content = await fontFace.getContentLegacy();\n return `@font-face {font-family: ${fontFaces[0].fontFace.family}; src: url(${content});}`;\n}\nasync function loadSceneFonts(elements) {\n const fontFamilies = _fonts__WEBPACK_IMPORTED_MODULE_2__.Fonts.getElementsFamilies(elements);\n await _fonts__WEBPACK_IMPORTED_MODULE_2__.Fonts.loadFontFaces(fontFamilies);\n}\nasync function fetchFontFromVault(url) {\n if (typeof url === \"string\" && !url.startsWith(\"data\") && url.endsWith(\".woff2\")) {\n const filename = decodeURIComponent(url.substring(url.lastIndexOf(\"/\") + 1));\n const arrayBuffer = hostPlugin.loadFontFromFile(filename);\n\n if (arrayBuffer) {\n return arrayBuffer;\n }\n }\n\n return;\n}\n\n//# sourceURL=webpack://ExcalidrawLib/./obsidianUtils.ts?");
3557
3557
 
3558
3558
  /***/ }),
3559
3559