Skip to content

Commit 27c2231

Browse files
Upgrade docusaurus and novorender-api to v2 (#39)
* Upgrade docusaurus and novorender-api to v2 - Update typescript (doesn't work with new novorender-api anymore), typedoc, docusaurus - Update git path to novorender-api - Update paths to novorender-api v2 files - Remove View.downloadImports and associated code - Rename merge-decl-files to extract-web-api and simplify it since we have just one .d.ts now. Also remove dts-bundle - not needed anymore - Do a hack to preserve links for data-js-api * Fix body data-theme * Prevent creating 2 views in playground (which causes blinking) * Fix opaque clipping planes * Update some previews and minor playground fix * - Change /ts to /novorender-api - Remove some "open source" mentions - Fix some links and casing * Fix some broken links * Fix (or a workaround) for broken links * Run theme workaround only in browser * Improve theme workaround * Minor comment fix * Update type-definitions/typedoc-custom-root.mjs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Use capital case Namespaces * Back to lowercase namespaces to not cause broken links * Update actions/checkout and use SSH path in git submodule * Use github_token for submodules * Try to fetch novorender-api separately * Remove token * Set ref * Add token back * - Set token to secrets.cicd - Update @novorender * Simplify repo pull * Add npm configuration * Move build outside oryx * run ci verbose for debugging * Remove procore artifactory from package-lock * Rollback * Configure npm * Try oryx build again * Clean up * Remove irrelevant comment --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 9efd857 commit 27c2231

39 files changed

+29247
-27906
lines changed

.github/workflows/azure-static-web-apps-happy-pebble-0a13f1503.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,21 @@ on:
88
types: [opened, synchronize, reopened, closed]
99
branches:
1010
- main
11-
1211
jobs:
1312
build_and_deploy_job:
1413
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
1514
runs-on: ubuntu-22.04
1615
name: Build and Deploy Job
1716
steps:
18-
- uses: actions/checkout@v2
17+
- uses: actions/checkout@v4
1918
with:
2019
submodules: true
21-
- name: Build And Deploy
20+
token: ${{ secrets.cicd }}
21+
- name: Configure npm
22+
run: |
23+
echo "@novorender:registry=https://npm.pkg.github.com" >> .npmrc
24+
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> .npmrc
25+
- name: Deploy
2226
id: builddeploy
2327
uses: Azure/static-web-apps-deploy@v1
2428
with:

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "@novorender"]
22
path = @novorender
3-
url = https://github.com/novorender/ts
3+
url = git@github.com:novorender/novorender-api.git

@novorender

demo-snippets/demo/types.ts

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type DeviceProfile, type ViewImports, type ViewImportmap } from "@novorender/api";
1+
import { type DeviceProfile } from "@novorender/api";
22
import type { IPosition } from "monaco-editor";
33

