New vite-based examples app (#1226)

Right now this examples app looks exactly the same as our old examples
app, but there are a couple of tiny differences:
- We use `vite` instead of our own esbuild setup for development and
bundling
- We use `@tldraw/assets` for smart asset hashing instead of copying the
assets to a public folder

You can use `@tldraw/assets` with vite with a bunch of extra config, but
it (plus a bunch of other bundlers) also support a special syntax for
specifying asset urls: `new URL('./my/asset.svg',
import.meta.url).href`. This approach is more standards-complient, but
doesn't work with every bundler just yet. This diff also adds a
url-based version of `@tldraw/assets`, although I'd like to tweak the
entry point - right now you need to import from
`@tldraw/assets/lib/urls`, but i'd like to find a way to get this to
`@tldraw/assets/urls` or something at some point.

There are a couple other extra fixes in here:
- vscode builds were broken, they're fixed now!
- there's also a little tweak to the `getBundlerAssetUrls` API to allow
passing in a function instead of an object for URL formatting
- there are new internal-only functions for injecting asset urls
globally instead of passing them in via react props. this means we can
get the benefits of cacheable URLs without having to clutter our
examples by passing them in
This commit is contained in:
alex 2023-05-05 14:10:36 +01:00 committed by GitHub
parent c76dc1596f
commit 880f82e658
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 1303 additions and 1187 deletions

View file

@ -1,209 +0,0 @@
# @tldraw/example
## 2.0.0-alpha.11
### Patch Changes
- Updated dependencies
- @tldraw/tldraw@2.0.0-alpha.11
## 2.0.0-alpha.10
### Patch Changes
- Updated dependencies [4b4399b6e]
- @tldraw/tldraw@2.0.0-alpha.10
## 2.0.0-alpha.9
### Patch Changes
- Release day!
- Updated dependencies
- @tldraw/tldraw@2.0.0-alpha.9
## 2.0.0-alpha.8
### Patch Changes
- Updated dependencies [23dd81cfe]
- @tldraw/editor@2.0.0-alpha.8
- @tldraw/tlsync@2.0.0-alpha.8
- @tldraw/ui@2.0.0-alpha.8
- @tldraw/app-shared@2.0.0-alpha.8
## 2.0.0-alpha.7
### Patch Changes
- Bug fixes.
- Updated dependencies
- @tldraw/app-shared@2.0.0-alpha.7
- @tldraw/editor@2.0.0-alpha.7
- @tldraw/polyfills@2.0.0-alpha.7
- @tldraw/tlsync@2.0.0-alpha.7
- @tldraw/tlvalidate@2.0.0-alpha.7
- @tldraw/ui@2.0.0-alpha.7
- @tldraw/utils@2.0.0-alpha.7
## 2.0.0-alpha.6
### Patch Changes
- Add licenses.
- Updated dependencies
- @tldraw/app-shared@2.0.0-alpha.6
- @tldraw/editor@2.0.0-alpha.6
- @tldraw/polyfills@2.0.0-alpha.6
- @tldraw/tlsync@2.0.0-alpha.6
- @tldraw/tlvalidate@2.0.0-alpha.6
- @tldraw/ui@2.0.0-alpha.6
- @tldraw/utils@2.0.0-alpha.6
## 2.0.0-alpha.5
### Patch Changes
- Add CSS files to tldraw/tldraw.
- Updated dependencies
- @tldraw/app-shared@2.0.0-alpha.5
- @tldraw/editor@2.0.0-alpha.5
- @tldraw/polyfills@2.0.0-alpha.5
- @tldraw/tlsync@2.0.0-alpha.5
- @tldraw/tlvalidate@2.0.0-alpha.5
- @tldraw/ui@2.0.0-alpha.5
- @tldraw/utils@2.0.0-alpha.5
## 2.0.0-alpha.4
### Patch Changes
- Add children to tldraw/tldraw
- Updated dependencies
- @tldraw/app-shared@2.0.0-alpha.4
- @tldraw/editor@2.0.0-alpha.4
- @tldraw/polyfills@2.0.0-alpha.4
- @tldraw/tlsync@2.0.0-alpha.4
- @tldraw/tlvalidate@2.0.0-alpha.4
- @tldraw/ui@2.0.0-alpha.4
- @tldraw/utils@2.0.0-alpha.4
## 2.0.0-alpha.3
### Patch Changes
- Change permissions.
- Updated dependencies
- @tldraw/app-shared@2.0.0-alpha.3
- @tldraw/editor@2.0.0-alpha.3
- @tldraw/polyfills@2.0.0-alpha.3
- @tldraw/tlsync@2.0.0-alpha.3
- @tldraw/tlvalidate@2.0.0-alpha.3
- @tldraw/ui@2.0.0-alpha.3
- @tldraw/utils@2.0.0-alpha.3
## 2.0.0-alpha.2
### Patch Changes
- Add tldraw, editor
- Updated dependencies
- @tldraw/app-shared@2.0.0-alpha.2
- @tldraw/editor@2.0.0-alpha.2
- @tldraw/polyfills@2.0.0-alpha.2
- @tldraw/tlsync@2.0.0-alpha.2
- @tldraw/tlvalidate@2.0.0-alpha.2
- @tldraw/ui@2.0.0-alpha.2
- @tldraw/utils@2.0.0-alpha.2
## 0.1.0-alpha.11
### Patch Changes
- Fix stale reactors.
- Updated dependencies
- @tldraw/app-shared@0.1.0-alpha.11
- @tldraw/polyfills@0.1.0-alpha.11
- @tldraw/tldraw-beta@0.1.0-alpha.11
- @tldraw/tlsync@0.1.0-alpha.11
- @tldraw/tlvalidate@0.1.0-alpha.11
- @tldraw/ui@0.1.0-alpha.11
- @tldraw/utils@0.1.0-alpha.11
## 0.1.0-alpha.10
### Patch Changes
- Fix type export bug.
- Updated dependencies
- @tldraw/app-shared@0.1.0-alpha.10
- @tldraw/polyfills@0.1.0-alpha.10
- @tldraw/tldraw-beta@0.1.0-alpha.10
- @tldraw/tlsync@0.1.0-alpha.10
- @tldraw/tlvalidate@0.1.0-alpha.10
- @tldraw/ui@0.1.0-alpha.10
- @tldraw/utils@0.1.0-alpha.10
## 0.1.0-alpha.9
### Patch Changes
- Fix import bugs.
- Updated dependencies
- @tldraw/app-shared@0.1.0-alpha.9
- @tldraw/polyfills@0.1.0-alpha.9
- @tldraw/tldraw-beta@0.1.0-alpha.9
- @tldraw/tlsync@0.1.0-alpha.9
- @tldraw/tlvalidate@0.1.0-alpha.9
- @tldraw/ui@0.1.0-alpha.9
- @tldraw/utils@0.1.0-alpha.9
## 0.1.0-alpha.8
### Patch Changes
- Changes validation requirements, exports validation helpers.
- Updated dependencies
- @tldraw/app-shared@0.1.0-alpha.8
- @tldraw/polyfills@0.1.0-alpha.8
- @tldraw/tldraw-beta@0.1.0-alpha.8
- @tldraw/tlsync@0.1.0-alpha.8
- @tldraw/tlvalidate@0.1.0-alpha.8
- @tldraw/ui@0.1.0-alpha.8
- @tldraw/utils@0.1.0-alpha.8
## 0.1.0-alpha.7
### Patch Changes
- - Pre-pre-release update
- Updated dependencies
- @tldraw/app-shared@0.1.0-alpha.7
- @tldraw/polyfills@0.1.0-alpha.7
- @tldraw/tldraw-beta@0.1.0-alpha.7
- @tldraw/tlsync@0.1.0-alpha.7
- @tldraw/tlvalidate@0.1.0-alpha.7
- @tldraw/ui@0.1.0-alpha.7
- @tldraw/utils@0.1.0-alpha.7
## 0.0.2-alpha.1
### Patch Changes
- Fix error with HMR
- Updated dependencies
- @tldraw/polyfills@0.0.2-alpha.1
- @tldraw/tldraw-beta@0.0.2-alpha.1
- @tldraw/tlsync@0.0.2-alpha.1
- @tldraw/ui@0.0.2-alpha.1
## 0.0.2-alpha.0
### Patch Changes
- Initial release
- Updated dependencies
- @tldraw/polyfills@0.0.2-alpha.0
- @tldraw/tldraw-beta@0.0.2-alpha.0
- @tldraw/tlsync@0.0.2-alpha.0
- @tldraw/ui@0.0.2-alpha.0

View file

@ -1,190 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
Copyright 2023 tldraw GB Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

16
apps/examples/package.json Executable file → Normal file
View file

@ -27,22 +27,20 @@
"infinite"
],
"scripts": {
"dev": "concurrently --names \"tsc,esbuild\" \"yarn run -T tsx ../../scripts/typecheck.ts --build --watch --preserveWatchOutput\" \"node ./scripts/dev.mjs\"",
"dev": "vite",
"build": "vite build",
"lint": "yarn run -T tsx ../../scripts/lint.ts"
},
"devDependencies": {
"@types/ip": "^1.1.0",
"browserslist-to-esbuild": "^1.2.0",
"concurrently": "^7.4.0",
"esbuild": "^0.16.7",
"ip": "^1.1.8",
"@babel/plugin-proposal-decorators": "^7.21.0",
"lazyrepo": "0.0.0-alpha.26",
"node-forge": "^1.3.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"vite": "^4.3.4"
},
"dependencies": {
"@tldraw/assets": "workspace:*",
"@tldraw/tldraw": "workspace:*",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.9.0",
"signia": "0.1.4",
"signia-react": "0.1.4"

View file

@ -1,129 +0,0 @@
// @ts-nocheck
/* eslint-disable */
import browserslist from 'browserslist-to-esbuild'
import esbuild from 'esbuild'
import { createServer, request } from 'http'
import ip from 'ip'
import chalk from 'kleur'
import * as url from 'url'
import fs from 'fs'
const LOG_REQUEST_PATHS = false
const { log } = console
const dirname = url.fileURLToPath(new URL('.', import.meta.url))
const PORT = 5420
const SSL_PORT = 5421
const OUT_DIR = dirname + '/../www/'
/** @type {{ write(data: any): any }[]} */
const clients = []
async function main() {
const isAnalyzeEnabled = process.env.ANALYZE === 'true'
const result = await esbuild.build({
entryPoints: ['src/index.tsx'],
outdir: OUT_DIR,
bundle: true,
minify: false,
sourcemap: true,
incremental: true,
format: 'cjs',
external: ['*.woff'],
target: browserslist(['defaults']),
metafile: isAnalyzeEnabled,
define: {
process: '{ "env": { "NODE_ENV": "development"} }',
},
loader: {
'.woff2': 'file',
'.svg': 'file',
'.json': 'file',
'.png': 'file',
},
watch: {
onRebuild(error) {
log('rebuilt')
if (error) {
log(error)
}
clients.forEach((res) => res.write('data: update\n\n'))
clients.length = 0
},
},
})
if (isAnalyzeEnabled) {
await fs.promises.writeFile('build.esbuild.json', JSON.stringify(result.metafile));
console.log(await esbuild.analyzeMetafile(result.metafile, {
verbose: true,
}))
}
esbuild.serve({ servedir: OUT_DIR, port: 8009 }, {}).then(({ host, port: esbuildPort }) => {
const handler = async (req, res) => {
const { url, method, headers } = req
if (req.url === '/esbuild')
return clients.push(
res.writeHead(200, {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache',
Connection: 'keep-alive',
})
)
/** @param {string} url */
function forwardRequest(url) {
const path = (url?.split('/').pop()?.indexOf('.') ?? -1) > -1 ? url : `/index.html` //for PWA with router
if (LOG_REQUEST_PATHS) {
console.log('[%s]=', method, path)
}
const req2 = request(
{ hostname: host, port: esbuildPort, path, method, headers },
(prxRes) => {
if (url === '/index.js') {
const jsReloadCode =
' (() => new EventSource("/esbuild").onmessage = () => location.reload())();'
const newHeaders = {
...prxRes.headers,
'content-length':
parseInt(prxRes.headers['content-length'] ?? '0', 10) + jsReloadCode.length,
}
res.writeHead(prxRes.statusCode ?? 0, newHeaders)
res.write(jsReloadCode)
} else {
res.writeHead(prxRes.statusCode ?? 0, prxRes.headers)
}
prxRes.pipe(res, { end: true })
}
)
req.pipe(req2, { end: true })
}
forwardRequest(url ?? '/')
}
const server = createServer(handler)
server.on('error', function (e) {
// Handle your error here
console.log(e)
})
server.listen(PORT, () => {
log(`Running on:\n`)
log(chalk.bold().cyan(` http://localhost:${PORT}`))
log(`\nNetwork:\n`)
log(chalk.bold().cyan(` http://${ip.address()}:${PORT}`))
})
})
}
main()

View file

@ -97,9 +97,9 @@ class CardUtil extends TLBoxUtil<CardShape> {
// Because the card tool can be just a rectangle, we can extend the
// TLBoxTool class. This gives us a lot of functionality for free.
export class CardTool extends TLBoxTool {
static id = 'card'
static initial = 'idle'
shapeType = 'card'
static override id = 'card'
static override initial = 'idle'
override shapeType = 'card'
}
// Finally, collect the custom tools and shapes into a config object

View file

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

View file

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="./icons/tldraw.svg" />
<link rel="apple-touch-icon" sizes="180x180" href="./icons/apple-touch-icon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<title>tldraw examples</title>
<link rel="stylesheet" href="./styles.css" />
</head>
<body>
<div id="root"></div>
<script type="module" src="./index.tsx"></script>
</body>
</html>

View file

@ -1,4 +1,10 @@
import { DefaultErrorFallback, ErrorBoundary } from '@tldraw/tldraw'
import { getBundlerAssetUrls } from '@tldraw/assets/src/urls'
import {
DefaultErrorFallback,
ErrorBoundary,
setDefaultEditorAssetUrls,
setDefaultUiAssetUrls,
} from '@tldraw/tldraw'
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { RouterProvider, createBrowserRouter } from 'react-router-dom'
@ -12,9 +18,18 @@ import ExampleScroll from './6-scroll/ScrollExample'
import ExampleMultiple from './7-multiple/MultipleExample'
import ErrorBoundaryExample from './8-error-boundaries/ErrorBoundaryExample'
import HideUiExample from './9-hide-ui/HideUiExample'
import './index.css'
const router = createBrowserRouter([
// 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()
setDefaultEditorAssetUrls(assetUrls)
setDefaultUiAssetUrls(assetUrls)
type Example = {
path: string
element: JSX.Element
}
export const allExamples: Example[] = [
{
path: '/',
element: <ExampleBasic />,
@ -55,7 +70,9 @@ const router = createBrowserRouter([
path: '/custom-components',
element: <CustomComponentsExample />,
},
])
]
const router = createBrowserRouter(allExamples)
const rootElement = document.getElementById('root')
const root = createRoot(rootElement!)

30
apps/examples/tsconfig.json Executable file → Normal file
View file

@ -1,29 +1,9 @@
{
"extends": "../../config/tsconfig.base.json",
"include": ["src", "./vite.config.ts"],
"exclude": ["node_modules", "dist", "**/*.css", ".tsbuild*", "./scripts/legacy-translations"],
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": true,
"checkJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"removeComments": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"noEmit": true,
"jsx": "react-jsx",
"incremental": true,
"baseUrl": ".",
"composite": true,
"sourceMap": false,
"importHelpers": false,
"skipDefaultLibCheck": true,
"experimentalDecorators": true
"outDir": "./.tsbuild"
},
"include": ["src", "scripts"],
"references": [{ "path": "../../packages/tldraw" }]
"references": [{ "path": "../../packages/tldraw" }, { "path": "../../packages/assets" }]
}

13
apps/examples/vercel.json Normal file
View file

@ -0,0 +1,13 @@
{
"headers": [
{
"source": "/assets/(.*)",
"headers": [
{
"key": "Cache-Control",
"value": "public,max-age=31536000,immutable"
}
]
}
]
}

View file

@ -0,0 +1,15 @@
import path from 'path'
import { defineConfig } from 'vite'
export default defineConfig({
root: path.join(__dirname, 'src'),
publicDir: path.join(__dirname, 'public'),
build: {
outDir: path.join(__dirname, 'dist'),
assetsInlineLimit: 0,
},
server: {
port: 5420,
},
clearScreen: false,
})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 281 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 425 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

View file

@ -1,16 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/tldraw.svg" />
<link id="manifest" rel="manifest" href="/manifest.json" />
<link rel="apple-touch-icon" sizes="180x180" href="/icons/apple-touch-icon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<title>tldraw</title>
<script type="module" crossorigin src="/index.js"></script>
<link rel="stylesheet" href="/index.css" />
</head>
<body>
<div id="root"></div>
</body>
</html>

View file

@ -1,35 +0,0 @@
{
"name": "tldraw",
"short_name": "tldraw",
"icons": [
{
"src": "/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "any"
},
{
"src": "/android-chrome-maskable-512x512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "any maskable"
},
{
"src": "/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "any"
},
{
"src": "/android-chrome-maskable-192x192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "any maskable"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"start_url": "/",
"display": "standalone",
"orientation": "portrait"
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

View file

@ -29,7 +29,7 @@
"scripts": {
"build": "yarn run -T tsx scripts/build.ts",
"build:vscode-editor": "yarn run -T tsx scripts/build.ts",
"dev-vscode": "yarn run -T tsx scripts/dev.ts",
"dev": "yarn run -T tsx scripts/dev.ts",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
"lint": "yarn run -T tsx ../../../scripts/lint.ts"
},

View file

@ -122,7 +122,7 @@
"dependencies": false
},
"scripts": {
"dev-vscode": "tsx scripts/dev.ts",
"dev": "tsx scripts/dev.ts",
"build": "cd ../editor && yarn build && cd ../extension && tsx scripts/build.ts",
"web": "vscode-test-web --browserType=chromium --extensionDevelopmentPath=.",
"package": "yarn build && tsx scripts/package.ts",

View file

@ -0,0 +1,440 @@
// This file is automatically generated by scripts/refresh-assets.ts.
// Do not edit manually.
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="../modules.d.ts" />
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 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-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
}

View file

@ -1,440 +1 @@
// This file is automatically generated by scripts/refresh-assets.ts.
// Do not edit manually.
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="../modules.d.ts" />
import codepenEmbedIconUrl from '../embed-icons/codepen.png'
import codesandboxEmbedIconUrl from '../embed-icons/codesandbox.png'
import excalidrawEmbedIconUrl from '../embed-icons/excalidraw.png'
import feltEmbedIconUrl from '../embed-icons/felt.png'
import figmaEmbedIconUrl from '../embed-icons/figma.png'
import githubGistEmbedIconUrl from '../embed-icons/github_gist.png'
import googleCalendarEmbedIconUrl from '../embed-icons/google_calendar.png'
import googleMapsEmbedIconUrl from '../embed-icons/google_maps.png'
import googleSlidesEmbedIconUrl from '../embed-icons/google_slides.png'
import observableEmbedIconUrl from '../embed-icons/observable.png'
import replitEmbedIconUrl from '../embed-icons/replit.png'
import scratchEmbedIconUrl from '../embed-icons/scratch.png'
import spotifyEmbedIconUrl from '../embed-icons/spotify.png'
import tldrawEmbedIconUrl from '../embed-icons/tldraw.png'
import vimeoEmbedIconUrl from '../embed-icons/vimeo.png'
import youtubeEmbedIconUrl from '../embed-icons/youtube.png'
import monospaceFontUrl from '../fonts/IBMPlexMono-Medium.woff2'
import sansSerifFontUrl from '../fonts/IBMPlexSans-Medium.woff2'
import serifFontUrl from '../fonts/IBMPlexSerif-Medium.woff2'
import drawFontUrl from '../fonts/Shantell_Sans-Normal-SemiBold.woff2'
import alignBottomCenterIconUrl from '../icons/icon/align-bottom-center.svg'
import alignBottomLeftIconUrl from '../icons/icon/align-bottom-left.svg'
import alignBottomRightIconUrl from '../icons/icon/align-bottom-right.svg'
import alignBottomIconUrl from '../icons/icon/align-bottom.svg'
import alignCenterCenterIconUrl from '../icons/icon/align-center-center.svg'
import alignCenterHorizontalIconUrl from '../icons/icon/align-center-horizontal.svg'
import alignCenterLeftIconUrl from '../icons/icon/align-center-left.svg'
import alignCenterRightIconUrl from '../icons/icon/align-center-right.svg'
import alignCenterVerticalIconUrl from '../icons/icon/align-center-vertical.svg'
import alignLeftIconUrl from '../icons/icon/align-left.svg'
import alignRightIconUrl from '../icons/icon/align-right.svg'
import alignTopCenterIconUrl from '../icons/icon/align-top-center.svg'
import alignTopLeftIconUrl from '../icons/icon/align-top-left.svg'
import alignTopRightIconUrl from '../icons/icon/align-top-right.svg'
import alignTopIconUrl from '../icons/icon/align-top.svg'
import arrowLeftIconUrl from '../icons/icon/arrow-left.svg'
import arrowheadArrowIconUrl from '../icons/icon/arrowhead-arrow.svg'
import arrowheadBarIconUrl from '../icons/icon/arrowhead-bar.svg'
import arrowheadDiamondIconUrl from '../icons/icon/arrowhead-diamond.svg'
import arrowheadDotIconUrl from '../icons/icon/arrowhead-dot.svg'
import arrowheadNoneIconUrl from '../icons/icon/arrowhead-none.svg'
import arrowheadSquareIconUrl from '../icons/icon/arrowhead-square.svg'
import arrowheadTriangleInvertedIconUrl from '../icons/icon/arrowhead-triangle-inverted.svg'
import arrowheadTriangleIconUrl from '../icons/icon/arrowhead-triangle.svg'
import aspectRatioIconUrl from '../icons/icon/aspect-ratio.svg'
import avatarIconUrl from '../icons/icon/avatar.svg'
import blobIconUrl from '../icons/icon/blob.svg'
import bringForwardIconUrl from '../icons/icon/bring-forward.svg'
import bringToFrontIconUrl from '../icons/icon/bring-to-front.svg'
import checkIconUrl from '../icons/icon/check.svg'
import checkboxCheckedIconUrl from '../icons/icon/checkbox-checked.svg'
import checkboxEmptyIconUrl from '../icons/icon/checkbox-empty.svg'
import chevronDownIconUrl from '../icons/icon/chevron-down.svg'
import chevronLeftIconUrl from '../icons/icon/chevron-left.svg'
import chevronRightIconUrl from '../icons/icon/chevron-right.svg'
import chevronUpIconUrl from '../icons/icon/chevron-up.svg'
import chevronsNeIconUrl from '../icons/icon/chevrons-ne.svg'
import chevronsSwIconUrl from '../icons/icon/chevrons-sw.svg'
import clipboardCopyIconUrl from '../icons/icon/clipboard-copy.svg'
import codeIconUrl from '../icons/icon/code.svg'
import collabIconUrl from '../icons/icon/collab.svg'
import colorIconUrl from '../icons/icon/color.svg'
import commentIconUrl from '../icons/icon/comment.svg'
import cross2IconUrl from '../icons/icon/cross-2.svg'
import crossIconUrl from '../icons/icon/cross.svg'
import dashDashedIconUrl from '../icons/icon/dash-dashed.svg'
import dashDottedIconUrl from '../icons/icon/dash-dotted.svg'
import dashDrawIconUrl from '../icons/icon/dash-draw.svg'
import dashSolidIconUrl from '../icons/icon/dash-solid.svg'
import discordIconUrl from '../icons/icon/discord.svg'
import distributeHorizontalIconUrl from '../icons/icon/distribute-horizontal.svg'
import distributeVerticalIconUrl from '../icons/icon/distribute-vertical.svg'
import dotIconUrl from '../icons/icon/dot.svg'
import dotsHorizontalIconUrl from '../icons/icon/dots-horizontal.svg'
import dotsVerticalIconUrl from '../icons/icon/dots-vertical.svg'
import dragHandleDotsIconUrl from '../icons/icon/drag-handle-dots.svg'
import duplicateIconUrl from '../icons/icon/duplicate.svg'
import editIconUrl from '../icons/icon/edit.svg'
import externalLinkIconUrl from '../icons/icon/external-link.svg'
import fileIconUrl from '../icons/icon/file.svg'
import fillNoneIconUrl from '../icons/icon/fill-none.svg'
import fillPatternIconUrl from '../icons/icon/fill-pattern.svg'
import fillSemiIconUrl from '../icons/icon/fill-semi.svg'
import fillSolidIconUrl from '../icons/icon/fill-solid.svg'
import followIconUrl from '../icons/icon/follow.svg'
import followingIconUrl from '../icons/icon/following.svg'
import fontDrawIconUrl from '../icons/icon/font-draw.svg'
import fontMonoIconUrl from '../icons/icon/font-mono.svg'
import fontSansIconUrl from '../icons/icon/font-sans.svg'
import fontSerifIconUrl from '../icons/icon/font-serif.svg'
import geoArrowDownIconUrl from '../icons/icon/geo-arrow-down.svg'
import geoArrowLeftIconUrl from '../icons/icon/geo-arrow-left.svg'
import geoArrowRightIconUrl from '../icons/icon/geo-arrow-right.svg'
import geoArrowUpIconUrl from '../icons/icon/geo-arrow-up.svg'
import geoDiamondIconUrl from '../icons/icon/geo-diamond.svg'
import geoEllipseIconUrl from '../icons/icon/geo-ellipse.svg'
import geoHexagonIconUrl from '../icons/icon/geo-hexagon.svg'
import geoOctagonIconUrl from '../icons/icon/geo-octagon.svg'
import geoOvalIconUrl from '../icons/icon/geo-oval.svg'
import geoPentagonIconUrl from '../icons/icon/geo-pentagon.svg'
import geoRectangleIconUrl from '../icons/icon/geo-rectangle.svg'
import geoRhombus2IconUrl from '../icons/icon/geo-rhombus-2.svg'
import geoRhombusIconUrl from '../icons/icon/geo-rhombus.svg'
import geoStarIconUrl from '../icons/icon/geo-star.svg'
import geoTrapezoidIconUrl from '../icons/icon/geo-trapezoid.svg'
import geoTriangleIconUrl from '../icons/icon/geo-triangle.svg'
import geoXBoxIconUrl from '../icons/icon/geo-x-box.svg'
import githubIconUrl from '../icons/icon/github.svg'
import groupIconUrl from '../icons/icon/group.svg'
import hiddenIconUrl from '../icons/icon/hidden.svg'
import imageIconUrl from '../icons/icon/image.svg'
import infoCircleIconUrl from '../icons/icon/info-circle.svg'
import leadingIconUrl from '../icons/icon/leading.svg'
import linkIconUrl from '../icons/icon/link.svg'
import lockSmallIconUrl from '../icons/icon/lock-small.svg'
import lockIconUrl from '../icons/icon/lock.svg'
import menuIconUrl from '../icons/icon/menu.svg'
import minusIconUrl from '../icons/icon/minus.svg'
import mixedIconUrl from '../icons/icon/mixed.svg'
import packIconUrl from '../icons/icon/pack.svg'
import pageIconUrl from '../icons/icon/page.svg'
import plusIconUrl from '../icons/icon/plus.svg'
import questionMarkCircleIconUrl from '../icons/icon/question-mark-circle.svg'
import questionMarkIconUrl from '../icons/icon/question-mark.svg'
import redoIconUrl from '../icons/icon/redo.svg'
import resetZoomIconUrl from '../icons/icon/reset-zoom.svg'
import rotateCcwIconUrl from '../icons/icon/rotate-ccw.svg'
import rotateCwIconUrl from '../icons/icon/rotate-cw.svg'
import rulerIconUrl from '../icons/icon/ruler.svg'
import searchIconUrl from '../icons/icon/search.svg'
import sendBackwardIconUrl from '../icons/icon/send-backward.svg'
import sendToBackIconUrl from '../icons/icon/send-to-back.svg'
import settingsHorizontalIconUrl from '../icons/icon/settings-horizontal.svg'
import settingsVertical1IconUrl from '../icons/icon/settings-vertical-1.svg'
import settingsVerticalIconUrl from '../icons/icon/settings-vertical.svg'
import share1IconUrl from '../icons/icon/share-1.svg'
import share2IconUrl from '../icons/icon/share-2.svg'
import sizeExtraLargeIconUrl from '../icons/icon/size-extra-large.svg'
import sizeLargeIconUrl from '../icons/icon/size-large.svg'
import sizeMediumIconUrl from '../icons/icon/size-medium.svg'
import sizeSmallIconUrl from '../icons/icon/size-small.svg'
import splineCubicIconUrl from '../icons/icon/spline-cubic.svg'
import splineLineIconUrl from '../icons/icon/spline-line.svg'
import stackHorizontalIconUrl from '../icons/icon/stack-horizontal.svg'
import stackVerticalIconUrl from '../icons/icon/stack-vertical.svg'
import stretchHorizontalIconUrl from '../icons/icon/stretch-horizontal.svg'
import stretchVerticalIconUrl from '../icons/icon/stretch-vertical.svg'
import textAlignCenterIconUrl from '../icons/icon/text-align-center.svg'
import textAlignJustifyIconUrl from '../icons/icon/text-align-justify.svg'
import textAlignLeftIconUrl from '../icons/icon/text-align-left.svg'
import textAlignRightIconUrl from '../icons/icon/text-align-right.svg'
import toolArrowIconUrl from '../icons/icon/tool-arrow.svg'
import toolEmbedIconUrl from '../icons/icon/tool-embed.svg'
import toolEraserIconUrl from '../icons/icon/tool-eraser.svg'
import toolFrameIconUrl from '../icons/icon/tool-frame.svg'
import toolHandIconUrl from '../icons/icon/tool-hand.svg'
import toolHighlighterIconUrl from '../icons/icon/tool-highlighter.svg'
import toolLineIconUrl from '../icons/icon/tool-line.svg'
import toolMediaIconUrl from '../icons/icon/tool-media.svg'
import toolNoteIconUrl from '../icons/icon/tool-note.svg'
import toolPencilIconUrl from '../icons/icon/tool-pencil.svg'
import toolPointerIconUrl from '../icons/icon/tool-pointer.svg'
import toolTextIconUrl from '../icons/icon/tool-text.svg'
import trashIconUrl from '../icons/icon/trash.svg'
import triangleDownIconUrl from '../icons/icon/triangle-down.svg'
import triangleUpIconUrl from '../icons/icon/triangle-up.svg'
import twitterIconUrl from '../icons/icon/twitter.svg'
import undoIconUrl from '../icons/icon/undo.svg'
import ungroupIconUrl from '../icons/icon/ungroup.svg'
import unlockSmallIconUrl from '../icons/icon/unlock-small.svg'
import unlockIconUrl from '../icons/icon/unlock.svg'
import visibleIconUrl from '../icons/icon/visible.svg'
import warningTriangleIconUrl from '../icons/icon/warning-triangle.svg'
import zoomInIconUrl from '../icons/icon/zoom-in.svg'
import zoomOutIconUrl from '../icons/icon/zoom-out.svg'
import arTranslationUrl from '../translations/ar.json'
import caTranslationUrl from '../translations/ca.json'
import daTranslationUrl from '../translations/da.json'
import deTranslationUrl from '../translations/de.json'
import enTranslationUrl from '../translations/en.json'
import esTranslationUrl from '../translations/es.json'
import faTranslationUrl from '../translations/fa.json'
import fiTranslationUrl from '../translations/fi.json'
import frTranslationUrl from '../translations/fr.json'
import glTranslationUrl from '../translations/gl.json'
import heTranslationUrl from '../translations/he.json'
import hiInTranslationUrl from '../translations/hi-in.json'
import huTranslationUrl from '../translations/hu.json'
import itTranslationUrl from '../translations/it.json'
import jaTranslationUrl from '../translations/ja.json'
import koKrTranslationUrl from '../translations/ko-kr.json'
import kuTranslationUrl from '../translations/ku.json'
import languagesTranslationUrl from '../translations/languages.json'
import mainTranslationUrl from '../translations/main.json'
import myTranslationUrl from '../translations/my.json'
import neTranslationUrl from '../translations/ne.json'
import noTranslationUrl from '../translations/no.json'
import plTranslationUrl from '../translations/pl.json'
import ptBrTranslationUrl from '../translations/pt-br.json'
import ptPtTranslationUrl from '../translations/pt-pt.json'
import roTranslationUrl from '../translations/ro.json'
import ruTranslationUrl from '../translations/ru.json'
import svTranslationUrl from '../translations/sv.json'
import teTranslationUrl from '../translations/te.json'
import thTranslationUrl from '../translations/th.json'
import trTranslationUrl from '../translations/tr.json'
import ukTranslationUrl from '../translations/uk.json'
import viTranslationUrl from '../translations/vi.json'
import zhCnTranslationUrl from '../translations/zh-cn.json'
import zhTwTranslationUrl from '../translations/zh-tw.json'
import { AssetUrlOptions, formatAssetUrl } from './utils'
/** @public */
export function getBundlerAssetUrls(opts?: AssetUrlOptions) {
return {
fonts: {
monospace: formatAssetUrl(monospaceFontUrl, opts),
sansSerif: formatAssetUrl(sansSerifFontUrl, opts),
serif: formatAssetUrl(serifFontUrl, opts),
draw: formatAssetUrl(drawFontUrl, opts),
},
icons: {
'align-bottom-center': formatAssetUrl(alignBottomCenterIconUrl, opts),
'align-bottom-left': formatAssetUrl(alignBottomLeftIconUrl, opts),
'align-bottom-right': formatAssetUrl(alignBottomRightIconUrl, opts),
'align-bottom': formatAssetUrl(alignBottomIconUrl, opts),
'align-center-center': formatAssetUrl(alignCenterCenterIconUrl, opts),
'align-center-horizontal': formatAssetUrl(alignCenterHorizontalIconUrl, opts),
'align-center-left': formatAssetUrl(alignCenterLeftIconUrl, opts),
'align-center-right': formatAssetUrl(alignCenterRightIconUrl, opts),
'align-center-vertical': formatAssetUrl(alignCenterVerticalIconUrl, opts),
'align-left': formatAssetUrl(alignLeftIconUrl, opts),
'align-right': formatAssetUrl(alignRightIconUrl, opts),
'align-top-center': formatAssetUrl(alignTopCenterIconUrl, opts),
'align-top-left': formatAssetUrl(alignTopLeftIconUrl, opts),
'align-top-right': formatAssetUrl(alignTopRightIconUrl, opts),
'align-top': formatAssetUrl(alignTopIconUrl, opts),
'arrow-left': formatAssetUrl(arrowLeftIconUrl, opts),
'arrowhead-arrow': formatAssetUrl(arrowheadArrowIconUrl, opts),
'arrowhead-bar': formatAssetUrl(arrowheadBarIconUrl, opts),
'arrowhead-diamond': formatAssetUrl(arrowheadDiamondIconUrl, opts),
'arrowhead-dot': formatAssetUrl(arrowheadDotIconUrl, opts),
'arrowhead-none': formatAssetUrl(arrowheadNoneIconUrl, opts),
'arrowhead-square': formatAssetUrl(arrowheadSquareIconUrl, opts),
'arrowhead-triangle-inverted': formatAssetUrl(arrowheadTriangleInvertedIconUrl, opts),
'arrowhead-triangle': formatAssetUrl(arrowheadTriangleIconUrl, opts),
'aspect-ratio': formatAssetUrl(aspectRatioIconUrl, opts),
avatar: formatAssetUrl(avatarIconUrl, opts),
blob: formatAssetUrl(blobIconUrl, opts),
'bring-forward': formatAssetUrl(bringForwardIconUrl, opts),
'bring-to-front': formatAssetUrl(bringToFrontIconUrl, opts),
check: formatAssetUrl(checkIconUrl, opts),
'checkbox-checked': formatAssetUrl(checkboxCheckedIconUrl, opts),
'checkbox-empty': formatAssetUrl(checkboxEmptyIconUrl, opts),
'chevron-down': formatAssetUrl(chevronDownIconUrl, opts),
'chevron-left': formatAssetUrl(chevronLeftIconUrl, opts),
'chevron-right': formatAssetUrl(chevronRightIconUrl, opts),
'chevron-up': formatAssetUrl(chevronUpIconUrl, opts),
'chevrons-ne': formatAssetUrl(chevronsNeIconUrl, opts),
'chevrons-sw': formatAssetUrl(chevronsSwIconUrl, opts),
'clipboard-copy': formatAssetUrl(clipboardCopyIconUrl, opts),
code: formatAssetUrl(codeIconUrl, opts),
collab: formatAssetUrl(collabIconUrl, opts),
color: formatAssetUrl(colorIconUrl, opts),
comment: formatAssetUrl(commentIconUrl, opts),
'cross-2': formatAssetUrl(cross2IconUrl, opts),
cross: formatAssetUrl(crossIconUrl, opts),
'dash-dashed': formatAssetUrl(dashDashedIconUrl, opts),
'dash-dotted': formatAssetUrl(dashDottedIconUrl, opts),
'dash-draw': formatAssetUrl(dashDrawIconUrl, opts),
'dash-solid': formatAssetUrl(dashSolidIconUrl, opts),
discord: formatAssetUrl(discordIconUrl, opts),
'distribute-horizontal': formatAssetUrl(distributeHorizontalIconUrl, opts),
'distribute-vertical': formatAssetUrl(distributeVerticalIconUrl, opts),
dot: formatAssetUrl(dotIconUrl, opts),
'dots-horizontal': formatAssetUrl(dotsHorizontalIconUrl, opts),
'dots-vertical': formatAssetUrl(dotsVerticalIconUrl, opts),
'drag-handle-dots': formatAssetUrl(dragHandleDotsIconUrl, opts),
duplicate: formatAssetUrl(duplicateIconUrl, opts),
edit: formatAssetUrl(editIconUrl, opts),
'external-link': formatAssetUrl(externalLinkIconUrl, opts),
file: formatAssetUrl(fileIconUrl, opts),
'fill-none': formatAssetUrl(fillNoneIconUrl, opts),
'fill-pattern': formatAssetUrl(fillPatternIconUrl, opts),
'fill-semi': formatAssetUrl(fillSemiIconUrl, opts),
'fill-solid': formatAssetUrl(fillSolidIconUrl, opts),
follow: formatAssetUrl(followIconUrl, opts),
following: formatAssetUrl(followingIconUrl, opts),
'font-draw': formatAssetUrl(fontDrawIconUrl, opts),
'font-mono': formatAssetUrl(fontMonoIconUrl, opts),
'font-sans': formatAssetUrl(fontSansIconUrl, opts),
'font-serif': formatAssetUrl(fontSerifIconUrl, opts),
'geo-arrow-down': formatAssetUrl(geoArrowDownIconUrl, opts),
'geo-arrow-left': formatAssetUrl(geoArrowLeftIconUrl, opts),
'geo-arrow-right': formatAssetUrl(geoArrowRightIconUrl, opts),
'geo-arrow-up': formatAssetUrl(geoArrowUpIconUrl, opts),
'geo-diamond': formatAssetUrl(geoDiamondIconUrl, opts),
'geo-ellipse': formatAssetUrl(geoEllipseIconUrl, opts),
'geo-hexagon': formatAssetUrl(geoHexagonIconUrl, opts),
'geo-octagon': formatAssetUrl(geoOctagonIconUrl, opts),
'geo-oval': formatAssetUrl(geoOvalIconUrl, opts),
'geo-pentagon': formatAssetUrl(geoPentagonIconUrl, opts),
'geo-rectangle': formatAssetUrl(geoRectangleIconUrl, opts),
'geo-rhombus-2': formatAssetUrl(geoRhombus2IconUrl, opts),
'geo-rhombus': formatAssetUrl(geoRhombusIconUrl, opts),
'geo-star': formatAssetUrl(geoStarIconUrl, opts),
'geo-trapezoid': formatAssetUrl(geoTrapezoidIconUrl, opts),
'geo-triangle': formatAssetUrl(geoTriangleIconUrl, opts),
'geo-x-box': formatAssetUrl(geoXBoxIconUrl, opts),
github: formatAssetUrl(githubIconUrl, opts),
group: formatAssetUrl(groupIconUrl, opts),
hidden: formatAssetUrl(hiddenIconUrl, opts),
image: formatAssetUrl(imageIconUrl, opts),
'info-circle': formatAssetUrl(infoCircleIconUrl, opts),
leading: formatAssetUrl(leadingIconUrl, opts),
link: formatAssetUrl(linkIconUrl, opts),
'lock-small': formatAssetUrl(lockSmallIconUrl, opts),
lock: formatAssetUrl(lockIconUrl, opts),
menu: formatAssetUrl(menuIconUrl, opts),
minus: formatAssetUrl(minusIconUrl, opts),
mixed: formatAssetUrl(mixedIconUrl, opts),
pack: formatAssetUrl(packIconUrl, opts),
page: formatAssetUrl(pageIconUrl, opts),
plus: formatAssetUrl(plusIconUrl, opts),
'question-mark-circle': formatAssetUrl(questionMarkCircleIconUrl, opts),
'question-mark': formatAssetUrl(questionMarkIconUrl, opts),
redo: formatAssetUrl(redoIconUrl, opts),
'reset-zoom': formatAssetUrl(resetZoomIconUrl, opts),
'rotate-ccw': formatAssetUrl(rotateCcwIconUrl, opts),
'rotate-cw': formatAssetUrl(rotateCwIconUrl, opts),
ruler: formatAssetUrl(rulerIconUrl, opts),
search: formatAssetUrl(searchIconUrl, opts),
'send-backward': formatAssetUrl(sendBackwardIconUrl, opts),
'send-to-back': formatAssetUrl(sendToBackIconUrl, opts),
'settings-horizontal': formatAssetUrl(settingsHorizontalIconUrl, opts),
'settings-vertical-1': formatAssetUrl(settingsVertical1IconUrl, opts),
'settings-vertical': formatAssetUrl(settingsVerticalIconUrl, opts),
'share-1': formatAssetUrl(share1IconUrl, opts),
'share-2': formatAssetUrl(share2IconUrl, opts),
'size-extra-large': formatAssetUrl(sizeExtraLargeIconUrl, opts),
'size-large': formatAssetUrl(sizeLargeIconUrl, opts),
'size-medium': formatAssetUrl(sizeMediumIconUrl, opts),
'size-small': formatAssetUrl(sizeSmallIconUrl, opts),
'spline-cubic': formatAssetUrl(splineCubicIconUrl, opts),
'spline-line': formatAssetUrl(splineLineIconUrl, opts),
'stack-horizontal': formatAssetUrl(stackHorizontalIconUrl, opts),
'stack-vertical': formatAssetUrl(stackVerticalIconUrl, opts),
'stretch-horizontal': formatAssetUrl(stretchHorizontalIconUrl, opts),
'stretch-vertical': formatAssetUrl(stretchVerticalIconUrl, opts),
'text-align-center': formatAssetUrl(textAlignCenterIconUrl, opts),
'text-align-justify': formatAssetUrl(textAlignJustifyIconUrl, opts),
'text-align-left': formatAssetUrl(textAlignLeftIconUrl, opts),
'text-align-right': formatAssetUrl(textAlignRightIconUrl, opts),
'tool-arrow': formatAssetUrl(toolArrowIconUrl, opts),
'tool-embed': formatAssetUrl(toolEmbedIconUrl, opts),
'tool-eraser': formatAssetUrl(toolEraserIconUrl, opts),
'tool-frame': formatAssetUrl(toolFrameIconUrl, opts),
'tool-hand': formatAssetUrl(toolHandIconUrl, opts),
'tool-highlighter': formatAssetUrl(toolHighlighterIconUrl, opts),
'tool-line': formatAssetUrl(toolLineIconUrl, opts),
'tool-media': formatAssetUrl(toolMediaIconUrl, opts),
'tool-note': formatAssetUrl(toolNoteIconUrl, opts),
'tool-pencil': formatAssetUrl(toolPencilIconUrl, opts),
'tool-pointer': formatAssetUrl(toolPointerIconUrl, opts),
'tool-text': formatAssetUrl(toolTextIconUrl, opts),
trash: formatAssetUrl(trashIconUrl, opts),
'triangle-down': formatAssetUrl(triangleDownIconUrl, opts),
'triangle-up': formatAssetUrl(triangleUpIconUrl, opts),
twitter: formatAssetUrl(twitterIconUrl, opts),
undo: formatAssetUrl(undoIconUrl, opts),
ungroup: formatAssetUrl(ungroupIconUrl, opts),
'unlock-small': formatAssetUrl(unlockSmallIconUrl, opts),
unlock: formatAssetUrl(unlockIconUrl, opts),
visible: formatAssetUrl(visibleIconUrl, opts),
'warning-triangle': formatAssetUrl(warningTriangleIconUrl, opts),
'zoom-in': formatAssetUrl(zoomInIconUrl, opts),
'zoom-out': formatAssetUrl(zoomOutIconUrl, opts),
},
translations: {
ar: formatAssetUrl(arTranslationUrl, opts),
ca: formatAssetUrl(caTranslationUrl, opts),
da: formatAssetUrl(daTranslationUrl, opts),
de: formatAssetUrl(deTranslationUrl, opts),
en: formatAssetUrl(enTranslationUrl, opts),
es: formatAssetUrl(esTranslationUrl, opts),
fa: formatAssetUrl(faTranslationUrl, opts),
fi: formatAssetUrl(fiTranslationUrl, opts),
fr: formatAssetUrl(frTranslationUrl, opts),
gl: formatAssetUrl(glTranslationUrl, opts),
he: formatAssetUrl(heTranslationUrl, opts),
'hi-in': formatAssetUrl(hiInTranslationUrl, opts),
hu: formatAssetUrl(huTranslationUrl, opts),
it: formatAssetUrl(itTranslationUrl, opts),
ja: formatAssetUrl(jaTranslationUrl, opts),
'ko-kr': formatAssetUrl(koKrTranslationUrl, opts),
ku: formatAssetUrl(kuTranslationUrl, opts),
languages: formatAssetUrl(languagesTranslationUrl, opts),
main: formatAssetUrl(mainTranslationUrl, opts),
my: formatAssetUrl(myTranslationUrl, opts),
ne: formatAssetUrl(neTranslationUrl, opts),
no: formatAssetUrl(noTranslationUrl, opts),
pl: formatAssetUrl(plTranslationUrl, opts),
'pt-br': formatAssetUrl(ptBrTranslationUrl, opts),
'pt-pt': formatAssetUrl(ptPtTranslationUrl, opts),
ro: formatAssetUrl(roTranslationUrl, opts),
ru: formatAssetUrl(ruTranslationUrl, opts),
sv: formatAssetUrl(svTranslationUrl, opts),
te: formatAssetUrl(teTranslationUrl, opts),
th: formatAssetUrl(thTranslationUrl, opts),
tr: formatAssetUrl(trTranslationUrl, opts),
uk: formatAssetUrl(ukTranslationUrl, opts),
vi: formatAssetUrl(viTranslationUrl, opts),
'zh-cn': formatAssetUrl(zhCnTranslationUrl, opts),
'zh-tw': formatAssetUrl(zhTwTranslationUrl, opts),
},
embedIcons: {
codepen: formatAssetUrl(codepenEmbedIconUrl, opts),
codesandbox: formatAssetUrl(codesandboxEmbedIconUrl, opts),
excalidraw: formatAssetUrl(excalidrawEmbedIconUrl, opts),
felt: formatAssetUrl(feltEmbedIconUrl, opts),
figma: formatAssetUrl(figmaEmbedIconUrl, opts),
github_gist: formatAssetUrl(githubGistEmbedIconUrl, opts),
google_calendar: formatAssetUrl(googleCalendarEmbedIconUrl, opts),
google_maps: formatAssetUrl(googleMapsEmbedIconUrl, opts),
google_slides: formatAssetUrl(googleSlidesEmbedIconUrl, opts),
observable: formatAssetUrl(observableEmbedIconUrl, opts),
replit: formatAssetUrl(replitEmbedIconUrl, opts),
scratch: formatAssetUrl(scratchEmbedIconUrl, opts),
spotify: formatAssetUrl(spotifyEmbedIconUrl, opts),
tldraw: formatAssetUrl(tldrawEmbedIconUrl, opts),
vimeo: formatAssetUrl(vimeoEmbedIconUrl, opts),
youtube: formatAssetUrl(youtubeEmbedIconUrl, opts),
},
} as const
}
export { getBundlerAssetUrls } from './imports'

599
packages/assets/src/urls.ts Normal file
View file

@ -0,0 +1,599 @@
// This file is automatically generated by scripts/refresh-assets.ts.
// Do not edit manually.
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="../modules.d.ts" />
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-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
}

View file

@ -2,15 +2,22 @@
export type AssetUrl = string | { src: string }
/** @public */
export type AssetUrlOptions = {
baseUrl?: string
}
export type AssetUrlOptions =
| {
baseUrl?: string
}
| ((assetUrl: string) => string)
/** @public */
export function formatAssetUrl(assetUrl: AssetUrl, { baseUrl = '' }: AssetUrlOptions = {}): string {
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(/^\.?\//, '')}`
}

View file

@ -619,7 +619,7 @@ export const DEFAULT_BOOKMARK_HEIGHT = 320;
export const DEFAULT_BOOKMARK_WIDTH = 300;
// @public (undocumented)
export const defaultEditorAssetUrls: EditorAssetUrls;
export let defaultEditorAssetUrls: EditorAssetUrls;
// @public (undocumented)
export function defaultEmptyAs(str: string, dflt: string): string;
@ -1443,6 +1443,9 @@ export const runtime: {
hardReset: () => void;
};
// @internal (undocumented)
export function setDefaultEditorAssetUrls(assetUrls: EditorAssetUrls): void;
// @public (undocumented)
export function setPointerCapture(element: Element, event: PointerEvent | React_3.PointerEvent<Element>): void;

View file

@ -107,7 +107,11 @@ export {
export { type RequiredKeys, type TLEasingType } from './lib/app/types/misc-types'
export { type TLReorderOperation } from './lib/app/types/reorder-types'
export { type TLResizeHandle, type TLSelectionHandle } from './lib/app/types/selection-types'
export { defaultEditorAssetUrls, type EditorAssetUrls } from './lib/assetUrls'
export {
defaultEditorAssetUrls,
setDefaultEditorAssetUrls,
type EditorAssetUrls,
} from './lib/assetUrls'
export { Canvas } from './lib/components/Canvas'
export { DefaultErrorFallback } from './lib/components/DefaultErrorFallback'
export {

View file

@ -9,7 +9,7 @@ export type EditorAssetUrls = {
}
/** @public */
export const defaultEditorAssetUrls: EditorAssetUrls = {
export let defaultEditorAssetUrls: EditorAssetUrls = {
fonts: {
draw: '/fonts/Shantell_Sans-Normal-SemiBold.woff2',
serif: '/fonts/IBMPlexSerif-Medium.woff2',
@ -17,3 +17,8 @@ export const defaultEditorAssetUrls: EditorAssetUrls = {
monospace: '/fonts/IBMPlexMono-Medium.woff2',
},
}
/** @internal */
export function setDefaultEditorAssetUrls(assetUrls: EditorAssetUrls) {
defaultEditorAssetUrls = assetUrls
}

View file

@ -1,6 +1,6 @@
import { rangeIntersection } from '@tldraw/primitives'
import * as React from 'react'
import { GapsSnapLine, PointsSnapLine, SnapLine } from '../app/managers/SnapManager'
import { type GapsSnapLine, type PointsSnapLine, type SnapLine } from '../app/managers/SnapManager'
function PointsSnapLine({ points, zoom }: { zoom: number } & PointsSnapLine) {
const l = 2.5 / zoom

View file

@ -33,6 +33,7 @@
"test-coverage": "lazy inherit",
"dev": "chokidar '../{editor,ui}/*.css' -c 'node ./scripts/copy-css-files.mjs' --initial",
"prebuild": "node ./scripts/copy-css-files.mjs",
"build": "node ./scripts/copy-css-files.mjs",
"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",

View file

@ -552,6 +552,9 @@ function Root({ id, open, children, modal, }: {
modal?: boolean;
}): JSX.Element;
// @internal (undocumented)
export function setDefaultUiAssetUrls(urls: UiAssetUrls): void;
// @public (undocumented)
export function Slider(props: SliderProps): JSX.Element;

View file

@ -6,6 +6,7 @@ export {
TldrawUiContextProvider,
type TldrawUiContextProviderProps,
} from './lib/TldrawUiContextProvider'
export { setDefaultUiAssetUrls } from './lib/assetUrls'
export { ContextMenu, type ContextMenuProps } from './lib/components/ContextMenu'
export { DebugPanel } from './lib/components/DebugPanel'
export { HTMLCanvas } from './lib/components/HTMLCanvas'

View file

@ -8,7 +8,7 @@ export type UiAssetUrls = EditorAssetUrls & {
embedIcons: Record<(typeof EMBED_DEFINITIONS)[number]['type'], string>
}
export const defaultUiAssetUrls: UiAssetUrls = {
export let defaultUiAssetUrls: UiAssetUrls = {
...defaultEditorAssetUrls,
icons: Object.fromEntries(
TLUiIconTypes.map((name) => [name, `/icons/icon/${name}.svg`])
@ -20,3 +20,8 @@ export const defaultUiAssetUrls: UiAssetUrls = {
EMBED_DEFINITIONS.map((def) => [def.type, `/embed-icons/${def.type}.png`])
) as Record<(typeof EMBED_DEFINITIONS)[number]['type'], string>,
}
/** @internal */
export function setDefaultUiAssetUrls(urls: UiAssetUrls) {
defaultUiAssetUrls = urls
}

View file

@ -537,6 +537,21 @@ __metadata:
languageName: node
linkType: hard
"@babel/plugin-proposal-decorators@npm:^7.21.0":
version: 7.21.0
resolution: "@babel/plugin-proposal-decorators@npm:7.21.0"
dependencies:
"@babel/helper-create-class-features-plugin": ^7.21.0
"@babel/helper-plugin-utils": ^7.20.2
"@babel/helper-replace-supers": ^7.20.7
"@babel/helper-split-export-declaration": ^7.18.6
"@babel/plugin-syntax-decorators": ^7.21.0
peerDependencies:
"@babel/core": ^7.0.0-0
checksum: 2889a060010af7ac2e24f7a193262e50a94e254dd86d273e25a2bec2a2f97dd95b136bb933f63448c1cdde4f38ac7877837685657aa8161699eb226d9f1eb453
languageName: node
linkType: hard
"@babel/plugin-proposal-dynamic-import@npm:^7.18.6":
version: 7.18.6
resolution: "@babel/plugin-proposal-dynamic-import@npm:7.18.6"
@ -731,6 +746,17 @@ __metadata:
languageName: node
linkType: hard
"@babel/plugin-syntax-decorators@npm:^7.21.0":
version: 7.21.0
resolution: "@babel/plugin-syntax-decorators@npm:7.21.0"
dependencies:
"@babel/helper-plugin-utils": ^7.20.2
peerDependencies:
"@babel/core": ^7.0.0-0
checksum: 31108e73c3e569f2795ddb4f5f1f32c13c6be97a107d41e318c8f58ca3fde0fa958af3d1a302ab64f36f73ce4d6dda7889732243561c087a7cc3b22192d42a65
languageName: node
linkType: hard
"@babel/plugin-syntax-dynamic-import@npm:^7.8.3":
version: 7.8.3
resolution: "@babel/plugin-syntax-dynamic-import@npm:7.8.3"
@ -4912,15 +4938,6 @@ __metadata:
languageName: node
linkType: hard
"@types/ip@npm:^1.1.0":
version: 1.1.0
resolution: "@types/ip@npm:1.1.0"
dependencies:
"@types/node": "*"
checksum: 05e1ef8b525e2f2d73f5cde7ef1e0e7aa1b027946e066b4063f9c8c2fde59a13762ec703e6df32e2db31db1dc3a54f46a7516bd6d970200d175ec7e9700bb83e
languageName: node
linkType: hard
"@types/is-ci@npm:^3.0.0":
version: 3.0.0
resolution: "@types/is-ci@npm:3.0.0"
@ -6641,16 +6658,7 @@ __metadata:
languageName: node
linkType: hard
"browserslist-to-esbuild@npm:^1.2.0":
version: 1.2.0
resolution: "browserslist-to-esbuild@npm:1.2.0"
dependencies:
browserslist: ^4.17.3
checksum: a6c1adc2ad8da0db23aa4f0b3c71e13561cbf61599e9acedc7890793d79aca250edb0f599095042e81587c88e87569bf3a1a68633026e81e4ac7548eb1c71b49
languageName: node
linkType: hard
"browserslist@npm:^4.17.3, browserslist@npm:^4.21.3, browserslist@npm:^4.21.5":
"browserslist@npm:^4.21.3, browserslist@npm:^4.21.5":
version: 4.21.5
resolution: "browserslist@npm:4.21.5"
dependencies:
@ -7331,26 +7339,6 @@ __metadata:
languageName: node
linkType: hard
"concurrently@npm:^7.4.0":
version: 7.6.0
resolution: "concurrently@npm:7.6.0"
dependencies:
chalk: ^4.1.0
date-fns: ^2.29.1
lodash: ^4.17.21
rxjs: ^7.0.0
shell-quote: ^1.7.3
spawn-command: ^0.0.2-1
supports-color: ^8.1.0
tree-kill: ^1.2.2
yargs: ^17.3.1
bin:
conc: dist/bin/concurrently.js
concurrently: dist/bin/concurrently.js
checksum: f705c9a7960f1b16559ca64958043faeeef6385c0bf30a03d1375e15ab2d96dba4f8166f1bbbb1c85e8da35ca0ce3c353875d71dff2aa132b2357bb533b3332e
languageName: node
linkType: hard
"config@workspace:config":
version: 0.0.0-use.local
resolution: "config@workspace:config"
@ -7649,7 +7637,7 @@ __metadata:
languageName: node
linkType: hard
"date-fns@npm:^2.16.1, date-fns@npm:^2.29.1":
"date-fns@npm:^2.16.1":
version: 2.29.3
resolution: "date-fns@npm:2.29.3"
checksum: e01cf5b62af04e05dfff921bb9c9933310ed0e1ae9a81eb8653452e64dc841acf7f6e01e1a5ae5644d0337e9a7f936175fd2cb6819dc122fdd9c5e86c56be484
@ -9472,19 +9460,16 @@ __metadata:
version: 0.0.0-use.local
resolution: "examples.tldraw.com@workspace:apps/examples"
dependencies:
"@babel/plugin-proposal-decorators": ^7.21.0
"@tldraw/assets": "workspace:*"
"@tldraw/tldraw": "workspace:*"
"@types/ip": ^1.1.0
browserslist-to-esbuild: ^1.2.0
concurrently: ^7.4.0
esbuild: ^0.16.7
ip: ^1.1.8
lazyrepo: 0.0.0-alpha.26
node-forge: ^1.3.1
react: ^18.2.0
react-dom: ^18.2.0
react-router-dom: ^6.9.0
signia: 0.1.4
signia-react: 0.1.4
vite: ^4.3.4
languageName: unknown
linkType: soft
@ -11067,7 +11052,7 @@ __metadata:
languageName: node
linkType: hard
"ip@npm:^1.1.5, ip@npm:^1.1.8":
"ip@npm:^1.1.5":
version: 1.1.8
resolution: "ip@npm:1.1.8"
checksum: a2ade53eb339fb0cbe9e69a44caab10d6e3784662285eb5d2677117ee4facc33a64679051c35e0dfdb1a3983a51ce2f5d2cb36446d52e10d01881789b76e28fb
@ -14306,13 +14291,6 @@ __metadata:
languageName: node
linkType: hard
"node-forge@npm:^1.3.1":
version: 1.3.1
resolution: "node-forge@npm:1.3.1"
checksum: 08fb072d3d670599c89a1704b3e9c649ff1b998256737f0e06fbd1a5bf41cae4457ccaee32d95052d80bbafd9ffe01284e078c8071f0267dc9744e51c5ed42a9
languageName: node
linkType: hard
"node-gyp-build@npm:^4.2.2":
version: 4.6.0
resolution: "node-gyp-build@npm:4.6.0"
@ -15247,7 +15225,7 @@ __metadata:
languageName: node
linkType: hard
"postcss@npm:^8.4.19, postcss@npm:^8.4.21":
"postcss@npm:^8.4.19, postcss@npm:^8.4.21, postcss@npm:^8.4.23":
version: 8.4.23
resolution: "postcss@npm:8.4.23"
dependencies:
@ -16441,6 +16419,20 @@ __metadata:
languageName: node
linkType: hard
"rollup@npm:^3.21.0":
version: 3.21.4
resolution: "rollup@npm:3.21.4"
dependencies:
fsevents: ~2.3.2
dependenciesMeta:
fsevents:
optional: true
bin:
rollup: dist/bin/rollup
checksum: ad7dec30ce31b47e32c3daf464b14c25e52f4e07b6ad9fa610b0abcff480b1a1fb01aabdefa6bac30ff1ee23ab16762621cd24810798148cdff74efda1a98874
languageName: node
linkType: hard
"run-async@npm:^2.4.0":
version: 2.4.1
resolution: "run-async@npm:2.4.1"
@ -16466,7 +16458,7 @@ __metadata:
languageName: node
linkType: hard
"rxjs@npm:^7.0.0, rxjs@npm:^7.5.5, rxjs@npm:^7.8.0":
"rxjs@npm:^7.5.5, rxjs@npm:^7.8.0":
version: 7.8.0
resolution: "rxjs@npm:7.8.0"
dependencies:
@ -16688,13 +16680,6 @@ __metadata:
languageName: node
linkType: hard
"shell-quote@npm:^1.7.3":
version: 1.8.1
resolution: "shell-quote@npm:1.8.1"
checksum: 5f01201f4ef504d4c6a9d0d283fa17075f6770bfbe4c5850b074974c68062f37929ca61700d95ad2ac8822e14e8c4b990ca0e6e9272e64befd74ce5e19f0736b
languageName: node
linkType: hard
"side-channel@npm:^1.0.4":
version: 1.0.4
resolution: "side-channel@npm:1.0.4"
@ -18576,6 +18561,43 @@ __metadata:
languageName: node
linkType: hard
"vite@npm:^4.3.4":
version: 4.3.4
resolution: "vite@npm:4.3.4"
dependencies:
esbuild: ^0.17.5
fsevents: ~2.3.2
postcss: ^8.4.23
rollup: ^3.21.0
peerDependencies:
"@types/node": ">= 14"
less: "*"
sass: "*"
stylus: "*"
sugarss: "*"
terser: ^5.4.0
dependenciesMeta:
fsevents:
optional: true
peerDependenciesMeta:
"@types/node":
optional: true
less:
optional: true
sass:
optional: true
stylus:
optional: true
sugarss:
optional: true
terser:
optional: true
bin:
vite: bin/vite.js
checksum: 90ce3923ef3e9a491851fb34effece43858d0ba915db17ea6ad0eb649bd77d81c69a71aafc55a6fbd11e4134b1a79eb7e2e3553f055d390d32ca0ff7c645acf6
languageName: node
linkType: hard
"vm2@npm:^3.9.11":
version: 3.9.17
resolution: "vm2@npm:3.9.17"

View file

@ -1,4 +1,5 @@
import { readFile, writeFile as writeFileUnchecked } from 'fs/promises'
import json5 from 'json5'
import { basename, dirname, join, relative } from 'path'
import prettier from 'prettier'
import { fileURLToPath } from 'url'
@ -10,11 +11,11 @@ export const REPO_ROOT = join(__dirname, isBublic ? '../../..' : '../..')
export const BUBLIC_ROOT = join(__dirname, '../..')
export async function readJsonIfExists(file: string) {
try {
return JSON.parse(await readFile(file, 'utf8'))
} catch {
const fileContents = await readFileIfExists(file)
if (fileContents === null) {
return null
}
return json5.parse(fileContents)
}
export async function readFileIfExists(file: string) {

View file

@ -11,10 +11,7 @@ import {
} from './lib/file'
// We'll need to copy the assets into these folders
const PUBLIC_FOLDER_PATHS = [
join(BUBLIC_ROOT, 'packages', 'assets'),
join(BUBLIC_ROOT, 'apps', 'examples', 'www'),
]
const PUBLIC_FOLDER_PATHS = [join(BUBLIC_ROOT, 'packages', 'assets')]
const FONT_MAPPING: Record<string, string> = {
'IBMPlexMono-Medium': 'monospace',
@ -26,16 +23,15 @@ const FONT_MAPPING: Record<string, string> = {
const ASSETS_FOLDER_PATH = join(BUBLIC_ROOT, 'assets')
const collectedAssetUrls: {
imports: { name: string; from: string }[]
assets: {
fonts: Record<string, string>
icons: Record<string, string>
translations: Record<string, string>
embedIcons: Record<string, string>
}
fonts: Record<string, string>
icons: Record<string, string>
translations: Record<string, string>
embedIcons: Record<string, string>
} = {
imports: [],
assets: { fonts: {}, icons: {}, translations: {}, embedIcons: {} },
fonts: {},
icons: {},
translations: {},
embedIcons: {},
}
// 1. ICONS
@ -100,12 +96,7 @@ async function copyIcons() {
// add to the asset declaration file
for (const icon of icons) {
const name = icon.replace('.svg', '')
const variableName = camelCase(`${name}IconUrl`)
collectedAssetUrls.imports.push({
name: variableName,
from: `icons/icon/${icon}`,
})
collectedAssetUrls.assets.icons[name] = variableName
collectedAssetUrls.icons[name] = `icons/icon/${icon}`
}
}
@ -138,12 +129,7 @@ async function copyEmbedIcons() {
// add to the asset declaration file
for (const item of itemsToCopy) {
const name = item.replace(extension, '')
const variableName = camelCase(`${name}EmbedIconUrl`)
collectedAssetUrls.imports.push({
name: variableName,
from: `${folderName}/${item}`,
})
collectedAssetUrls.assets.embedIcons[name] = variableName
collectedAssetUrls.embedIcons[name] = `${folderName}/${item}`
}
}
@ -181,12 +167,7 @@ async function copyFonts() {
console.log('Font mapping not found for', itemWithoutExtension)
process.exit(1)
}
const variableName = camelCase(`${name}FontUrl`)
collectedAssetUrls.imports.push({
name: variableName,
from: `${folderName}/${item}`,
})
collectedAssetUrls.assets.fonts[name] = variableName
collectedAssetUrls.fonts[name] = `${folderName}/${item}`
}
}
@ -255,38 +236,31 @@ async function copyTranslations() {
// add to the asset declaration file
for (const item of itemsToCopy) {
const name = item.replace(extension, '')
const variableName = camelCase(`${name}TranslationUrl`)
collectedAssetUrls.imports.push({
name: variableName,
from: `${folderName}/${item}`,
})
collectedAssetUrls.assets.translations[name] = variableName
collectedAssetUrls.translations[name] = `${folderName}/${item}`
}
}
// 4. ASSET DECLARATION FILE
async function writeAssetDeclarationFile() {
const assetDeclarationFilePath = join(BUBLIC_ROOT, 'packages', 'assets', 'src', 'index.ts')
// 4. ASSET DECLARATION FILES
async function writeUrlBasedAssetDeclarationFile() {
const assetDeclarationFilePath = join(BUBLIC_ROOT, 'packages', 'assets', 'src', 'urls.ts')
let assetDeclarationFile = `
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="../modules.d.ts" />
import {formatAssetUrl, AssetUrlOptions} from './utils';
`
for (const { name, from } of collectedAssetUrls.imports) {
assetDeclarationFile += `import ${name} from '../${from}';\n`
}
assetDeclarationFile += `
/** @public */
export function getBundlerAssetUrls(opts?: AssetUrlOptions) {
return {
${Object.entries(collectedAssetUrls.assets)
${Object.entries(collectedAssetUrls)
.flatMap(([type, assets]) => [
`${type}: {`,
...Object.entries(assets).map(
([name, variableName]) =>
`${JSON.stringify(name)}: formatAssetUrl(${variableName}, opts),`
([name, href]) =>
`${JSON.stringify(name)}: formatAssetUrl(new URL(${JSON.stringify(
'../' + href
)}, import.meta.url).href, opts),`
),
'},',
])
@ -297,9 +271,39 @@ async function writeAssetDeclarationFile() {
await writeTypescriptFile(assetDeclarationFilePath, assetDeclarationFile)
}
async function writeImportBasedAssetDeclarationFile(): Promise<void> {
let imports = `
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="../modules.d.ts" />
import {formatAssetUrl, AssetUrlOptions} from './utils';
`
function camelCase(name: string) {
return name.replace(/[_-]([a-z0-9])/gi, (g) => g[1].toUpperCase())
let declarations = `
/** @public */
export function getBundlerAssetUrls(opts?: AssetUrlOptions) {
return {
`
for (const [type, assets] of Object.entries(collectedAssetUrls)) {
declarations += `${type}: {\n`
for (const [name, href] of Object.entries(assets)) {
const variableName = `${type}_${name}`
.replace(/[^a-zA-Z0-9_]/g, '_')
.replace(/_+/g, '_')
.replace(/_(.)/g, (_, letter) => letter.toUpperCase())
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)
}
// --- RUN
@ -313,7 +317,8 @@ async function main() {
console.log('Copying translations...')
await copyTranslations()
console.log('Writing asset declaration file...')
await writeAssetDeclarationFile()
await writeUrlBasedAssetDeclarationFile()
await writeImportBasedAssetDeclarationFile()
console.log('Done!')
}