@cloudcrane/app-runtime 0.3.0 → 0.6.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/README.md +15 -1
- package/dist/compiler/compile.d.ts +1 -0
- package/dist/compiler/compile.js +7 -2
- package/dist/compiler/runtime.generated.d.ts +3 -3
- package/dist/compiler/runtime.generated.js +3 -3
- package/dist/host.d.ts +1 -1
- package/dist/host.js +1 -1
- package/dist/runtime/styles.d.ts +1 -1
- package/dist/runtime/styles.js +2 -1
- package/package.json +3 -3
- package/runtime-lock.json +3 -1
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ const { html, sha256, runtime } = compile(spec);
|
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
- `compile(spec)` returns the page, its sha256 and the runtime it was built
|
|
15
|
-
with (`@cloudcrane/app-runtime@0.
|
|
15
|
+
with (`@cloudcrane/app-runtime@0.4.0+<hash>`); it throws `CompileError`
|
|
16
16
|
listing every problem when the spec doesn't validate.
|
|
17
17
|
- `compile(spec, { runtime: "shared" })` links the runtime instead of inlining
|
|
18
18
|
it: the page names `runtimeFile().path` (`/_cc/runtime/<version>-<hash>.js`)
|
|
@@ -39,6 +39,20 @@ const { html, sha256, runtime } = compile(spec);
|
|
|
39
39
|
game.random(); // seeded by the page
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
+
The page kit runs an HTML page as it is, full screen. Its `localStorage`
|
|
43
|
+
works: what it holds is written into the frame when it opens, and each
|
|
44
|
+
change goes to the page, which keeps it under `<data.key>.coded.<id>` (at
|
|
45
|
+
most 4 MB), so it survives a reload and an update and the frame sees only
|
|
46
|
+
its own. Both kits reach the page through `window.__ccBus`.
|
|
47
|
+
|
|
48
|
+
A component's frame is allowed the device features the spec's `uses`
|
|
49
|
+
declares (its `allow`), and the page must allow them for frames too (in
|
|
50
|
+
Permissions-Policy, `geolocation=*` rather than `(self)`). Browsers give a
|
|
51
|
+
frame with no origin of its own no camera or microphone, so a page kit whose
|
|
52
|
+
spec declares either runs with the page's origin; it's then no more apart
|
|
53
|
+
from the page than an app written straight into it. A game kit always
|
|
54
|
+
stays apart.
|
|
55
|
+
|
|
42
56
|
- `@cloudcrane/app-runtime/host`: what a host publishing spec apps needs in one
|
|
43
57
|
import (validate, compile, derive the blueprint).
|
|
44
58
|
|
|
@@ -13,6 +13,7 @@ export type LinkedRuntime = {
|
|
|
13
13
|
path: string;
|
|
14
14
|
integrity: string;
|
|
15
15
|
};
|
|
16
|
+
/** `runtime` names the runtime the page carries, or is "page" for an HTML app's spec, which is its page as written, with none. */
|
|
16
17
|
export type Compiled = {
|
|
17
18
|
html: string;
|
|
18
19
|
sha256: string;
|
package/dist/compiler/compile.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { canonical, validateSpec } from "@cloudcrane/app-spec";
|
|
2
|
+
import { canonical, pageOf, validateSpec } from "@cloudcrane/app-spec";
|
|
3
3
|
import { CODED_CSS, DATESTRIP_CSS } from "../runtime/styles.js";
|
|
4
4
|
import { tokensCss } from "../runtime/theme.js";
|
|
5
5
|
import { RUNTIME_JS, RUNTIME_SHA256, RUNTIME_VERSION } from "./runtime.generated.js";
|
|
@@ -40,13 +40,18 @@ export function compile(input, options = {}) {
|
|
|
40
40
|
const { spec, problems } = validateSpec(input);
|
|
41
41
|
if (!spec)
|
|
42
42
|
throw new CompileError(problems);
|
|
43
|
+
// A spec that is an HTML app's page is that page, as written: no runtime, so any runtime version builds it the same.
|
|
44
|
+
const page = pageOf(spec);
|
|
45
|
+
if (page !== null)
|
|
46
|
+
return { html: page, sha256: createHash("sha256").update(page).digest("hex"), runtime: "page" };
|
|
43
47
|
if (spec.manifest.runtime !== RUNTIME_VERSION)
|
|
44
48
|
throw new CompileError([{ at: "manifest.runtime", problem: `this compiler builds runtime ${RUNTIME_VERSION}` }]);
|
|
45
49
|
// Only what drawing the app needs goes in the page: not the journeys, promises or tests.
|
|
46
|
-
// Coded components go in only when there are some.
|
|
50
|
+
// Coded components go in only when there are some, and the device features they may use only when it uses some.
|
|
47
51
|
const inPage = {
|
|
48
52
|
module: spec.module,
|
|
49
53
|
...(Object.keys(spec.components).length ? { components: spec.components } : {}),
|
|
54
|
+
...(spec.uses.length ? { uses: spec.uses } : {}),
|
|
50
55
|
data: spec.data,
|
|
51
56
|
logic: spec.logic,
|
|
52
57
|
surface: spec.surface,
|