@atomm-developer/generator-workbench 0.1.0 → 0.1.2
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/README.md +31 -3
- package/dist/index.d.ts +39 -6
- package/dist/index.es.js +1136 -309
- package/dist/index.umd.js +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -6,8 +6,9 @@ V1 provides:
|
|
|
6
6
|
|
|
7
7
|
- Web Component shell
|
|
8
8
|
- login / avatar / logout entry
|
|
9
|
-
-
|
|
10
|
-
-
|
|
9
|
+
- credits badge and export credit hint
|
|
10
|
+
- local template import entry and template publish modal
|
|
11
|
+
- billing-backed export actions
|
|
11
12
|
- runtime panel / canvas mounting
|
|
12
13
|
|
|
13
14
|
## Install
|
|
@@ -21,7 +22,7 @@ pnpm add @atomm-developer/generator-workbench
|
|
|
21
22
|
|
|
22
23
|
```html
|
|
23
24
|
<script src="https://static-res.atomm.com/scripts/js/generator-sdk/index.umd.js"></script>
|
|
24
|
-
<script src="https://static-res.atomm.com/scripts/js/generator-workbench/index.umd.js"></script>
|
|
25
|
+
<script src="https://static-res.atomm.com/scripts/js/generator-sdk/generator-workbench/index.umd.js"></script>
|
|
25
26
|
```
|
|
26
27
|
|
|
27
28
|
## Usage
|
|
@@ -38,6 +39,7 @@ workbench.sdk = sdk
|
|
|
38
39
|
workbench.runtime = runtime
|
|
39
40
|
workbench.config = {
|
|
40
41
|
title: 'My Generator',
|
|
42
|
+
mode: 'full',
|
|
41
43
|
templateEnabled: true,
|
|
42
44
|
exportEnabled: true,
|
|
43
45
|
studioEnabled: true,
|
|
@@ -46,6 +48,32 @@ workbench.config = {
|
|
|
46
48
|
await workbench.mount()
|
|
47
49
|
```
|
|
48
50
|
|
|
51
|
+
## Shell Modes
|
|
52
|
+
|
|
53
|
+
- `mode: 'full'` keeps the default shell with the top bar and the sidebar footer export area.
|
|
54
|
+
- `mode: 'template'` hides the top bar, keeps `#sidebar-footer`, and is useful when the host page already owns branding and login UI.
|
|
55
|
+
|
|
56
|
+
In `template` mode, the host shell can pass an external token into the workbench:
|
|
57
|
+
|
|
58
|
+
```js
|
|
59
|
+
await workbench.setAuthToken(token)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
This writes the token to `localStorage` using the SDK app key and then syncs the login state through `sdk.auth.syncToken(token)`.
|
|
63
|
+
|
|
64
|
+
## Billing Behavior
|
|
65
|
+
|
|
66
|
+
- When `sdk.credits` and `sdk.billing` are available, the top bar shows the current credits balance after login.
|
|
67
|
+
- The export trigger shows the current `creditsPerUse` hint from `sdk.billing.getUsage()`.
|
|
68
|
+
- `exportSvg()` and `openInStudio()` now follow the standard generator flow: ensure login first, then call `sdk.billing.consume()`, then perform the export action.
|
|
69
|
+
|
|
70
|
+
## Template Publish Behavior
|
|
71
|
+
|
|
72
|
+
- Clicking the top bar template publish action no longer downloads immediately.
|
|
73
|
+
- `generator-workbench` reads `runtime.getPanelSchema()`, renders the generator's own field groups in a modal, and preselects exportable `bind.path` fields.
|
|
74
|
+
- The template JSON is downloaded only after the user confirms the selected fields.
|
|
75
|
+
- `config.getTemplateFieldPaths()` still works as the default subset for the publish modal.
|
|
76
|
+
|
|
49
77
|
## Local Preview
|
|
50
78
|
|
|
51
79
|
```bash
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { AuthStatus } from '@atomm-developer/generator-sdk';
|
|
2
|
+
import { BillingChangeCallback } from '@atomm-developer/generator-sdk';
|
|
3
|
+
import { BillingCheckResult } from '@atomm-developer/generator-sdk';
|
|
4
|
+
import { BillingConsumeOptions } from '@atomm-developer/generator-sdk';
|
|
5
|
+
import { BillingConsumeResult } from '@atomm-developer/generator-sdk';
|
|
2
6
|
import { ExportDownloadResult } from '@atomm-developer/generator-sdk';
|
|
3
7
|
import { ExportOpenInStudioResult } from '@atomm-developer/generator-sdk';
|
|
4
8
|
import { GeneratorTemplateDefinition } from '@atomm-developer/generator-sdk';
|
|
5
9
|
import { PanelFilter } from '@atomm-developer/generator-sdk';
|
|
6
10
|
import { PanelSchema } from '@atomm-developer/generator-sdk';
|
|
7
11
|
import { TemplateBuildOptions } from '@atomm-developer/generator-sdk';
|
|
12
|
+
import { UsageInfo } from '@atomm-developer/generator-sdk';
|
|
8
13
|
import { UserInfo } from '@atomm-developer/generator-sdk';
|
|
9
14
|
|
|
10
15
|
export declare function defineGeneratorWorkbench(tagName?: string): typeof GeneratorWorkbenchElement;
|
|
@@ -33,12 +38,29 @@ export declare interface GeneratorRuntimeLike {
|
|
|
33
38
|
}
|
|
34
39
|
|
|
35
40
|
export declare interface GeneratorSDKLike {
|
|
41
|
+
getAppKey?(): string;
|
|
36
42
|
auth: {
|
|
37
43
|
getStatus(): AuthStatus;
|
|
44
|
+
syncToken?(token: string): Promise<AuthStatus> | AuthStatus;
|
|
38
45
|
login(): Promise<UserInfo>;
|
|
39
46
|
logout(): Promise<void>;
|
|
40
47
|
onChange(callback: (status: AuthStatus) => void): () => void;
|
|
41
48
|
};
|
|
49
|
+
credits?: {
|
|
50
|
+
getBalance(): Promise<{
|
|
51
|
+
quota: number;
|
|
52
|
+
}>;
|
|
53
|
+
getCachedBalance?(): number;
|
|
54
|
+
onChange?(callback: (balance: number) => void): () => void;
|
|
55
|
+
};
|
|
56
|
+
billing?: {
|
|
57
|
+
getUsage(): Promise<UsageInfo>;
|
|
58
|
+
getCachedUsage?(): UsageInfo | null;
|
|
59
|
+
check?(): BillingCheckResult;
|
|
60
|
+
consume(options?: BillingConsumeOptions): Promise<BillingConsumeResult>;
|
|
61
|
+
refreshCredits?(): Promise<void>;
|
|
62
|
+
onChange?(callback: BillingChangeCallback): () => void;
|
|
63
|
+
};
|
|
42
64
|
template: {
|
|
43
65
|
build(args: TemplateBuildOptions): GeneratorTemplateDefinition;
|
|
44
66
|
parse(text: string): GeneratorTemplateDefinition;
|
|
@@ -69,6 +91,7 @@ export declare interface GeneratorWorkbenchActionHookContext {
|
|
|
69
91
|
|
|
70
92
|
export declare interface GeneratorWorkbenchConfig {
|
|
71
93
|
title: string;
|
|
94
|
+
mode?: 'full' | 'template';
|
|
72
95
|
logoText?: string;
|
|
73
96
|
logoUrl?: string;
|
|
74
97
|
logoHref?: string;
|
|
@@ -78,6 +101,8 @@ export declare interface GeneratorWorkbenchConfig {
|
|
|
78
101
|
autoMount?: boolean;
|
|
79
102
|
panelTarget?: 'left' | 'right';
|
|
80
103
|
avatarMenuTrigger?: 'hover' | 'click';
|
|
104
|
+
/** Override the default atomm-ui CDN CSS URL injected into Shadow DOM */
|
|
105
|
+
atommUiCssUrl?: string;
|
|
81
106
|
runtimePanelFilter?: PanelFilter;
|
|
82
107
|
getTemplateMeta?: () => Record<string, unknown>;
|
|
83
108
|
getTemplateFieldPaths?: (panelSchema: PanelSchema) => string[];
|
|
@@ -90,14 +115,16 @@ export declare class GeneratorWorkbenchElement extends HTMLElement {
|
|
|
90
115
|
private _sdk;
|
|
91
116
|
private _runtime;
|
|
92
117
|
private _config;
|
|
93
|
-
private _refs;
|
|
94
118
|
private _mounted;
|
|
95
119
|
private _state;
|
|
96
120
|
private _cleanupAuth?;
|
|
121
|
+
private _cleanupCredits?;
|
|
122
|
+
private _cleanupBilling?;
|
|
97
123
|
private _authController?;
|
|
98
124
|
private _templateController?;
|
|
99
125
|
private _exportController?;
|
|
100
126
|
private _runtimeController?;
|
|
127
|
+
private _shellContext?;
|
|
101
128
|
constructor();
|
|
102
129
|
get sdk(): GeneratorSDKLike | null;
|
|
103
130
|
set sdk(value: GeneratorSDKLike | null);
|
|
@@ -112,17 +139,23 @@ export declare class GeneratorWorkbenchElement extends HTMLElement {
|
|
|
112
139
|
refreshLayout(): void;
|
|
113
140
|
importTemplate(file: File): Promise<void>;
|
|
114
141
|
exportTemplate(): Promise<void>;
|
|
142
|
+
exportTemplateWithFields(selectedFieldPaths?: string[]): Promise<void>;
|
|
115
143
|
exportSvg(): Promise<void>;
|
|
116
144
|
openInStudio(): Promise<void>;
|
|
145
|
+
setAuthToken(token: string): Promise<void>;
|
|
117
146
|
private render;
|
|
118
147
|
private bindControllers;
|
|
119
|
-
private
|
|
148
|
+
private bindShellCallbacks;
|
|
149
|
+
private openTemplateExportDialog;
|
|
150
|
+
private closeTemplateExportDialog;
|
|
151
|
+
private toggleTemplateExportField;
|
|
120
152
|
private bindAuthState;
|
|
153
|
+
private bindBillingSubscriptions;
|
|
121
154
|
private syncAuthUI;
|
|
122
|
-
private
|
|
123
|
-
private
|
|
124
|
-
private
|
|
125
|
-
private
|
|
155
|
+
private syncBillingUI;
|
|
156
|
+
private applyBillingUsage;
|
|
157
|
+
private resetBillingState;
|
|
158
|
+
private syncBillingState;
|
|
126
159
|
private handleLogin;
|
|
127
160
|
private handleLogout;
|
|
128
161
|
private handleError;
|