openplanr 2.2640.3 → 2.2640.4

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 (25) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/lib/host-packages/adapter-registry.json +5 -5
  3. package/lib/host-packages/capability-map.json +1 -1
  4. package/lib/host-packages/claude/.claude-plugin/marketplace.json +2 -2
  5. package/lib/host-packages/claude/openplanr/.claude-plugin/plugin.json +1 -1
  6. package/lib/host-packages/claude/openplanr/.openplanr-content.json +7 -7
  7. package/lib/host-packages/claude/openplanr/README.md +1 -1
  8. package/lib/host-packages/claude/openplanr/skills/design/scripts/design-share.mjs +105 -5
  9. package/lib/host-packages/claude/openplanr/skills/design-loop/scripts/design-share.mjs +105 -5
  10. package/lib/host-packages/claude/openplanr/skills/design-review/scripts/design-share.mjs +105 -5
  11. package/lib/host-packages/claude/openplanr/skills/plan/scripts/design-share.mjs +105 -5
  12. package/lib/host-packages/cursor/openplanr/.openplanr-content.json +6 -6
  13. package/lib/host-packages/cursor/openplanr/manifest.json +1 -1
  14. package/lib/host-packages/cursor/openplanr/rules/planr-design/scripts/design-share.mjs +105 -5
  15. package/lib/host-packages/cursor/openplanr/rules/planr-design-loop/scripts/design-share.mjs +105 -5
  16. package/lib/host-packages/cursor/openplanr/rules/planr-design-review/scripts/design-share.mjs +105 -5
  17. package/lib/host-packages/cursor/openplanr/rules/planr-plan/scripts/design-share.mjs +105 -5
  18. package/lib/host-packages/openai/.claude-plugin/marketplace.json +2 -2
  19. package/lib/host-packages/openai/openplanr/.codex-plugin/plugin.json +1 -1
  20. package/lib/host-packages/openai/openplanr/.openplanr-content.json +6 -6
  21. package/lib/host-packages/openai/openplanr/skills/design/scripts/design-share.mjs +105 -5
  22. package/lib/host-packages/openai/openplanr/skills/design-loop/scripts/design-share.mjs +105 -5
  23. package/lib/host-packages/openai/openplanr/skills/design-review/scripts/design-share.mjs +105 -5
  24. package/lib/host-packages/openai/openplanr/skills/plan/scripts/design-share.mjs +105 -5
  25. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.2640.4
4
+ ### Patch Changes
5
+
6
+ - fcc1c89: Design Share stores each repeated screen, script and style once and compresses the review before encrypting it, so large designs fit the upload limit. A 13-screen design at three sizes shrank from 19 MiB to 0.24 MiB. Links shared earlier keep opening.
7
+
3
8
  ## 2.2640.3
4
9
  ### Patch Changes
5
10
 
@@ -2,12 +2,12 @@
2
2
  "kind": "host-native-adapter-registry",
3
3
  "schemaVersion": "1.0.0",
4
4
  "protocolVersion": "1.8.0",
