サンプル
prosemirror-changeset 2.4.3
検証済みサンプル — npm prosemirror-changeset 2.4.3. node 22 · linux debian/x64 · docker で contract を実行し、成功しました: Change and Span represent replaced text ranges with…
sha256:14bd4500c487b038529ba4533a7eca368464e86a3facc5d3b37dc3b7fd0c7f86
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 1
- ビルドした署名鍵
- 1
宣言された環境
linux 24 · ubuntu · glibc 2.39 x64 npm
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-19 |
ケース
HOW- ゴール
- verify pkg:npm/prosemirror-changeset@2.4.3
- 作成日
- 2026-09-17T15:40:58Z
コントラクト
- Change and Span represent replaced text ranges with length and metadata
- Change.merge merges sequential changesets and combines span metadata
- Change.merge cancels out deletions that undo insertions
- Change toJSON and Change.fromJSON serialize and deserialize change instances preserving ranges and metadata
- ChangeSet.create initializes a change set tracking changes for a document
- ChangeSet.map transforms metadata across deleted and inserted spans
- ChangeSet.changedRange computes the bounding range of differences between changesets
- simplifyChanges preserves non-adjacent changes and handles empty change lists
ファイル
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
ソース
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify pkg:npm/prosemirror-changeset@2.4.3
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/prosemirror-changeset@2.4.3
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:b3968001dbfc9a203fe337333e52b1a1908e4fa6e9dfa94fcd68975fce1954be","contract":["Change and Span represent replaced text ranges with length and metadata","Change.merge merges sequential changesets and combines span metadata","Change.merge cancels out deletions that undo insertions","Change toJSON and Change.fromJSON serialize and deserialize change instances preserving ranges and metadata","ChangeSet.create initializes a change set tracking changes for a document","ChangeSet.map transforms metadata across deleted and inserted spans","ChangeSet.changedRange computes the bounding range of differences between changesets","simplifyChanges preserves non-adjacent changes and handles empty change lists"],"goal":"verify pkg:npm/prosemirror-changeset@2.4.3","kind":"HOW","packages":["pkg:npm/prosemirror-changeset@2.4.3"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/prosemirror-changeset@2.4.3"],"schemaVersion":1,"subject":"pkg:npm/prosemirror-changeset@2.4.3","verifierAdapter":"node-typescript@1"}
import { Change, Span, ChangeSet, simplifyChanges } from 'prosemirror-changeset';
export function createChange(fromA, toA, fromB, toB, deleted, inserted) {
return new Change(fromA, toA, fromB, toB, deleted, inserted);
}
export function createSpan(length, data) {
return new Span(length, data);
}
export function mergeChanges(x, y, combine) {
return Change.merge(x, y, combine);
}
export function createChangeSet(doc, combine, tokenEncoder, changes) {
return ChangeSet.create(doc, combine, tokenEncoder, changes);
}
export { Change, Span, ChangeSet, simplifyChanges };
{
"name": "prosemirror-changeset-sample",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "prosemirror-changeset-sample",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"prosemirror-changeset": "2.4.3"
}
},
"node_modules/orderedmap": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/orderedmap/-/orderedmap-2.1.1.tgz",
"integrity": "sha512-TvAWxi0nDe1j/rtMcWcIj94+Ffe6n7zhow33h40SKxmsmozs6dz/e+EajymfoFcHd7sxNn8yHM8839uixMOV6g==",
"license": "MIT"
},
"node_modules/prosemirror-changeset": {
"version": "2.4.3",
"resolved": "https://registry.npmjs.org/prosemirror-changeset/-/prosemirror-changeset-2.4.3.tgz",
"integrity": "sha512-J8jqUZ1xybXKY44v3K0c8m8ZTIqJPVT34t2UVyxv4VEWoNd5C9t5Y52GNuMriRJ3IpNxOSE2R60vN4qBrTMcyQ==",
"license": "MIT",
"dependencies": {
"prosemirror-transform": "^1.0.0"
}
},
"node_modules/prosemirror-model": {
"version": "1.25.11",
"resolved": "https://registry.npmjs.org/prosemirror-model/-/prosemirror-model-1.25.11.tgz",
"integrity": "sha512-QWg9RhnpLlogAmp3p96uEFrE5txQpFynd4vhBAELkwgOCWQs/X0yCzB3/hrHqiPwf91RG5KyWq6553zs9JqIOQ==",
"license": "MIT",
"dependencies": {
"orderedmap": "^2.0.0"
}
},
"node_modules/prosemirror-transform": {
"version": "1.12.1",
"resolved": "https://registry.npmjs.org/prosemirror-transform/-/prosemirror-transform-1.12.1.tgz",
"integrity": "sha512-t4F5615FycnCqsX7ShTUs8+jfnwcf46kuFRvSl/3qFx2QTZ4DjgowesLHQXcFP7G//TjesqZG3WtgL7vdyVJyA==",
"license": "MIT",
"dependencies": {
"prosemirror-model": "^1.21.0"
}
}
}
}
{
"name": "prosemirror-changeset-sample",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification for prosemirror-changeset",
"type": "module",
"main": "index.js",
"license": "MIT-0",
"dependencies": {
"prosemirror-changeset": "2.4.3"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/prosemirror-changeset@2.4.3",
"kind": "HOW",
"packages": [
"pkg:npm/prosemirror-changeset@2.4.3"
]
}
import assert from 'node:assert';
import { Change, Span, ChangeSet, simplifyChanges } from 'prosemirror-changeset';
import {
createChange,
createSpan,
mergeChanges,
createChangeSet
} from '../index.js';
// 1. Change and Span represent replaced text ranges with length and metadata
const delSpan = createSpan(5, { id: 'meta-1' });
const insSpan = createSpan(3, { id: 'meta-2' });
assert.strictEqual(delSpan.length, 5);
assert.strictEqual(delSpan.data.id, 'meta-1');
assert.strictEqual(insSpan.length, 3);
assert.strictEqual(insSpan.data.id, 'meta-2');
const change1 = createChange(10, 15, 10, 13, [delSpan], [insSpan]);
assert.strictEqual(change1.fromA, 10);
assert.strictEqual(change1.toA, 15);
assert.strictEqual(change1.fromB, 10);
assert.strictEqual(change1.toB, 13);
assert.strictEqual(change1.lenA, 5);
assert.strictEqual(change1.lenB, 3);
assert.strictEqual(change1.deleted.length, 1);
assert.strictEqual(change1.inserted.length, 1);
// 2. Change.merge merges sequential changesets and combines span metadata
const stepA = [createChange(1, 1, 1, 2, [], [createSpan(1, 'v1')])];
const stepB = [createChange(1, 1, 1, 2, [], [createSpan(1, 'v1')])];
const merged = mergeChanges(stepA, stepB, (a, b) => (a === b ? a : null));
assert.strictEqual(merged.length, 1);
assert.strictEqual(merged[0].fromA, 1);
assert.strictEqual(merged[0].toA, 1);
assert.strictEqual(merged[0].fromB, 1);
assert.strictEqual(merged[0].toB, 3);
assert.strictEqual(merged[0].inserted.length, 1);
assert.strictEqual(merged[0].inserted[0].length, 2);
assert.strictEqual(merged[0].inserted[0].data, 'v1');
// 3. Change.merge cancels out deletions that undo insertions
const insertChange = [createChange(2, 2, 2, 5, [], [createSpan(3, 'temp')])];
const deleteChange = [createChange(2, 5, 2, 2, [createSpan(3, 'temp')], [])];
const canceled = mergeChanges(insertChange, deleteChange, (a, b) => a);
assert.deepStrictEqual(canceled, []);
// 4. Change toJSON and Change.fromJSON serialize and deserialize change instances preserving ranges and metadata
const sampleChange = createChange(4, 9, 4, 11, [createSpan(5, 'removed')], [createSpan(7, 'added')]);
const json = JSON.parse(JSON.stringify(sampleChange.toJSON()));
const restored = Change.fromJSON(json);
assert.strictEqual(restored.fromA, 4);
assert.strictEqual(restored.toA, 9);
assert.strictEqual(restored.fromB, 4);
assert.strictEqual(restored.toB, 11);
assert.strictEqual(restored.deleted.length, 1);
assert.strictEqual(restored.deleted[0].length, 5);
assert.strictEqual(restored.deleted[0].data, 'removed');
assert.strictEqual(restored.inserted.length, 1);
assert.strictEqual(restored.inserted[0].length, 7);
assert.strictEqual(restored.inserted[0].data, 'added');
assert(restored instanceof Change);
assert(restored.deleted[0] instanceof Span);
// 5. ChangeSet.create initializes a change set tracking changes for a document
const docMock = { content: { size: 0, childCount: 0 } };
const changeSet = createChangeSet(docMock, (a, b) => (a === b ? a : null), undefined, [sampleChange]);
assert.strictEqual(changeSet.startDoc, docMock);
assert.strictEqual(changeSet.changes.length, 1);
assert.strictEqual(changeSet.changes[0], sampleChange);
// 6. ChangeSet.map transforms metadata across deleted and inserted spans
const mapped = changeSet.map(span => (typeof span.data === 'string' ? span.data.toUpperCase() : span.data));
assert.strictEqual(mapped.changes[0].deleted[0].data, 'REMOVED');
assert.strictEqual(mapped.changes[0].inserted[0].data, 'ADDED');
// 7. ChangeSet.changedRange computes the bounding range of differences between changesets
const baseChange = createChange(0, 5, 0, 5, [createSpan(5, 'shared')], [createSpan(5, 'shared')]);
const diffA = createChange(10, 15, 10, 15, [createSpan(5, 'delA')], [createSpan(5, 'insA')]);
const diffB = createChange(10, 15, 10, 15, [createSpan(5, 'delB')], [createSpan(5, 'insB')]);
const setA = createChangeSet(docMock, (a, b) => (a === b ? a : null), undefined, [baseChange, diffA]);
const setB = createChangeSet(docMock, (a, b) => (a === b ? a : null), undefined, [baseChange, diffB]);
const diffRange = setA.changedRange(setB);
assert.notStrictEqual(diffRange, null);
assert.strictEqual(diffRange.from, 10);
assert.strictEqual(diffRange.to, 15);
assert.strictEqual(setA.changedRange(setA), null);
// 8. simplifyChanges preserves non-adjacent changes and handles empty change lists
assert.deepStrictEqual(simplifyChanges([], docMock), []);
const singleCharReplacement = createChange(1, 2, 1, 2, [createSpan(1, 'a')], [createSpan(1, 'b')]);
const simplified = simplifyChanges([singleCharReplacement], docMock);
assert.strictEqual(simplified.length, 1);
assert.strictEqual(simplified[0], singleCharReplacement);
console.log('All contract assertions passed.');
オリジンシーダー
匿名