snapshot of https://github.com/tldraw/tldraw.git (main, 2026-09-23; blobs > 131072B omitted)
Some checks failed
Deploy analytics worker / Deploy analytics worker to ${{ (github.ref == 'refs/heads/production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Failing after 1s
i18n upload strings / Upload latest strings (push) Failing after 1s
Deploy bemo / Deploy bemo to ${{ (github.ref == 'refs/heads/bemo-production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Failing after 1s
Deploy grafana resources / ${{ github.event_name == 'push' && 'Deploy grafana resources' || 'Validate grafana resources (dry run)' }} (push) Failing after 0s
End to end tests (dotcom) / Check for relevant changes (push) Failing after 0s
End to end tests (examples) / Check for relevant changes (push) Failing after 0s
End to end tests (mermaid readability) / Check for relevant changes (push) Failing after 1s
End to end tests (perf) / Check for relevant changes (push) Failing after 0s
Publish editor extensions / Publish editor extensions (push) Failing after 1s
Publish SDK packages / Remove the publish-packages label (push) Has been skipped
Checks / Tests & checks (push) Has been cancelled
Checks / Build all projects (push) Has been cancelled
Deploy templates / Deploy templates (push) Has been cancelled
End to end tests (dotcom) / End to end tests (dotcom) (push) Has been cancelled
End to end tests (mermaid readability) / End to end tests (mermaid readability) (push) Has been cancelled
End to end tests (perf) / End to end tests (perf) (push) Has been cancelled
Deploy .com / Deploy dotcom to ${{ (github.ref == 'refs/heads/production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Has been cancelled
End to end tests (examples) / End to end tests (examples) (push) Has been cancelled
Publish SDK packages / Publish SDK packages (push) Has been cancelled
Publish SDK packages / Tell user released version (push) Has been cancelled
Publish SDK packages / Publishes code templates to separate repositories (push) Has been cancelled
Publish SDK packages / Deploys the template demos with the new SDK version (push) Has been cancelled
Some checks failed
Deploy analytics worker / Deploy analytics worker to ${{ (github.ref == 'refs/heads/production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Failing after 1s
i18n upload strings / Upload latest strings (push) Failing after 1s
Deploy bemo / Deploy bemo to ${{ (github.ref == 'refs/heads/bemo-production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Failing after 1s
Deploy grafana resources / ${{ github.event_name == 'push' && 'Deploy grafana resources' || 'Validate grafana resources (dry run)' }} (push) Failing after 0s
End to end tests (dotcom) / Check for relevant changes (push) Failing after 0s
End to end tests (examples) / Check for relevant changes (push) Failing after 0s
End to end tests (mermaid readability) / Check for relevant changes (push) Failing after 1s
End to end tests (perf) / Check for relevant changes (push) Failing after 0s
Publish editor extensions / Publish editor extensions (push) Failing after 1s
Publish SDK packages / Remove the publish-packages label (push) Has been skipped
Checks / Tests & checks (push) Has been cancelled
Checks / Build all projects (push) Has been cancelled
Deploy templates / Deploy templates (push) Has been cancelled
End to end tests (dotcom) / End to end tests (dotcom) (push) Has been cancelled
End to end tests (mermaid readability) / End to end tests (mermaid readability) (push) Has been cancelled
End to end tests (perf) / End to end tests (perf) (push) Has been cancelled
Deploy .com / Deploy dotcom to ${{ (github.ref == 'refs/heads/production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Has been cancelled
End to end tests (examples) / End to end tests (examples) (push) Has been cancelled
Publish SDK packages / Publish SDK packages (push) Has been cancelled
Publish SDK packages / Tell user released version (push) Has been cancelled
Publish SDK packages / Publishes code templates to separate repositories (push) Has been cancelled
Publish SDK packages / Deploys the template demos with the new SDK version (push) Has been cancelled
This commit is contained in:
1
internal/config/LICENSE.md
Normal file
1
internal/config/LICENSE.md
Normal file
@@ -0,0 +1 @@
|
||||
This code is licensed under the [tldraw license](https://github.com/tldraw/tldraw/blob/main/LICENSE.md)
|
||||
406
internal/config/api-extractor.json
Normal file
406
internal/config/api-extractor.json
Normal file
@@ -0,0 +1,406 @@
|
||||
/**
|
||||
* Config file for API Extractor. For more info, please visit: https://api-extractor.com
|
||||
*/
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
||||
/**
|
||||
* Optionally specifies another JSON config file that this file extends from. This provides a way for
|
||||
* standard settings to be shared across multiple projects.
|
||||
*
|
||||
* If the path starts with "./" or "../", the path is resolved relative to the folder of the file that contains
|
||||
* the "extends" field. Otherwise, the first path segment is interpreted as an NPM package name, and will be
|
||||
* resolved using NodeJS require().
|
||||
*
|
||||
* SUPPORTED TOKENS: none
|
||||
* DEFAULT VALUE: ""
|
||||
*/
|
||||
// "extends": "./shared/api-extractor-base.json"
|
||||
// "extends": "my-package/include/api-extractor-base.json"
|
||||
/**
|
||||
* Determines the "<projectFolder>" token that can be used with other config file settings. The project folder
|
||||
* typically contains the tsconfig.json and package.json config files, but the path is user-defined.
|
||||
*
|
||||
* The path is resolved relative to the folder of the config file that contains the setting.
|
||||
*
|
||||
* The default value for "projectFolder" is the token "<lookup>", which means the folder is determined by traversing
|
||||
* parent folders, starting from the folder containing api-extractor.json, and stopping at the first folder
|
||||
* that contains a tsconfig.json file. If a tsconfig.json file cannot be found in this way, then an error
|
||||
* will be reported.
|
||||
*
|
||||
* SUPPORTED TOKENS: <lookup>
|
||||
* DEFAULT VALUE: "<lookup>"
|
||||
*/
|
||||
"projectFolder": "../..",
|
||||
/**
|
||||
* (REQUIRED) Specifies the .d.ts file to be used as the starting point for analysis. API Extractor
|
||||
* analyzes the symbols exported by this module.
|
||||
*
|
||||
* The file extension must be ".d.ts" and not ".ts".
|
||||
*
|
||||
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
||||
* prepend a folder token such as "<projectFolder>".
|
||||
*
|
||||
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
||||
*/
|
||||
"mainEntryPointFilePath": "<projectFolder>/packages/<unscopedPackageName>/.tsbuild-api/index.d.ts",
|
||||
/**
|
||||
* A list of NPM package names whose exports should be treated as part of this package.
|
||||
*
|
||||
* For example, suppose that Webpack is used to generate a distributed bundle for the project "library1",
|
||||
* and another NPM package "library2" is embedded in this bundle. Some types from library2 may become part
|
||||
* of the exported API for library1, but by default API Extractor would generate a .d.ts rollup that explicitly
|
||||
* imports library2. To avoid this, we can specify:
|
||||
*
|
||||
* "bundledPackages": [ "library2" ],
|
||||
*
|
||||
* This would direct API Extractor to embed those types directly in the .d.ts rollup, as if they had been
|
||||
* local files for library1.
|
||||
*/
|
||||
"bundledPackages": [],
|
||||
/**
|
||||
* Specifies what type of newlines API Extractor should use when writing output files. By default, the output files
|
||||
* will be written with Windows-style newlines. To use POSIX-style newlines, specify "lf" instead.
|
||||
* To use the OS's default newline kind, specify "os".
|
||||
*
|
||||
* DEFAULT VALUE: "crlf"
|
||||
*/
|
||||
"newlineKind": "lf",
|
||||
/**
|
||||
* Set to true when invoking API Extractor's test harness. When `testMode` is true, the `toolVersion` field in the
|
||||
* .api.json file is assigned an empty string to prevent spurious diffs in output files tracked for tests.
|
||||
*
|
||||
* DEFAULT VALUE: "false"
|
||||
*/
|
||||
// "testMode": false,
|
||||
/**
|
||||
* Specifies how API Extractor sorts members of an enum when generating the .api.json file. By default, the output
|
||||
* files will be sorted alphabetically, which is "by-name". To keep the ordering in the source code, specify
|
||||
* "preserve".
|
||||
*
|
||||
* DEFAULT VALUE: "by-name"
|
||||
*/
|
||||
// "enumMemberOrder": "by-name",
|
||||
/**
|
||||
* Determines how the TypeScript compiler engine will be invoked by API Extractor.
|
||||
*/
|
||||
"compiler": {
|
||||
/**
|
||||
* Specifies the path to the tsconfig.json file to be used by API Extractor when analyzing the project.
|
||||
*
|
||||
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
||||
* prepend a folder token such as "<projectFolder>".
|
||||
*
|
||||
* Note: This setting will be ignored if "overrideTsconfig" is used.
|
||||
*
|
||||
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
||||
* DEFAULT VALUE: "<projectFolder>/tsconfig.json"
|
||||
*/
|
||||
"tsconfigFilePath": "<projectFolder>/packages/<unscopedPackageName>/tsconfig.json"
|
||||
/**
|
||||
* Provides a compiler configuration that will be used instead of reading the tsconfig.json file from disk.
|
||||
* The object must conform to the TypeScript tsconfig schema:
|
||||
*
|
||||
* http://json.schemastore.org/tsconfig
|
||||
*
|
||||
* If omitted, then the tsconfig.json file will be read from the "projectFolder".
|
||||
*
|
||||
* DEFAULT VALUE: no overrideTsconfig section
|
||||
*/
|
||||
// "overrideTsconfig": {
|
||||
// . . .
|
||||
// }
|
||||
/**
|
||||
* This option causes the compiler to be invoked with the --skipLibCheck option. This option is not recommended
|
||||
* and may cause API Extractor to produce incomplete or incorrect declarations, but it may be required when
|
||||
* dependencies contain declarations that are incompatible with the TypeScript engine that API Extractor uses
|
||||
* for its analysis. Where possible, the underlying issue should be fixed rather than relying on skipLibCheck.
|
||||
*
|
||||
* DEFAULT VALUE: false
|
||||
*/
|
||||
// "skipLibCheck": true,
|
||||
},
|
||||
/**
|
||||
* Configures how the API report file (*.api.md) will be generated.
|
||||
*/
|
||||
"apiReport": {
|
||||
/**
|
||||
* (REQUIRED) Whether to generate an API report.
|
||||
*/
|
||||
"enabled": true,
|
||||
/**
|
||||
* The filename for the API report files. It will be combined with "reportFolder" or "reportTempFolder" to produce
|
||||
* a full file path.
|
||||
*
|
||||
* The file extension should be ".api.md", and the string should not contain a path separator such as "\" or "/".
|
||||
*
|
||||
* SUPPORTED TOKENS: <packageName>, <unscopedPackageName>
|
||||
* DEFAULT VALUE: "<unscopedPackageName>.api.md"
|
||||
*/
|
||||
"reportFileName": "api-report",
|
||||
/**
|
||||
* Specifies the folder where the API report file is written. The file name portion is determined by
|
||||
* the "reportFileName" setting.
|
||||
*
|
||||
* The API report file is normally tracked by Git. Changes to it can be used to trigger a branch policy,
|
||||
* e.g. for an API review.
|
||||
*
|
||||
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
||||
* prepend a folder token such as "<projectFolder>".
|
||||
*
|
||||
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
||||
* DEFAULT VALUE: "<projectFolder>/temp/"
|
||||
*/
|
||||
"reportFolder": "<projectFolder>/packages/<unscopedPackageName>/",
|
||||
/**
|
||||
* Specifies the folder where the temporary report file is written. The file name portion is determined by
|
||||
* the "reportFileName" setting.
|
||||
*
|
||||
* After the temporary file is written to disk, it is compared with the file in the "reportFolder".
|
||||
* If they are different, a production build will fail.
|
||||
*
|
||||
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
||||
* prepend a folder token such as "<projectFolder>".
|
||||
*
|
||||
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
||||
* DEFAULT VALUE: "<projectFolder>/temp/"
|
||||
*/
|
||||
"reportTempFolder": "<projectFolder>/packages/<unscopedPackageName>/api/temp"
|
||||
/**
|
||||
* Whether "forgotten exports" should be included in the API report file. Forgotten exports are declarations
|
||||
* flagged with `ae-forgotten-export` warnings. See https://api-extractor.com/pages/messages/ae-forgotten-export/ to
|
||||
* learn more.
|
||||
*
|
||||
* DEFAULT VALUE: "false"
|
||||
*/
|
||||
// "includeForgottenExports": false
|
||||
},
|
||||
/**
|
||||
* Configures how the doc model file (*.api.json) will be generated.
|
||||
*/
|
||||
"docModel": {
|
||||
/**
|
||||
* (REQUIRED) Whether to generate a doc model file.
|
||||
*/
|
||||
"enabled": true,
|
||||
/**
|
||||
* The output path for the doc model file. The file extension should be ".api.json".
|
||||
*
|
||||
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
||||
* prepend a folder token such as "<projectFolder>".
|
||||
*
|
||||
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
||||
* DEFAULT VALUE: "<projectFolder>/temp/<unscopedPackageName>.api.json"
|
||||
*/
|
||||
"apiJsonFilePath": "<projectFolder>/packages/<unscopedPackageName>/api/api.json",
|
||||
/**
|
||||
* Whether "forgotten exports" should be included in the doc model file. Forgotten exports are declarations
|
||||
* flagged with `ae-forgotten-export` warnings. See https://api-extractor.com/pages/messages/ae-forgotten-export/ to
|
||||
* learn more.
|
||||
*
|
||||
* DEFAULT VALUE: "false"
|
||||
*/
|
||||
// "includeForgottenExports": false,
|
||||
/**
|
||||
* The base URL where the project's source code can be viewed on a website such as GitHub or
|
||||
* Azure DevOps. This URL path corresponds to the `<projectFolder>` path on disk.
|
||||
*
|
||||
* This URL is concatenated with the file paths serialized to the doc model to produce URL file paths to individual API items.
|
||||
* For example, if the `projectFolderUrl` is "https://github.com/microsoft/rushstack/tree/main/apps/api-extractor" and an API
|
||||
* item's file path is "api/ExtractorConfig.ts", the full URL file path would be
|
||||
* "https://github.com/microsoft/rushstack/tree/main/apps/api-extractor/api/ExtractorConfig.js".
|
||||
*
|
||||
* Can be omitted if you don't need source code links in your API documentation reference.
|
||||
*
|
||||
* SUPPORTED TOKENS: none
|
||||
* DEFAULT VALUE: ""
|
||||
*/
|
||||
"projectFolderUrl": "https://github.com/tldraw/tldraw/blob/main"
|
||||
},
|
||||
/**
|
||||
* Configures how the .d.ts rollup file will be generated.
|
||||
*/
|
||||
"dtsRollup": {
|
||||
/**
|
||||
* (REQUIRED) Whether to generate the .d.ts rollup file.
|
||||
*/
|
||||
"enabled": true,
|
||||
/**
|
||||
* Specifies the output path for a .d.ts rollup file to be generated without any trimming.
|
||||
* This file will include all declarations that are exported by the main entry point.
|
||||
*
|
||||
* If the path is an empty string, then this file will not be written.
|
||||
*
|
||||
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
||||
* prepend a folder token such as "<projectFolder>".
|
||||
*
|
||||
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
||||
* DEFAULT VALUE: "<projectFolder>/dist/<unscopedPackageName>.d.ts"
|
||||
*/
|
||||
"untrimmedFilePath": "<projectFolder>/packages/<unscopedPackageName>/api/internal.d.ts",
|
||||
/**
|
||||
* Specifies the output path for a .d.ts rollup file to be generated with trimming for an "alpha" release.
|
||||
* This file will include only declarations that are marked as "@public", "@beta", or "@alpha".
|
||||
*
|
||||
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
||||
* prepend a folder token such as "<projectFolder>".
|
||||
*
|
||||
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
||||
* DEFAULT VALUE: ""
|
||||
*/
|
||||
// "alphaTrimmedFilePath": "0.0.0",
|
||||
/**
|
||||
* Specifies the output path for a .d.ts rollup file to be generated with trimming for a "beta" release.
|
||||
* This file will include only declarations that are marked as "@public" or "@beta".
|
||||
*
|
||||
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
||||
* prepend a folder token such as "<projectFolder>".
|
||||
*
|
||||
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
||||
* DEFAULT VALUE: ""
|
||||
*/
|
||||
// "betaTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-beta.d.ts",
|
||||
/**
|
||||
* Specifies the output path for a .d.ts rollup file to be generated with trimming for a "public" release.
|
||||
* This file will include only declarations that are marked as "@public".
|
||||
*
|
||||
* If the path is an empty string, then this file will not be written.
|
||||
*
|
||||
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
||||
* prepend a folder token such as "<projectFolder>".
|
||||
*
|
||||
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
||||
* DEFAULT VALUE: ""
|
||||
*/
|
||||
"publicTrimmedFilePath": "<projectFolder>/packages/<unscopedPackageName>/api/public.d.ts"
|
||||
/**
|
||||
* When a declaration is trimmed, by default it will be replaced by a code comment such as
|
||||
* "Excluded from this release type: exampleMember". Set "omitTrimmingComments" to true to remove the
|
||||
* declaration completely.
|
||||
*
|
||||
* DEFAULT VALUE: false
|
||||
*/
|
||||
// "omitTrimmingComments": true
|
||||
},
|
||||
/**
|
||||
* Configures how the tsdoc-metadata.json file will be generated.
|
||||
*/
|
||||
"tsdocMetadata": {
|
||||
/**
|
||||
* Whether to generate the tsdoc-metadata.json file.
|
||||
*
|
||||
* DEFAULT VALUE: true
|
||||
*/
|
||||
"enabled": false
|
||||
/**
|
||||
* Specifies where the TSDoc metadata file should be written.
|
||||
*
|
||||
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
||||
* prepend a folder token such as "<projectFolder>".
|
||||
*
|
||||
* The default value is "<lookup>", which causes the path to be automatically inferred from the "tsdocMetadata",
|
||||
* "typings" or "main" fields of the project's package.json. If none of these fields are set, the lookup
|
||||
* falls back to "tsdoc-metadata.json" in the package folder.
|
||||
*
|
||||
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
|
||||
* DEFAULT VALUE: "<lookup>"
|
||||
*/
|
||||
// "tsdocMetadataFilePath": "<projectFolder>/dist/tsdoc-metadata.json"
|
||||
},
|
||||
/**
|
||||
* Configures how API Extractor reports error and warning messages produced during analysis.
|
||||
*
|
||||
* There are three sources of messages: compiler messages, API Extractor messages, and TSDoc messages.
|
||||
*/
|
||||
"messages": {
|
||||
/**
|
||||
* Configures handling of diagnostic messages reported by the TypeScript compiler engine while analyzing
|
||||
* the input .d.ts files.
|
||||
*
|
||||
* TypeScript message identifiers start with "TS" followed by an integer. For example: "TS2551"
|
||||
*
|
||||
* DEFAULT VALUE: A single "default" entry with logLevel=warning.
|
||||
*/
|
||||
"compilerMessageReporting": {
|
||||
/**
|
||||
* Configures the default routing for messages that don't match an explicit rule in this table.
|
||||
*/
|
||||
"default": {
|
||||
/**
|
||||
* Specifies whether the message should be written to the the tool's output log. Note that
|
||||
* the "addToApiReportFile" property may supersede this option.
|
||||
*
|
||||
* Possible values: "error", "warning", "none"
|
||||
*
|
||||
* Errors cause the build to fail and return a nonzero exit code. Warnings cause a production build fail
|
||||
* and return a nonzero exit code. For a non-production build (e.g. when "api-extractor run" includes
|
||||
* the "--local" option), the warning is displayed but the build will not fail.
|
||||
*
|
||||
* DEFAULT VALUE: "warning"
|
||||
*/
|
||||
"logLevel": "error"
|
||||
/**
|
||||
* When addToApiReportFile is true: If API Extractor is configured to write an API report file (.api.md),
|
||||
* then the message will be written inside that file; otherwise, the message is instead logged according to
|
||||
* the "logLevel" option.
|
||||
*
|
||||
* DEFAULT VALUE: false
|
||||
*/
|
||||
// "addToApiReportFile": false
|
||||
}
|
||||
// "TS2551": {
|
||||
// "logLevel": "warning",
|
||||
// "addToApiReportFile": true
|
||||
// },
|
||||
//
|
||||
// . . .
|
||||
},
|
||||
/**
|
||||
* Configures handling of messages reported by API Extractor during its analysis.
|
||||
*
|
||||
* API Extractor message identifiers start with "ae-". For example: "ae-extra-release-tag"
|
||||
*
|
||||
* DEFAULT VALUE: See api-extractor-defaults.json for the complete table of extractorMessageReporting mappings
|
||||
*/
|
||||
"extractorMessageReporting": {
|
||||
"default": {
|
||||
"logLevel": "error"
|
||||
},
|
||||
"ae-internal-missing-underscore": {
|
||||
"logLevel": "none",
|
||||
"addToApiReportFile": false
|
||||
},
|
||||
"ae-forgotten-export": {
|
||||
"logLevel": "error",
|
||||
"addToApiReportFile": false
|
||||
},
|
||||
"ae-wrong-input-file-type": {
|
||||
"logLevel": "none"
|
||||
}
|
||||
// "ae-extra-release-tag": {
|
||||
// "logLevel": "warning",
|
||||
// "addToApiReportFile": true
|
||||
// },
|
||||
//
|
||||
// . . .
|
||||
},
|
||||
/**
|
||||
* Configures handling of messages reported by the TSDoc parser when analyzing code comments.
|
||||
*
|
||||
* TSDoc message identifiers start with "tsdoc-". For example: "tsdoc-link-tag-unescaped-text"
|
||||
*
|
||||
* DEFAULT VALUE: A single "default" entry with logLevel=warning.
|
||||
*/
|
||||
"tsdocMessageReporting": {
|
||||
"default": {
|
||||
"logLevel": "error"
|
||||
// "addToApiReportFile": false
|
||||
}
|
||||
// "tsdoc-link-tag-unescaped-text": {
|
||||
// "logLevel": "warning",
|
||||
// "addToApiReportFile": true
|
||||
// },
|
||||
//
|
||||
// . . .
|
||||
}
|
||||
}
|
||||
}
|
||||
15
internal/config/package.json
Normal file
15
internal/config/package.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "config",
|
||||
"version": "0.0.0",
|
||||
"main": "index.js",
|
||||
"license": "SEE LICENSE IN LICENSE.md",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"@jest/expect-utils": "^30.0.5",
|
||||
"@peculiar/webcrypto": "^1.5.0",
|
||||
"jest-matcher-utils": "^30.0.5",
|
||||
"lazyrepo": "0.0.0-alpha.27",
|
||||
"vitest": "^5.0.0",
|
||||
"vitest-canvas-mock": "^1.1.3"
|
||||
}
|
||||
}
|
||||
37
internal/config/tsconfig.base.json
Normal file
37
internal/config/tsconfig.base.json
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"display": "Default",
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"importHelpers": true,
|
||||
"resolveJsonModule": true,
|
||||
"incremental": true,
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "react",
|
||||
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
||||
"module": "esnext",
|
||||
"target": "esnext",
|
||||
"moduleResolution": "bundler",
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitReturns": true,
|
||||
"noUncheckedSideEffectImports": false,
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"useDefineForClassFields": true,
|
||||
"noImplicitOverride": true,
|
||||
"experimentalDecorators": true,
|
||||
"types": ["node", "vitest/globals"]
|
||||
},
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
6
internal/config/tsconfig.json
Normal file
6
internal/config/tsconfig.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "./tsconfig.base.json",
|
||||
"include": ["vitest"],
|
||||
"exclude": ["node_modules", ".tsbuild*"],
|
||||
"compilerOptions": { "outDir": "./.tsbuild", "rootDir": "." }
|
||||
}
|
||||
51
internal/config/vitest/node-preset.ts
Normal file
51
internal/config/vitest/node-preset.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import path from 'path'
|
||||
import { defineConfig } from 'vitest/config'
|
||||
|
||||
const svgTransform = {
|
||||
name: 'svg-transform',
|
||||
transform(_code: string, id: string) {
|
||||
if (id.endsWith('.svg')) {
|
||||
return {
|
||||
code: 'export default {};',
|
||||
map: null,
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
},
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [svgTransform],
|
||||
test: {
|
||||
globals: true,
|
||||
environment: 'jsdom',
|
||||
// Persist transformed modules to node_modules/.vitest-cache so reruns skip re-transforming.
|
||||
// Only helps a warm cache: a cold run (fresh clone, cleared node_modules) pays full price.
|
||||
fsModuleCache: true,
|
||||
// Worker threads start much faster than forked processes. Projects needing real process
|
||||
// isolation (e.g. sync-worker, which passes node flags via execArgv) override this.
|
||||
pool: 'threads',
|
||||
setupFiles: [path.resolve(__dirname, './setup.ts')],
|
||||
include: ['src/**/*.{test,spec}.{js,ts,jsx,tsx}'],
|
||||
exclude: [
|
||||
'**/test/__fixtures__/**',
|
||||
'**/node_modules/**',
|
||||
'**/dist/**',
|
||||
'**/.tsbuild/**',
|
||||
'**/.tsbuild-dev/**',
|
||||
'**/.tsbuild-pub/**',
|
||||
],
|
||||
coverage: {
|
||||
include: ['src/**/*.{ts,tsx}'],
|
||||
exclude: ['**/*.test.*', '**/*.spec.*', '**/test/**', '**/__tests__/**'],
|
||||
},
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'~': path.resolve(process.cwd(), 'src'),
|
||||
},
|
||||
},
|
||||
ssr: {
|
||||
noExternal: ['@tiptap/react'],
|
||||
},
|
||||
})
|
||||
143
internal/config/vitest/setup.ts
Normal file
143
internal/config/vitest/setup.ts
Normal file
@@ -0,0 +1,143 @@
|
||||
import { equals, getObjectSubset, iterableEquality, subsetEquality } from '@jest/expect-utils'
|
||||
import {
|
||||
matcherHint,
|
||||
printDiffOrStringify,
|
||||
printExpected,
|
||||
printReceived,
|
||||
stringify,
|
||||
} from 'jest-matcher-utils'
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
await import('vitest-canvas-mock')
|
||||
}
|
||||
|
||||
// Crypto fallback for environments without a native WebCrypto implementation (e.g. the ai package).
|
||||
// jsdom provides window.crypto with subtle crypto, so this only kicks in elsewhere.
|
||||
if (typeof globalThis.crypto === 'undefined') {
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
const { Crypto } = require('@peculiar/webcrypto')
|
||||
globalThis.crypto = new Crypto()
|
||||
}
|
||||
|
||||
// Image.decode polyfill - this should be handled by individual package setups,
|
||||
// but including it here as a fallback
|
||||
if (typeof HTMLImageElement !== 'undefined') {
|
||||
if (!HTMLImageElement.prototype.decode) {
|
||||
HTMLImageElement.prototype.decode = function () {
|
||||
return Promise.resolve()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Path2D polyfills
|
||||
if (typeof Path2D !== 'undefined' && typeof Path2D.prototype.roundRect !== 'function') {
|
||||
Path2D.prototype.roundRect = function (x, y, w, h, _) {
|
||||
this.rect(x, y, w, h)
|
||||
}
|
||||
}
|
||||
|
||||
// CSS.supports polyfill for tests that use color spaces (e.g., highlight shapes)
|
||||
if (typeof CSS === 'undefined') {
|
||||
;(global as any).CSS = {}
|
||||
}
|
||||
if (typeof CSS.supports === 'undefined') {
|
||||
CSS.supports = () => false
|
||||
}
|
||||
|
||||
// Pointer capture polyfill. jsdom implements the PointerEvent constructor but not the pointer
|
||||
// capture model, so setPointerCapture/releasePointerCapture/hasPointerCapture are missing
|
||||
// (https://github.com/jsdom/jsdom/pull/2666). Our canvas event handlers capture the pointer on
|
||||
// pointerdown/up, so stub them out to avoid throwing.
|
||||
if (typeof Element !== 'undefined') {
|
||||
Element.prototype.setPointerCapture ??= function () {
|
||||
// noop
|
||||
}
|
||||
Element.prototype.releasePointerCapture ??= function () {
|
||||
// noop
|
||||
}
|
||||
Element.prototype.hasPointerCapture ??= function () {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Captured before any test file installs fake timers.
|
||||
const realSetTimeout = globalThis.setTimeout
|
||||
const realSetImmediate = globalThis.setImmediate
|
||||
|
||||
// Drain deferred React work before vitest tears down jsdom: exportToSvg unmounts its root in a
|
||||
// setTimeout(0) and every react-dom commit schedules a setImmediate that reads `window.event`.
|
||||
// Landing after teardown, those throw "window is not defined" as an unhandled error (flaky CI).
|
||||
if (typeof window !== 'undefined') {
|
||||
afterAll(async () => {
|
||||
// two passes: pass 1 fires pending timeouts and the setImmediate they enqueue; pass 2 covers
|
||||
// the scheduler re-arming itself when it yields mid-work
|
||||
for (let i = 0; i < 2; i++) {
|
||||
await new Promise((resolve) => realSetTimeout(resolve, 0))
|
||||
await new Promise((resolve) => realSetImmediate(resolve))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function convertNumbersInObject(obj: any, roundToNearest: number): any {
|
||||
if (!obj) return obj
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.map((x) => convertNumbersInObject(x, roundToNearest))
|
||||
}
|
||||
if (typeof obj === 'number') {
|
||||
// || 0 to avoid -0
|
||||
return Math.round(obj / roundToNearest) * roundToNearest || 0
|
||||
}
|
||||
if (typeof obj !== 'object') {
|
||||
return obj
|
||||
}
|
||||
|
||||
const r: any = {
|
||||
__converted: true,
|
||||
}
|
||||
|
||||
for (const k of Object.keys(obj)) {
|
||||
r[k] = convertNumbersInObject(obj[k], roundToNearest)
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
expect.extend({
|
||||
toCloselyMatchObject(actual: any, expected: any, roundToNearest = 0.0001) {
|
||||
const matcherName = 'toCloselyMatchObject'
|
||||
const options = {
|
||||
isNot: this.isNot,
|
||||
promise: this.promise,
|
||||
}
|
||||
|
||||
const EXPECTED_LABEL = 'Expected'
|
||||
const RECEIVED_LABEL = 'Received'
|
||||
|
||||
const newActualObj = convertNumbersInObject(actual, roundToNearest)
|
||||
|
||||
const newExpectedObj = convertNumbersInObject(expected, roundToNearest)
|
||||
|
||||
const pass = equals(newActualObj, newExpectedObj, [iterableEquality, subsetEquality])
|
||||
|
||||
const message = pass
|
||||
? () =>
|
||||
matcherHint(matcherName, undefined, undefined, options) +
|
||||
'\n\n' +
|
||||
`Expected: not ${printExpected(expected)}` +
|
||||
(stringify(expected) !== stringify(actual)
|
||||
? `\nReceived: ${printReceived(actual)}`
|
||||
: '')
|
||||
: () =>
|
||||
matcherHint(matcherName, undefined, undefined, options) +
|
||||
'\n\n' +
|
||||
printDiffOrStringify(
|
||||
expected,
|
||||
getObjectSubset(actual, expected),
|
||||
EXPECTED_LABEL,
|
||||
RECEIVED_LABEL,
|
||||
true
|
||||
)
|
||||
|
||||
return { message, pass }
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user