Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@automerge/automerge

Package Overview
Dependencies
Maintainers
4
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@automerge/automerge - npm Package Compare versions

Comparing version 2.1.13 to 2.2.0-rc.2

110

dist/mjs/next.js

@@ -210,2 +210,112 @@ /**

/**
* Return the text + block markers at a given path
*
* @remarks
* Rich text in automerge is represented as a sequence of characters with block
* markers appearing inline with the text, and inline formatting spans overlaid
* on the whole sequence. Block markers are normal automerge maps, but they are
* only visible via either the {@link block} function or the {@link spans}
* function. This function returns the current state of the spans
*/
export function spans(doc, path) {
const state = _state(doc, false);
const objPath = absoluteObjPath(doc, path, "spans");
try {
return state.handle.spans(objPath, state.heads);
}
catch (e) {
throw new RangeError(`Cannot splice: ${e}`);
}
}
/**
* Get the block marker at the given index
*/
export function block(doc, path, index) {
const objPath = absoluteObjPath(doc, path, "splitBlock");
const state = _state(doc, false);
index = cursorToIndex(state, objPath, index);
try {
return state.handle.getBlock(objPath, index);
}
catch (e) {
throw new RangeError(`Cannot get block: ${e}`);
}
}
/**
* Insert a new block marker at the given index
*/
export function splitBlock(doc, path, index, block) {
if (!_is_proxy(doc)) {
throw new RangeError("object cannot be modified outside of a change block");
}
const objPath = absoluteObjPath(doc, path, "splitBlock");
const state = _state(doc, false);
_clear_cache(doc);
index = cursorToIndex(state, objPath, index);
try {
state.handle.splitBlock(objPath, index, block);
}
catch (e) {
throw new RangeError(`Cannot splice: ${e}`);
}
}
/**
* Delete the block marker at the given index
*/
export function joinBlock(doc, path, index) {
if (!_is_proxy(doc)) {
throw new RangeError("object cannot be modified outside of a change block");
}
const objPath = absoluteObjPath(doc, path, "joinBlock");
const state = _state(doc, false);
_clear_cache(doc);
index = cursorToIndex(state, objPath, index);
try {
state.handle.joinBlock(objPath, index);
}
catch (e) {
throw new RangeError(`Cannot joinBlock: ${e}`);
}
}
/**
* Update the block marker at the given index
*/
export function updateBlock(doc, path, index, block) {
if (!_is_proxy(doc)) {
throw new RangeError("object cannot be modified outside of a change block");
}
const objPath = absoluteObjPath(doc, path, "updateBlock");
const state = _state(doc, false);
_clear_cache(doc);
index = cursorToIndex(state, objPath, index);
try {
state.handle.updateBlock(objPath, index, block);
}
catch (e) {
throw new RangeError(`Cannot updateBlock: ${e}`);
}
}
/**
* Update the spans at the given path
*
* @remarks
* Like {@link updateText} this will diff `newSpans` against the current state
* of the text at `path` and perform a reasonably minimal number of operations
* required to update the spans to the new state.
*/
export function updateSpans(doc, path, newSpans) {
if (!_is_proxy(doc)) {
throw new RangeError("object cannot be modified outside of a change block");
}
const objPath = absoluteObjPath(doc, path, "updateSpans");
const state = _state(doc, false);
_clear_cache(doc);
try {
state.handle.updateSpans(objPath, newSpans);
}
catch (e) {
throw new RangeError(`Cannot updateBlock: ${e}`);
}
}
/**
* Returns a cursor for the given position in a string.

@@ -212,0 +322,0 @@ *

2

dist/mjs/proxies.js

@@ -166,3 +166,3 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

if (key === STATE)
return { handle: context };
return { handle: context, textV2: target.textV2 };
if (!cache[key]) {

@@ -169,0 +169,0 @@ cache[key] = valueAt(target, key);

@@ -11,2 +11,5 @@ export class RawString {

}
toJSON() {
return this.val;
}
}

@@ -86,11 +86,4 @@ var __rest = (this && this.__rest) || function (s, e) {

handle.enableFreeze(!!opts.freeze);
handle.registerDatatype("counter", (n) => new Counter(n));
const textV2 = opts.enableTextV2 || false;
if (textV2) {
handle.registerDatatype("str", (n) => new RawString(n));
}
else {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
handle.registerDatatype("text", (n) => new Text(n));
}
registerDatatypes(handle, textV2);
const doc = handle.materialize("/", undefined, {

@@ -443,10 +436,4 @@ handle,

handle.enableFreeze(!!opts.freeze);
handle.registerDatatype("counter", (n) => new Counter(n));
const textV2 = opts.enableTextV2 || false;
if (textV2) {
handle.registerDatatype("str", (n) => new RawString(n));
}
else {
handle.registerDatatype("text", (n) => new Text(n));
}
registerDatatypes(handle, textV2);
const doc = handle.materialize("/", undefined, {

@@ -905,1 +892,24 @@ handle,

}
function registerDatatypes(handle, textV2) {
handle.registerDatatype("counter", (n) => new Counter(n), n => {
if (n instanceof Counter) {
return n.value;
}
});
if (textV2) {
handle.registerDatatype("str", (n) => {
return new RawString(n);
}, s => {
if (s instanceof RawString) {
return s.val;
}
});
}
else {
handle.registerDatatype("text", (n) => new Text(n), t => {
if (t instanceof Text) {
return t.join("");
}
});
}
}
import { Counter } from "./types.js";
export { Counter, type Doc, Int, Uint, Float64, type Patch, type PatchCallback, type Mark, type MarkSet, type MarkRange, type MarkValue, type Cursor, type PatchInfo, type PatchSource, } from "./types.js";
export { Counter, type Doc, Int, Uint, Float64, type Patch, type MapObjType, type PatchCallback, type Mark, type MarkSet, type MarkRange, type MarkValue, type Cursor, type PatchInfo, type PatchSource, } from "./types.js";
import { RawString } from "./raw_string.js";

@@ -4,0 +4,0 @@ export { RawString } from "./raw_string.js";

@@ -41,3 +41,4 @@ /**

import { type UnstableConflicts as Conflicts } from "./conflicts.js";
export type { PutPatch, DelPatch, SpliceTextPatch, InsertPatch, IncPatch, SyncMessage, Heads, Cursor, } from "@automerge/automerge-wasm";
export type { PutPatch, DelPatch, SpliceTextPatch, InsertPatch, IncPatch, MarkPatch, SyncMessage, Heads, Cursor, Span, } from "@automerge/automerge-wasm";
import { type Span, MaterializeValue } from "@automerge/automerge-wasm";
export type { ActorId, Change, ChangeOptions, Prop, DecodedChange, DecodedSyncMessage, ApplyOptions, ChangeFn, ChangeAtResult, MaterializeValue, SyncState, } from "./stable.js";

@@ -167,2 +168,44 @@ export { view, free, getHeads, change, changeAt, emptyChange, loadIncremental, saveIncremental, save, merge, getActorId, getLastLocalChange, getChanges, getAllChanges, applyChanges, getHistory, equals, encodeSyncState, decodeSyncState, generateSyncMessage, receiveSyncMessage, initSyncState, encodeChange, decodeChange, encodeSyncMessage, decodeSyncMessage, getMissingDeps, dump, toJS, isAutomerge, getObjectId, diff, insertAt, deleteAt, saveSince, } from "./stable.js";

/**
* Return the text + block markers at a given path
*
* @remarks
* Rich text in automerge is represented as a sequence of characters with block
* markers appearing inline with the text, and inline formatting spans overlaid
* on the whole sequence. Block markers are normal automerge maps, but they are
* only visible via either the {@link block} function or the {@link spans}
* function. This function returns the current state of the spans
*/
export declare function spans<T>(doc: Doc<T>, path: stable.Prop[]): Span[];
/**
* Get the block marker at the given index
*/
export declare function block<T>(doc: Doc<T>, path: stable.Prop[], index: number | Cursor): {
[key: string]: MaterializeValue;
} | null;
/**
* Insert a new block marker at the given index
*/
export declare function splitBlock<T>(doc: Doc<T>, path: stable.Prop[], index: number | Cursor, block: {
[key: string]: MaterializeValue;
}): void;
/**
* Delete the block marker at the given index
*/
export declare function joinBlock<T>(doc: Doc<T>, path: stable.Prop[], index: number | Cursor): void;
/**
* Update the block marker at the given index
*/
export declare function updateBlock<T>(doc: Doc<T>, path: stable.Prop[], index: number | Cursor, block: {
[key: string]: MaterializeValue;
}): void;
/**
* Update the spans at the given path
*
* @remarks
* Like {@link updateText} this will diff `newSpans` against the current state
* of the text at `path` and perform a reasonably minimal number of operations
* required to update the spans to the new state.
*/
export declare function updateSpans<T>(doc: Doc<T>, path: stable.Prop[], newSpans: Span[]): void;
/**
* Returns a cursor for the given position in a string.

@@ -169,0 +212,0 @@ *

@@ -8,2 +8,3 @@ export declare class RawString {

toString(): string;
toJSON(): string;
}

@@ -7,3 +7,3 @@ export { Text } from "./text.js";

import type { Patch } from "@automerge/automerge-wasm";
export type { Cursor, Patch, MarkSet, Mark, MarkRange, } from "@automerge/automerge-wasm";
export type { Cursor, MapObjType, MarkSet, Mark, MarkRange, MarkPatch, Patch, } from "@automerge/automerge-wasm";
export type AutomergeValue = ScalarValue | {

@@ -10,0 +10,0 @@ [key: string]: AutomergeValue;

@@ -7,3 +7,3 @@ {

],
"version": "2.1.13",
"version": "2.2.0-rc.2",
"description": "Javascript implementation of automerge, backed by @automerge/automerge-wasm",

@@ -74,5 +74,5 @@ "homepage": "https://github.com/automerge/automerge/tree/main/javascript",

"dependencies": {
"@automerge/automerge-wasm": "0.12.0",
"@automerge/automerge-wasm": "0.14.0",
"uuid": "^9.0.0"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc