From 71aef1764d57cec792970af89ac73770ded3883d Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 9 May 2023 17:08:38 +0100 Subject: [PATCH] Rework the assets package for strategy-specific imports (#1341) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The assets package now only exports esm-formatted .js files. There's one for each strategy - import-based, and meta.url-based. These are directly generated as .js and .d.ts files rather than generated as .ts and converted to js/dts through other means. As this package depends on esm-specific stuff to function, we don't publish a cjs version any more. ### Change Type - [ ] `patch` — Bug Fix - [ ] `minor` — New Feature - [x] `major` — Breaking Change - [ ] `dependencies` — Dependency Update (publishes a `patch` release, for devDependencies use `internal`) - [ ] `documentation` — Changes to the documentation only (will not publish a new version) - [ ] `tests` — Changes to any testing-related code only (will not publish a new version) - [ ] `internal` — Any other changes that don't affect the published package (will not publish a new version) ### Release Notes - [dev] If you're using the `@tldraw/assets` package, you need to update your code to `import { getAssetUrlsByImport } from '@tldraw/assets/imports'` instead of `import { getBundlerAssetUrls } from '@tldraw/assets` --- .eslintignore | 5 +- .eslintrc.js | 1 - .github/workflows/checks.yml | 6 +- apps/examples/src/index.tsx | 4 +- apps/vscode/editor/src/app.tsx | 5 +- packages/assets/imports.d.ts | 227 +++++++++ packages/assets/imports.js | 465 ++++++++++++++++++ packages/assets/package.json | 16 +- packages/assets/src/imports.ts | 442 ----------------- packages/assets/src/index.ts | 1 - packages/assets/src/urls.ts | 603 ----------------------- packages/assets/src/utils.ts | 23 - packages/assets/tsconfig.json | 2 +- packages/assets/urls.d.ts | 227 +++++++++ packages/assets/urls.js | 626 ++++++++++++++++++++++++ packages/tlschema/scripts/new-asset.js | 1 + packages/tlschema/scripts/new-record.js | 1 + packages/tlschema/tsconfig.json | 2 +- scripts/check-scripts.ts | 6 +- scripts/lib/file.ts | 11 +- scripts/refresh-assets.ts | 130 ++++- 21 files changed, 1688 insertions(+), 1116 deletions(-) create mode 100644 packages/assets/imports.d.ts create mode 100644 packages/assets/imports.js delete mode 100644 packages/assets/src/imports.ts delete mode 100644 packages/assets/src/index.ts delete mode 100644 packages/assets/src/urls.ts delete mode 100644 packages/assets/src/utils.ts create mode 100644 packages/assets/urls.d.ts create mode 100644 packages/assets/urls.js diff --git a/.eslintignore b/.eslintignore index d61341e10..44cebb406 100644 --- a/.eslintignore +++ b/.eslintignore @@ -14,4 +14,7 @@ **/api/* !**/pages/api/* **/*.json -**/lazy.config.ts \ No newline at end of file +**/lazy.config.ts +**/next.config.js +**/setupTests.js +**/setupJest.js diff --git a/.eslintrc.js b/.eslintrc.js index f137cec71..027c239d8 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -11,7 +11,6 @@ module.exports = { rootDir: ['apps/*/', 'packages/*/'], }, }, - ignorePatterns: ['**/*.js', '**/vscode-script-utils/*'], rules: { '@next/next/no-html-link-for-pages': 'off', 'react/jsx-key': 'off', diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index e11d183cc..692b62272 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -10,6 +10,10 @@ env: CI: 1 PRINT_GITHUB_ANNOTATIONS: 1 +defaults: + run: + shell: bash + jobs: build: name: 'Build and run checks' @@ -19,8 +23,6 @@ jobs: steps: - name: Check out code uses: actions/checkout@v3 - with: - fetch-depth: 0 - name: Setup Node.js environment uses: actions/setup-node@v3 diff --git a/apps/examples/src/index.tsx b/apps/examples/src/index.tsx index fa6865c4d..5147c196b 100644 --- a/apps/examples/src/index.tsx +++ b/apps/examples/src/index.tsx @@ -1,4 +1,4 @@ -import { getBundlerAssetUrls } from '@tldraw/assets/src/urls' +import { getAssetUrlsByMetaUrl } from '@tldraw/assets/urls' import { DefaultErrorFallback, ErrorBoundary, @@ -22,7 +22,7 @@ import HideUiExample from './9-hide-ui/HideUiExample' // we use secret internal `setDefaultAssetUrls` functions to set these at the // top-level so assets don't need to be passed down in every single example. -const assetUrls = getBundlerAssetUrls() +const assetUrls = getAssetUrlsByMetaUrl() setDefaultEditorAssetUrls(assetUrls) setDefaultUiAssetUrls(assetUrls) diff --git a/apps/vscode/editor/src/app.tsx b/apps/vscode/editor/src/app.tsx index 824b22e0d..feccc27fa 100644 --- a/apps/vscode/editor/src/app.tsx +++ b/apps/vscode/editor/src/app.tsx @@ -1,4 +1,3 @@ -import { getBundlerAssetUrls } from '@tldraw/assets' import { App, Canvas, @@ -13,6 +12,8 @@ import '@tldraw/editor/editor.css' import { TAB_ID, useLocalSyncClient } from '@tldraw/tlsync-client' import { ContextMenu, MenuSchema, TldrawUi } from '@tldraw/ui' // eslint-disable-next-line import/no-internal-modules +import { getAssetUrlsByImport } from '@tldraw/assets/imports' +// eslint-disable-next-line import/no-internal-modules import '@tldraw/ui/ui.css' import { useEffect, useMemo, useState } from 'react' import { VscodeMessage } from '../../messages' @@ -135,7 +136,7 @@ function TldrawInner({ uri, assetSrc, userId, isDarkMode, fileContents }: TLDraw userId, }) - const assetUrls = useMemo(() => getBundlerAssetUrls({ baseUrl: assetSrc }), [assetSrc]) + const assetUrls = useMemo(() => getAssetUrlsByImport({ baseUrl: assetSrc }), [assetSrc]) return ( string) + +export function getAssetUrlsByImport(opts?: AssetUrlOptions): { + fonts: { + monospace: string + sansSerif: string + serif: string + draw: string + } + icons: { + 'align-bottom-center': string + 'align-bottom-left': string + 'align-bottom-right': string + 'align-bottom': string + 'align-center-center': string + 'align-center-horizontal': string + 'align-center-left': string + 'align-center-right': string + 'align-center-vertical': string + 'align-left': string + 'align-right': string + 'align-top-center': string + 'align-top-left': string + 'align-top-right': string + 'align-top': string + 'arrow-left': string + 'arrowhead-arrow': string + 'arrowhead-bar': string + 'arrowhead-diamond': string + 'arrowhead-dot': string + 'arrowhead-none': string + 'arrowhead-square': string + 'arrowhead-triangle-inverted': string + 'arrowhead-triangle': string + 'aspect-ratio': string + avatar: string + blob: string + 'bring-forward': string + 'bring-to-front': string + check: string + 'checkbox-checked': string + 'checkbox-empty': string + 'chevron-down': string + 'chevron-left': string + 'chevron-right': string + 'chevron-up': string + 'chevrons-ne': string + 'chevrons-sw': string + 'clipboard-copy': string + code: string + collab: string + color: string + comment: string + 'cross-2': string + cross: string + 'dash-dashed': string + 'dash-dotted': string + 'dash-draw': string + 'dash-solid': string + discord: string + 'distribute-horizontal': string + 'distribute-vertical': string + dot: string + 'dots-horizontal': string + 'dots-vertical': string + 'drag-handle-dots': string + duplicate: string + edit: string + 'external-link': string + file: string + 'fill-none': string + 'fill-pattern': string + 'fill-semi': string + 'fill-solid': string + follow: string + following: string + 'font-draw': string + 'font-mono': string + 'font-sans': string + 'font-serif': string + 'geo-arrow-down': string + 'geo-arrow-left': string + 'geo-arrow-right': string + 'geo-arrow-up': string + 'geo-check-box': string + 'geo-diamond': string + 'geo-ellipse': string + 'geo-hexagon': string + 'geo-octagon': string + 'geo-oval': string + 'geo-pentagon': string + 'geo-rectangle': string + 'geo-rhombus-2': string + 'geo-rhombus': string + 'geo-star': string + 'geo-trapezoid': string + 'geo-triangle': string + 'geo-x-box': string + github: string + group: string + hidden: string + image: string + 'info-circle': string + leading: string + link: string + 'lock-small': string + lock: string + menu: string + minus: string + mixed: string + pack: string + page: string + plus: string + 'question-mark-circle': string + 'question-mark': string + redo: string + 'reset-zoom': string + 'rotate-ccw': string + 'rotate-cw': string + ruler: string + search: string + 'send-backward': string + 'send-to-back': string + 'settings-horizontal': string + 'settings-vertical-1': string + 'settings-vertical': string + 'share-1': string + 'share-2': string + 'size-extra-large': string + 'size-large': string + 'size-medium': string + 'size-small': string + 'spline-cubic': string + 'spline-line': string + 'stack-horizontal': string + 'stack-vertical': string + 'stretch-horizontal': string + 'stretch-vertical': string + 'text-align-center': string + 'text-align-justify': string + 'text-align-left': string + 'text-align-right': string + 'tool-arrow': string + 'tool-embed': string + 'tool-eraser': string + 'tool-frame': string + 'tool-hand': string + 'tool-highlighter': string + 'tool-line': string + 'tool-media': string + 'tool-note': string + 'tool-pencil': string + 'tool-pointer': string + 'tool-text': string + trash: string + 'triangle-down': string + 'triangle-up': string + twitter: string + undo: string + ungroup: string + 'unlock-small': string + unlock: string + visible: string + 'warning-triangle': string + 'zoom-in': string + 'zoom-out': string + } + translations: { + ar: string + ca: string + da: string + de: string + en: string + es: string + fa: string + fi: string + fr: string + gl: string + he: string + 'hi-in': string + hu: string + it: string + ja: string + 'ko-kr': string + ku: string + languages: string + main: string + my: string + ne: string + no: string + pl: string + 'pt-br': string + 'pt-pt': string + ro: string + ru: string + sv: string + te: string + th: string + tr: string + uk: string + vi: string + 'zh-cn': string + 'zh-tw': string + } + embedIcons: { + codepen: string + codesandbox: string + excalidraw: string + felt: string + figma: string + github_gist: string + google_calendar: string + google_maps: string + google_slides: string + observable: string + replit: string + scratch: string + spotify: string + tldraw: string + vimeo: string + youtube: string + } +} diff --git a/packages/assets/imports.js b/packages/assets/imports.js new file mode 100644 index 000000000..907ad4003 --- /dev/null +++ b/packages/assets/imports.js @@ -0,0 +1,465 @@ +// This file is automatically generated by scripts/refresh-assets.ts. +// Do not edit manually. + +// eslint-disable-next-line @typescript-eslint/triple-slash-reference +/// +import embedIconsCodepen from './embed-icons/codepen.png' +import embedIconsCodesandbox from './embed-icons/codesandbox.png' +import embedIconsExcalidraw from './embed-icons/excalidraw.png' +import embedIconsFelt from './embed-icons/felt.png' +import embedIconsFigma from './embed-icons/figma.png' +import embedIconsGithubGist from './embed-icons/github_gist.png' +import embedIconsGoogleCalendar from './embed-icons/google_calendar.png' +import embedIconsGoogleMaps from './embed-icons/google_maps.png' +import embedIconsGoogleSlides from './embed-icons/google_slides.png' +import embedIconsObservable from './embed-icons/observable.png' +import embedIconsReplit from './embed-icons/replit.png' +import embedIconsScratch from './embed-icons/scratch.png' +import embedIconsSpotify from './embed-icons/spotify.png' +import embedIconsTldraw from './embed-icons/tldraw.png' +import embedIconsVimeo from './embed-icons/vimeo.png' +import embedIconsYoutube from './embed-icons/youtube.png' +import fontsMonospace from './fonts/IBMPlexMono-Medium.woff2' +import fontsSansSerif from './fonts/IBMPlexSans-Medium.woff2' +import fontsSerif from './fonts/IBMPlexSerif-Medium.woff2' +import fontsDraw from './fonts/Shantell_Sans-Normal-SemiBold.woff2' +import iconsAlignBottomCenter from './icons/icon/align-bottom-center.svg' +import iconsAlignBottomLeft from './icons/icon/align-bottom-left.svg' +import iconsAlignBottomRight from './icons/icon/align-bottom-right.svg' +import iconsAlignBottom from './icons/icon/align-bottom.svg' +import iconsAlignCenterCenter from './icons/icon/align-center-center.svg' +import iconsAlignCenterHorizontal from './icons/icon/align-center-horizontal.svg' +import iconsAlignCenterLeft from './icons/icon/align-center-left.svg' +import iconsAlignCenterRight from './icons/icon/align-center-right.svg' +import iconsAlignCenterVertical from './icons/icon/align-center-vertical.svg' +import iconsAlignLeft from './icons/icon/align-left.svg' +import iconsAlignRight from './icons/icon/align-right.svg' +import iconsAlignTopCenter from './icons/icon/align-top-center.svg' +import iconsAlignTopLeft from './icons/icon/align-top-left.svg' +import iconsAlignTopRight from './icons/icon/align-top-right.svg' +import iconsAlignTop from './icons/icon/align-top.svg' +import iconsArrowLeft from './icons/icon/arrow-left.svg' +import iconsArrowheadArrow from './icons/icon/arrowhead-arrow.svg' +import iconsArrowheadBar from './icons/icon/arrowhead-bar.svg' +import iconsArrowheadDiamond from './icons/icon/arrowhead-diamond.svg' +import iconsArrowheadDot from './icons/icon/arrowhead-dot.svg' +import iconsArrowheadNone from './icons/icon/arrowhead-none.svg' +import iconsArrowheadSquare from './icons/icon/arrowhead-square.svg' +import iconsArrowheadTriangleInverted from './icons/icon/arrowhead-triangle-inverted.svg' +import iconsArrowheadTriangle from './icons/icon/arrowhead-triangle.svg' +import iconsAspectRatio from './icons/icon/aspect-ratio.svg' +import iconsAvatar from './icons/icon/avatar.svg' +import iconsBlob from './icons/icon/blob.svg' +import iconsBringForward from './icons/icon/bring-forward.svg' +import iconsBringToFront from './icons/icon/bring-to-front.svg' +import iconsCheck from './icons/icon/check.svg' +import iconsCheckboxChecked from './icons/icon/checkbox-checked.svg' +import iconsCheckboxEmpty from './icons/icon/checkbox-empty.svg' +import iconsChevronDown from './icons/icon/chevron-down.svg' +import iconsChevronLeft from './icons/icon/chevron-left.svg' +import iconsChevronRight from './icons/icon/chevron-right.svg' +import iconsChevronUp from './icons/icon/chevron-up.svg' +import iconsChevronsNe from './icons/icon/chevrons-ne.svg' +import iconsChevronsSw from './icons/icon/chevrons-sw.svg' +import iconsClipboardCopy from './icons/icon/clipboard-copy.svg' +import iconsCode from './icons/icon/code.svg' +import iconsCollab from './icons/icon/collab.svg' +import iconsColor from './icons/icon/color.svg' +import iconsComment from './icons/icon/comment.svg' +import iconsCross2 from './icons/icon/cross-2.svg' +import iconsCross from './icons/icon/cross.svg' +import iconsDashDashed from './icons/icon/dash-dashed.svg' +import iconsDashDotted from './icons/icon/dash-dotted.svg' +import iconsDashDraw from './icons/icon/dash-draw.svg' +import iconsDashSolid from './icons/icon/dash-solid.svg' +import iconsDiscord from './icons/icon/discord.svg' +import iconsDistributeHorizontal from './icons/icon/distribute-horizontal.svg' +import iconsDistributeVertical from './icons/icon/distribute-vertical.svg' +import iconsDot from './icons/icon/dot.svg' +import iconsDotsHorizontal from './icons/icon/dots-horizontal.svg' +import iconsDotsVertical from './icons/icon/dots-vertical.svg' +import iconsDragHandleDots from './icons/icon/drag-handle-dots.svg' +import iconsDuplicate from './icons/icon/duplicate.svg' +import iconsEdit from './icons/icon/edit.svg' +import iconsExternalLink from './icons/icon/external-link.svg' +import iconsFile from './icons/icon/file.svg' +import iconsFillNone from './icons/icon/fill-none.svg' +import iconsFillPattern from './icons/icon/fill-pattern.svg' +import iconsFillSemi from './icons/icon/fill-semi.svg' +import iconsFillSolid from './icons/icon/fill-solid.svg' +import iconsFollow from './icons/icon/follow.svg' +import iconsFollowing from './icons/icon/following.svg' +import iconsFontDraw from './icons/icon/font-draw.svg' +import iconsFontMono from './icons/icon/font-mono.svg' +import iconsFontSans from './icons/icon/font-sans.svg' +import iconsFontSerif from './icons/icon/font-serif.svg' +import iconsGeoArrowDown from './icons/icon/geo-arrow-down.svg' +import iconsGeoArrowLeft from './icons/icon/geo-arrow-left.svg' +import iconsGeoArrowRight from './icons/icon/geo-arrow-right.svg' +import iconsGeoArrowUp from './icons/icon/geo-arrow-up.svg' +import iconsGeoCheckBox from './icons/icon/geo-check-box.svg' +import iconsGeoDiamond from './icons/icon/geo-diamond.svg' +import iconsGeoEllipse from './icons/icon/geo-ellipse.svg' +import iconsGeoHexagon from './icons/icon/geo-hexagon.svg' +import iconsGeoOctagon from './icons/icon/geo-octagon.svg' +import iconsGeoOval from './icons/icon/geo-oval.svg' +import iconsGeoPentagon from './icons/icon/geo-pentagon.svg' +import iconsGeoRectangle from './icons/icon/geo-rectangle.svg' +import iconsGeoRhombus2 from './icons/icon/geo-rhombus-2.svg' +import iconsGeoRhombus from './icons/icon/geo-rhombus.svg' +import iconsGeoStar from './icons/icon/geo-star.svg' +import iconsGeoTrapezoid from './icons/icon/geo-trapezoid.svg' +import iconsGeoTriangle from './icons/icon/geo-triangle.svg' +import iconsGeoXBox from './icons/icon/geo-x-box.svg' +import iconsGithub from './icons/icon/github.svg' +import iconsGroup from './icons/icon/group.svg' +import iconsHidden from './icons/icon/hidden.svg' +import iconsImage from './icons/icon/image.svg' +import iconsInfoCircle from './icons/icon/info-circle.svg' +import iconsLeading from './icons/icon/leading.svg' +import iconsLink from './icons/icon/link.svg' +import iconsLockSmall from './icons/icon/lock-small.svg' +import iconsLock from './icons/icon/lock.svg' +import iconsMenu from './icons/icon/menu.svg' +import iconsMinus from './icons/icon/minus.svg' +import iconsMixed from './icons/icon/mixed.svg' +import iconsPack from './icons/icon/pack.svg' +import iconsPage from './icons/icon/page.svg' +import iconsPlus from './icons/icon/plus.svg' +import iconsQuestionMarkCircle from './icons/icon/question-mark-circle.svg' +import iconsQuestionMark from './icons/icon/question-mark.svg' +import iconsRedo from './icons/icon/redo.svg' +import iconsResetZoom from './icons/icon/reset-zoom.svg' +import iconsRotateCcw from './icons/icon/rotate-ccw.svg' +import iconsRotateCw from './icons/icon/rotate-cw.svg' +import iconsRuler from './icons/icon/ruler.svg' +import iconsSearch from './icons/icon/search.svg' +import iconsSendBackward from './icons/icon/send-backward.svg' +import iconsSendToBack from './icons/icon/send-to-back.svg' +import iconsSettingsHorizontal from './icons/icon/settings-horizontal.svg' +import iconsSettingsVertical1 from './icons/icon/settings-vertical-1.svg' +import iconsSettingsVertical from './icons/icon/settings-vertical.svg' +import iconsShare1 from './icons/icon/share-1.svg' +import iconsShare2 from './icons/icon/share-2.svg' +import iconsSizeExtraLarge from './icons/icon/size-extra-large.svg' +import iconsSizeLarge from './icons/icon/size-large.svg' +import iconsSizeMedium from './icons/icon/size-medium.svg' +import iconsSizeSmall from './icons/icon/size-small.svg' +import iconsSplineCubic from './icons/icon/spline-cubic.svg' +import iconsSplineLine from './icons/icon/spline-line.svg' +import iconsStackHorizontal from './icons/icon/stack-horizontal.svg' +import iconsStackVertical from './icons/icon/stack-vertical.svg' +import iconsStretchHorizontal from './icons/icon/stretch-horizontal.svg' +import iconsStretchVertical from './icons/icon/stretch-vertical.svg' +import iconsTextAlignCenter from './icons/icon/text-align-center.svg' +import iconsTextAlignJustify from './icons/icon/text-align-justify.svg' +import iconsTextAlignLeft from './icons/icon/text-align-left.svg' +import iconsTextAlignRight from './icons/icon/text-align-right.svg' +import iconsToolArrow from './icons/icon/tool-arrow.svg' +import iconsToolEmbed from './icons/icon/tool-embed.svg' +import iconsToolEraser from './icons/icon/tool-eraser.svg' +import iconsToolFrame from './icons/icon/tool-frame.svg' +import iconsToolHand from './icons/icon/tool-hand.svg' +import iconsToolHighlighter from './icons/icon/tool-highlighter.svg' +import iconsToolLine from './icons/icon/tool-line.svg' +import iconsToolMedia from './icons/icon/tool-media.svg' +import iconsToolNote from './icons/icon/tool-note.svg' +import iconsToolPencil from './icons/icon/tool-pencil.svg' +import iconsToolPointer from './icons/icon/tool-pointer.svg' +import iconsToolText from './icons/icon/tool-text.svg' +import iconsTrash from './icons/icon/trash.svg' +import iconsTriangleDown from './icons/icon/triangle-down.svg' +import iconsTriangleUp from './icons/icon/triangle-up.svg' +import iconsTwitter from './icons/icon/twitter.svg' +import iconsUndo from './icons/icon/undo.svg' +import iconsUngroup from './icons/icon/ungroup.svg' +import iconsUnlockSmall from './icons/icon/unlock-small.svg' +import iconsUnlock from './icons/icon/unlock.svg' +import iconsVisible from './icons/icon/visible.svg' +import iconsWarningTriangle from './icons/icon/warning-triangle.svg' +import iconsZoomIn from './icons/icon/zoom-in.svg' +import iconsZoomOut from './icons/icon/zoom-out.svg' +import translationsAr from './translations/ar.json' +import translationsCa from './translations/ca.json' +import translationsDa from './translations/da.json' +import translationsDe from './translations/de.json' +import translationsEn from './translations/en.json' +import translationsEs from './translations/es.json' +import translationsFa from './translations/fa.json' +import translationsFi from './translations/fi.json' +import translationsFr from './translations/fr.json' +import translationsGl from './translations/gl.json' +import translationsHe from './translations/he.json' +import translationsHiIn from './translations/hi-in.json' +import translationsHu from './translations/hu.json' +import translationsIt from './translations/it.json' +import translationsJa from './translations/ja.json' +import translationsKoKr from './translations/ko-kr.json' +import translationsKu from './translations/ku.json' +import translationsLanguages from './translations/languages.json' +import translationsMain from './translations/main.json' +import translationsMy from './translations/my.json' +import translationsNe from './translations/ne.json' +import translationsNo from './translations/no.json' +import translationsPl from './translations/pl.json' +import translationsPtBr from './translations/pt-br.json' +import translationsPtPt from './translations/pt-pt.json' +import translationsRo from './translations/ro.json' +import translationsRu from './translations/ru.json' +import translationsSv from './translations/sv.json' +import translationsTe from './translations/te.json' +import translationsTh from './translations/th.json' +import translationsTr from './translations/tr.json' +import translationsUk from './translations/uk.json' +import translationsVi from './translations/vi.json' +import translationsZhCn from './translations/zh-cn.json' +import translationsZhTw from './translations/zh-tw.json' + +/** @typedef {string | { src: string }} AssetUrl */ +/** @typedef {{ baseUrl?: string } | ((assetUrl: string) => string)} AssetUrlOptions */ + +/** + * @param {AssetUrl} assetUrl + * @param {AssetUrlOptions} [format] + * @returns {string} + */ +function formatAssetUrl(assetUrl, format = {}) { + const assetUrlString = typeof assetUrl === 'string' ? assetUrl : assetUrl.src + + if (typeof format === 'function') return format(assetUrlString) + + const { baseUrl = '' } = format + + if (assetUrlString.startsWith('data:')) return assetUrlString + if (assetUrlString.match(/^https?:\/\//)) return assetUrlString + + return `${baseUrl.replace(/\/$/, '')}/${assetUrlString.replace(/^\.?\//, '')}` +} + +/** + * @param {AssetUrlOptions} [opts] + * @public + */ +export function getAssetUrlsByImport(opts) { + return { + fonts: { + monospace: formatAssetUrl(fontsMonospace, opts), + sansSerif: formatAssetUrl(fontsSansSerif, opts), + serif: formatAssetUrl(fontsSerif, opts), + draw: formatAssetUrl(fontsDraw, opts), + }, + icons: { + 'align-bottom-center': formatAssetUrl(iconsAlignBottomCenter, opts), + 'align-bottom-left': formatAssetUrl(iconsAlignBottomLeft, opts), + 'align-bottom-right': formatAssetUrl(iconsAlignBottomRight, opts), + 'align-bottom': formatAssetUrl(iconsAlignBottom, opts), + 'align-center-center': formatAssetUrl(iconsAlignCenterCenter, opts), + 'align-center-horizontal': formatAssetUrl(iconsAlignCenterHorizontal, opts), + 'align-center-left': formatAssetUrl(iconsAlignCenterLeft, opts), + 'align-center-right': formatAssetUrl(iconsAlignCenterRight, opts), + 'align-center-vertical': formatAssetUrl(iconsAlignCenterVertical, opts), + 'align-left': formatAssetUrl(iconsAlignLeft, opts), + 'align-right': formatAssetUrl(iconsAlignRight, opts), + 'align-top-center': formatAssetUrl(iconsAlignTopCenter, opts), + 'align-top-left': formatAssetUrl(iconsAlignTopLeft, opts), + 'align-top-right': formatAssetUrl(iconsAlignTopRight, opts), + 'align-top': formatAssetUrl(iconsAlignTop, opts), + 'arrow-left': formatAssetUrl(iconsArrowLeft, opts), + 'arrowhead-arrow': formatAssetUrl(iconsArrowheadArrow, opts), + 'arrowhead-bar': formatAssetUrl(iconsArrowheadBar, opts), + 'arrowhead-diamond': formatAssetUrl(iconsArrowheadDiamond, opts), + 'arrowhead-dot': formatAssetUrl(iconsArrowheadDot, opts), + 'arrowhead-none': formatAssetUrl(iconsArrowheadNone, opts), + 'arrowhead-square': formatAssetUrl(iconsArrowheadSquare, opts), + 'arrowhead-triangle-inverted': formatAssetUrl(iconsArrowheadTriangleInverted, opts), + 'arrowhead-triangle': formatAssetUrl(iconsArrowheadTriangle, opts), + 'aspect-ratio': formatAssetUrl(iconsAspectRatio, opts), + avatar: formatAssetUrl(iconsAvatar, opts), + blob: formatAssetUrl(iconsBlob, opts), + 'bring-forward': formatAssetUrl(iconsBringForward, opts), + 'bring-to-front': formatAssetUrl(iconsBringToFront, opts), + check: formatAssetUrl(iconsCheck, opts), + 'checkbox-checked': formatAssetUrl(iconsCheckboxChecked, opts), + 'checkbox-empty': formatAssetUrl(iconsCheckboxEmpty, opts), + 'chevron-down': formatAssetUrl(iconsChevronDown, opts), + 'chevron-left': formatAssetUrl(iconsChevronLeft, opts), + 'chevron-right': formatAssetUrl(iconsChevronRight, opts), + 'chevron-up': formatAssetUrl(iconsChevronUp, opts), + 'chevrons-ne': formatAssetUrl(iconsChevronsNe, opts), + 'chevrons-sw': formatAssetUrl(iconsChevronsSw, opts), + 'clipboard-copy': formatAssetUrl(iconsClipboardCopy, opts), + code: formatAssetUrl(iconsCode, opts), + collab: formatAssetUrl(iconsCollab, opts), + color: formatAssetUrl(iconsColor, opts), + comment: formatAssetUrl(iconsComment, opts), + 'cross-2': formatAssetUrl(iconsCross2, opts), + cross: formatAssetUrl(iconsCross, opts), + 'dash-dashed': formatAssetUrl(iconsDashDashed, opts), + 'dash-dotted': formatAssetUrl(iconsDashDotted, opts), + 'dash-draw': formatAssetUrl(iconsDashDraw, opts), + 'dash-solid': formatAssetUrl(iconsDashSolid, opts), + discord: formatAssetUrl(iconsDiscord, opts), + 'distribute-horizontal': formatAssetUrl(iconsDistributeHorizontal, opts), + 'distribute-vertical': formatAssetUrl(iconsDistributeVertical, opts), + dot: formatAssetUrl(iconsDot, opts), + 'dots-horizontal': formatAssetUrl(iconsDotsHorizontal, opts), + 'dots-vertical': formatAssetUrl(iconsDotsVertical, opts), + 'drag-handle-dots': formatAssetUrl(iconsDragHandleDots, opts), + duplicate: formatAssetUrl(iconsDuplicate, opts), + edit: formatAssetUrl(iconsEdit, opts), + 'external-link': formatAssetUrl(iconsExternalLink, opts), + file: formatAssetUrl(iconsFile, opts), + 'fill-none': formatAssetUrl(iconsFillNone, opts), + 'fill-pattern': formatAssetUrl(iconsFillPattern, opts), + 'fill-semi': formatAssetUrl(iconsFillSemi, opts), + 'fill-solid': formatAssetUrl(iconsFillSolid, opts), + follow: formatAssetUrl(iconsFollow, opts), + following: formatAssetUrl(iconsFollowing, opts), + 'font-draw': formatAssetUrl(iconsFontDraw, opts), + 'font-mono': formatAssetUrl(iconsFontMono, opts), + 'font-sans': formatAssetUrl(iconsFontSans, opts), + 'font-serif': formatAssetUrl(iconsFontSerif, opts), + 'geo-arrow-down': formatAssetUrl(iconsGeoArrowDown, opts), + 'geo-arrow-left': formatAssetUrl(iconsGeoArrowLeft, opts), + 'geo-arrow-right': formatAssetUrl(iconsGeoArrowRight, opts), + 'geo-arrow-up': formatAssetUrl(iconsGeoArrowUp, opts), + 'geo-check-box': formatAssetUrl(iconsGeoCheckBox, opts), + 'geo-diamond': formatAssetUrl(iconsGeoDiamond, opts), + 'geo-ellipse': formatAssetUrl(iconsGeoEllipse, opts), + 'geo-hexagon': formatAssetUrl(iconsGeoHexagon, opts), + 'geo-octagon': formatAssetUrl(iconsGeoOctagon, opts), + 'geo-oval': formatAssetUrl(iconsGeoOval, opts), + 'geo-pentagon': formatAssetUrl(iconsGeoPentagon, opts), + 'geo-rectangle': formatAssetUrl(iconsGeoRectangle, opts), + 'geo-rhombus-2': formatAssetUrl(iconsGeoRhombus2, opts), + 'geo-rhombus': formatAssetUrl(iconsGeoRhombus, opts), + 'geo-star': formatAssetUrl(iconsGeoStar, opts), + 'geo-trapezoid': formatAssetUrl(iconsGeoTrapezoid, opts), + 'geo-triangle': formatAssetUrl(iconsGeoTriangle, opts), + 'geo-x-box': formatAssetUrl(iconsGeoXBox, opts), + github: formatAssetUrl(iconsGithub, opts), + group: formatAssetUrl(iconsGroup, opts), + hidden: formatAssetUrl(iconsHidden, opts), + image: formatAssetUrl(iconsImage, opts), + 'info-circle': formatAssetUrl(iconsInfoCircle, opts), + leading: formatAssetUrl(iconsLeading, opts), + link: formatAssetUrl(iconsLink, opts), + 'lock-small': formatAssetUrl(iconsLockSmall, opts), + lock: formatAssetUrl(iconsLock, opts), + menu: formatAssetUrl(iconsMenu, opts), + minus: formatAssetUrl(iconsMinus, opts), + mixed: formatAssetUrl(iconsMixed, opts), + pack: formatAssetUrl(iconsPack, opts), + page: formatAssetUrl(iconsPage, opts), + plus: formatAssetUrl(iconsPlus, opts), + 'question-mark-circle': formatAssetUrl(iconsQuestionMarkCircle, opts), + 'question-mark': formatAssetUrl(iconsQuestionMark, opts), + redo: formatAssetUrl(iconsRedo, opts), + 'reset-zoom': formatAssetUrl(iconsResetZoom, opts), + 'rotate-ccw': formatAssetUrl(iconsRotateCcw, opts), + 'rotate-cw': formatAssetUrl(iconsRotateCw, opts), + ruler: formatAssetUrl(iconsRuler, opts), + search: formatAssetUrl(iconsSearch, opts), + 'send-backward': formatAssetUrl(iconsSendBackward, opts), + 'send-to-back': formatAssetUrl(iconsSendToBack, opts), + 'settings-horizontal': formatAssetUrl(iconsSettingsHorizontal, opts), + 'settings-vertical-1': formatAssetUrl(iconsSettingsVertical1, opts), + 'settings-vertical': formatAssetUrl(iconsSettingsVertical, opts), + 'share-1': formatAssetUrl(iconsShare1, opts), + 'share-2': formatAssetUrl(iconsShare2, opts), + 'size-extra-large': formatAssetUrl(iconsSizeExtraLarge, opts), + 'size-large': formatAssetUrl(iconsSizeLarge, opts), + 'size-medium': formatAssetUrl(iconsSizeMedium, opts), + 'size-small': formatAssetUrl(iconsSizeSmall, opts), + 'spline-cubic': formatAssetUrl(iconsSplineCubic, opts), + 'spline-line': formatAssetUrl(iconsSplineLine, opts), + 'stack-horizontal': formatAssetUrl(iconsStackHorizontal, opts), + 'stack-vertical': formatAssetUrl(iconsStackVertical, opts), + 'stretch-horizontal': formatAssetUrl(iconsStretchHorizontal, opts), + 'stretch-vertical': formatAssetUrl(iconsStretchVertical, opts), + 'text-align-center': formatAssetUrl(iconsTextAlignCenter, opts), + 'text-align-justify': formatAssetUrl(iconsTextAlignJustify, opts), + 'text-align-left': formatAssetUrl(iconsTextAlignLeft, opts), + 'text-align-right': formatAssetUrl(iconsTextAlignRight, opts), + 'tool-arrow': formatAssetUrl(iconsToolArrow, opts), + 'tool-embed': formatAssetUrl(iconsToolEmbed, opts), + 'tool-eraser': formatAssetUrl(iconsToolEraser, opts), + 'tool-frame': formatAssetUrl(iconsToolFrame, opts), + 'tool-hand': formatAssetUrl(iconsToolHand, opts), + 'tool-highlighter': formatAssetUrl(iconsToolHighlighter, opts), + 'tool-line': formatAssetUrl(iconsToolLine, opts), + 'tool-media': formatAssetUrl(iconsToolMedia, opts), + 'tool-note': formatAssetUrl(iconsToolNote, opts), + 'tool-pencil': formatAssetUrl(iconsToolPencil, opts), + 'tool-pointer': formatAssetUrl(iconsToolPointer, opts), + 'tool-text': formatAssetUrl(iconsToolText, opts), + trash: formatAssetUrl(iconsTrash, opts), + 'triangle-down': formatAssetUrl(iconsTriangleDown, opts), + 'triangle-up': formatAssetUrl(iconsTriangleUp, opts), + twitter: formatAssetUrl(iconsTwitter, opts), + undo: formatAssetUrl(iconsUndo, opts), + ungroup: formatAssetUrl(iconsUngroup, opts), + 'unlock-small': formatAssetUrl(iconsUnlockSmall, opts), + unlock: formatAssetUrl(iconsUnlock, opts), + visible: formatAssetUrl(iconsVisible, opts), + 'warning-triangle': formatAssetUrl(iconsWarningTriangle, opts), + 'zoom-in': formatAssetUrl(iconsZoomIn, opts), + 'zoom-out': formatAssetUrl(iconsZoomOut, opts), + }, + translations: { + ar: formatAssetUrl(translationsAr, opts), + ca: formatAssetUrl(translationsCa, opts), + da: formatAssetUrl(translationsDa, opts), + de: formatAssetUrl(translationsDe, opts), + en: formatAssetUrl(translationsEn, opts), + es: formatAssetUrl(translationsEs, opts), + fa: formatAssetUrl(translationsFa, opts), + fi: formatAssetUrl(translationsFi, opts), + fr: formatAssetUrl(translationsFr, opts), + gl: formatAssetUrl(translationsGl, opts), + he: formatAssetUrl(translationsHe, opts), + 'hi-in': formatAssetUrl(translationsHiIn, opts), + hu: formatAssetUrl(translationsHu, opts), + it: formatAssetUrl(translationsIt, opts), + ja: formatAssetUrl(translationsJa, opts), + 'ko-kr': formatAssetUrl(translationsKoKr, opts), + ku: formatAssetUrl(translationsKu, opts), + languages: formatAssetUrl(translationsLanguages, opts), + main: formatAssetUrl(translationsMain, opts), + my: formatAssetUrl(translationsMy, opts), + ne: formatAssetUrl(translationsNe, opts), + no: formatAssetUrl(translationsNo, opts), + pl: formatAssetUrl(translationsPl, opts), + 'pt-br': formatAssetUrl(translationsPtBr, opts), + 'pt-pt': formatAssetUrl(translationsPtPt, opts), + ro: formatAssetUrl(translationsRo, opts), + ru: formatAssetUrl(translationsRu, opts), + sv: formatAssetUrl(translationsSv, opts), + te: formatAssetUrl(translationsTe, opts), + th: formatAssetUrl(translationsTh, opts), + tr: formatAssetUrl(translationsTr, opts), + uk: formatAssetUrl(translationsUk, opts), + vi: formatAssetUrl(translationsVi, opts), + 'zh-cn': formatAssetUrl(translationsZhCn, opts), + 'zh-tw': formatAssetUrl(translationsZhTw, opts), + }, + embedIcons: { + codepen: formatAssetUrl(embedIconsCodepen, opts), + codesandbox: formatAssetUrl(embedIconsCodesandbox, opts), + excalidraw: formatAssetUrl(embedIconsExcalidraw, opts), + felt: formatAssetUrl(embedIconsFelt, opts), + figma: formatAssetUrl(embedIconsFigma, opts), + github_gist: formatAssetUrl(embedIconsGithubGist, opts), + google_calendar: formatAssetUrl(embedIconsGoogleCalendar, opts), + google_maps: formatAssetUrl(embedIconsGoogleMaps, opts), + google_slides: formatAssetUrl(embedIconsGoogleSlides, opts), + observable: formatAssetUrl(embedIconsObservable, opts), + replit: formatAssetUrl(embedIconsReplit, opts), + scratch: formatAssetUrl(embedIconsScratch, opts), + spotify: formatAssetUrl(embedIconsSpotify, opts), + tldraw: formatAssetUrl(embedIconsTldraw, opts), + vimeo: formatAssetUrl(embedIconsVimeo, opts), + youtube: formatAssetUrl(embedIconsYoutube, opts), + }, + } +} diff --git a/packages/assets/package.json b/packages/assets/package.json index 7b99b5a71..0ee7eb2b5 100644 --- a/packages/assets/package.json +++ b/packages/assets/package.json @@ -24,23 +24,17 @@ "canvas", "infinite" ], - "/* NOTE */": "These `main` and `types` fields are rewritten by the build script. They are not the actual values we publish", - "main": "./src/index.ts", - "types": "./.tsbuild/index.d.ts", - "/* GOTCHA */": "files will include ./dist and index.d.ts by default, add any others you want to include in here", "files": [ "embed-icons", "icons", "fonts", - "translations" + "translations", + "imports.js", + "imports.d.ts", + "urls.js", + "urls.d.ts" ], "scripts": { - "test": "lazy inherit --passWithNoTests", - "test-coverage": "lazy inherit --passWithNoTests", - "build-package": "yarn run -T tsx ../../scripts/build-package.ts", - "build-api": "yarn run -T tsx ../../scripts/build-api.ts", - "prepack": "yarn run -T tsx ../../scripts/prepack.ts", - "postpack": "../../scripts/postpack.sh", "pack-tarball": "yarn pack", "lint": "yarn run -T tsx ../../scripts/lint.ts" }, diff --git a/packages/assets/src/imports.ts b/packages/assets/src/imports.ts deleted file mode 100644 index f19013725..000000000 --- a/packages/assets/src/imports.ts +++ /dev/null @@ -1,442 +0,0 @@ -// This file is automatically generated by scripts/refresh-assets.ts. -// Do not edit manually. - -// eslint-disable-next-line @typescript-eslint/triple-slash-reference -/// -import embedIconsCodepen from '../embed-icons/codepen.png' -import embedIconsCodesandbox from '../embed-icons/codesandbox.png' -import embedIconsExcalidraw from '../embed-icons/excalidraw.png' -import embedIconsFelt from '../embed-icons/felt.png' -import embedIconsFigma from '../embed-icons/figma.png' -import embedIconsGithubGist from '../embed-icons/github_gist.png' -import embedIconsGoogleCalendar from '../embed-icons/google_calendar.png' -import embedIconsGoogleMaps from '../embed-icons/google_maps.png' -import embedIconsGoogleSlides from '../embed-icons/google_slides.png' -import embedIconsObservable from '../embed-icons/observable.png' -import embedIconsReplit from '../embed-icons/replit.png' -import embedIconsScratch from '../embed-icons/scratch.png' -import embedIconsSpotify from '../embed-icons/spotify.png' -import embedIconsTldraw from '../embed-icons/tldraw.png' -import embedIconsVimeo from '../embed-icons/vimeo.png' -import embedIconsYoutube from '../embed-icons/youtube.png' -import fontsMonospace from '../fonts/IBMPlexMono-Medium.woff2' -import fontsSansSerif from '../fonts/IBMPlexSans-Medium.woff2' -import fontsSerif from '../fonts/IBMPlexSerif-Medium.woff2' -import fontsDraw from '../fonts/Shantell_Sans-Normal-SemiBold.woff2' -import iconsAlignBottomCenter from '../icons/icon/align-bottom-center.svg' -import iconsAlignBottomLeft from '../icons/icon/align-bottom-left.svg' -import iconsAlignBottomRight from '../icons/icon/align-bottom-right.svg' -import iconsAlignBottom from '../icons/icon/align-bottom.svg' -import iconsAlignCenterCenter from '../icons/icon/align-center-center.svg' -import iconsAlignCenterHorizontal from '../icons/icon/align-center-horizontal.svg' -import iconsAlignCenterLeft from '../icons/icon/align-center-left.svg' -import iconsAlignCenterRight from '../icons/icon/align-center-right.svg' -import iconsAlignCenterVertical from '../icons/icon/align-center-vertical.svg' -import iconsAlignLeft from '../icons/icon/align-left.svg' -import iconsAlignRight from '../icons/icon/align-right.svg' -import iconsAlignTopCenter from '../icons/icon/align-top-center.svg' -import iconsAlignTopLeft from '../icons/icon/align-top-left.svg' -import iconsAlignTopRight from '../icons/icon/align-top-right.svg' -import iconsAlignTop from '../icons/icon/align-top.svg' -import iconsArrowLeft from '../icons/icon/arrow-left.svg' -import iconsArrowheadArrow from '../icons/icon/arrowhead-arrow.svg' -import iconsArrowheadBar from '../icons/icon/arrowhead-bar.svg' -import iconsArrowheadDiamond from '../icons/icon/arrowhead-diamond.svg' -import iconsArrowheadDot from '../icons/icon/arrowhead-dot.svg' -import iconsArrowheadNone from '../icons/icon/arrowhead-none.svg' -import iconsArrowheadSquare from '../icons/icon/arrowhead-square.svg' -import iconsArrowheadTriangleInverted from '../icons/icon/arrowhead-triangle-inverted.svg' -import iconsArrowheadTriangle from '../icons/icon/arrowhead-triangle.svg' -import iconsAspectRatio from '../icons/icon/aspect-ratio.svg' -import iconsAvatar from '../icons/icon/avatar.svg' -import iconsBlob from '../icons/icon/blob.svg' -import iconsBringForward from '../icons/icon/bring-forward.svg' -import iconsBringToFront from '../icons/icon/bring-to-front.svg' -import iconsCheck from '../icons/icon/check.svg' -import iconsCheckboxChecked from '../icons/icon/checkbox-checked.svg' -import iconsCheckboxEmpty from '../icons/icon/checkbox-empty.svg' -import iconsChevronDown from '../icons/icon/chevron-down.svg' -import iconsChevronLeft from '../icons/icon/chevron-left.svg' -import iconsChevronRight from '../icons/icon/chevron-right.svg' -import iconsChevronUp from '../icons/icon/chevron-up.svg' -import iconsChevronsNe from '../icons/icon/chevrons-ne.svg' -import iconsChevronsSw from '../icons/icon/chevrons-sw.svg' -import iconsClipboardCopy from '../icons/icon/clipboard-copy.svg' -import iconsCode from '../icons/icon/code.svg' -import iconsCollab from '../icons/icon/collab.svg' -import iconsColor from '../icons/icon/color.svg' -import iconsComment from '../icons/icon/comment.svg' -import iconsCross2 from '../icons/icon/cross-2.svg' -import iconsCross from '../icons/icon/cross.svg' -import iconsDashDashed from '../icons/icon/dash-dashed.svg' -import iconsDashDotted from '../icons/icon/dash-dotted.svg' -import iconsDashDraw from '../icons/icon/dash-draw.svg' -import iconsDashSolid from '../icons/icon/dash-solid.svg' -import iconsDiscord from '../icons/icon/discord.svg' -import iconsDistributeHorizontal from '../icons/icon/distribute-horizontal.svg' -import iconsDistributeVertical from '../icons/icon/distribute-vertical.svg' -import iconsDot from '../icons/icon/dot.svg' -import iconsDotsHorizontal from '../icons/icon/dots-horizontal.svg' -import iconsDotsVertical from '../icons/icon/dots-vertical.svg' -import iconsDragHandleDots from '../icons/icon/drag-handle-dots.svg' -import iconsDuplicate from '../icons/icon/duplicate.svg' -import iconsEdit from '../icons/icon/edit.svg' -import iconsExternalLink from '../icons/icon/external-link.svg' -import iconsFile from '../icons/icon/file.svg' -import iconsFillNone from '../icons/icon/fill-none.svg' -import iconsFillPattern from '../icons/icon/fill-pattern.svg' -import iconsFillSemi from '../icons/icon/fill-semi.svg' -import iconsFillSolid from '../icons/icon/fill-solid.svg' -import iconsFollow from '../icons/icon/follow.svg' -import iconsFollowing from '../icons/icon/following.svg' -import iconsFontDraw from '../icons/icon/font-draw.svg' -import iconsFontMono from '../icons/icon/font-mono.svg' -import iconsFontSans from '../icons/icon/font-sans.svg' -import iconsFontSerif from '../icons/icon/font-serif.svg' -import iconsGeoArrowDown from '../icons/icon/geo-arrow-down.svg' -import iconsGeoArrowLeft from '../icons/icon/geo-arrow-left.svg' -import iconsGeoArrowRight from '../icons/icon/geo-arrow-right.svg' -import iconsGeoArrowUp from '../icons/icon/geo-arrow-up.svg' -import iconsGeoCheckBox from '../icons/icon/geo-check-box.svg' -import iconsGeoDiamond from '../icons/icon/geo-diamond.svg' -import iconsGeoEllipse from '../icons/icon/geo-ellipse.svg' -import iconsGeoHexagon from '../icons/icon/geo-hexagon.svg' -import iconsGeoOctagon from '../icons/icon/geo-octagon.svg' -import iconsGeoOval from '../icons/icon/geo-oval.svg' -import iconsGeoPentagon from '../icons/icon/geo-pentagon.svg' -import iconsGeoRectangle from '../icons/icon/geo-rectangle.svg' -import iconsGeoRhombus2 from '../icons/icon/geo-rhombus-2.svg' -import iconsGeoRhombus from '../icons/icon/geo-rhombus.svg' -import iconsGeoStar from '../icons/icon/geo-star.svg' -import iconsGeoTrapezoid from '../icons/icon/geo-trapezoid.svg' -import iconsGeoTriangle from '../icons/icon/geo-triangle.svg' -import iconsGeoXBox from '../icons/icon/geo-x-box.svg' -import iconsGithub from '../icons/icon/github.svg' -import iconsGroup from '../icons/icon/group.svg' -import iconsHidden from '../icons/icon/hidden.svg' -import iconsImage from '../icons/icon/image.svg' -import iconsInfoCircle from '../icons/icon/info-circle.svg' -import iconsLeading from '../icons/icon/leading.svg' -import iconsLink from '../icons/icon/link.svg' -import iconsLockSmall from '../icons/icon/lock-small.svg' -import iconsLock from '../icons/icon/lock.svg' -import iconsMenu from '../icons/icon/menu.svg' -import iconsMinus from '../icons/icon/minus.svg' -import iconsMixed from '../icons/icon/mixed.svg' -import iconsPack from '../icons/icon/pack.svg' -import iconsPage from '../icons/icon/page.svg' -import iconsPlus from '../icons/icon/plus.svg' -import iconsQuestionMarkCircle from '../icons/icon/question-mark-circle.svg' -import iconsQuestionMark from '../icons/icon/question-mark.svg' -import iconsRedo from '../icons/icon/redo.svg' -import iconsResetZoom from '../icons/icon/reset-zoom.svg' -import iconsRotateCcw from '../icons/icon/rotate-ccw.svg' -import iconsRotateCw from '../icons/icon/rotate-cw.svg' -import iconsRuler from '../icons/icon/ruler.svg' -import iconsSearch from '../icons/icon/search.svg' -import iconsSendBackward from '../icons/icon/send-backward.svg' -import iconsSendToBack from '../icons/icon/send-to-back.svg' -import iconsSettingsHorizontal from '../icons/icon/settings-horizontal.svg' -import iconsSettingsVertical1 from '../icons/icon/settings-vertical-1.svg' -import iconsSettingsVertical from '../icons/icon/settings-vertical.svg' -import iconsShare1 from '../icons/icon/share-1.svg' -import iconsShare2 from '../icons/icon/share-2.svg' -import iconsSizeExtraLarge from '../icons/icon/size-extra-large.svg' -import iconsSizeLarge from '../icons/icon/size-large.svg' -import iconsSizeMedium from '../icons/icon/size-medium.svg' -import iconsSizeSmall from '../icons/icon/size-small.svg' -import iconsSplineCubic from '../icons/icon/spline-cubic.svg' -import iconsSplineLine from '../icons/icon/spline-line.svg' -import iconsStackHorizontal from '../icons/icon/stack-horizontal.svg' -import iconsStackVertical from '../icons/icon/stack-vertical.svg' -import iconsStretchHorizontal from '../icons/icon/stretch-horizontal.svg' -import iconsStretchVertical from '../icons/icon/stretch-vertical.svg' -import iconsTextAlignCenter from '../icons/icon/text-align-center.svg' -import iconsTextAlignJustify from '../icons/icon/text-align-justify.svg' -import iconsTextAlignLeft from '../icons/icon/text-align-left.svg' -import iconsTextAlignRight from '../icons/icon/text-align-right.svg' -import iconsToolArrow from '../icons/icon/tool-arrow.svg' -import iconsToolEmbed from '../icons/icon/tool-embed.svg' -import iconsToolEraser from '../icons/icon/tool-eraser.svg' -import iconsToolFrame from '../icons/icon/tool-frame.svg' -import iconsToolHand from '../icons/icon/tool-hand.svg' -import iconsToolHighlighter from '../icons/icon/tool-highlighter.svg' -import iconsToolLine from '../icons/icon/tool-line.svg' -import iconsToolMedia from '../icons/icon/tool-media.svg' -import iconsToolNote from '../icons/icon/tool-note.svg' -import iconsToolPencil from '../icons/icon/tool-pencil.svg' -import iconsToolPointer from '../icons/icon/tool-pointer.svg' -import iconsToolText from '../icons/icon/tool-text.svg' -import iconsTrash from '../icons/icon/trash.svg' -import iconsTriangleDown from '../icons/icon/triangle-down.svg' -import iconsTriangleUp from '../icons/icon/triangle-up.svg' -import iconsTwitter from '../icons/icon/twitter.svg' -import iconsUndo from '../icons/icon/undo.svg' -import iconsUngroup from '../icons/icon/ungroup.svg' -import iconsUnlockSmall from '../icons/icon/unlock-small.svg' -import iconsUnlock from '../icons/icon/unlock.svg' -import iconsVisible from '../icons/icon/visible.svg' -import iconsWarningTriangle from '../icons/icon/warning-triangle.svg' -import iconsZoomIn from '../icons/icon/zoom-in.svg' -import iconsZoomOut from '../icons/icon/zoom-out.svg' -import translationsAr from '../translations/ar.json' -import translationsCa from '../translations/ca.json' -import translationsDa from '../translations/da.json' -import translationsDe from '../translations/de.json' -import translationsEn from '../translations/en.json' -import translationsEs from '../translations/es.json' -import translationsFa from '../translations/fa.json' -import translationsFi from '../translations/fi.json' -import translationsFr from '../translations/fr.json' -import translationsGl from '../translations/gl.json' -import translationsHe from '../translations/he.json' -import translationsHiIn from '../translations/hi-in.json' -import translationsHu from '../translations/hu.json' -import translationsIt from '../translations/it.json' -import translationsJa from '../translations/ja.json' -import translationsKoKr from '../translations/ko-kr.json' -import translationsKu from '../translations/ku.json' -import translationsLanguages from '../translations/languages.json' -import translationsMain from '../translations/main.json' -import translationsMy from '../translations/my.json' -import translationsNe from '../translations/ne.json' -import translationsNo from '../translations/no.json' -import translationsPl from '../translations/pl.json' -import translationsPtBr from '../translations/pt-br.json' -import translationsPtPt from '../translations/pt-pt.json' -import translationsRo from '../translations/ro.json' -import translationsRu from '../translations/ru.json' -import translationsSv from '../translations/sv.json' -import translationsTe from '../translations/te.json' -import translationsTh from '../translations/th.json' -import translationsTr from '../translations/tr.json' -import translationsUk from '../translations/uk.json' -import translationsVi from '../translations/vi.json' -import translationsZhCn from '../translations/zh-cn.json' -import translationsZhTw from '../translations/zh-tw.json' -import { AssetUrlOptions, formatAssetUrl } from './utils' - -/** @public */ -export function getBundlerAssetUrls(opts?: AssetUrlOptions) { - return { - fonts: { - monospace: formatAssetUrl(fontsMonospace, opts), - sansSerif: formatAssetUrl(fontsSansSerif, opts), - serif: formatAssetUrl(fontsSerif, opts), - draw: formatAssetUrl(fontsDraw, opts), - }, - icons: { - 'align-bottom-center': formatAssetUrl(iconsAlignBottomCenter, opts), - 'align-bottom-left': formatAssetUrl(iconsAlignBottomLeft, opts), - 'align-bottom-right': formatAssetUrl(iconsAlignBottomRight, opts), - 'align-bottom': formatAssetUrl(iconsAlignBottom, opts), - 'align-center-center': formatAssetUrl(iconsAlignCenterCenter, opts), - 'align-center-horizontal': formatAssetUrl(iconsAlignCenterHorizontal, opts), - 'align-center-left': formatAssetUrl(iconsAlignCenterLeft, opts), - 'align-center-right': formatAssetUrl(iconsAlignCenterRight, opts), - 'align-center-vertical': formatAssetUrl(iconsAlignCenterVertical, opts), - 'align-left': formatAssetUrl(iconsAlignLeft, opts), - 'align-right': formatAssetUrl(iconsAlignRight, opts), - 'align-top-center': formatAssetUrl(iconsAlignTopCenter, opts), - 'align-top-left': formatAssetUrl(iconsAlignTopLeft, opts), - 'align-top-right': formatAssetUrl(iconsAlignTopRight, opts), - 'align-top': formatAssetUrl(iconsAlignTop, opts), - 'arrow-left': formatAssetUrl(iconsArrowLeft, opts), - 'arrowhead-arrow': formatAssetUrl(iconsArrowheadArrow, opts), - 'arrowhead-bar': formatAssetUrl(iconsArrowheadBar, opts), - 'arrowhead-diamond': formatAssetUrl(iconsArrowheadDiamond, opts), - 'arrowhead-dot': formatAssetUrl(iconsArrowheadDot, opts), - 'arrowhead-none': formatAssetUrl(iconsArrowheadNone, opts), - 'arrowhead-square': formatAssetUrl(iconsArrowheadSquare, opts), - 'arrowhead-triangle-inverted': formatAssetUrl(iconsArrowheadTriangleInverted, opts), - 'arrowhead-triangle': formatAssetUrl(iconsArrowheadTriangle, opts), - 'aspect-ratio': formatAssetUrl(iconsAspectRatio, opts), - avatar: formatAssetUrl(iconsAvatar, opts), - blob: formatAssetUrl(iconsBlob, opts), - 'bring-forward': formatAssetUrl(iconsBringForward, opts), - 'bring-to-front': formatAssetUrl(iconsBringToFront, opts), - check: formatAssetUrl(iconsCheck, opts), - 'checkbox-checked': formatAssetUrl(iconsCheckboxChecked, opts), - 'checkbox-empty': formatAssetUrl(iconsCheckboxEmpty, opts), - 'chevron-down': formatAssetUrl(iconsChevronDown, opts), - 'chevron-left': formatAssetUrl(iconsChevronLeft, opts), - 'chevron-right': formatAssetUrl(iconsChevronRight, opts), - 'chevron-up': formatAssetUrl(iconsChevronUp, opts), - 'chevrons-ne': formatAssetUrl(iconsChevronsNe, opts), - 'chevrons-sw': formatAssetUrl(iconsChevronsSw, opts), - 'clipboard-copy': formatAssetUrl(iconsClipboardCopy, opts), - code: formatAssetUrl(iconsCode, opts), - collab: formatAssetUrl(iconsCollab, opts), - color: formatAssetUrl(iconsColor, opts), - comment: formatAssetUrl(iconsComment, opts), - 'cross-2': formatAssetUrl(iconsCross2, opts), - cross: formatAssetUrl(iconsCross, opts), - 'dash-dashed': formatAssetUrl(iconsDashDashed, opts), - 'dash-dotted': formatAssetUrl(iconsDashDotted, opts), - 'dash-draw': formatAssetUrl(iconsDashDraw, opts), - 'dash-solid': formatAssetUrl(iconsDashSolid, opts), - discord: formatAssetUrl(iconsDiscord, opts), - 'distribute-horizontal': formatAssetUrl(iconsDistributeHorizontal, opts), - 'distribute-vertical': formatAssetUrl(iconsDistributeVertical, opts), - dot: formatAssetUrl(iconsDot, opts), - 'dots-horizontal': formatAssetUrl(iconsDotsHorizontal, opts), - 'dots-vertical': formatAssetUrl(iconsDotsVertical, opts), - 'drag-handle-dots': formatAssetUrl(iconsDragHandleDots, opts), - duplicate: formatAssetUrl(iconsDuplicate, opts), - edit: formatAssetUrl(iconsEdit, opts), - 'external-link': formatAssetUrl(iconsExternalLink, opts), - file: formatAssetUrl(iconsFile, opts), - 'fill-none': formatAssetUrl(iconsFillNone, opts), - 'fill-pattern': formatAssetUrl(iconsFillPattern, opts), - 'fill-semi': formatAssetUrl(iconsFillSemi, opts), - 'fill-solid': formatAssetUrl(iconsFillSolid, opts), - follow: formatAssetUrl(iconsFollow, opts), - following: formatAssetUrl(iconsFollowing, opts), - 'font-draw': formatAssetUrl(iconsFontDraw, opts), - 'font-mono': formatAssetUrl(iconsFontMono, opts), - 'font-sans': formatAssetUrl(iconsFontSans, opts), - 'font-serif': formatAssetUrl(iconsFontSerif, opts), - 'geo-arrow-down': formatAssetUrl(iconsGeoArrowDown, opts), - 'geo-arrow-left': formatAssetUrl(iconsGeoArrowLeft, opts), - 'geo-arrow-right': formatAssetUrl(iconsGeoArrowRight, opts), - 'geo-arrow-up': formatAssetUrl(iconsGeoArrowUp, opts), - 'geo-check-box': formatAssetUrl(iconsGeoCheckBox, opts), - 'geo-diamond': formatAssetUrl(iconsGeoDiamond, opts), - 'geo-ellipse': formatAssetUrl(iconsGeoEllipse, opts), - 'geo-hexagon': formatAssetUrl(iconsGeoHexagon, opts), - 'geo-octagon': formatAssetUrl(iconsGeoOctagon, opts), - 'geo-oval': formatAssetUrl(iconsGeoOval, opts), - 'geo-pentagon': formatAssetUrl(iconsGeoPentagon, opts), - 'geo-rectangle': formatAssetUrl(iconsGeoRectangle, opts), - 'geo-rhombus-2': formatAssetUrl(iconsGeoRhombus2, opts), - 'geo-rhombus': formatAssetUrl(iconsGeoRhombus, opts), - 'geo-star': formatAssetUrl(iconsGeoStar, opts), - 'geo-trapezoid': formatAssetUrl(iconsGeoTrapezoid, opts), - 'geo-triangle': formatAssetUrl(iconsGeoTriangle, opts), - 'geo-x-box': formatAssetUrl(iconsGeoXBox, opts), - github: formatAssetUrl(iconsGithub, opts), - group: formatAssetUrl(iconsGroup, opts), - hidden: formatAssetUrl(iconsHidden, opts), - image: formatAssetUrl(iconsImage, opts), - 'info-circle': formatAssetUrl(iconsInfoCircle, opts), - leading: formatAssetUrl(iconsLeading, opts), - link: formatAssetUrl(iconsLink, opts), - 'lock-small': formatAssetUrl(iconsLockSmall, opts), - lock: formatAssetUrl(iconsLock, opts), - menu: formatAssetUrl(iconsMenu, opts), - minus: formatAssetUrl(iconsMinus, opts), - mixed: formatAssetUrl(iconsMixed, opts), - pack: formatAssetUrl(iconsPack, opts), - page: formatAssetUrl(iconsPage, opts), - plus: formatAssetUrl(iconsPlus, opts), - 'question-mark-circle': formatAssetUrl(iconsQuestionMarkCircle, opts), - 'question-mark': formatAssetUrl(iconsQuestionMark, opts), - redo: formatAssetUrl(iconsRedo, opts), - 'reset-zoom': formatAssetUrl(iconsResetZoom, opts), - 'rotate-ccw': formatAssetUrl(iconsRotateCcw, opts), - 'rotate-cw': formatAssetUrl(iconsRotateCw, opts), - ruler: formatAssetUrl(iconsRuler, opts), - search: formatAssetUrl(iconsSearch, opts), - 'send-backward': formatAssetUrl(iconsSendBackward, opts), - 'send-to-back': formatAssetUrl(iconsSendToBack, opts), - 'settings-horizontal': formatAssetUrl(iconsSettingsHorizontal, opts), - 'settings-vertical-1': formatAssetUrl(iconsSettingsVertical1, opts), - 'settings-vertical': formatAssetUrl(iconsSettingsVertical, opts), - 'share-1': formatAssetUrl(iconsShare1, opts), - 'share-2': formatAssetUrl(iconsShare2, opts), - 'size-extra-large': formatAssetUrl(iconsSizeExtraLarge, opts), - 'size-large': formatAssetUrl(iconsSizeLarge, opts), - 'size-medium': formatAssetUrl(iconsSizeMedium, opts), - 'size-small': formatAssetUrl(iconsSizeSmall, opts), - 'spline-cubic': formatAssetUrl(iconsSplineCubic, opts), - 'spline-line': formatAssetUrl(iconsSplineLine, opts), - 'stack-horizontal': formatAssetUrl(iconsStackHorizontal, opts), - 'stack-vertical': formatAssetUrl(iconsStackVertical, opts), - 'stretch-horizontal': formatAssetUrl(iconsStretchHorizontal, opts), - 'stretch-vertical': formatAssetUrl(iconsStretchVertical, opts), - 'text-align-center': formatAssetUrl(iconsTextAlignCenter, opts), - 'text-align-justify': formatAssetUrl(iconsTextAlignJustify, opts), - 'text-align-left': formatAssetUrl(iconsTextAlignLeft, opts), - 'text-align-right': formatAssetUrl(iconsTextAlignRight, opts), - 'tool-arrow': formatAssetUrl(iconsToolArrow, opts), - 'tool-embed': formatAssetUrl(iconsToolEmbed, opts), - 'tool-eraser': formatAssetUrl(iconsToolEraser, opts), - 'tool-frame': formatAssetUrl(iconsToolFrame, opts), - 'tool-hand': formatAssetUrl(iconsToolHand, opts), - 'tool-highlighter': formatAssetUrl(iconsToolHighlighter, opts), - 'tool-line': formatAssetUrl(iconsToolLine, opts), - 'tool-media': formatAssetUrl(iconsToolMedia, opts), - 'tool-note': formatAssetUrl(iconsToolNote, opts), - 'tool-pencil': formatAssetUrl(iconsToolPencil, opts), - 'tool-pointer': formatAssetUrl(iconsToolPointer, opts), - 'tool-text': formatAssetUrl(iconsToolText, opts), - trash: formatAssetUrl(iconsTrash, opts), - 'triangle-down': formatAssetUrl(iconsTriangleDown, opts), - 'triangle-up': formatAssetUrl(iconsTriangleUp, opts), - twitter: formatAssetUrl(iconsTwitter, opts), - undo: formatAssetUrl(iconsUndo, opts), - ungroup: formatAssetUrl(iconsUngroup, opts), - 'unlock-small': formatAssetUrl(iconsUnlockSmall, opts), - unlock: formatAssetUrl(iconsUnlock, opts), - visible: formatAssetUrl(iconsVisible, opts), - 'warning-triangle': formatAssetUrl(iconsWarningTriangle, opts), - 'zoom-in': formatAssetUrl(iconsZoomIn, opts), - 'zoom-out': formatAssetUrl(iconsZoomOut, opts), - }, - translations: { - ar: formatAssetUrl(translationsAr, opts), - ca: formatAssetUrl(translationsCa, opts), - da: formatAssetUrl(translationsDa, opts), - de: formatAssetUrl(translationsDe, opts), - en: formatAssetUrl(translationsEn, opts), - es: formatAssetUrl(translationsEs, opts), - fa: formatAssetUrl(translationsFa, opts), - fi: formatAssetUrl(translationsFi, opts), - fr: formatAssetUrl(translationsFr, opts), - gl: formatAssetUrl(translationsGl, opts), - he: formatAssetUrl(translationsHe, opts), - 'hi-in': formatAssetUrl(translationsHiIn, opts), - hu: formatAssetUrl(translationsHu, opts), - it: formatAssetUrl(translationsIt, opts), - ja: formatAssetUrl(translationsJa, opts), - 'ko-kr': formatAssetUrl(translationsKoKr, opts), - ku: formatAssetUrl(translationsKu, opts), - languages: formatAssetUrl(translationsLanguages, opts), - main: formatAssetUrl(translationsMain, opts), - my: formatAssetUrl(translationsMy, opts), - ne: formatAssetUrl(translationsNe, opts), - no: formatAssetUrl(translationsNo, opts), - pl: formatAssetUrl(translationsPl, opts), - 'pt-br': formatAssetUrl(translationsPtBr, opts), - 'pt-pt': formatAssetUrl(translationsPtPt, opts), - ro: formatAssetUrl(translationsRo, opts), - ru: formatAssetUrl(translationsRu, opts), - sv: formatAssetUrl(translationsSv, opts), - te: formatAssetUrl(translationsTe, opts), - th: formatAssetUrl(translationsTh, opts), - tr: formatAssetUrl(translationsTr, opts), - uk: formatAssetUrl(translationsUk, opts), - vi: formatAssetUrl(translationsVi, opts), - 'zh-cn': formatAssetUrl(translationsZhCn, opts), - 'zh-tw': formatAssetUrl(translationsZhTw, opts), - }, - embedIcons: { - codepen: formatAssetUrl(embedIconsCodepen, opts), - codesandbox: formatAssetUrl(embedIconsCodesandbox, opts), - excalidraw: formatAssetUrl(embedIconsExcalidraw, opts), - felt: formatAssetUrl(embedIconsFelt, opts), - figma: formatAssetUrl(embedIconsFigma, opts), - github_gist: formatAssetUrl(embedIconsGithubGist, opts), - google_calendar: formatAssetUrl(embedIconsGoogleCalendar, opts), - google_maps: formatAssetUrl(embedIconsGoogleMaps, opts), - google_slides: formatAssetUrl(embedIconsGoogleSlides, opts), - observable: formatAssetUrl(embedIconsObservable, opts), - replit: formatAssetUrl(embedIconsReplit, opts), - scratch: formatAssetUrl(embedIconsScratch, opts), - spotify: formatAssetUrl(embedIconsSpotify, opts), - tldraw: formatAssetUrl(embedIconsTldraw, opts), - vimeo: formatAssetUrl(embedIconsVimeo, opts), - youtube: formatAssetUrl(embedIconsYoutube, opts), - }, - } as const -} diff --git a/packages/assets/src/index.ts b/packages/assets/src/index.ts deleted file mode 100644 index 6114a9dae..000000000 --- a/packages/assets/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { getBundlerAssetUrls } from './imports' diff --git a/packages/assets/src/urls.ts b/packages/assets/src/urls.ts deleted file mode 100644 index d678e8c62..000000000 --- a/packages/assets/src/urls.ts +++ /dev/null @@ -1,603 +0,0 @@ -// This file is automatically generated by scripts/refresh-assets.ts. -// Do not edit manually. - -// eslint-disable-next-line @typescript-eslint/triple-slash-reference -/// -import { AssetUrlOptions, formatAssetUrl } from './utils' - -/** @public */ -export function getBundlerAssetUrls(opts?: AssetUrlOptions) { - return { - fonts: { - monospace: formatAssetUrl( - new URL('../fonts/IBMPlexMono-Medium.woff2', import.meta.url).href, - opts - ), - sansSerif: formatAssetUrl( - new URL('../fonts/IBMPlexSans-Medium.woff2', import.meta.url).href, - opts - ), - serif: formatAssetUrl( - new URL('../fonts/IBMPlexSerif-Medium.woff2', import.meta.url).href, - opts - ), - draw: formatAssetUrl( - new URL('../fonts/Shantell_Sans-Normal-SemiBold.woff2', import.meta.url).href, - opts - ), - }, - icons: { - 'align-bottom-center': formatAssetUrl( - new URL('../icons/icon/align-bottom-center.svg', import.meta.url).href, - opts - ), - 'align-bottom-left': formatAssetUrl( - new URL('../icons/icon/align-bottom-left.svg', import.meta.url).href, - opts - ), - 'align-bottom-right': formatAssetUrl( - new URL('../icons/icon/align-bottom-right.svg', import.meta.url).href, - opts - ), - 'align-bottom': formatAssetUrl( - new URL('../icons/icon/align-bottom.svg', import.meta.url).href, - opts - ), - 'align-center-center': formatAssetUrl( - new URL('../icons/icon/align-center-center.svg', import.meta.url).href, - opts - ), - 'align-center-horizontal': formatAssetUrl( - new URL('../icons/icon/align-center-horizontal.svg', import.meta.url).href, - opts - ), - 'align-center-left': formatAssetUrl( - new URL('../icons/icon/align-center-left.svg', import.meta.url).href, - opts - ), - 'align-center-right': formatAssetUrl( - new URL('../icons/icon/align-center-right.svg', import.meta.url).href, - opts - ), - 'align-center-vertical': formatAssetUrl( - new URL('../icons/icon/align-center-vertical.svg', import.meta.url).href, - opts - ), - 'align-left': formatAssetUrl( - new URL('../icons/icon/align-left.svg', import.meta.url).href, - opts - ), - 'align-right': formatAssetUrl( - new URL('../icons/icon/align-right.svg', import.meta.url).href, - opts - ), - 'align-top-center': formatAssetUrl( - new URL('../icons/icon/align-top-center.svg', import.meta.url).href, - opts - ), - 'align-top-left': formatAssetUrl( - new URL('../icons/icon/align-top-left.svg', import.meta.url).href, - opts - ), - 'align-top-right': formatAssetUrl( - new URL('../icons/icon/align-top-right.svg', import.meta.url).href, - opts - ), - 'align-top': formatAssetUrl( - new URL('../icons/icon/align-top.svg', import.meta.url).href, - opts - ), - 'arrow-left': formatAssetUrl( - new URL('../icons/icon/arrow-left.svg', import.meta.url).href, - opts - ), - 'arrowhead-arrow': formatAssetUrl( - new URL('../icons/icon/arrowhead-arrow.svg', import.meta.url).href, - opts - ), - 'arrowhead-bar': formatAssetUrl( - new URL('../icons/icon/arrowhead-bar.svg', import.meta.url).href, - opts - ), - 'arrowhead-diamond': formatAssetUrl( - new URL('../icons/icon/arrowhead-diamond.svg', import.meta.url).href, - opts - ), - 'arrowhead-dot': formatAssetUrl( - new URL('../icons/icon/arrowhead-dot.svg', import.meta.url).href, - opts - ), - 'arrowhead-none': formatAssetUrl( - new URL('../icons/icon/arrowhead-none.svg', import.meta.url).href, - opts - ), - 'arrowhead-square': formatAssetUrl( - new URL('../icons/icon/arrowhead-square.svg', import.meta.url).href, - opts - ), - 'arrowhead-triangle-inverted': formatAssetUrl( - new URL('../icons/icon/arrowhead-triangle-inverted.svg', import.meta.url).href, - opts - ), - 'arrowhead-triangle': formatAssetUrl( - new URL('../icons/icon/arrowhead-triangle.svg', import.meta.url).href, - opts - ), - 'aspect-ratio': formatAssetUrl( - new URL('../icons/icon/aspect-ratio.svg', import.meta.url).href, - opts - ), - avatar: formatAssetUrl(new URL('../icons/icon/avatar.svg', import.meta.url).href, opts), - blob: formatAssetUrl(new URL('../icons/icon/blob.svg', import.meta.url).href, opts), - 'bring-forward': formatAssetUrl( - new URL('../icons/icon/bring-forward.svg', import.meta.url).href, - opts - ), - 'bring-to-front': formatAssetUrl( - new URL('../icons/icon/bring-to-front.svg', import.meta.url).href, - opts - ), - check: formatAssetUrl(new URL('../icons/icon/check.svg', import.meta.url).href, opts), - 'checkbox-checked': formatAssetUrl( - new URL('../icons/icon/checkbox-checked.svg', import.meta.url).href, - opts - ), - 'checkbox-empty': formatAssetUrl( - new URL('../icons/icon/checkbox-empty.svg', import.meta.url).href, - opts - ), - 'chevron-down': formatAssetUrl( - new URL('../icons/icon/chevron-down.svg', import.meta.url).href, - opts - ), - 'chevron-left': formatAssetUrl( - new URL('../icons/icon/chevron-left.svg', import.meta.url).href, - opts - ), - 'chevron-right': formatAssetUrl( - new URL('../icons/icon/chevron-right.svg', import.meta.url).href, - opts - ), - 'chevron-up': formatAssetUrl( - new URL('../icons/icon/chevron-up.svg', import.meta.url).href, - opts - ), - 'chevrons-ne': formatAssetUrl( - new URL('../icons/icon/chevrons-ne.svg', import.meta.url).href, - opts - ), - 'chevrons-sw': formatAssetUrl( - new URL('../icons/icon/chevrons-sw.svg', import.meta.url).href, - opts - ), - 'clipboard-copy': formatAssetUrl( - new URL('../icons/icon/clipboard-copy.svg', import.meta.url).href, - opts - ), - code: formatAssetUrl(new URL('../icons/icon/code.svg', import.meta.url).href, opts), - collab: formatAssetUrl(new URL('../icons/icon/collab.svg', import.meta.url).href, opts), - color: formatAssetUrl(new URL('../icons/icon/color.svg', import.meta.url).href, opts), - comment: formatAssetUrl(new URL('../icons/icon/comment.svg', import.meta.url).href, opts), - 'cross-2': formatAssetUrl(new URL('../icons/icon/cross-2.svg', import.meta.url).href, opts), - cross: formatAssetUrl(new URL('../icons/icon/cross.svg', import.meta.url).href, opts), - 'dash-dashed': formatAssetUrl( - new URL('../icons/icon/dash-dashed.svg', import.meta.url).href, - opts - ), - 'dash-dotted': formatAssetUrl( - new URL('../icons/icon/dash-dotted.svg', import.meta.url).href, - opts - ), - 'dash-draw': formatAssetUrl( - new URL('../icons/icon/dash-draw.svg', import.meta.url).href, - opts - ), - 'dash-solid': formatAssetUrl( - new URL('../icons/icon/dash-solid.svg', import.meta.url).href, - opts - ), - discord: formatAssetUrl(new URL('../icons/icon/discord.svg', import.meta.url).href, opts), - 'distribute-horizontal': formatAssetUrl( - new URL('../icons/icon/distribute-horizontal.svg', import.meta.url).href, - opts - ), - 'distribute-vertical': formatAssetUrl( - new URL('../icons/icon/distribute-vertical.svg', import.meta.url).href, - opts - ), - dot: formatAssetUrl(new URL('../icons/icon/dot.svg', import.meta.url).href, opts), - 'dots-horizontal': formatAssetUrl( - new URL('../icons/icon/dots-horizontal.svg', import.meta.url).href, - opts - ), - 'dots-vertical': formatAssetUrl( - new URL('../icons/icon/dots-vertical.svg', import.meta.url).href, - opts - ), - 'drag-handle-dots': formatAssetUrl( - new URL('../icons/icon/drag-handle-dots.svg', import.meta.url).href, - opts - ), - duplicate: formatAssetUrl(new URL('../icons/icon/duplicate.svg', import.meta.url).href, opts), - edit: formatAssetUrl(new URL('../icons/icon/edit.svg', import.meta.url).href, opts), - 'external-link': formatAssetUrl( - new URL('../icons/icon/external-link.svg', import.meta.url).href, - opts - ), - file: formatAssetUrl(new URL('../icons/icon/file.svg', import.meta.url).href, opts), - 'fill-none': formatAssetUrl( - new URL('../icons/icon/fill-none.svg', import.meta.url).href, - opts - ), - 'fill-pattern': formatAssetUrl( - new URL('../icons/icon/fill-pattern.svg', import.meta.url).href, - opts - ), - 'fill-semi': formatAssetUrl( - new URL('../icons/icon/fill-semi.svg', import.meta.url).href, - opts - ), - 'fill-solid': formatAssetUrl( - new URL('../icons/icon/fill-solid.svg', import.meta.url).href, - opts - ), - follow: formatAssetUrl(new URL('../icons/icon/follow.svg', import.meta.url).href, opts), - following: formatAssetUrl(new URL('../icons/icon/following.svg', import.meta.url).href, opts), - 'font-draw': formatAssetUrl( - new URL('../icons/icon/font-draw.svg', import.meta.url).href, - opts - ), - 'font-mono': formatAssetUrl( - new URL('../icons/icon/font-mono.svg', import.meta.url).href, - opts - ), - 'font-sans': formatAssetUrl( - new URL('../icons/icon/font-sans.svg', import.meta.url).href, - opts - ), - 'font-serif': formatAssetUrl( - new URL('../icons/icon/font-serif.svg', import.meta.url).href, - opts - ), - 'geo-arrow-down': formatAssetUrl( - new URL('../icons/icon/geo-arrow-down.svg', import.meta.url).href, - opts - ), - 'geo-arrow-left': formatAssetUrl( - new URL('../icons/icon/geo-arrow-left.svg', import.meta.url).href, - opts - ), - 'geo-arrow-right': formatAssetUrl( - new URL('../icons/icon/geo-arrow-right.svg', import.meta.url).href, - opts - ), - 'geo-arrow-up': formatAssetUrl( - new URL('../icons/icon/geo-arrow-up.svg', import.meta.url).href, - opts - ), - 'geo-check-box': formatAssetUrl( - new URL('../icons/icon/geo-check-box.svg', import.meta.url).href, - opts - ), - 'geo-diamond': formatAssetUrl( - new URL('../icons/icon/geo-diamond.svg', import.meta.url).href, - opts - ), - 'geo-ellipse': formatAssetUrl( - new URL('../icons/icon/geo-ellipse.svg', import.meta.url).href, - opts - ), - 'geo-hexagon': formatAssetUrl( - new URL('../icons/icon/geo-hexagon.svg', import.meta.url).href, - opts - ), - 'geo-octagon': formatAssetUrl( - new URL('../icons/icon/geo-octagon.svg', import.meta.url).href, - opts - ), - 'geo-oval': formatAssetUrl(new URL('../icons/icon/geo-oval.svg', import.meta.url).href, opts), - 'geo-pentagon': formatAssetUrl( - new URL('../icons/icon/geo-pentagon.svg', import.meta.url).href, - opts - ), - 'geo-rectangle': formatAssetUrl( - new URL('../icons/icon/geo-rectangle.svg', import.meta.url).href, - opts - ), - 'geo-rhombus-2': formatAssetUrl( - new URL('../icons/icon/geo-rhombus-2.svg', import.meta.url).href, - opts - ), - 'geo-rhombus': formatAssetUrl( - new URL('../icons/icon/geo-rhombus.svg', import.meta.url).href, - opts - ), - 'geo-star': formatAssetUrl(new URL('../icons/icon/geo-star.svg', import.meta.url).href, opts), - 'geo-trapezoid': formatAssetUrl( - new URL('../icons/icon/geo-trapezoid.svg', import.meta.url).href, - opts - ), - 'geo-triangle': formatAssetUrl( - new URL('../icons/icon/geo-triangle.svg', import.meta.url).href, - opts - ), - 'geo-x-box': formatAssetUrl( - new URL('../icons/icon/geo-x-box.svg', import.meta.url).href, - opts - ), - github: formatAssetUrl(new URL('../icons/icon/github.svg', import.meta.url).href, opts), - group: formatAssetUrl(new URL('../icons/icon/group.svg', import.meta.url).href, opts), - hidden: formatAssetUrl(new URL('../icons/icon/hidden.svg', import.meta.url).href, opts), - image: formatAssetUrl(new URL('../icons/icon/image.svg', import.meta.url).href, opts), - 'info-circle': formatAssetUrl( - new URL('../icons/icon/info-circle.svg', import.meta.url).href, - opts - ), - leading: formatAssetUrl(new URL('../icons/icon/leading.svg', import.meta.url).href, opts), - link: formatAssetUrl(new URL('../icons/icon/link.svg', import.meta.url).href, opts), - 'lock-small': formatAssetUrl( - new URL('../icons/icon/lock-small.svg', import.meta.url).href, - opts - ), - lock: formatAssetUrl(new URL('../icons/icon/lock.svg', import.meta.url).href, opts), - menu: formatAssetUrl(new URL('../icons/icon/menu.svg', import.meta.url).href, opts), - minus: formatAssetUrl(new URL('../icons/icon/minus.svg', import.meta.url).href, opts), - mixed: formatAssetUrl(new URL('../icons/icon/mixed.svg', import.meta.url).href, opts), - pack: formatAssetUrl(new URL('../icons/icon/pack.svg', import.meta.url).href, opts), - page: formatAssetUrl(new URL('../icons/icon/page.svg', import.meta.url).href, opts), - plus: formatAssetUrl(new URL('../icons/icon/plus.svg', import.meta.url).href, opts), - 'question-mark-circle': formatAssetUrl( - new URL('../icons/icon/question-mark-circle.svg', import.meta.url).href, - opts - ), - 'question-mark': formatAssetUrl( - new URL('../icons/icon/question-mark.svg', import.meta.url).href, - opts - ), - redo: formatAssetUrl(new URL('../icons/icon/redo.svg', import.meta.url).href, opts), - 'reset-zoom': formatAssetUrl( - new URL('../icons/icon/reset-zoom.svg', import.meta.url).href, - opts - ), - 'rotate-ccw': formatAssetUrl( - new URL('../icons/icon/rotate-ccw.svg', import.meta.url).href, - opts - ), - 'rotate-cw': formatAssetUrl( - new URL('../icons/icon/rotate-cw.svg', import.meta.url).href, - opts - ), - ruler: formatAssetUrl(new URL('../icons/icon/ruler.svg', import.meta.url).href, opts), - search: formatAssetUrl(new URL('../icons/icon/search.svg', import.meta.url).href, opts), - 'send-backward': formatAssetUrl( - new URL('../icons/icon/send-backward.svg', import.meta.url).href, - opts - ), - 'send-to-back': formatAssetUrl( - new URL('../icons/icon/send-to-back.svg', import.meta.url).href, - opts - ), - 'settings-horizontal': formatAssetUrl( - new URL('../icons/icon/settings-horizontal.svg', import.meta.url).href, - opts - ), - 'settings-vertical-1': formatAssetUrl( - new URL('../icons/icon/settings-vertical-1.svg', import.meta.url).href, - opts - ), - 'settings-vertical': formatAssetUrl( - new URL('../icons/icon/settings-vertical.svg', import.meta.url).href, - opts - ), - 'share-1': formatAssetUrl(new URL('../icons/icon/share-1.svg', import.meta.url).href, opts), - 'share-2': formatAssetUrl(new URL('../icons/icon/share-2.svg', import.meta.url).href, opts), - 'size-extra-large': formatAssetUrl( - new URL('../icons/icon/size-extra-large.svg', import.meta.url).href, - opts - ), - 'size-large': formatAssetUrl( - new URL('../icons/icon/size-large.svg', import.meta.url).href, - opts - ), - 'size-medium': formatAssetUrl( - new URL('../icons/icon/size-medium.svg', import.meta.url).href, - opts - ), - 'size-small': formatAssetUrl( - new URL('../icons/icon/size-small.svg', import.meta.url).href, - opts - ), - 'spline-cubic': formatAssetUrl( - new URL('../icons/icon/spline-cubic.svg', import.meta.url).href, - opts - ), - 'spline-line': formatAssetUrl( - new URL('../icons/icon/spline-line.svg', import.meta.url).href, - opts - ), - 'stack-horizontal': formatAssetUrl( - new URL('../icons/icon/stack-horizontal.svg', import.meta.url).href, - opts - ), - 'stack-vertical': formatAssetUrl( - new URL('../icons/icon/stack-vertical.svg', import.meta.url).href, - opts - ), - 'stretch-horizontal': formatAssetUrl( - new URL('../icons/icon/stretch-horizontal.svg', import.meta.url).href, - opts - ), - 'stretch-vertical': formatAssetUrl( - new URL('../icons/icon/stretch-vertical.svg', import.meta.url).href, - opts - ), - 'text-align-center': formatAssetUrl( - new URL('../icons/icon/text-align-center.svg', import.meta.url).href, - opts - ), - 'text-align-justify': formatAssetUrl( - new URL('../icons/icon/text-align-justify.svg', import.meta.url).href, - opts - ), - 'text-align-left': formatAssetUrl( - new URL('../icons/icon/text-align-left.svg', import.meta.url).href, - opts - ), - 'text-align-right': formatAssetUrl( - new URL('../icons/icon/text-align-right.svg', import.meta.url).href, - opts - ), - 'tool-arrow': formatAssetUrl( - new URL('../icons/icon/tool-arrow.svg', import.meta.url).href, - opts - ), - 'tool-embed': formatAssetUrl( - new URL('../icons/icon/tool-embed.svg', import.meta.url).href, - opts - ), - 'tool-eraser': formatAssetUrl( - new URL('../icons/icon/tool-eraser.svg', import.meta.url).href, - opts - ), - 'tool-frame': formatAssetUrl( - new URL('../icons/icon/tool-frame.svg', import.meta.url).href, - opts - ), - 'tool-hand': formatAssetUrl( - new URL('../icons/icon/tool-hand.svg', import.meta.url).href, - opts - ), - 'tool-highlighter': formatAssetUrl( - new URL('../icons/icon/tool-highlighter.svg', import.meta.url).href, - opts - ), - 'tool-line': formatAssetUrl( - new URL('../icons/icon/tool-line.svg', import.meta.url).href, - opts - ), - 'tool-media': formatAssetUrl( - new URL('../icons/icon/tool-media.svg', import.meta.url).href, - opts - ), - 'tool-note': formatAssetUrl( - new URL('../icons/icon/tool-note.svg', import.meta.url).href, - opts - ), - 'tool-pencil': formatAssetUrl( - new URL('../icons/icon/tool-pencil.svg', import.meta.url).href, - opts - ), - 'tool-pointer': formatAssetUrl( - new URL('../icons/icon/tool-pointer.svg', import.meta.url).href, - opts - ), - 'tool-text': formatAssetUrl( - new URL('../icons/icon/tool-text.svg', import.meta.url).href, - opts - ), - trash: formatAssetUrl(new URL('../icons/icon/trash.svg', import.meta.url).href, opts), - 'triangle-down': formatAssetUrl( - new URL('../icons/icon/triangle-down.svg', import.meta.url).href, - opts - ), - 'triangle-up': formatAssetUrl( - new URL('../icons/icon/triangle-up.svg', import.meta.url).href, - opts - ), - twitter: formatAssetUrl(new URL('../icons/icon/twitter.svg', import.meta.url).href, opts), - undo: formatAssetUrl(new URL('../icons/icon/undo.svg', import.meta.url).href, opts), - ungroup: formatAssetUrl(new URL('../icons/icon/ungroup.svg', import.meta.url).href, opts), - 'unlock-small': formatAssetUrl( - new URL('../icons/icon/unlock-small.svg', import.meta.url).href, - opts - ), - unlock: formatAssetUrl(new URL('../icons/icon/unlock.svg', import.meta.url).href, opts), - visible: formatAssetUrl(new URL('../icons/icon/visible.svg', import.meta.url).href, opts), - 'warning-triangle': formatAssetUrl( - new URL('../icons/icon/warning-triangle.svg', import.meta.url).href, - opts - ), - 'zoom-in': formatAssetUrl(new URL('../icons/icon/zoom-in.svg', import.meta.url).href, opts), - 'zoom-out': formatAssetUrl(new URL('../icons/icon/zoom-out.svg', import.meta.url).href, opts), - }, - translations: { - ar: formatAssetUrl(new URL('../translations/ar.json', import.meta.url).href, opts), - ca: formatAssetUrl(new URL('../translations/ca.json', import.meta.url).href, opts), - da: formatAssetUrl(new URL('../translations/da.json', import.meta.url).href, opts), - de: formatAssetUrl(new URL('../translations/de.json', import.meta.url).href, opts), - en: formatAssetUrl(new URL('../translations/en.json', import.meta.url).href, opts), - es: formatAssetUrl(new URL('../translations/es.json', import.meta.url).href, opts), - fa: formatAssetUrl(new URL('../translations/fa.json', import.meta.url).href, opts), - fi: formatAssetUrl(new URL('../translations/fi.json', import.meta.url).href, opts), - fr: formatAssetUrl(new URL('../translations/fr.json', import.meta.url).href, opts), - gl: formatAssetUrl(new URL('../translations/gl.json', import.meta.url).href, opts), - he: formatAssetUrl(new URL('../translations/he.json', import.meta.url).href, opts), - 'hi-in': formatAssetUrl(new URL('../translations/hi-in.json', import.meta.url).href, opts), - hu: formatAssetUrl(new URL('../translations/hu.json', import.meta.url).href, opts), - it: formatAssetUrl(new URL('../translations/it.json', import.meta.url).href, opts), - ja: formatAssetUrl(new URL('../translations/ja.json', import.meta.url).href, opts), - 'ko-kr': formatAssetUrl(new URL('../translations/ko-kr.json', import.meta.url).href, opts), - ku: formatAssetUrl(new URL('../translations/ku.json', import.meta.url).href, opts), - languages: formatAssetUrl( - new URL('../translations/languages.json', import.meta.url).href, - opts - ), - main: formatAssetUrl(new URL('../translations/main.json', import.meta.url).href, opts), - my: formatAssetUrl(new URL('../translations/my.json', import.meta.url).href, opts), - ne: formatAssetUrl(new URL('../translations/ne.json', import.meta.url).href, opts), - no: formatAssetUrl(new URL('../translations/no.json', import.meta.url).href, opts), - pl: formatAssetUrl(new URL('../translations/pl.json', import.meta.url).href, opts), - 'pt-br': formatAssetUrl(new URL('../translations/pt-br.json', import.meta.url).href, opts), - 'pt-pt': formatAssetUrl(new URL('../translations/pt-pt.json', import.meta.url).href, opts), - ro: formatAssetUrl(new URL('../translations/ro.json', import.meta.url).href, opts), - ru: formatAssetUrl(new URL('../translations/ru.json', import.meta.url).href, opts), - sv: formatAssetUrl(new URL('../translations/sv.json', import.meta.url).href, opts), - te: formatAssetUrl(new URL('../translations/te.json', import.meta.url).href, opts), - th: formatAssetUrl(new URL('../translations/th.json', import.meta.url).href, opts), - tr: formatAssetUrl(new URL('../translations/tr.json', import.meta.url).href, opts), - uk: formatAssetUrl(new URL('../translations/uk.json', import.meta.url).href, opts), - vi: formatAssetUrl(new URL('../translations/vi.json', import.meta.url).href, opts), - 'zh-cn': formatAssetUrl(new URL('../translations/zh-cn.json', import.meta.url).href, opts), - 'zh-tw': formatAssetUrl(new URL('../translations/zh-tw.json', import.meta.url).href, opts), - }, - embedIcons: { - codepen: formatAssetUrl(new URL('../embed-icons/codepen.png', import.meta.url).href, opts), - codesandbox: formatAssetUrl( - new URL('../embed-icons/codesandbox.png', import.meta.url).href, - opts - ), - excalidraw: formatAssetUrl( - new URL('../embed-icons/excalidraw.png', import.meta.url).href, - opts - ), - felt: formatAssetUrl(new URL('../embed-icons/felt.png', import.meta.url).href, opts), - figma: formatAssetUrl(new URL('../embed-icons/figma.png', import.meta.url).href, opts), - github_gist: formatAssetUrl( - new URL('../embed-icons/github_gist.png', import.meta.url).href, - opts - ), - google_calendar: formatAssetUrl( - new URL('../embed-icons/google_calendar.png', import.meta.url).href, - opts - ), - google_maps: formatAssetUrl( - new URL('../embed-icons/google_maps.png', import.meta.url).href, - opts - ), - google_slides: formatAssetUrl( - new URL('../embed-icons/google_slides.png', import.meta.url).href, - opts - ), - observable: formatAssetUrl( - new URL('../embed-icons/observable.png', import.meta.url).href, - opts - ), - replit: formatAssetUrl(new URL('../embed-icons/replit.png', import.meta.url).href, opts), - scratch: formatAssetUrl(new URL('../embed-icons/scratch.png', import.meta.url).href, opts), - spotify: formatAssetUrl(new URL('../embed-icons/spotify.png', import.meta.url).href, opts), - tldraw: formatAssetUrl(new URL('../embed-icons/tldraw.png', import.meta.url).href, opts), - vimeo: formatAssetUrl(new URL('../embed-icons/vimeo.png', import.meta.url).href, opts), - youtube: formatAssetUrl(new URL('../embed-icons/youtube.png', import.meta.url).href, opts), - }, - } as const -} diff --git a/packages/assets/src/utils.ts b/packages/assets/src/utils.ts deleted file mode 100644 index 16c199707..000000000 --- a/packages/assets/src/utils.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** @public */ -export type AssetUrl = string | { src: string } - -/** @public */ -export type AssetUrlOptions = - | { - baseUrl?: string - } - | ((assetUrl: string) => string) - -/** @public */ -export function formatAssetUrl(assetUrl: AssetUrl, format: AssetUrlOptions = {}): string { - const assetUrlString = typeof assetUrl === 'string' ? assetUrl : assetUrl.src - - if (typeof format === 'function') return format(assetUrlString) - - const { baseUrl = '' } = format - - if (assetUrlString.startsWith('data:')) return assetUrlString - if (assetUrlString.match(/^https?:\/\//)) return assetUrlString - - return `${baseUrl.replace(/\/$/, '')}/${assetUrlString.replace(/^\.?\//, '')}` -} diff --git a/packages/assets/tsconfig.json b/packages/assets/tsconfig.json index e650c33c9..d959bd48a 100644 --- a/packages/assets/tsconfig.json +++ b/packages/assets/tsconfig.json @@ -1,6 +1,6 @@ { "extends": "../../config/tsconfig.base.json", - "include": ["src", "modules.d.ts"], + "include": ["urls.js", "imports.js", "modules.d.ts"], "exclude": ["node_modules", "dist", ".tsbuild*"], "compilerOptions": { "outDir": "./.tsbuild", diff --git a/packages/assets/urls.d.ts b/packages/assets/urls.d.ts new file mode 100644 index 000000000..efebf8ced --- /dev/null +++ b/packages/assets/urls.d.ts @@ -0,0 +1,227 @@ +// This file is automatically generated by scripts/refresh-assets.ts. +// Do not edit manually. + +type AssetUrl = string | { src: string } +type AssetUrlOptions = { baseUrl?: string } | ((assetUrl: string) => string) + +export function getAssetUrlsByMetaUrl(opts?: AssetUrlOptions): { + fonts: { + monospace: string + sansSerif: string + serif: string + draw: string + } + icons: { + 'align-bottom-center': string + 'align-bottom-left': string + 'align-bottom-right': string + 'align-bottom': string + 'align-center-center': string + 'align-center-horizontal': string + 'align-center-left': string + 'align-center-right': string + 'align-center-vertical': string + 'align-left': string + 'align-right': string + 'align-top-center': string + 'align-top-left': string + 'align-top-right': string + 'align-top': string + 'arrow-left': string + 'arrowhead-arrow': string + 'arrowhead-bar': string + 'arrowhead-diamond': string + 'arrowhead-dot': string + 'arrowhead-none': string + 'arrowhead-square': string + 'arrowhead-triangle-inverted': string + 'arrowhead-triangle': string + 'aspect-ratio': string + avatar: string + blob: string + 'bring-forward': string + 'bring-to-front': string + check: string + 'checkbox-checked': string + 'checkbox-empty': string + 'chevron-down': string + 'chevron-left': string + 'chevron-right': string + 'chevron-up': string + 'chevrons-ne': string + 'chevrons-sw': string + 'clipboard-copy': string + code: string + collab: string + color: string + comment: string + 'cross-2': string + cross: string + 'dash-dashed': string + 'dash-dotted': string + 'dash-draw': string + 'dash-solid': string + discord: string + 'distribute-horizontal': string + 'distribute-vertical': string + dot: string + 'dots-horizontal': string + 'dots-vertical': string + 'drag-handle-dots': string + duplicate: string + edit: string + 'external-link': string + file: string + 'fill-none': string + 'fill-pattern': string + 'fill-semi': string + 'fill-solid': string + follow: string + following: string + 'font-draw': string + 'font-mono': string + 'font-sans': string + 'font-serif': string + 'geo-arrow-down': string + 'geo-arrow-left': string + 'geo-arrow-right': string + 'geo-arrow-up': string + 'geo-check-box': string + 'geo-diamond': string + 'geo-ellipse': string + 'geo-hexagon': string + 'geo-octagon': string + 'geo-oval': string + 'geo-pentagon': string + 'geo-rectangle': string + 'geo-rhombus-2': string + 'geo-rhombus': string + 'geo-star': string + 'geo-trapezoid': string + 'geo-triangle': string + 'geo-x-box': string + github: string + group: string + hidden: string + image: string + 'info-circle': string + leading: string + link: string + 'lock-small': string + lock: string + menu: string + minus: string + mixed: string + pack: string + page: string + plus: string + 'question-mark-circle': string + 'question-mark': string + redo: string + 'reset-zoom': string + 'rotate-ccw': string + 'rotate-cw': string + ruler: string + search: string + 'send-backward': string + 'send-to-back': string + 'settings-horizontal': string + 'settings-vertical-1': string + 'settings-vertical': string + 'share-1': string + 'share-2': string + 'size-extra-large': string + 'size-large': string + 'size-medium': string + 'size-small': string + 'spline-cubic': string + 'spline-line': string + 'stack-horizontal': string + 'stack-vertical': string + 'stretch-horizontal': string + 'stretch-vertical': string + 'text-align-center': string + 'text-align-justify': string + 'text-align-left': string + 'text-align-right': string + 'tool-arrow': string + 'tool-embed': string + 'tool-eraser': string + 'tool-frame': string + 'tool-hand': string + 'tool-highlighter': string + 'tool-line': string + 'tool-media': string + 'tool-note': string + 'tool-pencil': string + 'tool-pointer': string + 'tool-text': string + trash: string + 'triangle-down': string + 'triangle-up': string + twitter: string + undo: string + ungroup: string + 'unlock-small': string + unlock: string + visible: string + 'warning-triangle': string + 'zoom-in': string + 'zoom-out': string + } + translations: { + ar: string + ca: string + da: string + de: string + en: string + es: string + fa: string + fi: string + fr: string + gl: string + he: string + 'hi-in': string + hu: string + it: string + ja: string + 'ko-kr': string + ku: string + languages: string + main: string + my: string + ne: string + no: string + pl: string + 'pt-br': string + 'pt-pt': string + ro: string + ru: string + sv: string + te: string + th: string + tr: string + uk: string + vi: string + 'zh-cn': string + 'zh-tw': string + } + embedIcons: { + codepen: string + codesandbox: string + excalidraw: string + felt: string + figma: string + github_gist: string + google_calendar: string + google_maps: string + google_slides: string + observable: string + replit: string + scratch: string + spotify: string + tldraw: string + vimeo: string + youtube: string + } +} diff --git a/packages/assets/urls.js b/packages/assets/urls.js new file mode 100644 index 000000000..1d8016d4b --- /dev/null +++ b/packages/assets/urls.js @@ -0,0 +1,626 @@ +// This file is automatically generated by scripts/refresh-assets.ts. +// Do not edit manually. + +// eslint-disable-next-line @typescript-eslint/triple-slash-reference +/// + +/** @typedef {string | { src: string }} AssetUrl */ +/** @typedef {{ baseUrl?: string } | ((assetUrl: string) => string)} AssetUrlOptions */ + +/** + * @param {AssetUrl} assetUrl + * @param {AssetUrlOptions} [format] + * @returns {string} + */ +function formatAssetUrl(assetUrl, format = {}) { + const assetUrlString = typeof assetUrl === 'string' ? assetUrl : assetUrl.src + + if (typeof format === 'function') return format(assetUrlString) + + const { baseUrl = '' } = format + + if (assetUrlString.startsWith('data:')) return assetUrlString + if (assetUrlString.match(/^https?:\/\//)) return assetUrlString + + return `${baseUrl.replace(/\/$/, '')}/${assetUrlString.replace(/^\.?\//, '')}` +} + +/** + * @param {AssetUrlOptions} [opts] + * @public + */ +export function getAssetUrlsByMetaUrl(opts) { + return { + fonts: { + monospace: formatAssetUrl( + new URL('./fonts/IBMPlexMono-Medium.woff2', import.meta.url).href, + opts + ), + sansSerif: formatAssetUrl( + new URL('./fonts/IBMPlexSans-Medium.woff2', import.meta.url).href, + opts + ), + serif: formatAssetUrl( + new URL('./fonts/IBMPlexSerif-Medium.woff2', import.meta.url).href, + opts + ), + draw: formatAssetUrl( + new URL('./fonts/Shantell_Sans-Normal-SemiBold.woff2', import.meta.url).href, + opts + ), + }, + icons: { + 'align-bottom-center': formatAssetUrl( + new URL('./icons/icon/align-bottom-center.svg', import.meta.url).href, + opts + ), + 'align-bottom-left': formatAssetUrl( + new URL('./icons/icon/align-bottom-left.svg', import.meta.url).href, + opts + ), + 'align-bottom-right': formatAssetUrl( + new URL('./icons/icon/align-bottom-right.svg', import.meta.url).href, + opts + ), + 'align-bottom': formatAssetUrl( + new URL('./icons/icon/align-bottom.svg', import.meta.url).href, + opts + ), + 'align-center-center': formatAssetUrl( + new URL('./icons/icon/align-center-center.svg', import.meta.url).href, + opts + ), + 'align-center-horizontal': formatAssetUrl( + new URL('./icons/icon/align-center-horizontal.svg', import.meta.url).href, + opts + ), + 'align-center-left': formatAssetUrl( + new URL('./icons/icon/align-center-left.svg', import.meta.url).href, + opts + ), + 'align-center-right': formatAssetUrl( + new URL('./icons/icon/align-center-right.svg', import.meta.url).href, + opts + ), + 'align-center-vertical': formatAssetUrl( + new URL('./icons/icon/align-center-vertical.svg', import.meta.url).href, + opts + ), + 'align-left': formatAssetUrl( + new URL('./icons/icon/align-left.svg', import.meta.url).href, + opts + ), + 'align-right': formatAssetUrl( + new URL('./icons/icon/align-right.svg', import.meta.url).href, + opts + ), + 'align-top-center': formatAssetUrl( + new URL('./icons/icon/align-top-center.svg', import.meta.url).href, + opts + ), + 'align-top-left': formatAssetUrl( + new URL('./icons/icon/align-top-left.svg', import.meta.url).href, + opts + ), + 'align-top-right': formatAssetUrl( + new URL('./icons/icon/align-top-right.svg', import.meta.url).href, + opts + ), + 'align-top': formatAssetUrl( + new URL('./icons/icon/align-top.svg', import.meta.url).href, + opts + ), + 'arrow-left': formatAssetUrl( + new URL('./icons/icon/arrow-left.svg', import.meta.url).href, + opts + ), + 'arrowhead-arrow': formatAssetUrl( + new URL('./icons/icon/arrowhead-arrow.svg', import.meta.url).href, + opts + ), + 'arrowhead-bar': formatAssetUrl( + new URL('./icons/icon/arrowhead-bar.svg', import.meta.url).href, + opts + ), + 'arrowhead-diamond': formatAssetUrl( + new URL('./icons/icon/arrowhead-diamond.svg', import.meta.url).href, + opts + ), + 'arrowhead-dot': formatAssetUrl( + new URL('./icons/icon/arrowhead-dot.svg', import.meta.url).href, + opts + ), + 'arrowhead-none': formatAssetUrl( + new URL('./icons/icon/arrowhead-none.svg', import.meta.url).href, + opts + ), + 'arrowhead-square': formatAssetUrl( + new URL('./icons/icon/arrowhead-square.svg', import.meta.url).href, + opts + ), + 'arrowhead-triangle-inverted': formatAssetUrl( + new URL('./icons/icon/arrowhead-triangle-inverted.svg', import.meta.url).href, + opts + ), + 'arrowhead-triangle': formatAssetUrl( + new URL('./icons/icon/arrowhead-triangle.svg', import.meta.url).href, + opts + ), + 'aspect-ratio': formatAssetUrl( + new URL('./icons/icon/aspect-ratio.svg', import.meta.url).href, + opts + ), + avatar: formatAssetUrl(new URL('./icons/icon/avatar.svg', import.meta.url).href, opts), + blob: formatAssetUrl(new URL('./icons/icon/blob.svg', import.meta.url).href, opts), + 'bring-forward': formatAssetUrl( + new URL('./icons/icon/bring-forward.svg', import.meta.url).href, + opts + ), + 'bring-to-front': formatAssetUrl( + new URL('./icons/icon/bring-to-front.svg', import.meta.url).href, + opts + ), + check: formatAssetUrl(new URL('./icons/icon/check.svg', import.meta.url).href, opts), + 'checkbox-checked': formatAssetUrl( + new URL('./icons/icon/checkbox-checked.svg', import.meta.url).href, + opts + ), + 'checkbox-empty': formatAssetUrl( + new URL('./icons/icon/checkbox-empty.svg', import.meta.url).href, + opts + ), + 'chevron-down': formatAssetUrl( + new URL('./icons/icon/chevron-down.svg', import.meta.url).href, + opts + ), + 'chevron-left': formatAssetUrl( + new URL('./icons/icon/chevron-left.svg', import.meta.url).href, + opts + ), + 'chevron-right': formatAssetUrl( + new URL('./icons/icon/chevron-right.svg', import.meta.url).href, + opts + ), + 'chevron-up': formatAssetUrl( + new URL('./icons/icon/chevron-up.svg', import.meta.url).href, + opts + ), + 'chevrons-ne': formatAssetUrl( + new URL('./icons/icon/chevrons-ne.svg', import.meta.url).href, + opts + ), + 'chevrons-sw': formatAssetUrl( + new URL('./icons/icon/chevrons-sw.svg', import.meta.url).href, + opts + ), + 'clipboard-copy': formatAssetUrl( + new URL('./icons/icon/clipboard-copy.svg', import.meta.url).href, + opts + ), + code: formatAssetUrl(new URL('./icons/icon/code.svg', import.meta.url).href, opts), + collab: formatAssetUrl(new URL('./icons/icon/collab.svg', import.meta.url).href, opts), + color: formatAssetUrl(new URL('./icons/icon/color.svg', import.meta.url).href, opts), + comment: formatAssetUrl(new URL('./icons/icon/comment.svg', import.meta.url).href, opts), + 'cross-2': formatAssetUrl(new URL('./icons/icon/cross-2.svg', import.meta.url).href, opts), + cross: formatAssetUrl(new URL('./icons/icon/cross.svg', import.meta.url).href, opts), + 'dash-dashed': formatAssetUrl( + new URL('./icons/icon/dash-dashed.svg', import.meta.url).href, + opts + ), + 'dash-dotted': formatAssetUrl( + new URL('./icons/icon/dash-dotted.svg', import.meta.url).href, + opts + ), + 'dash-draw': formatAssetUrl( + new URL('./icons/icon/dash-draw.svg', import.meta.url).href, + opts + ), + 'dash-solid': formatAssetUrl( + new URL('./icons/icon/dash-solid.svg', import.meta.url).href, + opts + ), + discord: formatAssetUrl(new URL('./icons/icon/discord.svg', import.meta.url).href, opts), + 'distribute-horizontal': formatAssetUrl( + new URL('./icons/icon/distribute-horizontal.svg', import.meta.url).href, + opts + ), + 'distribute-vertical': formatAssetUrl( + new URL('./icons/icon/distribute-vertical.svg', import.meta.url).href, + opts + ), + dot: formatAssetUrl(new URL('./icons/icon/dot.svg', import.meta.url).href, opts), + 'dots-horizontal': formatAssetUrl( + new URL('./icons/icon/dots-horizontal.svg', import.meta.url).href, + opts + ), + 'dots-vertical': formatAssetUrl( + new URL('./icons/icon/dots-vertical.svg', import.meta.url).href, + opts + ), + 'drag-handle-dots': formatAssetUrl( + new URL('./icons/icon/drag-handle-dots.svg', import.meta.url).href, + opts + ), + duplicate: formatAssetUrl(new URL('./icons/icon/duplicate.svg', import.meta.url).href, opts), + edit: formatAssetUrl(new URL('./icons/icon/edit.svg', import.meta.url).href, opts), + 'external-link': formatAssetUrl( + new URL('./icons/icon/external-link.svg', import.meta.url).href, + opts + ), + file: formatAssetUrl(new URL('./icons/icon/file.svg', import.meta.url).href, opts), + 'fill-none': formatAssetUrl( + new URL('./icons/icon/fill-none.svg', import.meta.url).href, + opts + ), + 'fill-pattern': formatAssetUrl( + new URL('./icons/icon/fill-pattern.svg', import.meta.url).href, + opts + ), + 'fill-semi': formatAssetUrl( + new URL('./icons/icon/fill-semi.svg', import.meta.url).href, + opts + ), + 'fill-solid': formatAssetUrl( + new URL('./icons/icon/fill-solid.svg', import.meta.url).href, + opts + ), + follow: formatAssetUrl(new URL('./icons/icon/follow.svg', import.meta.url).href, opts), + following: formatAssetUrl(new URL('./icons/icon/following.svg', import.meta.url).href, opts), + 'font-draw': formatAssetUrl( + new URL('./icons/icon/font-draw.svg', import.meta.url).href, + opts + ), + 'font-mono': formatAssetUrl( + new URL('./icons/icon/font-mono.svg', import.meta.url).href, + opts + ), + 'font-sans': formatAssetUrl( + new URL('./icons/icon/font-sans.svg', import.meta.url).href, + opts + ), + 'font-serif': formatAssetUrl( + new URL('./icons/icon/font-serif.svg', import.meta.url).href, + opts + ), + 'geo-arrow-down': formatAssetUrl( + new URL('./icons/icon/geo-arrow-down.svg', import.meta.url).href, + opts + ), + 'geo-arrow-left': formatAssetUrl( + new URL('./icons/icon/geo-arrow-left.svg', import.meta.url).href, + opts + ), + 'geo-arrow-right': formatAssetUrl( + new URL('./icons/icon/geo-arrow-right.svg', import.meta.url).href, + opts + ), + 'geo-arrow-up': formatAssetUrl( + new URL('./icons/icon/geo-arrow-up.svg', import.meta.url).href, + opts + ), + 'geo-check-box': formatAssetUrl( + new URL('./icons/icon/geo-check-box.svg', import.meta.url).href, + opts + ), + 'geo-diamond': formatAssetUrl( + new URL('./icons/icon/geo-diamond.svg', import.meta.url).href, + opts + ), + 'geo-ellipse': formatAssetUrl( + new URL('./icons/icon/geo-ellipse.svg', import.meta.url).href, + opts + ), + 'geo-hexagon': formatAssetUrl( + new URL('./icons/icon/geo-hexagon.svg', import.meta.url).href, + opts + ), + 'geo-octagon': formatAssetUrl( + new URL('./icons/icon/geo-octagon.svg', import.meta.url).href, + opts + ), + 'geo-oval': formatAssetUrl(new URL('./icons/icon/geo-oval.svg', import.meta.url).href, opts), + 'geo-pentagon': formatAssetUrl( + new URL('./icons/icon/geo-pentagon.svg', import.meta.url).href, + opts + ), + 'geo-rectangle': formatAssetUrl( + new URL('./icons/icon/geo-rectangle.svg', import.meta.url).href, + opts + ), + 'geo-rhombus-2': formatAssetUrl( + new URL('./icons/icon/geo-rhombus-2.svg', import.meta.url).href, + opts + ), + 'geo-rhombus': formatAssetUrl( + new URL('./icons/icon/geo-rhombus.svg', import.meta.url).href, + opts + ), + 'geo-star': formatAssetUrl(new URL('./icons/icon/geo-star.svg', import.meta.url).href, opts), + 'geo-trapezoid': formatAssetUrl( + new URL('./icons/icon/geo-trapezoid.svg', import.meta.url).href, + opts + ), + 'geo-triangle': formatAssetUrl( + new URL('./icons/icon/geo-triangle.svg', import.meta.url).href, + opts + ), + 'geo-x-box': formatAssetUrl( + new URL('./icons/icon/geo-x-box.svg', import.meta.url).href, + opts + ), + github: formatAssetUrl(new URL('./icons/icon/github.svg', import.meta.url).href, opts), + group: formatAssetUrl(new URL('./icons/icon/group.svg', import.meta.url).href, opts), + hidden: formatAssetUrl(new URL('./icons/icon/hidden.svg', import.meta.url).href, opts), + image: formatAssetUrl(new URL('./icons/icon/image.svg', import.meta.url).href, opts), + 'info-circle': formatAssetUrl( + new URL('./icons/icon/info-circle.svg', import.meta.url).href, + opts + ), + leading: formatAssetUrl(new URL('./icons/icon/leading.svg', import.meta.url).href, opts), + link: formatAssetUrl(new URL('./icons/icon/link.svg', import.meta.url).href, opts), + 'lock-small': formatAssetUrl( + new URL('./icons/icon/lock-small.svg', import.meta.url).href, + opts + ), + lock: formatAssetUrl(new URL('./icons/icon/lock.svg', import.meta.url).href, opts), + menu: formatAssetUrl(new URL('./icons/icon/menu.svg', import.meta.url).href, opts), + minus: formatAssetUrl(new URL('./icons/icon/minus.svg', import.meta.url).href, opts), + mixed: formatAssetUrl(new URL('./icons/icon/mixed.svg', import.meta.url).href, opts), + pack: formatAssetUrl(new URL('./icons/icon/pack.svg', import.meta.url).href, opts), + page: formatAssetUrl(new URL('./icons/icon/page.svg', import.meta.url).href, opts), + plus: formatAssetUrl(new URL('./icons/icon/plus.svg', import.meta.url).href, opts), + 'question-mark-circle': formatAssetUrl( + new URL('./icons/icon/question-mark-circle.svg', import.meta.url).href, + opts + ), + 'question-mark': formatAssetUrl( + new URL('./icons/icon/question-mark.svg', import.meta.url).href, + opts + ), + redo: formatAssetUrl(new URL('./icons/icon/redo.svg', import.meta.url).href, opts), + 'reset-zoom': formatAssetUrl( + new URL('./icons/icon/reset-zoom.svg', import.meta.url).href, + opts + ), + 'rotate-ccw': formatAssetUrl( + new URL('./icons/icon/rotate-ccw.svg', import.meta.url).href, + opts + ), + 'rotate-cw': formatAssetUrl( + new URL('./icons/icon/rotate-cw.svg', import.meta.url).href, + opts + ), + ruler: formatAssetUrl(new URL('./icons/icon/ruler.svg', import.meta.url).href, opts), + search: formatAssetUrl(new URL('./icons/icon/search.svg', import.meta.url).href, opts), + 'send-backward': formatAssetUrl( + new URL('./icons/icon/send-backward.svg', import.meta.url).href, + opts + ), + 'send-to-back': formatAssetUrl( + new URL('./icons/icon/send-to-back.svg', import.meta.url).href, + opts + ), + 'settings-horizontal': formatAssetUrl( + new URL('./icons/icon/settings-horizontal.svg', import.meta.url).href, + opts + ), + 'settings-vertical-1': formatAssetUrl( + new URL('./icons/icon/settings-vertical-1.svg', import.meta.url).href, + opts + ), + 'settings-vertical': formatAssetUrl( + new URL('./icons/icon/settings-vertical.svg', import.meta.url).href, + opts + ), + 'share-1': formatAssetUrl(new URL('./icons/icon/share-1.svg', import.meta.url).href, opts), + 'share-2': formatAssetUrl(new URL('./icons/icon/share-2.svg', import.meta.url).href, opts), + 'size-extra-large': formatAssetUrl( + new URL('./icons/icon/size-extra-large.svg', import.meta.url).href, + opts + ), + 'size-large': formatAssetUrl( + new URL('./icons/icon/size-large.svg', import.meta.url).href, + opts + ), + 'size-medium': formatAssetUrl( + new URL('./icons/icon/size-medium.svg', import.meta.url).href, + opts + ), + 'size-small': formatAssetUrl( + new URL('./icons/icon/size-small.svg', import.meta.url).href, + opts + ), + 'spline-cubic': formatAssetUrl( + new URL('./icons/icon/spline-cubic.svg', import.meta.url).href, + opts + ), + 'spline-line': formatAssetUrl( + new URL('./icons/icon/spline-line.svg', import.meta.url).href, + opts + ), + 'stack-horizontal': formatAssetUrl( + new URL('./icons/icon/stack-horizontal.svg', import.meta.url).href, + opts + ), + 'stack-vertical': formatAssetUrl( + new URL('./icons/icon/stack-vertical.svg', import.meta.url).href, + opts + ), + 'stretch-horizontal': formatAssetUrl( + new URL('./icons/icon/stretch-horizontal.svg', import.meta.url).href, + opts + ), + 'stretch-vertical': formatAssetUrl( + new URL('./icons/icon/stretch-vertical.svg', import.meta.url).href, + opts + ), + 'text-align-center': formatAssetUrl( + new URL('./icons/icon/text-align-center.svg', import.meta.url).href, + opts + ), + 'text-align-justify': formatAssetUrl( + new URL('./icons/icon/text-align-justify.svg', import.meta.url).href, + opts + ), + 'text-align-left': formatAssetUrl( + new URL('./icons/icon/text-align-left.svg', import.meta.url).href, + opts + ), + 'text-align-right': formatAssetUrl( + new URL('./icons/icon/text-align-right.svg', import.meta.url).href, + opts + ), + 'tool-arrow': formatAssetUrl( + new URL('./icons/icon/tool-arrow.svg', import.meta.url).href, + opts + ), + 'tool-embed': formatAssetUrl( + new URL('./icons/icon/tool-embed.svg', import.meta.url).href, + opts + ), + 'tool-eraser': formatAssetUrl( + new URL('./icons/icon/tool-eraser.svg', import.meta.url).href, + opts + ), + 'tool-frame': formatAssetUrl( + new URL('./icons/icon/tool-frame.svg', import.meta.url).href, + opts + ), + 'tool-hand': formatAssetUrl( + new URL('./icons/icon/tool-hand.svg', import.meta.url).href, + opts + ), + 'tool-highlighter': formatAssetUrl( + new URL('./icons/icon/tool-highlighter.svg', import.meta.url).href, + opts + ), + 'tool-line': formatAssetUrl( + new URL('./icons/icon/tool-line.svg', import.meta.url).href, + opts + ), + 'tool-media': formatAssetUrl( + new URL('./icons/icon/tool-media.svg', import.meta.url).href, + opts + ), + 'tool-note': formatAssetUrl( + new URL('./icons/icon/tool-note.svg', import.meta.url).href, + opts + ), + 'tool-pencil': formatAssetUrl( + new URL('./icons/icon/tool-pencil.svg', import.meta.url).href, + opts + ), + 'tool-pointer': formatAssetUrl( + new URL('./icons/icon/tool-pointer.svg', import.meta.url).href, + opts + ), + 'tool-text': formatAssetUrl( + new URL('./icons/icon/tool-text.svg', import.meta.url).href, + opts + ), + trash: formatAssetUrl(new URL('./icons/icon/trash.svg', import.meta.url).href, opts), + 'triangle-down': formatAssetUrl( + new URL('./icons/icon/triangle-down.svg', import.meta.url).href, + opts + ), + 'triangle-up': formatAssetUrl( + new URL('./icons/icon/triangle-up.svg', import.meta.url).href, + opts + ), + twitter: formatAssetUrl(new URL('./icons/icon/twitter.svg', import.meta.url).href, opts), + undo: formatAssetUrl(new URL('./icons/icon/undo.svg', import.meta.url).href, opts), + ungroup: formatAssetUrl(new URL('./icons/icon/ungroup.svg', import.meta.url).href, opts), + 'unlock-small': formatAssetUrl( + new URL('./icons/icon/unlock-small.svg', import.meta.url).href, + opts + ), + unlock: formatAssetUrl(new URL('./icons/icon/unlock.svg', import.meta.url).href, opts), + visible: formatAssetUrl(new URL('./icons/icon/visible.svg', import.meta.url).href, opts), + 'warning-triangle': formatAssetUrl( + new URL('./icons/icon/warning-triangle.svg', import.meta.url).href, + opts + ), + 'zoom-in': formatAssetUrl(new URL('./icons/icon/zoom-in.svg', import.meta.url).href, opts), + 'zoom-out': formatAssetUrl(new URL('./icons/icon/zoom-out.svg', import.meta.url).href, opts), + }, + translations: { + ar: formatAssetUrl(new URL('./translations/ar.json', import.meta.url).href, opts), + ca: formatAssetUrl(new URL('./translations/ca.json', import.meta.url).href, opts), + da: formatAssetUrl(new URL('./translations/da.json', import.meta.url).href, opts), + de: formatAssetUrl(new URL('./translations/de.json', import.meta.url).href, opts), + en: formatAssetUrl(new URL('./translations/en.json', import.meta.url).href, opts), + es: formatAssetUrl(new URL('./translations/es.json', import.meta.url).href, opts), + fa: formatAssetUrl(new URL('./translations/fa.json', import.meta.url).href, opts), + fi: formatAssetUrl(new URL('./translations/fi.json', import.meta.url).href, opts), + fr: formatAssetUrl(new URL('./translations/fr.json', import.meta.url).href, opts), + gl: formatAssetUrl(new URL('./translations/gl.json', import.meta.url).href, opts), + he: formatAssetUrl(new URL('./translations/he.json', import.meta.url).href, opts), + 'hi-in': formatAssetUrl(new URL('./translations/hi-in.json', import.meta.url).href, opts), + hu: formatAssetUrl(new URL('./translations/hu.json', import.meta.url).href, opts), + it: formatAssetUrl(new URL('./translations/it.json', import.meta.url).href, opts), + ja: formatAssetUrl(new URL('./translations/ja.json', import.meta.url).href, opts), + 'ko-kr': formatAssetUrl(new URL('./translations/ko-kr.json', import.meta.url).href, opts), + ku: formatAssetUrl(new URL('./translations/ku.json', import.meta.url).href, opts), + languages: formatAssetUrl( + new URL('./translations/languages.json', import.meta.url).href, + opts + ), + main: formatAssetUrl(new URL('./translations/main.json', import.meta.url).href, opts), + my: formatAssetUrl(new URL('./translations/my.json', import.meta.url).href, opts), + ne: formatAssetUrl(new URL('./translations/ne.json', import.meta.url).href, opts), + no: formatAssetUrl(new URL('./translations/no.json', import.meta.url).href, opts), + pl: formatAssetUrl(new URL('./translations/pl.json', import.meta.url).href, opts), + 'pt-br': formatAssetUrl(new URL('./translations/pt-br.json', import.meta.url).href, opts), + 'pt-pt': formatAssetUrl(new URL('./translations/pt-pt.json', import.meta.url).href, opts), + ro: formatAssetUrl(new URL('./translations/ro.json', import.meta.url).href, opts), + ru: formatAssetUrl(new URL('./translations/ru.json', import.meta.url).href, opts), + sv: formatAssetUrl(new URL('./translations/sv.json', import.meta.url).href, opts), + te: formatAssetUrl(new URL('./translations/te.json', import.meta.url).href, opts), + th: formatAssetUrl(new URL('./translations/th.json', import.meta.url).href, opts), + tr: formatAssetUrl(new URL('./translations/tr.json', import.meta.url).href, opts), + uk: formatAssetUrl(new URL('./translations/uk.json', import.meta.url).href, opts), + vi: formatAssetUrl(new URL('./translations/vi.json', import.meta.url).href, opts), + 'zh-cn': formatAssetUrl(new URL('./translations/zh-cn.json', import.meta.url).href, opts), + 'zh-tw': formatAssetUrl(new URL('./translations/zh-tw.json', import.meta.url).href, opts), + }, + embedIcons: { + codepen: formatAssetUrl(new URL('./embed-icons/codepen.png', import.meta.url).href, opts), + codesandbox: formatAssetUrl( + new URL('./embed-icons/codesandbox.png', import.meta.url).href, + opts + ), + excalidraw: formatAssetUrl( + new URL('./embed-icons/excalidraw.png', import.meta.url).href, + opts + ), + felt: formatAssetUrl(new URL('./embed-icons/felt.png', import.meta.url).href, opts), + figma: formatAssetUrl(new URL('./embed-icons/figma.png', import.meta.url).href, opts), + github_gist: formatAssetUrl( + new URL('./embed-icons/github_gist.png', import.meta.url).href, + opts + ), + google_calendar: formatAssetUrl( + new URL('./embed-icons/google_calendar.png', import.meta.url).href, + opts + ), + google_maps: formatAssetUrl( + new URL('./embed-icons/google_maps.png', import.meta.url).href, + opts + ), + google_slides: formatAssetUrl( + new URL('./embed-icons/google_slides.png', import.meta.url).href, + opts + ), + observable: formatAssetUrl( + new URL('./embed-icons/observable.png', import.meta.url).href, + opts + ), + replit: formatAssetUrl(new URL('./embed-icons/replit.png', import.meta.url).href, opts), + scratch: formatAssetUrl(new URL('./embed-icons/scratch.png', import.meta.url).href, opts), + spotify: formatAssetUrl(new URL('./embed-icons/spotify.png', import.meta.url).href, opts), + tldraw: formatAssetUrl(new URL('./embed-icons/tldraw.png', import.meta.url).href, opts), + vimeo: formatAssetUrl(new URL('./embed-icons/vimeo.png', import.meta.url).href, opts), + youtube: formatAssetUrl(new URL('./embed-icons/youtube.png', import.meta.url).href, opts), + }, + } +} diff --git a/packages/tlschema/scripts/new-asset.js b/packages/tlschema/scripts/new-asset.js index 3097f6043..3b2a2fbac 100644 --- a/packages/tlschema/scripts/new-asset.js +++ b/packages/tlschema/scripts/new-asset.js @@ -1,4 +1,5 @@ // @ts-check +/* eslint-disable */ const kleur = require('kleur') const fs = require('fs') diff --git a/packages/tlschema/scripts/new-record.js b/packages/tlschema/scripts/new-record.js index e098a89f3..2a77a2645 100644 --- a/packages/tlschema/scripts/new-record.js +++ b/packages/tlschema/scripts/new-record.js @@ -1,4 +1,5 @@ // @ts-check +/* eslint-disable */ const kleur = require('kleur') const fs = require('fs') diff --git a/packages/tlschema/tsconfig.json b/packages/tlschema/tsconfig.json index 3a2a3436f..a9b030de2 100644 --- a/packages/tlschema/tsconfig.json +++ b/packages/tlschema/tsconfig.json @@ -1,6 +1,6 @@ { "extends": "../../config/tsconfig.base.json", - "include": ["src"], + "include": ["src", "scripts"], "exclude": ["node_modules", "docs", "dist", ".tsbuild*"], "compilerOptions": { "outDir": "./.tsbuild", diff --git a/scripts/check-scripts.ts b/scripts/check-scripts.ts index 4d826af64..802fe3b8a 100644 --- a/scripts/check-scripts.ts +++ b/scripts/check-scripts.ts @@ -56,7 +56,11 @@ const perPackageExceptions: Record string | undefin test: () => 'lazy inherit --passWithNoTests', }, '@tldraw/assets': { - test: () => 'lazy inherit --passWithNoTests', + test: () => undefined, + 'build-package': () => undefined, + 'build-api': () => undefined, + prepack: () => undefined, + postpack: () => undefined, }, } diff --git a/scripts/lib/file.ts b/scripts/lib/file.ts index 0a5f5b3e0..af4fbf069 100644 --- a/scripts/lib/file.ts +++ b/scripts/lib/file.ts @@ -27,17 +27,22 @@ export async function readFileIfExists(file: string) { } const prettierConfigPromise = prettier.resolveConfig(__dirname) -export async function writeTypescriptFile(filePath: string, code: string) { +export async function writeCodeFile( + generator: string, + language: 'typescript' | 'javascript', + filePath: string, + code: string +) { const formattedCode = prettier.format( ` - // This file is automatically generated by scripts/refresh-assets.ts. + // This file is automatically generated by ${generator}. // Do not edit manually. ${code} `, { ...(await prettierConfigPromise), - parser: 'typescript', + parser: language === 'typescript' ? 'typescript' : 'babel', } ) await writeStringFile(filePath, formattedCode) diff --git a/scripts/refresh-assets.ts b/scripts/refresh-assets.ts index e89f1b9cd..0d6b68a13 100644 --- a/scripts/refresh-assets.ts +++ b/scripts/refresh-assets.ts @@ -4,10 +4,10 @@ import { optimize } from 'svgo' import { BUBLIC_ROOT, readJsonIfExists, + writeCodeFile, writeFile, writeJsonFile, writeStringFile, - writeTypescriptFile, } from './lib/file' // We'll need to copy the assets into these folders @@ -88,7 +88,9 @@ async function copyIcons() { ${icons.map((icon) => JSON.stringify(icon.replace('.svg', ''))).join(', ')} ] as const` - await writeTypescriptFile( + await writeCodeFile( + 'scripts/refresh-assets.ts', + 'typescript', join(BUBLIC_ROOT, 'packages', 'ui', 'src', 'lib', 'icon-types.ts'), iconTypeFile ) @@ -207,11 +209,16 @@ async function copyTranslations() { /** @public */ export const LANGUAGES = ${JSON.stringify(languagesSource)} as const ` - await writeTypescriptFile(languagesFilePath, languagesFile) + await writeCodeFile('scripts/refresh-assets.ts', 'typescript', languagesFilePath, languagesFile) const schemaPath = join(BUBLIC_ROOT, 'packages', 'tlschema', 'src') const schemaLanguagesFilePath = join(schemaPath, 'languages.ts') - await writeTypescriptFile(schemaLanguagesFilePath, languagesFile) + await writeCodeFile( + 'scripts/refresh-assets.ts', + 'typescript', + schemaLanguagesFilePath, + languagesFile + ) // main.ts @@ -221,7 +228,12 @@ async function copyTranslations() { /** @internal */ export const DEFAULT_TRANSLATION = ${JSON.stringify(defaultTranslation)} ` - await writeTypescriptFile(defaultTranslationFilePath, defaultTranslationFile) + await writeCodeFile( + 'scripts/refresh-assets.ts', + 'typescript', + defaultTranslationFilePath, + defaultTranslationFile + ) // translationKeys.ts @@ -231,7 +243,12 @@ async function copyTranslations() { /** @public */ export type TLTranslationKey = ${translationKeys.join(' | ')} ` - await writeTypescriptFile(translationKeysFilePath, translationKeysFile) + await writeCodeFile( + 'scripts/refresh-assets.ts', + 'typescript', + translationKeysFilePath, + translationKeysFile + ) // add to the asset declaration file for (const item of itemsToCopy) { @@ -240,18 +257,45 @@ async function copyTranslations() { } } +const assetDeclarationFileCommon = ` + /** @typedef {string | { src: string }} AssetUrl */ + /** @typedef {{ baseUrl?: string } | ((assetUrl: string) => string)} AssetUrlOptions */ + + /** + * @param {AssetUrl} assetUrl + * @param {AssetUrlOptions} [format] + * @returns {string} + */ + function formatAssetUrl(assetUrl, format = {}) { + const assetUrlString = typeof assetUrl === 'string' ? assetUrl : assetUrl.src + + if (typeof format === 'function') return format(assetUrlString) + + const { baseUrl = '' } = format + + if (assetUrlString.startsWith('data:')) return assetUrlString + if (assetUrlString.match(/^https?:\\/\\//)) return assetUrlString + + return \`\${baseUrl.replace(/\\/$/, '')}/\${assetUrlString.replace(/^\\.?\\//, '')}\` + } +` + // 4. ASSET DECLARATION FILES async function writeUrlBasedAssetDeclarationFile() { - const assetDeclarationFilePath = join(BUBLIC_ROOT, 'packages', 'assets', 'src', 'urls.ts') + const assetDeclarationFilePath = join(BUBLIC_ROOT, 'packages', 'assets', 'urls.js') let assetDeclarationFile = ` // eslint-disable-next-line @typescript-eslint/triple-slash-reference - /// - import {formatAssetUrl, AssetUrlOptions} from './utils'; + /// + + ${assetDeclarationFileCommon} ` assetDeclarationFile += ` - /** @public */ - export function getBundlerAssetUrls(opts?: AssetUrlOptions) { + /** + * @param {AssetUrlOptions} [opts] + * @public + */ + export function getAssetUrlsByMetaUrl(opts) { return { ${Object.entries(collectedAssetUrls) .flatMap(([type, assets]) => [ @@ -259,28 +303,39 @@ async function writeUrlBasedAssetDeclarationFile() { ...Object.entries(assets).map( ([name, href]) => `${JSON.stringify(name)}: formatAssetUrl(new URL(${JSON.stringify( - '../' + href + './' + href )}, import.meta.url).href, opts),` ), '},', ]) .join('\n')} - } as const + } } ` - await writeTypescriptFile(assetDeclarationFilePath, assetDeclarationFile) + await writeCodeFile( + 'scripts/refresh-assets.ts', + 'javascript', + assetDeclarationFilePath, + assetDeclarationFile + ) + + await writeAssetDeclarationDTSFile('urls', 'getAssetUrlsByMetaUrl') } async function writeImportBasedAssetDeclarationFile(): Promise { let imports = ` // eslint-disable-next-line @typescript-eslint/triple-slash-reference - /// - import {formatAssetUrl, AssetUrlOptions} from './utils'; + /// ` let declarations = ` - /** @public */ - export function getBundlerAssetUrls(opts?: AssetUrlOptions) { + ${assetDeclarationFileCommon} + + /** + * @param {AssetUrlOptions} [opts] + * @public + */ + export function getAssetUrlsByImport(opts) { return { ` @@ -291,19 +346,50 @@ async function writeImportBasedAssetDeclarationFile(): Promise { .replace(/[^a-zA-Z0-9_]/g, '_') .replace(/_+/g, '_') .replace(/_(.)/g, (_, letter) => letter.toUpperCase()) - imports += `import ${variableName} from ${JSON.stringify('../' + href)};\n` + imports += `import ${variableName} from ${JSON.stringify('./' + href)};\n` declarations += `${JSON.stringify(name)}: formatAssetUrl(${variableName}, opts),\n` } declarations += '},\n' } declarations += ` - } as const + } } ` - const assetDeclarationFilePath = join(BUBLIC_ROOT, 'packages', 'assets', 'src', 'imports.ts') - await writeTypescriptFile(assetDeclarationFilePath, imports + declarations) + const assetDeclarationFilePath = join(BUBLIC_ROOT, 'packages', 'assets', 'imports.js') + await writeCodeFile( + 'scripts/refresh-assets.ts', + 'javascript', + assetDeclarationFilePath, + imports + declarations + ) + + await writeAssetDeclarationDTSFile('imports', 'getAssetUrlsByImport') +} + +async function writeAssetDeclarationDTSFile(fileName: string, functionName: string) { + let dts = ` + type AssetUrl = string | { src: string } + type AssetUrlOptions = { baseUrl?: string } | ((assetUrl: string) => string) + + export function ${functionName}(opts?: AssetUrlOptions): { + ` + + for (const [type, assets] of Object.entries(collectedAssetUrls)) { + dts += `${type}: {\n` + for (const name of Object.keys(assets)) { + dts += `${JSON.stringify(name)}: string,\n` + } + dts += '},\n' + } + + dts += ` + } + ` + + const assetDeclarationFilePath = join(BUBLIC_ROOT, 'packages', 'assets', `${fileName}.d.ts`) + await writeCodeFile('scripts/refresh-assets.ts', 'typescript', assetDeclarationFilePath, dts) } // --- RUN