Skip to content

Commit

Permalink
Fix #809 Can't resolve '@photo-sphere-viewer/shared'
Browse files Browse the repository at this point in the history
  • Loading branch information
mistic100 committed Dec 21, 2022
1 parent e5ae238 commit 0d1cd43
Show file tree
Hide file tree
Showing 36 changed files with 83 additions and 93 deletions.
3 changes: 0 additions & 3 deletions build/plugins/esbuild-plugin-umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ function wrapUmd(fileContent, pkg, externals) {
if (!deps.includes('three')) {
deps.unshift('three');
}
if (deps.includes('@photo-sphere-viewer/shared')) {
deps.splice(deps.indexOf('@photo-sphere-viewer/shared'), 1);
}

const depsCommonJs = deps.map((dep) => `require('${dep}')`).join(', ');
const depsAmd = deps.map((dep) => `'${dep}'`).join(', ');
Expand Down
1 change: 0 additions & 1 deletion build/templates/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export const packageJson = (pkg) =>
];
}

delete content.dependencies['@photo-sphere-viewer/shared'];
delete content.devDependencies;
delete content.psv;
delete content.scripts;
Expand Down
4 changes: 2 additions & 2 deletions build/tsup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const externals = {
'@photo-sphere-viewer/settings-plugin': 'PhotoSphereViewer.SettingsPlugin',
};

