@powerhousedao/codegen 4.1.0-dev.30 → 4.1.0-dev.32
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/src/codegen/.hygen/templates/powerhouse/generate-document-model/object.esm.t +2 -2
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/ph-factories.esm.t +96 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/types.esm.t +2 -2
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/utils.esm.t +11 -11
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/CreateDocument.esm.t +1 -8
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/DriveExplorer.esm.t +0 -4
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/EditorContainer.esm.t +2 -4
- package/dist/tsconfig.hygen.tsbuildinfo +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +7 -7
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
to: "<%= rootDir %>/<%= h.changeCase.param(documentType) %>/gen/object.ts"
|
|
3
3
|
force: true
|
|
4
4
|
---
|
|
5
|
-
import { BaseDocumentClass, type
|
|
5
|
+
import { BaseDocumentClass, type BaseStateFromDocument, type PartialState, applyMixins, type SignalDispatch } from 'document-model';
|
|
6
6
|
import { <%= 'type ' + h.changeCase.pascal(documentType) %>State, <%= 'type ' + h.changeCase.pascal(documentType) %>LocalState, <%= 'type ' + h.changeCase.pascal(documentType) %>Document } from './types.js';
|
|
7
7
|
import { <%= 'type ' + h.changeCase.pascal(documentType) %>Action } from './actions.js';
|
|
8
8
|
import { reducer } from './reducer.js';
|
|
@@ -23,7 +23,7 @@ interface <%= h.changeCase.pascal(documentType) %> extends
|
|
|
23
23
|
class <%= h.changeCase.pascal(documentType) %> extends BaseDocumentClass<<%= h.changeCase.pascal(documentType) %>State, <%= h.changeCase.pascal(documentType) %>LocalState, <%= h.changeCase.pascal(documentType) %>Action> {
|
|
24
24
|
static fileExtension = '<%= extension %>';
|
|
25
25
|
|
|
26
|
-
constructor(initialState?: Partial<
|
|
26
|
+
constructor(initialState?: Partial<BaseStateFromDocument<<%= h.changeCase.pascal(documentType) %>Document>>, dispatch?: SignalDispatch) {
|
|
27
27
|
super(reducer, utils.createDocument(initialState), dispatch);
|
|
28
28
|
}
|
|
29
29
|
|
package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/ph-factories.esm.t
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: "<%= rootDir %>/<%= h.changeCase.param(documentType) %>/ph-factories.ts"
|
|
3
|
+
force: true
|
|
4
|
+
---
|
|
5
|
+
/**
|
|
6
|
+
* Factory methods for creating <%= h.changeCase.pascal(documentType) %>Document instances
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
createBaseState,
|
|
11
|
+
defaultBaseState,
|
|
12
|
+
type PHAuthState,
|
|
13
|
+
type PHDocumentState,
|
|
14
|
+
type PHBaseState,
|
|
15
|
+
} from "document-model";
|
|
16
|
+
import type {
|
|
17
|
+
<%= h.changeCase.pascal(documentType) %>Document,
|
|
18
|
+
<%= h.changeCase.pascal(documentType) %>LocalState,
|
|
19
|
+
<%= h.changeCase.pascal(documentType) %>State,
|
|
20
|
+
} from "./gen/types.js";
|
|
21
|
+
import { createDocument } from "./gen/utils.js";
|
|
22
|
+
|
|
23
|
+
export function defaultGlobalState(): <%= h.changeCase.pascal(documentType) %>State {
|
|
24
|
+
return <%- initialGlobalState %>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function defaultLocalState(): <%= h.changeCase.pascal(documentType) %>LocalState {
|
|
28
|
+
return <%- initialLocalState %>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function defaultPHState(): <%= h.changeCase.pascal(documentType) %>PHState {
|
|
32
|
+
return {
|
|
33
|
+
...defaultBaseState(),
|
|
34
|
+
global: defaultGlobalState(),
|
|
35
|
+
local: defaultLocalState(),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function createGlobalState(
|
|
40
|
+
state?: Partial<<%= h.changeCase.pascal(documentType) %>State>,
|
|
41
|
+
): <%= h.changeCase.pascal(documentType) %>State {
|
|
42
|
+
return {
|
|
43
|
+
...defaultGlobalState(),
|
|
44
|
+
...(state || {}),
|
|
45
|
+
} as <%= h.changeCase.pascal(documentType) %>State;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function createLocalState(
|
|
49
|
+
state?: Partial<<%= h.changeCase.pascal(documentType) %>LocalState>,
|
|
50
|
+
): <%= h.changeCase.pascal(documentType) %>LocalState {
|
|
51
|
+
return {
|
|
52
|
+
...defaultLocalState(),
|
|
53
|
+
...(state || {}),
|
|
54
|
+
} as <%= h.changeCase.pascal(documentType) %>LocalState;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function createState(
|
|
58
|
+
baseState?: Partial<PHBaseState>,
|
|
59
|
+
globalState?: Partial<<%= h.changeCase.pascal(documentType) %>State>,
|
|
60
|
+
localState?: Partial<<%= h.changeCase.pascal(documentType) %>LocalState>,
|
|
61
|
+
): <%= h.changeCase.pascal(documentType) %>PHState {
|
|
62
|
+
return {
|
|
63
|
+
...createBaseState(baseState?.auth, baseState?.document),
|
|
64
|
+
global: createGlobalState(globalState),
|
|
65
|
+
local: createLocalState(localState),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type <%= h.changeCase.pascal(documentType) %>PHState = PHBaseState & {
|
|
70
|
+
global: <%= h.changeCase.pascal(documentType) %>State;
|
|
71
|
+
local: <%= h.changeCase.pascal(documentType) %>LocalState;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Creates a <%= h.changeCase.pascal(documentType) %>Document with custom global and local state
|
|
76
|
+
* This properly handles the PHBaseState requirements while allowing
|
|
77
|
+
* document-specific state to be set.
|
|
78
|
+
*/
|
|
79
|
+
export function create<%= h.changeCase.pascal(documentType) %>Document(
|
|
80
|
+
state?: Partial<{
|
|
81
|
+
auth?: Partial<PHAuthState>;
|
|
82
|
+
document?: Partial<PHDocumentState>;
|
|
83
|
+
global?: Partial<<%= h.changeCase.pascal(documentType) %>State>;
|
|
84
|
+
local?: Partial<<%= h.changeCase.pascal(documentType) %>LocalState>;
|
|
85
|
+
}>,
|
|
86
|
+
): <%= h.changeCase.pascal(documentType) %>Document {
|
|
87
|
+
const document = createDocument(
|
|
88
|
+
state ? createState(
|
|
89
|
+
createBaseState(state.auth, state.document),
|
|
90
|
+
state.global,
|
|
91
|
+
state.local,
|
|
92
|
+
) : undefined
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
return document;
|
|
96
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
to: "<%= rootDir %>/<%= h.changeCase.param(documentType) %>/gen/types.ts"
|
|
3
3
|
force: true
|
|
4
4
|
---
|
|
5
|
-
import type { PHDocument,
|
|
5
|
+
import type { PHDocument, BaseStateFromDocument } from 'document-model';
|
|
6
6
|
import type { <%= h.changeCase.pascal(documentType) %>State } from './schema/types.js';
|
|
7
7
|
<% if(hasLocalSchema) { -%>
|
|
8
8
|
import type { <%= h.changeCase.pascal(documentType) %>LocalState } from './schema/types.js';
|
|
@@ -14,6 +14,6 @@ export type * from './schema/types.js';
|
|
|
14
14
|
<% if(!hasLocalSchema) { -%>
|
|
15
15
|
<%= 'type ' + h.changeCase.pascal(documentType) %>LocalState = Record<PropertyKey, never>;
|
|
16
16
|
<%} -%>
|
|
17
|
-
export type Extended<%= h.changeCase.pascal(documentType) %>State =
|
|
17
|
+
export type Extended<%= h.changeCase.pascal(documentType) %>State = BaseStateFromDocument<<%= h.changeCase.pascal(documentType) %>Document>;
|
|
18
18
|
export <%= 'type ' + h.changeCase.pascal(documentType) %>Document = PHDocument<<%= h.changeCase.pascal(documentType) %>State, <%= h.changeCase.pascal(documentType) %>LocalState>;
|
|
19
19
|
export type { <%= h.changeCase.pascal(documentType) %>State, <%= h.changeCase.pascal(documentType) %>LocalState, <%= h.changeCase.pascal(documentType) %>Action };
|
|
@@ -5,12 +5,11 @@ force: true
|
|
|
5
5
|
import {
|
|
6
6
|
type DocumentModelUtils,
|
|
7
7
|
baseCreateDocument,
|
|
8
|
-
baseCreateExtendedState,
|
|
9
8
|
baseSaveToFile,
|
|
10
9
|
baseSaveToFileHandle,
|
|
11
10
|
baseLoadFromFile,
|
|
12
11
|
baseLoadFromInput,
|
|
13
|
-
|
|
12
|
+
defaultBaseState,
|
|
14
13
|
generateId,
|
|
15
14
|
} from 'document-model';
|
|
16
15
|
import {
|
|
@@ -26,18 +25,12 @@ export const initialLocalState: <%= h.changeCase.pascal(documentType) %>LocalSta
|
|
|
26
25
|
const utils: DocumentModelUtils<<%= h.changeCase.pascal(documentType) %>Document> = {
|
|
27
26
|
fileExtension: '<%- fileExtension %>',
|
|
28
27
|
createState(state) {
|
|
29
|
-
return { ...
|
|
30
|
-
},
|
|
31
|
-
createExtendedState(extendedState) {
|
|
32
|
-
return baseCreateExtendedState(
|
|
33
|
-
{ ...extendedState },
|
|
34
|
-
utils.createState
|
|
35
|
-
);
|
|
28
|
+
return { ...defaultBaseState(), global: { ...initialGlobalState, ...state?.global }, local: { ...initialLocalState, ...state?.local } };
|
|
36
29
|
},
|
|
37
30
|
createDocument(state) {
|
|
38
31
|
const document = baseCreateDocument(
|
|
39
|
-
utils.
|
|
40
|
-
|
|
32
|
+
utils.createState,
|
|
33
|
+
state
|
|
41
34
|
);
|
|
42
35
|
|
|
43
36
|
document.header.documentType = '<%- documentTypeId %>';
|
|
@@ -61,4 +54,11 @@ const utils: DocumentModelUtils<<%= h.changeCase.pascal(documentType) %>Document
|
|
|
61
54
|
},
|
|
62
55
|
};
|
|
63
56
|
|
|
57
|
+
export const createDocument = utils.createDocument;
|
|
58
|
+
export const createState = utils.createState;
|
|
59
|
+
export const saveToFile = utils.saveToFile;
|
|
60
|
+
export const saveToFileHandle = utils.saveToFileHandle;
|
|
61
|
+
export const loadFromFile = utils.loadFromFile;
|
|
62
|
+
export const loadFromInput = utils.loadFromInput;
|
|
63
|
+
|
|
64
64
|
export default utils;
|
|
@@ -5,7 +5,6 @@ unless_exists: true
|
|
|
5
5
|
import {
|
|
6
6
|
addDocument,
|
|
7
7
|
useDocumentModelModules,
|
|
8
|
-
useEditorModules,
|
|
9
8
|
useSelectedDriveId,
|
|
10
9
|
useSelectedFolder,
|
|
11
10
|
type VetraDocumentModelModule,
|
|
@@ -20,7 +19,6 @@ export const CreateDocument = () => {
|
|
|
20
19
|
const selectedDriveId = useSelectedDriveId();
|
|
21
20
|
const selectedFolder = useSelectedFolder();
|
|
22
21
|
const documentModelModules = useDocumentModelModules();
|
|
23
|
-
const editorModules = useEditorModules();
|
|
24
22
|
|
|
25
23
|
async function handleAddDocument(module: VetraDocumentModelModule) {
|
|
26
24
|
if (!selectedDriveId) {
|
|
@@ -28,14 +26,9 @@ export const CreateDocument = () => {
|
|
|
28
26
|
}
|
|
29
27
|
await addDocument(
|
|
30
28
|
selectedDriveId,
|
|
31
|
-
`New ${module.documentModel.
|
|
29
|
+
`New ${module.documentModel.name} document`,
|
|
32
30
|
module.documentModel.id,
|
|
33
31
|
selectedFolder?.id,
|
|
34
|
-
undefined,
|
|
35
|
-
undefined,
|
|
36
|
-
editorModules?.find((e) =>
|
|
37
|
-
e.documentTypes.includes(module.documentModel.id),
|
|
38
|
-
)?.id,
|
|
39
32
|
);
|
|
40
33
|
}
|
|
41
34
|
|
|
@@ -116,10 +116,6 @@ export function DriveExplorer(props: DriveEditorProps) {
|
|
|
116
116
|
fileName,
|
|
117
117
|
documentModel.documentModel.id,
|
|
118
118
|
selectedFolder?.id,
|
|
119
|
-
undefined,
|
|
120
|
-
editorModules?.find((e) =>
|
|
121
|
-
e.documentTypes.includes(documentModel.documentModel.id),
|
|
122
|
-
)?.id,
|
|
123
119
|
);
|
|
124
120
|
|
|
125
121
|
selectedDocumentModel.current = null;
|
|
@@ -15,8 +15,6 @@ import {
|
|
|
15
15
|
useSelectedDocument,
|
|
16
16
|
useSelectedDrive,
|
|
17
17
|
} from "@powerhousedao/reactor-browser";
|
|
18
|
-
import { error } from "console";
|
|
19
|
-
import { title } from "process";
|
|
20
18
|
import { Suspense, useCallback, useState } from "react";
|
|
21
19
|
|
|
22
20
|
/**
|
|
@@ -81,7 +79,7 @@ export const EditorContainer = (props: { handleClose: () => void }) => {
|
|
|
81
79
|
onExport={onExport}
|
|
82
80
|
onShowRevisionHistory={() => setShowRevisionHistory(true)}
|
|
83
81
|
onSwitchboardLinkClick={() => {}} // Customize switchboard integration
|
|
84
|
-
title={
|
|
82
|
+
title={selectedDocument.header.name}
|
|
85
83
|
timelineButtonVisible={editorModule.config.timelineEnabled}
|
|
86
84
|
timelineItems={timelineItems.data}
|
|
87
85
|
onTimelineItemClick={setSelectedTimelineItem}
|
|
@@ -98,7 +96,7 @@ export const EditorContainer = (props: { handleClose: () => void }) => {
|
|
|
98
96
|
}}
|
|
99
97
|
dispatch={dispatch}
|
|
100
98
|
document={document}
|
|
101
|
-
error={error}
|
|
99
|
+
error={console.error}
|
|
102
100
|
/>
|
|
103
101
|
</Suspense>
|
|
104
102
|
);
|