@shaxpir/duiduidui-models 1.0.1 → 1.1.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.
- package/dist/models/{content/ArrayView.d.ts → ArrayView.d.ts} +1 -1
- package/dist/models/{content/ArrayView.js → ArrayView.js} +14 -14
- package/dist/models/BayesianScore.d.ts +9 -0
- package/dist/models/BayesianScore.js +27 -0
- package/dist/models/{markup/ChangeModel.d.ts → ChangeModel.d.ts} +2 -3
- package/dist/models/{markup/ChangeModel.js → ChangeModel.js} +20 -10
- package/dist/models/{content/Content.d.ts → Content.d.ts} +9 -10
- package/dist/models/{content/Content.js → Content.js} +2 -6
- package/dist/models/{content/ContentKind.d.ts → ContentKind.d.ts} +3 -0
- package/dist/models/{content/ContentKind.js → ContentKind.js} +5 -1
- package/dist/models/{content/Device.d.ts → Device.d.ts} +15 -7
- package/dist/models/{content/Device.js → Device.js} +14 -18
- package/dist/models/Hanzi.d.ts +15 -0
- package/dist/models/{content/Manifest.d.ts → Manifest.d.ts} +7 -3
- package/dist/models/{content/Manifest.js → Manifest.js} +12 -8
- package/dist/models/{content/Media.d.ts → Media.d.ts} +2 -3
- package/dist/models/{content/Media.js → Media.js} +4 -5
- package/dist/models/{content/Metric.d.ts → Metric.d.ts} +2 -3
- package/dist/models/{content/Metric.js → Metric.js} +18 -20
- package/dist/models/{content/Model.d.ts → Model.d.ts} +3 -5
- package/dist/models/{content/Model.js → Model.js} +5 -6
- package/dist/models/{markup/Operation.d.ts → Operation.d.ts} +2 -5
- package/dist/models/{markup/Operation.js → Operation.js} +30 -25
- package/dist/models/Phrase.d.ts +39 -0
- package/dist/models/{content/Profile.d.ts → Profile.d.ts} +1 -2
- package/dist/models/{content/Profile.js → Profile.js} +7 -9
- package/dist/models/Progress.d.ts +26 -0
- package/dist/models/Progress.js +39 -0
- package/dist/models/Review.d.ts +14 -0
- package/dist/models/{content/Session.d.ts → Session.d.ts} +7 -15
- package/dist/models/Session.js +103 -0
- package/dist/models/Term.d.ts +36 -0
- package/dist/models/Term.js +82 -0
- package/dist/models/User.d.ts +32 -0
- package/dist/models/User.js +65 -0
- package/dist/models/Workspace.d.ts +37 -0
- package/dist/models/Workspace.js +94 -0
- package/dist/models/index.d.ts +22 -2
- package/dist/models/index.js +22 -2
- package/dist/repo/PermissiveJson1.d.ts +16 -16
- package/dist/repo/PermissiveJson1.js +17 -7
- package/dist/repo/ShareSync.d.ts +6 -6
- package/dist/repo/ShareSync.js +26 -19
- package/dist/repo/index.d.ts +1 -0
- package/dist/repo/index.js +1 -0
- package/dist/util/index.d.ts +0 -6
- package/dist/util/index.js +0 -6
- package/lib/models/{content/ArrayView.ts → ArrayView.ts} +2 -2
- package/lib/models/BayesianScore.ts +32 -0
- package/lib/models/{markup/ChangeModel.ts → ChangeModel.ts} +3 -4
- package/lib/models/{content/Content.ts → Content.ts} +15 -18
- package/lib/models/{content/ContentKind.ts → ContentKind.ts} +6 -1
- package/lib/models/{content/Device.ts → Device.ts} +26 -22
- package/lib/models/Hanzi.ts +16 -0
- package/lib/models/{content/Manifest.ts → Manifest.ts} +15 -6
- package/lib/models/{content/Media.ts → Media.ts} +3 -4
- package/lib/models/Metric.ts +233 -0
- package/lib/models/{content/Model.ts → Model.ts} +4 -6
- package/lib/models/{markup/Operation.ts → Operation.ts} +6 -16
- package/lib/models/{content/Permissions.ts → Permissions.ts} +0 -2
- package/lib/models/Phrase.ts +53 -0
- package/lib/models/{content/Profile.ts → Profile.ts} +4 -6
- package/lib/models/Progress.ts +66 -0
- package/lib/models/Review.ts +18 -0
- package/lib/models/Session.ts +140 -0
- package/lib/models/Term.ts +139 -0
- package/lib/models/User.ts +97 -0
- package/lib/models/Workspace.ts +129 -0
- package/lib/models/index.ts +22 -2
- package/lib/repo/ShareSync.ts +9 -13
- package/lib/repo/index.ts +1 -0
- package/lib/util/index.ts +0 -6
- package/package.json +4 -15
- package/dist/models/OutboundMessage.d.ts +0 -18
- package/dist/models/OutboundMessage.js +0 -25
- package/dist/models/content/Activity.d.ts +0 -10
- package/dist/models/content/Billing.d.ts +0 -144
- package/dist/models/content/Billing.js +0 -418
- package/dist/models/content/Book.d.ts +0 -77
- package/dist/models/content/Book.js +0 -407
- package/dist/models/content/Category.d.ts +0 -16
- package/dist/models/content/Category.js +0 -20
- package/dist/models/content/Checkpointable.d.ts +0 -21
- package/dist/models/content/Checkpointable.js +0 -156
- package/dist/models/content/Comment.d.ts +0 -19
- package/dist/models/content/Comment.js +0 -53
- package/dist/models/content/ConceptArt.d.ts +0 -31
- package/dist/models/content/ConceptArt.js +0 -84
- package/dist/models/content/Context.d.ts +0 -28
- package/dist/models/content/Context.js +0 -162
- package/dist/models/content/DevEnv.d.ts +0 -5
- package/dist/models/content/DevEnv.js +0 -9
- package/dist/models/content/Dictionary.d.ts +0 -31
- package/dist/models/content/Dictionary.js +0 -5
- package/dist/models/content/DictionaryEntry.d.ts +0 -20
- package/dist/models/content/DictionaryEntry.js +0 -2
- package/dist/models/content/ElasticModel.d.ts +0 -149
- package/dist/models/content/ElasticModel.js +0 -179
- package/dist/models/content/Environment.d.ts +0 -61
- package/dist/models/content/Environment.js +0 -124
- package/dist/models/content/ExportOptions.d.ts +0 -64
- package/dist/models/content/ExportOptions.js +0 -213
- package/dist/models/content/Folder.d.ts +0 -16
- package/dist/models/content/Folder.js +0 -33
- package/dist/models/content/Fragment.d.ts +0 -54
- package/dist/models/content/Fragment.js +0 -181
- package/dist/models/content/Hanzi.d.ts +0 -21
- package/dist/models/content/HighlightRule.d.ts +0 -9
- package/dist/models/content/HighlightRule.js +0 -2
- package/dist/models/content/Migration.d.ts +0 -68
- package/dist/models/content/Migration.js +0 -155
- package/dist/models/content/Phrase.d.ts +0 -8
- package/dist/models/content/Placeholder.d.ts +0 -8
- package/dist/models/content/Placeholder.js +0 -36
- package/dist/models/content/RichText.d.ts +0 -58
- package/dist/models/content/RichText.js +0 -79
- package/dist/models/content/Session.js +0 -173
- package/dist/models/content/Speech.d.ts +0 -67
- package/dist/models/content/Speech.js +0 -97
- package/dist/models/content/Stub.d.ts +0 -24
- package/dist/models/content/Stub.js +0 -179
- package/dist/models/content/Time.d.ts +0 -56
- package/dist/models/content/Time.js +0 -295
- package/dist/models/content/User.d.ts +0 -36
- package/dist/models/content/User.js +0 -95
- package/dist/models/content/Workspace.d.ts +0 -71
- package/dist/models/content/Workspace.js +0 -237
- package/dist/models/content/index.d.ts +0 -17
- package/dist/models/content/index.js +0 -34
- package/dist/models/legacy/LegacyBodyFormat.d.ts +0 -9
- package/dist/models/legacy/LegacyBodyFormat.js +0 -2
- package/dist/models/legacy/LegacyComment.d.ts +0 -12
- package/dist/models/legacy/LegacyComment.js +0 -2
- package/dist/models/legacy/LegacyContent.d.ts +0 -53
- package/dist/models/legacy/LegacyContent.js +0 -55
- package/dist/models/legacy/LegacyConversion.d.ts +0 -55
- package/dist/models/legacy/LegacyConversion.js +0 -401
- package/dist/models/legacy/LegacyFragment.d.ts +0 -21
- package/dist/models/legacy/LegacyFragment.js +0 -2
- package/dist/models/legacy/LegacyLocator.d.ts +0 -8
- package/dist/models/legacy/LegacyLocator.js +0 -31
- package/dist/models/legacy/LegacyOutboundMessage.d.ts +0 -16
- package/dist/models/legacy/LegacyOutboundMessage.js +0 -13
- package/dist/models/legacy/LegacyPicture.d.ts +0 -14
- package/dist/models/legacy/LegacyPicture.js +0 -2
- package/dist/models/legacy/LegacyProfile.d.ts +0 -9
- package/dist/models/legacy/LegacyProfile.js +0 -2
- package/dist/models/legacy/LegacySession.d.ts +0 -41
- package/dist/models/legacy/LegacySession.js +0 -35
- package/dist/models/legacy/LegacyStory.d.ts +0 -23
- package/dist/models/legacy/LegacyStory.js +0 -2
- package/dist/models/legacy/LegacyStub.d.ts +0 -15
- package/dist/models/legacy/LegacyStub.js +0 -2
- package/dist/models/legacy/LegacyTransaction.d.ts +0 -14
- package/dist/models/legacy/LegacyTransaction.js +0 -49
- package/dist/models/legacy/LegacyUser.d.ts +0 -28
- package/dist/models/legacy/LegacyUser.js +0 -32
- package/dist/models/legacy/LegacyWorkspace.d.ts +0 -23
- package/dist/models/legacy/LegacyWorkspace.js +0 -6
- package/dist/models/legacy/index.d.ts +0 -15
- package/dist/models/legacy/index.js +0 -32
- package/dist/models/markup/BodyFormat.d.ts +0 -14
- package/dist/models/markup/BodyFormat.js +0 -190
- package/dist/models/markup/DeltaOps.d.ts +0 -5
- package/dist/models/markup/DeltaOps.js +0 -74
- package/dist/models/markup/HtmlMarkup.d.ts +0 -4
- package/dist/models/markup/HtmlMarkup.js +0 -21
- package/dist/models/markup/index.d.ts +0 -4
- package/dist/models/markup/index.js +0 -21
- package/dist/util/Async.d.ts +0 -8
- package/dist/util/Async.js +0 -18
- package/dist/util/Base62.d.ts +0 -6
- package/dist/util/Base62.js +0 -47
- package/dist/util/BinarySearch.d.ts +0 -7
- package/dist/util/BinarySearch.js +0 -46
- package/dist/util/CachingHasher.d.ts +0 -8
- package/dist/util/CachingHasher.js +0 -41
- package/dist/util/Color.d.ts +0 -32
- package/dist/util/Color.js +0 -204
- package/dist/util/Dispatch.d.ts +0 -15
- package/dist/util/Dispatch.js +0 -79
- package/dist/util/EditDistance.d.ts +0 -13
- package/dist/util/EditDistance.js +0 -184
- package/dist/util/NumberFormat.d.ts +0 -14
- package/dist/util/NumberFormat.js +0 -224
- package/dist/util/Struct.d.ts +0 -4
- package/dist/util/Struct.js +0 -15
- package/dist/util/Template.d.ts +0 -16
- package/dist/util/Template.js +0 -128
- package/dist/util/Text.d.ts +0 -45
- package/dist/util/Text.js +0 -243
- package/dist/util/Tuples.d.ts +0 -9
- package/dist/util/Tuples.js +0 -135
- package/dist/util/Validate.d.ts +0 -4
- package/dist/util/Validate.js +0 -11
- package/dist/util/Vocabulary.d.ts +0 -3
- package/dist/util/Vocabulary.js +0 -35
- package/lib/models/content/Billing.ts +0 -558
- package/lib/models/content/DevEnv.ts +0 -5
- package/lib/models/content/DictionaryEntry.ts +0 -22
- package/lib/models/content/Hanzi.ts +0 -25
- package/lib/models/content/Phrase.ts +0 -10
- package/lib/models/content/Time.ts +0 -328
- package/lib/models/content/User.ts +0 -130
- package/lib/models/content/index.ts +0 -19
- package/lib/models/markup/DeltaOps.ts +0 -71
- package/lib/models/markup/index.ts +0 -6
- package/lib/util/Base62.ts +0 -47
- package/lib/util/CachingHasher.ts +0 -38
- package/lib/util/Dispatch.ts +0 -92
- package/lib/util/NumberFormat.ts +0 -194
- package/lib/util/Struct.ts +0 -14
- package/lib/util/Tuples.ts +0 -131
- /package/dist/models/{content/GeoLocation.d.ts → GeoLocation.d.ts} +0 -0
- /package/dist/models/{content/GeoLocation.js → GeoLocation.js} +0 -0
- /package/dist/models/{content/Hanzi.js → Hanzi.js} +0 -0
- /package/dist/models/{content/Permissions.d.ts → Permissions.d.ts} +0 -0
- /package/dist/models/{content/Permissions.js → Permissions.js} +0 -0
- /package/dist/models/{content/Phrase.js → Phrase.js} +0 -0
- /package/dist/models/{content/Activity.js → Review.js} +0 -0
- /package/dist/{models/markup → repo}/TextEditOps.d.ts +0 -0
- /package/dist/{models/markup → repo}/TextEditOps.js +0 -0
- /package/lib/models/{content/GeoLocation.ts → GeoLocation.ts} +0 -0
- /package/lib/{models/markup → repo}/TextEditOps.ts +0 -0
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ExportOptions } from "../content/ExportOptions";
|
|
2
|
-
import { LegacyContent } from "./LegacyContent";
|
|
3
|
-
import { LegacyHeadLocator, LegacyLocator } from "./LegacyLocator";
|
|
4
|
-
import { LegacyStub } from "./LegacyStub";
|
|
5
|
-
export interface LegacyStoryPayload {
|
|
6
|
-
name: string;
|
|
7
|
-
subtitle: string;
|
|
8
|
-
synopsis_id: LegacyHeadLocator | null;
|
|
9
|
-
cover_art_id: LegacyHeadLocator | null;
|
|
10
|
-
author: string;
|
|
11
|
-
contributors: LegacyLocator[];
|
|
12
|
-
copyright: string;
|
|
13
|
-
publisher: string;
|
|
14
|
-
isbn: string;
|
|
15
|
-
manuscript: LegacyStub[];
|
|
16
|
-
notebook: LegacyStub[];
|
|
17
|
-
export_options: ExportOptions;
|
|
18
|
-
trash: Array<LegacyStub | LegacyHeadLocator>;
|
|
19
|
-
total_word_count: number;
|
|
20
|
-
}
|
|
21
|
-
export interface LegacyStory extends LegacyContent {
|
|
22
|
-
payload: LegacyStoryPayload;
|
|
23
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { LegacyContentKind } from "./LegacyContent";
|
|
2
|
-
import { LegacyHeadLocator, LegacyLocator } from "./LegacyLocator";
|
|
3
|
-
export interface LegacyStub {
|
|
4
|
-
kind: LegacyContentKind;
|
|
5
|
-
label: string;
|
|
6
|
-
parent?: LegacyHeadLocator;
|
|
7
|
-
children?: LegacyStub[];
|
|
8
|
-
}
|
|
9
|
-
export interface LegacyFolderStub extends LegacyStub {
|
|
10
|
-
id: LegacyHeadLocator;
|
|
11
|
-
}
|
|
12
|
-
export interface LegacyContentStub extends LegacyStub {
|
|
13
|
-
category?: string;
|
|
14
|
-
locator: LegacyLocator;
|
|
15
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { TransactionPayload, TransactionTopic } from "../content/Billing";
|
|
2
|
-
import { LegacyContent, LegacyDateTime } from "./LegacyContent";
|
|
3
|
-
import { LegacyUser } from "./LegacyUser";
|
|
4
|
-
export interface LegacyTransactionPayload {
|
|
5
|
-
at_utc_time?: LegacyDateTime;
|
|
6
|
-
topic: TransactionTopic;
|
|
7
|
-
details?: any;
|
|
8
|
-
}
|
|
9
|
-
export interface LegacyTransaction extends LegacyContent {
|
|
10
|
-
payload: LegacyTransactionPayload;
|
|
11
|
-
}
|
|
12
|
-
export declare class LegacyTransactionModel {
|
|
13
|
-
static create(user: LegacyUser, utcTime: LegacyDateTime, payload: TransactionPayload): LegacyTransaction;
|
|
14
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LegacyTransactionModel = void 0;
|
|
4
|
-
const util_1 = require("../../util");
|
|
5
|
-
const LegacyContent_1 = require("./LegacyContent");
|
|
6
|
-
class LegacyTransactionModel {
|
|
7
|
-
static create(user, utcTime, payload) {
|
|
8
|
-
payload = util_1.Struct.clone(payload);
|
|
9
|
-
let transactionId = user.payload.transaction_id;
|
|
10
|
-
let lastSeq = null;
|
|
11
|
-
let seq = 0;
|
|
12
|
-
if (user.payload.last_transaction !== null) {
|
|
13
|
-
lastSeq = Number(user.payload.last_transaction.split("-")[1]);
|
|
14
|
-
seq = lastSeq + 1;
|
|
15
|
-
}
|
|
16
|
-
let profileId = user.payload.profile_id;
|
|
17
|
-
let locator = transactionId + "-" + seq;
|
|
18
|
-
let parent = lastSeq === null ? null : transactionId + "-" + (lastSeq);
|
|
19
|
-
if (payload.at_utc_time) {
|
|
20
|
-
// The 'at_utc_time' field is only present in modern TransactionPayload objects.
|
|
21
|
-
// In the legacy objects, the field is just part of the content envelope.
|
|
22
|
-
delete payload.at_utc_time;
|
|
23
|
-
}
|
|
24
|
-
if (payload.details && payload.details.period) {
|
|
25
|
-
payload.details.period.start = LegacyContent_1.LegacyClock.fromCompact(payload.details.period.start);
|
|
26
|
-
payload.details.period.end = LegacyContent_1.LegacyClock.fromCompact(payload.details.period.end);
|
|
27
|
-
}
|
|
28
|
-
let transaction = {
|
|
29
|
-
"locator": locator,
|
|
30
|
-
"parent": parent,
|
|
31
|
-
"is_head": false,
|
|
32
|
-
"sync_time": utcTime,
|
|
33
|
-
"kind": LegacyContent_1.LegacyContentKind.TRANSACTION,
|
|
34
|
-
"id": transactionId,
|
|
35
|
-
"seq": seq,
|
|
36
|
-
"by": profileId,
|
|
37
|
-
"at": {
|
|
38
|
-
"local_time": utcTime,
|
|
39
|
-
"utc_time": utcTime
|
|
40
|
-
},
|
|
41
|
-
"model_version": 2,
|
|
42
|
-
"session": null,
|
|
43
|
-
"permissions": ["profile-" + profileId + "-read"],
|
|
44
|
-
"payload": payload
|
|
45
|
-
};
|
|
46
|
-
return transaction;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.LegacyTransactionModel = LegacyTransactionModel;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { CreditCard, PaymentStatus } from "../content/Billing";
|
|
2
|
-
import { LegacyContent, LegacyDateTime } from "./LegacyContent";
|
|
3
|
-
import { LegacyHeadLocator, LegacyLocator } from "./LegacyLocator";
|
|
4
|
-
export interface LegacyUserPayload {
|
|
5
|
-
email: string;
|
|
6
|
-
username?: string;
|
|
7
|
-
force_password_reset: boolean;
|
|
8
|
-
session_id: LegacyHeadLocator;
|
|
9
|
-
profile_id: LegacyHeadLocator;
|
|
10
|
-
workspace_id: LegacyHeadLocator;
|
|
11
|
-
transaction_id: LegacyHeadLocator;
|
|
12
|
-
last_transaction: LegacyLocator;
|
|
13
|
-
plan: string;
|
|
14
|
-
payment_status: PaymentStatus;
|
|
15
|
-
paid_until: LegacyDateTime;
|
|
16
|
-
stripe_customer_id: string;
|
|
17
|
-
credit_card: CreditCard;
|
|
18
|
-
salt: string;
|
|
19
|
-
pass_md5_salt_md5: string;
|
|
20
|
-
}
|
|
21
|
-
export interface LegacyUser extends LegacyContent {
|
|
22
|
-
payload: LegacyUserPayload;
|
|
23
|
-
}
|
|
24
|
-
export declare class LegacyUserModel {
|
|
25
|
-
static advance(user: LegacyUser): LegacyUser;
|
|
26
|
-
static isValidPassMd5(passMd5: string, userPayload: LegacyUserPayload): boolean;
|
|
27
|
-
static addSaltToPassMd5(salt: string, passMd5: string): string;
|
|
28
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.LegacyUserModel = void 0;
|
|
7
|
-
const md5_1 = __importDefault(require("md5"));
|
|
8
|
-
const Struct_1 = require("../../util/Struct");
|
|
9
|
-
const LegacyContent_1 = require("./LegacyContent");
|
|
10
|
-
const LegacyLocator_1 = require("./LegacyLocator");
|
|
11
|
-
class LegacyUserModel {
|
|
12
|
-
static advance(user) {
|
|
13
|
-
// Create a defensive copy of the content.
|
|
14
|
-
user = Struct_1.Struct.clone(user);
|
|
15
|
-
// Update all the fields for the new snapshot
|
|
16
|
-
user.at = LegacyContent_1.LegacyMultiClock.utcNow();
|
|
17
|
-
user.sync_time = user.at.utc_time;
|
|
18
|
-
user.seq = user.seq + 1;
|
|
19
|
-
user.parent = user.locator;
|
|
20
|
-
user.locator = LegacyLocator_1.LegacyLocatorModel.create(user.id, user.seq);
|
|
21
|
-
user.is_head = true;
|
|
22
|
-
return user;
|
|
23
|
-
}
|
|
24
|
-
static isValidPassMd5(passMd5, userPayload) {
|
|
25
|
-
let passMd5SaltMd5 = LegacyUserModel.addSaltToPassMd5(userPayload.salt, passMd5);
|
|
26
|
-
return passMd5SaltMd5 === userPayload.pass_md5_salt_md5;
|
|
27
|
-
}
|
|
28
|
-
static addSaltToPassMd5(salt, passMd5) {
|
|
29
|
-
return (0, md5_1.default)(passMd5 + salt);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.LegacyUserModel = LegacyUserModel;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ContentId } from "../content";
|
|
2
|
-
import { HighlightConfig, UxSettings } from "../content/Device";
|
|
3
|
-
import { LegacyContent, LegacyDateTime } from "./LegacyContent";
|
|
4
|
-
import { LegacyHeadLocator } from "./LegacyLocator";
|
|
5
|
-
import { LegacyStub } from "./LegacyStub";
|
|
6
|
-
export type LegacyWorkspaceArrayName = "stories" | "books" | "shorts" | "articles" | "poems" | "ideas" | "trash";
|
|
7
|
-
export declare const WORKSPACE_STUB_ARRAY_NAMES: LegacyWorkspaceArrayName[];
|
|
8
|
-
export interface LegacyWorkspacePayload {
|
|
9
|
-
primary_device: ContentId;
|
|
10
|
-
primary_device_last_update?: LegacyDateTime;
|
|
11
|
-
ux: UxSettings;
|
|
12
|
-
books?: LegacyStub[];
|
|
13
|
-
stories: LegacyStub[];
|
|
14
|
-
shorts: LegacyStub[];
|
|
15
|
-
articles: LegacyStub[];
|
|
16
|
-
poems: LegacyStub[];
|
|
17
|
-
ideas: LegacyStub[];
|
|
18
|
-
highlight: HighlightConfig;
|
|
19
|
-
trash: Array<LegacyHeadLocator>;
|
|
20
|
-
}
|
|
21
|
-
export interface LegacyWorkspace extends LegacyContent {
|
|
22
|
-
payload: LegacyWorkspacePayload;
|
|
23
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export * from './LegacyBodyFormat';
|
|
2
|
-
export * from './LegacyComment';
|
|
3
|
-
export * from './LegacyContent';
|
|
4
|
-
export * from './LegacyConversion';
|
|
5
|
-
export * from './LegacyFragment';
|
|
6
|
-
export * from './LegacyLocator';
|
|
7
|
-
export * from './LegacyOutboundMessage';
|
|
8
|
-
export * from './LegacyPicture';
|
|
9
|
-
export * from './LegacyProfile';
|
|
10
|
-
export * from './LegacySession';
|
|
11
|
-
export * from './LegacyStory';
|
|
12
|
-
export * from './LegacyStub';
|
|
13
|
-
export * from './LegacyTransaction';
|
|
14
|
-
export * from './LegacyUser';
|
|
15
|
-
export * from './LegacyWorkspace';
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// created from 'create-ts-index'
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
-
};
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
__exportStar(require("./LegacyBodyFormat"), exports);
|
|
19
|
-
__exportStar(require("./LegacyComment"), exports);
|
|
20
|
-
__exportStar(require("./LegacyContent"), exports);
|
|
21
|
-
__exportStar(require("./LegacyConversion"), exports);
|
|
22
|
-
__exportStar(require("./LegacyFragment"), exports);
|
|
23
|
-
__exportStar(require("./LegacyLocator"), exports);
|
|
24
|
-
__exportStar(require("./LegacyOutboundMessage"), exports);
|
|
25
|
-
__exportStar(require("./LegacyPicture"), exports);
|
|
26
|
-
__exportStar(require("./LegacyProfile"), exports);
|
|
27
|
-
__exportStar(require("./LegacySession"), exports);
|
|
28
|
-
__exportStar(require("./LegacyStory"), exports);
|
|
29
|
-
__exportStar(require("./LegacyStub"), exports);
|
|
30
|
-
__exportStar(require("./LegacyTransaction"), exports);
|
|
31
|
-
__exportStar(require("./LegacyUser"), exports);
|
|
32
|
-
__exportStar(require("./LegacyWorkspace"), exports);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Op as DeltaOp } from "@shaxpir/quill-delta";
|
|
2
|
-
import { ContentId } from "../content/Content";
|
|
3
|
-
import { LegacyBodyFormatPayload } from "../legacy/LegacyBodyFormat";
|
|
4
|
-
export declare class BodyFormatModel {
|
|
5
|
-
static fromDeltaOps(ops: DeltaOp[]): LegacyBodyFormatPayload;
|
|
6
|
-
static toDeltaOps(bodyformat: LegacyBodyFormatPayload): DeltaOp[];
|
|
7
|
-
static getMediaIdsFromDeltaOps(ops: DeltaOp[]): ContentId[];
|
|
8
|
-
static getCommentIdsFromDeltaOps(ops: DeltaOp[]): ContentId[];
|
|
9
|
-
static getLinePreceding(ops: DeltaOp[], index: number): string;
|
|
10
|
-
private static getSuffixAfterNewline;
|
|
11
|
-
private static findOpIndexAtTextIndex;
|
|
12
|
-
private static filterNonInsertOps;
|
|
13
|
-
private static getTextFromOp;
|
|
14
|
-
}
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BodyFormatModel = void 0;
|
|
4
|
-
const Struct_1 = require("../../util/Struct");
|
|
5
|
-
class BodyFormatModel {
|
|
6
|
-
static fromDeltaOps(ops) {
|
|
7
|
-
ops = BodyFormatModel.filterNonInsertOps(ops);
|
|
8
|
-
let body = "";
|
|
9
|
-
let format = [];
|
|
10
|
-
for (let i = 0, len = ops.length; i < len; i++) {
|
|
11
|
-
let op = ops[i];
|
|
12
|
-
let text = BodyFormatModel.getTextFromOp(ops, i);
|
|
13
|
-
let fmt = { at: body.length, len: text.length };
|
|
14
|
-
if (typeof (op.insert) !== "string") {
|
|
15
|
-
fmt.embed = Struct_1.Struct.clone(op.insert);
|
|
16
|
-
}
|
|
17
|
-
if (op.hasOwnProperty("attributes")) {
|
|
18
|
-
fmt.attr = Struct_1.Struct.clone(op.attributes);
|
|
19
|
-
}
|
|
20
|
-
format.push(fmt);
|
|
21
|
-
body += text;
|
|
22
|
-
}
|
|
23
|
-
return {
|
|
24
|
-
"body": body,
|
|
25
|
-
"format": format
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
static toDeltaOps(bodyformat) {
|
|
29
|
-
let ops = [];
|
|
30
|
-
let body = bodyformat.body;
|
|
31
|
-
let formatArr = bodyformat.format;
|
|
32
|
-
for (let i = 0, len = formatArr.length; i < len; i++) {
|
|
33
|
-
let rtFormat = formatArr[i];
|
|
34
|
-
let op;
|
|
35
|
-
if (rtFormat.hasOwnProperty('embed')) {
|
|
36
|
-
op = { insert: Struct_1.Struct.clone(rtFormat.embed) };
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
op = { insert: body.substr(rtFormat.at, rtFormat.len) };
|
|
40
|
-
}
|
|
41
|
-
if (rtFormat.hasOwnProperty('attr')) {
|
|
42
|
-
op.attributes = Struct_1.Struct.clone(rtFormat.attr);
|
|
43
|
-
// In an older version of the format, we had separate format parameters for subscript and
|
|
44
|
-
// superscript, but now we use a single "script" parameter with values "sub" and "super",
|
|
45
|
-
// which is the standard Parchment format. The problem with the old format is that it allows
|
|
46
|
-
// a character to be both subscript and superscript, which is not possible in the new format.
|
|
47
|
-
//So, we need to convert the old format to the new format, and we do that here.
|
|
48
|
-
if (op.attributes.hasOwnProperty('subscript') && op.attributes.subscript) {
|
|
49
|
-
op.attributes.script = 'sub';
|
|
50
|
-
delete op.attributes.subscript;
|
|
51
|
-
}
|
|
52
|
-
if (op.attributes.hasOwnProperty('superscript') && op.attributes.superscript) {
|
|
53
|
-
op.attributes.script = 'super';
|
|
54
|
-
delete op.attributes.superscript;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
ops.push(op);
|
|
58
|
-
}
|
|
59
|
-
return ops;
|
|
60
|
-
}
|
|
61
|
-
static getMediaIdsFromDeltaOps(ops) {
|
|
62
|
-
let mediaIds = new Set();
|
|
63
|
-
for (let i = 0, len = ops.length; i < len; i++) {
|
|
64
|
-
let op = ops[i];
|
|
65
|
-
if (op.insert && typeof (op.insert) === "object") {
|
|
66
|
-
const insert = op.insert;
|
|
67
|
-
if (insert.media) {
|
|
68
|
-
const fileName = insert.media;
|
|
69
|
-
const mediaId = fileName.substring(0, fileName.indexOf('.'));
|
|
70
|
-
mediaIds.add(mediaId);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return Array.from(mediaIds);
|
|
75
|
-
}
|
|
76
|
-
static getCommentIdsFromDeltaOps(ops) {
|
|
77
|
-
let commentIds = new Set();
|
|
78
|
-
for (let i = 0, len = ops.length; i < len; i++) {
|
|
79
|
-
let op = ops[i];
|
|
80
|
-
if (op.attributes && op.attributes.comment) {
|
|
81
|
-
// TODO: fix these "as any" casts, after updating the Comment model to
|
|
82
|
-
// conform with the new Delta "complex attributes" format
|
|
83
|
-
for (let j = 0; j < op.attributes.comment.length; j++) {
|
|
84
|
-
let commentId = op.attributes.comment[j];
|
|
85
|
-
commentIds.add(commentId);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return Array.from(commentIds);
|
|
90
|
-
}
|
|
91
|
-
// This method is used to determine the text that precedes a given index in the document,
|
|
92
|
-
// by finding the end-index in the delta operations, and then walking backward and accumulating
|
|
93
|
-
// text until we reach a newline character. Previously, the shaxpir-desktop app always had
|
|
94
|
-
// to call BodyFormatModel.fromDeltaOps() to get the full text of the document, and then use
|
|
95
|
-
// the index to slice out a single line. This method is much more efficient, because it only
|
|
96
|
-
// needs to walk backward through the delta operations until it finds the newline character.
|
|
97
|
-
static getLinePreceding(ops, index) {
|
|
98
|
-
ops = BodyFormatModel.filterNonInsertOps(ops);
|
|
99
|
-
let line = "";
|
|
100
|
-
const indexPair = BodyFormatModel.findOpIndexAtTextIndex(ops, index);
|
|
101
|
-
if (indexPair != null) {
|
|
102
|
-
const opIndex = indexPair.opIndex;
|
|
103
|
-
const textStartIndex = indexPair.textStartIndex;
|
|
104
|
-
const textFromLastOp = BodyFormatModel.getTextFromOp(ops, opIndex);
|
|
105
|
-
if (textStartIndex > 0) {
|
|
106
|
-
line = textFromLastOp.substring(0, textStartIndex);
|
|
107
|
-
const lineSuffix = BodyFormatModel.getSuffixAfterNewline(line);
|
|
108
|
-
if (line != lineSuffix) {
|
|
109
|
-
return lineSuffix;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
for (let i = opIndex - 1; i >= 0; i--) {
|
|
113
|
-
const text = BodyFormatModel.getTextFromOp(ops, i);
|
|
114
|
-
const textSuffix = BodyFormatModel.getSuffixAfterNewline(text);
|
|
115
|
-
if (text != textSuffix) {
|
|
116
|
-
line = textSuffix + line;
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
line = text + line;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return line;
|
|
125
|
-
}
|
|
126
|
-
static getSuffixAfterNewline(text) {
|
|
127
|
-
const indexOfLastNewline = text.lastIndexOf('\n');
|
|
128
|
-
if (indexOfLastNewline >= 0) {
|
|
129
|
-
return text.substring(indexOfLastNewline + 1);
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
return text;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
static findOpIndexAtTextIndex(ops, textIndex) {
|
|
136
|
-
let maxIndex = 0;
|
|
137
|
-
for (let i = 0, len = ops.length; i < len; i++) {
|
|
138
|
-
const text = BodyFormatModel.getTextFromOp(ops, i);
|
|
139
|
-
const startIndex = maxIndex;
|
|
140
|
-
const endIndex = startIndex + text.length;
|
|
141
|
-
if (textIndex >= startIndex && textIndex < endIndex) {
|
|
142
|
-
return {
|
|
143
|
-
opIndex: i,
|
|
144
|
-
textStartIndex: textIndex - startIndex
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
maxIndex = endIndex;
|
|
148
|
-
}
|
|
149
|
-
return null;
|
|
150
|
-
}
|
|
151
|
-
static filterNonInsertOps(ops) {
|
|
152
|
-
// HACK!!: We've seen some weird cases where the ops array (in a doc-delta, not a op-delta!)
|
|
153
|
-
// contains 'retain' or 'delete' ops (usually but not always at the end). This is not a valid op,
|
|
154
|
-
// and I'm not sure where it's coming from (maybe from root Quill, or from our own Quill fork,
|
|
155
|
-
// or maybe from the ShareDB client). Anyway, we need to filter it out, because it causes
|
|
156
|
-
// the downstream code to throw errors whenever we try to extract text from it. Removing it
|
|
157
|
-
// here shouldn't cause any problems, because the resultant "BodyFormat" object is only used
|
|
158
|
-
// for generating word-counts, and for ElasticModel transforms.
|
|
159
|
-
const filteredOps = [];
|
|
160
|
-
for (let i = 0, len = ops.length; i < len; i++) {
|
|
161
|
-
const op = ops[i];
|
|
162
|
-
if (op.hasOwnProperty('retain') || op.hasOwnProperty('delete')) {
|
|
163
|
-
continue;
|
|
164
|
-
}
|
|
165
|
-
filteredOps.push(ops[i]);
|
|
166
|
-
}
|
|
167
|
-
return filteredOps;
|
|
168
|
-
}
|
|
169
|
-
static getTextFromOp(ops, index) {
|
|
170
|
-
const op = ops[index];
|
|
171
|
-
if (op.hasOwnProperty("insert")) {
|
|
172
|
-
if (typeof (op.insert) === "string") {
|
|
173
|
-
return op.insert;
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
return "\n";
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
else if (op.hasOwnProperty("retain")) {
|
|
180
|
-
throw new Error("cant extract text from ops: illegal RETAIN op (idx: " + index + ") in " + JSON.stringify(ops));
|
|
181
|
-
}
|
|
182
|
-
else if (op.hasOwnProperty("delete")) {
|
|
183
|
-
throw new Error("cant extract text from ops: illegal DELETE op (idx: " + index + ") in " + JSON.stringify(ops));
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
throw new Error("cant extract text from ops: unexpected op (idx: " + index + ") in " + JSON.stringify(ops));
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
exports.BodyFormatModel = BodyFormatModel;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DeltaOpsModel = void 0;
|
|
4
|
-
const Struct_1 = require("../../util/Struct");
|
|
5
|
-
class DeltaOpsModel {
|
|
6
|
-
static splitOnNewlines(ops) {
|
|
7
|
-
let newOps = [];
|
|
8
|
-
for (let i = 0, iLen = ops.length; i < iLen; i++) {
|
|
9
|
-
let op = ops[i];
|
|
10
|
-
let text = "\n";
|
|
11
|
-
let embed = null;
|
|
12
|
-
let blockAttr = null;
|
|
13
|
-
let rangeAttr = null;
|
|
14
|
-
if (typeof (op.insert) === "string") {
|
|
15
|
-
text = op.insert;
|
|
16
|
-
if (op.hasOwnProperty("attributes")) {
|
|
17
|
-
for (let key in op.attributes) {
|
|
18
|
-
let val = op.attributes[key];
|
|
19
|
-
if (DeltaOpsModel.BLOCK_ATTR_KEYS.hasOwnProperty(key)) {
|
|
20
|
-
if (blockAttr == null) {
|
|
21
|
-
blockAttr = {};
|
|
22
|
-
}
|
|
23
|
-
blockAttr[key] = val;
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
if (rangeAttr == null) {
|
|
27
|
-
rangeAttr = {};
|
|
28
|
-
}
|
|
29
|
-
rangeAttr[key] = val;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
else if (op.hasOwnProperty("insert")) {
|
|
35
|
-
embed = Struct_1.Struct.clone(op.insert);
|
|
36
|
-
}
|
|
37
|
-
let parts = text.split(/(\n)/g);
|
|
38
|
-
let nonEmptyParts = [];
|
|
39
|
-
for (let j = 0, jLen = parts.length; j < jLen; j++) {
|
|
40
|
-
let part = parts[j];
|
|
41
|
-
if (part.length > 0) {
|
|
42
|
-
nonEmptyParts.push(part);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
parts = nonEmptyParts;
|
|
46
|
-
for (let j = 0, jLen = parts.length, jLast = jLen - 1; j < jLen; j++) {
|
|
47
|
-
let part = parts[j];
|
|
48
|
-
let newOp = { "insert": part, "attributes": {} };
|
|
49
|
-
if (embed !== null) {
|
|
50
|
-
newOp.insert = embed;
|
|
51
|
-
}
|
|
52
|
-
else if (part === "\n") {
|
|
53
|
-
if (j === jLast && blockAttr != null) {
|
|
54
|
-
newOp.attributes = blockAttr;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
else if (rangeAttr != null) {
|
|
58
|
-
newOp.attributes = rangeAttr;
|
|
59
|
-
}
|
|
60
|
-
newOps.push(newOp);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return newOps;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
exports.DeltaOpsModel = DeltaOpsModel;
|
|
67
|
-
DeltaOpsModel.BLOCK_ATTR_KEYS = {
|
|
68
|
-
"align": true,
|
|
69
|
-
"blockquote": true,
|
|
70
|
-
"header": true,
|
|
71
|
-
"indent": true,
|
|
72
|
-
"list": true,
|
|
73
|
-
"caption": true,
|
|
74
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HtmlMarkup = void 0;
|
|
4
|
-
class HtmlMarkup {
|
|
5
|
-
static escapeText(text) {
|
|
6
|
-
// STRIP OUT LINE FEEDS AND VERTICAL TABS
|
|
7
|
-
text = text.replace(/[\f\v]/g, "");
|
|
8
|
-
// ESCAPE SPECIAL HTML CHARACTERS
|
|
9
|
-
text = text.replace(/&/g, "&");
|
|
10
|
-
text = text.replace(/>/g, ">");
|
|
11
|
-
text = text.replace(/</g, "<");
|
|
12
|
-
text = text.replace(/'/g, "'");
|
|
13
|
-
text = text.replace(/"/g, """);
|
|
14
|
-
while (text.indexOf(" ") >= 0) {
|
|
15
|
-
text = text.replace(/(\x20*)\x20{2}/g, "$1 ");
|
|
16
|
-
}
|
|
17
|
-
return text;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.HtmlMarkup = HtmlMarkup;
|
|
21
|
-
HtmlMarkup.BLOCK_TAGS = "div,p,h1,h2,h3,h4,h5,li,blockquote";
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// created from 'create-ts-index'
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
-
};
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
__exportStar(require("./ChangeModel"), exports);
|
|
19
|
-
__exportStar(require("./DeltaOps"), exports);
|
|
20
|
-
__exportStar(require("./Operation"), exports);
|
|
21
|
-
__exportStar(require("./TextEditOps"), exports);
|
package/dist/util/Async.d.ts
DELETED
package/dist/util/Async.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.delay = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Returns a promise that delays for the given ms before resolving.
|
|
6
|
-
*
|
|
7
|
-
* Intended to be used e.g. `await delay(1000)`
|
|
8
|
-
*
|
|
9
|
-
* @param t milliseconds to delay for
|
|
10
|
-
*/
|
|
11
|
-
function delay(t) {
|
|
12
|
-
return new Promise((resolve) => {
|
|
13
|
-
setTimeout(() => {
|
|
14
|
-
resolve();
|
|
15
|
-
}, t);
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
exports.delay = delay;
|