@encorejs/saaz 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/LICENSE +203 -0
  2. package/README.md +1 -0
  3. package/dist/back/BackMemoryAdapter.d.ts +18 -0
  4. package/dist/back/BackMemoryAdapter.d.ts.map +1 -0
  5. package/dist/back/BackMemoryAdapter.js +69 -0
  6. package/dist/back/BackStorage.d.ts +20 -0
  7. package/dist/back/BackStorage.d.ts.map +1 -0
  8. package/dist/back/BackStorage.js +22 -0
  9. package/dist/back/SaazBack.d.ts +60 -0
  10. package/dist/back/SaazBack.d.ts.map +1 -0
  11. package/dist/back/SaazBack.js +188 -0
  12. package/dist/front/FrontIdbAdapter.d.ts +15 -0
  13. package/dist/front/FrontIdbAdapter.d.ts.map +1 -0
  14. package/dist/front/FrontIdbAdapter.js +159 -0
  15. package/dist/front/FrontMemoryAdapter.d.ts +16 -0
  16. package/dist/front/FrontMemoryAdapter.d.ts.map +1 -0
  17. package/dist/front/FrontMemoryAdapter.js +156 -0
  18. package/dist/front/FrontStorage.d.ts +23 -0
  19. package/dist/front/FrontStorage.d.ts.map +1 -0
  20. package/dist/front/FrontStorage.js +85 -0
  21. package/dist/front/SaazFront.d.ts +113 -0
  22. package/dist/front/SaazFront.d.ts.map +1 -0
  23. package/dist/front/SaazFront.js +756 -0
  24. package/dist/index.d.ts +8 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +9295 -0
  27. package/dist/index.js.map +7 -0
  28. package/dist/index.test.d.ts +2 -0
  29. package/dist/index.test.d.ts.map +1 -0
  30. package/dist/index.test.js +166 -0
  31. package/dist/rogue.d.ts +63 -0
  32. package/dist/rogue.d.ts.map +1 -0
  33. package/dist/rogue.js +548 -0
  34. package/dist/rogue.test.d.ts +2 -0
  35. package/dist/rogue.test.d.ts.map +1 -0
  36. package/dist/rogue.test.js +248 -0
  37. package/dist/shared/GeneratorSpy.d.ts +4 -0
  38. package/dist/shared/GeneratorSpy.d.ts.map +1 -0
  39. package/dist/shared/GeneratorSpy.js +41 -0
  40. package/dist/shared/transactions.d.ts +4 -0
  41. package/dist/shared/transactions.d.ts.map +1 -0
  42. package/dist/shared/transactions.js +131 -0
  43. package/dist/shared/utils.d.ts +5 -0
  44. package/dist/shared/utils.d.ts.map +1 -0
  45. package/dist/shared/utils.js +21 -0
  46. package/dist/tsdoc-metadata.json +11 -0
  47. package/dist/types.d.ts +240 -0
  48. package/dist/types.d.ts.map +1 -0
  49. package/dist/types.js +1 -0
  50. package/package.json +54 -0
