@ms-cloudpack/api-server 0.40.0 → 0.42.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/lib/common/createSession.d.ts +3 -6
- package/lib/common/createSession.d.ts.map +1 -1
- package/lib/common/createSession.js +12 -12
- package/lib/common/createSession.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/startApiServer.d.ts.map +1 -1
- package/lib/startApiServer.js +5 -1
- package/lib/startApiServer.js.map +1 -1
- package/lib/types/Session.d.ts +8 -0
- package/lib/types/Session.d.ts.map +1 -1
- package/lib/types/Session.js.map +1 -1
- package/lib/utilities/addOverride.d.ts.map +1 -1
- package/lib/utilities/addOverride.js +1 -1
- package/lib/utilities/addOverride.js.map +1 -1
- package/lib/utilities/formatBundleTaskResult.d.ts.map +1 -1
- package/lib/utilities/formatBundleTaskResult.js +24 -23
- package/lib/utilities/formatBundleTaskResult.js.map +1 -1
- package/lib/utilities/getSessionPath.d.ts +3 -0
- package/lib/utilities/getSessionPath.d.ts.map +1 -0
- package/lib/utilities/getSessionPath.js +6 -0
- package/lib/utilities/getSessionPath.js.map +1 -0
- package/lib/utilities/resolveDependenciesTask.d.ts +1 -1
- package/lib/utilities/resolveDependenciesTask.d.ts.map +1 -1
- package/lib/utilities/resolveDependenciesTask.js +3 -2
- package/lib/utilities/resolveDependenciesTask.js.map +1 -1
- package/lib/utilities/validateOverride.js +2 -2
- package/lib/utilities/validateOverride.js.map +1 -1
- package/package.json +11 -11
- package/lib/utilities/parseRequestInfo.d.ts +0 -30
- package/lib/utilities/parseRequestInfo.d.ts.map +0 -1
- package/lib/utilities/parseRequestInfo.js +0 -34
- package/lib/utilities/parseRequestInfo.js.map +0 -1
- package/lib/utilities/parseRequestUrl.d.ts +0 -14
- package/lib/utilities/parseRequestUrl.d.ts.map +0 -1
- package/lib/utilities/parseRequestUrl.js +0 -24
- package/lib/utilities/parseRequestUrl.js.map +0 -1
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import type { CloudpackConfig
|
|
2
|
-
import type {
|
|
1
|
+
import type { CloudpackConfig } from '@ms-cloudpack/common-types';
|
|
2
|
+
import type { Context } from '../types/Context.js';
|
|
3
3
|
import type { Session } from '../types/Session.js';
|
|
4
4
|
export declare function createSession(options: {
|
|
5
5
|
appPath: string;
|
|
6
6
|
overlayPath?: string;
|
|
7
7
|
config: CloudpackConfig;
|
|
8
|
-
}, context:
|
|
9
|
-
reporter: TaskReporter;
|
|
10
|
-
packages: PackageDefinitionsCache;
|
|
11
|
-
}): Promise<Session>;
|
|
8
|
+
}, context: Pick<Context, 'reporter' | 'packages'>): Promise<Session>;
|
|
12
9
|
//# sourceMappingURL=createSession.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSession.d.ts","sourceRoot":"","sources":["../../src/common/createSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"createSession.d.ts","sourceRoot":"","sources":["../../src/common/createSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAKlE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAUnD,wBAAsB,aAAa,CACjC,OAAO,EAAE;IACP,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,eAAe,CAAC;CACzB,EACD,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,UAAU,GAAG,UAAU,CAAC,GAC9C,OAAO,CAAC,OAAO,CAAC,CAqElB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
-
import fsExtra from 'fs-extra';
|
|
3
2
|
import path from 'path';
|
|
4
3
|
import { v4 as uuid } from 'uuid';
|
|
5
4
|
import { getLocalCachePath } from '../utilities/getCachePath.js';
|
|
6
5
|
import { resolveDependenciesTask } from '../utilities/resolveDependenciesTask.js';
|
|
6
|
+
import { readJson, writeJson, writeJsonSync } from '@ms-cloudpack/json-utilities';
|
|
7
7
|
export async function createSession(options, context) {
|
|
8
8
|
const { appPath, config, overlayPath } = options;
|
|
9
9
|
const projectName = path.basename(appPath);
|
|
@@ -12,18 +12,14 @@ export async function createSession(options, context) {
|
|
|
12
12
|
appPath,
|
|
13
13
|
additionalPaths: overlayPath ? [overlayPath] : [],
|
|
14
14
|
}, context);
|
|
15
|
-
if (!resolveMap) {
|
|
16
|
-
throw new Error('Could not resolve dependencies.');
|
|
17
|
-
}
|
|
18
15
|
let importMap = undefined;
|
|
19
|
-
await fsExtra.ensureDir(getLocalCachePath(appPath));
|
|
20
16
|
const versionsPath = path.join(getLocalCachePath(appPath), 'sessionVersions.json');
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
const previousVersions = await readJson(versionsPath);
|
|
18
|
+
const versions = previousVersions || { sessionVersion: 0, targetVersions: {} };
|
|
19
|
+
if (!previousVersions) {
|
|
20
|
+
await writeJson(versionsPath, versions);
|
|
24
21
|
}
|
|
25
|
-
|
|
26
|
-
const session = {
|
|
22
|
+
return {
|
|
27
23
|
id,
|
|
28
24
|
appPath,
|
|
29
25
|
config,
|
|
@@ -40,6 +36,11 @@ export async function createSession(options, context) {
|
|
|
40
36
|
resolveMap = newResolveMap;
|
|
41
37
|
},
|
|
42
38
|
sequence: 0,
|
|
39
|
+
urls: {
|
|
40
|
+
appServer: '',
|
|
41
|
+
bundleServer: '',
|
|
42
|
+
apiServer: '',
|
|
43
|
+
},
|
|
43
44
|
targetVersions: versions.targetVersions,
|
|
44
45
|
get sessionVersion() {
|
|
45
46
|
return versions.sessionVersion;
|
|
@@ -56,7 +57,7 @@ export async function createSession(options, context) {
|
|
|
56
57
|
versions.targetVersions[inputPath]++;
|
|
57
58
|
importMap = undefined;
|
|
58
59
|
// eslint-disable-next-line @ms-cloudpack/internal/no-sync-filesystem -- this function can't be async
|
|
59
|
-
|
|
60
|
+
writeJsonSync(versionsPath, versions);
|
|
60
61
|
},
|
|
61
62
|
get importMap() {
|
|
62
63
|
return importMap;
|
|
@@ -65,6 +66,5 @@ export async function createSession(options, context) {
|
|
|
65
66
|
importMap = newImportMap;
|
|
66
67
|
},
|
|
67
68
|
};
|
|
68
|
-
return session;
|
|
69
69
|
}
|
|
70
70
|
//# sourceMappingURL=createSession.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSession.js","sourceRoot":"","sources":["../../src/common/createSession.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createSession.js","sourceRoot":"","sources":["../../src/common/createSession.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAGlC,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAClF,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAOlF,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAIC,EACD,OAA+C;IAE/C,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAEjD,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC;IAClB,IAAI,UAAU,GAAG,MAAM,uBAAuB,CAC5C;QACE,OAAO;QACP,eAAe,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,WA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AAC;QACD,sBAAsB,EAAE,CAAC,SAAiB,EAAE,EAAE;YAC5C,QAAQ,CAAC,cAAc,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YACzC,QAAQ,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE,CAAC;YACrC,SAAS,GAAG,SAAS,CAAC;YACtB,qGAAqG;YACrG,aAAa,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;QACxC,CAAC;QACD,IAAI,SAAS;YACX,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,IAAI,SAAS,CAAC,YAAY;YACxB,SAAS,GAAG,YAAY,CAAC;QAC3B,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { CloudpackConfig } from '@ms-cloudpack/common-types';\nimport type { ImportMap } from '@ms-cloudpack/import-map';\nimport fs from 'fs';\nimport path from 'path';\nimport { v4 as uuid } from 'uuid';\nimport type { Context } from '../types/Context.js';\nimport type { Session } from '../types/Session.js';\nimport { getLocalCachePath } from '../utilities/getCachePath.js';\nimport { resolveDependenciesTask } from '../utilities/resolveDependenciesTask.js';\nimport { readJson, writeJson, writeJsonSync } from '@ms-cloudpack/json-utilities';\n\ntype Versions = {\n sessionVersion: number;\n targetVersions: Record<string, number>;\n};\n\nexport async function createSession(\n options: {\n appPath: string;\n overlayPath?: string;\n config: CloudpackConfig;\n },\n context: Pick<Context, 'reporter' | 'packages'>,\n): Promise<Session> {\n const { appPath, config, overlayPath } = options;\n\n const projectName = path.basename(appPath);\n const id = uuid();\n let resolveMap = await resolveDependenciesTask(\n {\n appPath,\n additionalPaths: overlayPath ? [overlayPath] : [],\n },\n context,\n );\n\n let importMap: ImportMap | undefined = undefined;\n\n const versionsPath = path.join(getLocalCachePath(appPath), 'sessionVersions.json');\n const previousVersions = await readJson<Versions>(versionsPath);\n const versions = previousVersions || { sessionVersion: 0, targetVersions: {} };\n if (!previousVersions) {\n await writeJson(versionsPath, versions);\n }\n\n return {\n id,\n appPath,\n config,\n projectName,\n type: 'web-app',\n mode: 'library',\n get resolveMap() {\n return resolveMap;\n },\n set resolveMap(newResolveMap) {\n // If the resolve map changes, clear the import map\n // so that it is regenerated on the next request\n importMap = undefined;\n resolveMap = newResolveMap;\n },\n sequence: 0,\n urls: {\n appServer: '',\n bundleServer: '',\n apiServer: '',\n },\n targetVersions: versions.targetVersions,\n get sessionVersion() {\n return versions.sessionVersion;\n },\n incrementSessionVersion: () => {\n versions.sessionVersion++;\n importMap = undefined;\n // Write the new session version to the file\n // eslint-disable-next-line @ms-cloudpack/internal/no-sync-filesystem -- this function can't be async\n fs.writeFileSync(versionsPath, JSON.stringify(versions, null, 2));\n },\n incrementTargetVersion: (inputPath: string) => {\n versions.targetVersions[inputPath] ??= 0;\n versions.targetVersions[inputPath]++;\n importMap = undefined;\n // eslint-disable-next-line @ms-cloudpack/internal/no-sync-filesystem -- this function can't be async\n writeJsonSync(versionsPath, versions);\n },\n get importMap() {\n return importMap;\n },\n set importMap(newImportMap) {\n importMap = newImportMap;\n },\n };\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -29,9 +29,9 @@ export { ZodTaskEndDescription } from './types/TaskEndDescription.js';
|
|
|
29
29
|
export { ZodTaskMessage } from './types/TaskMessage.js';
|
|
30
30
|
export { ZodTaskStartDescription } from './types/TaskStartDescription.js';
|
|
31
31
|
export { getCachePath, getLocalCachePath } from './utilities/getCachePath.js';
|
|
32
|
+
export { getSessionPath } from './utilities/getSessionPath.js';
|
|
32
33
|
export { getConsumedDependencies } from './utilities/getConsumedDependencies.js';
|
|
33
34
|
export { getConsumedPaths } from './utilities/getConsumedPaths.js';
|
|
34
|
-
export { parseRequestInfo } from './utilities/parseRequestInfo.js';
|
|
35
35
|
export { createPartialApiContext } from './common/createPartialApiContext.js';
|
|
36
36
|
export { addPackageOverride, ensurePackageBundled, getData, getSessionId, onDataChanged, openCodeEditor, openConfigEditor, openFilePath, reportMetric, syncDownload, syncUpload, validatePackageOverride, } from './apis/index.js';
|
|
37
37
|
//# sour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AA+B,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAGnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAG9E,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,OAAO,EACP,YAAY,EACZ,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,uBAAuB,GACxB,MAAM,iBAAiB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -8,10 +8,10 @@ export { ZodTaskEndDescription } from './types/TaskEndDescription.js';
|
|
|
8
8
|
export { ZodTaskMessage } from './types/TaskMessage.js';
|
|
9
9
|
export { ZodTaskStartDescription } from './types/TaskStartDescription.js';
|
|
10
10
|
export { getCachePath, getLocalCachePath } from './utilities/getCachePath.js';
|
|
11
|
+
export { getSessionPath } from './utilities/getSessionPath.js';
|
|
11
12
|
export { getConsumedDependencies } from './utilities/getConsumedDependencies.js';
|
|
12
13
|
export { getConsumedPaths } from './utilities/getConsumedPaths.js';
|
|
13
14
|
// Utilities
|
|
14
|
-
export { parseRequestInfo } from './utilities/parseRequestInfo.js';
|
|
15
15
|
export { createPartialApiContext } from './common/createPartialApiContext.js';
|
|
16
16
|
// API methods
|
|
17
17
|
export { addPackageOverride, ensurePackageBundled, getData, getSessionId, onDataChanged, openCodeEditor, openConfigEditor, openFilePath, reportMetric, syncDownload, syncUpload, validatePackageOverride, } from './apis/index.js';
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAgCA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO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AEnE,YAAY;AACZ,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAE9E,cAAc;AACd,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,OAAO,EACP,YAAY,EACZ,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,uBAAuB,GACxB,MAAM,iBAAiB,CAAC","sourcesContent":["export type { ApiServer } from './types/ApiServer.js';\nexport type { Context } from './types/Context.js';\nexport type { BundleInfo } from './types/BundleInfo.js';\nexport type { Session } from './types/Session.js';\nexport type { TaskStats } from './types/TaskStats.js';\nexport type { Task } from './types/Task.js';\nexport type { TaskDescription } from './types/TaskDescription.js';\nexport type { TaskEndDescription } from './types/TaskEndDescription.js';\nexport type { TaskMessage } from './types/TaskMessage.js';\nexport type { TaskOptions } from './types/TaskOptions.js';\nexport type { TaskStartDescription } from './types/TaskStartDescription.js';\nexport type { CloudpackServer } from './trpc/createCloudpackServer.js';\n\n// API types\nexport type { AddPackageOverrideInput } from './apis/addPackageOverride.js';\nexport type { OpenCodeEditorInput } from './apis/openCodeEditor.js';\nexport type { OpenFilePathInput } from './apis/openFilePath.js';\nexport type { ReportMetricInput } from './apis/reportMetric.js';\nexport type { ValidatePackageOverrideInput, ValidatePackageOverrideOutput } from './apis/validatePackageOverride.js';\n\n// TODO: delete these type exports once API reporting of \"forgotten\" exports is enabled\n// (they're not used and don't really need to be visible in the API)\nexport type {\n EnsurePackageBundledContext,\n EnsurePackageBundledInput,\n EnsurePackageBundledOutput,\n EnsurePackageBundledResult,\n} from './apis/ensurePackageBundled.js';\nexport type { BundleRequest } from './types/BundleRequest.js';\nexport type { BundleTaskOptions } from './types/BundleTaskOptions.js';\nexport type { OverrideOptions } from './types/OverrideOptions.js';\n\nexport { TaskRunner } from './utilities/TaskRunner.js';\nexport { reloadCountSource, taskListSource, taskStatsSource } from './data/busSources.js';\nexport { startApiServer } from './startApiServer.js';\nexport { createCloudpackClient } from './trpc/createCloudpackClient.js';\nexport { createCloudpackServer } from './trpc/createCloudpackServer.js';\nexport { ZodTaskDescription } from './types/TaskDescription.js';\nexport { ZodTaskEndDescription } from './types/TaskEndDescription.js';\nexport { ZodTaskMessage } from './types/TaskMessage.js';\nexport { ZodTaskStartDescription } from './types/TaskStartDescription.js';\nexport { getCachePath, getLocalCachePath } from './utilities/getCachePath.js';\nexport { getSessionPath } from './utilities/getSessionPath.js';\nexport { getConsumedDependencies } from './utilities/getConsumedDependencies.js';\nexport { getConsumedPaths } from './utilities/getConsumedPaths.js';\n\n// Utilities\nexport { createPartialApiContext } from './common/createPartialApiContext.js';\n\n// API methods\nexport {\n addPackageOverride,\n ensurePackageBundled,\n getData,\n getSessionId,\n onDataChanged,\n openCodeEditor,\n openConfigEditor,\n openFilePath,\n reportMetric,\n syncDownload,\n syncUpload,\n validatePackageOverride,\n} from './apis/index.js';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startApiServer.d.ts","sourceRoot":"","sources":["../src/startApiServer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAM5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGlD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAS1E;;;;;;;;;;;;;GAaG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE;IAC3C,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,eAAe,CAAC;IACjC,QAAQ,EAAE,uBAAuB,CAAC;IAClC,GAAG,EAAE,OAAO,CAAC;IACb,UAAU,EAAE,UAAU,CAAC;CACxB,GAAG,OAAO,CAAC,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"startApiServer.d.ts","sourceRoot":"","sources":["../src/startApiServer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAM5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGlD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAS1E;;;;;;;;;;;;;GAaG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE;IAC3C,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,eAAe,CAAC;IACjC,QAAQ,EAAE,uBAAuB,CAAC;IAClC,GAAG,EAAE,OAAO,CAAC;IACb,UAAU,EAAE,UAAU,CAAC;CACxB,GAAG,OAAO,CAAC,SAAS,CAAC,CAsTrB"}
|
package/lib/startApiServer.js
CHANGED
|
@@ -124,6 +124,7 @@ export async function startApiServer(params) {
|
|
|
124
124
|
try {
|
|
125
125
|
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
126
126
|
const request = JSON.parse(rawData.toString());
|
|
127
|
+
const requestId = request.requestId || '';
|
|
127
128
|
switch (request.type) {
|
|
128
129
|
/**
|
|
129
130
|
* Subscribe to a data subscription.
|
|
@@ -195,7 +196,6 @@ export async function startApiServer(params) {
|
|
|
195
196
|
}
|
|
196
197
|
case 'validateOverride': {
|
|
197
198
|
// TODO: Get filename from request data when chromium Issue 1371551 is fixed.
|
|
198
|
-
const requestId = request.requestId || '';
|
|
199
199
|
(async () => {
|
|
200
200
|
const input = request.data;
|
|
201
201
|
const fixable = await validateOverride(input, { session, packages });
|
|
@@ -233,6 +233,10 @@ export async function startApiServer(params) {
|
|
|
233
233
|
reportMetric({ input: request.data, ctx: { telemetryClient } });
|
|
234
234
|
break;
|
|
235
235
|
}
|
|
236
|
+
case 'getSessionId': {
|
|
237
|
+
sendMessage({ type: 'sessionId', requestId, data: { sessionId: session.id } });
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
236
240
|
}
|
|
237
241
|
}
|
|
238
242
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startApiServer.js","sourceRoot":"","sources":["../src/startApiServer.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,SAAS,EAAE,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAGhD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,OAAO,MAAM,UAAU,CAAC;AAM/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE1F,OAAO,EAAE,kBAAkB,EAAgC,MAAM,8BAA8B,CAAC;AAEhG,OAAO,EAAE,cAAc,EAA4B,MAAM,0BAA0B,CAAC;AACpF,OAAO,EAAE,YAAY,EAA0B,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,YAAY,EAA0B,MAAM,wBAAwB,CAAC;AAE9E;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAMpC;IACC,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,GA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,KAAK,EAAE,GAAG,EAAE,CACV,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACpC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAiB,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;YACxE,YAAY,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YAC7D,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC,CAAC;KACL,CAAC;AACJ,CAAC","sourcesContent":["import getPort from 'get-port';\nimport http from 'http';\nimport https from 'https';\nimport WebSocket, { WebSocketServer } from 'ws';\nimport type { DataBus } from '@ms-cloudpack/data-bus';\nimport type { TaskRunner } from './utilities/TaskRunner.js';\nimport { getCachePath } from './utilities/getCachePath.js';\nimport fsExtra from 'fs-extra';\nimport type { TaskDescription } from './types/TaskDescription.js';\nimport type { TaskEndDescription } from './types/TaskEndDescription.js';\nimport type { TaskStartDescription } from './types/TaskStartDescription.js';\nimport type { ApiServer } from './types/ApiServer.js';\nimport type { Session } from './types/Session.js';\nimport { validateOverride } from './utilities/validateOverride.js';\nimport { parseHttpsConfig, getDomain } from '@ms-cloudpack/create-express-app';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport { editCloudpackConfig } from './utilities/editCloudpackConfig.js';\nimport type { PackageDefinitionsCache } from '@ms-cloudpack/common-types';\nimport { reloadCountSource, taskListSource, taskStatsSource } from './data/busSources.js';\nimport type { TaskStats } from './types/TaskStats.js';\nimport { addPackageOverride, type AddPackageOverrideInput } from './apis/addPackageOverride.js';\nimport type { ValidatePackageOverrideInput, ValidatePackageOverrideOutput } from './apis/validatePackageOverride.js';\nimport { openCodeEditor, type OpenCodeEditorInput } from './apis/openCodeEditor.js';\nimport { openFilePath, type OpenFilePathInput } from './apis/openFilePath.js';\nimport { reportMetric, type ReportMetricInput } from './apis/reportMetric.js';\n\n/**\n * The api server handles the data pub/sub (for things like reporting build status)\n * and hosting the dashboard verb backend (for executing actions like loading vscode,\n * changing dependencies, connecting new projects to the running session, etc.)\n *\n * Each time `cloudpack start` is run, an api server will start up for that session. The\n * hosted web page will have a \"cloudpack-api-server\" header which points\n * to the websocket server.\n *\n * The bundle server will call the api server to publish build status updates.\n *\n * The app server will burn the api server url on the host html, so that client-side\n * javascript can connect and subscribe to page changes.\n */\nexport async function startApiServer(params: {\n session: Session;\n telemetryClient: TelemetryClient;\n packages: PackageDefinitionsCache;\n bus: DataBus;\n taskRunner: TaskRunner;\n}): Promise<ApiServer> {\n const { session, telemetryClient, packages, bus, taskRunner } = params;\n const host = getDomain(session.config?.devServer?.domain);\n const port = await getPort({ port: [9890, 9891, 9892, 9893] });\n const sessionStats: TaskStats = {\n status: 'idle',\n\n remainingTasks: 0,\n totalTasks: 0,\n\n totalErrors: 0,\n totalWarnings: 0,\n };\n\n const allTasks = new Map<string, TaskDescription>();\n\n function reportStart(taskStart: TaskStartDescription): void {\n const previousResult = allTasks.get(taskStart.id);\n const now = new Date().getTime();\n\n if (!previousResult) {\n sessionStats.totalTasks++;\n }\n\n if (previousResult?.status === 'complete') {\n sessionStats.totalErrors -= previousResult.errors?.length || 0;\n sessionStats.totalWarnings -= previousResult.warnings?.length || 0;\n }\n\n sessionStats.remainingTasks++;\n sessionStats.status = 'pending';\n\n allTasks.set(taskStart.id, {\n ...taskStart,\n status: 'pending',\n startTime: now,\n });\n\n bus.publish(taskStatsSource, sessionStats);\n bus.publish(taskListSource, { tasks: Array.from(allTasks.values()) });\n }\n\n function reportEnd(taskEnd: TaskEndDescription): void {\n const previousResult = allTasks.get(taskEnd.id);\n const now = new Date().getTime();\n\n if (previousResult) {\n sessionStats.remainingTasks--;\n sessionStats.totalErrors += taskEnd.errors?.length || 0;\n sessionStats.totalWarnings += taskEnd.warnings?.length || 0;\n\n allTasks.set(taskEnd.id, {\n ...previousResult,\n ...taskEnd,\n status: 'complete',\n durationMilliseconds: now - previousResult.startTime,\n lastUpdated: now,\n });\n\n if (sessionStats.remainingTasks === 0) {\n sessionStats.status = 'idle';\n }\n\n bus.publish(taskStatsSource, sessionStats);\n bus.publish(taskListSource, { tasks: Array.from(allTasks.values()) });\n }\n }\n\n taskRunner.on('executeStarted', reportStart);\n taskRunner.on('executeCompleted', reportEnd);\n\n bus.publish([session.id, 'status'], sessionStats);\n\n // Create a node http(s) server.\n let server: http.Server | https.Server;\n const httpsConfig = session.config?.devServer?.https;\n const protocol = httpsConfig ? 'wss' : 'ws';\n\n if (httpsConfig) {\n const { key, cert, passphrase } = parseHttpsConfig(httpsConfig);\n\n if (!key || !cert) {\n console.error('Invalid https config in cloudpack.config.json. Make sure key and cert are valid.');\n\n throw new Error('Invalid https config.');\n }\n\n server = https\n .createServer(\n {\n key,\n cert,\n passphrase,\n },\n () => {\n /* no-op */\n },\n )\n .listen(port, host);\n } else {\n server = http.createServer().listen(port, host);\n }\n\n // Create a websocket server which listens for subscriptions and verb requests,\n // and broadcasts the data to all connected clients.\n const socketServer = new WebSocketServer({ server }, () => {\n // console.log(`ApiServer: Started on port ${port}`);\n }).on('connection', (socket: WebSocket) => {\n const disposables = new Map<number, () => void>();\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n function sendMessage(message: any) {\n socket.send(JSON.stringify(message, null, 2));\n }\n\n socket.send(\n JSON.stringify({\n type: 'sequence',\n sequence: session.sequence,\n }),\n );\n\n socket\n .on('message', (rawData) => {\n try {\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n const request = JSON.parse(rawData.toString()) as {\n type: string;\n requestId?: string;\n data: Record<string, unknown>;\n };\n\n switch (request.type) {\n /**\n * Subscribe to a data subscription.\n */\n case 'subscribe': {\n const { path: subscriptionPath, id } = request.data;\n\n disposables.set(\n id as number,\n bus.subscribe(\n subscriptionPath as string[],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment\n (data: any) => sendMessage({ type: 'notify', id, path: subscriptionPath, data }),\n ),\n );\n\n break;\n }\n\n /**\n * Unsubscribe from a data subscription.\n */\n case 'unsubscribe': {\n const id = request.data.id as number | undefined;\n if (id) {\n const dispose = disposables.get(id);\n\n if (dispose) {\n dispose();\n disposables.delete(id);\n }\n }\n\n break;\n }\n\n /**\n * Open a file in VSCode.\n */\n case 'openSource': {\n openCodeEditor({ input: request.data as OpenCodeEditorInput, ctx: {} }).catch(() => {\n // ignore\n });\n break;\n }\n\n /**\n * Open a file or folder in the OS's default file manager.\n */\n case 'open': {\n openFilePath({ input: request.data as OpenFilePathInput, ctx: { session } }).catch(() => {\n // ignore\n });\n break;\n }\n\n /**\n * Opens the cloudpack config in VSCode for the user to manually edit. If the file doesn't exist,\n * it will be created.\n */\n case 'editConfig': {\n editCloudpackConfig(session.appPath).catch(() => {\n /* no-op */\n });\n break;\n }\n\n /**\n * Adds an override to the cloudpack config.\n */\n case 'addOverride': {\n // TODO: Send filename from request data to findResolveMapEntry when chromium Issue 1371551 is fixed.\n (async () => {\n const { packageName, importPath } = request.data as AddPackageOverrideInput;\n await addPackageOverride({\n input: { packageName, importPath },\n ctx: { session, bus, packages, taskRunner },\n });\n })().catch(() => {\n // no-op\n });\n break;\n }\n\n case 'validateOverride': {\n // TODO: Get filename from request data when chromium Issue 1371551 is fixed.\n const requestId = request.requestId || '';\n (async () => {\n const input = request.data as ValidatePackageOverrideInput;\n const fixable = await validateOverride(input, { session, packages });\n const result: ValidatePackageOverrideOutput = { fixable };\n sendMessage({ type: 'validateOverride', requestId, data: result });\n })().catch(() => {\n // no-op\n });\n break;\n }\n\n case 'restartAllTasks': {\n console.log('ApiServer: Restarting all tasks');\n\n // Clear entire local cache.\n // eslint-disable-next-line @ms-cloudpack/internal/no-sync-filesystem\n fsExtra.emptyDirSync(getCachePath());\n\n // All tasks can be removed as notifyReload()\n // will cause the client to add the tasks again.\n allTasks.forEach((_, id) => {\n taskRunner.remove(id);\n });\n\n // Update session version.\n session.incrementSessionVersion();\n\n notifyReload();\n break;\n }\n\n case 'restartTask': {\n const { id, inputPath } = request.data as Record<string, string>;\n console.log(`ApiServer: Restarting task ${id}`);\n taskRunner.remove(id);\n session.incrementTargetVersion(inputPath);\n notifyReload();\n break;\n }\n\n case 'reportMetric': {\n reportMetric({ input: request.data as ReportMetricInput, ctx: { telemetryClient } });\n break;\n }\n }\n } catch (err) {\n console.error('ApiServer: error handling message');\n console.error('Error:', (err as Error).stack || err);\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n console.error('Message:', rawData.toString());\n }\n })\n .on('close', () => {\n for (const d of disposables.values()) {\n d();\n }\n });\n });\n\n const notifyReload = () => {\n session.sequence++;\n socketServer.clients.forEach((socket: WebSocket) => {\n if (socket.readyState === WebSocket.OPEN) {\n socket.send(\n JSON.stringify({\n type: 'reload',\n data: { sessionId: session.id },\n }),\n );\n }\n });\n };\n\n bus.subscribe(reloadCountSource, notifyReload);\n\n return {\n url: `${protocol}://${host}:${port}`,\n port,\n close: () =>\n new Promise<void>((resolve, reject) => {\n socketServer.clients.forEach((socket: WebSocket) => socket.terminate());\n socketServer.close((err) => (err ? reject(err) : resolve()));\n server.close();\n }),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"startApiServer.js","sourceRoot":"","sources":["../src/startApiServer.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,SAAS,EAAE,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAGhD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,OAAO,MAAM,UAAU,CAAC;AAM/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAA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AI,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC;gBACrC,CAAC,EAAE,CAAC;YACN,CAAC;QACH,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,GAAG,EAAE;QACxB,OAAO,CAAC,QAAQ,EAAE,CAAC;QACnB,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAiB,EAAE,EAAE;YACjD,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,CAAC,IAAI,EAAE,CAAC;gBACzC,MAAM,CAAC,IAAI,CACT,IAAI,CAAC,SAAS,CAAC;oBACb,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,EAAE;iBAChC,CAAC,CACH,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,GAAG,CAAC,SAAS,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAC;IAE/C,OAAO;QACL,GAAG,EAAE,GAAG,QAAQ,MAAM,IAAI,IAAI,IAAI,EAAE;QACpC,IAAI;QACJ,KAAK,EAAE,GAAG,EAAE,CACV,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACpC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAiB,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;YACxE,YAAY,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YAC7D,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC,CAAC;KACL,CAAC;AACJ,CAAC","sourcesContent":["import getPort from 'get-port';\nimport http from 'http';\nimport https from 'https';\nimport WebSocket, { WebSocketServer } from 'ws';\nimport type { DataBus } from '@ms-cloudpack/data-bus';\nimport type { TaskRunner } from './utilities/TaskRunner.js';\nimport { getCachePath } from './utilities/getCachePath.js';\nimport fsExtra from 'fs-extra';\nimport type { TaskDescription } from './types/TaskDescription.js';\nimport type { TaskEndDescription } from './types/TaskEndDescription.js';\nimport type { TaskStartDescription } from './types/TaskStartDescription.js';\nimport type { ApiServer } from './types/ApiServer.js';\nimport type { Session } from './types/Session.js';\nimport { validateOverride } from './utilities/validateOverride.js';\nimport { parseHttpsConfig, getDomain } from '@ms-cloudpack/create-express-app';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport { editCloudpackConfig } from './utilities/editCloudpackConfig.js';\nimport type { PackageDefinitionsCache } from '@ms-cloudpack/common-types';\nimport { reloadCountSource, taskListSource, taskStatsSource } from './data/busSources.js';\nimport type { TaskStats } from './types/TaskStats.js';\nimport { addPackageOverride, type AddPackageOverrideInput } from './apis/addPackageOverride.js';\nimport type { ValidatePackageOverrideInput, ValidatePackageOverrideOutput } from './apis/validatePackageOverride.js';\nimport { openCodeEditor, type OpenCodeEditorInput } from './apis/openCodeEditor.js';\nimport { openFilePath, type OpenFilePathInput } from './apis/openFilePath.js';\nimport { reportMetric, type ReportMetricInput } from './apis/reportMetric.js';\n\n/**\n * The api server handles the data pub/sub (for things like reporting build status)\n * and hosting the dashboard verb backend (for executing actions like loading vscode,\n * changing dependencies, connecting new projects to the running session, etc.)\n *\n * Each time `cloudpack start` is run, an api server will start up for that session. The\n * hosted web page will have a \"cloudpack-api-server\" header which points\n * to the websocket server.\n *\n * The bundle server will call the api server to publish build status updates.\n *\n * The app server will burn the api server url on the host html, so that client-side\n * javascript can connect and subscribe to page changes.\n */\nexport async function startApiServer(params: {\n session: Session;\n telemetryClient: TelemetryClient;\n packages: PackageDefinitionsCache;\n bus: DataBus;\n taskRunner: TaskRunner;\n}): Promise<ApiServer> {\n const { session, telemetryClient, packages, bus, taskRunner } = params;\n const host = getDomain(session.config?.devServer?.domain);\n const port = await getPort({ port: [9890, 9891, 9892, 9893] });\n const sessionStats: TaskStats = {\n status: 'idle',\n\n remainingTasks: 0,\n totalTasks: 0,\n\n totalErrors: 0,\n totalWarnings: 0,\n };\n\n const allTasks = new Map<string, TaskDescription>();\n\n function reportStart(taskStart: TaskStartDescription): void {\n const previousResult = allTasks.get(taskStart.id);\n const now = new Date().getTime();\n\n if (!previousResult) {\n sessionStats.totalTasks++;\n }\n\n if (previousResult?.status === 'complete') {\n sessionStats.totalErrors -= previousResult.errors?.length || 0;\n sessionStats.totalWarnings -= previousResult.warnings?.length || 0;\n }\n\n sessionStats.remainingTasks++;\n sessionStats.status = 'pending';\n\n allTasks.set(taskStart.id, {\n ...taskStart,\n status: 'pending',\n startTime: now,\n });\n\n bus.publish(taskStatsSource, sessionStats);\n bus.publish(taskListSource, { tasks: Array.from(allTasks.values()) });\n }\n\n function reportEnd(taskEnd: TaskEndDescription): void {\n const previousResult = allTasks.get(taskEnd.id);\n const now = new Date().getTime();\n\n if (previousResult) {\n sessionStats.remainingTasks--;\n sessionStats.totalErrors += taskEnd.errors?.length || 0;\n sessionStats.totalWarnings += taskEnd.warnings?.length || 0;\n\n allTasks.set(taskEnd.id, {\n ...previousResult,\n ...taskEnd,\n status: 'complete',\n durationMilliseconds: now - previousResult.startTime,\n lastUpdated: now,\n });\n\n if (sessionStats.remainingTasks === 0) {\n sessionStats.status = 'idle';\n }\n\n bus.publish(taskStatsSource, sessionStats);\n bus.publish(taskListSource, { tasks: Array.from(allTasks.values()) });\n }\n }\n\n taskRunner.on('executeStarted', reportStart);\n taskRunner.on('executeCompleted', reportEnd);\n\n bus.publish([session.id, 'status'], sessionStats);\n\n // Create a node http(s) server.\n let server: http.Server | https.Server;\n const httpsConfig = session.config?.devServer?.https;\n const protocol = httpsConfig ? 'wss' : 'ws';\n\n if (httpsConfig) {\n const { key, cert, passphrase } = parseHttpsConfig(httpsConfig);\n\n if (!key || !cert) {\n console.error('Invalid https config in cloudpack.config.json. Make sure key and cert are valid.');\n\n throw new Error('Invalid https config.');\n }\n\n server = https\n .createServer(\n {\n key,\n cert,\n passphrase,\n },\n () => {\n /* no-op */\n },\n )\n .listen(port, host);\n } else {\n server = http.createServer().listen(port, host);\n }\n\n // Create a websocket server which listens for subscriptions and verb requests,\n // and broadcasts the data to all connected clients.\n const socketServer = new WebSocketServer({ server }, () => {\n // console.log(`ApiServer: Started on port ${port}`);\n }).on('connection', (socket: WebSocket) => {\n const disposables = new Map<number, () => void>();\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n function sendMessage(message: any) {\n socket.send(JSON.stringify(message, null, 2));\n }\n\n socket.send(\n JSON.stringify({\n type: 'sequence',\n sequence: session.sequence,\n }),\n );\n\n socket\n .on('message', (rawData) => {\n try {\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n const request = JSON.parse(rawData.toString()) as {\n type: string;\n requestId?: string;\n data: Record<string, unknown>;\n };\n\n const requestId = request.requestId || '';\n\n switch (request.type) {\n /**\n * Subscribe to a data subscription.\n */\n case 'subscribe': {\n const { path: subscriptionPath, id } = request.data;\n\n disposables.set(\n id as number,\n bus.subscribe(\n subscriptionPath as string[],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment\n (data: any) => sendMessage({ type: 'notify', id, path: subscriptionPath, data }),\n ),\n );\n\n break;\n }\n\n /**\n * Unsubscribe from a data subscription.\n */\n case 'unsubscribe': {\n const id = request.data.id as number | undefined;\n if (id) {\n const dispose = disposables.get(id);\n\n if (dispose) {\n dispose();\n disposables.delete(id);\n }\n }\n\n break;\n }\n\n /**\n * Open a file in VSCode.\n */\n case 'openSource': {\n openCodeEditor({ input: request.data as OpenCodeEditorInput, ctx: {} }).catch(() => {\n // ignore\n });\n break;\n }\n\n /**\n * Open a file or folder in the OS's default file manager.\n */\n case 'open': {\n openFilePath({ input: request.data as OpenFilePathInput, ctx: { session } }).catch(() => {\n // ignore\n });\n break;\n }\n\n /**\n * Opens the cloudpack config in VSCode for the user to manually edit. If the file doesn't exist,\n * it will be created.\n */\n case 'editConfig': {\n editCloudpackConfig(session.appPath).catch(() => {\n /* no-op */\n });\n break;\n }\n\n /**\n * Adds an override to the cloudpack config.\n */\n case 'addOverride': {\n // TODO: Send filename from request data to findResolveMapEntry when chromium Issue 1371551 is fixed.\n (async () => {\n const { packageName, importPath } = request.data as AddPackageOverrideInput;\n await addPackageOverride({\n input: { packageName, importPath },\n ctx: { session, bus, packages, taskRunner },\n });\n })().catch(() => {\n // no-op\n });\n break;\n }\n\n case 'validateOverride': {\n // TODO: Get filename from request data when chromium Issue 1371551 is fixed.\n (async () => {\n const input = request.data as ValidatePackageOverrideInput;\n const fixable = await validateOverride(input, { session, packages });\n const result: ValidatePackageOverrideOutput = { fixable };\n sendMessage({ type: 'validateOverride', requestId, data: result });\n })().catch(() => {\n // no-op\n });\n break;\n }\n\n case 'restartAllTasks': {\n console.log('ApiServer: Restarting all tasks');\n\n // Clear entire local cache.\n // eslint-disable-next-line @ms-cloudpack/internal/no-sync-filesystem\n fsExtra.emptyDirSync(getCachePath());\n\n // All tasks can be removed as notifyReload()\n // will cause the client to add the tasks again.\n allTasks.forEach((_, id) => {\n taskRunner.remove(id);\n });\n\n // Update session version.\n session.incrementSessionVersion();\n\n notifyReload();\n break;\n }\n\n case 'restartTask': {\n const { id, inputPath } = request.data as Record<string, string>;\n console.log(`ApiServer: Restarting task ${id}`);\n taskRunner.remove(id);\n session.incrementTargetVersion(inputPath);\n notifyReload();\n break;\n }\n\n case 'reportMetric': {\n reportMetric({ input: request.data as ReportMetricInput, ctx: { telemetryClient } });\n break;\n }\n\n case 'getSessionId': {\n sendMessage({ type: 'sessionId', requestId, data: { sessionId: session.id } });\n break;\n }\n }\n } catch (err) {\n console.error('ApiServer: error handling message');\n console.error('Error:', (err as Error).stack || err);\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n console.error('Message:', rawData.toString());\n }\n })\n .on('close', () => {\n for (const d of disposables.values()) {\n d();\n }\n });\n });\n\n const notifyReload = () => {\n session.sequence++;\n socketServer.clients.forEach((socket: WebSocket) => {\n if (socket.readyState === WebSocket.OPEN) {\n socket.send(\n JSON.stringify({\n type: 'reload',\n data: { sessionId: session.id },\n }),\n );\n }\n });\n };\n\n bus.subscribe(reloadCountSource, notifyReload);\n\n return {\n url: `${protocol}://${host}:${port}`,\n port,\n close: () =>\n new Promise<void>((resolve, reject) => {\n socketServer.clients.forEach((socket: WebSocket) => socket.terminate());\n socketServer.close((err) => (err ? reject(err) : resolve()));\n server.close();\n }),\n };\n}\n"]}
|
package/lib/types/Session.d.ts
CHANGED
|
@@ -37,6 +37,14 @@ export interface Session {
|
|
|
37
37
|
* up to date with the latest changes.
|
|
38
38
|
*/
|
|
39
39
|
sequence: number;
|
|
40
|
+
/**
|
|
41
|
+
* Urls of the active servers hosting this session.
|
|
42
|
+
*/
|
|
43
|
+
urls: {
|
|
44
|
+
appServer: string;
|
|
45
|
+
bundleServer: string;
|
|
46
|
+
apiServer: string;
|
|
47
|
+
};
|
|
40
48
|
/**
|
|
41
49
|
* Used to force a hard refresh on the client.
|
|
42
50
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Session.d.ts","sourceRoot":"","sources":["../../src/types/Session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE,MAAM,WAAW,OAAO;IACtB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,MAAM,EAAE,eAAe,CAAC;IAExB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,IAAI,EAAE,SAAS,GAAG,SAAS,CAAC;IAE5B;;;;;;OAMG;IACH,IAAI,EAAE,SAAS,GAAG,aAAa,GAAG,YAAY,CAAC;IAE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;IAEvB;;OAEG;IACH,uBAAuB,EAAE,MAAM,IAAI,CAAC;IAEpC;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEvC;;OAEG;IACH,sBAAsB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAEpD;;OAEG;IACH,SAAS,EAAE,SAAS,GAAG,SAAS,CAAC;CAClC"}
|
package/lib/types/Session.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Session.js","sourceRoot":"","sources":["../../src/types/Session.ts"],"names":[],"mappings":"","sourcesContent":["import type { ImportMap } from '@ms-cloudpack/import-map';\nimport type { ResolveMap } from '@ms-cloudpack/package-utilities';\nimport type { CloudpackConfig } from '@ms-cloudpack/common-types';\n\nexport interface Session {\n /**\n * The session id, used for identifying\n */\n id: string;\n\n /**\n * The config used by the session.\n */\n config: CloudpackConfig;\n\n /**\n * The primary application path to monitor.\n */\n appPath: string;\n\n /**\n * The type of session controls how the code is served via start.\n * Web apps require app server and asset hosting, while libraries\n * only need a bundle service.\n */\n type: 'web-app' | 'library';\n\n /**\n * The mode of the session controls how the code is bundled. Library\n * mode bundles each package in isolation, while development and\n * production modes bundle the full app graph together. Library\n * mode is fastest but packages must be complaint for loading in\n * the browser.\n */\n mode: 'library' | 'development' | 'production';\n\n /**\n * Used to resolve packages in the dependency graph.\n */\n resolveMap: ResolveMap;\n\n /**\n * Reload sequence to ensure that the client is always\n * up to date with the latest changes.\n */\n sequence: number;\n\n /**\n * Used to force a hard refresh on the client.\n */\n sessionVersion: number;\n\n /**\n * Used to increment the session version by 1.\n */\n incrementSessionVersion: () => void;\n\n /**\n * The name of the project folder.\n * Used to differentiate between multiple projects.\n */\n projectName: string;\n\n /**\n * The version of each target.\n * Used to force a client cache refresh on a single target.\n */\n targetVersions: Record<string, number>;\n\n /**\n * Increments the version for the given target.\n */\n incrementTargetVersion: (inputPath: string) => void;\n\n /**\n * The import map for the session.\n */\n importMap: ImportMap | undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Session.js","sourceRoot":"","sources":["../../src/types/Session.ts"],"names":[],"mappings":"","sourcesContent":["import type { ImportMap } from '@ms-cloudpack/import-map';\nimport type { ResolveMap } from '@ms-cloudpack/package-utilities';\nimport type { CloudpackConfig } from '@ms-cloudpack/common-types';\n\nexport interface Session {\n /**\n * The session id, used for identifying\n */\n id: string;\n\n /**\n * The config used by the session.\n */\n config: CloudpackConfig;\n\n /**\n * The primary application path to monitor.\n */\n appPath: string;\n\n /**\n * The type of session controls how the code is served via start.\n * Web apps require app server and asset hosting, while libraries\n * only need a bundle service.\n */\n type: 'web-app' | 'library';\n\n /**\n * The mode of the session controls how the code is bundled. Library\n * mode bundles each package in isolation, while development and\n * production modes bundle the full app graph together. Library\n * mode is fastest but packages must be complaint for loading in\n * the browser.\n */\n mode: 'library' | 'development' | 'production';\n\n /**\n * Used to resolve packages in the dependency graph.\n */\n resolveMap: ResolveMap;\n\n /**\n * Reload sequence to ensure that the client is always\n * up to date with the latest changes.\n */\n sequence: number;\n\n /**\n * Urls of the active servers hosting this session.\n */\n urls: {\n appServer: string;\n bundleServer: string;\n apiServer: string;\n };\n\n /**\n * Used to force a hard refresh on the client.\n */\n sessionVersion: number;\n\n /**\n * Used to increment the session version by 1.\n */\n incrementSessionVersion: () => void;\n\n /**\n * The name of the project folder.\n * Used to differentiate between multiple projects.\n */\n projectName: string;\n\n /**\n * The version of each target.\n * Used to force a client cache refresh on a single target.\n */\n targetVersions: Record<string, number>;\n\n /**\n * Increments the version for the given target.\n */\n incrementTargetVersion: (inputPath: string) => void;\n\n /**\n * The import map for the session.\n */\n importMap: ImportMap | undefined;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addOverride.d.ts","sourceRoot":"","sources":["../../src/utilities/addOverride.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"addOverride.d.ts","sourceRoot":"","sources":["../../src/utilities/addOverride.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,eAAe,EACrB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,CAAC,GAC7C,OAAO,CAAC;IACT,kDAAkD;IAClD,aAAa,EAAE,OAAO,CAAC;IACvB,sEAAsE;IACtE,KAAK,CAAC,EAAE,eAAe,CAAC;CACzB,CAAC,CAwHD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { checkMatch, readGeneratedConfig, writeGeneratedConfig } from '@ms-cloudpack/config';
|
|
2
|
+
import { parseRequestUrl } from '@ms-cloudpack/import-map';
|
|
2
3
|
import { addExportsMapEntry, findResolveMapEntry, flattenExportsMap, getExportsMap, } from '@ms-cloudpack/package-utilities';
|
|
3
4
|
import { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';
|
|
4
|
-
import { parseRequestUrl } from './parseRequestUrl.js';
|
|
5
5
|
/**
|
|
6
6
|
* The addOverride method is triggered by a user action in the overlay, when we detect new usage of an import path
|
|
7
7
|
* that isn't recognized. When the user triggers this override, we write it to the cloudpack generated config.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addOverride.js","sourceRoot":"","sources":["../../src/utilities/addOverride.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC7F,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,GAEd,MAAM,iCAAiC,CAAC;AACzC,OAAO,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DAAmD,WAAW,IAAI,CAAC,CAAC;YAChH,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QACzC,CAAC;QAED,6DAA6D;QAC7D,MAAM,kBAAkB,CACtB;YACE,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,OAAO;YACjC,WAAW;YACX,UAAU;SACX,EACD,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CACrC,CAAC;IACJ,CAAC;IAED,MAAM,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACpD,OAAO,CAAC,KAAK,CAAC,uBAAuB,WAAW,+BAA+B,CAAC,CAAC;IAEjF,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;AAClC,CAAC","sourcesContent":["import { checkMatch, readGeneratedConfig, writeGeneratedConfig } from '@ms-cloudpack/config';\nimport { parseRequestUrl } from '@ms-cloudpack/import-map';\nimport {\n addExportsMapEntry,\n findResolveMapEntry,\n flattenExportsMap,\n getExportsMap,\n type ResolveMapEntry,\n} from '@ms-cloudpack/package-utilities';\nimport { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport type { Context } from '../types/Context.js';\nimport type { OverrideOptions } from '../types/OverrideOptions.js';\n\n/**\n * The addOverride method is triggered by a user action in the overlay, when we detect new usage of an import path\n * that isn't recognized. When the user triggers this override, we write it to the cloudpack generated config.\n */\nexport async function addOverride(\n options: OverrideOptions,\n context: Pick<Context, 'packages' | 'session'>,\n): Promise<{\n /** Whether the override was successfully added */\n addedOverride: boolean;\n /** The entry (if any) in the resolve map the override was added to */\n entry?: ResolveMapEntry;\n}> {\n const { packageName, importPath, version, issuerUrl } = options;\n const { session, packages } = context;\n let addedOverride = false;\n let requiredBy = undefined;\n\n if (issuerUrl) {\n const { packageName: issuerName, version: issuerVersion } = parseRequestUrl(issuerUrl);\n requiredBy = { name: issuerName, version: issuerVersion };\n }\n\n const entry = findResolveMapEntry({\n packageName,\n resolveMap: session.resolveMap,\n definition: requiredBy,\n version,\n });\n\n if (!entry) {\n console.error(`Could not find entry of package \"${packageName}\" in resolve map`);\n return { addedOverride, entry };\n }\n\n const packagePath = entry.path;\n\n // Get current exports. We want to add an additional entry to what's there - not replace the default exports,\n // so we need the full map for the package.\n const exports = await getExportsMap({ packagePath }, { packages, config: session.config });\n const flattenedExports = flattenExportsMap(exports, { packagePath });\n\n // Return false if the import path already exists in the exports map.\n if (flattenedExports[normalizeRelativePath(importPath)]) {\n console.debug(`The import path \"${importPath}\" already exists in the exports map for \"${packageName}\".`);\n return { addedOverride, entry };\n }\n\n const addedExports = {};\n\n // Add the single new exports entry to the exports map.\n addedOverride = await addExportsMapEntry(\n {\n // This is required as addExportsMapEntry assumes addedExports is a record.\n exports: addedExports,\n packagePath,\n importPath,\n },\n { packages, config: session.config },\n );\n\n if (!addedOverride) {\n console.warn(\n `Unable to add override for package \"${packageName}\" to \"cloudpack.config.json\". The file \"${normalizeRelativePath(\n importPath,\n )}\" could not be found. Please check the import path and try again.`,\n );\n return { addedOverride, entry };\n }\n\n if (Array.isArray(exports)) {\n exports.push(addedExports);\n } else {\n const definition = await packages.get(packagePath);\n if (!definition) {\n console.error(`Could not find definition of package \"${packageName}\" in the cache`);\n return { addedOverride, entry };\n }\n definition.exports = [exports, addedExports];\n }\n\n // Parse the user config if it exists.\n const config = await readGeneratedConfig(session.appPath);\n\n // Ensure packageSettings exist.\n config.packageSettings ??= [];\n\n const configMatches = config.packageSettings.filter(({ match }) =>\n checkMatch({ name: packageName, version: entry.version, match, exactMatch: true }),\n );\n\n if (!configMatches.length) {\n config.packageSettings.push({\n match: {\n name: packageName,\n version: `^${entry.version}`,\n },\n exports: addedExports,\n });\n } else {\n if (configMatches.length > 1) {\n console.debug(\n `Found multiple matches for package \"${packageName}\" in cloudpack.config.json. Using the first match.`,\n );\n }\n\n // Use the first match and ensure exports exist\n configMatches[0].exports ??= {};\n\n const flattenedMatchExports = flattenExportsMap(configMatches[0].exports, { packagePath });\n\n // Return false if the import path already exists in the match exports map.\n if (flattenedMatchExports[normalizeRelativePath(importPath)]) {\n console.debug(`The import path \"${importPath}\" already exists in the config exports map for \"${packageName}\".`);\n return { addedOverride: false, entry };\n }\n\n // Add the single new exports entry to the match exports map.\n await addExportsMapEntry(\n {\n exports: configMatches[0].exports,\n packagePath,\n importPath,\n },\n { packages, config: session.config },\n );\n }\n\n await writeGeneratedConfig(config, session.appPath);\n console.debug(`Added override for \"${packageName}\" to \"cloudpack.config.json\".`);\n\n return { addedOverride, entry };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatBundleTaskResult.d.ts","sourceRoot":"","sources":["../../src/utilities/formatBundleTaskResult.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"formatBundleTaskResult.d.ts","sourceRoot":"","sources":["../../src/utilities/formatBundleTaskResult.ts"],"names":[],"mappings":"AACA,OAAO,EAAqC,KAAK,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC7G,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAK/D,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,aAAa,GAAG,sBAAsB,CAoD3F"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { formatLocation } from '@ms-cloudpack/path-utilities';
|
|
2
|
-
import { red, bulletedList, plural, indent
|
|
2
|
+
import { red, bulletedList, plural, indent } from '@ms-cloudpack/task-reporter';
|
|
3
3
|
import { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';
|
|
4
4
|
import { getFileSizeSync } from './getFileSizeSync.js';
|
|
5
5
|
import path from 'path';
|
|
@@ -20,29 +20,30 @@ export function formatBundleTaskResult(bundleRequest) {
|
|
|
20
20
|
source: 'bundleTask',
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
23
|
+
const errors = result.errors?.map((error) => {
|
|
24
|
+
const { text, source, location } = error;
|
|
25
|
+
const filePath = location ? ' ' + formatLocation({ ...location, fromPath: packagePath }) : '';
|
|
26
|
+
return `[${source}]${filePath}\n${red(indent(text, 1))}`;
|
|
27
|
+
});
|
|
28
|
+
const hasErrors = result.errors.length > 0;
|
|
29
|
+
const status = hasErrors ? 'fail' : 'complete';
|
|
30
|
+
const message = hasErrors ? plural(result.errors.length, 'error$s found') : undefined;
|
|
31
|
+
const details = bulletedList([
|
|
32
|
+
`Package: ${bundleRequest.packageName}@${bundleRequest.version}`,
|
|
33
|
+
`Bundler: ${result.bundlerName || 'unknown'}`,
|
|
34
|
+
`From cache: ${bundleRequest.resultFromCache}`,
|
|
35
|
+
`Input path: ${bundleRequest.packagePath}`,
|
|
36
|
+
`Entries:`,
|
|
37
|
+
Object.values(result.entries || {}),
|
|
38
|
+
`Output path: ${result.outputPath}`,
|
|
39
|
+
`Output files:`,
|
|
40
|
+
result.outputFiles.map((file) => `${normalizeRelativePath(file.outputPath)} (${getFileSizeSync(path.resolve(result.outputPath, file.outputPath))})`),
|
|
41
|
+
]);
|
|
35
42
|
return {
|
|
36
|
-
status
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
`Input path: ${bundleRequest.packagePath}`,
|
|
41
|
-
`Entries:`,
|
|
42
|
-
Object.values(result.entries || {}),
|
|
43
|
-
`Output path: ${result.outputPath}`,
|
|
44
|
-
result.outputFiles.map((file) => `${normalizeRelativePath(file.outputPath)} (${getFileSizeSync(path.resolve(result.outputPath, file.outputPath))})`),
|
|
45
|
-
]),
|
|
43
|
+
status,
|
|
44
|
+
message,
|
|
45
|
+
errors,
|
|
46
|
+
details,
|
|
46
47
|
};
|
|
47
48
|
}
|
|
48
49
|
//# sourceMappingURL=formatBundleTaskResult.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatBundleTaskResult.js","sourceRoot":"","sources":["../../src/utilities/formatBundleTaskResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,
|
|
1
|
+
{"version":3,"file":"formatBundleTaskResult.js","sourceRoot":"","sources":["../../src/utilities/formatBundleTaskResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAA+B,MAAM,6BAA6B,CAAC;AAE7G,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,UAAU,sBAAsB,CAAC,aAA4B;IACjE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,aAAa,CAAC;IAEpE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO;YACL,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,yCAAyC,WAAW,IAAI,OAAO,GAAG;SAC5E,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,WAAW,KAAK,EAAE,CAAC;IAC1B,MAAM,CAAC,MAAM,KAAK,EAAE,CAAC;IACrB,MAAM,CAAC,QAAQ,KAAK,EAAE,CAAC;IAEvB,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;QACzD,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;YACnB,IAAI,EAAE,mCAAmC,WAAW,SAAS,MAAM,CAAC,UAAU,GAAG;YACjF,MAAM,EAAE,YAAY;SACrB,CAAC,CAAC;IACL,CAAC;IAED,MAAM,MAA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AAO,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CACjD,GAAG,CACP;KACF,CAAC,CAAC;IAEH,OAAO;QACL,MAAM;QACN,OAAO;QACP,MAAM;QACN,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["import { formatLocation } from '@ms-cloudpack/path-utilities';\nimport { red, bulletedList, plural, indent, type TaskReporterTaskResult } from '@ms-cloudpack/task-reporter';\nimport type { BundleRequest } from '../types/BundleRequest.js';\nimport { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport { getFileSizeSync } from './getFileSizeSync.js';\nimport path from 'path';\n\nexport function formatBundleTaskResult(bundleRequest: BundleRequest): TaskReporterTaskResult {\n const { result, packageName, version, packagePath } = bundleRequest;\n\n if (!result) {\n return {\n status: 'fail',\n details: `[bundleTask] No result was found for \"${packageName}@${version}\"`,\n };\n }\n\n result.outputFiles ??= [];\n result.errors ??= [];\n result.warnings ??= [];\n\n if (!result.outputFiles.length && !result.errors?.length) {\n result.warnings.push({\n text: `No output files were found for \"${packageName}\" in \"${result.outputPath}\"`,\n source: 'bundleTask',\n });\n }\n\n const errors = result.errors?.map((error) => {\n const { text, source, location } = error;\n const filePath = location ? ' ' + formatLocation({ ...location, fromPath: packagePath }) : '';\n return `[${source}]${filePath}\\n${red(indent(text, 1))}`;\n });\n const hasErrors = result.errors.length > 0;\n const status = hasErrors ? 'fail' : 'complete';\n const message = hasErrors ? plural(result.errors.length, 'error$s found') : undefined;\n const details = bulletedList([\n `Package: ${bundleRequest.packageName}@${bundleRequest.version}`,\n `Bundler: ${result.bundlerName || 'unknown'}`,\n `From cache: ${bundleRequest.resultFromCache}`,\n `Input path: ${bundleRequest.packagePath}`,\n `Entries:`,\n Object.values(result.entries || {}),\n `Output path: ${result.outputPath}`,\n `Output files:`,\n result.outputFiles.map(\n (file) =>\n `${normalizeRelativePath(file.outputPath)} (${getFileSizeSync(\n path.resolve(result.outputPath, file.outputPath),\n )})`,\n ),\n ]);\n\n return {\n status,\n message,\n errors,\n details,\n };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSessionPath.d.ts","sourceRoot":"","sources":["../../src/utilities/getSessionPath.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,UAE9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSessionPath.js","sourceRoot":"","sources":["../../src/utilities/getSessionPath.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,MAAM,UAAU,cAAc,CAAC,OAAgB;IAC7C,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["import path from 'path';\nimport { getCachePath } from './getCachePath.js';\nimport type { Session } from '../types/Session.js';\n\nexport function getSessionPath(session: Session) {\n return path.join(getCachePath(), 'active-sessions', `${session.id}.json`);\n}\n"]}
|
|
@@ -3,7 +3,7 @@ import type { LinkedPath, ResolveMap } from '@ms-cloudpack/package-utilities';
|
|
|
3
3
|
import { type TaskReporter } from '@ms-cloudpack/task-reporter';
|
|
4
4
|
/**
|
|
5
5
|
* Resolves the locations of dependencies and returns the resolve map, logging results
|
|
6
|
-
* to the task reporter.
|
|
6
|
+
* to the task reporter. Throws if dependencies could not be resolved.
|
|
7
7
|
*/
|
|
8
8
|
export declare function resolveDependenciesTask(options: {
|
|
9
9
|
appPath: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveDependenciesTask.d.ts","sourceRoot":"","sources":["../../src/utilities/resolveDependenciesTask.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAmB,MAAM,iCAAiC,CAAC;AAE/F,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAElG;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE;IACP,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;CAC5B,EACD,OAAO,EAAE;IAAE,QAAQ,EAAE,YAAY,CAAC;IAAC,QAAQ,EAAE,uBAAuB,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"resolveDependenciesTask.d.ts","sourceRoot":"","sources":["../../src/utilities/resolveDependenciesTask.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAmB,MAAM,iCAAiC,CAAC;AAE/F,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAElG;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE;IACP,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;CAC5B,EACD,OAAO,EAAE;IAAE,QAAQ,EAAE,YAAY,CAAC;IAAC,QAAQ,EAAE,uBAAuB,CAAA;CAAE,GACrE,OAAO,CAAC,UAAU,CAAC,CAkDrB"}
|
|
@@ -2,7 +2,7 @@ import { createResolveMap } from '@ms-cloudpack/package-utilities';
|
|
|
2
2
|
import { bold, bulletedList, cyan, yellow } from '@ms-cloudpack/task-reporter';
|
|
3
3
|
/**
|
|
4
4
|
* Resolves the locations of dependencies and returns the resolve map, logging results
|
|
5
|
-
* to the task reporter.
|
|
5
|
+
* to the task reporter. Throws if dependencies could not be resolved.
|
|
6
6
|
*/
|
|
7
7
|
export async function resolveDependenciesTask(options, context) {
|
|
8
8
|
const { appPath, additionalPaths, linkedPaths } = options;
|
|
@@ -28,9 +28,10 @@ export async function resolveDependenciesTask(options, context) {
|
|
|
28
28
|
task.complete({
|
|
29
29
|
status: 'fail',
|
|
30
30
|
message: 'Failed to resolve dependencies',
|
|
31
|
+
errors: [String(err)],
|
|
31
32
|
forceShow: true,
|
|
32
33
|
// Don't use the message as "details" because this will cause the message to be logged twice
|
|
33
|
-
extended: err.stack
|
|
34
|
+
extended: err.stack,
|
|
34
35
|
});
|
|
35
36
|
if (err instanceof Error) {
|
|
36
37
|
// Remove the call stack because we already logged it in the extended details of the task
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveDependenciesTask.js","sourceRoot":"","sources":["../../src/utilities/resolveDependenciesTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAqB,MAAM,6BAA6B,CAAC;AAElG;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,OAIC,EACD,OAAsE;IAEtE,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAC1D,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACvC,IAAI,UAAkC,CAAC;IAEvC,2CAA2C;IAC3C,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAExD,IAAI,CAAC;QACH,UAAU,GAAG,MAAM,gBAAgB,CACjC;YACE,OAAO;YACP,eAAe;YACf,WAAW;SACZ,EACD;YACE,QAAQ;SACT,CACF,CAAC;QAEF,MAAM,EAAE,WAAW,EAAE,kBAAkB,EAAE,GAAG,yBAAyB,CAAC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,CAAC;YACxB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO;QACL,WAAW;QACX,kBAAkB;KACnB,CAAC;AACJ,CAAC","sourcesContent":["import type { PackageDefinitionsCache } from '@ms-cloudpack/common-types';\nimport type { LinkedPath, ResolveMap, ResolveMapEntry } from '@ms-cloudpack/package-utilities';\nimport { createResolveMap } from '@ms-cloudpack/package-utilities';\nimport { bold, bulletedList, cyan, yellow, type TaskReporter } from '@ms-cloudpack/task-reporter';\n\n/**\n * Resolves the locations of dependencies and returns the resolve map, logging results\n * to the task reporter. Throws if dependencies could not be resolved.\n */\nexport async function resolveDependenciesTask(\n options: {\n appPath: string;\n additionalPaths?: string[];\n linkedPaths?: LinkedPath[];\n },\n context: { reporter: TaskReporter; packages: PackageDefinitionsCache },\n): Promise<ResolveMap> {\n const { appPath, additionalPaths, linkedPaths } = options;\n const { reporter, packages } = context;\n let resolveMap: ResolveMap | undefined;\n\n // Grab the installed dependency locations.\n const task = reporter.addTask('Resolving dependencies');\n\n try {\n resolveMap = await createResolveMap(\n {\n appPath,\n additionalPaths,\n linkedPaths,\n },\n {\n packages,\n },\n );\n\n const { allPackages, duplicatedPackages } = getPackagesFromResolveMap(resolveMap);\n const message = `Found ${cyan(allPackages.size)} total packages, ${\n duplicatedPackages.size ? `${yellow(duplicatedPackages.size)} with multiple versions.` : `no duplicates.`\n }`;\n const extended = bulletedList(\n Array.from(duplicatedPackages.entries()).map(\n ([name, versions]) => `${bold(name)}: ${Array.from(versions).join(', ')}`,\n ),\n );\n\n task.complete({ message, extended, forceShow: true });\n\n return resolveMap;\n } catch (err) {\n task.complete({\n status: 'fail',\n message: 'Failed to resolve dependencies',\n errors: [String(err)],\n forceShow: true,\n // Don't use the message as \"details\" because this will cause the message to be logged twice\n extended: (err as Error).stack,\n });\n\n if (err instanceof Error) {\n // Remove the call stack because we already logged it in the extended details of the task\n err.stack = undefined;\n }\n\n throw err;\n }\n}\n\n/**\n * Given a resolveMap, returns a map of all packages and a map of packages with multiple versions.\n * This is used to log the results of the resolve task.\n */\nfunction getPackagesFromResolveMap(resolveMap: ResolveMap) {\n const allPackages = new Map<string, ResolveMapEntry>();\n const duplicatedPackages = new Map<string, Set<string>>();\n\n function addEntry(entry: ResolveMapEntry) {\n const existingEntry = allPackages.get(entry.name);\n if (existingEntry) {\n let dupeSet = duplicatedPackages.get(entry.name);\n if (!dupeSet) {\n dupeSet = new Set([existingEntry.version]);\n duplicatedPackages.set(entry.name, dupeSet);\n }\n dupeSet.add(entry.version);\n } else {\n allPackages.set(entry.name, entry);\n }\n }\n\n for (const currentEntry of Object.values(resolveMap)) {\n addEntry(currentEntry);\n\n if (currentEntry.scopedVersions) {\n for (const scopedEntry of Object.values(currentEntry.scopedVersions)) {\n addEntry(scopedEntry);\n }\n }\n }\n\n return {\n allPackages,\n duplicatedPackages,\n };\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { parseRequestUrl } from '@ms-cloudpack/import-map';
|
|
2
|
+
import { findFileInPackage, findResolveMapEntry } from '@ms-cloudpack/package-utilities';
|
|
3
3
|
/**
|
|
4
4
|
* Given a package name, import path, and optional issuerUrl, returns a boolean indicating if the given
|
|
5
5
|
* override is valid.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateOverride.js","sourceRoot":"","sources":["../../src/utilities/validateOverride.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validateOverride.js","sourceRoot":"","sources":["../../src/utilities/validateOverride.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAIzF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAAwB,EACxB,OAA8C;IAE9C,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IACvD,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACtC,IAAI,UAAU,GAA4B,SAAS,CAAC;IAEpD,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;QAClE,UAAU,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IACjC,CAAC;IAED,MAAM,KAAK,GAAG,mBAAmB,CAAC;QAChC,WAAW;QACX,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,UAAU;KACX,CAAC,CAAC;IAEH,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,iBAAiB,CAC1C;QACE,WAAW,EAAE,KAAK,CAAC,IAAI;QACvB,QAAQ,EAAE,UAAU;KACrB,EACD,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CACrC,CAAC;IAEF,OAAO,CAAC,CAAC,QAAQ,CAAC;AACpB,CAAC","sourcesContent":["import type { PackageJson } from '@ms-cloudpack/common-types';\nimport { parseRequestUrl } from '@ms-cloudpack/import-map';\nimport { findFileInPackage, findResolveMapEntry } from '@ms-cloudpack/package-utilities';\nimport type { Context } from '../types/Context.js';\nimport type { OverrideOptions } from '../types/OverrideOptions.js';\n\n/**\n * Given a package name, import path, and optional issuerUrl, returns a boolean indicating if the given\n * override is valid.\n */\nexport async function validateOverride(\n options: OverrideOptions,\n context: Pick<Context, 'session' | 'packages'>,\n): Promise<boolean> {\n const { packageName, importPath, issuerUrl } = options;\n const { session, packages } = context;\n let definition: PackageJson | undefined = undefined;\n\n if (issuerUrl) {\n const { packageName: name, version } = parseRequestUrl(issuerUrl);\n definition = { name, version };\n }\n\n const entry = findResolveMapEntry({\n packageName,\n resolveMap: session.resolveMap,\n definition,\n });\n\n if (!entry) {\n return false;\n }\n\n const { filePath } = await findFileInPackage(\n {\n packagePath: entry.path,\n filePath: importPath,\n },\n { packages, config: session.config },\n );\n\n return !!filePath;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/api-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.0",
|
|
4
4
|
"description": "An implementation of the API server that does interacts with a task scheduler.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -27,20 +27,20 @@
|
|
|
27
27
|
"@lage-run/logger": "^1.3.0",
|
|
28
28
|
"@lage-run/scheduler": "^1.1.9",
|
|
29
29
|
"@lage-run/target-graph": "^0.8.9",
|
|
30
|
-
"@ms-cloudpack/bundler": "^0.20.
|
|
31
|
-
"@ms-cloudpack/common-types": "^0.
|
|
32
|
-
"@ms-cloudpack/config": "^0.20.
|
|
33
|
-
"@ms-cloudpack/create-express-app": "^1.6.
|
|
30
|
+
"@ms-cloudpack/bundler": "^0.20.5",
|
|
31
|
+
"@ms-cloudpack/common-types": "^0.5.0",
|
|
32
|
+
"@ms-cloudpack/config": "^0.20.2",
|
|
33
|
+
"@ms-cloudpack/create-express-app": "^1.6.9",
|
|
34
34
|
"@ms-cloudpack/data-bus": "^0.4.2",
|
|
35
35
|
"@ms-cloudpack/file-watcher": "^0.1.2",
|
|
36
|
-
"@ms-cloudpack/import-map": "^0.3.
|
|
36
|
+
"@ms-cloudpack/import-map": "^0.3.3",
|
|
37
37
|
"@ms-cloudpack/json-utilities": "^0.1.4",
|
|
38
|
-
"@ms-cloudpack/package-hashes": "^0.5.
|
|
39
|
-
"@ms-cloudpack/package-utilities": "^7.
|
|
38
|
+
"@ms-cloudpack/package-hashes": "^0.5.13",
|
|
39
|
+
"@ms-cloudpack/package-utilities": "^7.4.1",
|
|
40
40
|
"@ms-cloudpack/path-string-parsing": "^1.2.1",
|
|
41
|
-
"@ms-cloudpack/path-utilities": "^2.7.
|
|
42
|
-
"@ms-cloudpack/remote-cache": "^0.7.
|
|
43
|
-
"@ms-cloudpack/task-reporter": "^0.
|
|
41
|
+
"@ms-cloudpack/path-utilities": "^2.7.6",
|
|
42
|
+
"@ms-cloudpack/remote-cache": "^0.7.2",
|
|
43
|
+
"@ms-cloudpack/task-reporter": "^0.14.0",
|
|
44
44
|
"@ms-cloudpack/telemetry": "^0.5.1",
|
|
45
45
|
"@trpc/client": "^10.45.0",
|
|
46
46
|
"@trpc/server": "^10.45.0",
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parse a request for package file from the bundle server, such as
|
|
3
|
-
* `/@scope/package@version/v3.2/bundled/path/to/file.js`
|
|
4
|
-
*
|
|
5
|
-
* Segments:
|
|
6
|
-
* - Package name (and optionally `@version`)
|
|
7
|
-
* - Optional refresh version `v#.#`
|
|
8
|
-
* - Optional type `bundled` or `unbundled` (defaults to unbundled)
|
|
9
|
-
* - Optional property `missing` (defaults to false)
|
|
10
|
-
* - Optional file path with leading slash (empty if no path)
|
|
11
|
-
*
|
|
12
|
-
* @param requestPath Pathname (server-relative URL) of the requested file.
|
|
13
|
-
* @returns Info about the requested file. If `requestPath` doesn't follow the expected format,
|
|
14
|
-
* the object will contain empty strings.
|
|
15
|
-
*/
|
|
16
|
-
export declare function parseRequestInfo(requestPath: string): {
|
|
17
|
-
/** Package name (empty string if invalid request) */
|
|
18
|
-
packageName: string;
|
|
19
|
-
/** Optional package version (default: empty string) */
|
|
20
|
-
version: string;
|
|
21
|
-
/** Optional hash (default: empty string) */
|
|
22
|
-
hash: string;
|
|
23
|
-
/** Whether the bundled version is requested (default: false) */
|
|
24
|
-
bundled: boolean;
|
|
25
|
-
/** Optional file path (default: empty string) */
|
|
26
|
-
filePath: string;
|
|
27
|
-
/** Whether the file is missing (default: false) */
|
|
28
|
-
missing: boolean;
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=parseRequestInfo.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parseRequestInfo.d.ts","sourceRoot":"","sources":["../../src/utilities/parseRequestInfo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG;IACrD,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,uDAAuD;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,OAAO,EAAE,OAAO,CAAC;IACjB,iDAAiD;IACjD,QAAQ,EAAE,MAAM,CAAC;IACjB,mDAAmD;IACnD,OAAO,EAAE,OAAO,CAAC;CAClB,CAoBA"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parse a request for package file from the bundle server, such as
|
|
3
|
-
* `/@scope/package@version/v3.2/bundled/path/to/file.js`
|
|
4
|
-
*
|
|
5
|
-
* Segments:
|
|
6
|
-
* - Package name (and optionally `@version`)
|
|
7
|
-
* - Optional refresh version `v#.#`
|
|
8
|
-
* - Optional type `bundled` or `unbundled` (defaults to unbundled)
|
|
9
|
-
* - Optional property `missing` (defaults to false)
|
|
10
|
-
* - Optional file path with leading slash (empty if no path)
|
|
11
|
-
*
|
|
12
|
-
* @param requestPath Pathname (server-relative URL) of the requested file.
|
|
13
|
-
* @returns Info about the requested file. If `requestPath` doesn't follow the expected format,
|
|
14
|
-
* the object will contain empty strings.
|
|
15
|
-
*/
|
|
16
|
-
export function parseRequestInfo(requestPath) {
|
|
17
|
-
// This is a hot path, and the following things appear to make the regex faster:
|
|
18
|
-
// - /(?:Non-capturing groups)/ where capturing isn't needed
|
|
19
|
-
// - /(Indexed capturing groups)/ instead of /(?<namedGroups>...)/
|
|
20
|
-
// - For character classes containing - , putting the - at the beginning
|
|
21
|
-
// - Anchoring to the beginning of the string with ^
|
|
22
|
-
const matches = requestPath.match(
|
|
23
|
-
// 1 package name 2 hash 3 version refresh 4 bundled or missing 4 file path end or query
|
|
24
|
-
/^\/?((?:@[-\w.]+\/)?[-\w.]+)(?:@([-\w.]+))?(?:\/h-([-0-9a-z.]+))?(?:\/v[\d.]+)?(?:\/(bundled|unbundled|missing))?(\/[-@\w.+/]+)?(?:\?|$)/) || [];
|
|
25
|
-
return {
|
|
26
|
-
packageName: matches[1] || '',
|
|
27
|
-
version: matches[2] || '',
|
|
28
|
-
hash: matches[3] || '',
|
|
29
|
-
bundled: matches[4] === 'bundled',
|
|
30
|
-
filePath: matches[5] || '',
|
|
31
|
-
missing: matches[4] === 'missing',
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=parseRequestInfo.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parseRequestInfo.js","sourceRoot":"","sources":["../../src/utilities/parseRequestInfo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,gBAAgB,CAAC,WAAmB;IAclD,gFAAgF;IAChF,4DAA4D;IAC5D,kEAAkE;IAClE,wEAAwE;IACxE,oDAAoD;IACpD,MAAM,OAAO,GACX,WAAW,CAAC,KAAK;IACf,wIAAwI;IACxI,0IAA0I,CAC3I,IAAI,EAAE,CAAC;IAEV,OAAO;QACL,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE;QAC7B,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE;QACzB,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE;QACtB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,SAAS;QACjC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE;QAC1B,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,SAAS;KAClC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Parse a request for package file from the bundle server, such as\n * `/@scope/package@version/v3.2/bundled/path/to/file.js`\n *\n * Segments:\n * - Package name (and optionally `@version`)\n * - Optional refresh version `v#.#`\n * - Optional type `bundled` or `unbundled` (defaults to unbundled)\n * - Optional property `missing` (defaults to false)\n * - Optional file path with leading slash (empty if no path)\n *\n * @param requestPath Pathname (server-relative URL) of the requested file.\n * @returns Info about the requested file. If `requestPath` doesn't follow the expected format,\n * the object will contain empty strings.\n */\nexport function parseRequestInfo(requestPath: string): {\n /** Package name (empty string if invalid request) */\n packageName: string;\n /** Optional package version (default: empty string) */\n version: string;\n /** Optional hash (default: empty string) */\n hash: string;\n /** Whether the bundled version is requested (default: false) */\n bundled: boolean;\n /** Optional file path (default: empty string) */\n filePath: string;\n /** Whether the file is missing (default: false) */\n missing: boolean;\n} {\n // This is a hot path, and the following things appear to make the regex faster:\n // - /(?:Non-capturing groups)/ where capturing isn't needed\n // - /(Indexed capturing groups)/ instead of /(?<namedGroups>...)/\n // - For character classes containing - , putting the - at the beginning\n // - Anchoring to the beginning of the string with ^\n const matches =\n requestPath.match(\n // 1 package name 2 hash 3 version refresh 4 bundled or missing 4 file path end or query\n /^\\/?((?:@[-\\w.]+\\/)?[-\\w.]+)(?:@([-\\w.]+))?(?:\\/h-([-0-9a-z.]+))?(?:\\/v[\\d.]+)?(?:\\/(bundled|unbundled|missing))?(\\/[-@\\w.+/]+)?(?:\\?|$)/,\n ) || [];\n\n return {\n packageName: matches[1] || '',\n version: matches[2] || '',\n hash: matches[3] || '',\n bundled: matches[4] === 'bundled',\n filePath: matches[5] || '',\n missing: matches[4] === 'missing',\n };\n}\n"]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { parseRequestInfo } from './parseRequestInfo.js';
|
|
2
|
-
/**
|
|
3
|
-
* Parse a complete package file request URL, such as
|
|
4
|
-
* `http://localhost/@scope/package@version/v3.2/bundled/path/to/file.js`.
|
|
5
|
-
* See `parseRequestInfo` for more details.
|
|
6
|
-
*
|
|
7
|
-
* Throws an error if `requestUrl` is not a syntactically valid complete URL.
|
|
8
|
-
*
|
|
9
|
-
* @param requestUrl Full URL of the requested file.
|
|
10
|
-
* @returns Info about the requested file. If `requestUrl` doesn't follow the expected format,
|
|
11
|
-
* the object will contain empty strings.
|
|
12
|
-
*/
|
|
13
|
-
export declare function parseRequestUrl(requestUrl: string): ReturnType<typeof parseRequestInfo>;
|
|
14
|
-
//# sourceMappingURL=parseRequestUrl.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parseRequestUrl.d.ts","sourceRoot":"","sources":["../../src/utilities/parseRequestUrl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAUvF"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { parseRequestInfo } from './parseRequestInfo.js';
|
|
2
|
-
/**
|
|
3
|
-
* Parse a complete package file request URL, such as
|
|
4
|
-
* `http://localhost/@scope/package@version/v3.2/bundled/path/to/file.js`.
|
|
5
|
-
* See `parseRequestInfo` for more details.
|
|
6
|
-
*
|
|
7
|
-
* Throws an error if `requestUrl` is not a syntactically valid complete URL.
|
|
8
|
-
*
|
|
9
|
-
* @param requestUrl Full URL of the requested file.
|
|
10
|
-
* @returns Info about the requested file. If `requestUrl` doesn't follow the expected format,
|
|
11
|
-
* the object will contain empty strings.
|
|
12
|
-
*/
|
|
13
|
-
export function parseRequestUrl(requestUrl) {
|
|
14
|
-
let pathname;
|
|
15
|
-
try {
|
|
16
|
-
pathname = new URL(requestUrl).pathname;
|
|
17
|
-
}
|
|
18
|
-
catch (err) {
|
|
19
|
-
// The error for URL parsing failure doesn't include the string, so throw a more helpful error.
|
|
20
|
-
throw new Error(`Invalid URL: ${requestUrl}`);
|
|
21
|
-
}
|
|
22
|
-
return parseRequestInfo(pathname);
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=parseRequestUrl.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parseRequestUrl.js","sourceRoot":"","sources":["../../src/utilities/parseRequestUrl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAAC,UAAkB;IAChD,IAAI,QAAgB,CAAC;IACrB,IAAI,CAAC;QACH,QAAQ,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC;IAC1C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,+FAA+F;QAC/F,MAAM,IAAI,KAAK,CAAC,gBAAgB,UAAU,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,gBAAgB,CAAC,QAAQ,CAAC,CAAC;AACpC,CAAC","sourcesContent":["import { parseRequestInfo } from './parseRequestInfo.js';\n\n/**\n * Parse a complete package file request URL, such as\n * `http://localhost/@scope/package@version/v3.2/bundled/path/to/file.js`.\n * See `parseRequestInfo` for more details.\n *\n * Throws an error if `requestUrl` is not a syntactically valid complete URL.\n *\n * @param requestUrl Full URL of the requested file.\n * @returns Info about the requested file. If `requestUrl` doesn't follow the expected format,\n * the object will contain empty strings.\n */\nexport function parseRequestUrl(requestUrl: string): ReturnType<typeof parseRequestInfo> {\n let pathname: string;\n try {\n pathname = new URL(requestUrl).pathname;\n } catch (err) {\n // The error for URL parsing failure doesn't include the string, so throw a more helpful error.\n throw new Error(`Invalid URL: ${requestUrl}`);\n }\n\n return parseRequestInfo(pathname);\n}\n"]}
|