@obelism/content 0.1.0 → 0.2.0
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 +11 -0
- package/dist/bridge.d.mts +17 -2
- package/dist/bridge.d.mts.map +1 -1
- package/dist/bridge.d.ts +17 -2
- package/dist/bridge.d.ts.map +1 -1
- package/dist/bridge.js +367 -92
- package/dist/bridge.mjs +367 -92
- package/dist/site.js +4 -0
- package/dist/site.mjs +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -77,6 +77,17 @@ const { summary } = await bridge.prompt('Make the heading shorter')
|
|
|
77
77
|
bridge.undo()
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
+
On a site signed in to edit (`@obelism/content/site`), the box also has **New
|
|
81
|
+
page**: a path (`/pricing`, or under an existing page) and what the page is
|
|
82
|
+
for. The CMS writes the page like the one the editor is on and stores it as a
|
|
83
|
+
draft, and the bridge opens it at `/` + its path. When your routes put CMS
|
|
84
|
+
pages elsewhere, say where:
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
getContentBridge({ pagePath: (path) => `/en/${path}` })
|
|
88
|
+
await bridge.createPage('/pricing', 'Our plans, for agencies') // or your own UI
|
|
89
|
+
```
|
|
90
|
+
|
|
80
91
|
The CMS runs prompts on Workers AI. To use your own model, set a prompt
|
|
81
92
|
endpoint under Space settings → Prompt editing and answer it with
|
|
82
93
|
`createPromptHandler` (it verifies the signed request; you call the model):
|
package/dist/bridge.d.mts
CHANGED
|
@@ -24,6 +24,12 @@ type BridgeState = {
|
|
|
24
24
|
type PromptResult = {
|
|
25
25
|
summary: string;
|
|
26
26
|
};
|
|
27
|
+
type CreatePageResult = {
|
|
28
|
+
summary: string;
|
|
29
|
+
entryId: string;
|
|
30
|
+
path: string;
|
|
31
|
+
url: string;
|
|
32
|
+
};
|
|
27
33
|
type ContentBridge = {
|
|
28
34
|
readonly isEditing: boolean;
|
|
29
35
|
readonly mode: 'editor' | 'site' | null;
|
|
@@ -34,6 +40,7 @@ type ContentBridge = {
|
|
|
34
40
|
prompt(prompt: string, options?: {
|
|
35
41
|
uid?: string | null;
|
|
36
42
|
}): Promise<PromptResult>;
|
|
43
|
+
createPage(path: string, prompt: string): Promise<CreatePageResult>;
|
|
37
44
|
undo(): void;
|
|
38
45
|
save(): Promise<void>;
|
|
39
46
|
publish(): Promise<void>;
|
|
@@ -64,6 +71,13 @@ type PromptLabels = {
|
|
|
64
71
|
signOut: string;
|
|
65
72
|
viewingDrafts: string;
|
|
66
73
|
selectHint: string;
|
|
74
|
+
newPage: string;
|
|
75
|
+
newPageCancel: string;
|
|
76
|
+
newPagePlaceholder: string;
|
|
77
|
+
path: string;
|
|
78
|
+
pathPlaceholder: string;
|
|
79
|
+
creating: string;
|
|
80
|
+
created: string;
|
|
67
81
|
};
|
|
68
82
|
declare const DEFAULT_PROMPT_LABELS: PromptLabels;
|
|
69
83
|
type PromptBoxOptions = {
|
|
@@ -73,10 +87,11 @@ type PromptBoxOptions = {
|
|
|
73
87
|
type BridgeOptions = {
|
|
74
88
|
url?: string | undefined;
|
|
75
89
|
prompt?: boolean | PromptBoxOptions | undefined;
|
|
90
|
+
pagePath?: ((path: string) => string) | undefined;
|
|
76
91
|
};
|
|
77
92
|
declare const peekContentBridge: () => ContentBridge | null;
|
|
78
|
-
declare const getContentBridge: ({ url, prompt, }?: BridgeOptions) => ContentBridge;
|
|
93
|
+
declare const getContentBridge: ({ url, prompt, pagePath, }?: BridgeOptions) => ContentBridge;
|
|
79
94
|
|
|
80
95
|
export { DEFAULT_PROMPT_LABELS, INITIAL_STATE, getContentBridge, peekContentBridge };
|
|
81
|
-
export type { BridgeEvent, BridgeEvents, BridgeListener, BridgeOptions, BridgeState, ContentBridge, PromptBoxOptions, PromptLabels, PromptResult };
|
|
96
|
+
export type { BridgeEvent, BridgeEvents, BridgeListener, BridgeOptions, BridgeState, ContentBridge, CreatePageResult, PromptBoxOptions, PromptLabels, PromptResult };
|
|
82
97
|
//# sourceMappingURL=bridge.d.mts.map
|
package/dist/bridge.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.d.mts","sources":["../src/bridge/createBridge.ts","../src/bridge/promptBox.ts","../src/bridge.ts"],"mappings":";;AAIA,KAAK,YAAY;AACjB;AACA,eAAe,KAAK;AACpB;AACA;AACA,WAAW,MAAM;AACjB,eAAe,MAAM;AACrB,YAAY,WAAW;AACvB;AACA,KAAK,WAAW,SAAS,YAAY;AACrC,KAAK,cAAc,WAAW,WAAW,cAAc,YAAY;AACnE,KAAK,WAAW;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,YAAY;AACjB;AACA;AACA,KAAK,aAAa;AAClB;AACA;AACA;AACA;AACA,iBAAiB,WAAW,sBAAsB,cAAc;AAChE,gBAAgB,WAAW;AAC3B;AACA;AACA,QAAQ,OAAO,CAAC,YAAY;AAC5B;AACA,YAAY,OAAO;AACnB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;AAEA,cAAc,aAAa,EAAE,WAAW;;
|
|
1
|
+
{"version":3,"file":"bridge.d.mts","sources":["../src/bridge/createBridge.ts","../src/bridge/promptBox.ts","../src/bridge.ts"],"mappings":";;AAIA,KAAK,YAAY;AACjB;AACA,eAAe,KAAK;AACpB;AACA;AACA,WAAW,MAAM;AACjB,eAAe,MAAM;AACrB,YAAY,WAAW;AACvB;AACA,KAAK,WAAW,SAAS,YAAY;AACrC,KAAK,cAAc,WAAW,WAAW,cAAc,YAAY;AACnE,KAAK,WAAW;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,YAAY;AACjB;AACA;AACA,KAAK,gBAAgB;AACrB;AACA;AACA;AACA;AACA;AACA,KAAK,aAAa;AAClB;AACA;AACA;AACA;AACA,iBAAiB,WAAW,sBAAsB,cAAc;AAChE,gBAAgB,WAAW;AAC3B;AACA;AACA,QAAQ,OAAO,CAAC,YAAY;AAC5B,8CAA8C,OAAO,CAAC,gBAAgB;AACtE;AACA,YAAY,OAAO;AACnB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;AAEA,cAAc,aAAa,EAAE,WAAW;;ACrDxC,KAAK,YAAY;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc,qBAAqB,EAAE,YAAY;AACjD,KAAK,gBAAgB;AACrB,aAAa,OAAO,CAAC,YAAY;AACjC;;AC1BA,KAAK,aAAa;AAClB;AACA,uBAAuB,gBAAgB;AACvC;AACA;AACA,cAAc,iBAAiB,QAAQ,aAAa;AACpD,cAAc,gBAAgB,gCAAgC,aAAa,KAAK,aAAa","names":[]}
|
package/dist/bridge.d.ts
CHANGED
|
@@ -24,6 +24,12 @@ type BridgeState = {
|
|
|
24
24
|
type PromptResult = {
|
|
25
25
|
summary: string;
|
|
26
26
|
};
|
|
27
|
+
type CreatePageResult = {
|
|
28
|
+
summary: string;
|
|
29
|
+
entryId: string;
|
|
30
|
+
path: string;
|
|
31
|
+
url: string;
|
|
32
|
+
};
|
|
27
33
|
type ContentBridge = {
|
|
28
34
|
readonly isEditing: boolean;
|
|
29
35
|
readonly mode: 'editor' | 'site' | null;
|
|
@@ -34,6 +40,7 @@ type ContentBridge = {
|
|
|
34
40
|
prompt(prompt: string, options?: {
|
|
35
41
|
uid?: string | null;
|
|
36
42
|
}): Promise<PromptResult>;
|
|
43
|
+
createPage(path: string, prompt: string): Promise<CreatePageResult>;
|
|
37
44
|
undo(): void;
|
|
38
45
|
save(): Promise<void>;
|
|
39
46
|
publish(): Promise<void>;
|
|
@@ -64,6 +71,13 @@ type PromptLabels = {
|
|
|
64
71
|
signOut: string;
|
|
65
72
|
viewingDrafts: string;
|
|
66
73
|
selectHint: string;
|
|
74
|
+
newPage: string;
|
|
75
|
+
newPageCancel: string;
|
|
76
|
+
newPagePlaceholder: string;
|
|
77
|
+
path: string;
|
|
78
|
+
pathPlaceholder: string;
|
|
79
|
+
creating: string;
|
|
80
|
+
created: string;
|
|
67
81
|
};
|
|
68
82
|
declare const DEFAULT_PROMPT_LABELS: PromptLabels;
|
|
69
83
|
type PromptBoxOptions = {
|
|
@@ -73,10 +87,11 @@ type PromptBoxOptions = {
|
|
|
73
87
|
type BridgeOptions = {
|
|
74
88
|
url?: string | undefined;
|
|
75
89
|
prompt?: boolean | PromptBoxOptions | undefined;
|
|
90
|
+
pagePath?: ((path: string) => string) | undefined;
|
|
76
91
|
};
|
|
77
92
|
declare const peekContentBridge: () => ContentBridge | null;
|
|
78
|
-
declare const getContentBridge: ({ url, prompt, }?: BridgeOptions) => ContentBridge;
|
|
93
|
+
declare const getContentBridge: ({ url, prompt, pagePath, }?: BridgeOptions) => ContentBridge;
|
|
79
94
|
|
|
80
95
|
export { DEFAULT_PROMPT_LABELS, INITIAL_STATE, getContentBridge, peekContentBridge };
|
|
81
|
-
export type { BridgeEvent, BridgeEvents, BridgeListener, BridgeOptions, BridgeState, ContentBridge, PromptBoxOptions, PromptLabels, PromptResult };
|
|
96
|
+
export type { BridgeEvent, BridgeEvents, BridgeListener, BridgeOptions, BridgeState, ContentBridge, CreatePageResult, PromptBoxOptions, PromptLabels, PromptResult };
|
|
82
97
|
//# sourceMappingURL=bridge.d.ts.map
|
package/dist/bridge.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.d.ts","sources":["../src/bridge/createBridge.ts","../src/bridge/promptBox.ts","../src/bridge.ts"],"mappings":";;AAIA,KAAK,YAAY;AACjB;AACA,eAAe,KAAK;AACpB;AACA;AACA,WAAW,MAAM;AACjB,eAAe,MAAM;AACrB,YAAY,WAAW;AACvB;AACA,KAAK,WAAW,SAAS,YAAY;AACrC,KAAK,cAAc,WAAW,WAAW,cAAc,YAAY;AACnE,KAAK,WAAW;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,YAAY;AACjB;AACA;AACA,KAAK,aAAa;AAClB;AACA;AACA;AACA;AACA,iBAAiB,WAAW,sBAAsB,cAAc;AAChE,gBAAgB,WAAW;AAC3B;AACA;AACA,QAAQ,OAAO,CAAC,YAAY;AAC5B;AACA,YAAY,OAAO;AACnB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;AAEA,cAAc,aAAa,EAAE,WAAW;;
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sources":["../src/bridge/createBridge.ts","../src/bridge/promptBox.ts","../src/bridge.ts"],"mappings":";;AAIA,KAAK,YAAY;AACjB;AACA,eAAe,KAAK;AACpB;AACA;AACA,WAAW,MAAM;AACjB,eAAe,MAAM;AACrB,YAAY,WAAW;AACvB;AACA,KAAK,WAAW,SAAS,YAAY;AACrC,KAAK,cAAc,WAAW,WAAW,cAAc,YAAY;AACnE,KAAK,WAAW;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,YAAY;AACjB;AACA;AACA,KAAK,gBAAgB;AACrB;AACA;AACA;AACA;AACA;AACA,KAAK,aAAa;AAClB;AACA;AACA;AACA;AACA,iBAAiB,WAAW,sBAAsB,cAAc;AAChE,gBAAgB,WAAW;AAC3B;AACA;AACA,QAAQ,OAAO,CAAC,YAAY;AAC5B,8CAA8C,OAAO,CAAC,gBAAgB;AACtE;AACA,YAAY,OAAO;AACnB,eAAe,OAAO;AACtB;AACA;AACA;AACA;AACA;AAEA,cAAc,aAAa,EAAE,WAAW;;ACrDxC,KAAK,YAAY;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc,qBAAqB,EAAE,YAAY;AACjD,KAAK,gBAAgB;AACrB,aAAa,OAAO,CAAC,YAAY;AACjC;;AC1BA,KAAK,aAAa;AAClB;AACA,uBAAuB,gBAAgB;AACvC;AACA;AACA,cAAc,iBAAiB,QAAQ,aAAa;AACpD,cAAc,gBAAgB,gCAAgC,aAAa,KAAK,aAAa","names":[]}
|