Skip to content

Commit cc2df2b

Browse files
committed
Merge branch 'master' into release
2 parents 27211f0 + e66222b commit cc2df2b

File tree

785 files changed

+20397
-11838
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

785 files changed

+20397
-11838
lines changed

.github/workflows/publish-docs.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Publish docs
2+
3+
on:
4+
workflow_dispatch
5+
6+
jobs:
7+
build:
8+
runs-on: windows-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- name: Use Node.js 16.x
12+
uses: actions/setup-node@v3
13+
with:
14+
node-version: '16.x'
15+
cache: 'npm'
16+
- run: npm ci
17+
- run: npm run docs:build
18+
- name: Upload pages artifact
19+
uses: actions/upload-pages-artifact@v2
20+
with:
21+
path: docs/.vitepress/dist
22+
23+
publish:
24+
needs: build
25+
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
26+
permissions:
27+
pages: write # to deploy to Pages
28+
id-token: write # to verify the deployment originates from an appropriate source
29+
30+
# Deploy to the github-pages environment
31+
environment:
32+
name: github-pages
33+
url: ${{ steps.deployment.outputs.page_url }}
34+
35+
# Specify runner + deployment step
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Deploy to GitHub Pages
39+
id: deployment
40+
uses: actions/deploy-pages@v2 # or the latest "vX.X.X" version tag for this action
41+
42+
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Update E2E snapshots
2+
3+
on:
4+
workflow_dispatch
5+
6+
jobs:
7+
update:
8+
runs-on: windows-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- name: Use Node.js 16.x
12+
uses: actions/setup-node@v3
13+
with:
14+
node-version: '16.x'
15+
cache: 'npm'
16+
- run: npm ci
17+
- run: npm run test-e2e --- -u
18+
- run: node scripts/copy-snapshot-changes.js
19+
- name: Upload changed snapshots
20+
uses: actions/upload-artifact@v3
21+
with:
22+
name: changed-snapshots
23+
path: .updated-snapshots/

.gitignore

+8-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,11 @@ devtools/temp
66
test/e2e/server/content/infinite-canvas.js
77
test/e2e/server/content/test-case/rhino.jpg
88
test/e2e/server/content/test-page/test-page-lib.js
9-
docs/dev/page/infinite-canvas.js
9+
docs/dev/page/infinite-canvas.js
10+
.rollup.cache
11+
dev-utils/app/dist
12+
docs/.vitepress/dist
13+
docs/.vitepress/cache
14+
docs/.vitepress/api-docs/.temp
15+
test-e2e/test-page-lib/impl/dist
16+
.updated-snapshots

.vscode/launch.json

+3-8
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,10 @@
88
"type": "node",
99
"request": "launch",
1010
"name": "Debug test",
11-
"skipFiles": [
12-
"<node_internals>/**"
13-
],
14-
"program": "${workspaceFolder}/node_modules/.bin/jest",
15-
"args": ["${fileBasenameNoExtension}", "--config","./test/jest.config.js"],
1611
"autoAttachChildProcesses": true,
17-
"windows": {
18-
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
19-
}
12+
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
13+
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
14+
"args": ["run", "${relativeFile}", "--test-timeout=3600000", "--config", "vitest.config.ts"]
2015
}
2116
]
2217
}

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var context = infiniteCanvas.getContext("2d");
2323
Include `InfiniteCanvas` in your web page:
2424

2525
```html
26-
<script src="https://cdn.jsdelivr.net/npm/[email protected].1/dist/infinite-canvas.js"></script>
26+
<script src="https://cdn.jsdelivr.net/npm/[email protected].2/dist/infinite-canvas.umd.cjs"></script>
2727
```
2828

2929
or install it using npm:

copy-e2e.js

-4
This file was deleted.

dist/infinite-canvas.js

+6,153-1
Large diffs are not rendered by default.

dist/infinite-canvas.umd.cjs

+1
Large diffs are not rendered by default.

