@automerge/automerge
Advanced tools
Comparing version 2.1.0-alpha.11 to 2.1.0-alpha.12
@@ -1,14 +0,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.unstableConflictAt = exports.stableConflictAt = void 0; | ||
const types_1 = require("./types"); | ||
const text_1 = require("./text"); | ||
const proxies_1 = require("./proxies"); | ||
function stableConflictAt(context, objectId, prop) { | ||
import { Counter } from "./types.js"; | ||
import { Text } from "./text.js"; | ||
import { mapProxy, listProxy } from "./proxies.js"; | ||
export function stableConflictAt(context, objectId, prop) { | ||
return conflictAt(context, objectId, prop, true, (context, conflictId) => { | ||
return new text_1.Text(context.text(conflictId)); | ||
return new Text(context.text(conflictId)); | ||
}); | ||
} | ||
exports.stableConflictAt = stableConflictAt; | ||
function unstableConflictAt(context, objectId, prop) { | ||
export function unstableConflictAt(context, objectId, prop) { | ||
return conflictAt(context, objectId, prop, true, (context, conflictId) => { | ||
@@ -18,3 +14,2 @@ return context.text(conflictId); | ||
} | ||
exports.unstableConflictAt = unstableConflictAt; | ||
function conflictAt(context, objectId, prop, textV2, handleText) { | ||
@@ -29,6 +24,6 @@ const values = context.getAll(objectId, prop); | ||
case "map": | ||
result[fullVal[1]] = (0, proxies_1.mapProxy)(context, fullVal[1], textV2, [prop]); | ||
result[fullVal[1]] = mapProxy(context, fullVal[1], textV2, [prop]); | ||
break; | ||
case "list": | ||
result[fullVal[1]] = (0, proxies_1.listProxy)(context, fullVal[1], textV2, [prop]); | ||
result[fullVal[1]] = listProxy(context, fullVal[1], textV2, [prop]); | ||
break; | ||
@@ -48,3 +43,3 @@ case "text": | ||
case "counter": | ||
result[fullVal[2]] = new types_1.Counter(fullVal[1]); | ||
result[fullVal[2]] = new Counter(fullVal[1]); | ||
break; | ||
@@ -51,0 +46,0 @@ case "timestamp": |
@@ -1,14 +0,11 @@ | ||
"use strict"; | ||
// Properties of the document root object | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TEXT = exports.COUNTER = exports.F64 = exports.INT = exports.UINT = exports.CLEAR_CACHE = exports.IS_PROXY = exports.OBJECT_ID = exports.TRACE = exports.STATE = void 0; | ||
exports.STATE = Symbol.for("_am_meta"); // symbol used to hide application metadata on automerge objects | ||
exports.TRACE = Symbol.for("_am_trace"); // used for debugging | ||
exports.OBJECT_ID = Symbol.for("_am_objectId"); // symbol used to hide the object id on automerge objects | ||
exports.IS_PROXY = Symbol.for("_am_isProxy"); // symbol used to test if the document is a proxy object | ||
exports.CLEAR_CACHE = Symbol.for("_am_clearCache"); // symbol used to tell a proxy object to clear its cache | ||
exports.UINT = Symbol.for("_am_uint"); | ||
exports.INT = Symbol.for("_am_int"); | ||
exports.F64 = Symbol.for("_am_f64"); | ||
exports.COUNTER = Symbol.for("_am_counter"); | ||
exports.TEXT = Symbol.for("_am_text"); | ||
export const STATE = Symbol.for("_am_meta"); // symbol used to hide application metadata on automerge objects | ||
export const TRACE = Symbol.for("_am_trace"); // used for debugging | ||
export const OBJECT_ID = Symbol.for("_am_objectId"); // symbol used to hide the object id on automerge objects | ||
export const IS_PROXY = Symbol.for("_am_isProxy"); // symbol used to test if the document is a proxy object | ||
export const CLEAR_CACHE = Symbol.for("_am_clearCache"); // symbol used to tell a proxy object to clear its cache | ||
export const UINT = Symbol.for("_am_uint"); | ||
export const INT = Symbol.for("_am_int"); | ||
export const F64 = Symbol.for("_am_f64"); | ||
export const COUNTER = Symbol.for("_am_counter"); | ||
export const TEXT = Symbol.for("_am_text"); |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getWriteableCounter = exports.Counter = void 0; | ||
const constants_1 = require("./constants"); | ||
import { COUNTER } from "./constants.js"; | ||
/** | ||
@@ -10,6 +7,6 @@ * The most basic CRDT: an integer value that can be changed only by | ||
*/ | ||
class Counter { | ||
export class Counter { | ||
constructor(value) { | ||
this.value = value || 0; | ||
Reflect.defineProperty(this, constants_1.COUNTER, { value: true }); | ||
Reflect.defineProperty(this, COUNTER, { value: true }); | ||
} | ||
@@ -61,3 +58,2 @@ /** | ||
} | ||
exports.Counter = Counter; | ||
/** | ||
@@ -100,6 +96,5 @@ * An instance of this class is used when a counter is accessed within a change | ||
*/ | ||
function getWriteableCounter(value, context, path, objectId, key) { | ||
export function getWriteableCounter(value, context, path, objectId, key) { | ||
return new WriteableCounter(value, context, path, objectId, key); | ||
} | ||
exports.getWriteableCounter = getWriteableCounter; | ||
//module.exports = { Counter, getWriteableCounter } |
@@ -1,18 +0,1 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.next = void 0; | ||
/** | ||
@@ -253,4 +236,4 @@ * # Automerge | ||
*/ | ||
__exportStar(require("./stable"), exports); | ||
const next = require("./next"); | ||
exports.next = next; | ||
export * from "./stable.js"; | ||
import * as next from "./next.js"; | ||
export { next }; |
@@ -1,10 +0,7 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports._is_proxy = exports._obj = exports._trace = exports._clear_cache = exports._state = void 0; | ||
const constants_1 = require("./constants"); | ||
function _state(doc, checkroot = true) { | ||
import { STATE, OBJECT_ID, CLEAR_CACHE, TRACE, IS_PROXY } from "./constants.js"; | ||
export function _state(doc, checkroot = true) { | ||
if (typeof doc !== "object") { | ||
throw new RangeError("must be the document root"); | ||
} | ||
const state = Reflect.get(doc, constants_1.STATE); | ||
const state = Reflect.get(doc, STATE); | ||
if (state === undefined || | ||
@@ -17,21 +14,16 @@ state == null || | ||
} | ||
exports._state = _state; | ||
function _clear_cache(doc) { | ||
Reflect.set(doc, constants_1.CLEAR_CACHE, true); | ||
export function _clear_cache(doc) { | ||
Reflect.set(doc, CLEAR_CACHE, true); | ||
} | ||
exports._clear_cache = _clear_cache; | ||
function _trace(doc) { | ||
return Reflect.get(doc, constants_1.TRACE); | ||
export function _trace(doc) { | ||
return Reflect.get(doc, TRACE); | ||
} | ||
exports._trace = _trace; | ||
function _obj(doc) { | ||
export function _obj(doc) { | ||
if (!(typeof doc === "object") || doc === null) { | ||
return null; | ||
} | ||
return Reflect.get(doc, constants_1.OBJECT_ID); | ||
return Reflect.get(doc, OBJECT_ID); | ||
} | ||
exports._obj = _obj; | ||
function _is_proxy(doc) { | ||
return !!Reflect.get(doc, constants_1.IS_PROXY); | ||
export function _is_proxy(doc) { | ||
return !!Reflect.get(doc, IS_PROXY); | ||
} | ||
exports._is_proxy = _is_proxy; |
@@ -1,14 +0,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ApiHandler = exports.UseApi = void 0; | ||
function UseApi(api) { | ||
export function UseApi(api) { | ||
for (const k in api) { | ||
// eslint-disable-next-line @typescript-eslint/no-extra-semi,@typescript-eslint/no-explicit-any | ||
; | ||
exports.ApiHandler[k] = api[k]; | ||
ApiHandler[k] = api[k]; | ||
} | ||
} | ||
exports.UseApi = UseApi; | ||
/* eslint-disable */ | ||
exports.ApiHandler = { | ||
export const ApiHandler = { | ||
create(options) { | ||
@@ -15,0 +11,0 @@ throw new RangeError("Automerge.use() not called"); |
@@ -1,10 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RawString = exports.Float64 = exports.Uint = exports.Int = exports.Counter = void 0; | ||
var types_1 = require("./types"); | ||
Object.defineProperty(exports, "Counter", { enumerable: true, get: function () { return types_1.Counter; } }); | ||
Object.defineProperty(exports, "Int", { enumerable: true, get: function () { return types_1.Int; } }); | ||
Object.defineProperty(exports, "Uint", { enumerable: true, get: function () { return types_1.Uint; } }); | ||
Object.defineProperty(exports, "Float64", { enumerable: true, get: function () { return types_1.Float64; } }); | ||
var raw_string_1 = require("./raw_string"); | ||
Object.defineProperty(exports, "RawString", { enumerable: true, get: function () { return raw_string_1.RawString; } }); | ||
export { Counter, Int, Uint, Float64, } from "./types.js"; | ||
export { RawString } from "./raw_string.js"; |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
/** | ||
@@ -38,53 +37,10 @@ * # The next API | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.unmark = exports.mark = exports.getCursorPosition = exports.getCursor = exports.splice = exports.load = exports.from = exports.clone = exports.init = exports.getBackend = exports.RawString = exports.saveSince = exports.deleteAt = exports.insertAt = exports.diff = exports.getObjectId = exports.isAutomerge = exports.toJS = exports.dump = exports.getMissingDeps = exports.decodeSyncMessage = exports.encodeSyncMessage = exports.decodeChange = exports.encodeChange = exports.initSyncState = exports.receiveSyncMessage = exports.generateSyncMessage = exports.decodeSyncState = exports.encodeSyncState = exports.equals = exports.getHistory = exports.applyChanges = exports.getAllChanges = exports.getChanges = exports.getLastLocalChange = exports.getActorId = exports.merge = exports.save = exports.saveIncremental = exports.loadIncremental = exports.emptyChange = exports.changeAt = exports.change = exports.getHeads = exports.free = exports.view = exports.Float64 = exports.Uint = exports.Int = exports.Counter = void 0; | ||
exports.getConflicts = exports.marks = void 0; | ||
var next_types_1 = require("./next_types"); | ||
Object.defineProperty(exports, "Counter", { enumerable: true, get: function () { return next_types_1.Counter; } }); | ||
Object.defineProperty(exports, "Int", { enumerable: true, get: function () { return next_types_1.Int; } }); | ||
Object.defineProperty(exports, "Uint", { enumerable: true, get: function () { return next_types_1.Uint; } }); | ||
Object.defineProperty(exports, "Float64", { enumerable: true, get: function () { return next_types_1.Float64; } }); | ||
const conflicts_1 = require("./conflicts"); | ||
var stable_1 = require("./stable"); | ||
Object.defineProperty(exports, "view", { enumerable: true, get: function () { return stable_1.view; } }); | ||
Object.defineProperty(exports, "free", { enumerable: true, get: function () { return stable_1.free; } }); | ||
Object.defineProperty(exports, "getHeads", { enumerable: true, get: function () { return stable_1.getHeads; } }); | ||
Object.defineProperty(exports, "change", { enumerable: true, get: function () { return stable_1.change; } }); | ||
Object.defineProperty(exports, "changeAt", { enumerable: true, get: function () { return stable_1.changeAt; } }); | ||
Object.defineProperty(exports, "emptyChange", { enumerable: true, get: function () { return stable_1.emptyChange; } }); | ||
Object.defineProperty(exports, "loadIncremental", { enumerable: true, get: function () { return stable_1.loadIncremental; } }); | ||
Object.defineProperty(exports, "saveIncremental", { enumerable: true, get: function () { return stable_1.saveIncremental; } }); | ||
Object.defineProperty(exports, "save", { enumerable: true, get: function () { return stable_1.save; } }); | ||
Object.defineProperty(exports, "merge", { enumerable: true, get: function () { return stable_1.merge; } }); | ||
Object.defineProperty(exports, "getActorId", { enumerable: true, get: function () { return stable_1.getActorId; } }); | ||
Object.defineProperty(exports, "getLastLocalChange", { enumerable: true, get: function () { return stable_1.getLastLocalChange; } }); | ||
Object.defineProperty(exports, "getChanges", { enumerable: true, get: function () { return stable_1.getChanges; } }); | ||
Object.defineProperty(exports, "getAllChanges", { enumerable: true, get: function () { return stable_1.getAllChanges; } }); | ||
Object.defineProperty(exports, "applyChanges", { enumerable: true, get: function () { return stable_1.applyChanges; } }); | ||
Object.defineProperty(exports, "getHistory", { enumerable: true, get: function () { return stable_1.getHistory; } }); | ||
Object.defineProperty(exports, "equals", { enumerable: true, get: function () { return stable_1.equals; } }); | ||
Object.defineProperty(exports, "encodeSyncState", { enumerable: true, get: function () { return stable_1.encodeSyncState; } }); | ||
Object.defineProperty(exports, "decodeSyncState", { enumerable: true, get: function () { return stable_1.decodeSyncState; } }); | ||
Object.defineProperty(exports, "generateSyncMessage", { enumerable: true, get: function () { return stable_1.generateSyncMessage; } }); | ||
Object.defineProperty(exports, "receiveSyncMessage", { enumerable: true, get: function () { return stable_1.receiveSyncMessage; } }); | ||
Object.defineProperty(exports, "initSyncState", { enumerable: true, get: function () { return stable_1.initSyncState; } }); | ||
Object.defineProperty(exports, "encodeChange", { enumerable: true, get: function () { return stable_1.encodeChange; } }); | ||
Object.defineProperty(exports, "decodeChange", { enumerable: true, get: function () { return stable_1.decodeChange; } }); | ||
Object.defineProperty(exports, "encodeSyncMessage", { enumerable: true, get: function () { return stable_1.encodeSyncMessage; } }); | ||
Object.defineProperty(exports, "decodeSyncMessage", { enumerable: true, get: function () { return stable_1.decodeSyncMessage; } }); | ||
Object.defineProperty(exports, "getMissingDeps", { enumerable: true, get: function () { return stable_1.getMissingDeps; } }); | ||
Object.defineProperty(exports, "dump", { enumerable: true, get: function () { return stable_1.dump; } }); | ||
Object.defineProperty(exports, "toJS", { enumerable: true, get: function () { return stable_1.toJS; } }); | ||
Object.defineProperty(exports, "isAutomerge", { enumerable: true, get: function () { return stable_1.isAutomerge; } }); | ||
Object.defineProperty(exports, "getObjectId", { enumerable: true, get: function () { return stable_1.getObjectId; } }); | ||
Object.defineProperty(exports, "diff", { enumerable: true, get: function () { return stable_1.diff; } }); | ||
Object.defineProperty(exports, "insertAt", { enumerable: true, get: function () { return stable_1.insertAt; } }); | ||
Object.defineProperty(exports, "deleteAt", { enumerable: true, get: function () { return stable_1.deleteAt; } }); | ||
Object.defineProperty(exports, "saveSince", { enumerable: true, get: function () { return stable_1.saveSince; } }); | ||
const stable = require("./stable"); | ||
var raw_string_1 = require("./raw_string"); | ||
Object.defineProperty(exports, "RawString", { enumerable: true, get: function () { return raw_string_1.RawString; } }); | ||
export { Counter, Int, Uint, Float64, } from "./next_types.js"; | ||
import { unstableConflictAt } from "./conflicts.js"; | ||
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"; | ||
import * as stable from "./stable.js"; | ||
export { RawString } from "./raw_string.js"; | ||
/** @hidden */ | ||
exports.getBackend = stable.getBackend; | ||
const internal_state_1 = require("./internal_state"); | ||
export const getBackend = stable.getBackend; | ||
import { _is_proxy, _state, _obj, _clear_cache } from "./internal_state.js"; | ||
/** | ||
@@ -99,3 +55,3 @@ * Create a new automerge document | ||
*/ | ||
function init(_opts) { | ||
export function init(_opts) { | ||
const opts = importOpts(_opts); | ||
@@ -105,3 +61,2 @@ opts.enableTextV2 = true; | ||
} | ||
exports.init = init; | ||
/** | ||
@@ -122,3 +77,3 @@ * Make a full writable copy of an automerge document | ||
*/ | ||
function clone(doc, _opts) { | ||
export function clone(doc, _opts) { | ||
const opts = importOpts(_opts); | ||
@@ -128,3 +83,2 @@ opts.enableTextV2 = true; | ||
} | ||
exports.clone = clone; | ||
/** | ||
@@ -146,3 +100,3 @@ * Create an automerge document from a POJO | ||
*/ | ||
function from(initialState, _opts) { | ||
export function from(initialState, _opts) { | ||
const opts = importOpts(_opts); | ||
@@ -152,3 +106,2 @@ opts.enableTextV2 = true; | ||
} | ||
exports.from = from; | ||
/** | ||
@@ -169,3 +122,3 @@ * Load an automerge document from a compressed document produce by {@link save} | ||
*/ | ||
function load(data, _opts) { | ||
export function load(data, _opts) { | ||
const opts = importOpts(_opts); | ||
@@ -180,3 +133,2 @@ opts.enableTextV2 = true; | ||
} | ||
exports.load = load; | ||
function importOpts(_actor) { | ||
@@ -218,12 +170,12 @@ if (typeof _actor === "object") { | ||
*/ | ||
function splice(doc, path, index, del, newText) { | ||
if (!(0, internal_state_1._is_proxy)(doc)) { | ||
export function splice(doc, path, index, del, newText) { | ||
if (!_is_proxy(doc)) { | ||
throw new RangeError("object cannot be modified outside of a change block"); | ||
} | ||
const state = (0, internal_state_1._state)(doc, false); | ||
const objectId = (0, internal_state_1._obj)(doc); | ||
const state = _state(doc, false); | ||
const objectId = _obj(doc); | ||
if (!objectId) { | ||
throw new RangeError("invalid object for splice"); | ||
} | ||
(0, internal_state_1._clear_cache)(doc); | ||
_clear_cache(doc); | ||
path.unshift(objectId); | ||
@@ -239,3 +191,2 @@ const value = path.join("/"); | ||
} | ||
exports.splice = splice; | ||
/** | ||
@@ -259,5 +210,5 @@ * Returns a cursor for the given position in a string. | ||
*/ | ||
function getCursor(doc, path, index) { | ||
const state = (0, internal_state_1._state)(doc, false); | ||
const objectId = (0, internal_state_1._obj)(doc); | ||
export function getCursor(doc, path, index) { | ||
const state = _state(doc, false); | ||
const objectId = _obj(doc); | ||
if (!objectId) { | ||
@@ -275,3 +226,2 @@ throw new RangeError("invalid object for getCursor"); | ||
} | ||
exports.getCursor = getCursor; | ||
/** | ||
@@ -286,5 +236,5 @@ * Returns the current index of the cursor. | ||
*/ | ||
function getCursorPosition(doc, path, cursor) { | ||
const state = (0, internal_state_1._state)(doc, false); | ||
const objectId = (0, internal_state_1._obj)(doc); | ||
export function getCursorPosition(doc, path, cursor) { | ||
const state = _state(doc, false); | ||
const objectId = _obj(doc); | ||
if (!objectId) { | ||
@@ -302,9 +252,8 @@ throw new RangeError("invalid object for getCursorPosition"); | ||
} | ||
exports.getCursorPosition = getCursorPosition; | ||
function mark(doc, path, range, name, value) { | ||
if (!(0, internal_state_1._is_proxy)(doc)) { | ||
export function mark(doc, path, range, name, value) { | ||
if (!_is_proxy(doc)) { | ||
throw new RangeError("object cannot be modified outside of a change block"); | ||
} | ||
const state = (0, internal_state_1._state)(doc, false); | ||
const objectId = (0, internal_state_1._obj)(doc); | ||
const state = _state(doc, false); | ||
const objectId = _obj(doc); | ||
if (!objectId) { | ||
@@ -322,9 +271,8 @@ throw new RangeError("invalid object for mark"); | ||
} | ||
exports.mark = mark; | ||
function unmark(doc, path, range, name) { | ||
if (!(0, internal_state_1._is_proxy)(doc)) { | ||
export function unmark(doc, path, range, name) { | ||
if (!_is_proxy(doc)) { | ||
throw new RangeError("object cannot be modified outside of a change block"); | ||
} | ||
const state = (0, internal_state_1._state)(doc, false); | ||
const objectId = (0, internal_state_1._obj)(doc); | ||
const state = _state(doc, false); | ||
const objectId = _obj(doc); | ||
if (!objectId) { | ||
@@ -342,6 +290,5 @@ throw new RangeError("invalid object for unmark"); | ||
} | ||
exports.unmark = unmark; | ||
function marks(doc, path) { | ||
const state = (0, internal_state_1._state)(doc, false); | ||
const objectId = (0, internal_state_1._obj)(doc); | ||
export function marks(doc, path) { | ||
const state = _state(doc, false); | ||
const objectId = _obj(doc); | ||
if (!objectId) { | ||
@@ -359,3 +306,2 @@ throw new RangeError("invalid object for unmark"); | ||
} | ||
exports.marks = marks; | ||
/** | ||
@@ -405,10 +351,10 @@ * Get the conflicts associated with a property | ||
*/ | ||
function getConflicts(doc, prop) { | ||
const state = (0, internal_state_1._state)(doc, false); | ||
export function getConflicts(doc, prop) { | ||
const state = _state(doc, false); | ||
if (!state.textV2) { | ||
throw new Error("use getConflicts for a stable document"); | ||
} | ||
const objectId = (0, internal_state_1._obj)(doc); | ||
const objectId = _obj(doc); | ||
if (objectId != null) { | ||
return (0, conflicts_1.unstableConflictAt)(state.handle, objectId, prop); | ||
return unstableConflictAt(state.handle, objectId, prop); | ||
} | ||
@@ -419,2 +365,1 @@ else { | ||
} | ||
exports.getConflicts = getConflicts; |
@@ -1,7 +0,4 @@ | ||
"use strict"; | ||
// Convenience classes to allow users to strictly specify the number type they want | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Float64 = exports.Uint = exports.Int = void 0; | ||
const constants_1 = require("./constants"); | ||
class Int { | ||
import { INT, UINT, F64 } from "./constants.js"; | ||
export class Int { | ||
constructor(value) { | ||
@@ -14,8 +11,7 @@ if (!(Number.isInteger(value) && | ||
this.value = value; | ||
Reflect.defineProperty(this, constants_1.INT, { value: true }); | ||
Reflect.defineProperty(this, INT, { value: true }); | ||
Object.freeze(this); | ||
} | ||
} | ||
exports.Int = Int; | ||
class Uint { | ||
export class Uint { | ||
constructor(value) { | ||
@@ -28,8 +24,7 @@ if (!(Number.isInteger(value) && | ||
this.value = value; | ||
Reflect.defineProperty(this, constants_1.UINT, { value: true }); | ||
Reflect.defineProperty(this, UINT, { value: true }); | ||
Object.freeze(this); | ||
} | ||
} | ||
exports.Uint = Uint; | ||
class Float64 { | ||
export class Float64 { | ||
constructor(value) { | ||
@@ -40,6 +35,5 @@ if (typeof value !== "number") { | ||
this.value = value || 0.0; | ||
Reflect.defineProperty(this, constants_1.F64, { value: true }); | ||
Reflect.defineProperty(this, F64, { value: true }); | ||
Object.freeze(this); | ||
} | ||
} | ||
exports.Float64 = Float64; |
@@ -1,9 +0,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.rootProxy = exports.textProxy = exports.listProxy = exports.mapProxy = void 0; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
const text_1 = require("./text"); | ||
const counter_1 = require("./counter"); | ||
const constants_1 = require("./constants"); | ||
const raw_string_1 = require("./raw_string"); | ||
import { Text } from "./text.js"; | ||
import { getWriteableCounter } from "./counter.js"; | ||
import { STATE, TRACE, IS_PROXY, OBJECT_ID, CLEAR_CACHE, COUNTER, INT, UINT, F64, } from "./constants.js"; | ||
import { RawString } from "./raw_string.js"; | ||
function parseListIndex(key) { | ||
@@ -62,3 +59,3 @@ if (typeof key === "string" && /^[0-9]+$/.test(key)) | ||
case "counter": { | ||
const counter = (0, counter_1.getWriteableCounter)(val, context, path, objectId, prop); | ||
const counter = getWriteableCounter(val, context, path, objectId, prop); | ||
return counter; | ||
@@ -76,12 +73,12 @@ } | ||
} | ||
else if (value[constants_1.UINT]) { | ||
else if (value[UINT]) { | ||
return [value.value, "uint"]; | ||
} | ||
else if (value[constants_1.INT]) { | ||
else if (value[INT]) { | ||
return [value.value, "int"]; | ||
} | ||
else if (value[constants_1.F64]) { | ||
else if (value[F64]) { | ||
return [value.value, "f64"]; | ||
} | ||
else if (value[constants_1.COUNTER]) { | ||
else if (value[COUNTER]) { | ||
return [value.value, "counter"]; | ||
@@ -92,6 +89,6 @@ } | ||
} | ||
else if (value instanceof raw_string_1.RawString) { | ||
else if (value instanceof RawString) { | ||
return [value.val, "str"]; | ||
} | ||
else if (value instanceof text_1.Text) { | ||
else if (value instanceof Text) { | ||
return [value, "text"]; | ||
@@ -154,3 +151,3 @@ } | ||
// but the tests should expose the break | ||
if (val && ((_c = (_b = val[constants_1.STATE]) === null || _b === void 0 ? void 0 : _b.handle) === null || _c === void 0 ? void 0 : _c.__wbg_ptr) === context.__wbg_ptr) { | ||
if (val && ((_c = (_b = val[STATE]) === null || _b === void 0 ? void 0 : _b.handle) === null || _c === void 0 ? void 0 : _c.__wbg_ptr) === context.__wbg_ptr) { | ||
return true; | ||
@@ -166,9 +163,9 @@ } | ||
} | ||
if (key === constants_1.OBJECT_ID) | ||
if (key === OBJECT_ID) | ||
return objectId; | ||
if (key === constants_1.IS_PROXY) | ||
if (key === IS_PROXY) | ||
return true; | ||
if (key === constants_1.TRACE) | ||
if (key === TRACE) | ||
return target.trace; | ||
if (key === constants_1.STATE) | ||
if (key === STATE) | ||
return { handle: context }; | ||
@@ -186,7 +183,7 @@ if (!cache[key]) { | ||
} | ||
if (key === constants_1.TRACE) { | ||
if (key === TRACE) { | ||
target.trace = val; | ||
return true; | ||
} | ||
if (key === constants_1.CLEAR_CACHE) { | ||
if (key === CLEAR_CACHE) { | ||
return true; | ||
@@ -270,9 +267,9 @@ } | ||
} | ||
if (index === constants_1.OBJECT_ID) | ||
if (index === OBJECT_ID) | ||
return objectId; | ||
if (index === constants_1.IS_PROXY) | ||
if (index === IS_PROXY) | ||
return true; | ||
if (index === constants_1.TRACE) | ||
if (index === TRACE) | ||
return target.trace; | ||
if (index === constants_1.STATE) | ||
if (index === STATE) | ||
return { handle: context }; | ||
@@ -294,3 +291,3 @@ if (index === "length") | ||
} | ||
if (index === constants_1.TRACE) { | ||
if (index === TRACE) { | ||
target.trace = val; | ||
@@ -386,3 +383,3 @@ return true; | ||
return { writable: true, value: context.length(objectId) }; | ||
if (index === constants_1.OBJECT_ID) | ||
if (index === OBJECT_ID) | ||
return { configurable: false, enumerable: false, value: objectId }; | ||
@@ -418,9 +415,9 @@ index = parseListIndex(index); | ||
} | ||
if (index === constants_1.OBJECT_ID) | ||
if (index === OBJECT_ID) | ||
return objectId; | ||
if (index === constants_1.IS_PROXY) | ||
if (index === IS_PROXY) | ||
return true; | ||
if (index === constants_1.TRACE) | ||
if (index === TRACE) | ||
return target.trace; | ||
if (index === constants_1.STATE) | ||
if (index === STATE) | ||
return { handle: context }; | ||
@@ -437,6 +434,6 @@ if (index === "length") | ||
getPrototypeOf( /*target*/) { | ||
return Object.getPrototypeOf(new text_1.Text()); | ||
return Object.getPrototypeOf(new Text()); | ||
}, | ||
}); | ||
function mapProxy(context, objectId, textV2, path) { | ||
export function mapProxy(context, objectId, textV2, path) { | ||
const target = { | ||
@@ -455,4 +452,3 @@ context, | ||
} | ||
exports.mapProxy = mapProxy; | ||
function listProxy(context, objectId, textV2, path) { | ||
export function listProxy(context, objectId, textV2, path) { | ||
const target = { | ||
@@ -471,4 +467,3 @@ context, | ||
} | ||
exports.listProxy = listProxy; | ||
function textProxy(context, objectId, path) { | ||
export function textProxy(context, objectId, path) { | ||
const target = { | ||
@@ -485,8 +480,6 @@ context, | ||
} | ||
exports.textProxy = textProxy; | ||
function rootProxy(context, textV2) { | ||
export function rootProxy(context, textV2) { | ||
/* eslint-disable-next-line */ | ||
return mapProxy(context, "_root", textV2, []); | ||
} | ||
exports.rootProxy = rootProxy; | ||
function listMethods(target) { | ||
@@ -537,3 +530,3 @@ const { context, objectId, path, textV2 } = target; | ||
const value = context.getWithType(objectId, i); | ||
if (value && (value[1] === o[constants_1.OBJECT_ID] || value[1] === o)) { | ||
if (value && (value[1] === o[OBJECT_ID] || value[1] === o)) { | ||
return i; | ||
@@ -827,3 +820,3 @@ } | ||
function assertText(value) { | ||
if (!(value instanceof text_1.Text)) { | ||
if (!(value instanceof Text)) { | ||
throw new Error("value was not a Text instance"); | ||
@@ -830,0 +823,0 @@ } |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RawString = void 0; | ||
class RawString { | ||
export class RawString { | ||
constructor(val) { | ||
@@ -9,2 +6,1 @@ this.val = val; | ||
} | ||
exports.RawString = RawString; |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
@@ -13,23 +12,15 @@ var t = {}; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.saveSince = exports.isAutomerge = exports.toJS = exports.dump = exports.getHeads = exports.getMissingDeps = exports.decodeSyncMessage = exports.encodeSyncMessage = exports.decodeChange = exports.encodeChange = exports.initSyncState = exports.receiveSyncMessage = exports.generateSyncMessage = exports.decodeSyncState = exports.encodeSyncState = exports.equals = exports.diff = exports.getHistory = exports.applyChanges = exports.getAllChanges = exports.getChanges = exports.getObjectId = exports.getLastLocalChange = exports.getConflicts = exports.getActorId = exports.merge = exports.save = exports.saveIncremental = exports.loadIncremental = exports.load = exports.emptyChange = exports.changeAt = exports.change = exports.from = exports.free = exports.clone = exports.view = exports.init = exports.getBackend = exports.use = exports.deleteAt = exports.insertAt = exports.Text = exports.Float64 = exports.Uint = exports.Int = exports.Counter = exports.uuid = void 0; | ||
/** @hidden **/ | ||
var uuid_1 = require("./uuid"); | ||
Object.defineProperty(exports, "uuid", { enumerable: true, get: function () { return uuid_1.uuid; } }); | ||
const proxies_1 = require("./proxies"); | ||
const constants_1 = require("./constants"); | ||
const types_1 = require("./types"); | ||
var types_2 = require("./types"); | ||
Object.defineProperty(exports, "Counter", { enumerable: true, get: function () { return types_2.Counter; } }); | ||
Object.defineProperty(exports, "Int", { enumerable: true, get: function () { return types_2.Int; } }); | ||
Object.defineProperty(exports, "Uint", { enumerable: true, get: function () { return types_2.Uint; } }); | ||
Object.defineProperty(exports, "Float64", { enumerable: true, get: function () { return types_2.Float64; } }); | ||
const text_1 = require("./text"); | ||
var text_2 = require("./text"); | ||
Object.defineProperty(exports, "Text", { enumerable: true, get: function () { return text_2.Text; } }); | ||
export { /** @hidden */ uuid } from "./uuid.js"; | ||
import { rootProxy } from "./proxies.js"; | ||
import { STATE } from "./constants.js"; | ||
import { Counter, } from "./types.js"; | ||
export { Counter, Int, Uint, Float64, } from "./types.js"; | ||
import { Text } from "./text.js"; | ||
export { Text } from "./text.js"; | ||
const SyncStateSymbol = Symbol("_syncstate"); | ||
const low_level_1 = require("./low_level"); | ||
const raw_string_1 = require("./raw_string"); | ||
const internal_state_1 = require("./internal_state"); | ||
const conflicts_1 = require("./conflicts"); | ||
import { ApiHandler, UseApi } from "./low_level.js"; | ||
import { RawString } from "./raw_string.js"; | ||
import { _state, _is_proxy, _trace, _obj } from "./internal_state.js"; | ||
import { stableConflictAt } from "./conflicts.js"; | ||
/** | ||
@@ -41,4 +32,4 @@ * Function for use in {@link change} which inserts values into a list at a given index | ||
*/ | ||
function insertAt(list, index, ...values) { | ||
if (!(0, internal_state_1._is_proxy)(list)) { | ||
export function insertAt(list, index, ...values) { | ||
if (!_is_proxy(list)) { | ||
throw new RangeError("object cannot be modified outside of a change block"); | ||
@@ -49,3 +40,2 @@ } | ||
} | ||
exports.insertAt = insertAt; | ||
/** | ||
@@ -57,4 +47,4 @@ * Function for use in {@link change} which deletes values from a list at a given index | ||
*/ | ||
function deleteAt(list, index, numDelete) { | ||
if (!(0, internal_state_1._is_proxy)(list)) { | ||
export function deleteAt(list, index, numDelete) { | ||
if (!_is_proxy(list)) { | ||
throw new RangeError("object cannot be modified outside of a change block"); | ||
@@ -65,15 +55,12 @@ } | ||
} | ||
exports.deleteAt = deleteAt; | ||
/** @hidden **/ | ||
function use(api) { | ||
(0, low_level_1.UseApi)(api); | ||
export function use(api) { | ||
UseApi(api); | ||
} | ||
exports.use = use; | ||
const wasm = require("@automerge/automerge-wasm"); | ||
import * as wasm from "@automerge/automerge-wasm"; | ||
use(wasm); | ||
/** @hidden */ | ||
function getBackend(doc) { | ||
return (0, internal_state_1._state)(doc).handle; | ||
export function getBackend(doc) { | ||
return _state(doc).handle; | ||
} | ||
exports.getBackend = getBackend; | ||
function importOpts(_actor) { | ||
@@ -96,3 +83,3 @@ if (typeof _actor === "object") { | ||
*/ | ||
function init(_opts) { | ||
export function init(_opts) { | ||
const opts = importOpts(_opts); | ||
@@ -103,12 +90,12 @@ const freeze = !!opts.freeze; | ||
const actor = opts.actor; | ||
const handle = low_level_1.ApiHandler.create({ actor, text_v1 }); | ||
const handle = ApiHandler.create({ actor, text_v1 }); | ||
handle.enableFreeze(!!opts.freeze); | ||
handle.registerDatatype("counter", (n) => new types_1.Counter(n)); | ||
handle.registerDatatype("counter", (n) => new Counter(n)); | ||
const textV2 = opts.enableTextV2 || false; | ||
if (textV2) { | ||
handle.registerDatatype("str", (n) => new raw_string_1.RawString(n)); | ||
handle.registerDatatype("str", (n) => new RawString(n)); | ||
} | ||
else { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
handle.registerDatatype("text", (n) => new text_1.Text(n)); | ||
handle.registerDatatype("text", (n) => new Text(n)); | ||
} | ||
@@ -124,3 +111,2 @@ const doc = handle.materialize("/", undefined, { | ||
} | ||
exports.init = init; | ||
/** | ||
@@ -141,4 +127,4 @@ * Make an immutable view of an automerge document as at `heads` | ||
*/ | ||
function view(doc, heads) { | ||
const state = (0, internal_state_1._state)(doc); | ||
export function view(doc, heads) { | ||
const state = _state(doc); | ||
const handle = state.handle; | ||
@@ -148,3 +134,2 @@ return state.handle.materialize("/", heads, Object.assign(Object.assign({}, state), { handle, | ||
} | ||
exports.view = view; | ||
/** | ||
@@ -165,4 +150,4 @@ * Make a full writable copy of an automerge document | ||
*/ | ||
function clone(doc, _opts) { | ||
const state = (0, internal_state_1._state)(doc); | ||
export function clone(doc, _opts) { | ||
const state = _state(doc); | ||
const heads = state.heads; | ||
@@ -178,3 +163,2 @@ const opts = importOpts(_opts); | ||
} | ||
exports.clone = clone; | ||
/** Explicity free the memory backing a document. Note that this is note | ||
@@ -184,6 +168,5 @@ * necessary in environments which support | ||
*/ | ||
function free(doc) { | ||
return (0, internal_state_1._state)(doc).handle.free(); | ||
export function free(doc) { | ||
return _state(doc).handle.free(); | ||
} | ||
exports.free = free; | ||
/** | ||
@@ -205,7 +188,6 @@ * Create an automerge document from a POJO | ||
*/ | ||
function from(initialState, _opts) { | ||
export function from(initialState, _opts) { | ||
return _change(init(_opts), "from", {}, d => Object.assign(d, initialState)) | ||
.newDoc; | ||
} | ||
exports.from = from; | ||
/** | ||
@@ -257,3 +239,3 @@ * Update the contents of an automerge document | ||
*/ | ||
function change(doc, options, callback) { | ||
export function change(doc, options, callback) { | ||
if (typeof options === "function") { | ||
@@ -272,3 +254,2 @@ return _change(doc, "change", {}, options).newDoc; | ||
} | ||
exports.change = change; | ||
/** | ||
@@ -330,3 +311,3 @@ * Make a change to the document as it was at a particular point in history | ||
*/ | ||
function changeAt(doc, scope, options, callback) { | ||
export function changeAt(doc, scope, options, callback) { | ||
if (typeof options === "function") { | ||
@@ -345,3 +326,2 @@ return _change(doc, "changeAt", {}, options, scope); | ||
} | ||
exports.changeAt = changeAt; | ||
function progressDocument(doc, source, heads, callback) { | ||
@@ -351,3 +331,3 @@ if (heads == null) { | ||
} | ||
const state = (0, internal_state_1._state)(doc); | ||
const state = _state(doc); | ||
const nextState = Object.assign(Object.assign({}, state), { heads: undefined }); | ||
@@ -372,3 +352,3 @@ let nextDoc; | ||
} | ||
const state = (0, internal_state_1._state)(doc); | ||
const state = _state(doc); | ||
if (doc === undefined || state === undefined) { | ||
@@ -380,3 +360,3 @@ throw new RangeError("must be the document root"); | ||
} | ||
if ((0, internal_state_1._is_proxy)(doc)) { | ||
if (_is_proxy(doc)) { | ||
throw new RangeError("Calls to Automerge.change cannot be nested"); | ||
@@ -390,3 +370,3 @@ } | ||
state.heads = heads; | ||
const root = (0, proxies_1.rootProxy)(state.handle, state.textV2); | ||
const root = rootProxy(state.handle, state.textV2); | ||
callback(root); | ||
@@ -429,3 +409,3 @@ if (state.handle.pendingOps() === 0) { | ||
*/ | ||
function emptyChange(doc, options) { | ||
export function emptyChange(doc, options) { | ||
if (options === undefined) { | ||
@@ -437,7 +417,7 @@ options = {}; | ||
} | ||
const state = (0, internal_state_1._state)(doc); | ||
const state = _state(doc); | ||
if (state.heads) { | ||
throw new RangeError("Attempting to change an outdated document. Use Automerge.clone() if you wish to make a writable copy."); | ||
} | ||
if ((0, internal_state_1._is_proxy)(doc)) { | ||
if (_is_proxy(doc)) { | ||
throw new RangeError("Calls to Automerge.change cannot be nested"); | ||
@@ -449,3 +429,2 @@ } | ||
} | ||
exports.emptyChange = emptyChange; | ||
/** | ||
@@ -466,3 +445,3 @@ * Load an automerge document from a compressed document produce by {@link save} | ||
*/ | ||
function load(data, _opts) { | ||
export function load(data, _opts) { | ||
const opts = importOpts(_opts); | ||
@@ -474,3 +453,3 @@ const actor = opts.actor; | ||
const allowMissingDeps = opts.allowMissingChanges || false; | ||
const handle = low_level_1.ApiHandler.load(data, { | ||
const handle = ApiHandler.load(data, { | ||
text_v1, | ||
@@ -482,9 +461,9 @@ actor, | ||
handle.enableFreeze(!!opts.freeze); | ||
handle.registerDatatype("counter", (n) => new types_1.Counter(n)); | ||
handle.registerDatatype("counter", (n) => new Counter(n)); | ||
const textV2 = opts.enableTextV2 || false; | ||
if (textV2) { | ||
handle.registerDatatype("str", (n) => new raw_string_1.RawString(n)); | ||
handle.registerDatatype("str", (n) => new RawString(n)); | ||
} | ||
else { | ||
handle.registerDatatype("text", (n) => new text_1.Text(n)); | ||
handle.registerDatatype("text", (n) => new Text(n)); | ||
} | ||
@@ -499,3 +478,2 @@ const doc = handle.materialize("/", undefined, { | ||
} | ||
exports.load = load; | ||
/** | ||
@@ -518,11 +496,11 @@ * Load changes produced by {@link saveIncremental}, or partial changes | ||
*/ | ||
function loadIncremental(doc, data, opts) { | ||
export function loadIncremental(doc, data, opts) { | ||
if (!opts) { | ||
opts = {}; | ||
} | ||
const state = (0, internal_state_1._state)(doc); | ||
const state = _state(doc); | ||
if (state.heads) { | ||
throw new RangeError("Attempting to change an out of date document - set at: " + (0, internal_state_1._trace)(doc)); | ||
throw new RangeError("Attempting to change an out of date document - set at: " + _trace(doc)); | ||
} | ||
if ((0, internal_state_1._is_proxy)(doc)) { | ||
if (_is_proxy(doc)) { | ||
throw new RangeError("Calls to Automerge.change cannot be nested"); | ||
@@ -534,3 +512,2 @@ } | ||
} | ||
exports.loadIncremental = loadIncremental; | ||
/** | ||
@@ -547,8 +524,8 @@ * Create binary save data to be appended to a save file or fed into {@link loadIncremental} | ||
*/ | ||
function saveIncremental(doc) { | ||
const state = (0, internal_state_1._state)(doc); | ||
export function saveIncremental(doc) { | ||
const state = _state(doc); | ||
if (state.heads) { | ||
throw new RangeError("Attempting to change an out of date document - set at: " + (0, internal_state_1._trace)(doc)); | ||
throw new RangeError("Attempting to change an out of date document - set at: " + _trace(doc)); | ||
} | ||
if ((0, internal_state_1._is_proxy)(doc)) { | ||
if (_is_proxy(doc)) { | ||
throw new RangeError("Calls to Automerge.change cannot be nested"); | ||
@@ -558,3 +535,2 @@ } | ||
} | ||
exports.saveIncremental = saveIncremental; | ||
/** | ||
@@ -567,6 +543,5 @@ * Export the contents of a document to a compressed format | ||
*/ | ||
function save(doc) { | ||
return (0, internal_state_1._state)(doc).handle.save(); | ||
export function save(doc) { | ||
return _state(doc).handle.save(); | ||
} | ||
exports.save = save; | ||
/** | ||
@@ -587,9 +562,9 @@ * Merge `local` into `remote` | ||
*/ | ||
function merge(local, remote) { | ||
const localState = (0, internal_state_1._state)(local); | ||
export function merge(local, remote) { | ||
const localState = _state(local); | ||
if (localState.heads) { | ||
throw new RangeError("Attempting to change an out of date document - set at: " + (0, internal_state_1._trace)(local)); | ||
throw new RangeError("Attempting to change an out of date document - set at: " + _trace(local)); | ||
} | ||
const heads = localState.handle.getHeads(); | ||
const remoteState = (0, internal_state_1._state)(remote); | ||
const remoteState = _state(remote); | ||
const changes = localState.handle.getChangesAdded(remoteState.handle); | ||
@@ -599,11 +574,9 @@ localState.handle.applyChanges(changes); | ||
} | ||
exports.merge = merge; | ||
/** | ||
* Get the actor ID associated with the document | ||
*/ | ||
function getActorId(doc) { | ||
const state = (0, internal_state_1._state)(doc); | ||
export function getActorId(doc) { | ||
const state = _state(doc); | ||
return state.handle.getActorId(); | ||
} | ||
exports.getActorId = getActorId; | ||
/** | ||
@@ -653,10 +626,10 @@ * Get the conflicts associated with a property | ||
*/ | ||
function getConflicts(doc, prop) { | ||
const state = (0, internal_state_1._state)(doc, false); | ||
export function getConflicts(doc, prop) { | ||
const state = _state(doc, false); | ||
if (state.textV2) { | ||
throw new Error("use unstable.getConflicts for an unstable document"); | ||
} | ||
const objectId = (0, internal_state_1._obj)(doc); | ||
const objectId = _obj(doc); | ||
if (objectId != null) { | ||
return (0, conflicts_1.stableConflictAt)(state.handle, objectId, prop); | ||
return stableConflictAt(state.handle, objectId, prop); | ||
} | ||
@@ -667,3 +640,2 @@ else { | ||
} | ||
exports.getConflicts = getConflicts; | ||
/** | ||
@@ -676,7 +648,6 @@ * Get the binary representation of the last change which was made to this doc | ||
*/ | ||
function getLastLocalChange(doc) { | ||
const state = (0, internal_state_1._state)(doc); | ||
export function getLastLocalChange(doc) { | ||
const state = _state(doc); | ||
return state.handle.getLastLocalChange() || undefined; | ||
} | ||
exports.getLastLocalChange = getLastLocalChange; | ||
/** | ||
@@ -689,6 +660,6 @@ * Return the object ID of an arbitrary javascript value | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function getObjectId(doc, prop) { | ||
export function getObjectId(doc, prop) { | ||
if (prop) { | ||
const state = (0, internal_state_1._state)(doc, false); | ||
const objectId = (0, internal_state_1._obj)(doc); | ||
const state = _state(doc, false); | ||
const objectId = _obj(doc); | ||
if (!state || !objectId) { | ||
@@ -700,6 +671,5 @@ return null; | ||
else { | ||
return (0, internal_state_1._obj)(doc); | ||
return _obj(doc); | ||
} | ||
} | ||
exports.getObjectId = getObjectId; | ||
/** | ||
@@ -711,7 +681,6 @@ * Get the changes which are in `newState` but not in `oldState`. The returned | ||
*/ | ||
function getChanges(oldState, newState) { | ||
const n = (0, internal_state_1._state)(newState); | ||
export function getChanges(oldState, newState) { | ||
const n = _state(newState); | ||
return n.handle.getChanges(getHeads(oldState)); | ||
} | ||
exports.getChanges = getChanges; | ||
/** | ||
@@ -724,7 +693,6 @@ * Get all the changes in a document | ||
*/ | ||
function getAllChanges(doc) { | ||
const state = (0, internal_state_1._state)(doc); | ||
export function getAllChanges(doc) { | ||
const state = _state(doc); | ||
return state.handle.getChanges([]); | ||
} | ||
exports.getAllChanges = getAllChanges; | ||
/** | ||
@@ -741,4 +709,4 @@ * Apply changes received from another document | ||
*/ | ||
function applyChanges(doc, changes, opts) { | ||
const state = (0, internal_state_1._state)(doc); | ||
export function applyChanges(doc, changes, opts) { | ||
const state = _state(doc); | ||
if (!opts) { | ||
@@ -750,3 +718,3 @@ opts = {}; | ||
} | ||
if ((0, internal_state_1._is_proxy)(doc)) { | ||
if (_is_proxy(doc)) { | ||
throw new RangeError("Calls to Automerge.change cannot be nested"); | ||
@@ -761,6 +729,5 @@ } | ||
} | ||
exports.applyChanges = applyChanges; | ||
/** @hidden */ | ||
function getHistory(doc) { | ||
const textV2 = (0, internal_state_1._state)(doc).textV2; | ||
export function getHistory(doc) { | ||
const textV2 = _state(doc).textV2; | ||
const history = getAllChanges(doc); | ||
@@ -777,3 +744,2 @@ return history.map((change, index) => ({ | ||
} | ||
exports.getHistory = getHistory; | ||
/** | ||
@@ -784,11 +750,10 @@ * Create a set of patches representing the change from one set of heads to another | ||
*/ | ||
function diff(doc, before, after) { | ||
const state = (0, internal_state_1._state)(doc); | ||
export function diff(doc, before, after) { | ||
const state = _state(doc); | ||
return state.handle.diff(before, after); | ||
} | ||
exports.diff = diff; | ||
/** @hidden */ | ||
// FIXME : no tests | ||
// FIXME can we just use deep equals now? | ||
function equals(val1, val2) { | ||
export function equals(val1, val2) { | ||
if (!isObject(val1) || !isObject(val2)) | ||
@@ -807,3 +772,2 @@ return val1 === val2; | ||
} | ||
exports.equals = equals; | ||
/** | ||
@@ -814,9 +778,8 @@ * encode a {@link SyncState} into binary to send over the network | ||
* */ | ||
function encodeSyncState(state) { | ||
const sync = low_level_1.ApiHandler.importSyncState(state); | ||
const result = low_level_1.ApiHandler.encodeSyncState(sync); | ||
export function encodeSyncState(state) { | ||
const sync = ApiHandler.importSyncState(state); | ||
const result = ApiHandler.encodeSyncState(sync); | ||
sync.free(); | ||
return result; | ||
} | ||
exports.encodeSyncState = encodeSyncState; | ||
/** | ||
@@ -827,9 +790,8 @@ * Decode some binary data into a {@link SyncState} | ||
*/ | ||
function decodeSyncState(state) { | ||
const sync = low_level_1.ApiHandler.decodeSyncState(state); | ||
const result = low_level_1.ApiHandler.exportSyncState(sync); | ||
export function decodeSyncState(state) { | ||
const sync = ApiHandler.decodeSyncState(state); | ||
const result = ApiHandler.exportSyncState(sync); | ||
sync.free(); | ||
return result; | ||
} | ||
exports.decodeSyncState = decodeSyncState; | ||
/** | ||
@@ -846,10 +808,9 @@ * Generate a sync message to send to the peer represented by `inState` | ||
*/ | ||
function generateSyncMessage(doc, inState) { | ||
const state = (0, internal_state_1._state)(doc); | ||
const syncState = low_level_1.ApiHandler.importSyncState(inState); | ||
export function generateSyncMessage(doc, inState) { | ||
const state = _state(doc); | ||
const syncState = ApiHandler.importSyncState(inState); | ||
const message = state.handle.generateSyncMessage(syncState); | ||
const outState = low_level_1.ApiHandler.exportSyncState(syncState); | ||
const outState = ApiHandler.exportSyncState(syncState); | ||
return [outState, message]; | ||
} | ||
exports.generateSyncMessage = generateSyncMessage; | ||
/** | ||
@@ -872,12 +833,12 @@ * Update a document and our sync state on receiving a sync message | ||
*/ | ||
function receiveSyncMessage(doc, inState, message, opts) { | ||
const syncState = low_level_1.ApiHandler.importSyncState(inState); | ||
export function receiveSyncMessage(doc, inState, message, opts) { | ||
const syncState = ApiHandler.importSyncState(inState); | ||
if (!opts) { | ||
opts = {}; | ||
} | ||
const state = (0, internal_state_1._state)(doc); | ||
const state = _state(doc); | ||
if (state.heads) { | ||
throw new RangeError("Attempting to change an outdated document. Use Automerge.clone() if you wish to make a writable copy."); | ||
} | ||
if ((0, internal_state_1._is_proxy)(doc)) { | ||
if (_is_proxy(doc)) { | ||
throw new RangeError("Calls to Automerge.change cannot be nested"); | ||
@@ -887,3 +848,3 @@ } | ||
state.handle.receiveSyncMessage(syncState, message); | ||
const outSyncState = low_level_1.ApiHandler.exportSyncState(syncState); | ||
const outSyncState = ApiHandler.exportSyncState(syncState); | ||
return [ | ||
@@ -895,3 +856,2 @@ progressDocument(doc, "receiveSyncMessage", heads, opts.patchCallback || state.patchCallback), | ||
} | ||
exports.receiveSyncMessage = receiveSyncMessage; | ||
/** | ||
@@ -905,51 +865,43 @@ * Create a new, blank {@link SyncState} | ||
*/ | ||
function initSyncState() { | ||
return low_level_1.ApiHandler.exportSyncState(low_level_1.ApiHandler.initSyncState()); | ||
export function initSyncState() { | ||
return ApiHandler.exportSyncState(ApiHandler.initSyncState()); | ||
} | ||
exports.initSyncState = initSyncState; | ||
/** @hidden */ | ||
function encodeChange(change) { | ||
return low_level_1.ApiHandler.encodeChange(change); | ||
export function encodeChange(change) { | ||
return ApiHandler.encodeChange(change); | ||
} | ||
exports.encodeChange = encodeChange; | ||
/** @hidden */ | ||
function decodeChange(data) { | ||
return low_level_1.ApiHandler.decodeChange(data); | ||
export function decodeChange(data) { | ||
return ApiHandler.decodeChange(data); | ||
} | ||
exports.decodeChange = decodeChange; | ||
/** @hidden */ | ||
function encodeSyncMessage(message) { | ||
return low_level_1.ApiHandler.encodeSyncMessage(message); | ||
export function encodeSyncMessage(message) { | ||
return ApiHandler.encodeSyncMessage(message); | ||
} | ||
exports.encodeSyncMessage = encodeSyncMessage; | ||
/** @hidden */ | ||
function decodeSyncMessage(message) { | ||
return low_level_1.ApiHandler.decodeSyncMessage(message); | ||
export function decodeSyncMessage(message) { | ||
return ApiHandler.decodeSyncMessage(message); | ||
} | ||
exports.decodeSyncMessage = decodeSyncMessage; | ||
/** | ||
* Get any changes in `doc` which are not dependencies of `heads` | ||
*/ | ||
function getMissingDeps(doc, heads) { | ||
const state = (0, internal_state_1._state)(doc); | ||
export function getMissingDeps(doc, heads) { | ||
const state = _state(doc); | ||
return state.handle.getMissingDeps(heads); | ||
} | ||
exports.getMissingDeps = getMissingDeps; | ||
/** | ||
* Get the hashes of the heads of this document | ||
*/ | ||
function getHeads(doc) { | ||
const state = (0, internal_state_1._state)(doc); | ||
export function getHeads(doc) { | ||
const state = _state(doc); | ||
return state.heads || state.handle.getHeads(); | ||
} | ||
exports.getHeads = getHeads; | ||
/** @hidden */ | ||
function dump(doc) { | ||
const state = (0, internal_state_1._state)(doc); | ||
export function dump(doc) { | ||
const state = _state(doc); | ||
state.handle.dump(); | ||
} | ||
exports.dump = dump; | ||
/** @hidden */ | ||
function toJS(doc) { | ||
const state = (0, internal_state_1._state)(doc); | ||
export function toJS(doc) { | ||
const state = _state(doc); | ||
const enabled = state.handle.enableFreeze(false); | ||
@@ -960,6 +912,5 @@ const result = state.handle.materialize(); | ||
} | ||
exports.toJS = toJS; | ||
function isAutomerge(doc) { | ||
export function isAutomerge(doc) { | ||
if (typeof doc == "object" && doc !== null) { | ||
return getObjectId(doc) === "_root" && !!Reflect.get(doc, constants_1.STATE); | ||
return getObjectId(doc) === "_root" && !!Reflect.get(doc, STATE); | ||
} | ||
@@ -970,11 +921,9 @@ else { | ||
} | ||
exports.isAutomerge = isAutomerge; | ||
function isObject(obj) { | ||
return typeof obj === "object" && obj !== null; | ||
} | ||
function saveSince(doc, heads) { | ||
const state = (0, internal_state_1._state)(doc); | ||
export function saveSince(doc, heads) { | ||
const state = _state(doc); | ||
const result = state.handle.saveSince(heads); | ||
return result; | ||
} | ||
exports.saveSince = saveSince; |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Text = void 0; | ||
const constants_1 = require("./constants"); | ||
class Text { | ||
import { TEXT, STATE } from "./constants.js"; | ||
export class Text { | ||
constructor(text) { | ||
@@ -19,3 +16,3 @@ if (typeof text === "string") { | ||
} | ||
Reflect.defineProperty(this, constants_1.TEXT, { value: true }); | ||
Reflect.defineProperty(this, TEXT, { value: true }); | ||
} | ||
@@ -107,3 +104,3 @@ get length() { | ||
set(index, value) { | ||
if (this[constants_1.STATE]) { | ||
if (this[STATE]) { | ||
throw new RangeError("object cannot be modified outside of a change block"); | ||
@@ -117,3 +114,3 @@ } | ||
insertAt(index, ...values) { | ||
if (this[constants_1.STATE]) { | ||
if (this[STATE]) { | ||
throw new RangeError("object cannot be modified outside of a change block"); | ||
@@ -133,3 +130,3 @@ } | ||
deleteAt(index, numDelete = 1) { | ||
if (this[constants_1.STATE]) { | ||
if (this[STATE]) { | ||
throw new RangeError("object cannot be modified outside of a change block"); | ||
@@ -188,2 +185,1 @@ } | ||
} | ||
exports.Text = Text; |
@@ -1,11 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Float64 = exports.Uint = exports.Int = exports.Counter = exports.Text = void 0; | ||
var text_1 = require("./text"); | ||
Object.defineProperty(exports, "Text", { enumerable: true, get: function () { return text_1.Text; } }); | ||
var counter_1 = require("./counter"); | ||
Object.defineProperty(exports, "Counter", { enumerable: true, get: function () { return counter_1.Counter; } }); | ||
var numbers_1 = require("./numbers"); | ||
Object.defineProperty(exports, "Int", { enumerable: true, get: function () { return numbers_1.Int; } }); | ||
Object.defineProperty(exports, "Uint", { enumerable: true, get: function () { return numbers_1.Uint; } }); | ||
Object.defineProperty(exports, "Float64", { enumerable: true, get: function () { return numbers_1.Float64; } }); | ||
export { Text } from "./text.js"; | ||
export { Counter } from "./counter.js"; | ||
export { Int, Uint, Float64 } from "./numbers.js"; |
@@ -1,18 +0,14 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.uuid = void 0; | ||
const uuid_1 = require("uuid"); | ||
import { v4 } from "uuid"; | ||
function defaultFactory() { | ||
return (0, uuid_1.v4)().replace(/-/g, ""); | ||
return v4().replace(/-/g, ""); | ||
} | ||
let factory = defaultFactory; | ||
const uuid = () => { | ||
export const uuid = () => { | ||
return factory(); | ||
}; | ||
exports.uuid = uuid; | ||
exports.uuid.setFactory = newFactory => { | ||
uuid.setFactory = newFactory => { | ||
factory = newFactory; | ||
}; | ||
exports.uuid.reset = () => { | ||
uuid.reset = () => { | ||
factory = defaultFactory; | ||
}; |
@@ -1,3 +0,3 @@ | ||
import { type Target, Text1Target, Text2Target } from "./proxies"; | ||
import { ValueType } from "./proxies"; | ||
import { type Target, Text1Target, Text2Target } from "./proxies.js"; | ||
import { ValueType } from "./proxies.js"; | ||
import type { Prop, ObjID } from "@automerge/automerge-wasm"; | ||
@@ -4,0 +4,0 @@ import { Automerge } from "@automerge/automerge-wasm"; |
@@ -236,4 +236,4 @@ /** | ||
*/ | ||
export * from "./stable"; | ||
import * as next from "./next"; | ||
export * from "./stable.js"; | ||
import * as next from "./next.js"; | ||
export { next }; |
import { type ObjID, type Heads, Automerge } from "@automerge/automerge-wasm"; | ||
import type { Doc, PatchCallback } from "./types"; | ||
import type { Doc, PatchCallback } from "./types.js"; | ||
export interface InternalState<T> { | ||
@@ -4,0 +4,0 @@ handle: Automerge; |
@@ -1,4 +0,4 @@ | ||
import { Counter } from "./types"; | ||
import { Text } from "./text"; | ||
import { mapProxy, listProxy } from "./proxies"; | ||
import { Counter } from "./types.js"; | ||
import { Text } from "./text.js"; | ||
import { mapProxy, listProxy } from "./proxies.js"; | ||
export function stableConflictAt(context, objectId, prop) { | ||
@@ -5,0 +5,0 @@ return conflictAt(context, objectId, prop, true, (context, conflictId) => { |
@@ -1,2 +0,2 @@ | ||
import { COUNTER } from "./constants"; | ||
import { COUNTER } from "./constants.js"; | ||
/** | ||
@@ -3,0 +3,0 @@ * The most basic CRDT: an integer value that can be changed only by |
@@ -236,4 +236,4 @@ /** | ||
*/ | ||
export * from "./stable"; | ||
import * as next from "./next"; | ||
export * from "./stable.js"; | ||
import * as next from "./next.js"; | ||
export { next }; |
@@ -1,2 +0,2 @@ | ||
import { STATE, OBJECT_ID, CLEAR_CACHE, TRACE, IS_PROXY } from "./constants"; | ||
import { STATE, OBJECT_ID, CLEAR_CACHE, TRACE, IS_PROXY } from "./constants.js"; | ||
export function _state(doc, checkroot = true) { | ||
@@ -3,0 +3,0 @@ if (typeof doc !== "object") { |
@@ -1,2 +0,2 @@ | ||
export { Counter, Int, Uint, Float64, } from "./types"; | ||
export { RawString } from "./raw_string"; | ||
export { Counter, Int, Uint, Float64, } from "./types.js"; | ||
export { RawString } from "./raw_string.js"; |
@@ -37,10 +37,10 @@ /** | ||
*/ | ||
export { Counter, Int, Uint, Float64, } from "./next_types"; | ||
import { unstableConflictAt } from "./conflicts"; | ||
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"; | ||
import * as stable from "./stable"; | ||
export { RawString } from "./raw_string"; | ||
export { Counter, Int, Uint, Float64, } from "./next_types.js"; | ||
import { unstableConflictAt } from "./conflicts.js"; | ||
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"; | ||
import * as stable from "./stable.js"; | ||
export { RawString } from "./raw_string.js"; | ||
/** @hidden */ | ||
export const getBackend = stable.getBackend; | ||
import { _is_proxy, _state, _obj, _clear_cache } from "./internal_state"; | ||
import { _is_proxy, _state, _obj, _clear_cache } from "./internal_state.js"; | ||
/** | ||
@@ -47,0 +47,0 @@ * Create a new automerge document |
// Convenience classes to allow users to strictly specify the number type they want | ||
import { INT, UINT, F64 } from "./constants"; | ||
import { INT, UINT, F64 } from "./constants.js"; | ||
export class Int { | ||
@@ -4,0 +4,0 @@ constructor(value) { |
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { Text } from "./text"; | ||
import { getWriteableCounter } from "./counter"; | ||
import { STATE, TRACE, IS_PROXY, OBJECT_ID, CLEAR_CACHE, COUNTER, INT, UINT, F64, } from "./constants"; | ||
import { RawString } from "./raw_string"; | ||
import { Text } from "./text.js"; | ||
import { getWriteableCounter } from "./counter.js"; | ||
import { STATE, TRACE, IS_PROXY, OBJECT_ID, CLEAR_CACHE, COUNTER, INT, UINT, F64, } from "./constants.js"; | ||
import { RawString } from "./raw_string.js"; | ||
function parseListIndex(key) { | ||
@@ -7,0 +7,0 @@ if (typeof key === "string" && /^[0-9]+$/.test(key)) |
@@ -13,14 +13,14 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
/** @hidden **/ | ||
export { /** @hidden */ uuid } from "./uuid"; | ||
import { rootProxy } from "./proxies"; | ||
import { STATE } from "./constants"; | ||
import { Counter, } from "./types"; | ||
export { Counter, Int, Uint, Float64, } from "./types"; | ||
import { Text } from "./text"; | ||
export { Text } from "./text"; | ||
export { /** @hidden */ uuid } from "./uuid.js"; | ||
import { rootProxy } from "./proxies.js"; | ||
import { STATE } from "./constants.js"; | ||
import { Counter, } from "./types.js"; | ||
export { Counter, Int, Uint, Float64, } from "./types.js"; | ||
import { Text } from "./text.js"; | ||
export { Text } from "./text.js"; | ||
const SyncStateSymbol = Symbol("_syncstate"); | ||
import { ApiHandler, UseApi } from "./low_level"; | ||
import { RawString } from "./raw_string"; | ||
import { _state, _is_proxy, _trace, _obj } from "./internal_state"; | ||
import { stableConflictAt } from "./conflicts"; | ||
import { ApiHandler, UseApi } from "./low_level.js"; | ||
import { RawString } from "./raw_string.js"; | ||
import { _state, _is_proxy, _trace, _obj } from "./internal_state.js"; | ||
import { stableConflictAt } from "./conflicts.js"; | ||
/** | ||
@@ -27,0 +27,0 @@ * Function for use in {@link change} which inserts values into a list at a given index |
@@ -1,2 +0,2 @@ | ||
import { TEXT, STATE } from "./constants"; | ||
import { TEXT, STATE } from "./constants.js"; | ||
export class Text { | ||
@@ -3,0 +3,0 @@ constructor(text) { |
@@ -1,3 +0,3 @@ | ||
export { Text } from "./text"; | ||
export { Counter } from "./counter"; | ||
export { Int, Uint, Float64 } from "./numbers"; | ||
export { Text } from "./text.js"; | ||
export { Counter } from "./counter.js"; | ||
export { Int, Uint, Float64 } from "./numbers.js"; |
@@ -1,5 +0,5 @@ | ||
import { Counter } from "./types"; | ||
export { Counter, type Doc, Int, Uint, Float64, type Patch, type PatchCallback, type Mark, type MarkRange, type MarkValue, type Cursor, type PatchInfo, type PatchSource, } from "./types"; | ||
import { RawString } from "./raw_string"; | ||
export { RawString } from "./raw_string"; | ||
import { Counter } from "./types.js"; | ||
export { Counter, type Doc, Int, Uint, Float64, type Patch, type PatchCallback, type Mark, type MarkRange, type MarkValue, type Cursor, type PatchInfo, type PatchSource, } from "./types.js"; | ||
import { RawString } from "./raw_string.js"; | ||
export { RawString } from "./raw_string.js"; | ||
export type AutomergeValue = ScalarValue | { | ||
@@ -6,0 +6,0 @@ [key: string]: AutomergeValue; |
@@ -37,9 +37,9 @@ /** | ||
*/ | ||
export { Counter, type Doc, Int, Uint, Float64, type Patch, type PatchCallback, type Mark, type MarkRange, type MarkValue, type AutomergeValue, type ScalarValue, type PatchSource, type PatchInfo, } from "./next_types"; | ||
import type { Cursor, Mark, MarkRange, MarkValue } from "./next_types"; | ||
import { type PatchCallback } from "./stable"; | ||
import { type UnstableConflicts as Conflicts } from "./conflicts"; | ||
export { Counter, type Doc, Int, Uint, Float64, type Patch, type PatchCallback, type Mark, type MarkRange, type MarkValue, type AutomergeValue, type ScalarValue, type PatchSource, type PatchInfo, } from "./next_types.js"; | ||
import type { Cursor, Mark, MarkRange, MarkValue } from "./next_types.js"; | ||
import { type PatchCallback } from "./stable.js"; | ||
import { type UnstableConflicts as Conflicts } from "./conflicts.js"; | ||
export type { PutPatch, DelPatch, SpliceTextPatch, InsertPatch, IncPatch, SyncMessage, Heads, Cursor, } from "@automerge/automerge-wasm"; | ||
export type { ChangeOptions, ApplyOptions, ChangeFn } from "./stable"; | ||
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"; | ||
export type { ActorId, Change, ChangeOptions, Prop, DecodedChange, DecodedSyncMessage, ApplyOptions, ChangeFn, ChangeAtResult, MaterializeValue, SyncState, } from "./stable.js"; | ||
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"; | ||
export type InitOptions<T> = { | ||
@@ -56,5 +56,5 @@ /** The actor ID to use for this document, a random one will be generated if `null` is passed */ | ||
}; | ||
import { ActorId, Doc } from "./stable"; | ||
import * as stable from "./stable"; | ||
export { RawString } from "./raw_string"; | ||
import { ActorId, Doc } from "./stable.js"; | ||
import * as stable from "./stable.js"; | ||
export { RawString } from "./raw_string.js"; | ||
/** @hidden */ | ||
@@ -61,0 +61,0 @@ export declare const getBackend: typeof stable.getBackend; |
@@ -1,5 +0,5 @@ | ||
import { Text } from "./text"; | ||
import { Text } from "./text.js"; | ||
import { Automerge, type ObjID, type Prop } from "@automerge/automerge-wasm"; | ||
import type { AutomergeValue, MapValue, ListValue } from "./types"; | ||
import { type AutomergeValue as UnstableAutomergeValue, MapValue as UnstableMapValue, ListValue as UnstableListValue } from "./next_types"; | ||
import type { AutomergeValue, MapValue, ListValue } from "./types.js"; | ||
import { type AutomergeValue as UnstableAutomergeValue, MapValue as UnstableMapValue, ListValue as UnstableListValue } from "./next_types.js"; | ||
type TargetCommon = { | ||
@@ -6,0 +6,0 @@ context: Automerge; |
/** @hidden **/ | ||
export { /** @hidden */ uuid } from "./uuid"; | ||
import { type AutomergeValue, type Doc, type PatchCallback, type Patch } from "./types"; | ||
export { type AutomergeValue, Counter, type Doc, Int, Uint, Float64, type Patch, type PatchCallback, type ScalarValue, type PatchInfo, type PatchSource, } from "./types"; | ||
export { Text } from "./text"; | ||
export { /** @hidden */ uuid } from "./uuid.js"; | ||
import { type AutomergeValue, type Doc, type PatchCallback, type Patch } from "./types.js"; | ||
export { type AutomergeValue, Counter, type Doc, Int, Uint, Float64, type Patch, type PatchCallback, type ScalarValue, type PatchInfo, type PatchSource, } from "./types.js"; | ||
export { Text } from "./text.js"; | ||
import type { API as WasmAPI, Actor as ActorId, Prop, ObjID, Change, DecodedChange, Heads, MaterializeValue, JsSyncState, SyncMessage, DecodedSyncMessage } from "@automerge/automerge-wasm"; | ||
@@ -17,3 +17,3 @@ export type { PutPatch, DelPatch, SpliceTextPatch, InsertPatch, IncPatch, SyncMessage, } from "@automerge/automerge-wasm"; | ||
}; | ||
import { type ChangeToEncode } from "./low_level"; | ||
import { type ChangeToEncode } from "./low_level.js"; | ||
import { Automerge } from "@automerge/automerge-wasm"; | ||
@@ -20,0 +20,0 @@ /** Options passed to {@link change}, and {@link emptyChange} |
import type { Value } from "@automerge/automerge-wasm"; | ||
import { STATE } from "./constants"; | ||
import type { InternalState } from "./internal_state"; | ||
import { STATE } from "./constants.js"; | ||
import type { InternalState } from "./internal_state.js"; | ||
export declare class Text { | ||
@@ -5,0 +5,0 @@ elems: Array<any>; |
@@ -1,6 +0,6 @@ | ||
export { Text } from "./text"; | ||
import { Text } from "./text"; | ||
export { Counter } from "./counter"; | ||
export { Int, Uint, Float64 } from "./numbers"; | ||
import { Counter } from "./counter"; | ||
export { Text } from "./text.js"; | ||
import { Text } from "./text.js"; | ||
export { Counter } from "./counter.js"; | ||
export { Int, Uint, Float64 } from "./numbers.js"; | ||
import { Counter } from "./counter.js"; | ||
import type { Patch } from "@automerge/automerge-wasm"; | ||
@@ -7,0 +7,0 @@ export type { Cursor, Patch, Mark, MarkRange } from "@automerge/automerge-wasm"; |
@@ -7,3 +7,3 @@ { | ||
], | ||
"version": "2.1.0-alpha.11", | ||
"version": "2.1.0-alpha.12", | ||
"description": "Javascript implementation of automerge, backed by @automerge/automerge-wasm", | ||
@@ -21,5 +21,20 @@ "homepage": "https://github.com/automerge/automerge/tree/main/javascript", | ||
], | ||
"type": "module", | ||
"types": "./dist/index.d.ts", | ||
"module": "./dist/mjs/index.js", | ||
"main": "./dist/cjs/index.js", | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/mjs/index.js", | ||
"require": "./dist/cjs/index.js", | ||
"default": "./dist/mjs/index.js" | ||
}, | ||
"./next": { | ||
"types": "./dist/next.d.ts", | ||
"import": "./dist/mjs/next.js", | ||
"require": "./dist/cjs/next.js", | ||
"default": "./dist/mjs/next.js" | ||
} | ||
}, | ||
"license": "MIT", | ||
@@ -31,3 +46,3 @@ "scripts": { | ||
"build": "tsc -p config/mjs.json && tsc -p config/cjs.json && tsc -p config/declonly.json --emitDeclarationOnly", | ||
"test": "ts-mocha --type-check test/*.ts", | ||
"test": "ts-mocha --loader=ts-node/esm --experimental-specifier-resolution=node --type-check test/*.ts", | ||
"deno:build": "denoify && node ./scripts/deno-prefixer.mjs", | ||
@@ -40,2 +55,3 @@ "deno:test": "deno test ./deno-tests/deno.ts --allow-read --allow-net", | ||
"@types/mocha": "^10.0.1", | ||
"@types/node": "^20.5.7", | ||
"@types/uuid": "^9.0.0", | ||
@@ -59,5 +75,5 @@ "@typescript-eslint/eslint-plugin": "^5.46.0", | ||
"dependencies": { | ||
"@automerge/automerge-wasm": "^0.2.10", | ||
"@automerge/automerge-wasm": "^0.2.11", | ||
"uuid": "^9.0.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Yes
246356
16
6764