Compare commits

...
327 changed files with 46227 additions and 254 deletions
-1
View File
@@ -7,7 +7,6 @@ on:
jobs:
Build:
if: "${{ contains(github.event.head_commit.message, 'chore(release): publish') == false }}"
continue-on-error: true
runs-on: ubuntu-latest
steps:
- name: Checkout code
+1
View File
@@ -26,6 +26,7 @@ packages/api/dist
packages/responses/dist
packages/sncrypto-common/dist
packages/sncrypto-web/dist
packages/snjs/dist
**/.pnp.*
**/.yarn/*
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+2 -1
View File
@@ -28,6 +28,7 @@
"build:desktop": "yarn workspaces foreach -pt --verbose -R --from @standardnotes/desktop --exclude @standardnotes/components-meta run build",
"build:mobile": "yarn workspaces foreach -pt --verbose -R --from @standardnotes/mobile --exclude @standardnotes/components-meta run build",
"build:web-server": "yarn workspaces foreach -pt --verbose -R --from @standardnotes/web-server --exclude @standardnotes/components-meta run build",
"build:snjs": "yarn workspaces foreach -pt --verbose -R --from @standardnotes/snjs --exclude @standardnotes/components-meta run build",
"start:server:web": "lerna run start --scope=@standardnotes/web-server",
"start:server:web:localhost": "lerna run start:no-binding --scope=@standardnotes/web-server",
"prepare": "husky install",
@@ -47,7 +48,7 @@
"@types/hoist-non-react-statics/@types/react": "17.0.2"
},
"dependencies": {
"@standardnotes/snjs": "^2.118.3"
"@standardnotes/snjs": "workspace:*"
},
"devDependencies": {
"@commitlint/cli": "^17.0.2",
+10
View File
@@ -3,6 +3,16 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.4.2](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-06)
**Note:** Version bump only for package @standardnotes/api
## [1.4.1](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-06)
### Bug Fixes
* add missing utils dependency on api ([bc666aa](https://github.com/standardnotes/app/commit/bc666aa98301ece42e259be2ed60b9201665988f))
# 1.4.0 (2022-07-06)
### Features
+3 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/api",
"version": "1.4.0",
"version": "1.4.2",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
@@ -36,9 +36,10 @@
"@standardnotes/common": "^1.23.1",
"@standardnotes/encryption": "workspace:*",
"@standardnotes/models": "workspace:*",
"@standardnotes/responses": "^1.9.0",
"@standardnotes/responses": "workspace:*",
"@standardnotes/security": "^1.1.0",
"@standardnotes/services": "workspace:*",
"@standardnotes/utils": "workspace:*",
"reflect-metadata": "^0.1.13"
}
}
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [3.23.52](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-06)
**Note:** Version bump only for package @standardnotes/desktop
## [3.23.51](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-06)
**Note:** Version bump only for package @standardnotes/desktop
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@standardnotes/desktop",
"main": "./app/dist/index.js",
"version": "3.23.51",
"version": "3.23.52",
"license": "AGPL-3.0-or-later",
"author": "Standard Notes.",
"private": true,
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.13.1](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-06)
**Note:** Version bump only for package @standardnotes/encryption
# [1.13.0](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-06)
### Features
+3 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/encryption",
"version": "1.13.0",
"version": "1.13.1",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
@@ -11,9 +11,7 @@
"files": [
"dist"
],
"publishConfig": {
"access": "public"
},
"private": true,
"license": "AGPL-3.0-or-later",
"scripts": {
"clean": "rm -fr dist",
@@ -40,7 +38,7 @@
"dependencies": {
"@standardnotes/common": "^1.23.1",
"@standardnotes/models": "workspace:*",
"@standardnotes/responses": "^1.9.0",
"@standardnotes/responses": "workspace:*",
"@standardnotes/services": "workspace:*",
"@standardnotes/sncrypto-common": "workspace:*",
"@standardnotes/utils": "workspace:*",
+6
View File
@@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [1.21.0](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-06)
### Features
* add snjs package ([0e40469](https://github.com/standardnotes/app/commit/0e40469e2fe868b88860f0f2541364696d8f7957))
# [1.20.0](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-06)
### Features
+1 -1
View File
@@ -36,7 +36,7 @@
},
"dependencies": {
"@standardnotes/sncrypto-web": "workspace:*",
"@standardnotes/snjs": "^2.61.3",
"@standardnotes/snjs": "workspace:*",
"regenerator-runtime": "^0.13.9"
}
}
+2 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/filepicker",
"version": "1.20.0",
"version": "1.21.0",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
@@ -11,9 +11,7 @@
"files": [
"dist"
],
"publishConfig": {
"access": "public"
},
"private": true,
"license": "AGPL-3.0-or-later",
"scripts": {
"clean": "rm -fr dist",
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.8.1](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-06)
**Note:** Version bump only for package @standardnotes/files
# [1.8.0](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-06)
### Features
+3 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/files",
"version": "1.8.0",
"version": "1.8.1",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
@@ -11,9 +11,7 @@
"files": [
"dist"
],
"publishConfig": {
"access": "public"
},
"private": true,
"license": "AGPL-3.0-or-later",
"scripts": {
"clean": "rm -fr dist",
@@ -36,7 +34,7 @@
"@standardnotes/encryption": "workspace:*",
"@standardnotes/filepicker": "workspace:*",
"@standardnotes/models": "workspace:*",
"@standardnotes/responses": "^1.9.0",
"@standardnotes/responses": "workspace:*",
"@standardnotes/services": "workspace:*",
"@standardnotes/sncrypto-common": "workspace:*",
"@standardnotes/utils": "workspace:*",
+10
View File
@@ -3,6 +3,16 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [3.30.0](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-06)
### Bug Fixes
* deps on weba and mobile ([d380711](https://github.com/standardnotes/app/commit/d38071168ac343a952643647996fca5f1018f2b1))
### Features
* add snjs package ([0e40469](https://github.com/standardnotes/app/commit/0e40469e2fe868b88860f0f2541364696d8f7957))
# [3.29.0](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-06)
### Bug Fixes
+2 -1
View File
@@ -30,7 +30,8 @@ module.exports = (async () => {
'../services',
'../files',
'../utils',
'../sncrypto-common'
'../sncrypto-common',
'../snjs',
],
transformer: {
getTransformOptions: async () => ({
+2 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/mobile",
"version": "3.29.0",
"version": "3.30.0",
"author": "Standard Notes.",
"private": true,
"license": "AGPL-3.0-or-later",
@@ -36,8 +36,6 @@
"@react-navigation/native": "^6.0.10",
"@react-navigation/stack": "^6.2.1",
"@standardnotes/components-meta": "workspace:*",
"@standardnotes/encryption": "workspace:*",
"@standardnotes/features": "workspace:*",
"@standardnotes/filepicker": "workspace:*",
"@standardnotes/files": "workspace:*",
"@standardnotes/icons": "workspace:*",
@@ -45,9 +43,8 @@
"@standardnotes/react-native-textview": "1.1.0",
"@standardnotes/react-native-utils": "1.0.1",
"@standardnotes/sncrypto-common": "workspace:*",
"@standardnotes/snjs": "^2.118.3",
"@standardnotes/snjs": "workspace:*",
"@standardnotes/stylekit": "5.29.3",
"@standardnotes/utils": "workspace:*",
"@standardnotes/web": "workspace:*",
"@types/styled-components-react-native": "5.1.3",
"dompurify": "^2.3.8",
+4 -2
View File
@@ -1,10 +1,12 @@
import { MobileTheme } from '@Root/Style/MobileTheme'
import { ComponentChecksumsType } from '@standardnotes/components-meta'
import RawComponentChecksumsFile from '@standardnotes/components-meta/dist/zips/checksums.json'
import { EncryptionService } from '@standardnotes/encryption'
import { FeatureDescription, FeatureIdentifier, GetFeatures } from '@standardnotes/features'
import {
ComponentMutator,
EncryptionService,
FeatureDescription,
FeatureIdentifier,
GetFeatures,
isRightVersionGreaterThanLeft,
PermissionDialog,
SNApplication,
@@ -4,8 +4,7 @@ import { ModalStackNavigationProp } from '@Root/ModalStack'
import { SCREEN_SETTINGS } from '@Root/Screens/screens'
import { FilesSection } from '@Screens/Settings/Sections/FilesSection'
import { WorkspacesSection } from '@Screens/Settings/Sections/WorkspacesSection'
import { FeatureIdentifier } from '@standardnotes/features'
import { ApplicationEvent, FeatureStatus } from '@standardnotes/snjs'
import { ApplicationEvent, FeatureIdentifier, FeatureStatus } from '@standardnotes/snjs'
import React, { useCallback, useEffect, useState } from 'react'
import { AuthSection } from './Sections/AuthSection'
import { CompanySection } from './Sections/CompanySection'
@@ -17,8 +17,7 @@ import {
import { SideMenuOptionIconDescriptionType } from '@Root/Screens/SideMenu/SideMenuSection'
import { SideMenuCell } from '@Screens/SideMenu/SideMenuCell'
import { UploadedFileItemActionType } from '@Screens/UploadedFilesList/UploadedFileItemAction'
import { FeatureIdentifier } from '@standardnotes/features'
import { FeatureStatus, SNNote } from '@standardnotes/snjs'
import { FeatureIdentifier, FeatureStatus, SNNote } from '@standardnotes/snjs'
import React, { FC } from 'react'
type Props = {
@@ -6,14 +6,15 @@ import { useSafeApplicationContext } from '@Root/Hooks/useSafeApplicationContext
import { SCREEN_COMPOSE, SCREEN_INPUT_MODAL_TAG, SCREEN_NOTE_HISTORY } from '@Root/Screens/screens'
import { Files } from '@Root/Screens/SideMenu/Files'
import { Listed } from '@Root/Screens/SideMenu/Listed'
import { FeatureIdentifier, FindNativeFeature } from '@standardnotes/features'
import {
ApplicationEvent,
ButtonType,
ComponentArea,
ComponentMutator,
ContentType,
FeatureIdentifier,
FeatureStatus,
FindNativeFeature,
NoteMutator,
NoteViewController,
PayloadEmitSource,
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.15.1](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-06)
**Note:** Version bump only for package @standardnotes/models
# [1.15.0](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-06)
### Features
+3 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/models",
"version": "1.15.0",
"version": "1.15.1",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
@@ -11,9 +11,7 @@
"files": [
"dist"
],
"publishConfig": {
"access": "public"
},
"private": true,
"license": "AGPL-3.0-or-later",
"scripts": {
"clean": "rm -fr dist",
@@ -35,7 +33,7 @@
"dependencies": {
"@standardnotes/common": "^1.23.1",
"@standardnotes/features": "workspace:*",
"@standardnotes/responses": "^1.9.0",
"@standardnotes/responses": "workspace:*",
"@standardnotes/utils": "workspace:*",
"lodash": "^4.17.21",
"reflect-metadata": "^0.1.13"
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.2.66](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-06)
**Note:** Version bump only for package @standardnotes/releases
## [1.2.65](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-06)
**Note:** Version bump only for package @standardnotes/releases
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/releases",
"version": "1.2.65",
"version": "1.2.66",
"license": "AGPL-3.0-or-later",
"main": "dist/releases.json",
"types": "dist/index.d.ts",
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.16.1](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-06)
**Note:** Version bump only for package @standardnotes/services
# [1.16.0](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-06)
### Bug Fixes
+3 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/services",
"version": "1.16.0",
"version": "1.16.1",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
@@ -11,9 +11,7 @@
"files": [
"dist"
],
"publishConfig": {
"access": "public"
},
"private": true,
"license": "AGPL-3.0-or-later",
"scripts": {
"clean": "rm -fr dist",
@@ -28,7 +26,7 @@
"@standardnotes/auth": "^3.19.4",
"@standardnotes/common": "^1.23.1",
"@standardnotes/models": "workspace:*",
"@standardnotes/responses": "^1.9.0",
"@standardnotes/responses": "workspace:*",
"@standardnotes/security": "^1.2.0",
"@standardnotes/utils": "workspace:*",
"reflect-metadata": "^0.1.13"
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.12.1](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2022-07-06)
**Note:** Version bump only for package @standardnotes/sncrypto-web
# 1.12.0 (2022-07-06)
### Bug Fixes
+2 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/sncrypto-web",
"version": "1.12.0",
"version": "1.12.1",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
@@ -13,9 +13,7 @@
"dist/**/*.d.ts"
],
"license": "AGPL-3.0-or-later",
"publishConfig": {
"access": "public"
},
"private": true,
"scripts": {
"clean": "rm -fr dist",
"prebuild": "yarn clean",
+7
View File
@@ -0,0 +1,7 @@
Edge 16
Firefox 53
Chrome 57
Safari 11
Opera 44
ios 11
ChromeAndroid 84
+5
View File
@@ -0,0 +1,5 @@
node_modules
dist
test
*.config.js
mocha/**/*
+9
View File
@@ -0,0 +1,9 @@
{
"extends": "../../.eslintrc",
"parserOptions": {
"project": "./linter.tsconfig.json"
},
"rules": {
"@typescript-eslint/no-explicit-any": ["warn", { "ignoreRestArgs": true }]
}
}
File diff suppressed because it is too large Load Diff
+7
View File
@@ -0,0 +1,7 @@
module.exports = function (api) {
api.cache.forever();
return {
presets: ['@babel/preset-env'],
};
};
+2
View File
@@ -0,0 +1,2 @@
//@ts-ignore
global['__VERSION__'] = global['SnjsVersion'] = require('./package.json').version
+37
View File
@@ -0,0 +1,37 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const base = require('../../node_modules/@standardnotes/config/src/jest.json');
module.exports = {
...base,
moduleNameMapper: {
'@Lib/(.*)': '<rootDir>/lib/$1',
'@Services/(.*)': '<rootDir>/lib/Services/$1',
},
globals: {
'ts-jest': {
tsconfig: '<rootDir>/lib/tsconfig.json',
isolatedModules: true,
babelConfig: 'babel.config.js',
},
},
clearMocks: true,
collectCoverageFrom: ['lib/**/{!(index),}.ts'],
coverageDirectory: 'coverage',
coverageReporters: ['json', 'text', 'html'],
resetMocks: true,
resetModules: true,
roots: ['<rootDir>/lib'],
setupFiles: ['<rootDir>/jest-global.ts'],
setupFilesAfterEnv: [],
transform: {
'^.+\\.(ts|js)?$': 'ts-jest',
},
coverageThreshold: {
global: {
branches: 13,
functions: 22,
lines: 27,
statements: 28,
},
},
}
+22
View File
@@ -0,0 +1,22 @@
{
"source": {
"includePattern": ".+\\.js(doc|x)?$",
"include": ["lib"],
"exclude": ["node_modules"]
},
"recurseDepth": 10,
"opts": {
"destination": "./docs/",
"recurse": true,
"template": "node_modules/docdash"
},
"tags": {
"allowUnknownTags": true,
"dictionaries": ["jsdoc", "closure"]
},
"docdash": {
"meta": {
"title": "SNJS Documentation"
}
}
}
@@ -0,0 +1,151 @@
import { SNLog } from './../Log'
import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
import {
AlertService,
DeviceInterface,
Environment,
namespacedKey,
Platform,
RawStorageKey,
} from '@standardnotes/services'
import { SNApplication } from './Application'
describe('application', () => {
// eslint-disable-next-line no-console
SNLog.onLog = console.log
SNLog.onError = console.error
let application: SNApplication
let device: DeviceInterface
let crypto: PureCryptoInterface
beforeEach(async () => {
const identifier = '123'
crypto = {} as jest.Mocked<PureCryptoInterface>
crypto.initialize = jest.fn()
device = {} as jest.Mocked<DeviceInterface>
device.openDatabase = jest.fn().mockResolvedValue(true)
device.getAllRawDatabasePayloads = jest.fn().mockReturnValue([])
device.setRawStorageValue = jest.fn()
device.getRawStorageValue = jest.fn().mockImplementation((key) => {
if (key === namespacedKey(identifier, RawStorageKey.SnjsVersion)) {
return '10.0.0'
}
return undefined
})
device.getDatabaseKeys = async () => {
return Promise.resolve(['1', '2', '3'])
}
application = new SNApplication({
environment: Environment.Mobile,
platform: Platform.Ios,
deviceInterface: device,
crypto: crypto,
alertService: {} as jest.Mocked<AlertService>,
identifier: identifier,
defaultHost: 'localhost',
appVersion: '1.0',
})
await application.prepareForLaunch({ receiveChallenge: jest.fn() })
})
it('diagnostics', async () => {
const diagnostics = await application.getDiagnostics()
expect(diagnostics).toEqual(
expect.objectContaining({
application: expect.objectContaining({
appVersion: '1.0',
environment: 3,
platform: 1,
}),
payloads: {
integrityPayloads: [],
nonDeletedItemCount: 0,
invalidPayloadsCount: 0,
},
items: { allIds: [] },
storage: {
storagePersistable: false,
persistencePolicy: 'Default',
encryptionPolicy: 'Default',
needsPersist: false,
currentPersistPromise: false,
isStorageWrapped: false,
allRawPayloadsCount: 0,
databaseKeys: ['1', '2', '3'],
},
encryption: expect.objectContaining({
getLatestVersion: '004',
hasAccount: false,
getUserVersion: undefined,
upgradeAvailable: false,
accountUpgradeAvailable: false,
passcodeUpgradeAvailable: false,
hasPasscode: false,
isPasscodeLocked: false,
itemsEncryption: expect.objectContaining({
itemsKeysIds: [],
}),
rootKeyEncryption: expect.objectContaining({
hasRootKey: false,
keyMode: 'RootKeyNone',
hasRootKeyWrapper: false,
hasAccount: false,
hasPasscode: false,
}),
}),
api: {
hasSession: false,
user: undefined,
registering: false,
authenticating: false,
changing: false,
refreshingSession: false,
filesHost: undefined,
host: 'localhost',
},
session: {
isSessionRenewChallengePresented: false,
online: false,
offline: true,
isSignedIn: false,
isSignedIntoFirstPartyServer: false,
},
sync: {
syncToken: undefined,
cursorToken: undefined,
lastSyncDate: undefined,
outOfSync: false,
completedOnlineDownloadFirstSync: false,
clientLocked: false,
databaseLoaded: false,
syncLock: false,
dealloced: false,
itemsNeedingSync: [],
itemsNeedingSyncCount: 0,
pendingRequestCount: 0,
},
protections: expect.objectContaining({
getLastSessionLength: undefined,
hasProtectionSources: false,
hasUnprotectedAccessSession: true,
hasBiometricsEnabled: false,
}),
keyRecovery: { queueLength: 0, isProcessingQueue: false },
features: {
roles: [],
features: [],
enabledExperimentalFeatures: [],
needsInitialFeaturesUpdate: true,
completedSuccessfulFeaturesRetrieval: false,
},
migrations: { activeMigrations: [] },
}),
)
})
})
File diff suppressed because it is too large Load Diff
+90
View File
@@ -0,0 +1,90 @@
import { SyncEvent } from '@standardnotes/services'
export { SyncEvent }
export enum ApplicationEvent {
SignedIn = 2,
SignedOut = 3,
/** When a full, potentially multi-page sync completes */
CompletedFullSync = 5,
FailedSync = 6,
HighLatencySync = 7,
EnteredOutOfSync = 8,
ExitedOutOfSync = 9,
/**
* The application has finished it `prepareForLaunch` state and is now ready for unlock
* Called when the application has initialized and is ready for launch, but before
* the application has been unlocked, if applicable. Use this to do pre-launch
* configuration, but do not attempt to access user data like notes or tags.
*/
Started = 10,
/**
* The applicaiton is fully unlocked and ready for i/o
* Called when the application has been fully decrypted and unlocked. Use this to
* to begin streaming data like notes and tags.
*/
Launched = 11,
LocalDataLoaded = 12,
/**
* When the root key or root key wrapper changes. Includes events like account state
* changes (registering, signing in, changing pw, logging out) and passcode state
* changes (adding, removing, changing).
*/
KeyStatusChanged = 13,
MajorDataChange = 14,
CompletedRestart = 15,
LocalDataIncrementalLoad = 16,
SyncStatusChanged = 17,
WillSync = 18,
InvalidSyncSession = 19,
LocalDatabaseReadError = 20,
LocalDatabaseWriteError = 21,
/** When a single roundtrip completes with sync, in a potentially multi-page sync request.
* If just a single roundtrip, this event will be triggered, along with CompletedFullSync */
CompletedIncrementalSync = 22,
/**
* The application has loaded all pending migrations (but not run any, except for the base one),
* and consumers may now call `hasPendingMigrations`
*/
MigrationsLoaded = 23,
/** When StorageService is ready to start servicing read/write requests */
StorageReady = 24,
PreferencesChanged = 25,
UnprotectedSessionBegan = 26,
UserRolesChanged = 27,
FeaturesUpdated = 28,
UnprotectedSessionExpired = 29,
/** Called when the app first launches and after first sync request made after sign in */
CompletedInitialSync = 30,
}
export function applicationEventForSyncEvent(syncEvent: SyncEvent) {
return (
{
[SyncEvent.SyncCompletedWithAllItemsUploaded]: ApplicationEvent.CompletedFullSync,
[SyncEvent.SingleRoundTripSyncCompleted]: ApplicationEvent.CompletedIncrementalSync,
[SyncEvent.SyncError]: ApplicationEvent.FailedSync,
[SyncEvent.SyncTakingTooLong]: ApplicationEvent.HighLatencySync,
[SyncEvent.EnterOutOfSync]: ApplicationEvent.EnteredOutOfSync,
[SyncEvent.ExitOutOfSync]: ApplicationEvent.ExitedOutOfSync,
[SyncEvent.LocalDataLoaded]: ApplicationEvent.LocalDataLoaded,
[SyncEvent.MajorDataChange]: ApplicationEvent.MajorDataChange,
[SyncEvent.LocalDataIncrementalLoad]: ApplicationEvent.LocalDataIncrementalLoad,
[SyncEvent.StatusChanged]: ApplicationEvent.SyncStatusChanged,
[SyncEvent.SyncWillBegin]: ApplicationEvent.WillSync,
[SyncEvent.InvalidSession]: ApplicationEvent.InvalidSyncSession,
[SyncEvent.DatabaseReadError]: ApplicationEvent.LocalDatabaseReadError,
[SyncEvent.DatabaseWriteError]: ApplicationEvent.LocalDatabaseWriteError,
[SyncEvent.DownloadFirstSyncCompleted]: ApplicationEvent.CompletedInitialSync,
} as any
)[syncEvent]
}
+34
View File
@@ -0,0 +1,34 @@
import { DecryptedItemInterface } from '@standardnotes/models'
import { SNApplication } from './Application'
/** Keeps an item reference up to date with changes */
export class LiveItem<T extends DecryptedItemInterface> {
public item: T
private removeObserver: () => void
constructor(uuid: string, application: SNApplication, onChange?: (item: T) => void) {
this.item = application.items.findSureItem(uuid)
onChange && onChange(this.item)
this.removeObserver = application.streamItems(this.item.content_type, ({ changed, inserted }) => {
const matchingItem = [...changed, ...inserted].find((item) => {
return item.uuid === uuid
})
if (matchingItem) {
this.item = matchingItem as T
onChange && onChange(this.item)
}
})
}
public deinit() {
if (!this.removeObserver) {
console.error('A LiveItem is attempting to be deinited more than once.')
} else {
this.removeObserver()
;(this.removeObserver as unknown) = undefined
}
}
}
@@ -0,0 +1,16 @@
import { ApplicationOptionsWhichHaveDefaults } from './Defaults'
import {
ApplicationDisplayOptions,
ApplicationOptionalConfiguratioOptions,
ApplicationSyncOptions,
} from './OptionalOptions'
import { RequiredApplicationOptions } from './RequiredOptions'
export type ApplicationConstructorOptions = RequiredApplicationOptions &
Partial<ApplicationSyncOptions & ApplicationDisplayOptions & ApplicationOptionalConfiguratioOptions>
export type FullyResolvedApplicationOptions = RequiredApplicationOptions &
ApplicationSyncOptions &
ApplicationDisplayOptions &
ApplicationOptionalConfiguratioOptions &
ApplicationOptionsWhichHaveDefaults
@@ -0,0 +1,11 @@
import { ApplicationDisplayOptions, ApplicationSyncOptions } from './OptionalOptions'
export interface ApplicationOptionsWhichHaveDefaults {
loadBatchSize: ApplicationSyncOptions['loadBatchSize']
supportsFileNavigation: ApplicationDisplayOptions['supportsFileNavigation']
}
export const ApplicationOptionsDefaults: ApplicationOptionsWhichHaveDefaults = {
loadBatchSize: 700,
supportsFileNavigation: false,
}

Some files were not shown because too many files have changed in this diff Show More