Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): update docusaurus monorepo to v3 (major) #3927

Merged
merged 18 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions documentation/docs/api_readme.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
`@cognite/reveal` supports `Node16` [module resolution](https://www.typescriptlang.org/tsconfig#moduleResolution), and if enabled in the consuming application will expose three modules:
- [@cognite/reveal](/api/modules/cognite_reveal.md) is the main module and has the main entry point of Reveal, [`Cognite3DViewer`](/api/classes/cognite_reveal.Cognite3DViewer.md). CAD models are represented by [`CogniteCadModel`](/api/classes/cognite_reveal.CogniteCadModel.md) and points clouds by [`CognitePointCloudModel`](/api/classes/cognite_reveal.CognitePointCloudModel.md).
- [@congite/reveal/tools](/api/modules/cognite_reveal_tools.md) contains a set of tools, e.g. [`AxisViewTool`](/api/classes/cognite_reveal_tools.AxisViewTool.md), [`TimelineTool`](/api/classes/cognite_reveal_tools.TimelineTool.md), and [`HtmlOverlayTool`](/api/classes/cognite_reveal_tools.HtmlOverlayTool.md) that works with `Cognite3DViewer`.
- [@cognite/reveal/extensions/datasource](/api/modules/cognite_reveal_extensions_datasource.md) allows providing custom data sources for geometry and model metadata.
- [@cognite/reveal](/api/@cognite/reveal/index.md) is the main module and has the main entry point of Reveal, [`Cognite3DViewer`](/api/@cognite/reveal/classes/Cognite3DViewer.md). CAD models are represented by [`CogniteCadModel`](/api/@cognite/reveal/classes/CogniteCadModel.md) and points clouds by [`CognitePointCloudModel`](/api/@cognite/reveal/classes/CognitePointCloudModel.md).
- [@congite/reveal/tools](/api/@cognite/reveal/tools/index.md) contains a set of tools, e.g. [`AxisViewTool`](/api/@cognite/reveal/tools/classes/AxisViewTool.md), [`TimelineTool`](/api/@cognite/reveal/tools/classes/TimelineTool.md), and [`HtmlOverlayTool`](/api/@cognite/reveal/tools/classes/HtmlOverlayTool.md) that works with `Cognite3DViewer`.
- [@cognite/reveal/extensions/datasource](/api/@cognite/reveal/extensions/datasource/index.md) allows providing custom data sources for geometry and model metadata.

:::note
If the consuming application does not enable `Node16` module resolution, then all types must be imported from `@cognite/reveal`.
:::
:::
3 changes: 2 additions & 1 deletion documentation/docs/components/LiveCodeSnippet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ function onRunCode(code: string) {
}

export const LiveCodeSnippet = (props: LiveCodeSnippetProps) => {

let code: string = props.children;
function setCode(newCode: string) {
code = newCode;
Expand Down Expand Up @@ -117,3 +116,5 @@ export const LiveCodeSnippet = (props: LiveCodeSnippetProps) => {
</button>
</>);
};

export default LiveCodeSnippet;
2 changes: 1 addition & 1 deletion documentation/docs/examples/cad-save-viewerstate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const myState = {
"renderGhosted": true
},
"modelId": 3356984403684032,
"revisionId": 6664823881595566,
"revisionId": 6049696084265067,
"styledSets": [
{
"token": "PropertyFilterNodeCollection",
Expand Down
16 changes: 8 additions & 8 deletions documentation/docs/examples/image360.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ description: Using and displaying 360 images using Reveal
import useBaseUrl from '@docusaurus/useBaseUrl';

360 images is a common way to augment the 3D experience of your application.
A 360 image is a controllable panoramic image that surrounds the original point from which the shot was taken.
A 360 image is a controllable panoramic image that surrounds the original point from which the shot was taken.
360 images simulate being in the shoes of a photographer and looking around to the left, right, up and down as desired as well as zooming.

The `Cognite3DViewer` entrypoint exposes the following methods related to 360 images.

```ts
add360ImageSet(
datasource: 'events',
eventFilter: { [key: string]: string },
datasource: 'events',
eventFilter: { [key: string]: string },
add360ImageOptions?: AddImage360Options
): Promise<Image360Collection>;

Expand All @@ -35,9 +35,9 @@ At this time, the only valid `datasource` is `'events'`, but you can expect more
The `eventFilter` property describes the filter that is used when fetching data from the data source.
This is a generic key-value pair and can point to any metdata that was set during ingestion.
`viewer.add360ImageSet(...)` will return a `Image360Collection` which contains each of the `image360` entities for this given set.
The definition of `Image360Collection` can be found [here.](../api/interfaces/cognite_reveal.Image360Collection)
The definition of `Image360Collection` can be found [here.](../api/@cognite/reveal/interfaces/Image360Collection)

The `AddImage360Options` is used for correcting / adding transformations to the set of 360 images. The declaration can be found [here.](../api/modules/cognite_reveal#addimage360options)
The `AddImage360Options` is used for correcting / adding transformations to the set of 360 images. The declaration can be found [here.](../api/@cognite/reveal/index.md#addimage360options)

:::note
The 360 images should be ingested with proper transformation data, and one should only rely on `AddImage360Options` when failing to do so or when using the same 360 images for multiple 3D models with different coordinate system.
Expand All @@ -63,11 +63,11 @@ An example of entering into a 360 image can be seen here:

To remove one or more 360 images you can use the `remove360Images(...)` method which will also cleanup icons and other related data to the instance.

The `Image360` declaration can be found here [here.](../api/interfaces/cognite_reveal.Image360)
The `Image360` declaration can be found here [here.](../api/@cognite/reveal/interfaces/Image360)

The `transform` property from `Image360` represents the world transformation (rotation and translation) of the 360 image.
The `Image360Visualization` object has convenience functionality related to the visualization of the 360 image such as setting the opacity of the given 360 image.

## Events
The `Image360Collection` exposes events `image360Entered` and `image360Exited` for subscribing to enter & exit from 360 image mode. The `image360Entered` event is also triggered when the [revision](#historical-images) of an image is changed.
Subscribing to the events can look like
Expand Down Expand Up @@ -104,4 +104,4 @@ const revisions = image360.getRevisions();
const newRevision = revisions[1];
await viewer.enter360Image(image360, newRevision);
alert(`Revision changed to ${newRevision.date}`);
```
```
4 changes: 2 additions & 2 deletions documentation/docs/extending/camera-manager.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ In certain cases it can be useful to customize behaviour of the camera:

To create a custom camera manager class, `CameraManager` interface from `@cognite/reveal` must be implemented
and provided to `Cognite3DViewer` on construction using the `cameraManager`-option. You can also set camera manager
in runtime by calling `setCameraManager` method of `Cognite3DViewer` class. Interface is defined [here in the API reference](../api/interfaces/cognite_reveal.CameraManager.md).
in runtime by calling `setCameraManager` method of `Cognite3DViewer` class. Interface is defined [here in the API reference](../api/@cognite/reveal/interfaces/CameraManager.md).

Main implementation specific functions are `setCameraState`, `fitCameraToBoundingBox` and `update`.
Setting state shouldn't be possible when `rotation` and `target` are passed at the same time because they could conflict.
Expand Down Expand Up @@ -160,4 +160,4 @@ the behaviour of camera controls (`OrbitControls` in this case). For calculating

3. Inside `update` method you should update `near` and `far` planes of the camera, which can be easily done using `updateCameraNearAndFar` method of `CameraManagerHelper`.

4. The functions `activate` and `deactivate` are called automatically when a new CameraManager is assigned to the Cognite3DViewer. These functions are intended to help manage enabling and disabling of input when the manager changes state. Return value of `get enabled` should reflect this state.
4. The functions `activate` and `deactivate` are called automatically when a new CameraManager is assigned to the Cognite3DViewer. These functions are intended to help manage enabling and disabling of input when the manager changes state. Return value of `get enabled` should reflect this state.
10 changes: 6 additions & 4 deletions documentation/docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module.exports = {
import { themes } from 'prism-react-renderer';

export default {
title: 'Reveal docs',
tagline: '@cognite/reveal documentation site',
url: 'https://cognitedata.github.io',
Expand All @@ -17,7 +19,7 @@ module.exports = {
},
prism: {
// changes syntax highlighting theme
theme: require('prism-react-renderer/themes/oceanicNext'),
theme: themes.oceaticNext
},
navbar: {
title: '@cognite/reveal',
Expand Down Expand Up @@ -85,9 +87,9 @@ module.exports = {
};

/*
* By default autogenerated sidebars are sorted alphabetically by path and filename.
* By default autogenerated sidebars are sorted alphabetically by path and filename.
* This function is used to allow items in the same folder to be sorted alphabetically by label.
*
*
* Documentation for sidebarItemsGenerator: https://docusaurus.io/docs/sidebar/autogenerated
*/
function recursiveSortByLabel(items) {
Expand Down
10 changes: 5 additions & 5 deletions documentation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
"dependencies": {
"@azure/msal-browser": "3.17.0",
"@codemirror/lang-javascript": "6.2.2",
"@docusaurus/core": "2.4.3",
"@docusaurus/preset-classic": "2.4.3",
"@docusaurus/remark-plugin-npm2yarn": "2.4.3",
"@docusaurus/core": "3.4.0",
"@docusaurus/preset-classic": "3.4.0",
"@docusaurus/remark-plugin-npm2yarn": "3.4.0",
"@uiw/codemirror-theme-material": "4.22.2",
"@uiw/react-codemirror": "4.22.2",
"clsx": "2.1.1",
Expand All @@ -44,8 +44,8 @@
"docusaurus-plugin-typedoc": "1.0.1",
"replace": "1.2.2",
"rimraf": "5.0.7",
"typedoc": "0.25.13",
"typedoc-plugin-markdown": "3.17.1",
"typedoc": "0.26.0",
"typedoc-plugin-markdown": "4.1.0",
"typedoc-plugin-no-inherit": "1.4.0",
"typescript": "5.5.2"
},
Expand Down
154 changes: 89 additions & 65 deletions documentation/src/plugins/remark-runnable-reveal-demo.js
Original file line number Diff line number Diff line change
@@ -1,73 +1,97 @@
const transformNode = (node) => {
const code = node.value
.trim()
// allows new lines in jsx snippets
.replace(/(\r\n|\n|\r)/gm, '\n')
// handles backtick usage in jsx snippets
.replace(/`/gm, '\\`')
.replace(/\$/gm, '\\$');
import { is } from "unist-util-is";
import { visit } from "unist-util-visit";

return [
{
type: 'jsx',
value: '<LiveCodeSnippet>{`' + code + '`}</LiveCodeSnippet>',
},
];
};
/**
* adapted from https://github.com/mrazauskas/docusaurus-remark-plugin-tab-blocks/blob/b7dab1533dc422df00ce965a87fef840a62255bb/index.js
*/

function getImportNodes(metaString) {

const docsPath = getDocsPath(metaString);

const versionedImportNode = {
runnable: {
type: 'import',
value:
"import { LiveCodeSnippet } from '@site/docs/components/LiveCodeSnippet';",
},
'runnable-1x': {
type: 'import',
value:
"import { LiveCodeSnippet } from '@site/versioned_docs/version-1.x/components/LiveCodeSnippet';",
},
'runnable-2x': {
type: 'import',
value:
"import { LiveCodeSnippet } from '@site/versioned_docs/version-2.x/components/LiveCodeSnippet';",
},
'runnable-3x': {
type: 'import',
value:
"import { LiveCodeSnippet } from '@site/versioned_docs/version-3.x/components/LiveCodeSnippet';",
},
'runnable-4x': {
type: 'import',
value:
"import { LiveCodeSnippet } from '@site/versioned_docs/version-4.x/components/LiveCodeSnippet';",
if (docsPath === undefined) {
return undefined;
}
};

module.exports = () => {
let transformed = false;
let importNode;
const transformer = (node) => {
if (node.type === 'code' && versionedImportNode[node.meta]) {
transformed = true;
importNode = versionedImportNode[node.meta];
return transformNode(node);
return {
data: {
estree: {
body: [
{
source: {
raw: `'@site/${docsPath}/components/LiveCodeSnippet'`,
type: "Literal",
value: `@site/${docsPath}/components/LiveCodeSnippet`,
},
specifiers: [
{
local: { name: "LiveCodeSnippet", type: "Identifier" },
type: "ImportDefaultSpecifier",
},
],
type: "ImportDeclaration",
},
],
type: "Program",
},
},
type: "mdxjsEsm",
value: `import LiveCodeSnippet from '@site/${docsPath}/components/LiveCodeSnippet';`,
};

function getDocsPath(metaString) {
switch(metaString) {
case 'runnable': return 'docs';
case 'runnable-1x': return 'versioned_docs/version-1.x';
case 'runnable-2x': return 'versioned_docs/version-2.x';
case 'runnable-3x': return 'versioned_docs/version-3.x';
case 'runnable-4x': return 'versioned_docs/version-4.x';
default: return undefined;
}
if (Array.isArray(node.children)) {
let index = 0;
while (index < node.children.length) {
const result = transformer(node.children[index]);
if (result) {
node.children.splice(index, 1, ...result);
index += result.length;
} else {
index += 1;
}
}
}

function createSnippet(codeNode) {
return {
type: 'mdxJsxFlowElement',
name: 'LiveCodeSnippet',
attributes: [],
children: [{ type: 'text', value: codeNode.value }]
};
}

function resolveConfig(options) {
return {
groupId: options.groupId,
labels: new Map([
["js", "JavaScript"],
["ts", "TypeScript"],
...(options.labels || []),
]),
sync: options.sync ?? true,
};
}

function plugin(options = {}) {
const config = resolveConfig(options);

return function transformer(tree) {
let importNodes = undefined;

visit(tree, ['code', 'mdxjsEsm'], (node, index, parent) => {
if (!node.meta?.includes('runnable')) {
return;
}

importNodes = getImportNodes(node.meta);

parent.children[index] = createSnippet(node);
});

if (importNodes !== undefined) {
tree.children.unshift(importNodes);
}
if (node.type === 'root' && transformed) {
node.children.unshift(importNode);
}
return null;
};
return transformer;
};
}

export default plugin;
6 changes: 5 additions & 1 deletion documentation/typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
"excludePrivate": true,
"excludeProtected": true,
"excludeInternal": true,
"excludeTags": ["@experimental"],
"visibilityFilters": {
"@experimental": true
},
"readme": "docs/api_readme.md",
"tsconfig": "../viewer/tsconfig.typedoc.json",
"out": "./generated",
Expand All @@ -18,4 +22,4 @@
"../viewer/api-entry-points/datasource.ts",
"../viewer/api-entry-points/tools.ts"
]
}
}
Loading
Loading