5
- "pipelineVersion": "0.55.4",
6
- "pluginVersion": "2.2640.3",
5
+ "pipelineVersion": "0.55.5",
6
+ "pluginVersion": "2.2640.4",
7
7
  "adapters": [
8
8
  {
9
9
  "id": "claude-code",
10
- "version": "2.2640.3",
10
+ "version": "2.2640.4",
11
11
  "capabilityLevel": "product",
12
12
  "installScopes": [
13
13
  "user",
@@ -19,7 +19,7 @@
19
19
  },
20
20
  {
21
21
  "id": "codex",
22
- "version": "2.2640.3",
22
+ "version": "2.2640.4",
23
23
  "capabilityLevel": "product",
24
24
  "installScopes": [
25
25
  "user",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  {
33
33
  "id": "cursor",
34
- "version": "2.2640.3",
34
+ "version": "2.2640.4",
35
35
  "capabilityLevel": "workflow",
36
36
  "installScopes": [
37
37
  "project"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "kind": "openplanr-capability-map",
3
3
  "schemaVersion": "1.0.0",
4
- "pluginVersion": "2.2640.3",
4
+ "pluginVersion": "2.2640.4",
5
5
  "families": [
6
6
  {
7
7
  "id": "planning",
@@ -5,14 +5,14 @@
5
5
  "name": "OpenPlanr"
6
6
  },
7
7
  "metadata": {
8
- "version": "2.2640.3",
8
+ "version": "2.2640.4",
9
9
  "description": "Generated local OpenPlanr package."
10
10
  },
11
11
  "plugins": [
12
12
  {
13
13
  "name": "planr",
14
14
  "source": "./openplanr",
15
- "version": "2.2640.3",
15
+ "version": "2.2640.4",
16
16
  "description": "Close the loop from intent to delivery. Plan, design, build, review, and operate from durable context in your repository.",
17
17
  "strict": true
18
18
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "planr",
3
3
  "displayName": "OpenPlanr",
4
- "version": "2.2640.3",
4
+ "version": "2.2640.4",
5
5
  "description": "Close the loop from intent to delivery. Plan, design, build, review, and operate from durable context in your repository.",
6
6
  "author": {
7
7
  "name": "OpenPlanr",
@@ -12,7 +12,7 @@
12
12
  },
13
13
  {
14
14
  "path": ".claude-plugin/plugin.json",
15
- "digest": "sha256:c851369ea7e66072fc2289aa3fe3b04048a79b0e5c7dbe6af24aa799f63d82de"
15
+ "digest": "sha256:3635e54a46deadee41df4178e18e306be863da02228361b1871feca2e4471f0e"
16
16
  },
17
17
  {
18
18
  "path": "agents/planr-backend.md",
@@ -52,7 +52,7 @@
52
52
  },
53
53
  {
54
54
  "path": "README.md",
55
- "digest": "sha256:2a68b4412e6247bd42055e0138eed6741aee5694dd0aed9e9c058505a6c89bb5"
55
+ "digest": "sha256:d56564195b147abfb1473d9e5312ef3fdc50c5ecf373619d4fff6ea6ccdb30f6"
56
56
  },
57
57
  {
58
58
  "path": "references/agents/shared/modes/default/backend.md",
@@ -416,7 +416,7 @@
416
416
  },
417
417
  {
418
418
  "path": "skills/design-loop/scripts/design-share.mjs",
419
- "digest": "sha256:b10d7ce9cdb3eb48b9aca803e4d2ecc4f8e477e91f4a0c6a3ae17a1f7985aa06"
419
+ "digest": "sha256:11de427bd02b89fdf6df5b3d8eaffa7c2025ab841712c7dfc0da6e5a3e41ca36"
420
420
  },
421
421
  {
422
422
  "path": "skills/design-loop/scripts/design.mjs",
@@ -624,7 +624,7 @@
624
624
  },
625
625
  {
626
626
  "path": "skills/design-review/scripts/design-share.mjs",
627
- "digest": "sha256:b10d7ce9cdb3eb48b9aca803e4d2ecc4f8e477e91f4a0c6a3ae17a1f7985aa06"
627
+ "digest": "sha256:11de427bd02b89fdf6df5b3d8eaffa7c2025ab841712c7dfc0da6e5a3e41ca36"
628
628
  },
629
629
  {
630
630
  "path": "skills/design-review/scripts/design.mjs",
@@ -832,7 +832,7 @@
832
832
  },
833
833
  {
834
834
  "path": "skills/design/scripts/design-share.mjs",
835
- "digest": "sha256:b10d7ce9cdb3eb48b9aca803e4d2ecc4f8e477e91f4a0c6a3ae17a1f7985aa06"
835
+ "digest": "sha256:11de427bd02b89fdf6df5b3d8eaffa7c2025ab841712c7dfc0da6e5a3e41ca36"
836
836
  },
837
837
  {
838
838
  "path": "skills/design/scripts/design.mjs",
@@ -1072,7 +1072,7 @@
1072
1072
  },
1073
1073
  {
1074
1074
  "path": "skills/plan/scripts/design-share.mjs",
1075
- "digest": "sha256:b10d7ce9cdb3eb48b9aca803e4d2ecc4f8e477e91f4a0c6a3ae17a1f7985aa06"
1075
+ "digest": "sha256:11de427bd02b89fdf6df5b3d8eaffa7c2025ab841712c7dfc0da6e5a3e41ca36"
1076
1076
  },
1077
1077
  {
1078
1078
  "path": "skills/plan/scripts/design.mjs",
@@ -1287,5 +1287,5 @@
1287
1287
  "digest": "sha256:06048f24128098919931db60272e0e14fe51bcbeba4b499db587e3b89d7bb3b9"
1288
1288
  }
1289
1289
  ],
1290
- "contentDigest": "sha256:93f808cc8a0b0719d52fa3d0a9bd6cc5536187c494d269d4c6405129a7ef3d42"
1290
+ "contentDigest": "sha256:6f6a89edee4d50fce3783c637e4331d5a0fdd0e6fb251ce05f725b216d879519"
1291
1291
  }
@@ -17,7 +17,7 @@ Follow with `/planr:plan` to decompose the specification into stories and tasks,
17
17
  ## Install the CLI
18
18
 
19
19
  Several skills call the deterministic `planr` CLI from the `openplanr` npm package, which ships
20
- this plugin at the same version (2.2640.3):
20
+ this plugin at the same version (2.2640.4):
21
21
 
22
22
  ```bash
23
23
  npm install -g openplanr
@@ -870,6 +870,104 @@ async function unseal(value, rawKey, context, limit = DESIGN_WORKSPACE_MAX_BYTES
870
870
  );
871
871
  return JSON.parse(decoder.decode(plaintext));
872
872
  }
873
+ var PACKED_BUNDLE_KIND = "openplanr-design-review-bundle-packed";
874
+ var PACKED_BUNDLE_MAX_BYTES = 128 * 1024 * 1024;
875
+ var SHARED_BLOCK_MIN_LENGTH = 2048;
876
+ var sharedBlockPattern = /(<(script|style)\b[^>]*>)([\s\S]*?)<\/\2\s*>/gi;
877
+ async function deflateRaw(bytes) {
878
+ const stream = new Blob([bytes]).stream().pipeThrough(new CompressionStream("deflate-raw"));
879
+ return new Uint8Array(await new Response(stream).arrayBuffer());
880
+ }
881
+ async function inflateRaw(bytes, limit) {
882
+ const reader = new Blob([bytes]).stream().pipeThrough(new DecompressionStream("deflate-raw")).getReader();
883
+ const chunks = [];
884
+ let size = 0;
885
+ for (; ; ) {
886
+ const { done, value } = await reader.read();
887
+ if (done) break;
888
+ size += value.byteLength;
889
+ if (size > limit) {
890
+ await reader.cancel();
891
+ throw new RangeError("The shared design expands beyond its size limit.");
892
+ }
893
+ chunks.push(value);
894
+ }
895
+ const inflated = new Uint8Array(size);
896
+ let offset = 0;
897
+ for (const chunk of chunks) {
898
+ inflated.set(chunk, offset);
899
+ offset += chunk.byteLength;
900
+ }
901
+ return inflated;
902
+ }
903
+ async function packDesignReviewBundle(bundle) {
904
+ const pages = [];
905
+ const pageIndex = /* @__PURE__ */ new Map();
906
+ const blocks = [];
907
+ const blockIndex = /* @__PURE__ */ new Map();
908
+ const segmentsOf = (html) => {
909
+ const segments = [];
910
+ let offset = 0;
911
+ for (const match of html.matchAll(sharedBlockPattern)) {
912
+ const body = match[3];
913
+ if (body.length < SHARED_BLOCK_MIN_LENGTH) continue;
914
+ const start = match.index + match[1].length;
915
+ segments.push(html.slice(offset, start));
916
+ if (!blockIndex.has(body)) blockIndex.set(body, blocks.push(body) - 1);
917
+ segments.push(blockIndex.get(body));
918
+ offset = start + body.length;
919
+ }
920
+ segments.push(html.slice(offset));
921
+ return segments;
922
+ };
923
+ const artifactPages = [];
924
+ const artifacts = bundle.envelope.artifacts.map(({ html, ...artifact }) => {
925
+ if (!pageIndex.has(html)) pageIndex.set(html, pages.push(segmentsOf(html)) - 1);
926
+ artifactPages.push(pageIndex.get(html));
927
+ return artifact;
928
+ });
929
+ const packed = {
930
+ bundle: { ...bundle, envelope: { ...bundle.envelope, artifacts } },
931
+ artifactPages,
932
+ pages,
933
+ blocks
934
+ };
935
+ return {
936
+ kind: PACKED_BUNDLE_KIND,
937
+ version: 1,
938
+ data: encodeWorkspaceBytes(await deflateRaw(encoder.encode(JSON.stringify(packed))))
939
+ };
940
+ }
941
+ async function unpackDesignReviewBundle(value, { maxBytes = PACKED_BUNDLE_MAX_BYTES } = {}) {
942
+ if (value?.kind !== PACKED_BUNDLE_KIND) return value;
943
+ if (value.version !== 1 || typeof value.data !== "string")
944
+ throw new Error("The shared design uses an unsupported packing.");
945
+ const { bundle, artifactPages, pages, blocks } = JSON.parse(
946
+ decoder.decode(await inflateRaw(decodeWorkspaceBytes(value.data), maxBytes))
947
+ );
948
+ const invalid2 = () => new Error("The shared design packing is invalid.");
949
+ if (!Array.isArray(bundle?.envelope?.artifacts) || !Array.isArray(pages) || !Array.isArray(blocks) || !Array.isArray(artifactPages) || artifactPages.length !== bundle.envelope.artifacts.length)
950
+ throw invalid2();
951
+ let expanded = 0;
952
+ const html = pages.map((segments) => {
953
+ if (!Array.isArray(segments)) throw invalid2();
954
+ const page = segments.map((segment) => {
955
+ if (typeof segment === "string") return segment;
956
+ if (!Number.isInteger(segment) || typeof blocks[segment] !== "string") throw invalid2();
957
+ return blocks[segment];
958
+ }).join("");
959
+ expanded += page.length;
960
+ if (expanded > maxBytes)
961
+ throw new RangeError("The shared design expands beyond its size limit.");
962
+ return page;
963
+ });
964
+ const artifacts = bundle.envelope.artifacts.map((artifact, index) => {
965
+ const page = html[artifactPages[index]];
966
+ if (page === void 0) throw invalid2();
967
+ return { ...artifact, html: page };
968
+ });
969
+ return { ...bundle, envelope: { ...bundle.envelope, artifacts } };
970
+ }
873
971
  var keyringContext = (id, epoch) => ({ type: "keyring", workspaceId: id, epoch });
874
972
  var revisionContext = (id, revision) => ({
875
973
  type: "revision",
@@ -914,7 +1012,7 @@ async function prepareRevision(custody, bundle) {
914
1012
  {
915
1013
  ...header,
916
1014
  ...await seal(
917
- bundle,
1015
+ await packDesignReviewBundle(bundle),
918
1016
  decodeWorkspaceBytes(custody.keys[custody.epoch]),
919
1017
  revisionContext(custody.id, header)
920
1018
  )
@@ -1084,10 +1182,12 @@ async function decryptWorkspaceRevision(access, revisionId = access.currentRevis
1084
1182
  throw new Error("The published design signature is invalid.");
1085
1183
  if (!access.keys[revision.epoch]) throw new Error("The access token cannot open this revision.");
1086
1184
  const bundle = assertDesignReviewBundle(
1087
- await unseal(
1088
- revision,
1089
- decodeWorkspaceBytes(access.keys[revision.epoch]),
1090
- revisionContext(access.id, revision)
1185
+ await unpackDesignReviewBundle(
1186
+ await unseal(
1187
+ revision,
1188
+ decodeWorkspaceBytes(access.keys[revision.epoch]),
1189
+ revisionContext(access.id, revision)
1190
+ )
1091
1191
  )
1092
1192
  );
1093
1193
  if (workspaceEnvelopeDigest(bundle.envelope) !== revision.reviewOf)
@@ -870,6 +870,104 @@ async function unseal(value, rawKey, context, limit = DESIGN_WORKSPACE_MAX_BYTES
870
870
  );
871
871
  return JSON.parse(decoder.decode(plaintext));
872
872
  }
873
+ var PACKED_BUNDLE_KIND = "openplanr-design-review-bundle-packed";
874
+ var PACKED_BUNDLE_MAX_BYTES = 128 * 1024 * 1024;
875
+ var SHARED_BLOCK_MIN_LENGTH = 2048;
876
+ var sharedBlockPattern = /(<(script|style)\b[^>]*>)([\s\S]*?)<\/\2\s*>/gi;
877
+ async function deflateRaw(bytes) {
878
+ const stream = new Blob([bytes]).stream().pipeThrough(new CompressionStream("deflate-raw"));
879
+ return new Uint8Array(await new Response(stream).arrayBuffer());
880
+ }
881
+ async function inflateRaw(bytes, limit) {
882
+ const reader = new Blob([bytes]).stream().pipeThrough(new DecompressionStream("deflate-raw")).getReader();
883
+ const chunks = [];
884
+ let size = 0;
885
+ for (; ; ) {
886
+ const { done, value } = await reader.read();
887
+ if (done) break;
888
+ size += value.byteLength;
889
+ if (size > limit) {
890
+ await reader.cancel();
891
+ throw new RangeError("The shared design expands beyond its size limit.");
892
+ }
893
+ chunks.push(value);
894
+ }
895
+ const inflated = new Uint8Array(size);
896
+ let offset = 0;
897
+ for (const chunk of chunks) {
898
+ inflated.set(chunk, offset);
899
+ offset += chunk.byteLength;
900
+ }
901
+ return inflated;
902
+ }
903
+ async function packDesignReviewBundle(bundle) {
904
+ const pages = [];
905
+ const pageIndex = /* @__PURE__ */ new Map();
906
+ const blocks = [];
907
+ const blockIndex = /* @__PURE__ */ new Map();
908
+ const segmentsOf = (html) => {
909
+ const segments = [];
910
+ let offset = 0;
911
+ for (const match of html.matchAll(sharedBlockPattern)) {
912
+ const body = match[3];
913
+ if (body.length < SHARED_BLOCK_MIN_LENGTH) continue;
914
+ const start = match.index + match[1].length;
915
+ segments.push(html.slice(offset, start));
916
+ if (!blockIndex.has(body)) blockIndex.set(body, blocks.push(body) - 1);
917
+ segments.push(blockIndex.get(body));
918
+ offset = start + body.length;
919
+ }
920
+ segments.push(html.slice(offset));
921
+ return segments;
922
+ };
923
+ const artifactPages = [];
924
+ const artifacts = bundle.envelope.artifacts.map(({ html, ...artifact }) => {
925
+ if (!pageIndex.has(html)) pageIndex.set(html, pages.push(segmentsOf(html)) - 1);
926
+ artifactPages.push(pageIndex.get(html));
927
+ return artifact;
928
+ });
929
+ const packed = {
930
+ bundle: { ...bundle, envelope: { ...bundle.envelope, artifacts } },
931
+ artifactPages,
932
+ pages,
933
+ blocks
934
+ };
935
+ return {
936
+ kind: PACKED_BUNDLE_KIND,
937
+ version: 1,
938
+ data: encodeWorkspaceBytes(await deflateRaw(encoder.encode(JSON.stringify(packed))))
939
+ };
940
+ }
941
+ async function unpackDesignReviewBundle(value, { maxBytes = PACKED_BUNDLE_MAX_BYTES } = {}) {
942
+ if (value?.kind !== PACKED_BUNDLE_KIND) return value;
943
+ if (value.version !== 1 || typeof value.data !== "string")
944
+ throw new Error("The shared design uses an unsupported packing.");
945
+ const { bundle, artifactPages, pages, blocks } = JSON.parse(
946
+ decoder.decode(await inflateRaw(decodeWorkspaceBytes(value.data), maxBytes))
947
+ );
948
+ const invalid2 = () => new Error("The shared design packing is invalid.");
949
+ if (!Array.isArray(bundle?.envelope?.artifacts) || !Array.isArray(pages) || !Array.isArray(blocks) || !Array.isArray(artifactPages) || artifactPages.length !== bundle.envelope.artifacts.length)
950
+ throw invalid2();
951
+ let expanded = 0;
952
+ const html = pages.map((segments) => {
953
+ if (!Array.isArray(segments)) throw invalid2();
954
+ const page = segments.map((segment) => {
955
+ if (typeof segment === "string") return segment;
956
+ if (!Number.isInteger(segment) || typeof blocks[segment] !== "string") throw invalid2();
957
+ return blocks[segment];
958
+ }).join("");
959
+ expanded += page.length;
960
+ if (expanded > maxBytes)
961
+ throw new RangeError("The shared design expands beyond its size limit.");
962
+ return page;
963
+ });
964
+ const artifacts = bundle.envelope.artifacts.map((artifact, index) => {
965
+ const page = html[artifactPages[index]];
966
+ if (page === void 0) throw invalid2();
967
+ return { ...artifact, html: page };
968
+ });
969
+ return { ...bundle, envelope: { ...bundle.envelope, artifacts } };
970
+ }
873
971
  var keyringContext = (id, epoch) => ({ type: "keyring", workspaceId: id, epoch });
874
972
  var revisionContext = (id, revision) => ({
875
973
  type: "revision",
@@ -914,7 +1012,7 @@ async function prepareRevision(custody, bundle) {
914
1012
  {
915
1013
  ...header,
916
1014
  ...await seal(
917
- bundle,
1015
+ await packDesignReviewBundle(bundle),
918
1016
  decodeWorkspaceBytes(custody.keys[custody.epoch]),
919
1017
  revisionContext(custody.id, header)
920
1018
  )
@@ -1084,10 +1182,12 @@ async function decryptWorkspaceRevision(access, revisionId = access.currentRevis
1084
1182
  throw new Error("The published design signature is invalid.");
1085
1183
  if (!access.keys[revision.epoch]) throw new Error("The access token cannot open this revision.");
1086
1184
  const bundle = assertDesignReviewBundle(
1087
- await unseal(
1088
- revision,
1089
- decodeWorkspaceBytes(access.keys[revision.epoch]),
1090
- revisionContext(access.id, revision)
1185
+ await unpackDesignReviewBundle(
1186
+ await unseal(
1187
+ revision,
1188
+ decodeWorkspaceBytes(access.keys[revision.epoch]),
1189
+ revisionContext(access.id, revision)
1190
+ )
1091
1191
  )
1092
1192
  );
1093
1193
  if (workspaceEnvelopeDigest(bundle.envelope) !== revision.reviewOf)
@@ -870,6 +870,104 @@ async function unseal(value, rawKey, context, limit = DESIGN_WORKSPACE_MAX_BYTES
870
870
  );
871
871
  return JSON.parse(decoder.decode(plaintext));
872
872
  }
873
+ var PACKED_BUNDLE_KIND = "openplanr-design-review-bundle-packed";
874
+ var PACKED_BUNDLE_MAX_BYTES = 128 * 1024 * 1024;
875
+ var SHARED_BLOCK_MIN_LENGTH = 2048;
876
+ var sharedBlockPattern = /(<(script|style)\b[^>]*>)([\s\S]*?)<\/\2\s*>/gi;
877
+ async function deflateRaw(bytes) {
878
+ const stream = new Blob([bytes]).stream().pipeThrough(new CompressionStream("deflate-raw"));
879
+ return new Uint8Array(await new Response(stream).arrayBuffer());
880
+ }
881
+ async function inflateRaw(bytes, limit) {
882
+ const reader = new Blob([bytes]).stream().pipeThrough(new DecompressionStream("deflate-raw")).getReader();
883
+ const chunks = [];
884
+ let size = 0;
885
+ for (; ; ) {
886
+ const { done, value } = await reader.read();
887
+ if (done) break;
888
+ size += value.byteLength;
889
+ if (size > limit) {
890
+ await reader.cancel();
891
+ throw new RangeError("The shared design expands beyond its size limit.");
892
+ }
893
+ chunks.push(value);
894
+ }
895
+ const inflated = new Uint8Array(size);
896
+ let offset = 0;
897
+ for (const chunk of chunks) {
898
+ inflated.set(chunk, offset);
899
+ offset += chunk.byteLength;
900
+ }
901
+ return inflated;
902
+ }
903
+ async function packDesignReviewBundle(bundle) {
904
+ const pages = [];
905
+ const pageIndex = /* @__PURE__ */ new Map();
906
+ const blocks = [];
907
+ const blockIndex = /* @__PURE__ */ new Map();
908
+ const segmentsOf = (html) => {
909
+ const segments = [];
910
+ let offset = 0;
911
+ for (const match of html.matchAll(sharedBlockPattern)) {
912
+ const body = match[3];
913
+ if (body.length < SHARED_BLOCK_MIN_LENGTH) continue;
914
+ const start = match.index + match[1].length;
915
+ segments.push(html.slice(offset, start));
916
+ if (!blockIndex.has(body)) blockIndex.set(body, blocks.push(body) - 1);
917
+ segments.push(blockIndex.get(body));
918
+ offset = start + body.length;
919
+ }
920
+ segments.push(html.slice(offset));
921
+ return segments;
922
+ };
923
+ const artifactPages = [];
924
+ const artifacts = bundle.envelope.artifacts.map(({ html, ...artifact }) => {
925
+ if (!pageIndex.has(html)) pageIndex.set(html, pages.push(segmentsOf(html)) - 1);
926
+ artifactPages.push(pageIndex.get(html));
927
+ return artifact;
928
+ });
929
+ const packed = {
930
+ bundle: { ...bundle, envelope: { ...bundle.envelope, artifacts } },
931
+ artifactPages,
932
+ pages,
933
+ blocks
934
+ };
935
+ return {
936
+ kind: PACKED_BUNDLE_KIND,
937
+ version: 1,
938
+ data: encodeWorkspaceBytes(await deflateRaw(encoder.encode(JSON.stringify(packed))))
939
+ };
940
+ }
941
+ async function unpackDesignReviewBundle(value, { maxBytes = PACKED_BUNDLE_MAX_BYTES } = {}) {
942
+ if (value?.kind !== PACKED_BUNDLE_KIND) return value;
943
+ if (value.version !== 1 || typeof value.data !== "string")
944
+ throw new Error("The shared design uses an unsupported packing.");
945
+ const { bundle, artifactPages, pages, blocks } = JSON.parse(
946
+ decoder.decode(await inflateRaw(decodeWorkspaceBytes(value.data), maxBytes))
947
+ );
948
+ const invalid2 = () => new Error("The shared design packing is invalid.");
949
+ if (!Array.isArray(bundle?.envelope?.artifacts) || !Array.isArray(pages) || !Array.isArray(blocks) || !Array.isArray(artifactPages) || artifactPages.length !== bundle.envelope.artifacts.length)
950
+ throw invalid2();
951
+ let expanded = 0;
952
+ const html = pages.map((segments) => {
953
+ if (!Array.isArray(segments)) throw invalid2();
954
+ const page = segments.map((segment) => {
955
+ if (typeof segment === "string") return segment;
956
+ if (!Number.isInteger(segment) || typeof blocks[segment] !== "string") throw invalid2();
957
+ return blocks[segment];
958
+ }).join("");
959
+ expanded += page.length;
960
+ if (expanded > maxBytes)
961
+ throw new RangeError("The shared design expands beyond its size limit.");
962
+ return page;
963
+ });
964
+ const artifacts = bundle.envelope.artifacts.map((artifact, index) => {
965
+ const page = html[artifactPages[index]];
966
+ if (page === void 0) throw invalid2();
967
+ return { ...artifact, html: page };
968
+ });
969
+ return { ...bundle, envelope: { ...bundle.envelope, artifacts } };
970
+ }
873
971
  var keyringContext = (id, epoch) => ({ type: "keyring", workspaceId: id, epoch });
874
972
  var revisionContext = (id, revision) => ({
875
973
  type: "revision",
@@ -914,7 +1012,7 @@ async function prepareRevision(custody, bundle) {
914
1012
  {
915
1013
  ...header,
916
1014
  ...await seal(
917
- bundle,
1015
+ await packDesignReviewBundle(bundle),
918
1016
  decodeWorkspaceBytes(custody.keys[custody.epoch]),
919
1017
  revisionContext(custody.id, header)
920
1018
  )
@@ -1084,10 +1182,12 @@ async function decryptWorkspaceRevision(access, revisionId = access.currentRevis
1084
1182
  throw new Error("The published design signature is invalid.");
1085
1183
  if (!access.keys[revision.epoch]) throw new Error("The access token cannot open this revision.");
1086
1184
  const bundle = assertDesignReviewBundle(
1087
- await unseal(
1088
- revision,
1089
- decodeWorkspaceBytes(access.keys[revision.epoch]),
1090
- revisionContext(access.id, revision)
1185
+ await unpackDesignReviewBundle(
1186
+ await unseal(
1187
+ revision,
1188
+ decodeWorkspaceBytes(access.keys[revision.epoch]),
1189
+ revisionContext(access.id, revision)
1190
+ )
1091
1191
  )
1092
1192
  );
1093
1193
  if (workspaceEnvelopeDigest(bundle.envelope) !== revision.reviewOf)
@@ -870,6 +870,104 @@ async function unseal(value, rawKey, context, limit = DESIGN_WORKSPACE_MAX_BYTES
870
870
  );
871
871
  return JSON.parse(decoder.decode(plaintext));
872
872
  }
873
+ var PACKED_BUNDLE_KIND = "openplanr-design-review-bundle-packed";
874
+ var PACKED_BUNDLE_MAX_BYTES = 128 * 1024 * 1024;
875
+ var SHARED_BLOCK_MIN_LENGTH = 2048;
876
+ var sharedBlockPattern = /(<(script|style)\b[^>]*>)([\s\S]*?)<\/\2\s*>/gi;
877
+ async function deflateRaw(bytes) {
878
+ const stream = new Blob([bytes]).stream().pipeThrough(new CompressionStream("deflate-raw"));
879
+ return new Uint8Array(await new Response(stream).arrayBuffer());
880
+ }
881
+ async function inflateRaw(bytes, limit) {
882
+ const reader = new Blob([bytes]).stream().pipeThrough(new DecompressionStream("deflate-raw")).getReader();
883
+ const chunks = [];
884
+ let size = 0;
885
+ for (; ; ) {
886
+ const { done, value } = await reader.read();
887
+ if (done) break;
888
+ size += value.byteLength;
889
+ if (size > limit) {
890
+ await reader.cancel();
891
+ throw new RangeError("The shared design expands beyond its size limit.");
892
+ }
893
+ chunks.push(value);
894
+ }
895
+ const inflated = new Uint8Array(size);
896
+ let offset = 0;
897
+ for (const chunk of chunks) {
898
+ inflated.set(chunk, offset);
899
+ offset += chunk.byteLength;
900
+ }
901
+ return inflated;
902
+ }
903
+ async function packDesignReviewBundle(bundle) {
904
+ const pages = [];
905
+ const pageIndex = /* @__PURE__ */ new Map();
906
+ const blocks = [];
907
+ const blockIndex = /* @__PURE__ */ new Map();
908
+ const segmentsOf = (html) => {
909
+ const segments = [];
910
+ let offset = 0;
911
+ for (const match of html.matchAll(sharedBlockPattern)) {
912
+ const body = match[3];
913
+ if (body.length < SHARED_BLOCK_MIN_LENGTH) continue;
914
+ const start = match.index + match[1].length;
915
+ segments.push(html.slice(offset, start));
916
+ if (!blockIndex.has(body)) blockIndex.set(body, blocks.push(body) - 1);
917
+ segments.push(blockIndex.get(body));
918
+ offset = start + body.length;
919
+ }
920
+ segments.push(html.slice(offset));
921
+ return segments;
922
+ };
923
+ const artifactPages = [];
924
+ const artifacts = bundle.envelope.artifacts.map(({ html, ...artifact }) => {
925
+ if (!pageIndex.has(html)) pageIndex.set(html, pages.push(segmentsOf(html)) - 1);
926
+ artifactPages.push(pageIndex.get(html));
927
+ return artifact;
928
+ });
929
+ const packed = {
930
+ bundle: { ...bundle, envelope: { ...bundle.envelope, artifacts } },
931
+ artifactPages,
932
+ pages,
933
+ blocks
934
+ };
935
+ return {
936
+ kind: PACKED_BUNDLE_KIND,
937
+ version: 1,
938
+ data: encodeWorkspaceBytes(await deflateRaw(encoder.encode(JSON.stringify(packed))))
939
+ };
940
+ }
941
+ async function unpackDesignReviewBundle(value, { maxBytes = PACKED_BUNDLE_MAX_BYTES } = {}) {
942
+ if (value?.kind !== PACKED_BUNDLE_KIND) return value;
943
+ if (value.version !== 1 || typeof value.data !== "string")
944
+ throw new Error("The shared design uses an unsupported packing.");
945
+ const { bundle, artifactPages, pages, blocks } = JSON.parse(
946
+ decoder.decode(await inflateRaw(decodeWorkspaceBytes(value.data), maxBytes))
947
+ );
948
+ const invalid2 = () => new Error("The shared design packing is invalid.");
949
+ if (!Array.isArray(bundle?.envelope?.artifacts) || !Array.isArray(pages) || !Array.isArray(blocks) || !Array.isArray(artifactPages) || artifactPages.length !== bundle.envelope.artifacts.length)
950
+ throw invalid2();
951
+ let expanded = 0;
952
+ const html = pages.map((segments) => {
953
+ if (!Array.isArray(segments)) throw invalid2();
954
+ const page = segments.map((segment) => {
955
+ if (typeof segment === "string") return segment;
956
+ if (!Number.isInteger(segment) || typeof blocks[segment] !== "string") throw invalid2();
957
+ return blocks[segment];
958
+ }).join("");
959
+ expanded += page.length;
960
+ if (expanded > maxBytes)
961
+ throw new RangeError("The shared design expands beyond its size limit.");
962
+ return page;
963
+ });
964
+ const artifacts = bundle.envelope.artifacts.map((artifact, index) => {
965
+ const page = html[artifactPages[index]];
966
+ if (page === void 0) throw invalid2();
967
+ return { ...artifact, html: page };
968
+ });
969
+ return { ...bundle, envelope: { ...bundle.envelope, artifacts } };
970
+ }
873
971
  var keyringContext = (id, epoch) => ({ type: "keyring", workspaceId: id, epoch });
874
972
  var revisionContext = (id, revision) => ({
875
973
  type: "revision",
@@ -914,7 +1012,7 @@ async function prepareRevision(custody, bundle) {
914
1012
  {
915
1013
  ...header,
916
1014
  ...await seal(
917
- bundle,
1015
+ await packDesignReviewBundle(bundle),
918
1016
  decodeWorkspaceBytes(custody.keys[custody.epoch]),
919
1017
  revisionContext(custody.id, header)
920
1018
  )
@@ -1084,10 +1182,12 @@ async function decryptWorkspaceRevision(access, revisionId = access.currentRevis
1084
1182
  throw new Error("The published design signature is invalid.");
1085
1183
  if (!access.keys[revision.epoch]) throw new Error("The access token cannot open this revision.");
1086
1184
  const bundle = assertDesignReviewBundle(
1087
- await unseal(
1088
- revision,
1089
- decodeWorkspaceBytes(access.keys[revision.epoch]),
1090
- revisionContext(access.id, revision)
1185
+ await unpackDesignReviewBundle(
1186
+ await unseal(
1187
+ revision,
1188
+ decodeWorkspaceBytes(access.keys[revision.epoch]),
1189
+ revisionContext(access.id, revision)
1190
+ )
1091
1191
  )
1092
1192
  );
1093
1193
  if (workspaceEnvelopeDigest(bundle.envelope) !== revision.reviewOf)