From 6c5f37442cec5b23f0f532854e28948e81129c51 Mon Sep 17 00:00:00 2001 From: nd0ut Date: Mon, 15 May 2023 20:11:24 +0300 Subject: [PATCH] fix: get rid of `ctxOwner` flag due to it's buggy behaviour --- abstract/ActivityBlock.js | 2 +- abstract/Block.js | 15 ++++----------- abstract/SolutionBlock.js | 3 +-- abstract/UploaderBlock.js | 2 +- blocks/CameraSource/CameraSource.js | 2 +- blocks/CloudImageEditor/CloudImageEditor.js | 2 +- blocks/CloudImageEditor/src/CloudEditor.js | 2 +- blocks/CloudImageEditor/src/CropFrame.js | 2 +- .../CloudImageEditor/src/EditorButtonControl.js | 2 +- .../CloudImageEditor/src/EditorFilterControl.js | 2 +- blocks/CloudImageEditor/src/EditorImageCropper.js | 2 +- blocks/CloudImageEditor/src/EditorSlider.js | 2 +- blocks/CloudImageEditor/src/EditorToolbar.js | 2 +- .../src/elements/button/LrBtnUi.js | 2 +- .../src/elements/slider/SliderUi.js | 2 +- .../CloudImageEditor/src/elements/slider/test.js | 2 +- blocks/Color/Color.js | 2 +- blocks/ConfirmationDialog/ConfirmationDialog.js | 2 +- blocks/Copyright/Copyright.js | 2 +- blocks/DataOutput/DataOutput.js | 2 +- blocks/DropArea/DropArea.js | 3 +-- blocks/EditableCanvas/EditableCanvas.js | 2 +- blocks/EditableCanvas/EditableCanvasToolbar.js | 2 +- blocks/ExternalSource/ExternalSource.js | 2 +- blocks/FileItem/FileItem.js | 2 +- blocks/FilePreview/FilePreview.js | 2 +- blocks/Icon/Icon.js | 2 +- blocks/LiveHtml/LiveHtml.js | 2 +- blocks/MessageBox/MessageBox.js | 2 +- blocks/Modal/Modal.js | 2 +- blocks/ProgressBar/ProgressBar.js | 2 +- blocks/ProgressBarCommon/ProgressBarCommon.js | 2 +- blocks/Select/Select.js | 2 +- blocks/SimpleBtn/SimpleBtn.js | 2 +- blocks/SourceBtn/SourceBtn.js | 2 +- blocks/UploadDetails/UploadDetails.js | 2 +- blocks/UploadList/UploadList.js | 2 +- blocks/UrlSource/UrlSource.js | 2 +- blocks/Video/Video.js | 2 +- .../file-uploader/minimal/FileUploaderMinimal.js | 2 +- 40 files changed, 43 insertions(+), 52 deletions(-) diff --git a/abstract/ActivityBlock.js b/abstract/ActivityBlock.js index b40e74be5..27facdb28 100644 --- a/abstract/ActivityBlock.js +++ b/abstract/ActivityBlock.js @@ -8,7 +8,7 @@ const ACTIVE_PROP = '___ACTIVITY_IS_ACTIVE___'; export class ActivityBlock extends Block { historyTracked = false; - ctxInit = activityBlockCtx(this); + init$ = activityBlockCtx(this); _debouncedHistoryFlush = debounce(this._historyFlush.bind(this), 10); diff --git a/abstract/Block.js b/abstract/Block.js index 4a06df412..a00a241ed 100644 --- a/abstract/Block.js +++ b/abstract/Block.js @@ -1,8 +1,8 @@ -import { BaseComponent, Data } from '@symbiotejs/symbiote'; +import { BaseComponent } from '@symbiotejs/symbiote'; +import { createWindowHeightTracker, getIsWindowHeightTracked } from '../utils/createWindowHeightTracker.js'; import { applyTemplateData, getPluralObjects } from '../utils/template-utils.js'; -import { l10nProcessor } from './l10nProcessor.js'; import { blockCtx } from './CTX.js'; -import { createWindowHeightTracker, getIsWindowHeightTracked } from '../utils/createWindowHeightTracker.js'; +import { l10nProcessor } from './l10nProcessor.js'; const TAG_PREFIX = 'lr-'; @@ -10,8 +10,7 @@ export class Block extends BaseComponent { static StateConsumerScope = null; allowCustomTemplate = true; - ctxInit = blockCtx(); - init$ = this.ctxInit; + init$ = blockCtx(); /** * @param {String} str @@ -119,12 +118,6 @@ export class Block extends BaseComponent { this.constructor['template'] = null; this.processInnerHtml = true; } - if (this.isConnected && this['__ctxOwner']) { - let data = Data.getCtx(this.ctxName, false); - if (data) { - data.store = { ...this.ctxInit }; - } - } super.connectedCallback(); } diff --git a/abstract/SolutionBlock.js b/abstract/SolutionBlock.js index 574817259..9dc23104d 100644 --- a/abstract/SolutionBlock.js +++ b/abstract/SolutionBlock.js @@ -2,8 +2,7 @@ import { ShadowWrapper } from '../blocks/ShadowWrapper/ShadowWrapper.js'; import { uploaderBlockCtx } from './CTX.js'; export class SolutionBlock extends ShadowWrapper { - ctxInit = uploaderBlockCtx(this); - ctxOwner = true; + init$ = uploaderBlockCtx(this); _template = null; static set template(value) { diff --git a/abstract/UploaderBlock.js b/abstract/UploaderBlock.js index 0934530cb..ce282256d 100644 --- a/abstract/UploaderBlock.js +++ b/abstract/UploaderBlock.js @@ -11,7 +11,7 @@ import { Modal } from '../blocks/Modal/Modal.js'; import { stringToArray } from '../utils/stringToArray.js'; export class UploaderBlock extends ActivityBlock { - ctxInit = uploaderBlockCtx(this); + init$ = uploaderBlockCtx(this); cssInit$ = { ...this.cssInit$, '--cfg-max-concurrent-requests': 1, diff --git a/blocks/CameraSource/CameraSource.js b/blocks/CameraSource/CameraSource.js index 73385f0db..c8a3498c7 100644 --- a/blocks/CameraSource/CameraSource.js +++ b/blocks/CameraSource/CameraSource.js @@ -10,7 +10,7 @@ export class CameraSource extends UploaderBlock { _unsubPermissions = null; init$ = { - ...this.ctxInit, + ...this.init$, video: null, videoTransformCss: null, shotBtnDisabled: true, diff --git a/blocks/CloudImageEditor/CloudImageEditor.js b/blocks/CloudImageEditor/CloudImageEditor.js index 2c490725d..9ccb9696f 100644 --- a/blocks/CloudImageEditor/CloudImageEditor.js +++ b/blocks/CloudImageEditor/CloudImageEditor.js @@ -6,7 +6,7 @@ export class CloudImageEditor extends UploaderBlock { activityType = ActivityBlock.activities.CLOUD_IMG_EDIT; init$ = { - ...this.ctxInit, + ...this.init$, cdnUrl: null, }; diff --git a/blocks/CloudImageEditor/src/CloudEditor.js b/blocks/CloudImageEditor/src/CloudEditor.js index 1e8a64e18..d808348e0 100644 --- a/blocks/CloudImageEditor/src/CloudEditor.js +++ b/blocks/CloudImageEditor/src/CloudEditor.js @@ -22,7 +22,7 @@ export class CloudEditor extends Block { } init$ = { - ...this.ctxInit, + ...this.init$, ...initState(this), }; diff --git a/blocks/CloudImageEditor/src/CropFrame.js b/blocks/CloudImageEditor/src/CropFrame.js index 05a28ad5d..aa17f6768 100644 --- a/blocks/CloudImageEditor/src/CropFrame.js +++ b/blocks/CloudImageEditor/src/CropFrame.js @@ -24,7 +24,7 @@ import { classNames } from './lib/classNames.js'; export class CropFrame extends Block { init$ = { - ...this.ctxInit, + ...this.init$, dragging: false, }; diff --git a/blocks/CloudImageEditor/src/EditorButtonControl.js b/blocks/CloudImageEditor/src/EditorButtonControl.js index f0df635e3..0f134e9f1 100644 --- a/blocks/CloudImageEditor/src/EditorButtonControl.js +++ b/blocks/CloudImageEditor/src/EditorButtonControl.js @@ -3,7 +3,7 @@ import { classNames } from './lib/classNames.js'; export class EditorButtonControl extends Block { init$ = { - ...this.ctxInit, + ...this.init$, active: false, title: '', icon: '', diff --git a/blocks/CloudImageEditor/src/EditorFilterControl.js b/blocks/CloudImageEditor/src/EditorFilterControl.js index 7c3c0fed1..a7139feb7 100644 --- a/blocks/CloudImageEditor/src/EditorFilterControl.js +++ b/blocks/CloudImageEditor/src/EditorFilterControl.js @@ -6,7 +6,7 @@ import { preloadImage } from './lib/preloadImage.js'; export class EditorFilterControl extends EditorButtonControl { init$ = { - ...this.ctxInit, + ...this.init$, active: false, title: '', icon: '', diff --git a/blocks/CloudImageEditor/src/EditorImageCropper.js b/blocks/CloudImageEditor/src/EditorImageCropper.js index abd4cf1f2..0de6f270b 100644 --- a/blocks/CloudImageEditor/src/EditorImageCropper.js +++ b/blocks/CloudImageEditor/src/EditorImageCropper.js @@ -53,7 +53,7 @@ function validateCrop(crop) { export class EditorImageCropper extends Block { init$ = { - ...this.ctxInit, + ...this.init$, image: null, '*padding': CROP_PADDING, /** @type {Operations} */ diff --git a/blocks/CloudImageEditor/src/EditorSlider.js b/blocks/CloudImageEditor/src/EditorSlider.js index 3c9a39905..52c0dc2cc 100644 --- a/blocks/CloudImageEditor/src/EditorSlider.js +++ b/blocks/CloudImageEditor/src/EditorSlider.js @@ -10,7 +10,7 @@ export const FAKE_ORIGINAL_FILTER = 'original'; export class EditorSlider extends Block { init$ = { - ...this.ctxInit, + ...this.init$, disabled: false, min: 0, max: 100, diff --git a/blocks/CloudImageEditor/src/EditorToolbar.js b/blocks/CloudImageEditor/src/EditorToolbar.js index e2fae02a3..eb93f2fac 100644 --- a/blocks/CloudImageEditor/src/EditorToolbar.js +++ b/blocks/CloudImageEditor/src/EditorToolbar.js @@ -49,7 +49,7 @@ export class EditorToolbar extends Block { super(); this.init$ = { - ...this.ctxInit, + ...this.init$, '*sliderEl': null, /** @type {import('./types.js').LoadingOperations} */ '*loadingOperations': new Map(), diff --git a/blocks/CloudImageEditor/src/elements/button/LrBtnUi.js b/blocks/CloudImageEditor/src/elements/button/LrBtnUi.js index b9a6f4304..8f277a24e 100644 --- a/blocks/CloudImageEditor/src/elements/button/LrBtnUi.js +++ b/blocks/CloudImageEditor/src/elements/button/LrBtnUi.js @@ -10,7 +10,7 @@ export class LrBtnUi extends Block { this._iconHidden = false; this.init$ = { - ...this.ctxInit, + ...this.init$, text: '', icon: '', iconCss: this._iconCss(), diff --git a/blocks/CloudImageEditor/src/elements/slider/SliderUi.js b/blocks/CloudImageEditor/src/elements/slider/SliderUi.js index ec9e8b0f9..bab0180bc 100644 --- a/blocks/CloudImageEditor/src/elements/slider/SliderUi.js +++ b/blocks/CloudImageEditor/src/elements/slider/SliderUi.js @@ -2,7 +2,7 @@ import { Block } from '../../../../../abstract/Block.js'; export class SliderUi extends Block { init$ = { - ...this.ctxInit, + ...this.init$, disabled: false, min: 0, max: 100, diff --git a/blocks/CloudImageEditor/src/elements/slider/test.js b/blocks/CloudImageEditor/src/elements/slider/test.js index a0eccb0f7..eb03889ff 100644 --- a/blocks/CloudImageEditor/src/elements/slider/test.js +++ b/blocks/CloudImageEditor/src/elements/slider/test.js @@ -4,7 +4,7 @@ import { SliderUi } from './SliderUi.js'; class CtxProvider extends Block { init$ = { - ...this.ctxInit, + ...this.init$, min: 0, max: 100, defaultValue: 50, diff --git a/blocks/Color/Color.js b/blocks/Color/Color.js index 2543d6315..479d30d0e 100644 --- a/blocks/Color/Color.js +++ b/blocks/Color/Color.js @@ -2,7 +2,7 @@ import { Block } from '../../abstract/Block.js'; export class Color extends Block { init$ = { - ...this.ctxInit, + ...this.init$, inputOpacity: 0, '*selectedColor': '#f00', onChange: () => { diff --git a/blocks/ConfirmationDialog/ConfirmationDialog.js b/blocks/ConfirmationDialog/ConfirmationDialog.js index c74299dd0..8391f9028 100644 --- a/blocks/ConfirmationDialog/ConfirmationDialog.js +++ b/blocks/ConfirmationDialog/ConfirmationDialog.js @@ -20,7 +20,7 @@ export class ConfirmationDialog extends ActivityBlock { _defaults = new UiConfirmation(); init$ = { - ...this.ctxInit, + ...this.init$, activityCaption: '', messageTxt: '', confirmBtnTxt: '', diff --git a/blocks/Copyright/Copyright.js b/blocks/Copyright/Copyright.js index 8b195b6b4..285e2384e 100644 --- a/blocks/Copyright/Copyright.js +++ b/blocks/Copyright/Copyright.js @@ -7,7 +7,7 @@ export class Copyright extends Block { }; init$ = { - ...this.ctxInit, + ...this.init$, removeCopyright: false, }; diff --git a/blocks/DataOutput/DataOutput.js b/blocks/DataOutput/DataOutput.js index f35e23118..7699a5532 100644 --- a/blocks/DataOutput/DataOutput.js +++ b/blocks/DataOutput/DataOutput.js @@ -7,7 +7,7 @@ export class DataOutput extends UploaderBlock { processInnerHtml = true; init$ = { - ...this.ctxInit, + ...this.init$, output: null, filesData: null, }; diff --git a/blocks/DropArea/DropArea.js b/blocks/DropArea/DropArea.js index 3dfcfd644..6bac70ea2 100644 --- a/blocks/DropArea/DropArea.js +++ b/blocks/DropArea/DropArea.js @@ -7,7 +7,7 @@ import { stringToArray } from '../../utils/stringToArray.js'; export class DropArea extends UploaderBlock { init$ = { - ...this.ctxInit, + ...this.init$, state: DropzoneState.INACTIVE, withIcon: false, isClickable: false, @@ -78,7 +78,6 @@ export class DropArea extends UploaderBlock { }, /** @param {(File | String)[]} items */ onItems: (items) => { - debugger; if (!items.length) { return; } diff --git a/blocks/EditableCanvas/EditableCanvas.js b/blocks/EditableCanvas/EditableCanvas.js index 610aefc5b..d42b76ea5 100644 --- a/blocks/EditableCanvas/EditableCanvas.js +++ b/blocks/EditableCanvas/EditableCanvas.js @@ -14,7 +14,7 @@ import { checkerboardCssBg } from '../svg-backgrounds/svg-backgrounds.js'; export class EditableCanvas extends Block { init$ = { - ...this.ctxInit, + ...this.init$, refMap: null, disabled: true, toolbarHidden: true, diff --git a/blocks/EditableCanvas/EditableCanvasToolbar.js b/blocks/EditableCanvas/EditableCanvasToolbar.js index 8b89174d6..d39a0cb7a 100644 --- a/blocks/EditableCanvas/EditableCanvasToolbar.js +++ b/blocks/EditableCanvas/EditableCanvasToolbar.js @@ -78,7 +78,7 @@ export class EditorToolbar extends Block { } init$ = { - ...this.ctxInit, + ...this.init$, fsIcon: FS_ICON.FS, rangeActive: false, rangeCaption: '', diff --git a/blocks/ExternalSource/ExternalSource.js b/blocks/ExternalSource/ExternalSource.js index 49e648472..ce2b4382e 100644 --- a/blocks/ExternalSource/ExternalSource.js +++ b/blocks/ExternalSource/ExternalSource.js @@ -15,7 +15,7 @@ export class ExternalSource extends UploaderBlock { activityType = ActivityBlock.activities.EXTERNAL; init$ = { - ...this.ctxInit, + ...this.init$, activityIcon: '', activityCaption: '', counter: 0, diff --git a/blocks/FileItem/FileItem.js b/blocks/FileItem/FileItem.js index 7918ef7b2..51b071055 100644 --- a/blocks/FileItem/FileItem.js +++ b/blocks/FileItem/FileItem.js @@ -38,7 +38,7 @@ export class FileItem extends UploaderBlock { }; init$ = { - ...this.ctxInit, + ...this.init$, uid: '', itemName: '', errorText: '', diff --git a/blocks/FilePreview/FilePreview.js b/blocks/FilePreview/FilePreview.js index dbe4b899b..1bcfef193 100644 --- a/blocks/FilePreview/FilePreview.js +++ b/blocks/FilePreview/FilePreview.js @@ -4,7 +4,7 @@ import { TRANSPARENT_PIXEL_SRC } from '../../utils/transparentPixelSrc.js'; export class FilePreview extends Block { init$ = { - ...this.ctxInit, + ...this.init$, checkerboard: false, src: TRANSPARENT_PIXEL_SRC, }; diff --git a/blocks/Icon/Icon.js b/blocks/Icon/Icon.js index d164215e8..3c9ecccbf 100644 --- a/blocks/Icon/Icon.js +++ b/blocks/Icon/Icon.js @@ -2,7 +2,7 @@ import { Block } from '../../abstract/Block.js'; export class Icon extends Block { init$ = { - ...this.ctxInit, + ...this.init$, name: '', path: '', size: '24', diff --git a/blocks/LiveHtml/LiveHtml.js b/blocks/LiveHtml/LiveHtml.js index a38fa9e3f..6b0c52c70 100644 --- a/blocks/LiveHtml/LiveHtml.js +++ b/blocks/LiveHtml/LiveHtml.js @@ -155,7 +155,7 @@ export class LiveHtml extends Block { } init$ = { - ...this.ctxInit, + ...this.init$, src: '', code: INIT_HTML, spellcheck: false, diff --git a/blocks/MessageBox/MessageBox.js b/blocks/MessageBox/MessageBox.js index 1dbca7d9a..b901dad84 100644 --- a/blocks/MessageBox/MessageBox.js +++ b/blocks/MessageBox/MessageBox.js @@ -9,7 +9,7 @@ export class UiMessage { export class MessageBox extends Block { init$ = { - ...this.ctxInit, + ...this.init$, iconName: 'info', captionTxt: 'Message caption', msgTxt: 'Message...', diff --git a/blocks/Modal/Modal.js b/blocks/Modal/Modal.js index 6a0e921f5..02e109869 100644 --- a/blocks/Modal/Modal.js +++ b/blocks/Modal/Modal.js @@ -22,7 +22,7 @@ export class Modal extends Block { }; init$ = { - ...this.ctxInit, + ...this.init$, '*modalActive': false, isOpen: false, closeClicked: this._handleDialogClose, diff --git a/blocks/ProgressBar/ProgressBar.js b/blocks/ProgressBar/ProgressBar.js index ce353fb03..41a8b2646 100644 --- a/blocks/ProgressBar/ProgressBar.js +++ b/blocks/ProgressBar/ProgressBar.js @@ -7,7 +7,7 @@ export class ProgressBar extends Block { _unknownMode = false; init$ = { - ...this.ctxInit, + ...this.init$, width: 0, opacity: 0, }; diff --git a/blocks/ProgressBarCommon/ProgressBarCommon.js b/blocks/ProgressBarCommon/ProgressBarCommon.js index 286975f52..ceb2342f3 100644 --- a/blocks/ProgressBarCommon/ProgressBarCommon.js +++ b/blocks/ProgressBarCommon/ProgressBarCommon.js @@ -2,7 +2,7 @@ import { UploaderBlock } from '../../abstract/UploaderBlock.js'; export class ProgressBarCommon extends UploaderBlock { init$ = { - ...this.ctxInit, + ...this.init$, visible: false, unknown: false, value: 0, diff --git a/blocks/Select/Select.js b/blocks/Select/Select.js index 6193856a7..695de6509 100644 --- a/blocks/Select/Select.js +++ b/blocks/Select/Select.js @@ -2,7 +2,7 @@ import { Block } from '../../abstract/Block.js'; export class Select extends Block { init$ = { - ...this.ctxInit, + ...this.init$, currentText: '', options: [], selectHtml: '', diff --git a/blocks/SimpleBtn/SimpleBtn.js b/blocks/SimpleBtn/SimpleBtn.js index e87856e36..cee19efd1 100644 --- a/blocks/SimpleBtn/SimpleBtn.js +++ b/blocks/SimpleBtn/SimpleBtn.js @@ -2,7 +2,7 @@ import { UploaderBlock } from '../../abstract/UploaderBlock.js'; export class SimpleBtn extends UploaderBlock { init$ = { - ...this.ctxInit, + ...this.init$, '*simpleButtonText': '', onClick: () => { this.initFlow(); diff --git a/blocks/SourceBtn/SourceBtn.js b/blocks/SourceBtn/SourceBtn.js index 135a419cd..ccf1505d3 100644 --- a/blocks/SourceBtn/SourceBtn.js +++ b/blocks/SourceBtn/SourceBtn.js @@ -8,7 +8,7 @@ export class SourceBtn extends UploaderBlock { _registeredTypes = {}; init$ = { - ...this.ctxInit, + ...this.init$, iconName: 'default', }; diff --git a/blocks/UploadDetails/UploadDetails.js b/blocks/UploadDetails/UploadDetails.js index dfa8ae4ff..caf132ed0 100644 --- a/blocks/UploadDetails/UploadDetails.js +++ b/blocks/UploadDetails/UploadDetails.js @@ -10,7 +10,7 @@ export class UploadDetails extends UploaderBlock { pauseRender = true; init$ = { - ...this.ctxInit, + ...this.init$, checkerboard: false, fileSize: null, fileName: '', diff --git a/blocks/UploadList/UploadList.js b/blocks/UploadList/UploadList.js index 42ec2e603..fb56043c6 100644 --- a/blocks/UploadList/UploadList.js +++ b/blocks/UploadList/UploadList.js @@ -9,7 +9,7 @@ export class UploadList extends UploaderBlock { activityType = ActivityBlock.activities.UPLOAD_LIST; init$ = { - ...this.ctxInit, + ...this.init$, doneBtnVisible: false, doneBtnEnabled: false, uploadBtnVisible: false, diff --git a/blocks/UrlSource/UrlSource.js b/blocks/UrlSource/UrlSource.js index 1dccc457b..41ab8459a 100644 --- a/blocks/UrlSource/UrlSource.js +++ b/blocks/UrlSource/UrlSource.js @@ -5,7 +5,7 @@ export class UrlSource extends UploaderBlock { activityType = ActivityBlock.activities.URL; init$ = { - ...this.ctxInit, + ...this.init$, importDisabled: true, onUpload: () => { let url = this.ref.input['value']; diff --git a/blocks/Video/Video.js b/blocks/Video/Video.js index 5100a0ebc..93f9539a1 100644 --- a/blocks/Video/Video.js +++ b/blocks/Video/Video.js @@ -83,7 +83,7 @@ export class Video extends Block { } init$ = { - ...this.ctxInit, + ...this.init$, src: '', ppIcon: ICO_MAP.PLAY, fsIcon: ICO_MAP.FS_ON, diff --git a/solutions/file-uploader/minimal/FileUploaderMinimal.js b/solutions/file-uploader/minimal/FileUploaderMinimal.js index b7d997a4b..c51dbf994 100644 --- a/solutions/file-uploader/minimal/FileUploaderMinimal.js +++ b/solutions/file-uploader/minimal/FileUploaderMinimal.js @@ -5,7 +5,7 @@ export class FileUploaderMinimal extends SolutionBlock { pauseRender = true; init$ = { - ...this.ctxInit, + ...this.init$, selectClicked: () => { this.ref.uBlock.openSystemDialog(); },