@paged-media/plugin-sdk 0.2.31-canary.0 → 0.2.33-canary.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/dist/index.d.ts CHANGED
@@ -698,19 +698,38 @@ declare function loadBundle(getEditor: () => PagedEditor, bundle: PagedBundle, o
698
698
  * KEEP IN SYNC with plugin-cli's WASM_MAX_* and the schema's `maxBytes`
699
699
  * maximum — the CLI hand-mirrors the contract. */
700
700
  declare const WASM_BUDGETS: {
701
- /** Hard per-artifact byte ceiling for layout/codec/compute. A
702
- * release-optimised wasm layout engine (Blitz-class) lands in the
703
- * low-single-digit MiB; 8 MiB rejects an accidentally-bundled debug
704
- * build while leaving headroom for one real engine. A manifest
705
- * `maxBytes` may only TIGHTEN this. */
701
+ /**
702
+ * THE budget, as of 2026-08-19 (maintainer decision): **100 MB for the
703
+ * whole app including every plugin.**
704
+ *
705
+ * The per-thing ceilings below used to be the governance. They were
706
+ * the wrong shape: each capped one artifact or one bundle, so eight
707
+ * bundles could each pass their own gate while the app shipped a
708
+ * quarter of a gigabyte, and nothing in any repo measured the sum.
709
+ * What a user downloads is the sum, so the sum is what is governed.
710
+ *
711
+ * This constant is the CONTRACT; the enforcement lives where the app
712
+ * is assembled, in the editor's `scripts/wasm-budget.mjs` (run in its
713
+ * `checks` CI job), because only the app knows which bundles ship. It
714
+ * deduplicates by real path — pnpm links one store entry from many
715
+ * packages, and a naive walk over-counts nearly 6x. Measured 2026-08-19:
716
+ * 49.4 MB across 9 distinct artifacts, ~50 MB of headroom.
717
+ */
718
+ readonly maxAppTotalBytes: number;
719
+ /** Per-artifact ceiling for layout/codec/compute. Folded into the
720
+ * app-wide envelope on 2026-08-19 (was 8 MiB, briefly 25): a single
721
+ * artifact is no longer independently interesting, since the sum is
722
+ * bounded. Kept — not deleted — so a manifest `maxBytes` still has
723
+ * something to TIGHTEN and the loader keeps a hard upper stop. */
706
724
  readonly maxArtifactBytes: number;
707
- /** D-07b — the governed HIGHER ceiling for `purpose: "engine"` (a
708
- * vendored DB/query engine like DuckDB-WASM ≈ 36 MiB). 64 MiB fits the
709
- * real artifacts with headroom; still a hard cap a manifest may only
710
- * tighten. Only the `engine` purpose earns it. */
725
+ /** D-07b — was the HIGHER ceiling for `purpose: "engine"` (a vendored
726
+ * DB/query engine like DuckDB-WASM ≈ 36 MiB) back when ordinary
727
+ * artifacts were capped far lower. Now equal to the ordinary cap; the
728
+ * `purpose` distinction survives for governance/telemetry, not size. */
711
729
  readonly maxEngineArtifactBytes: number;
712
- /** Total declared wasm across one bundle. Sized so one `engine`
713
- * artifact + a codec fit. */
730
+ /** Total declared wasm across ONE bundle. Also the app-wide number —
731
+ * one bundle may in principle spend the entire envelope, and the
732
+ * app-wide check is what stops the app as a whole. */
714
733
  readonly maxTotalBytes: number;
715
734
  /** Wall-clock budget for fetch + compile + instantiate. Protects the
716
735
  * editor's main flow from a pathological module; advisory, the loader
package/dist/index.js CHANGED
@@ -624,6 +624,42 @@ function createBundleHost(getEditor, manifest, options) {
624
624
  );
625
625
  return store.add(getEditor().registries.keybindings.register(c));
626
626
  },
627
+ menu(c) {
628
+ assertNamespaced(c.command, "menu");
629
+ requireDeclared(
630
+ lists(declared?.commands, c.command),
631
+ "contribute.menu",
632
+ `contributes.commands[] must include "${c.command}" before a menu entry can invoke it`
633
+ );
634
+ const scope = c.scope ?? "document";
635
+ const editContext = typeof scope === "object" ? scope.editContext : null;
636
+ const menus = getEditor().registries.menus;
637
+ if (!menus) {
638
+ return { dispose() {
639
+ } };
640
+ }
641
+ return store.add(
642
+ menus.register({
643
+ path: c.path,
644
+ command: c.command,
645
+ order: c.order,
646
+ group: c.group,
647
+ // The scope becomes a `when` predicate, which is the host's
648
+ // existing vocabulary for "does this apply where you are
649
+ // standing" — the same field the Insert items and the Window
650
+ // menu already use. A context-scoped entry is simply one whose
651
+ // predicate asks what context is active.
652
+ when: (state2) => {
653
+ const st = state2;
654
+ if (!st?.document?.handle || (st.document.handle.pageCount ?? 0) === 0) {
655
+ return false;
656
+ }
657
+ if (editContext === null) return true;
658
+ return st.editContext?.type === editContext;
659
+ }
660
+ })
661
+ );
662
+ },
627
663
  overlay(c) {
628
664
  assertNamespaced(c.id, "overlay");
629
665
  requireDeclared(
@@ -2625,20 +2661,39 @@ function loadBundle(getEditor, bundle, options) {
2625
2661
 
2626
2662
  // src/wasm-bundle-loader.ts
2627
2663
  var WASM_BUDGETS = {
2628
- /** Hard per-artifact byte ceiling for layout/codec/compute. A
2629
- * release-optimised wasm layout engine (Blitz-class) lands in the
2630
- * low-single-digit MiB; 8 MiB rejects an accidentally-bundled debug
2631
- * build while leaving headroom for one real engine. A manifest
2632
- * `maxBytes` may only TIGHTEN this. */
2633
- maxArtifactBytes: 8 * 1024 * 1024,
2634
- /** D-07b — the governed HIGHER ceiling for `purpose: "engine"` (a
2635
- * vendored DB/query engine like DuckDB-WASM ≈ 36 MiB). 64 MiB fits the
2636
- * real artifacts with headroom; still a hard cap a manifest may only
2637
- * tighten. Only the `engine` purpose earns it. */
2638
- maxEngineArtifactBytes: 64 * 1024 * 1024,
2639
- /** Total declared wasm across one bundle. Sized so one `engine`
2640
- * artifact + a codec fit. */
2641
- maxTotalBytes: 80 * 1024 * 1024,
2664
+ /**
2665
+ * THE budget, as of 2026-08-19 (maintainer decision): **100 MB for the
2666
+ * whole app including every plugin.**
2667
+ *
2668
+ * The per-thing ceilings below used to be the governance. They were
2669
+ * the wrong shape: each capped one artifact or one bundle, so eight
2670
+ * bundles could each pass their own gate while the app shipped a
2671
+ * quarter of a gigabyte, and nothing in any repo measured the sum.
2672
+ * What a user downloads is the sum, so the sum is what is governed.
2673
+ *
2674
+ * This constant is the CONTRACT; the enforcement lives where the app
2675
+ * is assembled, in the editor's `scripts/wasm-budget.mjs` (run in its
2676
+ * `checks` CI job), because only the app knows which bundles ship. It
2677
+ * deduplicates by real path — pnpm links one store entry from many
2678
+ * packages, and a naive walk over-counts nearly 6x. Measured 2026-08-19:
2679
+ * 49.4 MB across 9 distinct artifacts, ~50 MB of headroom.
2680
+ */
2681
+ maxAppTotalBytes: 100 * 1e3 * 1e3,
2682
+ /** Per-artifact ceiling for layout/codec/compute. Folded into the
2683
+ * app-wide envelope on 2026-08-19 (was 8 MiB, briefly 25): a single
2684
+ * artifact is no longer independently interesting, since the sum is
2685
+ * bounded. Kept — not deleted — so a manifest `maxBytes` still has
2686
+ * something to TIGHTEN and the loader keeps a hard upper stop. */
2687
+ maxArtifactBytes: 100 * 1e3 * 1e3,
2688
+ /** D-07b — was the HIGHER ceiling for `purpose: "engine"` (a vendored
2689
+ * DB/query engine like DuckDB-WASM ≈ 36 MiB) back when ordinary
2690
+ * artifacts were capped far lower. Now equal to the ordinary cap; the
2691
+ * `purpose` distinction survives for governance/telemetry, not size. */
2692
+ maxEngineArtifactBytes: 100 * 1e3 * 1e3,
2693
+ /** Total declared wasm across ONE bundle. Also the app-wide number —
2694
+ * one bundle may in principle spend the entire envelope, and the
2695
+ * app-wide check is what stops the app as a whole. */
2696
+ maxTotalBytes: 100 * 1e3 * 1e3,
2642
2697
  /** Wall-clock budget for fetch + compile + instantiate. Protects the
2643
2698
  * editor's main flow from a pathological module; advisory, the loader
2644
2699
  * aborts with a clear error when exceeded. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paged-media/plugin-sdk",
3
- "version": "0.2.31-canary.0",
3
+ "version": "0.2.33-canary.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -11,7 +11,7 @@
11
11
  }
12
12
  },
13
13
  "dependencies": {
14
- "@paged-media/plugin-api": "0.2.31-canary.0"
14
+ "@paged-media/plugin-api": "0.2.33-canary.0"
15
15
  },
16
16
  "peerDependencies": {
17
17
  "react": "^18.3.0"
@@ -22,7 +22,7 @@
22
22
  }
23
23
  },
24
24
  "devDependencies": {
25
- "@paged-media/canvas-wasm": "0.61.0",
25
+ "@paged-media/canvas-wasm": "0.62.0",
26
26
  "@types/node": "20.19.39",
27
27
  "@types/react": "^18.3.12",
28
28
  "react": "^18.3.0",