openpencil/packages/scene-graph/package.json
Danila Poyarkov 510cdbc36f
feat(scene-graph)!: let a SceneGraph take its ID generator (#887)
* feat(scene-graph): let a SceneGraph take its ID generator

The constructor accepts an ID generator, used for the root node and for
nodes, variables, and collections created later; generated IDs skip any
node, variable, collection, or mode ID already in the graph.

Refs #770

Signed-off-by: Marc Went <marc@went.io>

* perf(scene-graph): check mode IDs without allocating per created entity

Generating an ID spread every collection into a new array and scanned it
for each candidate, which runs on every createNode. Check the node,
variable, and collection maps first and walk the modes with an early exit.
An index of mode IDs is not kept because history snapshots, transfer, and
undo replace collection maps and edit modes in place, which would leave it
stale.

* test(scene-graph): cover injected ID generators and collision skipping

* docs: note the SceneGraph ID generator in the changelog

* test(core): keep reopened .fig GUIDs when a sibling is inserted before them

Refs #770

* test(collab): cover concurrent additions, same-property writes, and delete versus edit

Move the synced-store harness to tests/helpers/collab so the new cases
live in tests/app/collab, and let it bind graph events as a collab session
does. The cases edit both peers while disconnected and check the
converged graphs.

Refs #770

* fix(scene-graph): keep a collection's IDs apart and stop on an exhausted generator

createCollection asks for the collection and default mode IDs before
registering either, so a generator repeating a candidate gave both the
same ID. A generator that only returned taken IDs looped forever, even in
the constructor; it now throws after a bounded number of attempts.

* test: require the inserted GUID and a real disconnect in new tests

The GUID test passed even if export dropped the inserted layer, and the
concurrent-edit helper would have tested sequential sync had its peers
not been disconnectable.

* feat(scene-graph): create variable modes through the graph's ID generator

The editor minted added and duplicated modes as mode:<random hex>, so an
injected generator governed every graph entity except modes added after
a collection's first. SceneGraph.createMode mints the ID and adds the
mode; undo and redo replay it with addMode.

* test(core): type the reopened .fig buffer in the GUID test

* refactor(scene-graph)!: share random helpers and one component property ID

randomHex, randomInt, and randomIndex move from @open-pencil/core/random
to @open-pencil/scene-graph/random, so format packages can use them:
design-jsx and the MCP test server dropped private copies. Component
property IDs, written as prop:<random hex> in six places across Core and
design-jsx, come from createComponentPropertyId.

* docs: point the randomness rule at the shared ID and random helpers

---------

Signed-off-by: Marc Went <marc@went.io>
Co-authored-by: Marc Went <marc@went.io>
2026-10-05 08:21:22 +00:00

221 lines
6.2 KiB
JSON

{
"name": "@open-pencil/scene-graph",
"version": "0.15.1",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/open-pencil/open-pencil.git",
"directory": "packages/scene-graph"
},
"files": [
"dist",
"src",
"README.md"
],
"type": "module",
"sideEffects": false,
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"bun": "./src/index.ts",
"import": "./dist/index.js",
"default": "./dist/index.js"
},
"./arrow-caps": {
"types": "./dist/arrow-caps.d.ts",
"bun": "./src/arrow-caps.ts",
"import": "./dist/arrow-caps.js",
"default": "./dist/arrow-caps.js"
},
"./copy": {
"types": "./dist/copy.d.ts",
"bun": "./src/copy.ts",
"import": "./dist/copy.js",
"default": "./dist/copy.js"
},
"./node-defaults": {
"types": "./dist/node-defaults.d.ts",
"bun": "./src/node-defaults.ts",
"import": "./dist/node-defaults.js",
"default": "./dist/node-defaults.js"
},
"./instances": {
"types": "./dist/instances.d.ts",
"bun": "./src/instances.ts",
"import": "./dist/instances.js",
"default": "./dist/instances.js"
},
"./snap": {
"types": "./dist/snap.d.ts",
"bun": "./src/snap.ts",
"import": "./dist/snap.js",
"default": "./dist/snap.js"
},
"./source-metadata": {
"types": "./dist/source-metadata.d.ts",
"bun": "./src/source-metadata.ts",
"import": "./dist/source-metadata.js",
"default": "./dist/source-metadata.js"
},
"./undo": {
"types": "./dist/undo.d.ts",
"bun": "./src/undo.ts",
"import": "./dist/undo.js",
"default": "./dist/undo.js"
},
"./variant-name": {
"types": "./dist/variant-name.d.ts",
"bun": "./src/variant-name.ts",
"import": "./dist/variant-name.js",
"default": "./dist/variant-name.js"
},
"./variant-properties": {
"types": "./dist/variant-properties.d.ts",
"bun": "./src/variant-properties.ts",
"import": "./dist/variant-properties.js",
"default": "./dist/variant-properties.js"
},
"./vector-network": {
"types": "./dist/vector-network.d.ts",
"bun": "./src/vector-network.ts",
"import": "./dist/vector-network.js",
"default": "./dist/vector-network.js"
},
"./guides": {
"types": "./dist/guides.d.ts",
"bun": "./src/guides.ts",
"import": "./dist/guides.js",
"default": "./dist/guides.js"
},
"./layout-guides": {
"types": "./dist/layout-guides.d.ts",
"bun": "./src/layout-guides.ts",
"import": "./dist/layout-guides.js",
"default": "./dist/layout-guides.js"
},
"./types": {
"types": "./dist/types.d.ts",
"bun": "./src/types.ts",
"import": "./dist/types.js",
"default": "./dist/types.js"
},
"./primitives": {
"types": "./dist/primitives.d.ts",
"bun": "./src/primitives.ts",
"import": "./dist/primitives.js",
"default": "./dist/primitives.js"
},
"./constants": {
"types": "./dist/constants.d.ts",
"bun": "./src/constants.ts",
"import": "./dist/constants.js",
"default": "./dist/constants.js"
},
"./hit-test": {
"types": "./dist/hit-test.d.ts",
"bun": "./src/hit-test.ts",
"import": "./dist/hit-test.js",
"default": "./dist/hit-test.js"
},
"./preview": {
"types": "./dist/preview.d.ts",
"bun": "./src/preview.ts",
"import": "./dist/preview.js",
"default": "./dist/preview.js"
},
"./text-picture": {
"types": "./dist/text-picture.d.ts",
"bun": "./src/text-picture.ts",
"import": "./dist/text-picture.js",
"default": "./dist/text-picture.js"
},
"./variables": {
"types": "./dist/variables.d.ts",
"bun": "./src/variables.ts",
"import": "./dist/variables.js",
"default": "./dist/variables.js"
},
"./images": {
"types": "./dist/images.d.ts",
"bun": "./src/images.ts",
"import": "./dist/images.js",
"default": "./dist/images.js"
},
"./coordinate": {
"types": "./dist/coordinate.d.ts",
"bun": "./src/coordinate.ts",
"import": "./dist/coordinate.js",
"default": "./dist/coordinate.js"
},
"./matrix": {
"types": "./dist/matrix.d.ts",
"bun": "./src/matrix.ts",
"import": "./dist/matrix.js",
"default": "./dist/matrix.js"
},
"./geometry": {
"types": "./dist/geometry.d.ts",
"bun": "./src/geometry.ts",
"import": "./dist/geometry.js",
"default": "./dist/geometry.js"
},
"./resize": {
"types": "./dist/resize.d.ts",
"bun": "./src/resize.ts",
"import": "./dist/resize.js",
"default": "./dist/resize.js"
},
"./random": {
"types": "./dist/random.d.ts",
"bun": "./src/random.ts",
"import": "./dist/random.js",
"default": "./dist/random.js"
},
"./parse-path": {
"types": "./dist/parse-path.d.ts",
"bun": "./src/parse-path.ts",
"import": "./dist/parse-path.js",
"default": "./dist/parse-path.js"
},
"./color": {
"types": "./dist/color.d.ts",
"bun": "./src/color/index.ts",
"import": "./dist/color.js",
"default": "./dist/color.js"
},
"./text-direction": {
"types": "./dist/text-direction.d.ts",
"bun": "./src/text-direction.ts",
"import": "./dist/text-direction.js",
"default": "./dist/text-direction.js"
}
},
"publishConfig": {
"access": "public",
"provenance": true
},
"scripts": {
"build": "bunx tsdown --config tsdown.config.ts",
"check": "bun run typecheck && bun run test && bun run build && bun run smoke:dist",
"prepack": "bun run build",
"smoke:dist": "bun scripts/smoke-dist.ts",
"test": "bun test tests",
"typecheck": "bunx tsc --noEmit -p tsconfig.test.json"
},
"dependencies": {
"culori": "^4.0.2",
"es-toolkit": "^1.52.0",
"nanoevents": "^9.1.0",
"svgpath": "^2.6.0",
"valibot": "^1.5.0"
},
"devDependencies": {
"@types/bun": "^1.3.14",
"@types/culori": "^4.0.1",
"tsdown": "^0.22.14",
"typescript": "~5.8.3"
}
}