@microsoft/managed-apps-dev-gateway 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +187 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/resources/DevelopmentMiddleware.d.ts +20 -0
- package/dist/resources/DevelopmentMiddleware.d.ts.map +1 -0
- package/dist/resources/DevelopmentMiddleware.js +117 -0
- package/dist/resources/DevelopmentMiddleware.js.map +1 -0
- package/dist/resources/PackagedResources.d.ts +10 -0
- package/dist/resources/PackagedResources.d.ts.map +1 -0
- package/dist/resources/PackagedResources.js +14 -0
- package/dist/resources/PackagedResources.js.map +1 -0
- package/dist/resources/appScript.js +69 -0
- package/dist/resources/loader.html +98 -0
- package/dist/resources/localDevWorker.js +68 -0
- package/dist/snapshot/OobRevision.d.ts +38 -0
- package/dist/snapshot/OobRevision.d.ts.map +1 -0
- package/dist/snapshot/OobRevision.js +40 -0
- package/dist/snapshot/OobRevision.js.map +1 -0
- package/dist/snapshot/PathPolicy.d.ts +69 -0
- package/dist/snapshot/PathPolicy.d.ts.map +1 -0
- package/dist/snapshot/PathPolicy.js +129 -0
- package/dist/snapshot/PathPolicy.js.map +1 -0
- package/dist/snapshot/SnapshotReader.d.ts +63 -0
- package/dist/snapshot/SnapshotReader.d.ts.map +1 -0
- package/dist/snapshot/SnapshotReader.js +182 -0
- package/dist/snapshot/SnapshotReader.js.map +1 -0
- package/dist/snapshot/SnapshotSource.d.ts +49 -0
- package/dist/snapshot/SnapshotSource.d.ts.map +1 -0
- package/dist/snapshot/SnapshotSource.js +81 -0
- package/dist/snapshot/SnapshotSource.js.map +1 -0
- package/dist/snapshot/index.d.ts +9 -0
- package/dist/snapshot/index.d.ts.map +1 -0
- package/dist/snapshot/index.js +8 -0
- package/dist/snapshot/index.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { validateDevelopmentSnapshotUpdate } from '@microsoft/managed-apps-common/gateway';
|
|
5
|
+
import { readDevelopmentSnapshotAsync } from './SnapshotReader.js';
|
|
6
|
+
/**
|
|
7
|
+
* Holds the last snapshot that read and validated cleanly, and mints the combined
|
|
8
|
+
* revision for one bootstrap lifetime.
|
|
9
|
+
*
|
|
10
|
+
* A failed refresh leaves the previous snapshot installed and rethrows, so invalid
|
|
11
|
+
* input can never downgrade a working session to an empty manifest. This is state
|
|
12
|
+
* for a caller that decides *when* to refresh; it is not a watcher, debouncer or
|
|
13
|
+
* session coordinator, and it performs no HTTP work.
|
|
14
|
+
*/
|
|
15
|
+
export class DevelopmentSnapshotSource {
|
|
16
|
+
projectRoot;
|
|
17
|
+
revision = 0;
|
|
18
|
+
current;
|
|
19
|
+
/**
|
|
20
|
+
* Tail of the serialized refresh queue. Refreshes must not interleave: the
|
|
21
|
+
* combined revision is allocated from `this.revision`, and an `await` between
|
|
22
|
+
* allocation and installation would let two overlapping refreshes both mint
|
|
23
|
+
* `N + 1` and hand back distinct snapshots carrying the same revision. Each
|
|
24
|
+
* caller installs a fulfilled gate before awaiting the previous one, preserving
|
|
25
|
+
* FIFO order without letting a failed refresh poison the callers behind it.
|
|
26
|
+
*/
|
|
27
|
+
pending = Promise.resolve();
|
|
28
|
+
constructor(projectRoot) {
|
|
29
|
+
this.projectRoot = projectRoot;
|
|
30
|
+
}
|
|
31
|
+
/** The last successful read, or `undefined` before the first one. */
|
|
32
|
+
get snapshot() {
|
|
33
|
+
return this.current?.snapshot;
|
|
34
|
+
}
|
|
35
|
+
/** Init bytes matching {@link snapshot}, retained for exact-body retries. */
|
|
36
|
+
get initBody() {
|
|
37
|
+
return this.current?.initBody;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Re-read the project. On success the new snapshot is installed and classified
|
|
41
|
+
* relative to the previous one, so a caller can tell a connector-only metadata
|
|
42
|
+
* update from an OOB or identity change. On failure the previous snapshot stays
|
|
43
|
+
* installed and the error propagates.
|
|
44
|
+
*
|
|
45
|
+
* Concurrent calls are serialized, not coalesced: every call performs its own
|
|
46
|
+
* read, in call order, and observes the state left by the one before it.
|
|
47
|
+
*/
|
|
48
|
+
async refreshAsync() {
|
|
49
|
+
const previous = this.pending;
|
|
50
|
+
let release = () => undefined;
|
|
51
|
+
this.pending = new Promise((resolve) => {
|
|
52
|
+
release = resolve;
|
|
53
|
+
});
|
|
54
|
+
await previous;
|
|
55
|
+
try {
|
|
56
|
+
return await this.readAndInstallAsync();
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
release();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async readAndInstallAsync() {
|
|
63
|
+
const previous = this.current;
|
|
64
|
+
const read = await readDevelopmentSnapshotAsync({
|
|
65
|
+
projectRoot: this.projectRoot,
|
|
66
|
+
revision: this.revision + 1,
|
|
67
|
+
});
|
|
68
|
+
if (previous && read.snapshot.oob.revision === previous.snapshot.oob.revision) {
|
|
69
|
+
// Nothing the consumers care about changed; keep the installed revision so
|
|
70
|
+
// an idle poll cannot exhaust the safe-integer revision space.
|
|
71
|
+
if (JSON.stringify(read.snapshot.hostConfig) === JSON.stringify(previous.snapshot.hostConfig)) {
|
|
72
|
+
return { read: previous, change: 'metadata' };
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const { change } = validateDevelopmentSnapshotUpdate(read.snapshot, previous?.snapshot);
|
|
76
|
+
this.revision = read.snapshot.revision;
|
|
77
|
+
this.current = read;
|
|
78
|
+
return { read, change };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=SnapshotSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SnapshotSource.js","sourceRoot":"","sources":["../../src/snapshot/SnapshotSource.ts"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C;SAC5B,CAAC,CAAC;QAEH,IAAI,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;YAC9E,2EAA2E;YAC3E,+DAA+D;YAC/D,IACE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,EACzF,CAAC;gBACD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;YAChD,CAAC;QACH,CAAC;QAED,MAAM,EAAE,MAAM,EAAE,GAAG,iCAAiC,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACxF,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
export { canonicalJson, computeOobRevision } from './OobRevision.js';
|
|
5
|
+
export { assertRealPathContainedAsync, canonicalizeRootAsync, resolveSchemaPathAsync, SnapshotReadError, SnapshotReadErrorCode, } from './PathPolicy.js';
|
|
6
|
+
export type { DevelopmentSnapshotRead, ReadDevelopmentSnapshotOptions } from './SnapshotReader.js';
|
|
7
|
+
export { readDevelopmentSnapshotAsync } from './SnapshotReader.js';
|
|
8
|
+
export { DevelopmentSnapshotSource } from './SnapshotSource.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/snapshot/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EACL,4BAA4B,EAC5B,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,uBAAuB,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAAC;AAChG,OAAO,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
export { canonicalJson, computeOobRevision } from './OobRevision.js';
|
|
5
|
+
export { assertRealPathContainedAsync, canonicalizeRootAsync, resolveSchemaPathAsync, SnapshotReadError, SnapshotReadErrorCode, } from './PathPolicy.js';
|
|
6
|
+
export { readDevelopmentSnapshotAsync } from './SnapshotReader.js';
|
|
7
|
+
export { DevelopmentSnapshotSource } from './SnapshotSource.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/snapshot/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EACL,4BAA4B,EAC5B,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@microsoft/managed-apps-dev-gateway",
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Local development bootstrap resources for Microsoft Managed Apps",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./snapshot": {
|
|
15
|
+
"types": "./dist/snapshot/index.d.ts",
|
|
16
|
+
"default": "./dist/snapshot/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"LICENSE",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsc -p tsconfig.build.json && tsc-esm-fix --target dist && bun scripts/copy-resources.ts",
|
|
26
|
+
"dev": "tsc -p tsconfig.json --watch",
|
|
27
|
+
"check-types": "tsc --noEmit",
|
|
28
|
+
"lint": "eslint src/",
|
|
29
|
+
"test": "bun test --isolate src/",
|
|
30
|
+
"clean": "bun ../../scripts/clean.ts dist .turbo tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@microsoft/managed-apps-common": "0.25.0",
|
|
34
|
+
"zod": "4.4.3"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@microsoft/managed-apps-gateway-client": "0.1.0",
|
|
38
|
+
"@repo/repo-config": "0.0.0",
|
|
39
|
+
"@types/bun": "1.3.13",
|
|
40
|
+
"@types/node": "24.13.1",
|
|
41
|
+
"tsc-esm-fix": "3.1.2",
|
|
42
|
+
"typescript": "5.9.3"
|
|
43
|
+
},
|
|
44
|
+
"keywords": [
|
|
45
|
+
"microsoft-managed-apps",
|
|
46
|
+
"local-development"
|
|
47
|
+
]
|
|
48
|
+
}
|