@evercoast/workers 0.0.0-stage → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +46 -2
- package/bin/evercoast-workers.js +24 -0
- package/dist/corto_decoder.worker.js +1 -0
- package/dist/ecfm_decoder.worker.js +1 -0
- package/dist/ecsplat_decoder.worker.js +1 -0
- package/dist/ecspz_decoder.worker.js +1 -0
- package/dist/ecv_decoder.worker.js +1 -0
- package/dist/gc_sorter.worker.js +1 -0
- package/dist/img_loader.worker.js +1 -0
- package/dist/manifest.json +82 -0
- package/dist/obj_decoder.worker.js +2 -0
- package/dist/ply_decoder.worker.js +3 -0
- package/dist/realtime_decoder.worker.js +1 -0
- package/dist/splat_decoder.worker.js +1 -0
- package/dist/spz_decoder.worker.js +1 -0
- package/index.d.ts +25 -0
- package/index.js +36 -0
- package/package.json +48 -5
- package/vite.d.ts +15 -0
- package/vite.js +45 -0
package/package.json
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@evercoast/workers",
|
|
3
|
+
"version": "2.5.0",
|
|
4
|
+
"description": "Evercoast WebSDK web workers, to serve the decode workers from your own origin instead of the Evercoast CDN",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"./dist/*.worker.js",
|
|
8
|
+
"./dist/manifest.json",
|
|
9
|
+
"./bin",
|
|
10
|
+
"./index.js",
|
|
11
|
+
"./index.d.ts",
|
|
12
|
+
"./vite.js",
|
|
13
|
+
"./vite.d.ts",
|
|
14
|
+
"README.md",
|
|
15
|
+
"LICENSE"
|
|
16
|
+
],
|
|
17
|
+
"bin": {
|
|
18
|
+
"evercoast-workers": "./bin/evercoast-workers.js"
|
|
19
|
+
},
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./index.d.ts",
|
|
23
|
+
"default": "./index.js"
|
|
24
|
+
},
|
|
25
|
+
"./vite": {
|
|
26
|
+
"types": "./vite.d.ts",
|
|
27
|
+
"default": "./vite.js"
|
|
28
|
+
},
|
|
29
|
+
"./manifest.json": "./dist/manifest.json",
|
|
30
|
+
"./dist/*": "./dist/*",
|
|
31
|
+
"./package.json": "./package.json"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "node ./scripts/build.mjs",
|
|
35
|
+
"lint": "node --check index.js && node --check vite.js && node --check bin/evercoast-workers.js && node --check scripts/build.mjs",
|
|
36
|
+
"pack": "npm pack --pack-destination ./../../releases",
|
|
37
|
+
"clean": "rimraf dist"
|
|
38
|
+
},
|
|
39
|
+
"keywords": [],
|
|
40
|
+
"author": {
|
|
41
|
+
"name": "Evercoast",
|
|
42
|
+
"email": "support@evercoast.com",
|
|
43
|
+
"url": "https://support.evercoast.com/docs/web-player-sdk-overview"
|
|
44
|
+
},
|
|
45
|
+
"license": "MIT",
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=18"
|
|
48
|
+
}
|
|
49
|
+
}
|
package/vite.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
import type { WorkerEntry } from './index';
|
|
3
|
+
|
|
4
|
+
export interface EvercoastWorkersOptions {
|
|
5
|
+
/** Path of the app the workers are served under, defaults to 'evercoast-workers/' */
|
|
6
|
+
path?: string;
|
|
7
|
+
/** Only serve the workers an entry loads, defaults to all */
|
|
8
|
+
entry?: WorkerEntry;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Serve the Evercoast workers from the app's own origin: from this package in development, and emitted with the
|
|
13
|
+
* app's build output. Set the player's worker root to match, e.g. `config.root = '/evercoast-workers/'`.
|
|
14
|
+
*/
|
|
15
|
+
export default function evercoastWorkers(options?: EvercoastWorkersOptions): Plugin;
|
package/vite.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Vite plugin serving the Evercoast workers from the app's own origin: from this package in development, and
|
|
2
|
+
// emitted with the app's build output
|
|
3
|
+
import { createReadStream } from 'fs'
|
|
4
|
+
import { readFile } from 'fs/promises'
|
|
5
|
+
import { join } from 'path'
|
|
6
|
+
import { workerFiles, workersDir } from './index.js'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Serve the Evercoast workers under `path` of the app. Set the player's worker root to match, e.g.
|
|
10
|
+
* `config.root = '/evercoast-workers/'`.
|
|
11
|
+
*/
|
|
12
|
+
export default function evercoastWorkers({ path = 'evercoast-workers/', entry } = {}) {
|
|
13
|
+
const dir = path.replace(/^\/+/, '').replace(/\/?$/, '/')
|
|
14
|
+
let base = '/'
|
|
15
|
+
return {
|
|
16
|
+
name: 'evercoast-workers',
|
|
17
|
+
configResolved(config) {
|
|
18
|
+
// a relative base ('' or './') is served from the root in development
|
|
19
|
+
base = config.base.startsWith('/') ? config.base : '/'
|
|
20
|
+
},
|
|
21
|
+
configureServer(server) {
|
|
22
|
+
const files = new Set(workerFiles(entry))
|
|
23
|
+
server.middlewares.use((req, res, next) => {
|
|
24
|
+
const url = new URL(req.url ?? '/', 'http://localhost')
|
|
25
|
+
const prefix = base + dir
|
|
26
|
+
const file = url.pathname.startsWith(prefix) ? url.pathname.slice(prefix.length) : undefined
|
|
27
|
+
if (!file || !files.has(file)) {
|
|
28
|
+
next()
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
res.setHeader('Content-Type', 'text/javascript')
|
|
32
|
+
createReadStream(join(workersDir, file)).pipe(res)
|
|
33
|
+
})
|
|
34
|
+
},
|
|
35
|
+
async generateBundle() {
|
|
36
|
+
for (const file of workerFiles(entry)) {
|
|
37
|
+
this.emitFile({
|
|
38
|
+
type: 'asset',
|
|
39
|
+
fileName: dir + file,
|
|
40
|
+
source: await readFile(join(workersDir, file))
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|