dist/types/infinite-canvas-rendering-context-2d.d.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
/**
22
* This interface inherits all properties and methods from [`CanvasRenderingContext2D`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D)
3-
*
4-
* @remarks
5-
* `InfiniteCanvasRenderingContext2D` currently does **not** support [`getImageData()`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/getImageData), [`createImageData()`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createImageData), [`isPointInPath()`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/isPointInPath), [`isPointInStroke()`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/isPointInStroke), [`drawFocusIfNeeded()`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawFocusIfNeeded) and [`scrollPathIntoView()`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/scrollPathIntoView)
63
*/
74
export interface InfiniteCanvasRenderingContext2D extends CanvasRenderingContext2D {
85
/**

dist/types/infinite-canvas-touch-list.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { InfiniteCanvasTouch } from "./infinite-canvas-touch";
22
export interface InfiniteCanvasTouchList extends TouchList {
3+
[Symbol.iterator](): IterableIterator<InfiniteCanvasTouch>;
34
item(index: number): InfiniteCanvasTouch | null;
45
[index: number]: InfiniteCanvasTouch;
56
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { fileURLToPath } from "url";
2+
import { Application, TSConfigReader, type TypeDocOptions } from 'typedoc'
3+
4+
export const outDir = fileURLToPath(new URL('./.temp', import.meta.url));
5+
6+
export async function createApplication(): Promise<Application>{
7+
const application = new Application();
8+
application.options.addReader(new TSConfigReader())
9+
await application.bootstrapWithPlugins({
10+
entryPoints: [fileURLToPath(new URL('../../../src/api-surface/infinite-canvas.ts', import.meta.url))],
11+
entryPointStrategy: 'expand',
12+
tsconfig: fileURLToPath(new URL('../../../ts-config-types.json', import.meta.url)),
13+
out: outDir,
14+
excludeExternals: true,
15+
hideInPageTOC: true,
16+
hideBreadcrumbs: true,
17+
githubPages: false,
18+
plugin: ['typedoc-plugin-markdown'],
19+
readme: 'none',
20+
entryDocument: 'index.md'
21+
} as Partial<TypeDocOptions>)
22+
return application;
23+
}
24+
25+
export async function watchApplication(){
26+
const application = await createApplication();
27+
await new Promise<void>((res) => {
28+
application.convertAndWatch(async (project) => {
29+
await application.generateDocs(project, outDir);
30+
res();
31+
})
32+
})
33+
}
34+
35+
export async function buildApplication(){
36+
const app = await createApplication();
37+
const project = await app.convert();
38+
if(!project){
39+
return;
40+
}
41+
await app.generateDocs(project, outDir);
42+
}
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import type { PluginOption } from "vite";
2+
import path from 'path'
3+
import fs from 'fs/promises'
4+
import { outDir, watchApplication } from './create-application'
5+
6+
export default function addApi(): PluginOption{
7+
let watching: boolean = false;
8+
return {
9+
name: 'vite-plugin-add-api-docs-serve',
10+
apply: 'serve',
11+
configureServer: async () => {
12+
if(watching){
13+
return;
14+
}
15+
await watchApplication();
16+
watching = true;
17+
},
18+
load: {
19+
order: 'post',
20+
handler: async (id: string) => {
21+
const apiMatch = id.match(/^\/api\/(.*)$/)
22+
if(!apiMatch){
23+
return;
24+
}
25+
const [,requested] = apiMatch;
26+
const resultPath = path.resolve(outDir, requested);
27+
const result = await fs.readFile(resultPath, {encoding: 'utf-8'});
28+
return result;
29+
}
30+
}
31+
};
32+
}

docs/.vitepress/config.ts

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { fileURLToPath } from 'url'
2+
import { defineConfig } from 'vitepress'
3+
import { addExamples } from '../../examples/backend/vite-plugin'
4+
import addApi from './api-docs/serve-plugin'
5+
6+
// https://vitepress.dev/reference/site-config
7+
export default defineConfig({
8+
title: "InfiniteCanvas",
9+
ignoreDeadLinks: true,
10+
description: "The HTML &lt;canvas&gt; element, made infinite",
11+
themeConfig: {
12+
logo: '/logo.svg',
13+
// https://vitepress.dev/reference/default-theme-config
14+
nav: [
15+
{ text: 'Home', link: '/' },
16+
{ text: 'Guide', link: '/guide' },
17+
{ text: 'API', link: '/api/' }
18+
],
19+
20+
sidebar: [
21+
{
22+
text: 'Getting started',
23+
link: '/getting-started'
24+
},
25+
{
26+
text: 'Guide',
27+
link: '/guide'
28+
},
29+
{
30+
text: 'API',
31+
link: '/api/'
32+
}
33+
],
34+
35+
socialLinks: [
36+
{ icon: 'github', link: 'https://github.com/emilefokkema/infinite-canvas' }
37+
],
38+
39+
outline: [2, 3]
40+
},
41+
vite: {
42+
build: {
43+
emptyOutDir: false
44+
},
45+
resolve: {
46+
alias: {
47+
'infinite-canvas': fileURLToPath(new URL('../../src/infinite-canvas.ts', import.meta.url))
48+
}
49+
},
50+
plugins: [
51+
addExamples({external: {publicPath: '/examples'}}),
52+
addApi()
53+
]
54+
}
55+
})
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { defineLoader } from 'vitepress'
2+
// @ts-ignore: The current file is part of both the 'ts-config-docs-app.json' project and the 'ts-config-docs-config.json'
3+
// project, but retrieve-examples.ts is only part of the latter. C'est la vitepress.
4+
import { findExamples } from '../../../examples/backend/retrieval/retrieve-examples';
5+
import type { ExampleProject } from '../../../examples/shared/examples'
6+
7+
declare const data: ExampleProject[];
8+
export {data}
9+
10+
export default defineLoader({
11+
async load(): Promise<ExampleProject[]>{
12+
return await findExamples([
13+
'getting-started',
14+
'start-path-at-infinity',
15+
'line-to-infinity',
16+
'infinite-rectangles-1'
17+
]);
18+
}
19+
})
+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<script setup lang="ts">
2+
import sdk from '@stackblitz/sdk'
3+
import { onMounted, inject, shallowRef } from 'vue'
4+
import { exampleDataInjectionKey } from './constants'
5+
import type { ExampleProject } from '../../../examples/shared/examples';
6+
const props = defineProps({
7+
exampleId: {
8+
type: String,
9+
required: true
10+
}
11+
})
12+
13+
const data = inject(exampleDataInjectionKey);
14+
const project = shallowRef<ExampleProject | null>(null);
15+
16+
function openProjectInStackBlitz(): void{
17+
const projectValue = project.value;
18+
if(!projectValue){
19+
return;
20+
}
21+
const packageJson = {
22+
name: projectValue.id,
23+
version: "0.0.0",
24+
private: true,
25+
dependencies: {'ef-infinite-canvas': '^0.6.2'}
26+
}
27+
sdk.openProject({
28+
title: projectValue.title,
29+
template: 'javascript',
30+
files: {
31+
...projectValue.files,
32+
'package.json': JSON.stringify(packageJson, null, 2)
33+
},
34+
dependencies: packageJson.dependencies
35+
})
36+
}
37+
onMounted(() => {
38+
if(!data){
39+
return;
40+
}
41+
project.value = data.find((p: ExampleProject) => p.id === props.exampleId) || null;
42+
})
43+
</script>
44+
45+
<template>
46+
<div>
47+
<div v-if="!!project" class="stackblitz-button" @click="openProjectInStackBlitz">
48+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" height="28" width="28">
49+
<path fill="#1374EF" d="M12.747 16.273h-7.46L18.925 1.5l-3.671 10.227h7.46L9.075 26.5l3.671-10.227z"></path>
50+
</svg>
51+
</div>
52+
<div class="warning" v-else>could not find example files!</div>
53+
</div>
54+
55+
56+
</template>
57+
58+
<style lang="css" scoped>
59+
.stackblitz-button{
60+
display: inline-block;
61+
color: #1374EF;
62+
opacity: .7;
63+
cursor: pointer;
64+
}
65+
.stackblitz-button:hover{
66+
opacity: 1;
67+
}
68+
.warning{
69+
color: #ff000044;
70+
}
71+
</style>

docs/.vitepress/theme/constants.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type { InjectionKey } from "vue";
2+
import type { ExampleProject } from '../../../examples/shared/examples';
3+
import type { ExampleRegistry } from "./example-registry";
4+
5+
export const exampleDataInjectionKey: InjectionKey<ExampleProject[]> = Symbol();
6+
export const exampleRegistryInjectionKey: InjectionKey<ExampleRegistry> = Symbol();

0 commit comments

Comments
 (0)