@huukhanhnguyen/model / core/share
core/share
extractShared()
extractShared(
doc,type,id):ShareBundle|null
Deep-copy the record id of type out of doc, plus everything it transitively references. Null when the doc has no such record. Broken references inside the source are skipped (copy what exists — fail-soft).
Parameters
doc
type
"material" | "layer" | "pattern" | "texture"
id
string
Returns
ShareBundle | null
installModel()
installModel(
lanes,sourceDoc,proposedKey): {key:string; }
Install a catalog model into lanes as ONE new components[] entry — the "install from library" law replacing loadModel/placeModel entirely (see this module's doc). sourceDoc is the already-resolved (validated) document; proposedKey names the new component (renamed on a key conflict, same as every other lane mergeShared plans). The source's own components[] entries copy alongside it (their placeComponent refs rewritten by the ordinary rename pass); its parameters/operations become the new component's own parameters/operations — animation fields travel with parameters unchanged (plain JSON, nothing special to carry), and url-method parameters (attached fonts/images) travel the same way: the folded component's own parameters lane is the only "asset lane" an install needs. A luminaire needs no special case: its emitting data document rides in objects[] like any other object. settings.units is NOT converted — internal length is always mm; authored numeric args are mm regardless of the source's display unit (units is display-only). Deliberately NOT copied: tables/views/ sheets/cameras — install brings the geometry definition, not the paperwork. Throws if the source has no objects[] content (a component's operations can't be empty — schema law). Returns the installed key (post-rename).
Parameters
lanes
sourceDoc
proposedKey
string
Returns
{ key: string; }
key
key:
string
mergeShared()
mergeShared(
lanes,bundle): {id:string; }
Copy bundle into lanes. Identical same-id records are REUSED (a re-copy is a no-op); conflicting ones are renamed with every internal reference rewritten. Returns the root record's FINAL id in the target.
ponytail: when ANY rename occurs in a REFERENCED lane (textures/ components), the whole plan re-runs with reuse disabled — a reused-but- rewritten dependency would otherwise silently recombine incoming content with the target's same-named records. Mixed partial-conflict copies duplicate a few identical records instead; the common cases (clean target, exact re-copy) keep full dedup. Materials/layers are referenced by nothing, so their renames never trigger the re-plan.
Parameters
lanes
bundle
Returns
{ id: string; }
id
id:
string
SHARE_TYPES
Re-exports SHARE_TYPES