@paged-media/plugin-sdk 0.2.5-canary.0 → 0.2.6-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.
Files changed (2) hide show
  1. package/dist/index.js +18 -0
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -185,8 +185,26 @@ function createBundleHost(getEditor, manifest, options) {
185
185
  );
186
186
  }
187
187
  };
188
+ const foreignMetadataKey = (m) => {
189
+ if (m.op === "setPluginMetadata") {
190
+ return m.args.key === metadataKey(manifest) ? null : m.args.key;
191
+ }
192
+ if (m.op === "batch") {
193
+ for (const child of m.args.ops) {
194
+ const bad = foreignMetadataKey(child);
195
+ if (bad !== null) return bad;
196
+ }
197
+ }
198
+ return null;
199
+ };
188
200
  const document = {
189
201
  async mutate(mutation) {
202
+ const foreign = foreignMetadataKey(mutation);
203
+ if (foreign !== null) {
204
+ const error = `setPluginMetadata key "${foreign}" is outside this plugin's namespace ("${metadataKey(manifest)}")`;
205
+ log.warn(error);
206
+ return { applied: false, error };
207
+ }
190
208
  try {
191
209
  const reply = await getEditor().client.mutate(mutation);
192
210
  if (reply.kind === "mutationApplied") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paged-media/plugin-sdk",
3
- "version": "0.2.5-canary.0",
3
+ "version": "0.2.6-canary.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -11,14 +11,14 @@
11
11
  }
12
12
  },
13
13
  "dependencies": {
14
- "@paged-media/plugin-api": "0.2.5-canary.0"
14
+ "@paged-media/plugin-api": "0.2.6-canary.0"
15
15
  },
16
16
  "devDependencies": {
17
17
  "typescript": "^5.6.3",
18
18
  "vitest": "^2.1.8"
19
19
  },
20
20
  "description": "The Paged plugin runtime: loadBundle, the in-process BundleHost adapter, the gesture kit, and version negotiation.",
21
- "license": "UNLICENSED",
21
+ "license": "MPL-2.0 OR LicenseRef-PMEL",
22
22
  "files": [
23
23
  "dist"
24
24
  ],