angular-intlayer 8.1.2 → 8.1.3
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/cjs/UI/ContentSelector.component.cjs +2 -116
- package/dist/cjs/UI/ContentSelector.component.cjs.map +1 -1
- package/dist/cjs/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.cjs +1 -11
- package/dist/cjs/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.cjs +1 -8
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -29
- package/dist/cjs/client/index.cjs +1 -28
- package/dist/cjs/client/installIntlayer.cjs +1 -77
- package/dist/cjs/client/installIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useDictionary.cjs +1 -15
- package/dist/cjs/client/useDictionary.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryAsync.cjs +1 -24
- package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +1 -25
- package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
- package/dist/cjs/client/useIntl.cjs +1 -40
- package/dist/cjs/client/useIntl.cjs.map +1 -1
- package/dist/cjs/client/useIntlayer.cjs +1 -44
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useLoadDynamic.cjs +1 -28
- package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
- package/dist/cjs/client/useLocale.cjs +1 -60
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/client/useLocaleStorage.cjs +1 -60
- package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
- package/dist/cjs/editor/ContentSelectorWrapper.component.cjs +2 -51
- package/dist/cjs/editor/ContentSelectorWrapper.component.cjs.map +1 -1
- package/dist/cjs/editor/EditedContentRenderer.component.cjs +1 -54
- package/dist/cjs/editor/EditedContentRenderer.component.cjs.map +1 -1
- package/dist/cjs/editor/EditorSelectorRenderer.component.cjs +2 -35
- package/dist/cjs/editor/EditorSelectorRenderer.component.cjs.map +1 -1
- package/dist/cjs/editor/communicator.cjs +1 -63
- package/dist/cjs/editor/communicator.cjs.map +1 -1
- package/dist/cjs/editor/configuration.cjs +1 -22
- package/dist/cjs/editor/configuration.cjs.map +1 -1
- package/dist/cjs/editor/createSharedComposable.cjs +1 -50
- package/dist/cjs/editor/createSharedComposable.cjs.map +1 -1
- package/dist/cjs/editor/dictionariesRecord.cjs +1 -49
- package/dist/cjs/editor/dictionariesRecord.cjs.map +1 -1
- package/dist/cjs/editor/editedContent.cjs +1 -61
- package/dist/cjs/editor/editedContent.cjs.map +1 -1
- package/dist/cjs/editor/editorEnabled.cjs +1 -49
- package/dist/cjs/editor/editorEnabled.cjs.map +1 -1
- package/dist/cjs/editor/editorLocale.cjs +1 -21
- package/dist/cjs/editor/editorLocale.cjs.map +1 -1
- package/dist/cjs/editor/focusDictionary.cjs +1 -62
- package/dist/cjs/editor/focusDictionary.cjs.map +1 -1
- package/dist/cjs/editor/index.cjs +1 -25
- package/dist/cjs/editor/installIntlayerEditor.cjs +1 -52
- package/dist/cjs/editor/installIntlayerEditor.cjs.map +1 -1
- package/dist/cjs/editor/useCrossFrameMessageListener.cjs +1 -73
- package/dist/cjs/editor/useCrossFrameMessageListener.cjs.map +1 -1
- package/dist/cjs/editor/useCrossFrameState.cjs +1 -114
- package/dist/cjs/editor/useCrossFrameState.cjs.map +1 -1
- package/dist/cjs/editor/useCrossURLPathState.cjs +1 -65
- package/dist/cjs/editor/useCrossURLPathState.cjs.map +1 -1
- package/dist/cjs/editor/useEditedContentRenderer.cjs +1 -35
- package/dist/cjs/editor/useEditedContentRenderer.cjs.map +1 -1
- package/dist/cjs/editor/useEditor.cjs +1 -24
- package/dist/cjs/editor/useEditor.cjs.map +1 -1
- package/dist/cjs/editor/useIframeClickInterceptor.cjs +1 -39
- package/dist/cjs/editor/useIframeClickInterceptor.cjs.map +1 -1
- package/dist/cjs/getDictionary.cjs +1 -17
- package/dist/cjs/getDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayer.cjs +1 -18
- package/dist/cjs/getIntlayer.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -49
- package/dist/cjs/markdown/index.cjs +1 -13
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs +1 -79
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs.map +1 -1
- package/dist/cjs/plugins.cjs +1 -188
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/cjs/renderIntlayerNode.cjs +1 -28
- package/dist/cjs/renderIntlayerNode.cjs.map +1 -1
- package/dist/cjs/webpack/index.cjs +1 -4
- package/dist/cjs/webpack/mergeConfig.cjs +1 -44
- package/dist/cjs/webpack/mergeConfig.cjs.map +1 -1
- package/dist/esm/UI/ContentSelector.component.mjs +2 -109
- package/dist/esm/UI/ContentSelector.component.mjs.map +1 -1
- package/dist/esm/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs +1 -10
- package/dist/esm/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs +1 -7
- package/dist/esm/client/index.mjs +1 -10
- package/dist/esm/client/installIntlayer.mjs +1 -65
- package/dist/esm/client/installIntlayer.mjs.map +1 -1
- package/dist/esm/client/useDictionary.mjs +1 -13
- package/dist/esm/client/useDictionary.mjs.map +1 -1
- package/dist/esm/client/useDictionaryAsync.mjs +1 -21
- package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
- package/dist/esm/client/useDictionaryDynamic.mjs +1 -22
- package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
- package/dist/esm/client/useIntl.mjs +1 -38
- package/dist/esm/client/useIntl.mjs.map +1 -1
- package/dist/esm/client/useIntlayer.mjs +1 -41
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/client/useLoadDynamic.mjs +1 -26
- package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
- package/dist/esm/client/useLocale.mjs +1 -57
- package/dist/esm/client/useLocale.mjs.map +1 -1
- package/dist/esm/client/useLocaleStorage.mjs +1 -53
- package/dist/esm/client/useLocaleStorage.mjs.map +1 -1
- package/dist/esm/editor/ContentSelectorWrapper.component.mjs +2 -44
- package/dist/esm/editor/ContentSelectorWrapper.component.mjs.map +1 -1
- package/dist/esm/editor/EditedContentRenderer.component.mjs +1 -47
- package/dist/esm/editor/EditedContentRenderer.component.mjs.map +1 -1
- package/dist/esm/editor/EditorSelectorRenderer.component.mjs +2 -28
- package/dist/esm/editor/EditorSelectorRenderer.component.mjs.map +1 -1
- package/dist/esm/editor/communicator.mjs +1 -58
- package/dist/esm/editor/communicator.mjs.map +1 -1
- package/dist/esm/editor/configuration.mjs +1 -19
- package/dist/esm/editor/configuration.mjs.map +1 -1
- package/dist/esm/editor/createSharedComposable.mjs +1 -47
- package/dist/esm/editor/createSharedComposable.mjs.map +1 -1
- package/dist/esm/editor/dictionariesRecord.mjs +1 -45
- package/dist/esm/editor/dictionariesRecord.mjs.map +1 -1
- package/dist/esm/editor/editedContent.mjs +1 -57
- package/dist/esm/editor/editedContent.mjs.map +1 -1
- package/dist/esm/editor/editorEnabled.mjs +1 -45
- package/dist/esm/editor/editorEnabled.mjs.map +1 -1
- package/dist/esm/editor/editorLocale.mjs +1 -19
- package/dist/esm/editor/editorLocale.mjs.map +1 -1
- package/dist/esm/editor/focusDictionary.mjs +1 -58
- package/dist/esm/editor/focusDictionary.mjs.map +1 -1
- package/dist/esm/editor/index.mjs +1 -6
- package/dist/esm/editor/installIntlayerEditor.mjs +1 -49
- package/dist/esm/editor/installIntlayerEditor.mjs.map +1 -1
- package/dist/esm/editor/useCrossFrameMessageListener.mjs +1 -71
- package/dist/esm/editor/useCrossFrameMessageListener.mjs.map +1 -1
- package/dist/esm/editor/useCrossFrameState.mjs +1 -112
- package/dist/esm/editor/useCrossFrameState.mjs.map +1 -1
- package/dist/esm/editor/useCrossURLPathState.mjs +1 -62
- package/dist/esm/editor/useCrossURLPathState.mjs.map +1 -1
- package/dist/esm/editor/useEditedContentRenderer.mjs +1 -26
- package/dist/esm/editor/useEditedContentRenderer.mjs.map +1 -1
- package/dist/esm/editor/useEditor.mjs +1 -23
- package/dist/esm/editor/useEditor.mjs.map +1 -1
- package/dist/esm/editor/useIframeClickInterceptor.mjs +1 -36
- package/dist/esm/editor/useIframeClickInterceptor.mjs.map +1 -1
- package/dist/esm/getDictionary.mjs +1 -15
- package/dist/esm/getDictionary.mjs.map +1 -1
- package/dist/esm/getIntlayer.mjs +1 -16
- package/dist/esm/getIntlayer.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -14
- package/dist/esm/markdown/index.mjs +1 -3
- package/dist/esm/markdown/installIntlayerMarkdown.mjs +1 -68
- package/dist/esm/markdown/installIntlayerMarkdown.mjs.map +1 -1
- package/dist/esm/plugins.mjs +1 -182
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/esm/renderIntlayerNode.mjs +1 -26
- package/dist/esm/renderIntlayerNode.mjs.map +1 -1
- package/dist/esm/webpack/index.mjs +1 -3
- package/dist/esm/webpack/mergeConfig.mjs +1 -42
- package/dist/esm/webpack/mergeConfig.mjs.map +1 -1
- package/dist/types/client/useDictionaryDynamic.d.ts +2 -2
- package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
- package/dist/types/editor/ContentSelectorWrapper.component.d.ts +1 -1
- package/dist/types/editor/ContentSelectorWrapper.component.d.ts.map +1 -1
- package/dist/types/editor/EditorSelectorRenderer.component.d.ts +1 -1
- package/dist/types/getDictionary.d.ts +3 -3
- package/dist/types/getDictionary.d.ts.map +1 -1
- package/dist/types/getIntlayer.d.ts +1 -1
- package/dist/types/getIntlayer.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/markdown/installIntlayerMarkdown.d.ts +1 -1
- package/dist/types/markdown/installIntlayerMarkdown.d.ts.map +1 -1
- package/dist/types/plugins.d.ts +1 -1
- package/dist/types/plugins.d.ts.map +1 -1
- package/dist/types/webpack/mergeConfig.d.ts.map +1 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditedContentRenderer.component.mjs","names":[],"sources":["../../../src/editor/EditedContentRenderer.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, computed, Input, signal } from '@angular/core';\nimport { getContent } from '@intlayer/core';\nimport type { ContentNode, KeyPath, Locale } from '@intlayer/types';\nimport { useEditedContentRenderer } from './useEditedContentRenderer';\n\nexport interface EditedContentRendererProps {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: Locale;\n}\n\n@Component({\n selector: 'app-edited-content-renderer',\n standalone: true,\n imports: [CommonModule],\n template: ` <span [innerHTML]=\"renderedContent()\"></span> `,\n})\nexport class EditedContentRendererComponent {\n @Input() dictionaryKey!: string;\n @Input() keyPath!: KeyPath[];\n @Input() locale?: Locale;\n\n private fallback = signal('');\n\n private rawContent = computed(() => {\n return useEditedContentRenderer(\n this.dictionaryKey,\n this.keyPath,\n this.fallback\n );\n });\n\n /**\n * Object → getContent → string, same as the React version.\n */\n renderedContent = computed(() => {\n const rawContentValue = this.rawContent();\n\n if (typeof rawContentValue === 'object' && rawContentValue !== null) {\n const transformed = getContent(\n rawContentValue as ContentNode,\n {\n dictionaryKey: this.dictionaryKey,\n keyPath: this.keyPath,\n },\n this.locale\n );\n\n if (typeof transformed !== 'string') {\n console.error(\n `Incorrect edited content format. Content type: ${typeof transformed}. Expected string. Value ${JSON.stringify(\n transformed\n )}`\n );\n return this.fallback();\n }\n return transformed;\n }\n\n return rawContentValue() as string;\n });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EditedContentRenderer.component.mjs","names":[],"sources":["../../../src/editor/EditedContentRenderer.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, computed, Input, signal } from '@angular/core';\nimport { getContent } from '@intlayer/core/interpreter';\nimport type { ContentNode, KeyPath, Locale } from '@intlayer/types';\nimport { useEditedContentRenderer } from './useEditedContentRenderer';\n\nexport interface EditedContentRendererProps {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: Locale;\n}\n\n@Component({\n selector: 'app-edited-content-renderer',\n standalone: true,\n imports: [CommonModule],\n template: ` <span [innerHTML]=\"renderedContent()\"></span> `,\n})\nexport class EditedContentRendererComponent {\n @Input() dictionaryKey!: string;\n @Input() keyPath!: KeyPath[];\n @Input() locale?: Locale;\n\n private fallback = signal('');\n\n private rawContent = computed(() => {\n return useEditedContentRenderer(\n this.dictionaryKey,\n this.keyPath,\n this.fallback\n );\n });\n\n /**\n * Object → getContent → string, same as the React version.\n */\n renderedContent = computed(() => {\n const rawContentValue = this.rawContent();\n\n if (typeof rawContentValue === 'object' && rawContentValue !== null) {\n const transformed = getContent(\n rawContentValue as ContentNode,\n {\n dictionaryKey: this.dictionaryKey,\n keyPath: this.keyPath,\n },\n this.locale\n );\n\n if (typeof transformed !== 'string') {\n console.error(\n `Incorrect edited content format. Content type: ${typeof transformed}. Expected string. Value ${JSON.stringify(\n transformed\n )}`\n );\n return this.fallback();\n }\n return transformed;\n }\n\n return rawContentValue() as string;\n });\n}\n"],"mappings":"wcAkBO,IAAA,EAAA,KAAqC,CAC1C,cACA,QACA,OAEA,SAAmB,EAAO,GAAG,CAE7B,WAAqB,MACZ,EACL,KAAK,cACL,KAAK,QACL,KAAK,SACN,CACD,CAKF,gBAAkB,MAAe,CAC/B,IAAM,EAAkB,KAAK,YAAY,CAEzC,GAAI,OAAO,GAAoB,UAAY,EAA0B,CACnE,IAAM,EAAc,EAClB,EACA,CACE,cAAe,KAAK,cACpB,QAAS,KAAK,QACf,CACD,KAAK,OACN,CAUD,OARI,OAAO,GAAgB,SAQpB,GAPL,QAAQ,MACN,kDAAkD,OAAO,EAAY,2BAA2B,KAAK,UACnG,EACD,GACF,CACM,KAAK,UAAU,EAK1B,OAAO,GAAiB,EACxB,KA1CD,GAAO,CAAA,EAAA,cAAA,OAAA,CAAA,CAAA,EAAA,UAAA,gBAAA,IAAA,GAAA,IACP,GAAO,CAAA,EAAA,cAAA,MAAA,CAAA,CAAA,EAAA,UAAA,UAAA,IAAA,GAAA,IACP,GAAO,CAAA,EAAA,cAAA,OAAA,CAAA,CAAA,EAAA,UAAA,SAAA,IAAA,GAAA,MATT,EAAU,CACT,SAAU,8BACV,WAAY,GACZ,QAAS,CAAC,EAAa,CACvB,SAAU,kDACX,CAAC,CAAA,CAAA,EAAA"}
|
|
@@ -1,26 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";
|
|
3
|
-
import { ContentSelectorWrapperComponent } from "./ContentSelectorWrapper.component.mjs";
|
|
4
|
-
import { EditedContentRendererComponent } from "./EditedContentRenderer.component.mjs";
|
|
5
|
-
import { CommonModule } from "@angular/common";
|
|
6
|
-
import { Component, Input } from "@angular/core";
|
|
7
|
-
|
|
8
|
-
//#region src/editor/EditorSelectorRenderer.component.ts
|
|
9
|
-
let EditorSelectorRendererComponent = class EditorSelectorRendererComponent {
|
|
10
|
-
dictionaryKey;
|
|
11
|
-
keyPath;
|
|
12
|
-
};
|
|
13
|
-
__decorate([Input(), __decorateMetadata("design:type", String)], EditorSelectorRendererComponent.prototype, "dictionaryKey", void 0);
|
|
14
|
-
__decorate([Input(), __decorateMetadata("design:type", Array)], EditorSelectorRendererComponent.prototype, "keyPath", void 0);
|
|
15
|
-
EditorSelectorRendererComponent = __decorate([Component({
|
|
16
|
-
selector: "app-editor-selector-renderer",
|
|
17
|
-
standalone: true,
|
|
18
|
-
imports: [
|
|
19
|
-
CommonModule,
|
|
20
|
-
ContentSelectorWrapperComponent,
|
|
21
|
-
EditedContentRendererComponent
|
|
22
|
-
],
|
|
23
|
-
template: `
|
|
1
|
+
import{__decorateMetadata as e}from"../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs";import{__decorate as t}from"../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";import{ContentSelectorWrapperComponent as n}from"./ContentSelectorWrapper.component.mjs";import{EditedContentRendererComponent as r}from"./EditedContentRenderer.component.mjs";import{CommonModule as i}from"@angular/common";import{Component as a,Input as o}from"@angular/core";let s=class{dictionaryKey;keyPath};t([o(),e(`design:type`,String)],s.prototype,`dictionaryKey`,void 0),t([o(),e(`design:type`,Array)],s.prototype,`keyPath`,void 0),s=t([a({selector:`app-editor-selector-renderer`,standalone:!0,imports:[i,n,r],template:`
|
|
24
2
|
<app-content-selector-wrapper
|
|
25
3
|
[dictionaryKey]="dictionaryKey"
|
|
26
4
|
[keyPath]="keyPath"
|
|
@@ -32,9 +10,5 @@ EditorSelectorRendererComponent = __decorate([Component({
|
|
|
32
10
|
<ng-content></ng-content>
|
|
33
11
|
</app-edited-content-renderer>
|
|
34
12
|
</app-content-selector-wrapper>
|
|
35
|
-
`
|
|
36
|
-
})], EditorSelectorRendererComponent);
|
|
37
|
-
|
|
38
|
-
//#endregion
|
|
39
|
-
export { EditorSelectorRendererComponent };
|
|
13
|
+
`})],s);export{s as EditorSelectorRendererComponent};
|
|
40
14
|
//# sourceMappingURL=EditorSelectorRenderer.component.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorSelectorRenderer.component.mjs","names":[],"sources":["../../../src/editor/EditorSelectorRenderer.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, Input } from '@angular/core';\nimport type { NodeProps } from '@intlayer/core';\nimport { ContentSelectorWrapperComponent } from './ContentSelectorWrapper.component';\nimport { EditedContentRendererComponent } from './EditedContentRenderer.component';\n\n/**\n * Combine your NodeProps (which include dictionaryKey & keyPath)\n * with any other div-like attributes.\n */\nexport interface EditorSelectorRendererProps extends NodeProps {\n [key: string]: any;\n}\n\n@Component({\n selector: 'app-editor-selector-renderer',\n standalone: true,\n imports: [\n CommonModule,\n ContentSelectorWrapperComponent,\n EditedContentRendererComponent,\n ],\n template: `\n <app-content-selector-wrapper\n [dictionaryKey]=\"dictionaryKey\"\n [keyPath]=\"keyPath\"\n >\n <app-edited-content-renderer\n [dictionaryKey]=\"dictionaryKey\"\n [keyPath]=\"keyPath\"\n >\n <ng-content></ng-content>\n </app-edited-content-renderer>\n </app-content-selector-wrapper>\n `,\n})\nexport class EditorSelectorRendererComponent {\n @Input() dictionaryKey!: string;\n @Input() keyPath!: any[];\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EditorSelectorRenderer.component.mjs","names":[],"sources":["../../../src/editor/EditorSelectorRenderer.component.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, Input } from '@angular/core';\nimport type { NodeProps } from '@intlayer/core/interpreter';\nimport { ContentSelectorWrapperComponent } from './ContentSelectorWrapper.component';\nimport { EditedContentRendererComponent } from './EditedContentRenderer.component';\n\n/**\n * Combine your NodeProps (which include dictionaryKey & keyPath)\n * with any other div-like attributes.\n */\nexport interface EditorSelectorRendererProps extends NodeProps {\n [key: string]: any;\n}\n\n@Component({\n selector: 'app-editor-selector-renderer',\n standalone: true,\n imports: [\n CommonModule,\n ContentSelectorWrapperComponent,\n EditedContentRendererComponent,\n ],\n template: `\n <app-content-selector-wrapper\n [dictionaryKey]=\"dictionaryKey\"\n [keyPath]=\"keyPath\"\n >\n <app-edited-content-renderer\n [dictionaryKey]=\"dictionaryKey\"\n [keyPath]=\"keyPath\"\n >\n <ng-content></ng-content>\n </app-edited-content-renderer>\n </app-content-selector-wrapper>\n `,\n})\nexport class EditorSelectorRendererComponent {\n @Input() dictionaryKey!: string;\n @Input() keyPath!: any[];\n}\n"],"mappings":"4dAoCO,IAAA,EAAA,KAAsC,CAC3C,cACA,YADC,GAAO,CAAA,EAAA,cAAA,OAAA,CAAA,CAAA,EAAA,UAAA,gBAAA,IAAA,GAAA,IACP,GAAO,CAAA,EAAA,cAAA,MAAA,CAAA,CAAA,EAAA,UAAA,UAAA,IAAA,GAAA,MAxBT,EAAU,CACT,SAAU,+BACV,WAAY,GACZ,QAAS,CACP,EACA,EACA,EACD,CACD,SAAU;;;;;;;;;;;;IAaX,CAAC,CAAA,CAAA,EAAA"}
|
|
@@ -1,59 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
//#region src/editor/communicator.ts
|
|
4
|
-
const randomUUID = () => Math.random().toString(36).slice(2);
|
|
5
|
-
const { editor } = configuration;
|
|
6
|
-
/**
|
|
7
|
-
* Default values for the communicator
|
|
8
|
-
*/
|
|
9
|
-
const defaultValue = {
|
|
10
|
-
postMessage: () => null,
|
|
11
|
-
allowedOrigins: [
|
|
12
|
-
editor?.applicationURL,
|
|
13
|
-
editor?.editorURL,
|
|
14
|
-
editor?.cmsURL
|
|
15
|
-
],
|
|
16
|
-
senderId: ""
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Singleton instance
|
|
20
|
-
*/
|
|
21
|
-
let instance = null;
|
|
22
|
-
/**
|
|
23
|
-
* Creates a communicator client
|
|
24
|
-
* @param options - Options for configuring the communicator
|
|
25
|
-
*/
|
|
26
|
-
const createCommunicator = (options = { postMessage: () => null }) => {
|
|
27
|
-
if (instance) return instance;
|
|
28
|
-
instance = {
|
|
29
|
-
...defaultValue,
|
|
30
|
-
...options,
|
|
31
|
-
senderId: randomUUID()
|
|
32
|
-
};
|
|
33
|
-
return instance;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Helper to install the Intlayer communicator into the injector
|
|
37
|
-
*/
|
|
38
|
-
const installCommunicator = (_injector, options = { postMessage: () => null }) => {
|
|
39
|
-
createCommunicator(options);
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Hook to access the communicator
|
|
43
|
-
* @returns The communicator instance
|
|
44
|
-
*/
|
|
45
|
-
const useCommunicator = () => {
|
|
46
|
-
try {
|
|
47
|
-
return createCommunicator() || defaultValue;
|
|
48
|
-
} catch (_error) {
|
|
49
|
-
console.warn("useCommunicator: Error accessing communicator. Returning default communicator.");
|
|
50
|
-
return {
|
|
51
|
-
postMessage: () => null,
|
|
52
|
-
senderId: ""
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
//#endregion
|
|
58
|
-
export { createCommunicator, installCommunicator, useCommunicator };
|
|
1
|
+
import e from"@intlayer/config/built";const t=()=>Math.random().toString(36).slice(2),{editor:n}=e,r={postMessage:()=>null,allowedOrigins:[n?.applicationURL,n?.editorURL,n?.cmsURL],senderId:``};let i=null;const a=(e={postMessage:()=>null})=>i||(i={...r,...e,senderId:t()},i),o=(e,t={postMessage:()=>null})=>{a(t)},s=()=>{try{return a()||r}catch{return console.warn(`useCommunicator: Error accessing communicator. Returning default communicator.`),{postMessage:()=>null,senderId:``}}};export{a as createCommunicator,o as installCommunicator,s as useCommunicator};
|
|
59
2
|
//# sourceMappingURL=communicator.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"communicator.mjs","names":[],"sources":["../../../src/editor/communicator.ts"],"sourcesContent":["import type { Injector } from '@angular/core';\nimport configuration from '@intlayer/config/built';\n\nconst randomUUID = () => Math.random().toString(36).slice(2);\n\n/**\n * Interface defining a cross-frame communicator\n */\nexport type Communicator = {\n postMessage: typeof window.postMessage;\n allowedOrigins?: string[];\n senderId: string;\n};\n\n/**\n * Configuration options for the communicator\n */\nexport type CommunicatorOptions = Omit<Communicator, 'senderId'>;\n\nconst { editor } = configuration;\n\n/**\n * Default values for the communicator\n */\nconst defaultValue: Communicator = {\n postMessage: () => null,\n allowedOrigins: [\n editor?.applicationURL,\n editor?.editorURL,\n editor?.cmsURL,\n ] as string[],\n senderId: '',\n};\n\n/**\n * Singleton instance\n */\nlet instance: Communicator | null = null;\n\nconst _INTLAYER_COMMUNICATOR_SYMBOL = Symbol('Communicator');\n\n/**\n * Creates a communicator client\n * @param options - Options for configuring the communicator\n */\nexport const createCommunicator = (\n options: CommunicatorOptions = { postMessage: () => null }\n) => {\n if (instance) return instance;\n\n instance = {\n ...defaultValue,\n ...options,\n senderId: randomUUID(),\n };\n\n return instance;\n};\n\n/**\n * Helper to install the Intlayer communicator into the injector\n */\nexport const installCommunicator = (\n _injector: Injector,\n options: CommunicatorOptions = { postMessage: () => null }\n) => {\n const _client = createCommunicator(options);\n\n // Angular doesn't have a direct equivalent to Vue's app.provide\n // The client is stored as a singleton and accessed via createCommunicator\n};\n\n/**\n * Hook to access the communicator\n * @returns The communicator instance\n */\nexport const useCommunicator = (): Communicator => {\n try {\n const communicator = createCommunicator();\n return communicator || defaultValue;\n } catch (_error) {\n console.warn(\n 'useCommunicator: Error accessing communicator. Returning default communicator.'\n );\n return {\n postMessage: () => null,\n senderId: '',\n };\n }\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"communicator.mjs","names":[],"sources":["../../../src/editor/communicator.ts"],"sourcesContent":["import type { Injector } from '@angular/core';\nimport configuration from '@intlayer/config/built';\n\nconst randomUUID = () => Math.random().toString(36).slice(2);\n\n/**\n * Interface defining a cross-frame communicator\n */\nexport type Communicator = {\n postMessage: typeof window.postMessage;\n allowedOrigins?: string[];\n senderId: string;\n};\n\n/**\n * Configuration options for the communicator\n */\nexport type CommunicatorOptions = Omit<Communicator, 'senderId'>;\n\nconst { editor } = configuration;\n\n/**\n * Default values for the communicator\n */\nconst defaultValue: Communicator = {\n postMessage: () => null,\n allowedOrigins: [\n editor?.applicationURL,\n editor?.editorURL,\n editor?.cmsURL,\n ] as string[],\n senderId: '',\n};\n\n/**\n * Singleton instance\n */\nlet instance: Communicator | null = null;\n\nconst _INTLAYER_COMMUNICATOR_SYMBOL = Symbol('Communicator');\n\n/**\n * Creates a communicator client\n * @param options - Options for configuring the communicator\n */\nexport const createCommunicator = (\n options: CommunicatorOptions = { postMessage: () => null }\n) => {\n if (instance) return instance;\n\n instance = {\n ...defaultValue,\n ...options,\n senderId: randomUUID(),\n };\n\n return instance;\n};\n\n/**\n * Helper to install the Intlayer communicator into the injector\n */\nexport const installCommunicator = (\n _injector: Injector,\n options: CommunicatorOptions = { postMessage: () => null }\n) => {\n const _client = createCommunicator(options);\n\n // Angular doesn't have a direct equivalent to Vue's app.provide\n // The client is stored as a singleton and accessed via createCommunicator\n};\n\n/**\n * Hook to access the communicator\n * @returns The communicator instance\n */\nexport const useCommunicator = (): Communicator => {\n try {\n const communicator = createCommunicator();\n return communicator || defaultValue;\n } catch (_error) {\n console.warn(\n 'useCommunicator: Error accessing communicator. Returning default communicator.'\n );\n return {\n postMessage: () => null,\n senderId: '',\n };\n }\n};\n"],"mappings":"sCAGA,MAAM,MAAmB,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE,CAgBtD,CAAE,UAAW,EAKb,EAA6B,CACjC,gBAAmB,KACnB,eAAgB,CACd,GAAQ,eACR,GAAQ,UACR,GAAQ,OACT,CACD,SAAU,GACX,CAKD,IAAI,EAAgC,KAQpC,MAAa,GACX,EAA+B,CAAE,gBAAmB,KAAM,GAEtD,IAEJ,EAAW,CACT,GAAG,EACH,GAAG,EACH,SAAU,GAAY,CACvB,CAEM,GAMI,GACX,EACA,EAA+B,CAAE,gBAAmB,KAAM,GACvD,CACa,EAAmB,EAAQ,EAUhC,MAAsC,CACjD,GAAI,CAEF,OADqB,GAAoB,EAClB,OACR,CAIf,OAHA,QAAQ,KACN,iFACD,CACM,CACL,gBAAmB,KACnB,SAAU,GACX"}
|
|
@@ -1,20 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { DestroyRef, inject } from "@angular/core";
|
|
3
|
-
import { MessageKey } from "@intlayer/editor";
|
|
4
|
-
import configuration from "@intlayer/config/built";
|
|
5
|
-
|
|
6
|
-
//#region src/editor/configuration.ts
|
|
7
|
-
const useConfiguration = () => {
|
|
8
|
-
const [pushedConfiguration, setConfiguration] = useCrossFrameState(MessageKey.INTLAYER_CONFIGURATION);
|
|
9
|
-
try {
|
|
10
|
-
if (inject(DestroyRef, { optional: true })) {
|
|
11
|
-
if (!pushedConfiguration()) setConfiguration(configuration);
|
|
12
|
-
}
|
|
13
|
-
} catch {
|
|
14
|
-
console.warn("useConfiguration called outside injection context; configuration may not be synchronized.");
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
export { useConfiguration };
|
|
1
|
+
import{useCrossFrameState as e}from"./useCrossFrameState.mjs";import{DestroyRef as t,inject as n}from"@angular/core";import{MessageKey as r}from"@intlayer/editor";import i from"@intlayer/config/built";const a=()=>{let[a,o]=e(r.INTLAYER_CONFIGURATION);try{n(t,{optional:!0})&&(a()||o(i))}catch{console.warn(`useConfiguration called outside injection context; configuration may not be synchronized.`)}};export{a as useConfiguration};
|
|
20
2
|
//# sourceMappingURL=configuration.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.mjs","names":[],"sources":["../../../src/editor/configuration.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport { MessageKey } from '@intlayer/editor';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport const useConfiguration = () => {\n const [pushedConfiguration, setConfiguration] =\n useCrossFrameState<IntlayerConfig>(MessageKey.INTLAYER_CONFIGURATION);\n\n // Use Angular's injection context instead of Vue's onMounted\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n\n if (destroyRef) {\n // Execute immediately since Angular doesn't have the same lifecycle hooks\n if (!pushedConfiguration()) {\n setConfiguration(configuration);\n }\n }\n } catch {\n console.warn(\n 'useConfiguration called outside injection context; ' +\n 'configuration may not be synchronized.'\n );\n }\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"configuration.mjs","names":[],"sources":["../../../src/editor/configuration.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport { MessageKey } from '@intlayer/editor';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport const useConfiguration = () => {\n const [pushedConfiguration, setConfiguration] =\n useCrossFrameState<IntlayerConfig>(MessageKey.INTLAYER_CONFIGURATION);\n\n // Use Angular's injection context instead of Vue's onMounted\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n\n if (destroyRef) {\n // Execute immediately since Angular doesn't have the same lifecycle hooks\n if (!pushedConfiguration()) {\n setConfiguration(configuration);\n }\n }\n } catch {\n console.warn(\n 'useConfiguration called outside injection context; ' +\n 'configuration may not be synchronized.'\n );\n }\n};\n"],"mappings":"yMAMA,MAAa,MAAyB,CACpC,GAAM,CAAC,EAAqB,GAC1B,EAAmC,EAAW,uBAAuB,CAGvE,GAAI,CACiB,EAAO,EAAY,CAAE,SAAU,GAAM,CAAC,GAIlD,GAAqB,EACxB,EAAiB,EAAc,OAG7B,CACN,QAAQ,KACN,4FAED"}
|
|
@@ -1,48 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
//#region src/editor/createSharedComposable.ts
|
|
4
|
-
/**
|
|
5
|
-
* Angular replacement for Vue's tryOnScopeDispose
|
|
6
|
-
* Uses Angular's DestroyRef to handle cleanup when the injection context is destroyed
|
|
7
|
-
*/
|
|
8
|
-
function tryOnScopeDispose(fn) {
|
|
9
|
-
try {
|
|
10
|
-
const destroyRef = inject(DestroyRef, { optional: true });
|
|
11
|
-
if (destroyRef) {
|
|
12
|
-
destroyRef.onDestroy(fn);
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
return false;
|
|
16
|
-
} catch {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Angular equivalent of Vue's createSharedComposable
|
|
22
|
-
* Creates a singleton pattern for services/composables
|
|
23
|
-
*/
|
|
24
|
-
const createSharedComposable = (composable) => {
|
|
25
|
-
let subscribers = 0;
|
|
26
|
-
let state;
|
|
27
|
-
let cleanupFn;
|
|
28
|
-
const dispose = () => {
|
|
29
|
-
subscribers -= 1;
|
|
30
|
-
if (cleanupFn && subscribers <= 0) {
|
|
31
|
-
cleanupFn();
|
|
32
|
-
state = void 0;
|
|
33
|
-
cleanupFn = void 0;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
return ((...args) => {
|
|
37
|
-
subscribers += 1;
|
|
38
|
-
if (!state) {
|
|
39
|
-
state = composable(...args);
|
|
40
|
-
if (tryOnScopeDispose(dispose)) cleanupFn = dispose;
|
|
41
|
-
} else tryOnScopeDispose(dispose);
|
|
42
|
-
return state;
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
//#endregion
|
|
47
|
-
export { createSharedComposable, tryOnScopeDispose };
|
|
1
|
+
import{DestroyRef as e,inject as t}from"@angular/core";function n(n){try{let r=t(e,{optional:!0});return r?(r.onDestroy(n),!0):!1}catch{return!1}}const r=e=>{let t=0,r,i,a=()=>{--t,i&&t<=0&&(i(),r=void 0,i=void 0)};return((...o)=>(t+=1,r?n(a):(r=e(...o),n(a)&&(i=a)),r))};export{r as createSharedComposable,n as tryOnScopeDispose};
|
|
48
2
|
//# sourceMappingURL=createSharedComposable.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSharedComposable.mjs","names":[],"sources":["../../../src/editor/createSharedComposable.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core';\n\ntype AnyFn = (...args: any[]) => any;\n\nexport type SharedComposableReturn<T extends AnyFn = AnyFn> = T;\n\n/**\n * Angular replacement for Vue's tryOnScopeDispose\n * Uses Angular's DestroyRef to handle cleanup when the injection context is destroyed\n */\nexport function tryOnScopeDispose(fn: () => void) {\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n if (destroyRef) {\n destroyRef.onDestroy(fn);\n return true;\n }\n return false;\n } catch {\n // If called outside injection context, return false\n return false;\n }\n}\n\n/**\n * Angular equivalent of Vue's createSharedComposable\n * Creates a singleton pattern for services/composables\n */\nexport const createSharedComposable = <Fn extends AnyFn>(\n composable: Fn\n): SharedComposableReturn<Fn> => {\n let subscribers = 0;\n let state: ReturnType<Fn> | undefined;\n let cleanupFn: (() => void) | undefined;\n\n const dispose = () => {\n subscribers -= 1;\n if (cleanupFn && subscribers <= 0) {\n cleanupFn();\n state = undefined;\n cleanupFn = undefined;\n }\n };\n\n return <Fn>((...args) => {\n subscribers += 1;\n if (!state) {\n state = composable(...args);\n // Set up cleanup when the first subscriber is destroyed\n if (tryOnScopeDispose(dispose)) {\n cleanupFn = dispose;\n }\n } else {\n // For additional subscribers, just set up their individual cleanup\n tryOnScopeDispose(dispose);\n }\n return state;\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"createSharedComposable.mjs","names":[],"sources":["../../../src/editor/createSharedComposable.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core';\n\ntype AnyFn = (...args: any[]) => any;\n\nexport type SharedComposableReturn<T extends AnyFn = AnyFn> = T;\n\n/**\n * Angular replacement for Vue's tryOnScopeDispose\n * Uses Angular's DestroyRef to handle cleanup when the injection context is destroyed\n */\nexport function tryOnScopeDispose(fn: () => void) {\n try {\n const destroyRef = inject(DestroyRef, { optional: true });\n if (destroyRef) {\n destroyRef.onDestroy(fn);\n return true;\n }\n return false;\n } catch {\n // If called outside injection context, return false\n return false;\n }\n}\n\n/**\n * Angular equivalent of Vue's createSharedComposable\n * Creates a singleton pattern for services/composables\n */\nexport const createSharedComposable = <Fn extends AnyFn>(\n composable: Fn\n): SharedComposableReturn<Fn> => {\n let subscribers = 0;\n let state: ReturnType<Fn> | undefined;\n let cleanupFn: (() => void) | undefined;\n\n const dispose = () => {\n subscribers -= 1;\n if (cleanupFn && subscribers <= 0) {\n cleanupFn();\n state = undefined;\n cleanupFn = undefined;\n }\n };\n\n return <Fn>((...args) => {\n subscribers += 1;\n if (!state) {\n state = composable(...args);\n // Set up cleanup when the first subscriber is destroyed\n if (tryOnScopeDispose(dispose)) {\n cleanupFn = dispose;\n }\n } else {\n // For additional subscribers, just set up their individual cleanup\n tryOnScopeDispose(dispose);\n }\n return state;\n });\n};\n"],"mappings":"uDAUA,SAAgB,EAAkB,EAAgB,CAChD,GAAI,CACF,IAAM,EAAa,EAAO,EAAY,CAAE,SAAU,GAAM,CAAC,CAKzD,OAJI,GACF,EAAW,UAAU,EAAG,CACjB,IAEF,QACD,CAEN,MAAO,IAQX,MAAa,EACX,GAC+B,CAC/B,IAAI,EAAc,EACd,EACA,EAEE,MAAgB,CACpB,IACI,GAAa,GAAe,IAC9B,GAAW,CACX,EAAQ,IAAA,GACR,EAAY,IAAA,KAIhB,QAAa,GAAG,KACd,GAAe,EACV,EAQH,EAAkB,EAAQ,EAP1B,EAAQ,EAAW,GAAG,EAAK,CAEvB,EAAkB,EAAQ,GAC5B,EAAY,IAMT"}
|
|
@@ -1,46 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useCrossFrameState } from "./useCrossFrameState.mjs";
|
|
3
|
-
import { effect, signal } from "@angular/core";
|
|
4
|
-
import { MessageKey } from "@intlayer/editor";
|
|
5
|
-
|
|
6
|
-
//#region src/editor/dictionariesRecord.ts
|
|
7
|
-
/**
|
|
8
|
-
* Singleton instance
|
|
9
|
-
*/
|
|
10
|
-
let instance = null;
|
|
11
|
-
const createDictionaryRecordClient = () => {
|
|
12
|
-
if (instance) return instance;
|
|
13
|
-
const localeDictionariesSignal = signal(void 0);
|
|
14
|
-
instance = {
|
|
15
|
-
localeDictionaries: localeDictionariesSignal.asReadonly(),
|
|
16
|
-
setLocaleDictionaries: (newValue) => {
|
|
17
|
-
localeDictionariesSignal.set(newValue ?? {});
|
|
18
|
-
},
|
|
19
|
-
setLocaleDictionary(dictionary) {
|
|
20
|
-
const current = localeDictionariesSignal();
|
|
21
|
-
localeDictionariesSignal.set({
|
|
22
|
-
...current,
|
|
23
|
-
[dictionary.localId]: dictionary
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
return instance;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Helper to install the provider into the injector
|
|
31
|
-
*/
|
|
32
|
-
const installDictionariesRecord = (_injector) => {
|
|
33
|
-
createDictionaryRecordClient();
|
|
34
|
-
};
|
|
35
|
-
const useDictionariesRecord = createSharedComposable(() => {
|
|
36
|
-
const client = createDictionaryRecordClient();
|
|
37
|
-
if (!client) throw new Error("DictionariesRecord state not found");
|
|
38
|
-
const [_dictionariesRecord, setDictionariesRecord] = useCrossFrameState(MessageKey.INTLAYER_LOCALE_DICTIONARIES_CHANGED, void 0);
|
|
39
|
-
effect(() => {
|
|
40
|
-
setDictionariesRecord(client.localeDictionaries());
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
//#endregion
|
|
45
|
-
export { createDictionaryRecordClient, installDictionariesRecord, useDictionariesRecord };
|
|
1
|
+
import{createSharedComposable as e}from"./createSharedComposable.mjs";import{useCrossFrameState as t}from"./useCrossFrameState.mjs";import{effect as n,signal as r}from"@angular/core";import{MessageKey as i}from"@intlayer/editor";let a=null;const o=()=>{if(a)return a;let e=r(void 0);return a={localeDictionaries:e.asReadonly(),setLocaleDictionaries:t=>{e.set(t??{})},setLocaleDictionary(t){let n=e();e.set({...n,[t.localId]:t})}},a},s=e=>{o()},c=e(()=>{let e=o();if(!e)throw Error(`DictionariesRecord state not found`);let[r,a]=t(i.INTLAYER_LOCALE_DICTIONARIES_CHANGED,void 0);n(()=>{a(e.localeDictionaries())})});export{o as createDictionaryRecordClient,s as installDictionariesRecord,c as useDictionariesRecord};
|
|
46
2
|
//# sourceMappingURL=dictionariesRecord.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dictionariesRecord.mjs","names":[],"sources":["../../../src/editor/dictionariesRecord.ts"],"sourcesContent":["import { effect, type Injector, type Signal, signal } from '@angular/core';\nimport { MessageKey } from '@intlayer/editor';\nimport type { Dictionary } from '@intlayer/types';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameState } from './useCrossFrameState';\n\n/**\n * Singleton instance\n */\nlet instance: DictionariesRecordClient | null = null;\n\nexport type DictionaryContent = Record<Dictionary['key'], Dictionary>;\n\ntype DictionariesRecordClient = {\n localeDictionaries: Signal<DictionaryContent>;\n setLocaleDictionaries: (newValue: DictionaryContent) => void;\n setLocaleDictionary: (dictionary: Dictionary) => void;\n};\n\nexport const createDictionaryRecordClient = () => {\n if (instance) return instance;\n\n const localeDictionariesSignal = signal<DictionaryContent | undefined>(\n undefined\n );\n\n instance = {\n localeDictionaries:\n localeDictionariesSignal.asReadonly() as Signal<DictionaryContent>,\n\n setLocaleDictionaries: (newValue) => {\n localeDictionariesSignal.set(newValue ?? {});\n },\n\n setLocaleDictionary(dictionary) {\n const current = localeDictionariesSignal();\n localeDictionariesSignal.set({\n ...current,\n [dictionary.localId!]: dictionary,\n });\n },\n };\n\n return instance;\n};\n\n/**\n * Helper to install the provider into the injector\n */\nexport const installDictionariesRecord = (_injector: Injector) => {\n const _client = createDictionaryRecordClient();\n\n // Angular doesn't have a direct equivalent to Vue's app.provide\n // The client is stored as a singleton and accessed via createDictionaryRecordClient\n};\n\nexport const useDictionariesRecord = createSharedComposable(() => {\n const client = createDictionaryRecordClient();\n\n if (!client) {\n throw new Error('DictionariesRecord state not found');\n }\n\n const [_dictionariesRecord, setDictionariesRecord] =\n useCrossFrameState<DictionaryContent>(\n MessageKey.INTLAYER_LOCALE_DICTIONARIES_CHANGED,\n undefined\n );\n\n // Use Angular effects instead of Vue watchers\n effect(() => {\n const newValue = client.localeDictionaries();\n setDictionariesRecord(newValue); // its undefined but shouldnt\n });\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"dictionariesRecord.mjs","names":[],"sources":["../../../src/editor/dictionariesRecord.ts"],"sourcesContent":["import { effect, type Injector, type Signal, signal } from '@angular/core';\nimport { MessageKey } from '@intlayer/editor';\nimport type { Dictionary } from '@intlayer/types';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameState } from './useCrossFrameState';\n\n/**\n * Singleton instance\n */\nlet instance: DictionariesRecordClient | null = null;\n\nexport type DictionaryContent = Record<Dictionary['key'], Dictionary>;\n\ntype DictionariesRecordClient = {\n localeDictionaries: Signal<DictionaryContent>;\n setLocaleDictionaries: (newValue: DictionaryContent) => void;\n setLocaleDictionary: (dictionary: Dictionary) => void;\n};\n\nexport const createDictionaryRecordClient = () => {\n if (instance) return instance;\n\n const localeDictionariesSignal = signal<DictionaryContent | undefined>(\n undefined\n );\n\n instance = {\n localeDictionaries:\n localeDictionariesSignal.asReadonly() as Signal<DictionaryContent>,\n\n setLocaleDictionaries: (newValue) => {\n localeDictionariesSignal.set(newValue ?? {});\n },\n\n setLocaleDictionary(dictionary) {\n const current = localeDictionariesSignal();\n localeDictionariesSignal.set({\n ...current,\n [dictionary.localId!]: dictionary,\n });\n },\n };\n\n return instance;\n};\n\n/**\n * Helper to install the provider into the injector\n */\nexport const installDictionariesRecord = (_injector: Injector) => {\n const _client = createDictionaryRecordClient();\n\n // Angular doesn't have a direct equivalent to Vue's app.provide\n // The client is stored as a singleton and accessed via createDictionaryRecordClient\n};\n\nexport const useDictionariesRecord = createSharedComposable(() => {\n const client = createDictionaryRecordClient();\n\n if (!client) {\n throw new Error('DictionariesRecord state not found');\n }\n\n const [_dictionariesRecord, setDictionariesRecord] =\n useCrossFrameState<DictionaryContent>(\n MessageKey.INTLAYER_LOCALE_DICTIONARIES_CHANGED,\n undefined\n );\n\n // Use Angular effects instead of Vue watchers\n effect(() => {\n const newValue = client.localeDictionaries();\n setDictionariesRecord(newValue); // its undefined but shouldnt\n });\n});\n"],"mappings":"qOASA,IAAI,EAA4C,KAUhD,MAAa,MAAqC,CAChD,GAAI,EAAU,OAAO,EAErB,IAAM,EAA2B,EAC/B,IAAA,GACD,CAmBD,MAjBA,GAAW,CACT,mBACE,EAAyB,YAAY,CAEvC,sBAAwB,GAAa,CACnC,EAAyB,IAAI,GAAY,EAAE,CAAC,EAG9C,oBAAoB,EAAY,CAC9B,IAAM,EAAU,GAA0B,CAC1C,EAAyB,IAAI,CAC3B,GAAG,GACF,EAAW,SAAW,EACxB,CAAC,EAEL,CAEM,GAMI,EAA6B,GAAwB,CAChD,GAA8B,EAMnC,EAAwB,MAA6B,CAChE,IAAM,EAAS,GAA8B,CAE7C,GAAI,CAAC,EACH,MAAU,MAAM,qCAAqC,CAGvD,GAAM,CAAC,EAAqB,GAC1B,EACE,EAAW,qCACX,IAAA,GACD,CAGH,MAAa,CAEX,EADiB,EAAO,oBAAoB,CACb,EAC/B,EACF"}
|
|
@@ -1,58 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useCrossFrameState } from "./useCrossFrameState.mjs";
|
|
3
|
-
import { getContentNodeByKeyPath } from "@intlayer/core";
|
|
4
|
-
import { effect, signal } from "@angular/core";
|
|
5
|
-
import { MessageKey } from "@intlayer/editor";
|
|
6
|
-
|
|
7
|
-
//#region src/editor/editedContent.ts
|
|
8
|
-
/**
|
|
9
|
-
* Singleton instance
|
|
10
|
-
*/
|
|
11
|
-
let instance = null;
|
|
12
|
-
/**
|
|
13
|
-
* Creates an edited content client
|
|
14
|
-
*/
|
|
15
|
-
const createEditedContentClient = () => {
|
|
16
|
-
if (instance) return instance;
|
|
17
|
-
const editedContentSignal = signal({});
|
|
18
|
-
instance = {
|
|
19
|
-
editedContent: editedContentSignal.asReadonly(),
|
|
20
|
-
getEditedContentValue: (localDictionaryIdOrKey, keyPath) => {
|
|
21
|
-
const editedContent = editedContentSignal();
|
|
22
|
-
if (!editedContent) return void 0;
|
|
23
|
-
if (localDictionaryIdOrKey.includes(":local:") || localDictionaryIdOrKey.includes(":remote:")) return getContentNodeByKeyPath(editedContent?.[localDictionaryIdOrKey]?.content ?? {}, keyPath);
|
|
24
|
-
const filteredDictionariesLocalId = Object.keys(editedContent).filter((key) => key.startsWith(`${localDictionaryIdOrKey}:`));
|
|
25
|
-
for (const localDictionaryId of filteredDictionariesLocalId) {
|
|
26
|
-
const contentNode = getContentNodeByKeyPath(editedContent?.[localDictionaryId]?.content ?? {}, keyPath);
|
|
27
|
-
if (contentNode) return contentNode;
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
setEditedContent: (editedContent) => {
|
|
31
|
-
editedContentSignal.set(editedContent);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
return instance;
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Helper to install the edited content into the injector
|
|
38
|
-
*/
|
|
39
|
-
const installEditedContent = (_injector) => {
|
|
40
|
-
createEditedContentClient();
|
|
41
|
-
};
|
|
42
|
-
const useEditedContent = createSharedComposable(() => {
|
|
43
|
-
const client = createEditedContentClient();
|
|
44
|
-
if (!client) throw new Error("EditedContent state not found");
|
|
45
|
-
const [edited, setEdited] = useCrossFrameState(MessageKey.INTLAYER_EDITED_CONTENT_CHANGED, {});
|
|
46
|
-
effect(() => {
|
|
47
|
-
const newValue = edited();
|
|
48
|
-
client.setEditedContent(newValue ?? {});
|
|
49
|
-
});
|
|
50
|
-
effect(() => {
|
|
51
|
-
setEdited(client.editedContent());
|
|
52
|
-
});
|
|
53
|
-
return client;
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
//#endregion
|
|
57
|
-
export { createEditedContentClient, installEditedContent, useEditedContent };
|
|
1
|
+
import{createSharedComposable as e}from"./createSharedComposable.mjs";import{useCrossFrameState as t}from"./useCrossFrameState.mjs";import{effect as n,signal as r}from"@angular/core";import{MessageKey as i}from"@intlayer/editor";import{getContentNodeByKeyPath as a}from"@intlayer/core/dictionaryManipulator";let o=null;const s=()=>{if(o)return o;let e=r({});return o={editedContent:e.asReadonly(),getEditedContentValue:(t,n)=>{let r=e();if(!r)return;if(t.includes(`:local:`)||t.includes(`:remote:`))return a(r?.[t]?.content??{},n);let i=Object.keys(r).filter(e=>e.startsWith(`${t}:`));for(let e of i){let t=a(r?.[e]?.content??{},n);if(t)return t}},setEditedContent:t=>{e.set(t)}},o},c=e=>{s()},l=e(()=>{let e=s();if(!e)throw Error(`EditedContent state not found`);let[r,a]=t(i.INTLAYER_EDITED_CONTENT_CHANGED,{});return n(()=>{let t=r();e.setEditedContent(t??{})}),n(()=>{a(e.editedContent())}),e});export{s as createEditedContentClient,c as installEditedContent,l as useEditedContent};
|
|
58
2
|
//# sourceMappingURL=editedContent.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editedContent.mjs","names":[],"sources":["../../../src/editor/editedContent.ts"],"sourcesContent":["import { effect, type Injector, type Signal, signal } from '@angular/core';\nimport { getContentNodeByKeyPath } from '@intlayer/core';\nimport { MessageKey } from '@intlayer/editor';\nimport type {\n ContentNode,\n Dictionary,\n KeyPath,\n LocalDictionaryId,\n} from '@intlayer/types';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport type EditedContent = Record<Dictionary['key'], Dictionary>;\n\ntype EditedContentClient = {\n editedContent: Signal<EditedContent>;\n setEditedContent: (editedContent: EditedContent) => void;\n getEditedContentValue: (\n localDictionaryIdOrKey: LocalDictionaryId | Dictionary['key'] | string,\n keyPath: KeyPath[]\n ) => ContentNode | undefined;\n};\n\n/**\n * Singleton instance\n */\nlet instance: EditedContentClient | null = null;\n\nconst _INTLAYER_EDITED_CONTENT_SYMBOL = Symbol('EditedContent');\n\n/**\n * Creates an edited content client\n */\nexport const createEditedContentClient = () => {\n if (instance) return instance;\n\n const editedContentSignal = signal<EditedContent>({});\n\n instance = {\n editedContent: editedContentSignal.asReadonly(),\n getEditedContentValue: (\n localDictionaryIdOrKey: LocalDictionaryId | Dictionary['key'] | string,\n keyPath: KeyPath[]\n ): ContentNode | undefined => {\n const editedContent = editedContentSignal();\n\n if (!editedContent) return undefined;\n\n const isDictionaryId =\n localDictionaryIdOrKey.includes(':local:') ||\n localDictionaryIdOrKey.includes(':remote:');\n\n if (isDictionaryId) {\n const currentContent =\n editedContent?.[localDictionaryIdOrKey as LocalDictionaryId]\n ?.content ?? {};\n\n const contentNode = getContentNodeByKeyPath(currentContent, keyPath);\n\n return contentNode;\n }\n\n const filteredDictionariesLocalId = Object.keys(editedContent).filter(\n (key) => key.startsWith(`${localDictionaryIdOrKey}:`)\n );\n\n for (const localDictionaryId of filteredDictionariesLocalId) {\n const currentContent =\n editedContent?.[localDictionaryId as LocalDictionaryId]?.content ??\n {};\n const contentNode = getContentNodeByKeyPath(currentContent, keyPath);\n\n if (contentNode) return contentNode;\n }\n\n return undefined;\n },\n setEditedContent: (editedContent: EditedContent) => {\n editedContentSignal.set(editedContent);\n },\n };\n\n return instance;\n};\n\n/**\n * Helper to install the edited content into the injector\n */\nexport const installEditedContent = (_injector: Injector) => {\n const _client = createEditedContentClient();\n\n // Angular doesn't have a direct equivalent to Vue's app.provide\n // The client is stored as a singleton and accessed via createEditedContentClient\n};\n\nexport const useEditedContent = createSharedComposable(() => {\n const client = createEditedContentClient();\n\n if (!client) {\n throw new Error('EditedContent state not found');\n }\n\n const [edited, setEdited] = useCrossFrameState<EditedContent>(\n MessageKey.INTLAYER_EDITED_CONTENT_CHANGED,\n {}\n );\n\n // Use Angular effects instead of Vue watchers\n effect(() => {\n const newValue = edited();\n client.setEditedContent(newValue ?? {});\n });\n\n effect(() => {\n const newValue = client.editedContent();\n setEdited(newValue);\n });\n\n return client;\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"editedContent.mjs","names":[],"sources":["../../../src/editor/editedContent.ts"],"sourcesContent":["import { effect, type Injector, type Signal, signal } from '@angular/core';\nimport { getContentNodeByKeyPath } from '@intlayer/core/dictionaryManipulator';\nimport { MessageKey } from '@intlayer/editor';\nimport type {\n ContentNode,\n Dictionary,\n KeyPath,\n LocalDictionaryId,\n} from '@intlayer/types';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport type EditedContent = Record<Dictionary['key'], Dictionary>;\n\ntype EditedContentClient = {\n editedContent: Signal<EditedContent>;\n setEditedContent: (editedContent: EditedContent) => void;\n getEditedContentValue: (\n localDictionaryIdOrKey: LocalDictionaryId | Dictionary['key'] | string,\n keyPath: KeyPath[]\n ) => ContentNode | undefined;\n};\n\n/**\n * Singleton instance\n */\nlet instance: EditedContentClient | null = null;\n\nconst _INTLAYER_EDITED_CONTENT_SYMBOL = Symbol('EditedContent');\n\n/**\n * Creates an edited content client\n */\nexport const createEditedContentClient = () => {\n if (instance) return instance;\n\n const editedContentSignal = signal<EditedContent>({});\n\n instance = {\n editedContent: editedContentSignal.asReadonly(),\n getEditedContentValue: (\n localDictionaryIdOrKey: LocalDictionaryId | Dictionary['key'] | string,\n keyPath: KeyPath[]\n ): ContentNode | undefined => {\n const editedContent = editedContentSignal();\n\n if (!editedContent) return undefined;\n\n const isDictionaryId =\n localDictionaryIdOrKey.includes(':local:') ||\n localDictionaryIdOrKey.includes(':remote:');\n\n if (isDictionaryId) {\n const currentContent =\n editedContent?.[localDictionaryIdOrKey as LocalDictionaryId]\n ?.content ?? {};\n\n const contentNode = getContentNodeByKeyPath(currentContent, keyPath);\n\n return contentNode;\n }\n\n const filteredDictionariesLocalId = Object.keys(editedContent).filter(\n (key) => key.startsWith(`${localDictionaryIdOrKey}:`)\n );\n\n for (const localDictionaryId of filteredDictionariesLocalId) {\n const currentContent =\n editedContent?.[localDictionaryId as LocalDictionaryId]?.content ??\n {};\n const contentNode = getContentNodeByKeyPath(currentContent, keyPath);\n\n if (contentNode) return contentNode;\n }\n\n return undefined;\n },\n setEditedContent: (editedContent: EditedContent) => {\n editedContentSignal.set(editedContent);\n },\n };\n\n return instance;\n};\n\n/**\n * Helper to install the edited content into the injector\n */\nexport const installEditedContent = (_injector: Injector) => {\n const _client = createEditedContentClient();\n\n // Angular doesn't have a direct equivalent to Vue's app.provide\n // The client is stored as a singleton and accessed via createEditedContentClient\n};\n\nexport const useEditedContent = createSharedComposable(() => {\n const client = createEditedContentClient();\n\n if (!client) {\n throw new Error('EditedContent state not found');\n }\n\n const [edited, setEdited] = useCrossFrameState<EditedContent>(\n MessageKey.INTLAYER_EDITED_CONTENT_CHANGED,\n {}\n );\n\n // Use Angular effects instead of Vue watchers\n effect(() => {\n const newValue = edited();\n client.setEditedContent(newValue ?? {});\n });\n\n effect(() => {\n const newValue = client.editedContent();\n setEdited(newValue);\n });\n\n return client;\n});\n"],"mappings":"oTA0BA,IAAI,EAAuC,KAO3C,MAAa,MAAkC,CAC7C,GAAI,EAAU,OAAO,EAErB,IAAM,EAAsB,EAAsB,EAAE,CAAC,CA8CrD,MA5CA,GAAW,CACT,cAAe,EAAoB,YAAY,CAC/C,uBACE,EACA,IAC4B,CAC5B,IAAM,EAAgB,GAAqB,CAE3C,GAAI,CAAC,EAAe,OAMpB,GAHE,EAAuB,SAAS,UAAU,EAC1C,EAAuB,SAAS,WAAW,CAS3C,OAFoB,EAHlB,IAAgB,IACZ,SAAW,EAAE,CAEyC,EAAQ,CAKtE,IAAM,EAA8B,OAAO,KAAK,EAAc,CAAC,OAC5D,GAAQ,EAAI,WAAW,GAAG,EAAuB,GAAG,CACtD,CAED,IAAK,IAAM,KAAqB,EAA6B,CAI3D,IAAM,EAAc,EAFlB,IAAgB,IAAyC,SACzD,EAAE,CACwD,EAAQ,CAEpE,GAAI,EAAa,OAAO,IAK5B,iBAAmB,GAAiC,CAClD,EAAoB,IAAI,EAAc,EAEzC,CAEM,GAMI,EAAwB,GAAwB,CAC3C,GAA2B,EAMhC,EAAmB,MAA6B,CAC3D,IAAM,EAAS,GAA2B,CAE1C,GAAI,CAAC,EACH,MAAU,MAAM,gCAAgC,CAGlD,GAAM,CAAC,EAAQ,GAAa,EAC1B,EAAW,gCACX,EAAE,CACH,CAaD,OAVA,MAAa,CACX,IAAM,EAAW,GAAQ,CACzB,EAAO,iBAAiB,GAAY,EAAE,CAAC,EACvC,CAEF,MAAa,CAEX,EADiB,EAAO,eAAe,CACpB,EACnB,CAEK,GACP"}
|
|
@@ -1,46 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useCrossFrameMessageListener } from "./useCrossFrameMessageListener.mjs";
|
|
3
|
-
import { computed, effect, signal } from "@angular/core";
|
|
4
|
-
import { MessageKey } from "@intlayer/editor";
|
|
5
|
-
|
|
6
|
-
//#region src/editor/editorEnabled.ts
|
|
7
|
-
/**
|
|
8
|
-
* Singleton instance
|
|
9
|
-
*/
|
|
10
|
-
let instance = null;
|
|
11
|
-
/**
|
|
12
|
-
* Creates an editor wrapperEnabled client
|
|
13
|
-
*/
|
|
14
|
-
const createEditorEnabledClient = () => {
|
|
15
|
-
if (instance) return instance;
|
|
16
|
-
const wrapperEnabledSignal = signal(false);
|
|
17
|
-
const isInIframeSignal = signal(false);
|
|
18
|
-
const enabledSignal = computed(() => wrapperEnabledSignal() && isInIframeSignal());
|
|
19
|
-
instance = {
|
|
20
|
-
wrapperEnabled: wrapperEnabledSignal.asReadonly(),
|
|
21
|
-
isInIframe: isInIframeSignal.asReadonly(),
|
|
22
|
-
enabled: enabledSignal
|
|
23
|
-
};
|
|
24
|
-
return instance;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Helper to install the editor wrapperEnabled state into the injector
|
|
28
|
-
*/
|
|
29
|
-
const installEditorEnabled = (_injector) => {
|
|
30
|
-
createEditorEnabledClient();
|
|
31
|
-
};
|
|
32
|
-
const useEditorEnabled = createSharedComposable(() => {
|
|
33
|
-
const client = createEditorEnabledClient();
|
|
34
|
-
if (!client) throw new Error("EditorEnabled state not found");
|
|
35
|
-
useCrossFrameMessageListener(`${MessageKey.INTLAYER_EDITOR_ENABLED}/post`, (data) => {
|
|
36
|
-
client.wrapperEnabled.set(data);
|
|
37
|
-
});
|
|
38
|
-
effect(() => {
|
|
39
|
-
if (typeof window !== "undefined") client.isInIframe.set(window.self !== window.top);
|
|
40
|
-
}, { allowSignalWrites: true });
|
|
41
|
-
return client;
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
//#endregion
|
|
45
|
-
export { createEditorEnabledClient, installEditorEnabled, useEditorEnabled };
|
|
1
|
+
import{createSharedComposable as e}from"./createSharedComposable.mjs";import{useCrossFrameMessageListener as t}from"./useCrossFrameMessageListener.mjs";import{computed as n,effect as r,signal as i}from"@angular/core";import{MessageKey as a}from"@intlayer/editor";let o=null;const s=()=>{if(o)return o;let e=i(!1),t=i(!1),r=n(()=>e()&&t());return o={wrapperEnabled:e.asReadonly(),isInIframe:t.asReadonly(),enabled:r},o},c=e=>{s()},l=e(()=>{let e=s();if(!e)throw Error(`EditorEnabled state not found`);return t(`${a.INTLAYER_EDITOR_ENABLED}/post`,t=>{e.wrapperEnabled.set(t)}),r(()=>{typeof window<`u`&&e.isInIframe.set(window.self!==window.top)},{allowSignalWrites:!0}),e});export{s as createEditorEnabledClient,c as installEditorEnabled,l as useEditorEnabled};
|
|
46
2
|
//# sourceMappingURL=editorEnabled.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editorEnabled.mjs","names":[],"sources":["../../../src/editor/editorEnabled.ts"],"sourcesContent":["import {\n computed,\n effect,\n type Injector,\n type Signal,\n signal,\n} from '@angular/core';\nimport { MessageKey } from '@intlayer/editor';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameMessageListener } from './useCrossFrameMessageListener';\n\n/* ------------------------------------------------------------------ */\n/* public type – identical to the React version */\n/* ------------------------------------------------------------------ */\nexport type EditorEnabledStateProps = {\n wrapperEnabled: Signal<boolean>;\n isInIframe: Signal<boolean>;\n enabled: Signal<boolean>;\n};\n\n/**\n * Singleton instance\n */\nlet instance: EditorEnabledStateProps | null = null;\n\nconst _INTLAYER_EDITOR_ENABLED_SYMBOL = Symbol('EditorEnabled');\n\n/**\n * Creates an editor wrapperEnabled client\n */\nexport const createEditorEnabledClient = () => {\n if (instance) return instance;\n\n const wrapperEnabledSignal = signal(false);\n const isInIframeSignal = signal(false);\n const enabledSignal = computed(\n () => wrapperEnabledSignal() && isInIframeSignal()\n );\n\n instance = {\n wrapperEnabled: wrapperEnabledSignal.asReadonly(),\n isInIframe: isInIframeSignal.asReadonly(),\n enabled: enabledSignal,\n };\n\n return instance;\n};\n\n/**\n * Helper to install the editor wrapperEnabled state into the injector\n */\nexport const installEditorEnabled = (_injector: Injector) => {\n const _client = createEditorEnabledClient();\n\n // Angular doesn't have a direct equivalent to Vue's app.provide\n // The client is stored as a singleton and accessed via createEditorEnabledClient\n};\n\nexport const useEditorEnabled = createSharedComposable(() => {\n const client = createEditorEnabledClient();\n\n if (!client) {\n throw new Error('EditorEnabled state not found');\n }\n\n // Listen for the iframe parent if the editor send a message `INTLAYER_EDITOR_ENABLED`\n useCrossFrameMessageListener<boolean>(\n `${MessageKey.INTLAYER_EDITOR_ENABLED}/post`,\n (data) => {\n (client.wrapperEnabled as any).set(data);\n }\n );\n\n // Use effect to set up the iframe check immediately\n effect(\n () => {\n if (typeof window !== 'undefined') {\n (client.isInIframe as any).set(window.self !== window.top);\n }\n },\n { allowSignalWrites: true }\n );\n\n return client;\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"editorEnabled.mjs","names":[],"sources":["../../../src/editor/editorEnabled.ts"],"sourcesContent":["import {\n computed,\n effect,\n type Injector,\n type Signal,\n signal,\n} from '@angular/core';\nimport { MessageKey } from '@intlayer/editor';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameMessageListener } from './useCrossFrameMessageListener';\n\n/* ------------------------------------------------------------------ */\n/* public type – identical to the React version */\n/* ------------------------------------------------------------------ */\nexport type EditorEnabledStateProps = {\n wrapperEnabled: Signal<boolean>;\n isInIframe: Signal<boolean>;\n enabled: Signal<boolean>;\n};\n\n/**\n * Singleton instance\n */\nlet instance: EditorEnabledStateProps | null = null;\n\nconst _INTLAYER_EDITOR_ENABLED_SYMBOL = Symbol('EditorEnabled');\n\n/**\n * Creates an editor wrapperEnabled client\n */\nexport const createEditorEnabledClient = () => {\n if (instance) return instance;\n\n const wrapperEnabledSignal = signal(false);\n const isInIframeSignal = signal(false);\n const enabledSignal = computed(\n () => wrapperEnabledSignal() && isInIframeSignal()\n );\n\n instance = {\n wrapperEnabled: wrapperEnabledSignal.asReadonly(),\n isInIframe: isInIframeSignal.asReadonly(),\n enabled: enabledSignal,\n };\n\n return instance;\n};\n\n/**\n * Helper to install the editor wrapperEnabled state into the injector\n */\nexport const installEditorEnabled = (_injector: Injector) => {\n const _client = createEditorEnabledClient();\n\n // Angular doesn't have a direct equivalent to Vue's app.provide\n // The client is stored as a singleton and accessed via createEditorEnabledClient\n};\n\nexport const useEditorEnabled = createSharedComposable(() => {\n const client = createEditorEnabledClient();\n\n if (!client) {\n throw new Error('EditorEnabled state not found');\n }\n\n // Listen for the iframe parent if the editor send a message `INTLAYER_EDITOR_ENABLED`\n useCrossFrameMessageListener<boolean>(\n `${MessageKey.INTLAYER_EDITOR_ENABLED}/post`,\n (data) => {\n (client.wrapperEnabled as any).set(data);\n }\n );\n\n // Use effect to set up the iframe check immediately\n effect(\n () => {\n if (typeof window !== 'undefined') {\n (client.isInIframe as any).set(window.self !== window.top);\n }\n },\n { allowSignalWrites: true }\n );\n\n return client;\n});\n"],"mappings":"uQAuBA,IAAI,EAA2C,KAO/C,MAAa,MAAkC,CAC7C,GAAI,EAAU,OAAO,EAErB,IAAM,EAAuB,EAAO,GAAM,CACpC,EAAmB,EAAO,GAAM,CAChC,EAAgB,MACd,GAAsB,EAAI,GAAkB,CACnD,CAQD,MANA,GAAW,CACT,eAAgB,EAAqB,YAAY,CACjD,WAAY,EAAiB,YAAY,CACzC,QAAS,EACV,CAEM,GAMI,EAAwB,GAAwB,CAC3C,GAA2B,EAMhC,EAAmB,MAA6B,CAC3D,IAAM,EAAS,GAA2B,CAE1C,GAAI,CAAC,EACH,MAAU,MAAM,gCAAgC,CAqBlD,OAjBA,EACE,GAAG,EAAW,wBAAwB,OACrC,GAAS,CACP,EAAO,eAAuB,IAAI,EAAK,EAE3C,CAGD,MACQ,CACA,OAAO,OAAW,KACnB,EAAO,WAAmB,IAAI,OAAO,OAAS,OAAO,IAAI,EAG9D,CAAE,kBAAmB,GAAM,CAC5B,CAEM,GACP"}
|
|
@@ -1,20 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useCrossFrameState } from "./useCrossFrameState.mjs";
|
|
3
|
-
import { INTLAYER_TOKEN } from "../client/installIntlayer.mjs";
|
|
4
|
-
import { effect, inject } from "@angular/core";
|
|
5
|
-
import { MessageKey } from "@intlayer/editor";
|
|
6
|
-
|
|
7
|
-
//#region src/editor/editorLocale.ts
|
|
8
|
-
const useEditorLocale = createSharedComposable(() => {
|
|
9
|
-
const client = inject(INTLAYER_TOKEN);
|
|
10
|
-
if (!client) throw new Error("IntlayerEditor state not found");
|
|
11
|
-
const [_data, setData] = useCrossFrameState(MessageKey.INTLAYER_CURRENT_LOCALE);
|
|
12
|
-
effect(() => {
|
|
13
|
-
setData(client.locale());
|
|
14
|
-
});
|
|
15
|
-
return client;
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
export { useEditorLocale };
|
|
1
|
+
import{createSharedComposable as e}from"./createSharedComposable.mjs";import{useCrossFrameState as t}from"./useCrossFrameState.mjs";import{INTLAYER_TOKEN as n}from"../client/installIntlayer.mjs";import{effect as r,inject as i}from"@angular/core";import{MessageKey as a}from"@intlayer/editor";const o=e(()=>{let e=i(n);if(!e)throw Error(`IntlayerEditor state not found`);let[o,s]=t(a.INTLAYER_CURRENT_LOCALE);return r(()=>{s(e.locale())}),e});export{o as useEditorLocale};
|
|
20
2
|
//# sourceMappingURL=editorLocale.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editorLocale.mjs","names":[],"sources":["../../../src/editor/editorLocale.ts"],"sourcesContent":["import { effect, inject } from '@angular/core';\nimport { MessageKey } from '@intlayer/editor';\nimport type { Locale, LocalesValues } from '@intlayer/types';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from '../client';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport const useEditorLocale = createSharedComposable(() => {\n const client = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n if (!client) {\n throw new Error('IntlayerEditor state not found');\n }\n\n const [_data, setData] = useCrossFrameState<LocalesValues>(\n MessageKey.INTLAYER_CURRENT_LOCALE\n );\n\n // Use Angular effects instead of Vue watchers\n effect(() => {\n const newValue = client.locale();\n setData(newValue as Locale);\n });\n\n return client;\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"editorLocale.mjs","names":[],"sources":["../../../src/editor/editorLocale.ts"],"sourcesContent":["import { effect, inject } from '@angular/core';\nimport { MessageKey } from '@intlayer/editor';\nimport type { Locale, LocalesValues } from '@intlayer/types';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from '../client';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport const useEditorLocale = createSharedComposable(() => {\n const client = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n if (!client) {\n throw new Error('IntlayerEditor state not found');\n }\n\n const [_data, setData] = useCrossFrameState<LocalesValues>(\n MessageKey.INTLAYER_CURRENT_LOCALE\n );\n\n // Use Angular effects instead of Vue watchers\n effect(() => {\n const newValue = client.locale();\n setData(newValue as Locale);\n });\n\n return client;\n});\n"],"mappings":"oSAOA,MAAa,EAAkB,MAA6B,CAC1D,IAAM,EAAS,EAAyB,EAAe,CAEvD,GAAI,CAAC,EACH,MAAU,MAAM,iCAAiC,CAGnD,GAAM,CAAC,EAAO,GAAW,EACvB,EAAW,wBACZ,CAQD,OALA,MAAa,CAEX,EADiB,EAAO,QAAQ,CACL,EAC3B,CAEK,GACP"}
|
|
@@ -1,59 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useCrossFrameState } from "./useCrossFrameState.mjs";
|
|
3
|
-
import { effect, signal } from "@angular/core";
|
|
4
|
-
import { MessageKey } from "@intlayer/editor";
|
|
5
|
-
|
|
6
|
-
//#region src/editor/focusDictionary.ts
|
|
7
|
-
/**
|
|
8
|
-
* Singleton instance
|
|
9
|
-
*/
|
|
10
|
-
let instance = null;
|
|
11
|
-
/**
|
|
12
|
-
* Creates a focus dictionary client
|
|
13
|
-
*/
|
|
14
|
-
const createFocusDictionaryClient = () => {
|
|
15
|
-
if (instance) return instance;
|
|
16
|
-
const focusedContentSignal = signal(null);
|
|
17
|
-
const setFocusedContent = (focussedContent) => {
|
|
18
|
-
focusedContentSignal.set(focussedContent);
|
|
19
|
-
};
|
|
20
|
-
const setFocusedContentKeyPath = (keyPath) => {
|
|
21
|
-
const current = focusedContentSignal();
|
|
22
|
-
if (!current) return;
|
|
23
|
-
setFocusedContent({
|
|
24
|
-
...current,
|
|
25
|
-
keyPath
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
instance = {
|
|
29
|
-
focusedContent: focusedContentSignal.asReadonly(),
|
|
30
|
-
setFocusedContent,
|
|
31
|
-
setFocusedContentKeyPath
|
|
32
|
-
};
|
|
33
|
-
return instance;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Helper to install the focus dictionary into the injector
|
|
37
|
-
*/
|
|
38
|
-
const installFocusDictionary = (_injector) => {
|
|
39
|
-
createFocusDictionaryClient();
|
|
40
|
-
};
|
|
41
|
-
/** consumer */
|
|
42
|
-
const useFocusDictionary = createSharedComposable(() => {
|
|
43
|
-
const client = createFocusDictionaryClient();
|
|
44
|
-
const [focusedContent, setFocusedContent] = useCrossFrameState(MessageKey.INTLAYER_FOCUSED_CONTENT_CHANGED);
|
|
45
|
-
if (!client) throw new Error("FocusDictionary state not found");
|
|
46
|
-
effect(() => {
|
|
47
|
-
const newValue = client.focusedContent();
|
|
48
|
-
if (JSON.stringify(newValue) !== JSON.stringify(focusedContent())) setFocusedContent(newValue);
|
|
49
|
-
});
|
|
50
|
-
effect(() => {
|
|
51
|
-
const newValue = focusedContent();
|
|
52
|
-
if (JSON.stringify(newValue) !== JSON.stringify(client.focusedContent())) client.setFocusedContent(newValue ?? null);
|
|
53
|
-
});
|
|
54
|
-
return client;
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
//#endregion
|
|
58
|
-
export { createFocusDictionaryClient, installFocusDictionary, useFocusDictionary };
|
|
1
|
+
import{createSharedComposable as e}from"./createSharedComposable.mjs";import{useCrossFrameState as t}from"./useCrossFrameState.mjs";import{effect as n,signal as r}from"@angular/core";import{MessageKey as i}from"@intlayer/editor";let a=null;const o=()=>{if(a)return a;let e=r(null),t=t=>{e.set(t)};return a={focusedContent:e.asReadonly(),setFocusedContent:t,setFocusedContentKeyPath:n=>{let r=e();r&&t({...r,keyPath:n})}},a},s=e=>{o()},c=e(()=>{let e=o(),[r,a]=t(i.INTLAYER_FOCUSED_CONTENT_CHANGED);if(!e)throw Error(`FocusDictionary state not found`);return n(()=>{let t=e.focusedContent();JSON.stringify(t)!==JSON.stringify(r())&&a(t)}),n(()=>{let t=r();JSON.stringify(t)!==JSON.stringify(e.focusedContent())&&e.setFocusedContent(t??null)}),e});export{o as createFocusDictionaryClient,s as installFocusDictionary,c as useFocusDictionary};
|
|
59
2
|
//# sourceMappingURL=focusDictionary.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focusDictionary.mjs","names":[],"sources":["../../../src/editor/focusDictionary.ts"],"sourcesContent":["import { effect, type Injector, type Signal, signal } from '@angular/core';\nimport { MessageKey } from '@intlayer/editor';\nimport type { KeyPath } from '@intlayer/types';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport type FileContent = {\n dictionaryKey: string;\n keyPath?: KeyPath[];\n dictionaryPath?: string;\n};\n\ntype FocusDictionaryClient = {\n focusedContent: Signal<FileContent | null>;\n setFocusedContent: (focussedContent: FileContent | null) => void;\n setFocusedContentKeyPath: (keyPath: KeyPath[]) => void;\n};\n\n/**\n * Singleton instance\n */\nlet instance: FocusDictionaryClient | null = null;\n\n/**\n * Creates a focus dictionary client\n */\nexport const createFocusDictionaryClient = () => {\n if (instance) return instance;\n\n const focusedContentSignal = signal<FileContent | null>(null);\n\n const setFocusedContent = (focussedContent: FileContent | null) => {\n focusedContentSignal.set(focussedContent);\n };\n\n const setFocusedContentKeyPath = (keyPath: KeyPath[]) => {\n const current = focusedContentSignal();\n if (!current) return;\n setFocusedContent({ ...current, keyPath });\n };\n\n instance = {\n focusedContent: focusedContentSignal.asReadonly(),\n setFocusedContent,\n setFocusedContentKeyPath,\n } as FocusDictionaryClient;\n\n return instance;\n};\n\n/**\n * Helper to install the focus dictionary into the injector\n */\nexport const installFocusDictionary = (_injector: Injector) => {\n const _client = createFocusDictionaryClient();\n\n // Angular doesn't have a direct equivalent to Vue's app.provide\n // The client is stored as a singleton and accessed via createFocusDictionaryClient\n};\n\n/** consumer */\nexport const useFocusDictionary = createSharedComposable(() => {\n const client = createFocusDictionaryClient();\n const [focusedContent, setFocusedContent] =\n useCrossFrameState<FileContent | null>(\n MessageKey.INTLAYER_FOCUSED_CONTENT_CHANGED\n );\n\n if (!client) {\n throw new Error('FocusDictionary state not found');\n }\n\n // Use Angular effects instead of Vue watchers\n // Watch local (client) and update cross-frame\n effect(() => {\n const newValue = client.focusedContent();\n if (JSON.stringify(newValue) !== JSON.stringify(focusedContent())) {\n setFocusedContent(newValue);\n }\n });\n\n // Watch cross-frame and update local\n effect(() => {\n const newValue = focusedContent();\n if (JSON.stringify(newValue) !== JSON.stringify(client.focusedContent())) {\n client.setFocusedContent(newValue ?? null);\n }\n });\n\n return client;\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"focusDictionary.mjs","names":[],"sources":["../../../src/editor/focusDictionary.ts"],"sourcesContent":["import { effect, type Injector, type Signal, signal } from '@angular/core';\nimport { MessageKey } from '@intlayer/editor';\nimport type { KeyPath } from '@intlayer/types';\nimport { createSharedComposable } from './createSharedComposable';\nimport { useCrossFrameState } from './useCrossFrameState';\n\nexport type FileContent = {\n dictionaryKey: string;\n keyPath?: KeyPath[];\n dictionaryPath?: string;\n};\n\ntype FocusDictionaryClient = {\n focusedContent: Signal<FileContent | null>;\n setFocusedContent: (focussedContent: FileContent | null) => void;\n setFocusedContentKeyPath: (keyPath: KeyPath[]) => void;\n};\n\n/**\n * Singleton instance\n */\nlet instance: FocusDictionaryClient | null = null;\n\n/**\n * Creates a focus dictionary client\n */\nexport const createFocusDictionaryClient = () => {\n if (instance) return instance;\n\n const focusedContentSignal = signal<FileContent | null>(null);\n\n const setFocusedContent = (focussedContent: FileContent | null) => {\n focusedContentSignal.set(focussedContent);\n };\n\n const setFocusedContentKeyPath = (keyPath: KeyPath[]) => {\n const current = focusedContentSignal();\n if (!current) return;\n setFocusedContent({ ...current, keyPath });\n };\n\n instance = {\n focusedContent: focusedContentSignal.asReadonly(),\n setFocusedContent,\n setFocusedContentKeyPath,\n } as FocusDictionaryClient;\n\n return instance;\n};\n\n/**\n * Helper to install the focus dictionary into the injector\n */\nexport const installFocusDictionary = (_injector: Injector) => {\n const _client = createFocusDictionaryClient();\n\n // Angular doesn't have a direct equivalent to Vue's app.provide\n // The client is stored as a singleton and accessed via createFocusDictionaryClient\n};\n\n/** consumer */\nexport const useFocusDictionary = createSharedComposable(() => {\n const client = createFocusDictionaryClient();\n const [focusedContent, setFocusedContent] =\n useCrossFrameState<FileContent | null>(\n MessageKey.INTLAYER_FOCUSED_CONTENT_CHANGED\n );\n\n if (!client) {\n throw new Error('FocusDictionary state not found');\n }\n\n // Use Angular effects instead of Vue watchers\n // Watch local (client) and update cross-frame\n effect(() => {\n const newValue = client.focusedContent();\n if (JSON.stringify(newValue) !== JSON.stringify(focusedContent())) {\n setFocusedContent(newValue);\n }\n });\n\n // Watch cross-frame and update local\n effect(() => {\n const newValue = focusedContent();\n if (JSON.stringify(newValue) !== JSON.stringify(client.focusedContent())) {\n client.setFocusedContent(newValue ?? null);\n }\n });\n\n return client;\n});\n"],"mappings":"qOAqBA,IAAI,EAAyC,KAK7C,MAAa,MAAoC,CAC/C,GAAI,EAAU,OAAO,EAErB,IAAM,EAAuB,EAA2B,KAAK,CAEvD,EAAqB,GAAwC,CACjE,EAAqB,IAAI,EAAgB,EAe3C,MANA,GAAW,CACT,eAAgB,EAAqB,YAAY,CACjD,oBACA,yBATgC,GAAuB,CACvD,IAAM,EAAU,GAAsB,CACjC,GACL,EAAkB,CAAE,GAAG,EAAS,UAAS,CAAC,EAO3C,CAEM,GAMI,EAA0B,GAAwB,CAC7C,GAA6B,EAOlC,EAAqB,MAA6B,CAC7D,IAAM,EAAS,GAA6B,CACtC,CAAC,EAAgB,GACrB,EACE,EAAW,iCACZ,CAEH,GAAI,CAAC,EACH,MAAU,MAAM,kCAAkC,CAoBpD,OAfA,MAAa,CACX,IAAM,EAAW,EAAO,gBAAgB,CACpC,KAAK,UAAU,EAAS,GAAK,KAAK,UAAU,GAAgB,CAAC,EAC/D,EAAkB,EAAS,EAE7B,CAGF,MAAa,CACX,IAAM,EAAW,GAAgB,CAC7B,KAAK,UAAU,EAAS,GAAK,KAAK,UAAU,EAAO,gBAAgB,CAAC,EACtE,EAAO,kBAAkB,GAAY,KAAK,EAE5C,CAEK,GACP"}
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { EditedContentRendererComponent } from "./EditedContentRenderer.component.mjs";
|
|
3
|
-
import { EditorSelectorRendererComponent } from "./EditorSelectorRenderer.component.mjs";
|
|
4
|
-
import { installIntlayerEditor } from "./installIntlayerEditor.mjs";
|
|
5
|
-
|
|
6
|
-
export { ContentSelectorWrapperComponent, EditedContentRendererComponent, EditorSelectorRendererComponent, installIntlayerEditor };
|
|
1
|
+
import{ContentSelectorWrapperComponent as e}from"./ContentSelectorWrapper.component.mjs";import{EditedContentRendererComponent as t}from"./EditedContentRenderer.component.mjs";import{EditorSelectorRendererComponent as n}from"./EditorSelectorRenderer.component.mjs";import{installIntlayerEditor as r}from"./installIntlayerEditor.mjs";export{e as ContentSelectorWrapperComponent,t as EditedContentRendererComponent,n as EditorSelectorRendererComponent,r as installIntlayerEditor};
|