export default function createConfig(pkg) {
export default function createConfig(pkg, entry = 'src/index.ts') {
const banner = `/*!
* ${pkg.psv.globalName} ${pkg.version}
${
Expand All @@ -30,7 +30,7 @@ ${
return defineConfig((options) => {
const dev = options.watch || options.define?.['config'] === 'dev';
return {
entryPoints: ['src/index.ts'],
entryPoints: [entry],
outDir: 'dist',
format: dev ? ['iife'] : ['iife', 'esm'],
globalName: pkg.psv.globalName,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@
"vue-slider-component": "^3.2.23",
"vue-swatches": "^2.1.1",
"vuepress": "^1.9.7",
"yaml": "^2.1.3"
"yaml": "^2.2.0"
}
}
2 changes: 1 addition & 1 deletion packages/autorotate-plugin/src/AutorotatePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { VideoPlugin } from '@photo-sphere-viewer/video-plugin';
import { MathUtils, SplineCurve, Vector2 } from 'three';
import { AutorotateEvent, AutorotatePluginEvents } from './events';
import { AutorotateKeypoint, AutorotatePluginConfig } from './model';
// import { debugCurve } from '@photo-sphere-viewer/shared';
// import { debugCurve } from '../../shared/autorotate-utils';

type ParsedAutorotatePluginConfig = Omit<
AutorotatePluginConfig,
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-plugin/src/style.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '../../shared/src/vars';
@import '../../shared/vars';

$psv-compass-margin: 10px !default;

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/styles/index.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@use 'sass:list';
@use 'sass:map';
@import '../../../shared/src/vars';
@import '../../../shared/vars';
@import 'viewer';
@import 'loader';
@import 'navbar';
Expand Down
3 changes: 1 addition & 2 deletions packages/cubemap-tiles-adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"types": "./src/index.ts",
"dependencies": {
"@photo-sphere-viewer/core": "0.0.0",
"@photo-sphere-viewer/cubemap-adapter": "0.0.0",
"@photo-sphere-viewer/shared": "0.0.0"
"@photo-sphere-viewer/cubemap-adapter": "0.0.0"
},
"scripts": {
"build": "tsup",
Expand Down
3 changes: 2 additions & 1 deletion packages/cubemap-tiles-adapter/src/CubemapTilesAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { TextureData, Viewer } from '@photo-sphere-viewer/core';
import { AbstractAdapter, CONSTANTS, events, PSVError, utils } from '@photo-sphere-viewer/core';
import { CubemapAdapter } from '@photo-sphere-viewer/cubemap-adapter';
import { buildErrorMaterial, Queue, Task } from '@photo-sphere-viewer/shared';
import {
BoxGeometry,
Frustum,
Expand All @@ -14,6 +13,8 @@ import {
Vector2,
Vector3,
} from 'three';
import { Queue, Task } from '../../shared/Queue';
import { buildErrorMaterial } from '../../shared/tiles-utils';
import { CubemapTilesAdapterConfig, CubemapTilesPanorama } from './model';

type CubemapMesh = Mesh<BoxGeometry, MeshBasicMaterial[]>;
Expand Down
3 changes: 1 addition & 2 deletions packages/cubemap-video-adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"main": "./src/index.ts",
"types": "./src/index.ts",
"dependencies": {
"@photo-sphere-viewer/core": "0.0.0",
"@photo-sphere-viewer/shared": "0.0.0"
"@photo-sphere-viewer/core": "0.0.0"
},
"scripts": {
"build": "tsup",
Expand Down
2 changes: 1 addition & 1 deletion packages/cubemap-video-adapter/src/CubemapVideoAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { TextureData, Viewer } from '@photo-sphere-viewer/core';
import { CONSTANTS, utils } from '@photo-sphere-viewer/core';
import { AbstractVideoAdapter } from '@photo-sphere-viewer/shared';
import { BoxGeometry, Mesh, ShaderMaterial, Vector2, VideoTexture } from 'three';
import { AbstractVideoAdapter } from '../../shared/AbstractVideoAdapter';
import { CubemapVideoAdapterConfig, CubemapVideoPanorama } from './model';

type CubemapMesh = Mesh<BoxGeometry, ShaderMaterial>;
Expand Down
2 changes: 1 addition & 1 deletion packages/cubemap-video-adapter/src/model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AbstractVideoAdapterConfig, AbstractVideoPanorama } from '@photo-sphere-viewer/shared';
import type { AbstractVideoAdapterConfig, AbstractVideoPanorama } from '../../shared/AbstractVideoAdapter';

/**
* Configuration of a cubemap video
Expand Down
3 changes: 1 addition & 2 deletions packages/equirectangular-tiles-adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"main": "./src/index.ts",
"types": "./src/index.ts",
"dependencies": {
"@photo-sphere-viewer/core": "0.0.0",
"@photo-sphere-viewer/shared": "0.0.0"
"@photo-sphere-viewer/core": "0.0.0"
},
"scripts": {
"build": "tsup",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { TextureData, Viewer } from '@photo-sphere-viewer/core';
import { AbstractAdapter, CONSTANTS, EquirectangularAdapter, events, PSVError, utils } from '@photo-sphere-viewer/core';
import { buildErrorMaterial, Queue, Task } from '@photo-sphere-viewer/shared';
import {
Frustum,
ImageLoader,
Expand All @@ -12,6 +11,8 @@ import {
Texture,
Vector3,
} from 'three';
import { Queue, Task } from '../../shared/Queue';
import { buildErrorMaterial } from '../../shared/tiles-utils';
import { EquirectangularTilesAdapterConfig, EquirectangularTilesPanorama } from './model';

/* the faces of the top and bottom rows are made of a single triangle (3 vertices)
Expand Down
3 changes: 1 addition & 2 deletions packages/equirectangular-video-adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"main": "./src/index.ts",
"types": "./src/index.ts",
"dependencies": {
"@photo-sphere-viewer/core": "0.0.0",
"@photo-sphere-viewer/shared": "0.0.0"
"@photo-sphere-viewer/core": "0.0.0"
},
"scripts": {
"build": "tsup",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { TextureData, Viewer } from '@photo-sphere-viewer/core';
import { CONSTANTS, PSVError, utils } from '@photo-sphere-viewer/core';
import { AbstractVideoAdapter } from '@photo-sphere-viewer/shared';
import { MathUtils, Mesh, MeshBasicMaterial, SphereGeometry, VideoTexture } from 'three';
import { AbstractVideoAdapter } from '../../shared/AbstractVideoAdapter';
import { EquirectangularVideoAdapterConfig, EquirectangularVideoPanorama } from './model';

type EquirectangularMesh = Mesh<SphereGeometry, MeshBasicMaterial>;
Expand Down
2 changes: 1 addition & 1 deletion packages/equirectangular-video-adapter/src/model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { EquirectangularAdapterConfig } from '@photo-sphere-viewer/core';
import type { AbstractVideoAdapterConfig, AbstractVideoPanorama } from '@photo-sphere-viewer/shared';
import type { AbstractVideoAdapterConfig, AbstractVideoPanorama } from '../../shared/AbstractVideoAdapter';

/**
* Configuration of an equirectangular video
Expand Down
2 changes: 1 addition & 1 deletion packages/gallery-plugin/src/style.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '../../shared/src/vars';
@import '../../shared/vars';

$psv-gallery-padding: 15px !default;
$psv-gallery-border: 1px solid $psv-caption-text-color !default;
Expand Down
2 changes: 1 addition & 1 deletion packages/markers-plugin/src/style.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '../../shared/src/vars';
@import '../../shared/vars';

.psv-markers {
user-select: none;
Expand Down
2 changes: 1 addition & 1 deletion packages/settings-plugin/src/style.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@use 'sass:list';
@import '../../shared/src/vars';
@import '../../shared/vars';

$psv-settings-margin: 10px !default;
$psv-settings-item-height: $psv-panel-menu-item-height !default;
Expand Down
1 change: 0 additions & 1 deletion packages/shared/.typedoc/README.md

This file was deleted.

File renamed without changes.
46 changes: 45 additions & 1 deletion packages/shared/src/Queue.ts → packages/shared/Queue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,48 @@
import { Status, Task } from './Task';
/**
* @internal
*/
const enum Status {
DISABLED,
PENDING,
RUNNING,
CANCELLED,
DONE,
ERROR,
}

/**
* @internal
*/
export class Task {
status: Status = Status.PENDING;

constructor(
public readonly id: string,
public priority: number,
private readonly fn: (task: Task) => Promise<any>
) {}

start() {
this.status = Status.RUNNING;
return this.fn(this).then(
() => {
this.status = Status.DONE;
},
() => {
this.status = Status.ERROR;
}
);
}

cancel() {
this.status = Status.CANCELLED;
}

isCancelled() {
return this.status === Status.CANCELLED;
}
}


/**
* @internal
Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 4 additions & 1 deletion packages/shared/src/index.ts → packages/shared/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/**
* This file only exists for the UMD test
*/

export * from './AbstractVideoAdapter';
export * from './autorotate-utils';
export * from './Queue';
export * from './Task';
export * from './tiles-utils';
8 changes: 2 additions & 6 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@
},
"scripts": {
"build:dev": "tsup --define.config dev",
"lint": "eslint . --fix && stylelint \"src/**/*.scss\" --fix",
"test": "mocha -r ts-node/register \"src/**/*.spec.ts\""
"lint": "eslint . --fix && stylelint \"*.scss\" --fix",
"test": "mocha -r ts-node/register \"*.spec.ts\""
},
"psv": {
"globalName": "PhotoSphereViewer.Shared"
},
"typedoc": {
"displayName": "Shared",
"readmeFile": "./.typedoc/README.md"
}
}
44 changes: 0 additions & 44 deletions packages/shared/src/Task.ts

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion packages/shared/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*.ts", "typings.d.ts"],
"include": ["*.ts"],
"exclude": ["dist", "node_modules"]
}
2 changes: 1 addition & 1 deletion packages/shared/tsup.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import createConfig from '../../build/tsup.config';
import pkg from './package.json' assert { type: 'json' };

export default createConfig(pkg);
export default createConfig(pkg, 'index.ts');
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { execSync } from 'child_process';
import { readFileSync } from 'fs';
import assert from 'assert';
import pkg from '../package.json';
import pkg from './package.json';

/**
* This test ensures that the custom UMD plugin is behaving correctly
Expand Down Expand Up @@ -45,9 +45,7 @@ describe('UMD', () => {
var require_core = () => PhotoSphereViewer;
// three
var require_three = () => THREE;
// src/index.ts`;
var require_three = () => THREE;`;

const actual = output.split('\n').slice(0, expected.split('\n').length).join('\n');

Expand Down
2 changes: 1 addition & 1 deletion packages/video-plugin/src/VideoPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { PauseOverlay } from './components/PauseOverlay';
import { ProgressBar } from './components/ProgressBar';
import { BufferEvent, PlayPauseEvent, ProgressEvent, VideoPluginEvents, VolumeChangeEvent } from './events';
import { VideoKeypoint, VideoPluginConfig } from './model';
// import { debugCurve } from '@photo-sphere-viewer/shared';
// import { debugCurve } from '../../shared/autorotate-utils';

const getConfig = utils.getConfigParser<VideoPluginConfig>({
progressbar: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/video-plugin/src/style.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@use 'sass:map';
@import '../../shared/src/vars';
@import '../../shared/vars';

$psv-progressbar-height: 3px !default;
$psv-progressbar-height-active: 5px !default;
Expand Down
2 changes: 1 addition & 1 deletion packages/virtual-tour-plugin/src/style.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '../../shared/src/vars';
@import '../../shared/vars';

.psv-virtual-tour {
&__marker {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11037,10 +11037,10 @@ yaml@^1.10.0, yaml@^1.10.2:
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b"
integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==

yaml@^2.1.3:
version "2.1.3"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.1.3.tgz#9b3a4c8aff9821b696275c79a8bee8399d945207"
integrity sha512-AacA8nRULjKMX2DvWvOAdBZMOfQlypSFkjcOcu9FalllIDJ1kvlREzcdIZmidQUqqeMv7jorHjq2HlLv/+c2lg==
yaml@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.2.0.tgz#882c762992888b4144bffdec5745df340627fdd3"
integrity sha512-auf7Gi6QwO7HW//GA9seGvTXVGWl1CM/ADWh1+RxtXr6XOxnT65ovDl9fTi4e0monEyJxCHqDpF6QnFDXmJE4g==

[email protected]:
version "20.2.4"
Expand Down

0 comments on commit 0d1cd43

Please sign in to comment.