44
export interface IModule<R = void, P extends any[] = []> {
@@ -23,31 +23,19 @@ export interface ICanvas {
2323
export interface IDemoContext<T = any> {
2424
readonly canvasElements: ICanvas;
2525
readonly deviceProfile: DeviceProfile;
26-
readonly imports: ViewImports;
2726
reportErrors(...errors: any[]): void;
2827
}
2928

30-
/** Core imports, you can provide your own to `createDemoContext` if want */
31-
export let coreImportsPromise: Promise<ViewImports>;
32-
// for fixing docusaurus build
33-
if (typeof window !== "undefined" && typeof navigator !== 'undefined') {
29+
export async function createDemoContext(
30+
canvasElements: ICanvas,
31+
reportErrors: (...errors: any[]) => void
32+
): Promise<IDemoContext> {
3433
// must be imported dynamically to fix SSG build
35-
import("@novorender/api").then(({ View }) => {
36-
const baseUrl = new URL(".", location.origin);
37-
const coreImportsMap: ViewImportmap = { baseUrl };
38-
coreImportsPromise = View.downloadImports(coreImportsMap);
39-
});
40-
}
41-
42-
export async function createDemoContext(canvasElements: ICanvas, reportErrors: (...errors: any[]) => void, importsPromise: Promise<ViewImports> = coreImportsPromise): Promise<IDemoContext> {
43-
44-
// must be imported dynamically to fix SSG build
45-
const { getDeviceProfile } = await import("@novorender/api")
34+
const { getDeviceProfile } = await import("@novorender/api");
4635

4736
const gpuTier = 2; // laptop with reasonably new/powerful GPU.
4837
const deviceProfile = getDeviceProfile(gpuTier);
49-
const imports = await importsPromise;
50-
return { canvasElements, deviceProfile, imports, reportErrors };
38+
return { canvasElements, deviceProfile, reportErrors };
5139
}
5240

5341
export interface IDempProps {

demo-snippets/guides/clipping/visualize.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { type RecursivePartial, type RenderStateClipping, ClippingMode } from "@novorender/api";
22

33
export function main(centerX: number, centerY: number, centerZ: number): RecursivePartial<RenderStateClipping> {
4+
// Set samplesMSAA larger than 1 for the planes to have transparency
5+
// view.modifyRenderState({ output: { samplesMSAA: 2 } });
6+
47
return {
58
enabled: true,
69
draw: true,

demo-snippets/guides/interactive_examples/basic.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
import { View, type DeviceProfile, type ViewImports } from "@novorender/api";
1+
import { View, type DeviceProfile } from "@novorender/api";
22

3-
export async function main(canvas: HTMLCanvasElement, deviceProfile: DeviceProfile, imports: ViewImports, signal: AbortSignal) {
4-
const view = new View(canvas, deviceProfile, imports);
3+
export async function main(
4+
canvas: HTMLCanvasElement,
5+
deviceProfile: DeviceProfile,
6+
signal: AbortSignal
7+
) {
8+
const view = new View(canvas, deviceProfile);
59
view.modifyRenderState({ grid: { enabled: true } });
610
await view.run(signal);
711
view.dispose();

demo-snippets/guides/object_metadata/metadata_from_search.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,17 @@ export async function main(view: View, sceneData: SceneData) {
1818

1919
const searchResult: ObjectData[] = [];
2020

21-
// Use the first 5 results to keep the properties in the property box relatively short
22-
for (let i = 0; i < 5; i++) {
21+
// Use the first 10 results to keep the properties in the property box relatively short
22+
for (let i = 0; i < 10; i++) {
2323
const iteratorResult = await iterator.next();
2424
if (iteratorResult.done) {
2525
break;
2626
}
2727
// Because we have set the search option "full: true"
2828
// .loadMetadata() will not result in any more requests being made
2929
// Try flipping it to false and see the difference in the network request log
30-
const objectWithMetadata = await iteratorResult.value.loadMetaData();
30+
const objectWithMetadata =
31+
await iteratorResult.value.loadMetaData();
3132
searchResult.push(objectWithMetadata);
3233
}
3334

demo-snippets/guides/views/creation.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import { getDeviceProfile, View, type GPUTier, type ViewImports } from "@novorender/api";
1+
import { getDeviceProfile, View, type GPUTier } from "@novorender/api";
22

3-
export async function main(canvas: HTMLCanvasElement, _: unknown, imports: ViewImports) {
3+
export async function main(canvas: HTMLCanvasElement, _: unknown) {
44
const gpuTier: GPUTier = 2;
55
const deviceProfile = getDeviceProfile(gpuTier);
6-
const view = new View(canvas, deviceProfile, imports);
6+
const view = new View(canvas, deviceProfile);
77
view.modifyRenderState({ grid: { enabled: true } });
88
const abortController = new AbortController();
9-
setTimeout(() => { abortController.abort(); }, 5_000); // exit after 5 seconds.
9+
setTimeout(() => {
10+
abortController.abort();
11+
}, 5_000); // exit after 5 seconds.
1012
await view.run(abortController.signal);
1113
view.dispose();
1214
alert("View disposed!");

demo-snippets/hosts/barebone.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { IDemoContext, IDemoHost, IModule } from "../demo";
2-
import { DeviceProfile, Core3DImports } from "@novorender/api";
2+
import { DeviceProfile } from "@novorender/api";
33

4-
type Args = [canvas: HTMLCanvasElement, deviceProfile: DeviceProfile, imports: Core3DImports, signal: AbortSignal];
4+
type Args = [
5+
canvas: HTMLCanvasElement,
6+
deviceProfile: DeviceProfile,
7+
signal: AbortSignal,
8+
];
59
type Ret = Promise<void>;
610
type Module = IModule<Ret, Args>;
711

@@ -24,15 +28,14 @@ export class BareboneDemoHost implements IDemoHost<Module> {
2428
const {
2529
canvasElements: { primaryCanvas: canvas },
2630
deviceProfile,
27-
imports,
2831
} = this.context;
2932
this.abortController?.abort();
3033
this.abortController = new AbortController();
3134
const { signal } = this.abortController;
3235
let moduleError;
3336
try {
3437
await this.mainPromise;
35-
this.mainPromise = module.main(canvas, deviceProfile, imports, signal);
38+
this.mainPromise = module.main(canvas, deviceProfile, signal);
3639
} catch (error) {
3740
moduleError = error;
3841
} finally {

demo-snippets/hosts/base.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ export abstract class BaseDemoHost {
1111
const {
1212
canvasElements: { primaryCanvas: canvas },
1313
deviceProfile,
14-
imports,
1514
} = this.context;
16-
this.view = new View(canvas, deviceProfile, imports);
15+
this.view = new View(canvas, deviceProfile);
1716
}
1817

1918
async run(cb: (isReady: boolean) => void) {
@@ -37,12 +36,13 @@ export abstract class BaseDemoHost {
3736
init?(): Promise<void>;
3837
animate?(time: number): Promise<void>;
3938

40-
async loadScene(baseUrl: URL, sceneId: string, version: string = "index.json") {
39+
async loadScene(
40+
baseUrl: URL,
41+
sceneId: string,
42+
version: string = "index.json"
43+
) {
4144
const { view } = this;
42-
const config = await view.loadScene(
43-
baseUrl,
44-
sceneId,
45-
version);
45+
const config = await view.loadScene(baseUrl, sceneId, version);
4646
const { center, radius } = config.boundingSphere;
4747
view.activeController.autoFit(center, radius);
4848
const [cx, cy, cz] = config.center;

0 commit comments

Comments
 (0)