@datalayer/agent-runtimes 1.3.95 → 1.3.96
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/dist-embed/datalayer-app-main.js +3 -3
- package/dist-embed/datalayer-app.js +1 -1
- package/lib/apps/__tests__/fixtures/sceneCheckCases.json +352 -0
- package/lib/apps/apps/sceneChecks.d.ts +92 -0
- package/lib/apps/apps/sceneChecks.js +649 -0
- package/lib/apps/apps/sceneShape.d.ts +8 -0
- package/lib/apps/apps/sceneShape.js +191 -0
- package/lib/apps/apps/sceneYaml.d.ts +64 -0
- package/lib/apps/apps/sceneYaml.js +253 -0
- package/lib/apps/core/canvasParts.d.ts +28 -0
- package/lib/apps/core/canvasParts.js +14 -0
- package/lib/apps/core/index.d.ts +1 -0
- package/lib/apps/core/index.js +2 -0
- package/lib/apps/embed/loader.js +10 -0
- package/lib/apps/plugins/agents/SandboxSelector.js +13 -2
- package/lib/apps/plugins/agents/host.d.ts +2 -0
- package/lib/apps/plugins/agents/host.js +16 -0
- package/lib/apps/plugins/agents/plugin.js +10 -2
- package/lib/apps/plugins/agents/switchable.d.ts +12 -0
- package/lib/apps/plugins/agents/switchable.js +23 -0
- package/lib/apps/plugins/canvas-parts/index.d.ts +44 -0
- package/lib/apps/plugins/canvas-parts/index.js +209 -0
- package/lib/hooks/useAgUi.js +4 -1
- package/lib/protocols/AGUIAdapter.js +5 -1
- package/lib/protocols/agUiRefusal.d.ts +47 -0
- package/lib/protocols/agUiRefusal.js +87 -0
- package/lib/specs/apps.js +20 -12
- package/lib/specs/scenes.js +103 -98
- package/lib/specs/teams/teams.js +1 -1
- package/package.json +3 -1
- package/scripts/dist-embed.mjs +116 -0
- package/scripts/record-scene-checks.py +600 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Put `dist-embed/` in a checkout: the embed element's own bundle.
|
|
4
|
+
*
|
|
5
|
+
* `dist-embed/datalayer-app.js` is what a page loads to put an application on
|
|
6
|
+
* someone else's site (LOOP D-08). A release carries it — `npm run build:embed`
|
|
7
|
+
* runs in the release, and the npm package ships the folder — but a workspace
|
|
8
|
+
* checkout has never run it, and the folder is gitignored. The landing's
|
|
9
|
+
* production build refuses to ship without it, because an embed bundle that
|
|
10
|
+
* does not match the runtime it talks to is worse than none:
|
|
11
|
+
*
|
|
12
|
+
* Error: @datalayer/agent-runtimes has no dist-embed/datalayer-app.js …
|
|
13
|
+
* install a release that carries the embed bundle (1.3.93 or later)
|
|
14
|
+
*
|
|
15
|
+
* Two ways to get it, and the right one depends on what you are doing:
|
|
16
|
+
*
|
|
17
|
+
* node scripts/dist-embed.mjs # build it here, from this tree
|
|
18
|
+
* node scripts/dist-embed.mjs --release # take the published one of this
|
|
19
|
+
* # package's own version
|
|
20
|
+
* node scripts/dist-embed.mjs --release 1.3.95 # or of the one named
|
|
21
|
+
*
|
|
22
|
+
* Build it when you changed the embed's own code and want to see it. Take the
|
|
23
|
+
* release when you only need the landing to build: the download is seconds
|
|
24
|
+
* against minutes, and it is byte for byte what the deployed runtime serves.
|
|
25
|
+
* `--force` replaces a folder that is already there; without it, an existing
|
|
26
|
+
* `dist-embed/datalayer-app.js` is left alone and said so.
|
|
27
|
+
*
|
|
28
|
+
* @module scripts/dist-embed
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
import { execFileSync } from 'node:child_process';
|
|
32
|
+
import { existsSync, mkdtempSync, rmSync, cpSync, readFileSync, statSync } from 'node:fs';
|
|
33
|
+
import { tmpdir } from 'node:os';
|
|
34
|
+
import { dirname, join } from 'node:path';
|
|
35
|
+
import { fileURLToPath } from 'node:url';
|
|
36
|
+
|
|
37
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
38
|
+
const ROOT = join(HERE, '..');
|
|
39
|
+
const OUT = join(ROOT, 'dist-embed');
|
|
40
|
+
const MADE = join(OUT, 'datalayer-app.js');
|
|
41
|
+
|
|
42
|
+
const args = process.argv.slice(2);
|
|
43
|
+
const wants = (name) => args.includes(name);
|
|
44
|
+
/** The value after a flag, when it is not another flag. */
|
|
45
|
+
const after = (name) => {
|
|
46
|
+
const at = args.indexOf(name);
|
|
47
|
+
const value = at < 0 ? '' : String(args[at + 1] ?? '');
|
|
48
|
+
return value.startsWith('-') ? '' : value;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const say = (line) => process.stdout.write(`${line}\n`);
|
|
52
|
+
|
|
53
|
+
const ownVersion = () => JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf8')).version;
|
|
54
|
+
|
|
55
|
+
/** How big the folder is, in words a person reads. */
|
|
56
|
+
const sizeOf = (path) => {
|
|
57
|
+
const bytes = Number(
|
|
58
|
+
execFileSync('du', ['-sb', path], { encoding: 'utf8' }).split(/\s+/)[0] || 0
|
|
59
|
+
);
|
|
60
|
+
return bytes > 1024 * 1024 ? `${Math.round(bytes / (1024 * 1024))} MB` : `${Math.round(bytes / 1024)} KB`;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
function fromRelease(version) {
|
|
64
|
+
const named = `@datalayer/agent-runtimes@${version}`;
|
|
65
|
+
say(`Taking the embed bundle of ${named} from npm…`);
|
|
66
|
+
const work = mkdtempSync(join(tmpdir(), 'dist-embed-'));
|
|
67
|
+
try {
|
|
68
|
+
const packed = execFileSync('npm', ['pack', named, '--silent'], {
|
|
69
|
+
cwd: work,
|
|
70
|
+
encoding: 'utf8',
|
|
71
|
+
})
|
|
72
|
+
.trim()
|
|
73
|
+
.split('\n')
|
|
74
|
+
.pop();
|
|
75
|
+
const tarball = join(work, packed);
|
|
76
|
+
if (!existsSync(tarball)) {
|
|
77
|
+
throw new Error(`npm pack wrote no tarball for ${named}`);
|
|
78
|
+
}
|
|
79
|
+
execFileSync('tar', ['xzf', tarball, 'package/dist-embed'], { cwd: work });
|
|
80
|
+
const taken = join(work, 'package', 'dist-embed');
|
|
81
|
+
if (!existsSync(join(taken, 'datalayer-app.js'))) {
|
|
82
|
+
throw new Error(`${named} carries no dist-embed/datalayer-app.js: it predates the embed bundle`);
|
|
83
|
+
}
|
|
84
|
+
rmSync(OUT, { recursive: true, force: true });
|
|
85
|
+
cpSync(taken, OUT, { recursive: true });
|
|
86
|
+
} finally {
|
|
87
|
+
rmSync(work, { recursive: true, force: true });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function build() {
|
|
92
|
+
say('Building the embed bundle from this tree (vite.embed.config.ts)…');
|
|
93
|
+
execFileSync('npm', ['run', 'build:embed'], { cwd: ROOT, stdio: 'inherit' });
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (existsSync(MADE) && !wants('--force')) {
|
|
97
|
+
say(`dist-embed is already here (${sizeOf(OUT)}): nothing done. Pass --force to replace it.`);
|
|
98
|
+
process.exit(0);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
try {
|
|
102
|
+
if (wants('--release')) {
|
|
103
|
+
fromRelease(after('--release') || ownVersion());
|
|
104
|
+
} else {
|
|
105
|
+
build();
|
|
106
|
+
}
|
|
107
|
+
} catch (refused) {
|
|
108
|
+
say(`The embed bundle could not be made: ${refused.message}`);
|
|
109
|
+
process.exit(1);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (!existsSync(MADE)) {
|
|
113
|
+
say('The embed bundle was not made: dist-embed/datalayer-app.js is absent.');
|
|
114
|
+
process.exit(1);
|
|
115
|
+
}
|
|
116
|
+
say(`dist-embed is ready: ${sizeOf(OUT)}, ${Math.round(statSync(MADE).size / 1024)} KB of loader.`);
|