@vived/host 5.4.1 → 5.4.2
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.
|
@@ -43,7 +43,20 @@ class GetAssetStreamURLHandlerImp extends GetAssetStreamURLHandler {
|
|
|
43
43
|
this.getAssetUC
|
|
44
44
|
.getAsset(assetID)
|
|
45
45
|
.then((asset) => {
|
|
46
|
-
|
|
46
|
+
// Prefer the remote streaming URL. For a freshly uploaded asset the
|
|
47
|
+
// backend has not produced a fileURL yet, but the host is still holding
|
|
48
|
+
// the uploaded bytes locally — fall back to the blob URL so it can be
|
|
49
|
+
// streamed this session without a reload. blobURL is the managed URL
|
|
50
|
+
// created by setFile (revoked on dispose), so no new object URL leaks.
|
|
51
|
+
if (asset.fileURL) {
|
|
52
|
+
callback(asset.fileURL);
|
|
53
|
+
}
|
|
54
|
+
else if (asset.blobURL) {
|
|
55
|
+
callback(asset.blobURL);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
callback(undefined);
|
|
59
|
+
}
|
|
47
60
|
})
|
|
48
61
|
.catch((e) => {
|
|
49
62
|
this.error(e.message);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GetAssetStreamURLHandler.js","sourceRoot":"","sources":["../../../../src/Handler/UCs/GetAssetStreamURLHandler.ts"],"names":[],"mappings":";;;AA0BA,oEAIC;AA9BD,sCAAqD;AACrD,yCAA0C;AAC1C,0CAKqB;AAOrB,MAAsB,wBACpB,SAAQ,kBAAW;IADrB;;QAMW,gBAAW,GAAG,sBAAsB,CAAC;IAIhD,CAAC;;AAVD,4DAUC;AANiB,6BAAI,GAAG,0BAA0B,AAA7B,CAA8B;AAQpD,SAAgB,4BAA4B,CAC1C,SAAoB;IAEpB,OAAO,IAAI,2BAA2B,CAAC,SAAS,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,2BAA4B,SAAQ,wBAAwB;IAChE,IAAY,UAAU;QACpB,IAAI,CAAC;YACH,O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AAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACrD,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,IAAI,CAAC,KAAK,CAAC,4DAA4D,CAAC,CAAC;YACzE,OAAO;QACT,CAAC;QAED,WAAW,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;CACF","sourcesContent":["import { AppObject, AppObjectUC } from \"@vived/core\";\r\nimport { GetAssetUC } from \"../../Assets\";\r\nimport {\r\n HostHandlerEntity,\r\n RequestHandler,\r\n UnableToParsePayload,\r\n UnsupportedRequestVersion\r\n} from \"../Entities\";\r\n\r\nexport type GetAssetStreamURLAction = (\r\n assetID: string,\r\n callback: (url: string | undefined) => void\r\n) => void;\r\n\r\nexport abstract class GetAssetStreamURLHandler\r\n extends AppObjectUC\r\n implements RequestHandler\r\n{\r\n static readonly type = \"GetAssetStreamURLHandler\";\r\n\r\n readonly requestType = \"GET_ASSET_STREAM_URL\";\r\n\r\n abstract action: GetAssetStreamURLAction;\r\n abstract handleRequest: (version: number, payload?: unknown) => void;\r\n}\r\n\r\nexport function makeGetAssetStreamURLHandler(\r\n appObject: AppObject\r\n): GetAssetStreamURLHandler {\r\n return new GetAssetStreamURLHandlerImp(appObject);\r\n}\r\n\r\nclass GetAssetStreamURLHandlerImp extends GetAssetStreamURLHandler {\r\n private get getAssetUC() {\r\n try {\r\n return this.getCachedSingleton<GetAssetUC>(GetAssetUC.type);\r\n } catch {\r\n return undefined;\r\n }\r\n }\r\n\r\n action: GetAssetStreamURLAction = (assetID, callback) => {\r\n if (!this.getAssetUC) {\r\n this.error(\"Unable to find GetAssetUC\");\r\n callback(undefined);\r\n return;\r\n }\r\n\r\n this.getAssetUC\r\n .getAsset(assetID)\r\n .then((asset) => {\r\n // Prefer the remote streaming URL. For a freshly uploaded asset the\r\n // backend has not produced a fileURL yet, but the host is still holding\r\n // the uploaded bytes locally — fall back to the blob URL so it can be\r\n // streamed this session without a reload. blobURL is the managed URL\r\n // created by setFile (revoked on dispose), so no new object URL leaks.\r\n if (asset.fileURL) {\r\n callback(asset.fileURL);\r\n } else if (asset.blobURL) {\r\n callback(asset.blobURL);\r\n } else {\r\n callback(undefined);\r\n }\r\n })\r\n .catch((e: Error) => {\r\n this.error(e.message);\r\n callback(undefined);\r\n });\r\n };\r\n\r\n handleRequest = (version: number, payload: unknown) => {\r\n if (version === 1) {\r\n const { assetID, callback } = this.castPayloadV1(payload);\r\n this.action(assetID, callback);\r\n } else {\r\n throw new UnsupportedRequestVersion(this.requestType, version);\r\n }\r\n };\r\n\r\n private castPayloadV1(payload: unknown): Payload_V1 {\r\n const castPayload = payload as Payload_V1;\r\n if (!castPayload.assetID || !castPayload.callback) {\r\n throw new UnableToParsePayload(\r\n this.requestType,\r\n 1,\r\n JSON.stringify(payload)\r\n );\r\n }\r\n\r\n return castPayload;\r\n }\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, GetAssetStreamURLHandler.type);\r\n\r\n const hostHandler = HostHandlerEntity.get(appObject);\r\n if (!hostHandler) {\r\n this.error(\"UC added to an entity that does not have HostHandlerEntity\");\r\n return;\r\n }\r\n\r\n hostHandler.registerRequestHandler(this);\r\n }\r\n}\r\n\r\ntype Payload_V1 = {\r\n assetID: string;\r\n callback: (url: string | undefined) => void;\r\n};\r\n"]}
|
|
@@ -38,7 +38,20 @@ class GetAssetStreamURLHandlerImp extends GetAssetStreamURLHandler {
|
|
|
38
38
|
this.getAssetUC
|
|
39
39
|
.getAsset(assetID)
|
|
40
40
|
.then((asset) => {
|
|
41
|
-
|
|
41
|
+
// Prefer the remote streaming URL. For a freshly uploaded asset the
|
|
42
|
+
// backend has not produced a fileURL yet, but the host is still holding
|
|
43
|
+
// the uploaded bytes locally — fall back to the blob URL so it can be
|
|
44
|
+
// streamed this session without a reload. blobURL is the managed URL
|
|
45
|
+
// created by setFile (revoked on dispose), so no new object URL leaks.
|
|
46
|
+
if (asset.fileURL) {
|
|
47
|
+
callback(asset.fileURL);
|
|
48
|
+
}
|
|
49
|
+
else if (asset.blobURL) {
|
|
50
|
+
callback(asset.blobURL);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
callback(undefined);
|
|
54
|
+
}
|
|
42
55
|
})
|
|
43
56
|
.catch((e) => {
|
|
44
57
|
this.error(e.message);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GetAssetStreamURLHandler.js","sourceRoot":"","sources":["../../../../src/Handler/UCs/GetAssetStreamURLHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,WAAW,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,iBAAiB,EAEjB,oBAAoB,EACpB,yBAAyB,EAC1B,MAAM,aAAa,CAAC;AAOrB,MAAM,OAAgB,wBACpB,SAAQ,WAAW;IADrB;;QAMW,gBAAW,GAAG,sBAAsB,CAAC;IAIhD,CAAC;;AANiB,6BAAI,GAAG,0BAA0B,AAA7B,CAA8B;AAQpD,MAAM,UAAU,4BAA4B,CAC1C,SAAoB;IAEpB,OAAO,IAAI,2BAA2B,CAAC,SAAS,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,2BAA4B,SAAQ,wBAAwB;IAChE,IAAY,UAAU;QACpB,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,kBAAkB,CAAa,UAAU,CAAC,IAAI,CAAC,CAAC;QAC9D,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;
|
|
1
|
+
{"version":3,"file":"GetAssetStreamURLHandler.js","sourceRoot":"","sources":["../../../../src/Handler/UCs/GetAssetStreamURLHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,WAAW,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,iBAAiB,EAEjB,oBAAoB,EACpB,yBAAyB,EAC1B,MAAM,aAA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n RequestHandler,\r\n UnableToParsePayload,\r\n UnsupportedRequestVersion\r\n} from \"../Entities\";\r\n\r\nexport type GetAssetStreamURLAction = (\r\n assetID: string,\r\n callback: (url: string | undefined) => void\r\n) => void;\r\n\r\nexport abstract class GetAssetStreamURLHandler\r\n extends AppObjectUC\r\n implements RequestHandler\r\n{\r\n static readonly type = \"GetAssetStreamURLHandler\";\r\n\r\n readonly requestType = \"GET_ASSET_STREAM_URL\";\r\n\r\n abstract action: GetAssetStreamURLAction;\r\n abstract handleRequest: (version: number, payload?: unknown) => void;\r\n}\r\n\r\nexport function makeGetAssetStreamURLHandler(\r\n appObject: AppObject\r\n): GetAssetStreamURLHandler {\r\n return new GetAssetStreamURLHandlerImp(appObject);\r\n}\r\n\r\nclass GetAssetStreamURLHandlerImp extends GetAssetStreamURLHandler {\r\n private get getAssetUC() {\r\n try {\r\n return this.getCachedSingleton<GetAssetUC>(GetAssetUC.type);\r\n } catch {\r\n return undefined;\r\n }\r\n }\r\n\r\n action: GetAssetStreamURLAction = (assetID, callback) => {\r\n if (!this.getAssetUC) {\r\n this.error(\"Unable to find GetAssetUC\");\r\n callback(undefined);\r\n return;\r\n }\r\n\r\n this.getAssetUC\r\n .getAsset(assetID)\r\n .then((asset) => {\r\n // Prefer the remote streaming URL. For a freshly uploaded asset the\r\n // backend has not produced a fileURL yet, but the host is still holding\r\n // the uploaded bytes locally — fall back to the blob URL so it can be\r\n // streamed this session without a reload. blobURL is the managed URL\r\n // created by setFile (revoked on dispose), so no new object URL leaks.\r\n if (asset.fileURL) {\r\n callback(asset.fileURL);\r\n } else if (asset.blobURL) {\r\n callback(asset.blobURL);\r\n } else {\r\n callback(undefined);\r\n }\r\n })\r\n .catch((e: Error) => {\r\n this.error(e.message);\r\n callback(undefined);\r\n });\r\n };\r\n\r\n handleRequest = (version: number, payload: unknown) => {\r\n if (version === 1) {\r\n const { assetID, callback } = this.castPayloadV1(payload);\r\n this.action(assetID, callback);\r\n } else {\r\n throw new UnsupportedRequestVersion(this.requestType, version);\r\n }\r\n };\r\n\r\n private castPayloadV1(payload: unknown): Payload_V1 {\r\n const castPayload = payload as Payload_V1;\r\n if (!castPayload.assetID || !castPayload.callback) {\r\n throw new UnableToParsePayload(\r\n this.requestType,\r\n 1,\r\n JSON.stringify(payload)\r\n );\r\n }\r\n\r\n return castPayload;\r\n }\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, GetAssetStreamURLHandler.type);\r\n\r\n const hostHandler = HostHandlerEntity.get(appObject);\r\n if (!hostHandler) {\r\n this.error(\"UC added to an entity that does not have HostHandlerEntity\");\r\n return;\r\n }\r\n\r\n hostHandler.registerRequestHandler(this);\r\n }\r\n}\r\n\r\ntype Payload_V1 = {\r\n assetID: string;\r\n callback: (url: string | undefined) => void;\r\n};\r\n"]}
|