Skip to content

Commit

Permalink
Convert to modules. Try to fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
javagl committed Nov 27, 2023
1 parent a79c2cc commit b6e792f
Show file tree
Hide file tree
Showing 216 changed files with 853 additions and 989 deletions.
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"about:start": "echo 'Start the tools, as a TypeScript command line application'",
"about:eslint": "echo 'Perform linting of the source code. This may modify the source files.'",
"about:build": "echo 'Run the TypeScript compiler to generate the build output.'",
"about:clean": "echo 'Clean the cached build information'",
"about:test": "echo 'Execute the unit tests'",
"about:coverage": "echo 'Compute the test coverage'",
"about:prettier-check": "echo 'Check the formatting of the source code (without fixing formatting errors).'",
Expand All @@ -63,8 +62,7 @@
"about:package": "echo 'Prepare a package that can then be published on NPM'",
"start": "npx ts-node src/main.ts",
"eslint": "eslint \"./**/*.ts\" --cache",
"build": "tsc --build --verbose",
"clean": "tsc --build --clean",
"build": "tsc --build --verbose --force",
"test": "ts-node node_modules/jasmine/bin/jasmine --config=specs/jasmine.json",
"coverage": "nyc npm run test",
"prettier-check": "prettier --check \"**/*\"",
Expand Down
3 changes: 2 additions & 1 deletion packages/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@3d-tiles-tools/base",
"version": "0.3.0",
"description": "3D Tiles tools basic utility classes",
"type": "module",
"source": "./src/index.ts",
"types": "./build/index.d.ts",
"dependencies": {
Expand All @@ -16,7 +17,7 @@
"scripts": {
"about:build": "echo 'Run the TypeScript compiler to generate the build output.'",
"about:test": "echo 'Execute the unit tests'",
"build": "npx tsc --build",
"build": "npx tsc --build --verbose --force",
"test": "ts-node ../../node_modules/jasmine/bin/jasmine --config=specs/jasmine.json"
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/base/specs/base/BuffersJsonSpec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Buffers } from "../../src/base/Buffers";
import { Buffers } from "../../src/base/Buffers.js";

describe("Buffer::isProbablyJson", function () {
it("detects JSON object", function () {
Expand Down
2 changes: 1 addition & 1 deletion packages/base/specs/base/IterablesSpec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Iterables } from "../../src/base/Iterables";
import { Iterables } from "../../src/base/Iterables.js";

// Note: These tests obtain iterable objects, most of them create
// arrays from these iterable objects TWICE, to make sure that
Expand Down
4 changes: 2 additions & 2 deletions packages/base/specs/contentTypes/ContentDataTypeChecksSpec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ContentDataTypes } from "../../src/contentTypes/ContentDataTypes";
import { ContentDataTypeChecks } from "../../src/contentTypes/ContentDataTypeChecks";
import { ContentDataTypes } from "../../src/contentTypes/ContentDataTypes.js";
import { ContentDataTypeChecks } from "../../src/contentTypes/ContentDataTypeChecks.js";

describe("ContentDataTypeChecks", function () {
it("returns true when included is undefined and excluded is undefined", async function () {
Expand Down
6 changes: 3 additions & 3 deletions packages/base/specs/contentTypes/ContentDataTypesSpec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ContentDataTypes } from "../../src/contentTypes/ContentDataTypes";
import { BufferedContentData } from "../../src/contentTypes/BufferedContentData";
import { ContentDataTypeRegistry } from "../../src/contentTypes/ContentDataTypeRegistry";
import { ContentDataTypes } from "../../src/contentTypes/ContentDataTypes.js";
import { BufferedContentData } from "../../src/contentTypes/BufferedContentData.js";
import { ContentDataTypeRegistry } from "../../src/contentTypes/ContentDataTypeRegistry.js";

describe("ContentDataTypeRegistry.findContentDataType", function () {
it("detects GLB", async function () {
Expand Down
4 changes: 2 additions & 2 deletions packages/base/specs/contentTypes/LazyContentDataSpec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-vars */

import { LazyContentData } from "../../src/contentTypes/LazyContentData";
import { ResourceResolver } from "../../src/io/ResourceResolver";
import { LazyContentData } from "../../src/contentTypes/LazyContentData.js";
import { ResourceResolver } from "../../src/io/ResourceResolver.js";

function createTestResourceResolver(): ResourceResolver {
return {
Expand Down
4 changes: 2 additions & 2 deletions packages/base/specs/jasmine.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"spec_dir": "specs",
"spec_files": ["**/*Spec.ts"],
"spec_dir": "build",
"spec_files": ["**/*Spec.[t|j]s"],
"helpers": [],
"random": false
}
4 changes: 2 additions & 2 deletions packages/base/specs/spatial/TreeCoordinatesSpec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { OctreeCoordinates } from "../../src/spatial/OctreeCoordinates";
import { QuadtreeCoordinates } from "../../src/spatial/QuadtreeCoordinates";
import { OctreeCoordinates } from "../../src/spatial/OctreeCoordinates.js";
import { QuadtreeCoordinates } from "../../src/spatial/QuadtreeCoordinates.js";

describe("TreeCoordinates", function () {
it("allows iterating over the quadtree children multiple times", function () {
Expand Down
13 changes: 13 additions & 0 deletions packages/base/specs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "../build/specs",
},
"include": [
"./**/*"
],
"references": [
{ "path": "../src/tsconfig.json" }
]
}
4 changes: 2 additions & 2 deletions packages/base/src/base/Buffers.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import zlib from "zlib";

import { defined } from "./defined";
import { defined } from "./defined.js";

import { DataError } from "./DataError";
import { DataError } from "./DataError.js";

/**
* Methods related to buffers.
Expand Down
2 changes: 1 addition & 1 deletion packages/base/src/base/Iterables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from "path";

import { PathLike } from "fs";

import { DeveloperError } from "./DeveloperError";
import { DeveloperError } from "./DeveloperError.js";

/**
* Utility methods for iterable objects.
Expand Down
10 changes: 5 additions & 5 deletions packages/base/src/binary/BinaryBufferDataResolver.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { defined } from "../base/defined";
import { defined } from "../base/defined.js";

import { ResourceResolver } from "../io/ResourceResolver";
import { ResourceResolver } from "../io/ResourceResolver.js";

import { BinaryBufferData } from "./BinaryBufferData";
import { BinaryBufferStructure } from "./BinaryBufferStructure";
import { BinaryDataError } from "./BinaryDataError";
import { BinaryBufferData } from "./BinaryBufferData.js";
import { BinaryBufferStructure } from "./BinaryBufferStructure.js";
import { BinaryDataError } from "./BinaryDataError.js";

/**
* A class for resolving binary buffer data.
Expand Down
2 changes: 1 addition & 1 deletion packages/base/src/binary/BinaryBufferStructure.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BufferObject } from "@3d-tiles-tools/structure";
import { BufferObject } from "@3d-tiles-tools/structure";
import { BufferView } from "@3d-tiles-tools/structure";

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/base/src/binary/BinaryBuffers.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { BufferObject } from "@3d-tiles-tools/structure";
import { BufferView } from "@3d-tiles-tools/structure";

import { BinaryBufferStructure } from "./BinaryBufferStructure";
import { BinaryBufferData } from "./BinaryBufferData";
import { BinaryBufferStructure } from "./BinaryBufferStructure.js";
import { BinaryBufferData } from "./BinaryBufferData.js";

/**
* Methods related to binary buffers.
Expand Down
6 changes: 3 additions & 3 deletions packages/base/src/contentTypes/BufferedContentData.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import fs from "fs";
import path from "path";

import { Buffers } from "../base/Buffers";
import { Buffers } from "../base/Buffers.js";

import { ContentData } from "./ContentData";
import { ContentData } from "./ContentData.js";

import { Loggers } from "../logging/Loggers";
import { Loggers } from "../logging/Loggers.js";
const logger = Loggers.get("tilesetProcessing");

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/base/src/contentTypes/ContentDataTypeChecks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ContentData } from "./ContentData";
import { ContentDataTypeRegistry } from "./ContentDataTypeRegistry";
import { ContentData } from "./ContentData.js";
import { ContentDataTypeRegistry } from "./ContentDataTypeRegistry.js";

/**
* Methods to create predicates that check whether a given
Expand Down
2 changes: 1 addition & 1 deletion packages/base/src/contentTypes/ContentDataTypeEntry.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ContentData } from "./ContentData";
import { ContentData } from "./ContentData.js";

/**
* An entry of the registered content data types,
Expand Down
12 changes: 6 additions & 6 deletions packages/base/src/contentTypes/ContentDataTypeRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ContentData } from "./ContentData";
import { ContentDataTypes } from "./ContentDataTypes";
import { ContentDataTypeEntry } from "./ContentDataTypeEntry";
import { defined } from "../base/defined";
import { DeveloperError } from "../base/DeveloperError";
import { BufferedContentData } from "./BufferedContentData";
import { ContentData } from "./ContentData.js";
import { ContentDataTypes } from "./ContentDataTypes.js";
import { ContentDataTypeEntry } from "./ContentDataTypeEntry.js";
import { defined } from "../base/defined.js";
import { DeveloperError } from "../base/DeveloperError.js";
import { BufferedContentData } from "./BufferedContentData.js";

/**
* A class for determining the type of data that a URI points to.
Expand Down
8 changes: 4 additions & 4 deletions packages/base/src/contentTypes/LazyContentData.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import path from "path";

import { defined } from "../base/defined";
import { Buffers } from "../base/Buffers";
import { defined } from "../base/defined.js";
import { Buffers } from "../base/Buffers.js";

import { ResourceResolver } from "../io/ResourceResolver";
import { ResourceResolver } from "../io/ResourceResolver.js";

import { ContentData } from "./ContentData";
import { ContentData } from "./ContentData.js";

/**
* Lazy implementation of the `ContentData` interface.
Expand Down
62 changes: 31 additions & 31 deletions packages/base/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
export * from "./base/Buffers";
export * from "./base/DataError";
export * from "./base/defaultValue";
export * from "./base/defined";
export * from "./base/DeveloperError";
export * from "./base/Iterables";
export * from "./base/Paths";
export * from "./base/Uris";
export * from "./base/Buffers.js";
export * from "./base/DataError.js";
export * from "./base/defaultValue.js";
export * from "./base/defined.js";
export * from "./base/DeveloperError.js";
export * from "./base/Iterables.js";
export * from "./base/Paths.js";
export * from "./base/Uris.js";

export * from "./binary/BinaryBufferData";
export * from "./binary/BinaryBufferDataResolver";
export * from "./binary/BinaryBuffers";
export * from "./binary/BinaryBufferStructure";
export * from "./binary/BinaryDataError";
export * from "./binary/BinaryBufferData.js";
export * from "./binary/BinaryBufferDataResolver.js";
export * from "./binary/BinaryBuffers.js";
export * from "./binary/BinaryBufferStructure.js";
export * from "./binary/BinaryDataError.js";

export * from "./contentTypes/BufferedContentData";
export * from "./contentTypes/ContentData";
export * from "./contentTypes/ContentDataTypeChecks";
export * from "./contentTypes/ContentDataTypeEntry";
export * from "./contentTypes/ContentDataTypeRegistry";
export * from "./contentTypes/ContentDataTypes";
export * from "./contentTypes/LazyContentData";
export * from "./contentTypes/BufferedContentData.js";
export * from "./contentTypes/ContentData.js";
export * from "./contentTypes/ContentDataTypeChecks.js";
export * from "./contentTypes/ContentDataTypeEntry.js";
export * from "./contentTypes/ContentDataTypeRegistry.js";
export * from "./contentTypes/ContentDataTypes.js";
export * from "./contentTypes/LazyContentData.js";

export * from "./io/FileResourceResolver";
export * from "./io/ResourceResolver";
export * from "./io/ResourceResolvers";
export * from "./io/UnzippingResourceResolver";
export * from "./io/FileResourceResolver.js";
export * from "./io/ResourceResolver.js";
export * from "./io/ResourceResolvers.js";
export * from "./io/UnzippingResourceResolver.js";

export * from "./logging/Loggers";
export * from "./logging/Loggers.js";

export * from "./spatial/MortonOrder";
export * from "./spatial/OctreeCoordinates";
export * from "./spatial/Octrees";
export * from "./spatial/QuadtreeCoordinates";
export * from "./spatial/Quadtrees";
export * from "./spatial/TreeCoordinates";
export * from "./spatial/MortonOrder.js";
export * from "./spatial/OctreeCoordinates.js";
export * from "./spatial/Octrees.js";
export * from "./spatial/QuadtreeCoordinates.js";
export * from "./spatial/Quadtrees.js";
export * from "./spatial/TreeCoordinates.js";
4 changes: 2 additions & 2 deletions packages/base/src/io/FileResourceResolver.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import fs from "fs";
import path from "path";

import { Uris } from "../base/Uris";
import { Uris } from "../base/Uris.js";

import { ResourceResolver } from "./ResourceResolver";
import { ResourceResolver } from "./ResourceResolver.js";

/**
* Implementation of a `ResourceResolver` based on a file system.
Expand Down
6 changes: 3 additions & 3 deletions packages/base/src/io/ResourceResolvers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FileResourceResolver } from "./FileResourceResolver";
import { ResourceResolver } from "./ResourceResolver";
import { UnzippingResourceResolver } from "./UnzippingResourceResolver";
import { FileResourceResolver } from "./FileResourceResolver.js";
import { ResourceResolver } from "./ResourceResolver.js";
import { UnzippingResourceResolver } from "./UnzippingResourceResolver.js";

/**
* Methods to create `ResourceResolver` instances.
Expand Down
4 changes: 2 additions & 2 deletions packages/base/src/io/UnzippingResourceResolver.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import zlib from "zlib";

import { Buffers } from "../base/Buffers";
import { Buffers } from "../base/Buffers.js";

import { ResourceResolver } from "./ResourceResolver";
import { ResourceResolver } from "./ResourceResolver.js";

/**
* Implementation of a `ResourceResolver` that obtains the resource
Expand Down
2 changes: 1 addition & 1 deletion packages/base/src/logging/Loggers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class Loggers {
timestamp: pino.stdTimeFunctions.isoTime,
};

const logger = pino(loggerOptions, transport);
const logger = (pino as any)(loggerOptions, transport);
Loggers.allLoggers[""] = logger;
return logger;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/base/src/spatial/OctreeCoordinates.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MortonOrder } from "./MortonOrder";
import { Octrees } from "./Octrees";
import { TreeCoordinates } from "./TreeCoordinates";
import { MortonOrder } from "./MortonOrder.js";
import { Octrees } from "./Octrees.js";
import { TreeCoordinates } from "./TreeCoordinates.js";

/**
* An implementation of `TreeCoordinates` for octrees
Expand Down
2 changes: 1 addition & 1 deletion packages/base/src/spatial/Octrees.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OctreeCoordinates } from "./OctreeCoordinates";
import { OctreeCoordinates } from "./OctreeCoordinates.js";

/**
* Methods related to octrees
Expand Down
6 changes: 3 additions & 3 deletions packages/base/src/spatial/QuadtreeCoordinates.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MortonOrder } from "./MortonOrder";
import { Quadtrees } from "./Quadtrees";
import { TreeCoordinates } from "./TreeCoordinates";
import { MortonOrder } from "./MortonOrder.js";
import { Quadtrees } from "./Quadtrees.js";
import { TreeCoordinates } from "./TreeCoordinates.js";

/**
* An implementation of `TreeCoordinates` for octrees
Expand Down
2 changes: 1 addition & 1 deletion packages/base/src/spatial/Quadtrees.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { QuadtreeCoordinates } from "./QuadtreeCoordinates";
import { QuadtreeCoordinates } from "./QuadtreeCoordinates.js";

/**
* Methods related to quadtrees.
Expand Down
12 changes: 12 additions & 0 deletions packages/base/src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"declaration": true,
"composite": true,
"rootDir": ".",
"outDir": "../build/src",
},
"include": [
"./**/*"
]
}
7 changes: 3 additions & 4 deletions packages/base/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
"compilerOptions": {
"declaration": true,
"composite": true,
"outDir": "./build",
"rootDir": "./src",
},
"include": [
"src/**/*"
"references": [
{ "path": "./src/tsconfig.json" },
{ "path": "./specs/tsconfig.json" }
]
}
Loading

0 comments on commit b6e792f

Please sign in to comment.