UNPKG

travels

Version:

A fast, framework-agnostic undo/redo core library powered by Mutative JSON Patch

1 lines 114 kB
{"version":3,"file":"index.cjs","sources":["../node_modules/tslib/tslib.es6.mjs","utils.js","travels.js","createTravels.js"],"sourcesContent":["/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\n\nvar extendStatics = function(d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n if (typeof b !== \"function\" && b !== null)\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n }\n return t;\n }\n return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n var _, done = false;\n for (var i = decorators.length - 1; i >= 0; i--) {\n var context = {};\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n if (kind === \"accessor\") {\n if (result === void 0) continue;\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n if (_ = accept(result.get)) descriptor.get = _;\n if (_ = accept(result.set)) descriptor.set = _;\n if (_ = accept(result.init)) initializers.unshift(_);\n }\n else if (_ = accept(result)) {\n if (kind === \"field\") initializers.unshift(_);\n else descriptor[key] = _;\n }\n }\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\n done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n var useValue = arguments.length > 2;\n for (var i = 0; i < initializers.length; i++) {\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n }\n return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n}\n\nexport function __generator(thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n for (var ar = [], i = 0; i < arguments.length; i++)\n ar = ar.concat(__read(arguments[i]));\n return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n};\n\nvar ownKeys = function(o) {\n ownKeys = Object.getOwnPropertyNames || function (o) {\n var ar = [];\n for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;\n return ar;\n };\n return ownKeys(o);\n};\n\nexport function __importStar(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== \"default\") __createBinding(result, mod, k[i]);\n __setModuleDefault(result, mod);\n return result;\n}\n\nexport function __importDefault(mod) {\n return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n if (value !== null && value !== void 0) {\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n var dispose, inner;\n if (async) {\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n dispose = value[Symbol.asyncDispose];\n }\n if (dispose === void 0) {\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n dispose = value[Symbol.dispose];\n if (async) inner = dispose;\n }\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\n env.stack.push({ value: value, dispose: dispose, async: async });\n }\n else if (async) {\n env.stack.push({ async: true });\n }\n return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n var e = new Error(message);\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n function fail(e) {\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n env.hasError = true;\n }\n var r, s = 0;\n function next() {\n while (r = env.stack.pop()) {\n try {\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\n if (r.dispose) {\n var result = r.dispose.call(r.value);\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n }\n else s |= 1;\n }\n catch (e) {\n fail(e);\n }\n }\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\n if (env.hasError) throw env.error;\n }\n return next();\n}\n\nexport function __rewriteRelativeImportExtension(path, preserveJsx) {\n if (typeof path === \"string\" && /^\\.\\.?\\//.test(path)) {\n return path.replace(/\\.(tsx)$|((?:\\.d)?)((?:\\.[^./]+?)?)\\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {\n return tsx ? preserveJsx ? \".jsx\" : \".js\" : d && (!ext || !cm) ? m : (d + ext + \".\" + cm.toLowerCase() + \"js\");\n });\n }\n return path;\n}\n\nexport default {\n __extends,\n __assign,\n __rest,\n __decorate,\n __param,\n __esDecorate,\n __runInitializers,\n __propKey,\n __setFunctionName,\n __metadata,\n __awaiter,\n __generator,\n __createBinding,\n __exportStar,\n __values,\n __read,\n __spread,\n __spreadArrays,\n __spreadArray,\n __await,\n __asyncGenerator,\n __asyncDelegator,\n __asyncValues,\n __makeTemplateObject,\n __importStar,\n __importDefault,\n __classPrivateFieldGet,\n __classPrivateFieldSet,\n __classPrivateFieldIn,\n __addDisposableResource,\n __disposeResources,\n __rewriteRelativeImportExtension,\n};\n","export const isObjectLike = (value) => {\n return typeof value === 'object' && value !== null;\n};\nexport const isPlainObject = (value) => {\n if (!isObjectLike(value)) {\n return false;\n }\n const proto = Object.getPrototypeOf(value);\n if (proto === null) {\n return true;\n }\n return proto === Object.prototype;\n};\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsTUFBTSxDQUFDLE1BQU0sWUFBWSxHQUFHLENBQzFCLEtBQWMsRUFDeUIsRUFBRTtJQUN6QyxPQUFPLE9BQU8sS0FBSyxLQUFLLFFBQVEsSUFBSSxLQUFLLEtBQUssSUFBSSxDQUFDO0FBQ3JELENBQUMsQ0FBQztBQUVGLE1BQU0sQ0FBQyxNQUFNLGFBQWEsR0FBRyxDQUMzQixLQUFjLEVBQ3lCLEVBQUU7SUFDekMsSUFBSSxDQUFDLFlBQVksQ0FBQyxLQUFLLENBQUMsRUFBRSxDQUFDO1FBQ3pCLE9BQU8sS0FBSyxDQUFDO0lBQ2YsQ0FBQztJQUVELE1BQU0sS0FBSyxHQUFHLE1BQU0sQ0FBQyxjQUFjLENBQUMsS0FBSyxDQUFDLENBQUM7SUFDM0MsSUFBSSxLQUFLLEtBQUssSUFBSSxFQUFFLENBQUM7UUFDbkIsT0FBTyxJQUFJLENBQUM7SUFDZCxDQUFDO0lBRUQsT0FBTyxLQUFLLEtBQUssTUFBTSxDQUFDLFNBQVMsQ0FBQztBQUNwQyxDQUFDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgY29uc3QgaXNPYmplY3RMaWtlID0gKFxuICB2YWx1ZTogdW5rbm93blxuKTogdmFsdWUgaXMgUmVjb3JkPFByb3BlcnR5S2V5LCB1bmtub3duPiA9PiB7XG4gIHJldHVybiB0eXBlb2YgdmFsdWUgPT09ICdvYmplY3QnICYmIHZhbHVlICE9PSBudWxsO1xufTtcblxuZXhwb3J0IGNvbnN0IGlzUGxhaW5PYmplY3QgPSAoXG4gIHZhbHVlOiB1bmtub3duXG4pOiB2YWx1ZSBpcyBSZWNvcmQ8UHJvcGVydHlLZXksIHVua25vd24+ID0+IHtcbiAgaWYgKCFpc09iamVjdExpa2UodmFsdWUpKSB7XG4gICAgcmV0dXJuIGZhbHNlO1xuICB9XG5cbiAgY29uc3QgcHJvdG8gPSBPYmplY3QuZ2V0UHJvdG90eXBlT2YodmFsdWUpO1xuICBpZiAocHJvdG8gPT09IG51bGwpIHtcbiAgICByZXR1cm4gdHJ1ZTtcbiAgfVxuXG4gIHJldHVybiBwcm90byA9PT0gT2JqZWN0LnByb3RvdHlwZTtcbn07XG4iXX0=","import { __rest } from \"tslib\";\nimport { apply, create, rawReturn, } from 'mutative';\nimport { isObjectLike, isPlainObject } from './utils';\nconst cloneTravelPatches = (base) => ({\n patches: base ? base.patches.map((patch) => [...patch]) : [],\n inversePatches: base ? base.inversePatches.map((patch) => [...patch]) : [],\n});\nconst deepCloneValue = (value) => {\n if (value === null || typeof value !== 'object') {\n return value;\n }\n if (Array.isArray(value)) {\n return value.map(deepCloneValue);\n }\n const cloned = {};\n for (const key in value) {\n if (Object.prototype.hasOwnProperty.call(value, key)) {\n cloned[key] = deepCloneValue(value[key]);\n }\n }\n return cloned;\n};\nconst deepClone = (source, target) => {\n if (target && source && typeof source === 'object') {\n for (const key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = deepCloneValue(source[key]);\n }\n }\n return target;\n }\n return deepCloneValue(source);\n};\nconst hasOnlyArrayIndices = (value) => {\n if (!Array.isArray(value)) {\n return false;\n }\n return Reflect.ownKeys(value).every((key) => {\n if (key === 'length') {\n return true;\n }\n if (typeof key === 'symbol') {\n return false;\n }\n const index = Number(key);\n return Number.isInteger(index) && index >= 0 && String(index) === key;\n });\n};\n// Align mutable value updates with immutable replacements by syncing objects\nconst overwriteDraftWith = (draft, value) => {\n const draftIsArray = Array.isArray(draft);\n const valueIsArray = Array.isArray(value);\n const draftKeys = Reflect.ownKeys(draft);\n for (const key of draftKeys) {\n if (draftIsArray && key === 'length') {\n continue;\n }\n if (!Object.prototype.hasOwnProperty.call(value, key)) {\n delete draft[key];\n }\n }\n if (draftIsArray && valueIsArray) {\n draft.length = value.length;\n }\n Object.assign(draft, value);\n};\n/**\n * Core Travels class for managing undo/redo history\n */\nexport class Travels {\n constructor(initialState, options = {}) {\n this.listeners = new Set();\n this.pendingState = null;\n this.historyCache = null;\n this.historyVersion = 0;\n this.mutableFallbackWarned = false;\n /**\n * Subscribe to state changes\n * @returns Unsubscribe function\n */\n this.subscribe = (listener) => {\n this.listeners.add(listener);\n return () => {\n this.listeners.delete(listener);\n };\n };\n /**\n * Get the current state\n */\n this.getState = () => this.state;\n const { maxHistory = 10, initialPatches, initialPosition = 0, autoArchive = true, mutable = false, patchesOptions } = options, mutativeOptions = __rest(options, [\"maxHistory\", \"initialPatches\", \"initialPosition\", \"autoArchive\", \"mutable\", \"patchesOptions\"]);\n // Validate and enforce maxHistory constraints\n if (maxHistory < 0) {\n throw new Error(`Travels: maxHistory must be non-negative, but got ${maxHistory}`);\n }\n if (maxHistory === 0 && process.env.NODE_ENV !== 'production') {\n console.warn('Travels: maxHistory is 0, which disables undo/redo history. This is rarely intended.');\n }\n // Validate options in development mode\n if (process.env.NODE_ENV !== 'production') {\n if (initialPatches) {\n if (!Array.isArray(initialPatches.patches) ||\n !Array.isArray(initialPatches.inversePatches)) {\n console.error(`Travels: initialPatches must have 'patches' and 'inversePatches' arrays`);\n }\n else if (initialPatches.patches.length !== initialPatches.inversePatches.length) {\n console.error(`Travels: initialPatches.patches and initialPatches.inversePatches must have the same length`);\n }\n }\n }\n this.state = initialState;\n // For mutable mode, deep clone initialState to prevent mutations\n this.initialState = mutable ? deepClone(initialState) : initialState;\n this.maxHistory = maxHistory;\n this.autoArchive = autoArchive;\n this.mutable = mutable;\n this.options = Object.assign(Object.assign({}, mutativeOptions), { enablePatches: patchesOptions !== null && patchesOptions !== void 0 ? patchesOptions : true });\n const { patches: normalizedPatches, position: normalizedPosition } = this.normalizeInitialHistory(initialPatches, initialPosition);\n this.allPatches = normalizedPatches;\n this.initialPatches = initialPatches\n ? cloneTravelPatches(normalizedPatches)\n : undefined;\n this.position = normalizedPosition;\n this.initialPosition = normalizedPosition;\n this.tempPatches = cloneTravelPatches();\n }\n normalizeInitialHistory(initialPatches, initialPosition) {\n const cloned = cloneTravelPatches(initialPatches);\n const total = cloned.patches.length;\n const historyLimit = this.maxHistory > 0 ? this.maxHistory : 0;\n const invalidInitialPosition = typeof initialPosition !== 'number' || !Number.isFinite(initialPosition);\n let position = invalidInitialPosition ? 0 : initialPosition;\n const clampedPosition = Math.max(0, Math.min(position, total));\n if (process.env.NODE_ENV !== 'production' &&\n (invalidInitialPosition || clampedPosition !== position)) {\n console.warn(`Travels: initialPosition (${initialPosition}) is invalid for available patches (${total}). ` +\n `Using ${clampedPosition} instead.`);\n }\n position = clampedPosition;\n if (total === 0) {\n return { patches: cloned, position: 0 };\n }\n if (historyLimit === 0) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`Travels: maxHistory (${this.maxHistory}) discards persisted history.`);\n }\n return { patches: cloneTravelPatches(), position: 0 };\n }\n if (historyLimit >= total) {\n return { patches: cloned, position };\n }\n const trim = total - historyLimit;\n const trimmedBase = {\n patches: cloned.patches.slice(-historyLimit),\n inversePatches: cloned.inversePatches.slice(-historyLimit),\n };\n const trimmed = cloneTravelPatches(trimmedBase);\n const adjustedPosition = Math.max(0, Math.min(historyLimit, position - trim));\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`Travels: initialPatches length (${total}) exceeds maxHistory (${historyLimit}). ` +\n `Trimmed to last ${historyLimit} steps. Position adjusted to ${adjustedPosition}.`);\n }\n return {\n patches: trimmed,\n position: adjustedPosition,\n };\n }\n invalidateHistoryCache() {\n this.historyVersion += 1;\n this.historyCache = null;\n }\n /**\n * Notify all listeners of state changes\n */\n notify() {\n this.listeners.forEach((listener) => listener(this.state, this.getPatches(), this.position));\n }\n /**\n * Check if patches contain root-level replacement operations\n * Root replacement cannot be done mutably as it changes the type/value of the entire state\n */\n hasRootReplacement(patches) {\n return patches.some((patch) => Array.isArray(patch.path) &&\n patch.path.length === 0 &&\n patch.op === 'replace');\n }\n /**\n * Update the state\n */\n setState(updater) {\n let patches;\n let inversePatches;\n const canUseMutableRoot = this.mutable && isObjectLike(this.state);\n const isFunctionUpdater = typeof updater === 'function';\n const stateIsArray = Array.isArray(this.state);\n const updaterIsArray = Array.isArray(updater);\n const canMutatePlainObjects = !stateIsArray &&\n !updaterIsArray &&\n isPlainObject(this.state) &&\n isPlainObject(updater);\n const canMutateArrays = stateIsArray &&\n updaterIsArray &&\n hasOnlyArrayIndices(this.state) &&\n hasOnlyArrayIndices(updater);\n const canMutateWithValue = canUseMutableRoot &&\n !isFunctionUpdater &&\n (canMutateArrays || canMutatePlainObjects);\n const useMutable = (isFunctionUpdater && canUseMutableRoot) || canMutateWithValue;\n if (this.mutable && !canUseMutableRoot && !this.mutableFallbackWarned) {\n this.mutableFallbackWarned = true;\n if (process.env.NODE_ENV !== 'production') {\n console.warn('Travels: mutable mode requires the state root to be an object. Falling back to immutable updates.');\n }\n }\n if (useMutable) {\n // For observable state: generate patches then apply mutably\n [, patches, inversePatches] = create(this.state, isFunctionUpdater\n ? updater\n : (draft) => {\n overwriteDraftWith(draft, updater);\n }, this.options);\n // Apply patches to mutate the existing state object\n apply(this.state, patches, { mutable: true });\n // Keep the same reference\n this.pendingState = this.state;\n }\n else {\n // For immutable state: create new object\n const [nextState, p, ip] = (typeof updater === 'function'\n ? create(this.state, updater, this.options)\n : create(this.state, () => isObjectLike(updater)\n ? rawReturn(updater)\n : updater, this.options));\n patches = p;\n inversePatches = ip;\n this.state = nextState;\n this.pendingState = nextState;\n }\n // Reset pendingState asynchronously\n Promise.resolve().then(() => {\n this.pendingState = null;\n });\n const hasNoChanges = patches.length === 0 && inversePatches.length === 0;\n if (hasNoChanges) {\n return;\n }\n if (this.autoArchive) {\n const notLast = this.position < this.allPatches.patches.length;\n // Remove all patches after the current position\n if (notLast) {\n this.allPatches.patches.splice(this.position, this.allPatches.patches.length - this.position);\n this.allPatches.inversePatches.splice(this.position, this.allPatches.inversePatches.length - this.position);\n }\n this.allPatches.patches.push(patches);\n this.allPatches.inversePatches.push(inversePatches);\n this.position =\n this.maxHistory < this.allPatches.patches.length\n ? this.maxHistory\n : this.position + 1;\n if (this.maxHistory < this.allPatches.patches.length) {\n // Handle maxHistory = 0 case: clear all patches\n if (this.maxHistory === 0) {\n this.allPatches.patches = [];\n this.allPatches.inversePatches = [];\n }\n else {\n this.allPatches.patches = this.allPatches.patches.slice(-this.maxHistory);\n this.allPatches.inversePatches = this.allPatches.inversePatches.slice(-this.maxHistory);\n }\n }\n }\n else {\n const notLast = this.position <\n this.allPatches.patches.length +\n Number(!!this.tempPatches.patches.length);\n // Remove all patches after the current position\n if (notLast) {\n this.allPatches.patches.splice(this.position, this.allPatches.patches.length - this.position);\n this.allPatches.inversePatches.splice(this.position, this.allPatches.inversePatches.length - this.position);\n }\n if (!this.tempPatches.patches.length || notLast) {\n this.position =\n this.maxHistory < this.allPatches.patches.length + 1\n ? this.maxHistory\n : this.position + 1;\n }\n if (notLast) {\n this.tempPatches.patches.length = 0;\n this.tempPatches.inversePatches.length = 0;\n }\n this.tempPatches.patches.push(patches);\n this.tempPatches.inversePatches.push(inversePatches);\n }\n this.invalidateHistoryCache();\n this.notify();\n }\n /**\n * Archive the current state (only for manual archive mode)\n */\n archive() {\n var _a;\n if (this.autoArchive) {\n console.warn('Auto archive is enabled, no need to archive manually');\n return;\n }\n if (!this.tempPatches.patches.length)\n return;\n // Use pendingState if available, otherwise use current state\n const stateToUse = ((_a = this.pendingState) !== null && _a !== void 0 ? _a : this.state);\n // Merge temp patches\n const [, patches, inversePatches] = create(stateToUse, (draft) => apply(draft, this.tempPatches.inversePatches.flat().reverse()), this.options);\n this.allPatches.patches.push(inversePatches);\n this.allPatches.inversePatches.push(patches);\n // Respect maxHistory limit\n if (this.maxHistory < this.allPatches.patches.length) {\n // Handle maxHistory = 0 case: clear all patches\n if (this.maxHistory === 0) {\n this.allPatches.patches = [];\n this.allPatches.inversePatches = [];\n }\n else {\n this.allPatches.patches = this.allPatches.patches.slice(-this.maxHistory);\n this.allPatches.inversePatches = this.allPatches.inversePatches.slice(-this.maxHistory);\n }\n }\n // Clear temporary patches after archiving\n this.tempPatches.patches.length = 0;\n this.tempPatches.inversePatches.length = 0;\n this.invalidateHistoryCache();\n this.notify();\n }\n /**\n * Get all patches including temporary patches\n */\n getAllPatches() {\n const shouldArchive = !this.autoArchive && !!this.tempPatches.patches.length;\n if (shouldArchive) {\n return {\n patches: this.allPatches.patches.concat([\n this.tempPatches.patches.flat(),\n ]),\n inversePatches: this.allPatches.inversePatches.concat([\n this.tempPatches.inversePatches.flat().reverse(),\n ]),\n };\n }\n return this.allPatches;\n }\n /**\n * Get the complete history of states\n *\n * @returns The history array. Reference equality indicates cache hit.\n *\n * @remarks\n * **IMPORTANT**: Do not modify the returned array. It is cached internally.\n * - In development mode, the array is frozen\n * - In production mode, modifications will corrupt the cache\n */\n getHistory() {\n if (this.historyCache &&\n this.historyCache.version === this.historyVersion) {\n return this.historyCache.history;\n }\n const history = [this.state];\n let currentState = this.state;\n const _allPatches = this.getAllPatches();\n const patches = !this.autoArchive && _allPatches.patches.length > this.maxHistory\n ? _allPatches.patches.slice(_allPatches.patches.length - this.maxHistory)\n : _allPatches.patches;\n const inversePatches = !this.autoArchive && _allPatches.inversePatches.length > this.maxHistory\n ? _allPatches.inversePatches.slice(_allPatches.inversePatches.length - this.maxHistory)\n : _allPatches.inversePatches;\n // Build future history\n for (let i = this.position; i < patches.length; i++) {\n currentState = apply(currentState, patches[i]);\n history.push(currentState);\n }\n // Build past history\n currentState = this.state;\n for (let i = this.position - 1; i > -1; i--) {\n currentState = apply(currentState, inversePatches[i]);\n history.unshift(currentState);\n }\n this.historyCache = {\n version: this.historyVersion,\n history,\n };\n // In development mode, freeze the history array to prevent accidental mutations\n if (process.env.NODE_ENV !== 'production') {\n Object.freeze(history);\n }\n return history;\n }\n /**\n * Go to a specific position in the history\n */\n go(nextPosition) {\n const shouldArchive = !this.autoArchive && !!this.tempPatches.patches.length;\n if (shouldArchive) {\n this.archive();\n }\n const _allPatches = this.getAllPatches();\n const back = nextPosition < this.position;\n if (nextPosition > _allPatches.patches.length) {\n console.warn(`Can't go forward to position ${nextPosition}`);\n nextPosition = _allPatches.patches.length;\n }\n if (nextPosition < 0) {\n console.warn(`Can't go back to position ${nextPosition}`);\n nextPosition = 0;\n }\n if (nextPosition === this.position)\n return;\n if (shouldArchive) {\n const lastInversePatch = _allPatches.inversePatches.slice(-1)[0];\n _allPatches.inversePatches[_allPatches.inversePatches.length - 1] = [\n ...lastInversePatch,\n ].reverse();\n }\n const patchesToApply = back\n ? _allPatches.inversePatches\n .slice(-this.maxHistory)\n .slice(nextPosition, this.position)\n .flat()\n .reverse()\n : _allPatches.patches\n .slice(-this.maxHistory)\n .slice(this.position, nextPosition)\n .flat();\n // Can only use mutable mode if:\n // 1. mutable mode is enabled\n // 2. current state is an object\n // 3. patches don't contain root-level replacements (which change the entire state)\n const canGoMutably = this.mutable &&\n isObjectLike(this.state) &&\n !this.hasRootReplacement(patchesToApply);\n if (canGoMutably) {\n // For observable state: mutate in place\n apply(this.state, patchesToApply, { mutable: true });\n }\n else {\n // For immutable state or primitive types: create new state\n this.state = apply(this.state, patchesToApply);\n }\n this.position = nextPosition;\n this.invalidateHistoryCache();\n this.notify();\n }\n /**\n * Go back in the history\n */\n back(amount = 1) {\n this.go(this.position - amount);\n }\n /**\n * Go forward in the history\n */\n forward(amount = 1) {\n this.go(this.position + amount);\n }\n /**\n * Reset to the initial state\n */\n reset() {\n const canResetMutably = this.mutable &&\n isObjectLike(this.state) &&\n isObjectLike(this.initialState);\n if (canResetMutably) {\n // For observable state: use patch system to reset to initial state\n // Generate patches from current state to initial state\n const [, patches] = create(this.state, (draft) => {\n // Clear all properties\n for (const key of Object.keys(draft)) {\n delete draft[key];\n }\n // Deep copy all properties from initialState\n deepClone(this.initialState, draft);\n }, this.options);\n apply(this.state, patches, { mutable: true });\n }\n else {\n // For immutable state: reassign reference\n this.state = this.initialState;\n }\n this.position = this.initialPosition;\n this.allPatches = cloneTravelPatches(this.initialPatches);\n this.tempPatches = cloneTravelPatches();\n this.invalidateHistoryCache();\n this.notify();\n }\n /**\n * Check if it's possible to go back\n */\n canBack() {\n return this.position > 0;\n }\n /**\n * Check if it's possible to go forward\n */\n canForward() {\n const shouldArchive = !this.autoArchive && !!this.tempPatches.patches.length;\n const _allPatches = this.getAllPatches();\n // Temporary patches represent the current state, not a future state\n return shouldArchive\n ? this.position < _allPatches.patches.length - 1\n : this.position < _allPatches.patches.length;\n }\n /**\n * Check if it's possible to archive the current state\n */\n canArchive() {\n return !this.autoArchive && !!this.tempPatches.patches.length;\n }\n /**\n * Get the current position in the history\n */\n getPosition() {\n return this.position;\n }\n /**\n * Get the patches history\n */\n getPatches() {\n const shouldArchive = !this.autoArchive && !!this.tempPatches.patches.length;\n return shouldArchive ? this.getAllPatches() : this.allPatches;\n }\n /**\n * Get the controls object\n */\n getControls() {\n const self = this;\n const controls = {\n get position() {\n return self.getPosition();\n },\n getHistory: () => self.getHistory(),\n get patches() {\n return self.getPatches();\n },\n back: (amount) => self.back(amount),\n forward: (amount) => self.forward(amount),\n reset: () => self.reset(),\n go: (position) => self.go(position),\n canBack: () => self.canBack(),\n canForward: () => self.canForward(),\n };\n if (!this.autoArchive) {\n controls.archive = () => self.archive();\n controls.canArchive = () => self.canArchive();\n }\n return controls;\n }\n}\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHJhdmVscy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy90cmF2ZWxzLnRz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