@standardagents/code-web 0.14.3-canary.6cc75f → 0.14.4-branch.9e48e914.ee06ef

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.
Files changed (37) hide show
  1. package/README.md +9 -1
  2. package/dist/build.json +1 -1
  3. package/dist/licenses/jco-transpile.txt +220 -0
  4. package/dist/manifest.json +1 -1
  5. package/dist/manifest.sig +1 -1
  6. package/dist/pkg/standard_web.d.ts +50 -12
  7. package/dist/pkg/standard_web.js +292 -20
  8. package/dist/pkg/standard_web_bg.wasm +0 -0
  9. package/dist/pkg/standard_web_bg.wasm.d.ts +17 -12
  10. package/dist/plugins/clock-cells/clock_cells.core.wasm +0 -0
  11. package/dist/plugins/clock-cells/clock_cells.wasm +0 -0
  12. package/dist/plugins/clock-cells/standard-plugin.json +11 -0
  13. package/dist/plugins/host/transpile.js +51 -0
  14. package/dist/plugins/host/ui-jspi.js +14851 -0
  15. package/dist/plugins/host/ui.core2.wasm +0 -0
  16. package/dist/plugins/host/ui.core3.wasm +0 -0
  17. package/dist/plugins/host/ui.js +14675 -0
  18. package/dist/plugins/host/world.js +172 -0
  19. package/dist/plugins/jco/cli.js +141 -0
  20. package/dist/plugins/jco/common.js +16 -0
  21. package/dist/plugins/jco/config.js +7 -0
  22. package/dist/plugins/jco/environment.js +24 -0
  23. package/dist/plugins/jco/filesystem.js +339 -0
  24. package/dist/plugins/jco/in-memory-filesystem.js +620 -0
  25. package/dist/plugins/jco/io.js +366 -0
  26. package/dist/plugins/jco/js-component-bindgen-component.core.wasm +0 -0
  27. package/dist/plugins/jco/js-component-bindgen-component.core2.wasm +0 -0
  28. package/dist/plugins/jco/js-component-bindgen-component.js +14272 -0
  29. package/dist/plugins/jco/opfs-filesystem.js +245 -0
  30. package/dist/plugins/jco/random.js +51 -0
  31. package/dist/plugins/plasma-pixels/plasma_pixels.core.wasm +0 -0
  32. package/dist/plugins/plasma-pixels/plasma_pixels.wasm +0 -0
  33. package/dist/plugins/plasma-pixels/standard-plugin.json +11 -0
  34. package/dist/plugins/runtime.js +1044 -0
  35. package/dist/plugins/samples.json +81 -0
  36. package/dist/plugins/worker.js +411 -0
  37. package/package.json +8 -2
@@ -0,0 +1,51 @@
1
+ // The trusted transpile step, run in the viewer (docs/plugin-runtime.md,
2
+ // "The browser runtime"): jco's transpiler, the same pinned version the
3
+ // build uses, splits a plugin's verified component into its core modules,
4
+ // and the viewer keeps only the one that exports the world. jco's generated
5
+ // JavaScript for the component is discarded unread: the only glue that ever
6
+ // runs is the viewer's own reference glue (world.js).
7
+ //
8
+ // The build runs the same function in Node on the sample plugins, so a
9
+ // sample and an account package reach a Worker the same way.
10
+ import { ACCOUNT_IMPORTS, selectMain } from './world.js'
11
+
12
+ /** jco's `generate` options: sync instantiation, core modules as files. */
13
+ export const GENERATE_OPTIONS = Object.freeze({
14
+ name: 'plugin',
15
+ noTypescript: true,
16
+ instantiation: { tag: 'sync' },
17
+ map: [],
18
+ noNodejsCompat: true,
19
+ base64Cutoff: 0,
20
+ tlaCompat: false,
21
+ validLiftingOptimization: false,
22
+ tracing: false,
23
+ noComponentErrorWrapping: true,
24
+ })
25
+
26
+ const WORLD_PACKAGE = 'standard:plugin/'
27
+ const CORE_FILE = /\.core\d*\.wasm$/
28
+
29
+ /**
30
+ * The plugin's world core module, from its component's bytes. `generate`
31
+ * is jco's (`js-component-bindgen-component.js`). Throws when jco refuses
32
+ * the component, when it imports an interface outside `standard:plugin`,
33
+ * or when no single core module exports the world.
34
+ */
35
+ export async function extractMain(component, generate) {
36
+ let generated
37
+ try {
38
+ generated = generate(component instanceof Uint8Array ? component : new Uint8Array(component), GENERATE_OPTIONS)
39
+ } catch (error) {
40
+ throw new Error(`jco refused the component: ${error?.payload ?? error?.message ?? error}`)
41
+ }
42
+ const outside = generated.imports.filter(name => !name.startsWith(WORLD_PACKAGE))
43
+ if (outside.length) throw new Error(`the component imports outside the ui-plugin world: ${outside.join(', ')}`)
44
+ const cores = generated.files.filter(([name]) => CORE_FILE.test(name)).map(([, bytes]) => bytes)
45
+ const modules = await Promise.all(cores.map(bytes => WebAssembly.compile(bytes)))
46
+ const main = selectMain(modules)
47
+ return cores[modules.indexOf(main)]
48
+ }
49
+
50
+ /** The account-backed imports in the async form jco takes. */
51
+ export const JSPI_IMPORTS = ACCOUNT_IMPORTS