719332d272
We currently serve icons in the form of 141 separate svg files. This is pretty inefficient: it results in 141 http requests each with its own overheads and costs. Each one is generally less than 1kb of data. This PR merges all of our icons into a single 44kb icon file. Each item in the svg has an ID, and we use the ID in the asset url to target the specific icon. This also fixes a lot of the icon preloading issues: because the icon file is already loaded, there's no extra request needed when panels open etc. I was messing with this whilst killing time before a late meeting so made a shitty overengineered code generator, dont at me ### Change type - [x] `improvement` ### Release notes - Serve icons more efficiently, and make sure they're still available if tldraw goes offline.
265 lines
14 KiB
JavaScript
265 lines
14 KiB
JavaScript
// This file is automatically generated by scripts/refresh-assets.ts.
|
|
// Do not edit manually. Or do, I'm a comment, not a cop.
|
|
|
|
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
|
|
/// <reference path="./modules.d.ts" />
|
|
import { formatAssetUrl } from './utils.js'
|
|
|
|
/**
|
|
* @param {AssetUrlOptions} [opts]
|
|
* @public
|
|
*/
|
|
export function getAssetUrlsByMetaUrl(opts) {
|
|
const iconsIcon0MergedSvg = formatAssetUrl(
|
|
new URL('./icons/icon/0_merged.svg', import.meta.url).href,
|
|
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-Tldrawish.woff2', import.meta.url).href,
|
|
opts
|
|
),
|
|
},
|
|
icons: {
|
|
'align-bottom': iconsIcon0MergedSvg + '#align-bottom',
|
|
'align-center-horizontal': iconsIcon0MergedSvg + '#align-center-horizontal',
|
|
'align-center-vertical': iconsIcon0MergedSvg + '#align-center-vertical',
|
|
'align-left': iconsIcon0MergedSvg + '#align-left',
|
|
'align-right': iconsIcon0MergedSvg + '#align-right',
|
|
'align-top': iconsIcon0MergedSvg + '#align-top',
|
|
'arrow-left': iconsIcon0MergedSvg + '#arrow-left',
|
|
'arrowhead-arrow': iconsIcon0MergedSvg + '#arrowhead-arrow',
|
|
'arrowhead-bar': iconsIcon0MergedSvg + '#arrowhead-bar',
|
|
'arrowhead-diamond': iconsIcon0MergedSvg + '#arrowhead-diamond',
|
|
'arrowhead-dot': iconsIcon0MergedSvg + '#arrowhead-dot',
|
|
'arrowhead-none': iconsIcon0MergedSvg + '#arrowhead-none',
|
|
'arrowhead-square': iconsIcon0MergedSvg + '#arrowhead-square',
|
|
'arrowhead-triangle-inverted': iconsIcon0MergedSvg + '#arrowhead-triangle-inverted',
|
|
'arrowhead-triangle': iconsIcon0MergedSvg + '#arrowhead-triangle',
|
|
blob: iconsIcon0MergedSvg + '#blob',
|
|
'bring-forward': iconsIcon0MergedSvg + '#bring-forward',
|
|
'bring-to-front': iconsIcon0MergedSvg + '#bring-to-front',
|
|
broken: iconsIcon0MergedSvg + '#broken',
|
|
'check-circle': iconsIcon0MergedSvg + '#check-circle',
|
|
check: iconsIcon0MergedSvg + '#check',
|
|
'chevron-down': iconsIcon0MergedSvg + '#chevron-down',
|
|
'chevron-left': iconsIcon0MergedSvg + '#chevron-left',
|
|
'chevron-right': iconsIcon0MergedSvg + '#chevron-right',
|
|
'chevron-up': iconsIcon0MergedSvg + '#chevron-up',
|
|
'chevrons-ne': iconsIcon0MergedSvg + '#chevrons-ne',
|
|
'chevrons-sw': iconsIcon0MergedSvg + '#chevrons-sw',
|
|
'clipboard-copied': iconsIcon0MergedSvg + '#clipboard-copied',
|
|
'clipboard-copy': iconsIcon0MergedSvg + '#clipboard-copy',
|
|
color: iconsIcon0MergedSvg + '#color',
|
|
'cross-2': iconsIcon0MergedSvg + '#cross-2',
|
|
'cross-circle': iconsIcon0MergedSvg + '#cross-circle',
|
|
'dash-dashed': iconsIcon0MergedSvg + '#dash-dashed',
|
|
'dash-dotted': iconsIcon0MergedSvg + '#dash-dotted',
|
|
'dash-draw': iconsIcon0MergedSvg + '#dash-draw',
|
|
'dash-solid': iconsIcon0MergedSvg + '#dash-solid',
|
|
disconnected: iconsIcon0MergedSvg + '#disconnected',
|
|
discord: iconsIcon0MergedSvg + '#discord',
|
|
'distribute-horizontal': iconsIcon0MergedSvg + '#distribute-horizontal',
|
|
'distribute-vertical': iconsIcon0MergedSvg + '#distribute-vertical',
|
|
dot: iconsIcon0MergedSvg + '#dot',
|
|
'dots-horizontal': iconsIcon0MergedSvg + '#dots-horizontal',
|
|
'dots-vertical': iconsIcon0MergedSvg + '#dots-vertical',
|
|
'drag-handle-dots': iconsIcon0MergedSvg + '#drag-handle-dots',
|
|
duplicate: iconsIcon0MergedSvg + '#duplicate',
|
|
edit: iconsIcon0MergedSvg + '#edit',
|
|
'external-link': iconsIcon0MergedSvg + '#external-link',
|
|
'fill-fill': iconsIcon0MergedSvg + '#fill-fill',
|
|
'fill-none': iconsIcon0MergedSvg + '#fill-none',
|
|
'fill-pattern': iconsIcon0MergedSvg + '#fill-pattern',
|
|
'fill-semi': iconsIcon0MergedSvg + '#fill-semi',
|
|
'fill-solid': iconsIcon0MergedSvg + '#fill-solid',
|
|
follow: iconsIcon0MergedSvg + '#follow',
|
|
following: iconsIcon0MergedSvg + '#following',
|
|
'font-draw': iconsIcon0MergedSvg + '#font-draw',
|
|
'font-mono': iconsIcon0MergedSvg + '#font-mono',
|
|
'font-sans': iconsIcon0MergedSvg + '#font-sans',
|
|
'font-serif': iconsIcon0MergedSvg + '#font-serif',
|
|
'geo-arrow-down': iconsIcon0MergedSvg + '#geo-arrow-down',
|
|
'geo-arrow-left': iconsIcon0MergedSvg + '#geo-arrow-left',
|
|
'geo-arrow-right': iconsIcon0MergedSvg + '#geo-arrow-right',
|
|
'geo-arrow-up': iconsIcon0MergedSvg + '#geo-arrow-up',
|
|
'geo-check-box': iconsIcon0MergedSvg + '#geo-check-box',
|
|
'geo-cloud': iconsIcon0MergedSvg + '#geo-cloud',
|
|
'geo-diamond': iconsIcon0MergedSvg + '#geo-diamond',
|
|
'geo-ellipse': iconsIcon0MergedSvg + '#geo-ellipse',
|
|
'geo-heart': iconsIcon0MergedSvg + '#geo-heart',
|
|
'geo-hexagon': iconsIcon0MergedSvg + '#geo-hexagon',
|
|
'geo-octagon': iconsIcon0MergedSvg + '#geo-octagon',
|
|
'geo-oval': iconsIcon0MergedSvg + '#geo-oval',
|
|
'geo-pentagon': iconsIcon0MergedSvg + '#geo-pentagon',
|
|
'geo-rectangle': iconsIcon0MergedSvg + '#geo-rectangle',
|
|
'geo-rhombus-2': iconsIcon0MergedSvg + '#geo-rhombus-2',
|
|
'geo-rhombus': iconsIcon0MergedSvg + '#geo-rhombus',
|
|
'geo-star': iconsIcon0MergedSvg + '#geo-star',
|
|
'geo-trapezoid': iconsIcon0MergedSvg + '#geo-trapezoid',
|
|
'geo-triangle': iconsIcon0MergedSvg + '#geo-triangle',
|
|
'geo-x-box': iconsIcon0MergedSvg + '#geo-x-box',
|
|
github: iconsIcon0MergedSvg + '#github',
|
|
group: iconsIcon0MergedSvg + '#group',
|
|
'horizontal-align-end': iconsIcon0MergedSvg + '#horizontal-align-end',
|
|
'horizontal-align-middle': iconsIcon0MergedSvg + '#horizontal-align-middle',
|
|
'horizontal-align-start': iconsIcon0MergedSvg + '#horizontal-align-start',
|
|
'info-circle': iconsIcon0MergedSvg + '#info-circle',
|
|
leading: iconsIcon0MergedSvg + '#leading',
|
|
link: iconsIcon0MergedSvg + '#link',
|
|
lock: iconsIcon0MergedSvg + '#lock',
|
|
menu: iconsIcon0MergedSvg + '#menu',
|
|
minus: iconsIcon0MergedSvg + '#minus',
|
|
mixed: iconsIcon0MergedSvg + '#mixed',
|
|
pack: iconsIcon0MergedSvg + '#pack',
|
|
plus: iconsIcon0MergedSvg + '#plus',
|
|
'question-mark-circle': iconsIcon0MergedSvg + '#question-mark-circle',
|
|
'question-mark': iconsIcon0MergedSvg + '#question-mark',
|
|
redo: iconsIcon0MergedSvg + '#redo',
|
|
'reset-zoom': iconsIcon0MergedSvg + '#reset-zoom',
|
|
'rotate-ccw': iconsIcon0MergedSvg + '#rotate-ccw',
|
|
'rotate-cw': iconsIcon0MergedSvg + '#rotate-cw',
|
|
'send-backward': iconsIcon0MergedSvg + '#send-backward',
|
|
'send-to-back': iconsIcon0MergedSvg + '#send-to-back',
|
|
'share-1': iconsIcon0MergedSvg + '#share-1',
|
|
'size-extra-large': iconsIcon0MergedSvg + '#size-extra-large',
|
|
'size-large': iconsIcon0MergedSvg + '#size-large',
|
|
'size-medium': iconsIcon0MergedSvg + '#size-medium',
|
|
'size-small': iconsIcon0MergedSvg + '#size-small',
|
|
'spline-cubic': iconsIcon0MergedSvg + '#spline-cubic',
|
|
'spline-line': iconsIcon0MergedSvg + '#spline-line',
|
|
'stack-horizontal': iconsIcon0MergedSvg + '#stack-horizontal',
|
|
'stack-vertical': iconsIcon0MergedSvg + '#stack-vertical',
|
|
'status-offline': iconsIcon0MergedSvg + '#status-offline',
|
|
'stretch-horizontal': iconsIcon0MergedSvg + '#stretch-horizontal',
|
|
'stretch-vertical': iconsIcon0MergedSvg + '#stretch-vertical',
|
|
'text-align-center': iconsIcon0MergedSvg + '#text-align-center',
|
|
'text-align-left': iconsIcon0MergedSvg + '#text-align-left',
|
|
'text-align-right': iconsIcon0MergedSvg + '#text-align-right',
|
|
'toggle-off': iconsIcon0MergedSvg + '#toggle-off',
|
|
'toggle-on': iconsIcon0MergedSvg + '#toggle-on',
|
|
'tool-arrow': iconsIcon0MergedSvg + '#tool-arrow',
|
|
'tool-eraser': iconsIcon0MergedSvg + '#tool-eraser',
|
|
'tool-frame': iconsIcon0MergedSvg + '#tool-frame',
|
|
'tool-hand': iconsIcon0MergedSvg + '#tool-hand',
|
|
'tool-highlight': iconsIcon0MergedSvg + '#tool-highlight',
|
|
'tool-laser': iconsIcon0MergedSvg + '#tool-laser',
|
|
'tool-line': iconsIcon0MergedSvg + '#tool-line',
|
|
'tool-media': iconsIcon0MergedSvg + '#tool-media',
|
|
'tool-note': iconsIcon0MergedSvg + '#tool-note',
|
|
'tool-pencil': iconsIcon0MergedSvg + '#tool-pencil',
|
|
'tool-pointer': iconsIcon0MergedSvg + '#tool-pointer',
|
|
'tool-screenshot': iconsIcon0MergedSvg + '#tool-screenshot',
|
|
'tool-text': iconsIcon0MergedSvg + '#tool-text',
|
|
trash: iconsIcon0MergedSvg + '#trash',
|
|
twitter: iconsIcon0MergedSvg + '#twitter',
|
|
undo: iconsIcon0MergedSvg + '#undo',
|
|
ungroup: iconsIcon0MergedSvg + '#ungroup',
|
|
unlock: iconsIcon0MergedSvg + '#unlock',
|
|
'vertical-align-end': iconsIcon0MergedSvg + '#vertical-align-end',
|
|
'vertical-align-middle': iconsIcon0MergedSvg + '#vertical-align-middle',
|
|
'vertical-align-start': iconsIcon0MergedSvg + '#vertical-align-start',
|
|
'warning-triangle': iconsIcon0MergedSvg + '#warning-triangle',
|
|
'zoom-in': iconsIcon0MergedSvg + '#zoom-in',
|
|
'zoom-out': iconsIcon0MergedSvg + '#zoom-out',
|
|
},
|
|
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),
|
|
cs: formatAssetUrl(new URL('./translations/cs.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),
|
|
hr: formatAssetUrl(new URL('./translations/hr.json', import.meta.url).href, opts),
|
|
hu: formatAssetUrl(new URL('./translations/hu.json', import.meta.url).href, opts),
|
|
id: formatAssetUrl(new URL('./translations/id.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),
|
|
sl: formatAssetUrl(new URL('./translations/sl.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
|
|
),
|
|
desmos: formatAssetUrl(new URL('./embed-icons/desmos.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),
|
|
val_town: formatAssetUrl(new URL('./embed-icons/val_town.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),
|
|
},
|
|
}
|
|
}
|