@@ -0,0 +1,248 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { BackMemoryAdapter } from './back/BackMemoryAdapter';
11
+ import SaazBack from './back/SaazBack';
12
+ import { FrontMemoryAdapter } from './front/FrontMemoryAdapter';
13
+ import { SaazFront } from './front/SaazFront';
14
+ import { change, fromOps, jsonFromCell } from './rogue';
15
+ const ahistoricSnapshot = {
16
+ $type: ['map', 'base'],
17
+ $branches: {
18
+ base: {
19
+ $mapProps: {
20
+ foo: {
21
+ $type: ['map', 'base'],
22
+ $branches: {
23
+ base: {
24
+ $boxedValue: 'some value here, but this will be ignored, because this is an obj register.',
25
+ $mapProps: {
26
+ bar: {
27
+ $type: ['boxed', 'base'],
28
+ $branches: {
29
+ base: {
30
+ $boxedValue: 'some value here. this is an lww register, and it can contain any json value.',
31
+ },
32
+ },
33
+ },
34
+ },
35
+ },
36
+ },
37
+ },
38
+ },
39
+ },
40
+ },
41
+ };
42
+ describe(`Rogue`, () => {
43
+ test('setting a non-existing prop', () => {
44
+ const [rep, ops] = change({}, (draft) => {
45
+ expect(draft.a).toBe(undefined);
46
+ draft.a = 1;
47
+ expect(draft.a).toBe(1);
48
+ });
49
+ expect(jsonFromCell(rep)).toEqual({ a: 1 });
50
+ expect([rep, ops]).toMatchSnapshot();
51
+ const [rep2] = fromOps({}, ops);
52
+ expect(rep2).toEqual(rep);
53
+ });
54
+ test('overriding an existing prop with the same value', () => {
55
+ const [rep1] = change({}, (draft) => {
56
+ draft.a = 1;
57
+ });
58
+ const [rep2, ops] = change(rep1, (draft) => {
59
+ expect(draft.a).toBe(1);
60
+ draft.a = 1;
61
+ expect(draft.a).toBe(1);
62
+ });
63
+ expect(rep1).toBe(rep2);
64
+ expect(ops).toEqual([]);
65
+ });
66
+ test('overriding an existing prop', () => {
67
+ const [rep1] = change({}, (draft) => {
68
+ draft.a = 1;
69
+ });
70
+ const [rep2, ops] = change(rep1, (draft) => {
71
+ expect(draft.a).toBe(1);
72
+ draft.a = 2;
73
+ expect(draft.a).toBe(2);
74
+ });
75
+ expect(jsonFromCell(rep2)).toEqual({ a: 2 });
76
+ expect(ops).toHaveLength(1);
77
+ expect(ops).toMatchSnapshot();
78
+ const [rep3] = fromOps(rep1, ops);
79
+ expect(rep3).toEqual(rep2);
80
+ });
81
+ test('setting a non-existing prop to an object', () => {
82
+ const [rep, ops] = change({}, (draft) => {
83
+ expect(draft.a).toBe(undefined);
84
+ draft.a = { b: 1 };
85
+ expect(draft.a).toEqual(draft.a);
86
+ expect(draft.a).toEqual({ b: 1 });
87
+ });
88
+ expect(jsonFromCell(rep)).toEqual({ a: { b: 1 } });
89
+ expect([rep, ops]).toMatchSnapshot();
90
+ const [rep2] = fromOps({}, ops);
91
+ expect(rep2).toEqual(rep);
92
+ });
93
+ test('setting an existing prop to an object', () => {
94
+ const [rep] = change({}, (draft) => {
95
+ draft.a = { b: 1 };
96
+ });
97
+ expect(jsonFromCell(rep)).toEqual({ a: { b: 1 } });
98
+ const [rep2, ops2] = change(rep, (draft) => {
99
+ expect(draft.a).toEqual({ b: 1 });
100
+ draft.a = { b: 2 };
101
+ expect(draft.a).toEqual({ b: 2 });
102
+ });
103
+ expect(jsonFromCell(rep2)).toEqual({ a: { b: 2 } });
104
+ const [rep3] = fromOps(rep, ops2);
105
+ expect(rep3).toEqual(rep2);
106
+ });
107
+ test('setting an existing prop from an object', () => {
108
+ const [rep] = change({}, (draft) => {
109
+ draft.a = { b: 1 };
110
+ });
111
+ expect(jsonFromCell(rep)).toEqual({ a: { b: 1 } });
112
+ const [rep2, ops2] = change(rep, (draft) => {
113
+ expect(draft.a).toEqual({ b: 1 });
114
+ draft.a = { c: 1 };
115
+ expect(draft.a).toEqual({ c: 1 });
116
+ });
117
+ expect(jsonFromCell(rep2)).toEqual({ a: { c: 1 } });
118
+ const [rep3] = fromOps(rep, ops2);
119
+ expect(rep3).toEqual(rep2);
120
+ });
121
+ test(`merging defaults`, () => {
122
+ const [, ops1_1] = change({}, (draft) => {
123
+ draft.a = { aStep: 1, foo: 'setBy1', obj: { objA: 'true' } };
124
+ });
125
+ const [, ops2_1] = change({}, (draft) => {
126
+ draft.a = { bStep: 1, foo: 'setBy2', obj: { objB: 'true' } };
127
+ });
128
+ const merge1 = fromOps({}, [...ops2_1, ...ops1_1])[0];
129
+ const _11 = jsonFromCell(merge1);
130
+ expect(_11).toMatchSnapshot();
131
+ // console.log(_11)
132
+ });
133
+ function scenario(name, steps) {
134
+ describe(name, () => {
135
+ let last = {
136
+ json: {},
137
+ backwardOps: [],
138
+ ops: [],
139
+ rep: {},
140
+ };
141
+ const byStep = {};
142
+ for (const [stepName, fn] of Object.entries(steps)) {
143
+ test(stepName, () => {
144
+ const prev = Object.assign({}, last);
145
+ const [rep, ops, backwardOps] = change(prev.rep, (draft) => {
146
+ fn(draft, prev.json, prev.ops);
147
+ });
148
+ const stepResult = {
149
+ rep,
150
+ ops,
151
+ backwardOps,
152
+ json: jsonFromCell(rep),
153
+ prev,
154
+ };
155
+ last.next = stepResult;
156
+ last = stepResult;
157
+ byStep[stepName] = stepResult;
158
+ });
159
+ }
160
+ // i = 0 so that we skip the first step, which is the initial state
161
+ for (let i = 1; i < Object.keys(steps).length; i++) {
162
+ const prevStepName = Object.keys(steps)[i - 1];
163
+ const stepName = Object.keys(steps)[i];
164
+ test(`${prevStepName} => ${stepName}`, () => {
165
+ const stepResult = byStep[stepName];
166
+ const [rep] = fromOps(stepResult.prev.rep, stepResult.ops);
167
+ expect(rep).toEqual(stepResult.rep);
168
+ });
169
+ test(`${prevStepName} <= ${stepName}`, () => {
170
+ const stepResult = byStep[stepName];
171
+ const [rep] = fromOps(stepResult.rep, stepResult.backwardOps);
172
+ const s = jsonFromCell(rep);
173
+ // note that as opposed to the previous test, we're not comparing cells, we're
174
+ // comparing snapshots. This is because the cells are not guaranteed to be the
175
+ // same when undoing a change, but the snapshots are.
176
+ expect(s).toEqual(stepResult.prev.json);
177
+ });
178
+ }
179
+ });
180
+ }
181
+ scenario('scenario 1', {
182
+ step1: (draft) => {
183
+ expect(draft.a).toBe(undefined);
184
+ draft.a = 1;
185
+ expect(draft.a).toBe(1);
186
+ },
187
+ step2: (_, snapshot, ops) => {
188
+ expect(snapshot).toEqual({ a: 1 });
189
+ },
190
+ });
191
+ scenario('scenario 2', {
192
+ step1: (draft) => {
193
+ draft.a = { a1: { a11: 1 } };
194
+ expect(draft.a.a1).toEqual({ a11: 1 });
195
+ draft.a.a1.a11 = 2;
196
+ expect(draft.a).toEqual({ a1: { a11: 2 } });
197
+ },
198
+ step2: (_, snapshot, ops) => {
199
+ expect(snapshot).toEqual({ a: { a1: { a11: 2 } } });
200
+ },
201
+ });
202
+ scenario('scenario 3', {
203
+ step1: (draft) => {
204
+ draft.a = { a1: { a11: 1 } };
205
+ expect(draft.a.a1).toEqual({ a11: 1 });
206
+ draft.a = { b: 1 };
207
+ expect(draft.a).toEqual({ b: 1 });
208
+ },
209
+ step2: (draft, snapshot, ops) => {
210
+ expect(draft.a).toEqual({ b: 1 });
211
+ draft.a = 1;
212
+ },
213
+ step3: (draft, snapshot) => {
214
+ expect(snapshot).toEqual({ a: 1 });
215
+ },
216
+ });
217
+ describe(`saaz integration`, () => {
218
+ test(`test`, () => __awaiter(void 0, void 0, void 0, function* () {
219
+ const schema = {
220
+ version: 1,
221
+ // migrateOp(state: $IntentionalAny) {},
222
+ // migrateCell(s) {},
223
+ generators: {},
224
+ editors: {
225
+ increaseBy(state, generators, opts) {
226
+ state.count += opts.by;
227
+ },
228
+ },
229
+ opShape: null,
230
+ cellShape: null,
231
+ };
232
+ const backend = new SaazBack({
233
+ schema,
234
+ dbName: 'test',
235
+ storageAdapter: new BackMemoryAdapter(),
236
+ });
237
+ const saaz = new SaazFront({
238
+ schema,
239
+ dbName: 'test',
240
+ peerId: '1',
241
+ storageAdapter: new FrontMemoryAdapter(),
242
+ backend,
243
+ });
244
+ saaz.tx((editors) => { });
245
+ saaz.teardown();
246
+ }));
247
+ });
248
+ });
@@ -0,0 +1,4 @@
1
+ import type { GeneratorRecordings } from '../types';
2
+ import type { ValidGenerators } from '../types';
3
+ export declare function createGeneratorsSpy<Generators extends ValidGenerators>(generators: ValidGenerators, prevREcordings?: GeneratorRecordings, playbackOnly?: boolean): [spy: Generators, recordings: GeneratorRecordings];
4
+ //# sourceMappingURL=GeneratorSpy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GeneratorSpy.d.ts","sourceRoot":"","sources":["../../src/shared/GeneratorSpy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,mBAAmB,EAAC,MAAM,UAAU,CAAA;AAGlE,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,UAAU,CAAA;AAG7C,wBAAgB,mBAAmB,CAAC,UAAU,SAAS,eAAe,EACpE,UAAU,EAAE,eAAe,EAC3B,cAAc,GAAE,mBAAwB,EACxC,YAAY,GAAE,OAAe,GAC5B,CAAC,GAAG,EAAE,UAAU,EAAE,UAAU,EAAE,mBAAmB,CAAC,CAmDpD"}
@@ -0,0 +1,41 @@
1
+ import { cloneDeep } from 'lodash-es';
2
+ import { stableValueHash } from '@encorejs/utils/stableJsonStringify';
3
+ export function createGeneratorsSpy(generators, prevREcordings = {}, playbackOnly = false) {
4
+ const recordings = cloneDeep(prevREcordings);
5
+ const calls = {};
6
+ const spy = Object.fromEntries(Object.entries(generators).map(([fnName, fn]) => {
7
+ if (typeof fn !== 'function') {
8
+ throw new Error(`Generator method "${fnName}" is not a function`);
9
+ }
10
+ if (typeof fnName !== 'string') {
11
+ throw new Error('key is not a string');
12
+ }
13
+ const spyFn = (...args) => {
14
+ var _a;
15
+ const key = stableValueHash([fnName, args]);
16
+ // Monotonic per-(fnName,args) call counter: 0 on first call, then 1, 2…
17
+ // (the previous `if (!calls[key])` test was stuck at 0 because 0 is
18
+ // falsy, so every same-args call collided on recording slot 0).
19
+ const callIndex = (_a = calls[key]) !== null && _a !== void 0 ? _a : 0;
20
+ calls[key] = callIndex + 1;
21
+ if (playbackOnly &&
22
+ (!Array.isArray(recordings[key]) ||
23
+ recordings[key].length < callIndex)) {
24
+ throw new Error(`Generator method "${fnName}" was called with arguments that were not recorded: ${JSON.stringify(args)}`);
25
+ }
26
+ if (!recordings[key]) {
27
+ recordings[key] = [];
28
+ }
29
+ if (recordings[key].length > callIndex) {
30
+ return recordings[key][callIndex];
31
+ }
32
+ else {
33
+ const ret = fn(args[0]);
34
+ recordings[key][callIndex] = ret;
35
+ return ret;
36
+ }
37
+ };
38
+ return [fnName, spyFn];
39
+ }));
40
+ return [spy, recordings];
41
+ }
@@ -0,0 +1,4 @@
1
+ import type { EditorDefinitionToEditorInvocable, Invokations, Transaction, Schema, ValidOpSnapshot as ValidOpSnapshot, GeneratorRecordings, FullSnapshot } from '../types';
2
+ export declare function applyOptimisticUpdateToState<OpSnapshot extends ValidOpSnapshot>({ invokations, generatorRecordings, draftOps, }: Pick<Transaction, 'invokations' | 'generatorRecordings' | 'draftOps'>, before: FullSnapshot<OpSnapshot>, schema: Schema<OpSnapshot>, playbackOnly?: boolean, testDeterminism?: boolean): [after: FullSnapshot<OpSnapshot>, generatorRecordings: GeneratorRecordings];
3
+ export declare function recordInvokations<Editors extends {}>(editors: Editors, fn: (editors: EditorDefinitionToEditorInvocable<Editors>) => void): Invokations;
4
+ //# sourceMappingURL=transactions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["../../src/shared/transactions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,iCAAiC,EACjC,WAAW,EACX,WAAW,EAIX,MAAM,EACN,eAAe,IAAI,eAAe,EAElC,mBAAmB,EACnB,YAAY,EACb,MAAM,UAAU,CAAA;AAGjB,wBAAgB,4BAA4B,CAC1C,UAAU,SAAS,eAAe,EAElC,EACE,WAAW,EACX,mBAAmB,EACnB,QAAQ,GACT,EAAE,IAAI,CAAC,WAAW,EAAE,aAAa,GAAG,qBAAqB,GAAG,UAAU,CAAC,EACxE,MAAM,EAAE,YAAY,CAAC,UAAU,CAAC,EAChC,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,EAC1B,YAAY,GAAE,OAAe,EAC7B,eAAe,GAAE,OAAc,GAC9B,CAAC,KAAK,EAAE,YAAY,CAAC,UAAU,CAAC,EAAE,mBAAmB,EAAE,mBAAmB,CAAC,CAY7E;AAED,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,EAAE,EAClD,OAAO,EAAE,OAAO,EAChB,EAAE,EAAE,CAAC,OAAO,EAAE,iCAAiC,CAAC,OAAO,CAAC,KAAK,IAAI,GAChE,WAAW,CAgBb"}
@@ -0,0 +1,131 @@
1
+ import * as GeneratorSpy from './GeneratorSpy';
2
+ import { createDraft, finishDraft } from 'immer';
3
+ import { get } from 'lodash-es';
4
+ import { fromOps } from '../rogue';
5
+ export function applyOptimisticUpdateToState({ invokations, generatorRecordings, draftOps, }, before, schema, playbackOnly = false, testDeterminism = true) {
6
+ const draft = createDraft(before.op);
7
+ const [generatorSpy, newRecordings] = GeneratorSpy.createGeneratorsSpy(schema.generators, generatorRecordings, playbackOnly);
8
+ runInvokations(schema, draft, invokations, generatorSpy);
9
+ const opSnapshotAfter = finishDraft(draft);
10
+ const [cellAfter] = fromOps(before.cell, draftOps);
11
+ return [{ op: opSnapshotAfter, cell: cellAfter }, newRecordings];
12
+ }
13
+ export function recordInvokations(editors, fn) {
14
+ const { invokableEditors, release, invokations } = invokables.getInvokables(editors);
15
+ let released = false;
16
+ try {
17
+ fn(invokableEditors);
18
+ release();
19
+ released = true;
20
+ }
21
+ catch (error) {
22
+ throw error;
23
+ }
24
+ finally {
25
+ if (!released) {
26
+ release();
27
+ }
28
+ }
29
+ return invokations;
30
+ }
31
+ function runInvokations(schema, prevState, invokations, generatorSpy) {
32
+ for (const [fnPath, opts] of invokations) {
33
+ const fn = get(schema.editors, fnPath.split('.'));
34
+ if (typeof fn !== 'function') {
35
+ throw new Error(`editor ${fnPath} not found. Transaction may be corrupt, or the editor names may have changed`);
36
+ }
37
+ fn(prevState, generatorSpy, opts);
38
+ }
39
+ }
40
+ var invokables;
41
+ (function (invokables) {
42
+ class Pool {
43
+ constructor(_factory) {
44
+ this._factory = _factory;
45
+ this._items = [];
46
+ }
47
+ /**
48
+ * Get an item from the pool. If the pool is empty, a new item is created. Also starts a timer to ensure that the item is released back into the pool.
49
+ *
50
+ * @returns A tuple of the item and a function to release the item back into the pool.
51
+ *
52
+ */
53
+ get(releaseTimeoutms = 0) {
54
+ const item = this._items.length === 0 ? this._factory() : this._items.pop();
55
+ let released = false;
56
+ // if the invokables are not released within 0ms, it's probably a bug + memory leak.
57
+ const releaseTimeout = setTimeout(() => {
58
+ if (!released) {
59
+ throw new Error('Release timeout exceeded.');
60
+ }
61
+ }, releaseTimeoutms);
62
+ const release = () => {
63
+ released = true;
64
+ clearTimeout(releaseTimeout);
65
+ this._items.push(item);
66
+ };
67
+ return [item, release];
68
+ }
69
+ }
70
+ const pools = new WeakMap();
71
+ function getPool(editorDefinition) {
72
+ if (!pools.has(editorDefinition)) {
73
+ function createPoolItem(editors) {
74
+ const context = {
75
+ snapshot: {},
76
+ invokations: [],
77
+ };
78
+ const invokableEditors = createInvokables(editors, context);
79
+ return { context, invokableEditors };
80
+ }
81
+ const pool = new Pool(() => createPoolItem(editorDefinition));
82
+ pools.set(editorDefinition, pool);
83
+ return pool;
84
+ }
85
+ else {
86
+ return pools.get(editorDefinition);
87
+ }
88
+ }
89
+ function createInvokables(editors, context, pathSoFar = []) {
90
+ const cache = {};
91
+ const proxy = new Proxy(new Function(), {
92
+ get(_, prop) {
93
+ if (prop in cache) {
94
+ return cache[prop];
95
+ }
96
+ else if (!(prop in editors)) {
97
+ const path = [...pathSoFar, prop];
98
+ throw new Error(`editor "${path.join('.')}" not found`);
99
+ }
100
+ else {
101
+ const path = [...pathSoFar, prop];
102
+ const sub = createInvokables(editors[prop], context, path);
103
+ cache[prop] = sub;
104
+ return sub;
105
+ }
106
+ },
107
+ apply(_, __, args) {
108
+ const opts = args[0];
109
+ if (typeof editors !== 'function') {
110
+ throw new Error(`editor "${pathSoFar.join('.')}" is not a function`);
111
+ }
112
+ else {
113
+ context.invokations.push([pathSoFar.join('.'), opts]);
114
+ }
115
+ },
116
+ });
117
+ return proxy;
118
+ }
119
+ function getInvokables(editorDefinitions) {
120
+ const pool = getPool(editorDefinitions);
121
+ const [poolItem, release] = pool.get();
122
+ const { context, invokableEditors } = poolItem;
123
+ context.invokations = [];
124
+ return {
125
+ invokableEditors: invokableEditors,
126
+ release,
127
+ invokations: context.invokations,
128
+ };
129
+ }
130
+ invokables.getInvokables = getInvokables;
131
+ })(invokables || (invokables = {}));
@@ -0,0 +1,5 @@
1
+ import type { FullSnapshot, Schema } from '../types';
2
+ export declare function ensureStateIsUptodate<S extends {
3
+ $schemaVersion: number;
4
+ }>(original: FullSnapshot<S> | null, schema: Schema<S>): FullSnapshot<S>;
5
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/shared/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,EAAC,MAAM,UAAU,CAAA;AAInE,wBAAgB,qBAAqB,CAAC,CAAC,SAAS;IAAC,cAAc,EAAE,MAAM,CAAA;CAAC,EACtE,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,EAChC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAChB,YAAY,CAAC,CAAC,CAAC,CAoBjB"}
@@ -0,0 +1,21 @@
1
+ const empty = { op: {}, cell: {} };
2
+ export function ensureStateIsUptodate(original, schema) {
3
+ if (original === null) {
4
+ return empty;
5
+ }
6
+ return original;
7
+ // if (
8
+ // !original ||
9
+ // typeof original.op.$schemaVersion !== 'number' ||
10
+ // original.op.$schemaVersion < schema.version
11
+ // ) {
12
+ // return {
13
+ // op: produce((original?.op ?? {}) as {}, (originalDraft) => {
14
+ // schema.migrateOp(originalDraft)
15
+ // }) as S,
16
+ // cell: original?.cell ?? {},
17
+ // }
18
+ // } else {
19
+ // return original
20
+ // }
21
+ }
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.36.4"
9
+ }
10
+ ]
11
+ }