@3cr/viewer-browser 0.0.45 → 0.0.47
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/package.json +1 -1
- package/src/main.ts +1 -1
- package/scripts/modules.d.ts +0 -2
- package/scripts/postPublish.js +0 -93
- package/scripts/postPublish.ts +0 -106
- package/src/types/window.shim.ts +0 -24
package/package.json
CHANGED
package/src/main.ts
CHANGED
package/scripts/modules.d.ts
DELETED
package/scripts/postPublish.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
// import { CloudFront, S3 } from 'aws-sdk';
|
|
7
|
-
const randomstring_1 = require("randomstring");
|
|
8
|
-
const path_1 = require("path");
|
|
9
|
-
const mime_types_1 = require("mime-types");
|
|
10
|
-
const fs_1 = require("fs");
|
|
11
|
-
const aws_sdk_1 = __importDefault(require("aws-sdk"));
|
|
12
|
-
const package_json_1 = require("../package.json");
|
|
13
|
-
const { CloudFront, S3 } = aws_sdk_1.default;
|
|
14
|
-
//Note: Config is injected in CI now. (leaving this for in case we need to do a local)
|
|
15
|
-
// import dotenv from 'dotenv';
|
|
16
|
-
// dotenv.config();
|
|
17
|
-
const { DIST_NAME, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, BUCKET_NAME } = process.env;
|
|
18
|
-
if (!AWS_ACCESS_KEY_ID || !AWS_SECRET_ACCESS_KEY)
|
|
19
|
-
throw Error('Please define environment variables for AWS');
|
|
20
|
-
if (!DIST_NAME)
|
|
21
|
-
throw Error('Please define environment variables for DIST_NAME');
|
|
22
|
-
const DistributionName = DIST_NAME;
|
|
23
|
-
const BucketName = BUCKET_NAME;
|
|
24
|
-
const s3 = new S3({
|
|
25
|
-
region: 'ap-southeast-2',
|
|
26
|
-
});
|
|
27
|
-
const cloudfront = new CloudFront();
|
|
28
|
-
async function uploadDir(s3Path) {
|
|
29
|
-
for (const name of (0, fs_1.readdirSync)(s3Path)) {
|
|
30
|
-
const filePath = (0, path_1.join)(s3Path, name);
|
|
31
|
-
const stat = (0, fs_1.statSync)(filePath);
|
|
32
|
-
if (stat.isFile()) {
|
|
33
|
-
if (!filePath.endsWith('.map'))
|
|
34
|
-
await executeUpload(s3Path, filePath);
|
|
35
|
-
}
|
|
36
|
-
else if (stat.isDirectory()) {
|
|
37
|
-
await uploadDir(filePath);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
async function executeUpload(s3Path, filePath) {
|
|
42
|
-
const parentDir = s3Path.includes('/')
|
|
43
|
-
? s3Path.substring(0, s3Path.indexOf('/'))
|
|
44
|
-
: s3Path;
|
|
45
|
-
const bucketPath = filePath.substring(parentDir.length + 1);
|
|
46
|
-
const options = {
|
|
47
|
-
Bucket: BucketName,
|
|
48
|
-
Key: `${bucketPath}`,
|
|
49
|
-
Body: (0, fs_1.readFileSync)(filePath).toString().replace("{{version}}", package_json_1.version),
|
|
50
|
-
};
|
|
51
|
-
if (typeof (0, mime_types_1.lookup)(bucketPath) === 'string') {
|
|
52
|
-
options.ContentType = (0, mime_types_1.lookup)(bucketPath);
|
|
53
|
-
}
|
|
54
|
-
await s3.putObject(options).promise();
|
|
55
|
-
}
|
|
56
|
-
async function deployToAws() {
|
|
57
|
-
const listObjectsParams = {
|
|
58
|
-
Bucket: BucketName,
|
|
59
|
-
Prefix: ``
|
|
60
|
-
};
|
|
61
|
-
const listObjectsResponse = await s3
|
|
62
|
-
.listObjectsV2(listObjectsParams)
|
|
63
|
-
.promise();
|
|
64
|
-
if (listObjectsResponse.Contents && listObjectsResponse.Contents.length > 0) {
|
|
65
|
-
const deleteParams = {
|
|
66
|
-
Bucket: BucketName,
|
|
67
|
-
Delete: {
|
|
68
|
-
Objects: listObjectsResponse.Contents?.map((x) => ({
|
|
69
|
-
Key: x.Key || '',
|
|
70
|
-
})).filter((x) => x.Key !== '') || [],
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
await s3.deleteObjects(deleteParams).promise();
|
|
74
|
-
}
|
|
75
|
-
await uploadDir('playground');
|
|
76
|
-
const reference = (0, randomstring_1.generate)(16);
|
|
77
|
-
const params = {
|
|
78
|
-
DistributionId: DistributionName,
|
|
79
|
-
InvalidationBatch: {
|
|
80
|
-
CallerReference: reference,
|
|
81
|
-
Paths: {
|
|
82
|
-
Quantity: 1,
|
|
83
|
-
Items: ['/*'],
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
};
|
|
87
|
-
console.log(`Creating Invalidation for (${DistributionName}): ${reference}`);
|
|
88
|
-
const invalidation = await cloudfront.createInvalidation(params).promise();
|
|
89
|
-
console.log(invalidation);
|
|
90
|
-
}
|
|
91
|
-
deployToAws()
|
|
92
|
-
.then((data) => console.log(data))
|
|
93
|
-
.catch((err) => console.error(err));
|
package/scripts/postPublish.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
// import { CloudFront, S3 } from 'aws-sdk';
|
|
2
|
-
import { generate } from 'randomstring';
|
|
3
|
-
import { join } from 'path';
|
|
4
|
-
import { lookup } from 'mime-types';
|
|
5
|
-
import { readdirSync, statSync, readFileSync } from 'fs';
|
|
6
|
-
import pkg from 'aws-sdk';
|
|
7
|
-
import {version} from '../package.json';
|
|
8
|
-
const { CloudFront, S3 } = pkg;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import { CreateInvalidationRequest } from 'aws-sdk/clients/cloudfront';
|
|
12
|
-
import {DeleteObjectsRequest, ListObjectsV2Request, PutObjectRequest } from 'aws-sdk/clients/s3';
|
|
13
|
-
|
|
14
|
-
//Note: Config is injected in CI now. (leaving this for in case we need to do a local)
|
|
15
|
-
// import dotenv from 'dotenv';
|
|
16
|
-
// dotenv.config();
|
|
17
|
-
|
|
18
|
-
const { DIST_NAME, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, BUCKET_NAME } = process.env;
|
|
19
|
-
|
|
20
|
-
if (!AWS_ACCESS_KEY_ID || !AWS_SECRET_ACCESS_KEY) throw Error('Please define environment variables for AWS');
|
|
21
|
-
if (!DIST_NAME) throw Error('Please define environment variables for DIST_NAME');
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const DistributionName = DIST_NAME as string;
|
|
25
|
-
const BucketName = BUCKET_NAME as string;
|
|
26
|
-
const s3 = new S3({
|
|
27
|
-
region: 'ap-southeast-2',
|
|
28
|
-
});
|
|
29
|
-
const cloudfront = new CloudFront();
|
|
30
|
-
|
|
31
|
-
async function uploadDir(s3Path: string) {
|
|
32
|
-
for (const name of readdirSync(s3Path)) {
|
|
33
|
-
const filePath = join(s3Path, name);
|
|
34
|
-
const stat = statSync(filePath);
|
|
35
|
-
|
|
36
|
-
if (stat.isFile()) {
|
|
37
|
-
if (!filePath.endsWith('.map')) await executeUpload(s3Path, filePath);
|
|
38
|
-
} else if (stat.isDirectory()) {
|
|
39
|
-
await uploadDir(filePath);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
async function executeUpload(s3Path: string, filePath: string) {
|
|
44
|
-
const parentDir = s3Path.includes('/')
|
|
45
|
-
? s3Path.substring(0, s3Path.indexOf('/'))
|
|
46
|
-
: s3Path;
|
|
47
|
-
const bucketPath = filePath.substring(parentDir.length + 1);
|
|
48
|
-
const options: PutObjectRequest = {
|
|
49
|
-
Bucket: BucketName,
|
|
50
|
-
Key: `${bucketPath}`,
|
|
51
|
-
Body: readFileSync(filePath).toString().replace("{{version}}", version),
|
|
52
|
-
};
|
|
53
|
-
if (typeof lookup(bucketPath) === 'string') {
|
|
54
|
-
options.ContentType = lookup(bucketPath) as string;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
await s3.putObject(options).promise();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async function deployToAws() {
|
|
61
|
-
const listObjectsParams: ListObjectsV2Request = {
|
|
62
|
-
Bucket: BucketName,
|
|
63
|
-
Prefix: ``
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const listObjectsResponse = await s3
|
|
67
|
-
.listObjectsV2(listObjectsParams)
|
|
68
|
-
.promise();
|
|
69
|
-
|
|
70
|
-
if (listObjectsResponse.Contents && listObjectsResponse.Contents.length > 0) {
|
|
71
|
-
const deleteParams: DeleteObjectsRequest = {
|
|
72
|
-
Bucket: BucketName,
|
|
73
|
-
Delete: {
|
|
74
|
-
Objects:
|
|
75
|
-
listObjectsResponse.Contents?.map((x) => ({
|
|
76
|
-
Key: x.Key || '',
|
|
77
|
-
})).filter((x) => x.Key !== '') || [],
|
|
78
|
-
},
|
|
79
|
-
};
|
|
80
|
-
await s3.deleteObjects(deleteParams).promise();
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
await uploadDir('playground');
|
|
84
|
-
|
|
85
|
-
const reference = generate(16);
|
|
86
|
-
const params: CreateInvalidationRequest = {
|
|
87
|
-
DistributionId: DistributionName,
|
|
88
|
-
InvalidationBatch: {
|
|
89
|
-
CallerReference: reference,
|
|
90
|
-
Paths: {
|
|
91
|
-
Quantity: 1,
|
|
92
|
-
Items: ['/*'],
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
};
|
|
96
|
-
console.log(`Creating Invalidation for (${DistributionName}): ${reference}`);
|
|
97
|
-
|
|
98
|
-
const invalidation = await cloudfront.createInvalidation(params).promise();
|
|
99
|
-
console.log(invalidation);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
deployToAws()
|
|
103
|
-
.then((data) => console.log(data))
|
|
104
|
-
.catch((err) => console.error(err));
|
|
105
|
-
|
|
106
|
-
|
package/src/types/window.shim.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// export {};
|
|
2
|
-
//
|
|
3
|
-
// declare global {
|
|
4
|
-
// interface Window {
|
|
5
|
-
// createUnityInstance(element: HTMLElement, config: UnityConfig): Promise<UnityInstance>;
|
|
6
|
-
// receiveMessageFromUnity(payload: string): void;
|
|
7
|
-
// }
|
|
8
|
-
// }
|
|
9
|
-
// export interface UnityInstance {
|
|
10
|
-
// SendMessage: (payload: string) => void;
|
|
11
|
-
// }
|
|
12
|
-
// export interface UnityConfig {
|
|
13
|
-
// dataUrl: string;
|
|
14
|
-
// frameworkUrl: string;
|
|
15
|
-
// codeUrl: string;
|
|
16
|
-
// streamingAssetsUrl: string;
|
|
17
|
-
// companyName: string;
|
|
18
|
-
// productName: string;
|
|
19
|
-
// productVersion: string;
|
|
20
|
-
// webglContextAttributes: WebglConfig;
|
|
21
|
-
// }
|
|
22
|
-
// export interface WebglConfig {
|
|
23
|
-
// preserveDrawingBuffer: boolean;
|
|
24
|
-
// }
|