@mirage-x/mirror 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +2 -2
- package/README.md +2 -2
- package/dist/build.d.ts +8 -1
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +16 -6
- package/dist/build.js.map +1 -1
- package/dist/compareOutput.d.ts +2 -1
- package/dist/compareOutput.d.ts.map +1 -1
- package/dist/compareOutput.js +4 -4
- package/dist/compareOutput.js.map +1 -1
- package/dist/feedback/attachCoreAndFrames.d.ts +13 -0
- package/dist/feedback/attachCoreAndFrames.d.ts.map +1 -1
- package/dist/feedback/attachCoreAndFrames.js +36 -17
- package/dist/feedback/attachCoreAndFrames.js.map +1 -1
- package/dist/feedback/index.d.ts +2 -2
- package/dist/feedback/index.d.ts.map +1 -1
- package/dist/feedback/index.js +1 -1
- package/dist/feedback/index.js.map +1 -1
- package/dist/feedback/sanitize.d.ts +8 -3
- package/dist/feedback/sanitize.d.ts.map +1 -1
- package/dist/feedback/sanitize.js +98 -14
- package/dist/feedback/sanitize.js.map +1 -1
- package/dist/frame/env.d.ts +25 -0
- package/dist/frame/env.d.ts.map +1 -0
- package/dist/frame/env.js +38 -0
- package/dist/frame/env.js.map +1 -0
- package/dist/frame/fromFeedback.d.ts +8 -0
- package/dist/frame/fromFeedback.d.ts.map +1 -0
- package/dist/frame/fromFeedback.js +13 -0
- package/dist/frame/fromFeedback.js.map +1 -0
- package/dist/frame/installFrame/index.d.ts +14 -2
- package/dist/frame/installFrame/index.d.ts.map +1 -1
- package/dist/frame/installFrame/index.js +15 -5
- package/dist/frame/installFrame/index.js.map +1 -1
- package/dist/frame/placeCore.d.ts +12 -2
- package/dist/frame/placeCore.d.ts.map +1 -1
- package/dist/frame/placeCore.js +13 -3
- package/dist/frame/placeCore.js.map +1 -1
- package/dist/frame/simpleFrame/index.d.ts +15 -1
- package/dist/frame/simpleFrame/index.d.ts.map +1 -1
- package/dist/frame/simpleFrame/index.js +16 -4
- package/dist/frame/simpleFrame/index.js.map +1 -1
- package/dist/frdt/util.d.ts +2 -0
- package/dist/frdt/util.d.ts.map +1 -1
- package/dist/frdt/util.js +5 -0
- package/dist/frdt/util.js.map +1 -1
- package/dist/frdt/versions.d.ts +41 -10
- package/dist/frdt/versions.d.ts.map +1 -1
- package/dist/frdt/versions.js +106 -10
- package/dist/frdt/versions.js.map +1 -1
- package/dist/generateClient.d.ts +10 -1
- package/dist/generateClient.d.ts.map +1 -1
- package/dist/generateClient.js +12 -12
- package/dist/generateClient.js.map +1 -1
- package/dist/index.d.ts +7 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.ja.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
- `build()`: Unit の Resonite 側のテンプレートと、MirageX の core、frame をまとめて、Resonite に置くオブジェクト `output.brson` を作ります
|
|
8
8
|
- `generateMirrorUnitFromFeedback`: Unit のテンプレートを作ります。feedback(`ResFeedback.brson`)があればそれを使います
|
|
9
9
|
- feedback: `fetchFeedback` と `attachUnits` で、Resonite で作り込んだ Unit をプロジェクトに取り込みます
|
|
10
|
-
- 同梱の core と frame(`generateSimpleFrame`、`generateInstallFrame`)
|
|
10
|
+
- 同梱の core と frame(`generateSimpleFrame`、`generateInstallFrame`)と、独自の frame の feedback から作る frame(`generateSimpleFrameFromFeedback`、`generateInstallFrameFromFeedback`、`placeCore`)
|
|
11
11
|
|
|
12
12
|
文書の読み書きには [`@frdt/frdt`](https://www.npmjs.com/package/@frdt/frdt) を使っています。`@mirage-x/server` には依存しないので、ビルドする環境にサーバーの依存は要りません。
|
|
13
13
|
|
|
@@ -17,7 +17,7 @@ MirageX は 3 つのパッケージで公開していて、一緒に使います
|
|
|
17
17
|
npm install @mirage-x/core @mirage-x/server @mirage-x/mirror react@19
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
Node.js 22 以上、ESM のみです。3 つのパッケージはバージョンを揃えてください。
|
|
20
|
+
Node.js 22.13 以上、ESM のみです。3 つのパッケージはバージョンを揃えてください。
|
|
21
21
|
|
|
22
22
|
## ライセンス
|
|
23
23
|
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ The build-time part of [MirageX](https://github.com/rheniumNV/mirage-x#readme),
|
|
|
7
7
|
- `build()`: assembles your Units' Resonite templates, the MirageX core and a frame into `output.brson`, the object you place in Resonite
|
|
8
8
|
- `generateMirrorUnitFromFeedback`: a Unit's template, from its feedback (`ResFeedback.brson`) when there is one
|
|
9
9
|
- Feedback: `fetchFeedback` and `attachUnits` pull the Units you shaped in Resonite back into your project
|
|
10
|
-
- The bundled core and frames (`generateSimpleFrame`, `generateInstallFrame`)
|
|
10
|
+
- The bundled core and frames (`generateSimpleFrame`, `generateInstallFrame`), and your own frames from their feedback (`generateSimpleFrameFromFeedback`, `generateInstallFrameFromFeedback`, `placeCore`)
|
|
11
11
|
|
|
12
12
|
Documents are read and written with [`@frdt/frdt`](https://www.npmjs.com/package/@frdt/frdt). It does not depend on `@mirage-x/server`, so a build environment does not need the server's dependencies.
|
|
13
13
|
|
|
@@ -17,7 +17,7 @@ MirageX is published as three packages, used together: [`@mirage-x/core`](https:
|
|
|
17
17
|
npm install @mirage-x/core @mirage-x/server @mirage-x/mirror react@19
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
Node.js 22 or later, ESM only. Keep the three packages at the same version.
|
|
20
|
+
Node.js 22.13 or later, ESM only. Keep the three packages at the same version.
|
|
21
21
|
|
|
22
22
|
## License
|
|
23
23
|
|
package/dist/build.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { VersionSource } from "./frdt/versions.js";
|
|
1
2
|
import { type GenerateFrame, type MirrorUnits } from "./generateClient.js";
|
|
2
|
-
export
|
|
3
|
+
export { VERSION_VARIABLE } from "./frame/env.js";
|
|
3
4
|
export type BuildConfig = {
|
|
4
5
|
appCode: string;
|
|
5
6
|
cv: {
|
|
@@ -23,6 +24,12 @@ export type BuildConfig = {
|
|
|
23
24
|
};
|
|
24
25
|
resetOnSave?: boolean;
|
|
25
26
|
developCode?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Where the output's `VersionNumber` and `FeatureFlags` come from.
|
|
29
|
+
* `"oldest"` (default): the oldest of the core's, the frame's and the
|
|
30
|
+
* Units', with the flags all of them have. `"frame"`: the frame's.
|
|
31
|
+
*/
|
|
32
|
+
versionSource?: VersionSource;
|
|
26
33
|
};
|
|
27
34
|
export type BuildResult = {
|
|
28
35
|
/** false when the output is the same as the previous build. */
|
package/dist/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,WAAW,EACjB,MAAM,qBAAqB,CAAC;AAI7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE;QACF,MAAM,EAAE;YACN,IAAI,EAAE;gBACJ,IAAI,EAAE,MAAM,CAAC;gBACb,OAAO,EAAE,MAAM,CAAC;gBAChB,QAAQ,EAAE,MAAM,CAAC;aAClB,CAAC;YACF,MAAM,EAAE;gBACN,IAAI,EAAE,MAAM,CAAC;gBACb,QAAQ,EAAE,OAAO,CAAC;aACnB,CAAC;SACH,CAAC;KACH,CAAC;IACF,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE;QACjB,EAAE,EAAE,MAAM,CAAC;QACX,EAAE,EAAE,MAAM,CAAC;QACX,EAAE,EAAE,MAAM,CAAC;KACZ,CAAC;IACF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,+DAA+D;IAC/D,OAAO,EAAE,OAAO,CAAC;IACjB,sDAAsD;IACtD,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAqBF;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,GAChB,QAAQ,WAAW,EACnB,OAAO,WAAW,EAClB,eAAe,aAAa,KAC3B,OAAO,CAAC,WAAW,CAkErB,CAAC"}
|
package/dist/build.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import {
|
|
3
|
+
import { VERSION_VARIABLE, mirageXEnvSlots, setAppVersion, } from "./frame/env.js";
|
|
4
4
|
import { generateClient, } from "./generateClient.js";
|
|
5
5
|
/** Seed for `renumberIds`, so that the same output writes the same bytes. */
|
|
6
6
|
const ID_SEED = 0;
|
|
7
|
-
export
|
|
7
|
+
export { VERSION_VARIABLE } from "./frame/env.js";
|
|
8
8
|
const readPreviousVersion = (outputPath) => {
|
|
9
9
|
try {
|
|
10
10
|
const version = JSON.parse(fs.readFileSync(path.resolve(outputPath, "version.json"), "utf-8")).version;
|
|
@@ -53,9 +53,17 @@ export const build = async (config, units, generateFrame) => {
|
|
|
53
53
|
resetOnSave: config.resetOnSave ?? true,
|
|
54
54
|
units,
|
|
55
55
|
generateFrame,
|
|
56
|
+
versionSource: config.versionSource,
|
|
56
57
|
});
|
|
57
58
|
output.renumberIds(ID_SEED);
|
|
58
59
|
console.debug("end generating");
|
|
60
|
+
// Checked on every build, so a frame with another layout fails at once,
|
|
61
|
+
// not only when a later build has to update the version.
|
|
62
|
+
const envSlots = mirageXEnvSlots(output).length;
|
|
63
|
+
if (envSlots !== 2) {
|
|
64
|
+
throw new Error(`The output must have MirageX's ENV at DV/ENV and AppRoot/Main/DV/ENV ` +
|
|
65
|
+
`(found ${envSlots}); place the core with placeCore`);
|
|
66
|
+
}
|
|
59
67
|
const previous = readPrevious(outputBrsonPath);
|
|
60
68
|
if (previousVersion && previous?.equals(output.writeBrson())) {
|
|
61
69
|
console.info("no change in output");
|
|
@@ -63,10 +71,12 @@ export const build = async (config, units, generateFrame) => {
|
|
|
63
71
|
}
|
|
64
72
|
if (previousVersion) {
|
|
65
73
|
// Values only; ids and structure stay the same. Only MirageX's ENV
|
|
66
|
-
// slots (frame and core), not variables of the same name in units
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
// slots (frame and core), not variables of the same name in units or in
|
|
75
|
+
// another app's ENV embedded in the frame or a unit.
|
|
76
|
+
const { updated } = setAppVersion(output, newVersion);
|
|
77
|
+
if (updated !== 2) {
|
|
78
|
+
throw new Error(`${VERSION_VARIABLE} not found in MirageX's ENV slots (${updated} ` +
|
|
79
|
+
"of 2 set); the version cannot be updated");
|
|
70
80
|
}
|
|
71
81
|
}
|
|
72
82
|
fs.mkdirSync(config.outputPath, { recursive: true });
|
package/dist/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,aAAa,GACd,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,cAAc,GAGf,MAAM,qBAAqB,CAAC;AAE7B,6EAA6E;AAC7E,MAAM,OAAO,GAAG,C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EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC;IACtD,CAAC;IAED,IAAI,eAAe,EAAE,CAAC;QACpB,mEAAmE;QACnE,wEAAwE;QACxE,qDAAqD;QACrD,MAAM,EAAE,OAAO,EAAE,GAAG,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QACtD,IAAI,OAAO,KAAK,CAAC,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CACb,GAAG,gBAAgB,sCAAsC,OAAO,GAAG;gBACjE,0CAA0C,CAC7C,CAAC;QACJ,CAAC;IACH,CAAC;IAED,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACrD,EAAE,CAAC,aAAa,CAAC,eAAe,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;IACvD,EAAE,CAAC,aAAa,CACd,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,cAAc,CAAC,EAC/C,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CACjD,CAAC;IAEF,OAAO,CAAC,IAAI,CAAC,qBAAqB,UAAU,EAAE,CAAC,CAAC;IAChD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;AAChD,CAAC,CAAC"}
|
package/dist/compareOutput.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Document, type Difference } from "@frdt/frdt";
|
|
2
2
|
/**
|
|
3
3
|
* Compare two `build` outputs by structure and values (frdt `compare`: ids
|
|
4
|
-
* are not compared), ignoring the app version `build` writes into
|
|
4
|
+
* are not compared), ignoring the app version `build` writes into MirageX's
|
|
5
|
+
* ENV slots (the version of another app's ENV embedded in it is compared).
|
|
5
6
|
* An empty result means the outputs are the same apart from that.
|
|
6
7
|
*/
|
|
7
8
|
export declare const compareOutput: (expected: Document, actual: Document) => Difference[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compareOutput.d.ts","sourceRoot":"","sources":["../src/compareOutput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAW,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"compareOutput.d.ts","sourceRoot":"","sources":["../src/compareOutput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAW,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAWhE;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GACxB,UAAU,QAAQ,EAClB,QAAQ,QAAQ,KACf,UAAU,EACoD,CAAC"}
|
package/dist/compareOutput.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Document, compare } from "@frdt/frdt";
|
|
2
|
-
import {
|
|
3
|
-
import { setVariableValues, str } from "./frdt/util.js";
|
|
2
|
+
import { setAppVersion } from "./frame/env.js";
|
|
4
3
|
/** A copy of `doc` with the app version in MirageX's ENV slots cleared. */
|
|
5
4
|
const withoutAppVersion = (doc) => {
|
|
6
5
|
const copy = Document.open(doc.writeBrson());
|
|
7
|
-
|
|
6
|
+
setAppVersion(copy, "");
|
|
8
7
|
return copy;
|
|
9
8
|
};
|
|
10
9
|
/**
|
|
11
10
|
* Compare two `build` outputs by structure and values (frdt `compare`: ids
|
|
12
|
-
* are not compared), ignoring the app version `build` writes into
|
|
11
|
+
* are not compared), ignoring the app version `build` writes into MirageX's
|
|
12
|
+
* ENV slots (the version of another app's ENV embedded in it is compared).
|
|
13
13
|
* An empty result means the outputs are the same apart from that.
|
|
14
14
|
*/
|
|
15
15
|
export const compareOutput = (expected, actual) => compare(withoutAppVersion(expected), withoutAppVersion(actual));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compareOutput.js","sourceRoot":"","sources":["../src/compareOutput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAmB,MAAM,YAAY,CAAC;AAEhE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"compareOutput.js","sourceRoot":"","sources":["../src/compareOutput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAmB,MAAM,YAAY,CAAC;AAEhE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,2EAA2E;AAC3E,MAAM,iBAAiB,GAAG,CAAC,GAAa,EAAY,EAAE;IACpD,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;IAC7C,aAAa,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACxB,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,QAAkB,EAClB,MAAgB,EACF,EAAE,CAChB,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC"}
|
|
@@ -10,6 +10,19 @@ export type AttachFeedbackPaths = {
|
|
|
10
10
|
* (children of `Main/Package`), which are generated by the build.
|
|
11
11
|
*/
|
|
12
12
|
export declare const attachCore: (option: AttachFeedbackPaths) => void;
|
|
13
|
+
export type AttachFrameOptions = AttachFeedbackPaths & {
|
|
14
|
+
/** The frame's `Static.FrameCode` (a feedback with another is skipped). */
|
|
15
|
+
expectedFrameCode: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* A frame: the whole feedback without the core (`AppRoot/Main`) and the
|
|
19
|
+
* environment (`DV/ENV`), written as `ResFeedback.brson` in `outputPath` for
|
|
20
|
+
* `generateSimpleFrameFromFeedback` / `generateInstallFrameFromFeedback`.
|
|
21
|
+
* Skipped with a warning when the feedback is a different frame
|
|
22
|
+
* (`Static.FrameCode`), and then returns `false`; fails without one. (An
|
|
23
|
+
* unchanged frame is not rewritten.)
|
|
24
|
+
*/
|
|
25
|
+
export declare const attachFrame: (option: AttachFrameOptions) => boolean;
|
|
13
26
|
export declare const attachSimpleFrame: (option: AttachFeedbackPaths) => void;
|
|
14
27
|
export declare const attachInstallFrame: (option: AttachFeedbackPaths) => void;
|
|
15
28
|
//# sourceMappingURL=attachCoreAndFrames.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachCoreAndFrames.d.ts","sourceRoot":"","sources":["../../src/feedback/attachCoreAndFrames.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"attachCoreAndFrames.d.ts","sourceRoot":"","sources":["../../src/feedback/attachCoreAndFrames.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,mBAAmB,GAAG;IAChC,4EAA4E;IAC5E,SAAS,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AA6BF;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,mBAAmB,KAAG,IAmBxD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,mBAAmB,GAAG;IACrD,2EAA2E;IAC3E,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,GAAI,QAAQ,kBAAkB,KAAG,OACG,CAAC;AAkC7D,eAAO,MAAM,iBAAiB,GAAI,QAAQ,mBAAmB,KAAG,IAE/D,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,QAAQ,mBAAmB,KAAG,IAKhE,CAAC"}
|
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
import { requireChild, requireReference, stringOf, variableIndex } from "../frdt/util.js";
|
|
2
|
+
import { envUnder } from "../frame/env.js";
|
|
2
3
|
import { extractPart, readStagedFeedback, readStagedMeta, writePart, } from "./staging.js";
|
|
4
|
+
/**
|
|
5
|
+
* MirageX's ENV under `slot` (see `envUnder`); it must be there. Warns when
|
|
6
|
+
* the `DV` holds more than one ENV: the last is taken as MirageX's, which is
|
|
7
|
+
* wrong if another app's ENV was added after it in Resonite.
|
|
8
|
+
*/
|
|
9
|
+
const requireEnv = (slot) => {
|
|
10
|
+
const env = envUnder(slot);
|
|
11
|
+
if (!env) {
|
|
12
|
+
throw new Error(`Slot "DV/ENV" not found under "${slot.name()}"`);
|
|
13
|
+
}
|
|
14
|
+
const envs = requireChild(slot, "DV")
|
|
15
|
+
.children()
|
|
16
|
+
.filter((child) => child.name() === "ENV");
|
|
17
|
+
if (envs.length > 1) {
|
|
18
|
+
console.warn(`"${slot.name()}/DV" has ${envs.length} ENV slots; the last is ` +
|
|
19
|
+
"removed as MirageX's. If another app's ENV was added after it, " +
|
|
20
|
+
"move that ENV before MirageX's in Resonite and save again");
|
|
21
|
+
}
|
|
22
|
+
return env;
|
|
23
|
+
};
|
|
3
24
|
/** The slot the root's `Static.AppRoot` points at. */
|
|
4
25
|
const appRootOf = (doc) => doc.slotById(requireReference(doc.root(), "Static.AppRoot"));
|
|
5
26
|
/**
|
|
@@ -15,7 +36,7 @@ export const attachCore = (option) => {
|
|
|
15
36
|
if (child.id() !== main.id())
|
|
16
37
|
doc.removeSlot(child);
|
|
17
38
|
}
|
|
18
|
-
doc.removeSlot(
|
|
39
|
+
doc.removeSlot(requireEnv(main));
|
|
19
40
|
for (const child of requireChild(main, "Package").children()) {
|
|
20
41
|
doc.removeSlot(child);
|
|
21
42
|
}
|
|
@@ -28,10 +49,15 @@ export const attachCore = (option) => {
|
|
|
28
49
|
};
|
|
29
50
|
/**
|
|
30
51
|
* A frame: the whole feedback without the core (`AppRoot/Main`) and the
|
|
31
|
-
* environment (`DV/ENV`)
|
|
32
|
-
*
|
|
52
|
+
* environment (`DV/ENV`), written as `ResFeedback.brson` in `outputPath` for
|
|
53
|
+
* `generateSimpleFrameFromFeedback` / `generateInstallFrameFromFeedback`.
|
|
54
|
+
* Skipped with a warning when the feedback is a different frame
|
|
55
|
+
* (`Static.FrameCode`), and then returns `false`; fails without one. (An
|
|
56
|
+
* unchanged frame is not rewritten.)
|
|
33
57
|
*/
|
|
34
|
-
const attachFrame = (option) => {
|
|
58
|
+
export const attachFrame = (option) => attachFrameAs(option, `frame ${option.expectedFrameCode}`);
|
|
59
|
+
/** `attachFrame`, naming the frame `label` in the log. */
|
|
60
|
+
const attachFrameAs = (option, label) => {
|
|
35
61
|
const doc = readStagedFeedback(option.inputPath);
|
|
36
62
|
const root = doc.root();
|
|
37
63
|
const frameCodeIndex = variableIndex(root, "Static.FrameCode");
|
|
@@ -43,29 +69,22 @@ const attachFrame = (option) => {
|
|
|
43
69
|
}
|
|
44
70
|
if (frameCode !== option.expectedFrameCode) {
|
|
45
71
|
console.warn(`FrameCode is not ${option.expectedFrameCode}. FrameCode: ${frameCode}`);
|
|
46
|
-
return;
|
|
72
|
+
return false;
|
|
47
73
|
}
|
|
48
74
|
doc.removeSlot(requireChild(appRootOf(doc), "Main"));
|
|
49
|
-
doc.removeSlot(
|
|
75
|
+
doc.removeSlot(requireEnv(root));
|
|
50
76
|
writePart({
|
|
51
77
|
outputDir: option.outputPath,
|
|
52
78
|
part: extractPart(doc, root),
|
|
53
79
|
meta: readStagedMeta(option.inputPath),
|
|
54
|
-
label
|
|
80
|
+
label,
|
|
55
81
|
});
|
|
82
|
+
return true;
|
|
56
83
|
};
|
|
57
84
|
export const attachSimpleFrame = (option) => {
|
|
58
|
-
|
|
59
|
-
...option,
|
|
60
|
-
expectedFrameCode: "Simple",
|
|
61
|
-
label: "simple frame",
|
|
62
|
-
});
|
|
85
|
+
attachFrameAs({ ...option, expectedFrameCode: "Simple" }, "simple frame");
|
|
63
86
|
};
|
|
64
87
|
export const attachInstallFrame = (option) => {
|
|
65
|
-
|
|
66
|
-
...option,
|
|
67
|
-
expectedFrameCode: "InstalledAvatar",
|
|
68
|
-
label: "install frame",
|
|
69
|
-
});
|
|
88
|
+
attachFrameAs({ ...option, expectedFrameCode: "InstalledAvatar" }, "install frame");
|
|
70
89
|
};
|
|
71
90
|
//# sourceMappingURL=attachCoreAndFrames.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachCoreAndFrames.js","sourceRoot":"","sources":["../../src/feedback/attachCoreAndFrames.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC1F,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,cAAc,EACd,SAAS,GACV,MAAM,cAAc,CAAC;AAStB,sDAAsD;AACtD,MAAM,SAAS,GAAG,CAAC,GAAa,EAAE,EAAE,CAClC,GAAG,CAAC,QAAQ,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAE/D;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAA2B,EAAQ,EAAE;IAC9D,MAAM,GAAG,GAAG,kBAAkB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACjD,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;IAC/B,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAE3C,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;QACvC,IAAI,KAAK,CAAC,EAAE,EAAE,KAAK,IAAI,CAAC,EAAE,EAAE;YAAE,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACtD,CAAC;IACD,GAAG,CAAC,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"attachCoreAndFrames.js","sourceRoot":"","sources":["../../src/feedback/attachCoreAndFrames.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC1F,OAAO,EAAE,QAAQ,E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QACf,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAChD,CAAC;IACD,IAAI,SAAS,KAAK,MAAM,CAAC,iBAAiB,EAAE,CAAC;QAC3C,OAAO,CAAC,IAAI,CACV,oBAAoB,MAAM,CAAC,iBAAiB,gBAAgB,SAAS,EAAE,CACxE,CAAC;QACF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACrD,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IAEjC,SAAS,CAAC;QACR,SAAS,EAAE,MAAM,CAAC,UAAU;QAC5B,IAAI,EAAE,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC;QAC5B,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC,SAAS,CAAC;QACtC,KAAK;KACN,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAA2B,EAAQ,EAAE;IACrE,aAAa,CAAC,EAAE,GAAG,MAAM,EAAE,iBAAiB,EAAE,QAAQ,EAAE,EAAE,cAAc,CAAC,CAAC;AAC5E,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,MAA2B,EAAQ,EAAE;IACtE,aAAa,CACX,EAAE,GAAG,MAAM,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,EACnD,eAAe,CAChB,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/feedback/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { fetchFeedback } from "./fetchFeedback.js";
|
|
2
2
|
export { attachUnits } from "./attachUnits.js";
|
|
3
3
|
export type { AttachUnitsOptions } from "./attachUnits.js";
|
|
4
|
-
export { attachCore, attachSimpleFrame, attachInstallFrame, } from "./attachCoreAndFrames.js";
|
|
5
|
-
export type { AttachFeedbackPaths } from "./attachCoreAndFrames.js";
|
|
4
|
+
export { attachCore, attachFrame, attachSimpleFrame, attachInstallFrame, } from "./attachCoreAndFrames.js";
|
|
5
|
+
export type { AttachFeedbackPaths, AttachFrameOptions, } from "./attachCoreAndFrames.js";
|
|
6
6
|
export { readFeedback, readFeedbackIfExists, writeFeedback, writeFeedbackIfChanged, } from "./feedbackFile.js";
|
|
7
7
|
export type { FeedbackFile } from "./feedbackFile.js";
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/feedback/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/feedback/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EACL,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,aAAa,EACb,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/feedback/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { fetchFeedback } from "./fetchFeedback.js";
|
|
2
2
|
export { attachUnits } from "./attachUnits.js";
|
|
3
|
-
export { attachCore, attachSimpleFrame, attachInstallFrame, } from "./attachCoreAndFrames.js";
|
|
3
|
+
export { attachCore, attachFrame, attachSimpleFrame, attachInstallFrame, } from "./attachCoreAndFrames.js";
|
|
4
4
|
export { readFeedback, readFeedbackIfExists, writeFeedback, writeFeedbackIfChanged, } from "./feedbackFile.js";
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/feedback/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/feedback/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EACL,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAKlC,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,aAAa,EACb,sBAAsB,GACvB,MAAM,mBAAmB,CAAC"}
|
|
@@ -4,11 +4,16 @@ import type { Document } from "@frdt/frdt";
|
|
|
4
4
|
* its first child in that case, otherwise `doc` itself.
|
|
5
5
|
*/
|
|
6
6
|
export declare const unwrapHolder: (doc: Document) => Document;
|
|
7
|
+
/** A value saved from a local session: a debug URL or a local host. */
|
|
8
|
+
export declare const isDevelopmentValue: (value: string) => boolean;
|
|
7
9
|
/**
|
|
8
10
|
* Clear the developer's local connection settings that a feedback picks up
|
|
9
|
-
* while it is saved from a local session
|
|
10
|
-
* `ws://`
|
|
11
|
-
*
|
|
11
|
+
* while it is saved from a local session: a local host (see `isLocalHost`) or
|
|
12
|
+
* a debug `http://` / `ws://` URL in `Static.Web.Host`, `Env.Host.Fallback`,
|
|
13
|
+
* a cloud variable's fallback or a `WebsocketClient` (which is disconnected),
|
|
14
|
+
* and a debug URL of a `StaticBinary`. MirageX sets its own at build and run
|
|
15
|
+
* time. Other values, such as the production host of another app embedded in
|
|
16
|
+
* a frame, are kept. Returns how many fields were changed.
|
|
12
17
|
*/
|
|
13
18
|
export declare const sanitizeFeedback: (doc: Document) => number;
|
|
14
19
|
//# sourceMappingURL=sanitize.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/feedback/sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAe,MAAM,YAAY,CAAC;AAIxD;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,KAAK,QAAQ,KAAG,QAO5C,CAAC;
|
|
1
|
+
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/feedback/sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAe,MAAM,YAAY,CAAC;AAIxD;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,KAAK,QAAQ,KAAG,QAO5C,CAAC;AAiFF,uEAAuE;AACvE,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAAM,YACC,CAAC;AA8BlD;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAAI,KAAK,QAAQ,KAAG,MAkDhD,CAAC"}
|
|
@@ -12,14 +12,90 @@ export const unwrapHolder = (doc) => {
|
|
|
12
12
|
return doc.extract(first, { unresolved: "null" }).document();
|
|
13
13
|
};
|
|
14
14
|
const FRAMEWORK = "[FrooxEngine]FrooxEngine.";
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const isDebugUrl = (
|
|
15
|
+
/**
|
|
16
|
+
* `DynamicValueVariable<string>`s that hold a host to connect to. (The
|
|
17
|
+
* `Static.Web.Url.*` variables are `Uri`s driven from these at run time and
|
|
18
|
+
* are left as they are.)
|
|
19
|
+
*/
|
|
20
|
+
const HOST_VARIABLES = new Set(["Static.Web.Host", "Env.Host.Fallback"]);
|
|
21
|
+
/** An unencrypted `http://` / `ws://` URL (`@` is how Resonite saves a Uri). */
|
|
22
|
+
const isDebugUrl = (value) => /^\s*@?(http|ws):\/\//i.test(value);
|
|
23
|
+
/** The host name in a host (`name:port`) or a URL, lower case. */
|
|
24
|
+
const hostOf = (value) => {
|
|
25
|
+
const withoutScheme = value
|
|
26
|
+
.trim()
|
|
27
|
+
.replace(/^@/, "")
|
|
28
|
+
.replace(/^[a-z][a-z0-9+.-]*:\/\//i, "");
|
|
29
|
+
const authority = withoutScheme.split(/[/?#]/)[0] ?? "";
|
|
30
|
+
const host = authority.slice(authority.lastIndexOf("@") + 1).toLowerCase();
|
|
31
|
+
if (host.startsWith("[")) {
|
|
32
|
+
return host.slice(1, host.indexOf("]"));
|
|
33
|
+
}
|
|
34
|
+
// A bare IPv6 address (more than one colon) has no port to strip.
|
|
35
|
+
if (host.indexOf(":") !== host.lastIndexOf(":")) {
|
|
36
|
+
return host;
|
|
37
|
+
}
|
|
38
|
+
return host.split(":")[0].replace(/\.$/, "");
|
|
39
|
+
};
|
|
40
|
+
/** The four parts of a dotted IPv4 address, or `null`. */
|
|
41
|
+
const ipv4Of = (host) => {
|
|
42
|
+
const parts = host.split(".");
|
|
43
|
+
if (parts.length !== 4 || !parts.every((p) => /^\d{1,3}$/.test(p))) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
const numbers = parts.map(Number);
|
|
47
|
+
return numbers.every((n) => n <= 255) ? numbers : null;
|
|
48
|
+
};
|
|
49
|
+
const isLocalIpv4 = ([a, b]) => a === 127 || // loopback
|
|
50
|
+
a === 10 ||
|
|
51
|
+
(a === 172 && b >= 16 && b <= 31) ||
|
|
52
|
+
(a === 192 && b === 168) || // private
|
|
53
|
+
(a === 100 && b >= 64 && b <= 127) || // shared (CGNAT, Tailscale)
|
|
54
|
+
(a === 169 && b === 254) || // link-local
|
|
55
|
+
a === 0; // this network (0.0.0.0)
|
|
56
|
+
const isLocalIpv6 = (host) => {
|
|
57
|
+
const mapped = host.match(/^::ffff:(\d+\.\d+\.\d+\.\d+)$/);
|
|
58
|
+
if (mapped) {
|
|
59
|
+
const ip = ipv4Of(mapped[1]);
|
|
60
|
+
return ip !== null && isLocalIpv4(ip);
|
|
61
|
+
}
|
|
62
|
+
return (/^(0*:)*:?0*1$/.test(host) || // ::1, 0:0:0:0:0:0:0:1
|
|
63
|
+
/^(0*:)*:?0*$/.test(host) || // ::
|
|
64
|
+
/^fe[89ab][0-9a-f]?:/.test(host) || // link-local
|
|
65
|
+
/^f[cd][0-9a-f]{0,2}:/.test(host) // unique local
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* A host on the developer's machine or network: `localhost`, a name with no
|
|
70
|
+
* dot (a PC on the LAN), a local domain (`.local`, `.lan`, `.internal`,
|
|
71
|
+
* `.home.arpa`), or a loopback, private, shared or link-local IP.
|
|
72
|
+
*/
|
|
73
|
+
const isLocalHost = (host) => {
|
|
74
|
+
if (host === "")
|
|
75
|
+
return false;
|
|
76
|
+
if (host.includes(":"))
|
|
77
|
+
return isLocalIpv6(host);
|
|
78
|
+
const ip = ipv4Of(host);
|
|
79
|
+
if (ip)
|
|
80
|
+
return isLocalIpv4(ip);
|
|
81
|
+
return (!host.includes(".") ||
|
|
82
|
+
/\.(localhost|local|lan|internal|home\.arpa)$/.test(host));
|
|
83
|
+
};
|
|
84
|
+
/** A value saved from a local session: a debug URL or a local host. */
|
|
85
|
+
export const isDevelopmentValue = (value) => isDebugUrl(value) || isLocalHost(hostOf(value));
|
|
86
|
+
/**
|
|
87
|
+
* A value that is a host or a URL (a scheme, a port, a dot, `localhost` or an
|
|
88
|
+
* IP), not just any text. A cloud variable's fallback can be any string.
|
|
89
|
+
*/
|
|
90
|
+
const looksLikeHost = (value) => {
|
|
91
|
+
const trimmed = value.trim().replace(/^@/, "");
|
|
92
|
+
return (/^[a-z][a-z0-9+.-]*:\/\//i.test(trimmed) ||
|
|
93
|
+
// name:port, where the name has a letter (not a time like 10:30)
|
|
94
|
+
/^[^\s/:]*[a-z][^\s/:]*:\d{2,5}(\/|$)/i.test(trimmed) ||
|
|
95
|
+
/^\[[0-9a-f:.%]+\]/i.test(trimmed) ||
|
|
96
|
+
(/^[^\s/]+\.[^\s/]+/.test(trimmed) && !/\s/.test(trimmed)) ||
|
|
97
|
+
hostOf(trimmed) === "localhost");
|
|
98
|
+
};
|
|
23
99
|
/**
|
|
24
100
|
* Read a field, `undefined` when the component has no such field or its value
|
|
25
101
|
* is not one frdt can read as a value.
|
|
@@ -34,9 +110,12 @@ const read = (slot, i, field) => {
|
|
|
34
110
|
};
|
|
35
111
|
/**
|
|
36
112
|
* Clear the developer's local connection settings that a feedback picks up
|
|
37
|
-
* while it is saved from a local session
|
|
38
|
-
* `ws://`
|
|
39
|
-
*
|
|
113
|
+
* while it is saved from a local session: a local host (see `isLocalHost`) or
|
|
114
|
+
* a debug `http://` / `ws://` URL in `Static.Web.Host`, `Env.Host.Fallback`,
|
|
115
|
+
* a cloud variable's fallback or a `WebsocketClient` (which is disconnected),
|
|
116
|
+
* and a debug URL of a `StaticBinary`. MirageX sets its own at build and run
|
|
117
|
+
* time. Other values, such as the production host of another app embedded in
|
|
118
|
+
* a frame, are kept. Returns how many fields were changed.
|
|
40
119
|
*/
|
|
41
120
|
export const sanitizeFeedback = (doc) => {
|
|
42
121
|
let changed = 0;
|
|
@@ -49,14 +128,19 @@ export const sanitizeFeedback = (doc) => {
|
|
|
49
128
|
if (typeName === `${FRAMEWORK}DynamicValueVariable<string>`) {
|
|
50
129
|
const name = stringOf(read(slot, i, "VariableName"));
|
|
51
130
|
const value = stringOf(read(slot, i, "Value"));
|
|
52
|
-
if (name &&
|
|
131
|
+
if (name &&
|
|
132
|
+
HOST_VARIABLES.has(name) &&
|
|
133
|
+
value &&
|
|
134
|
+
isDevelopmentValue(value)) {
|
|
53
135
|
clear(slot, i, "Value", str(""));
|
|
54
136
|
}
|
|
55
137
|
return;
|
|
56
138
|
}
|
|
57
139
|
if (typeName.startsWith(`${FRAMEWORK}CloudValueVariableDriver<`)) {
|
|
58
140
|
const fallback = stringOf(read(slot, i, "FallbackValue"));
|
|
59
|
-
if (fallback &&
|
|
141
|
+
if (fallback &&
|
|
142
|
+
looksLikeHost(fallback) &&
|
|
143
|
+
isDevelopmentValue(fallback)) {
|
|
60
144
|
clear(slot, i, "FallbackValue", str(""));
|
|
61
145
|
}
|
|
62
146
|
return;
|
|
@@ -70,7 +154,7 @@ export const sanitizeFeedback = (doc) => {
|
|
|
70
154
|
}
|
|
71
155
|
if (typeName === `${FRAMEWORK}WebsocketClient`) {
|
|
72
156
|
const url = stringOf(read(slot, i, "URL"));
|
|
73
|
-
if (url &&
|
|
157
|
+
if (url && isDevelopmentValue(url)) {
|
|
74
158
|
clear(slot, i, "URL", str(""));
|
|
75
159
|
clear(slot, i, "IsConnected", bool(false));
|
|
76
160
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitize.js","sourceRoot":"","sources":["../../src/feedback/sanitize.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhE;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAa,EAAY,EAAE;IACtD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IACxB,MAAM,CAA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, Slot } from "@frdt/frdt";
|
|
2
|
+
/** The app version `build` writes into MirageX's ENV slots. */
|
|
3
|
+
export declare const VERSION_VARIABLE = "Env.Version.Current";
|
|
4
|
+
/**
|
|
5
|
+
* MirageX's ENV under `slot`: the last `ENV` child of its `DV`. `placeCore`
|
|
6
|
+
* and `generateClient` add it after any slot already there, so an ENV of
|
|
7
|
+
* another app placed in the same `DV` comes first.
|
|
8
|
+
*/
|
|
9
|
+
export declare const envUnder: (slot: Slot) => Slot | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* The ENV slots MirageX places in an output: the frame's (`DV/ENV` under the
|
|
12
|
+
* root) and the core's (`Main/DV/ENV` under the slot the root's
|
|
13
|
+
* `Static.AppRoot` points at). Found by where they are, not by name, so an ENV
|
|
14
|
+
* of another app embedded in the frame or in a unit is left alone.
|
|
15
|
+
*/
|
|
16
|
+
export declare const mirageXEnvSlots: (doc: Document) => Slot[];
|
|
17
|
+
/**
|
|
18
|
+
* Set the app version in MirageX's ENV slots. Returns how many ENV slots were
|
|
19
|
+
* found and how many values were set.
|
|
20
|
+
*/
|
|
21
|
+
export declare const setAppVersion: (doc: Document, version: string) => {
|
|
22
|
+
envSlots: number;
|
|
23
|
+
updated: number;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/frame/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAWjD,+DAA+D;AAC/D,eAAO,MAAM,gBAAgB,wBAAwB,CAAC;AAEtD;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,MAAM,IAAI,KAAG,IAAI,GAAG,SAG5C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,QAAQ,KAAG,IAAI,EAWnD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,GACxB,KAAK,QAAQ,EACb,SAAS,MAAM,KACd;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAOrC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { allSlots, childNamed, lastChildNamed, referenceOf, setVariableValues, str, } from "../frdt/util.js";
|
|
2
|
+
/** The app version `build` writes into MirageX's ENV slots. */
|
|
3
|
+
export const VERSION_VARIABLE = "Env.Version.Current";
|
|
4
|
+
/**
|
|
5
|
+
* MirageX's ENV under `slot`: the last `ENV` child of its `DV`. `placeCore`
|
|
6
|
+
* and `generateClient` add it after any slot already there, so an ENV of
|
|
7
|
+
* another app placed in the same `DV` comes first.
|
|
8
|
+
*/
|
|
9
|
+
export const envUnder = (slot) => {
|
|
10
|
+
const dv = childNamed(slot, "DV");
|
|
11
|
+
return dv && lastChildNamed(dv, "ENV");
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The ENV slots MirageX places in an output: the frame's (`DV/ENV` under the
|
|
15
|
+
* root) and the core's (`Main/DV/ENV` under the slot the root's
|
|
16
|
+
* `Static.AppRoot` points at). Found by where they are, not by name, so an ENV
|
|
17
|
+
* of another app embedded in the frame or in a unit is left alone.
|
|
18
|
+
*/
|
|
19
|
+
export const mirageXEnvSlots = (doc) => {
|
|
20
|
+
const root = doc.root();
|
|
21
|
+
const appRootId = referenceOf(root, "Static.AppRoot");
|
|
22
|
+
const appRoot = appRootId === null
|
|
23
|
+
? undefined
|
|
24
|
+
: allSlots(root).find((slot) => slot.id() === appRootId);
|
|
25
|
+
const main = appRoot && childNamed(appRoot, "Main");
|
|
26
|
+
return [envUnder(root), main && envUnder(main)].filter((slot) => slot !== undefined);
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Set the app version in MirageX's ENV slots. Returns how many ENV slots were
|
|
30
|
+
* found and how many values were set.
|
|
31
|
+
*/
|
|
32
|
+
export const setAppVersion = (doc, version) => {
|
|
33
|
+
const slots = mirageXEnvSlots(doc);
|
|
34
|
+
const ids = new Set(slots.map((slot) => slot.id()));
|
|
35
|
+
const updated = setVariableValues(doc, VERSION_VARIABLE, str(version), (slot) => ids.has(slot.id()));
|
|
36
|
+
return { envSlots: slots.length, updated };
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/frame/env.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,QAAQ,EACR,UAAU,EACV,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,GAAG,GACJ,MAAM,iBAAiB,CAAC;AAEzB,+DAA+D;AAC/D,MAAM,CAAC,MAAM,gBAAgB,GAAG,qBAAqB,CAAC;AAEtD;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAU,EAAoB,EAAE;IACvD,MAAM,EAAE,GAAG,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,OAAO,EAAE,IAAI,cAAc,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;AACzC,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAa,EAAU,EAAE;IACvD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IACxB,MAAM,SAAS,GAAG,WAAW,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;IACtD,MAAM,OAAO,GACX,SAAS,KAAK,IAAI;QAChB,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,SAAS,CAAC,CAAC;IAC7D,MAAM,IAAI,GAAG,OAAO,IAAI,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACpD,OAAO,CAAC,Q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