@dxos/plugin-template 0.7.4 → 0.7.5-main.499c70c
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/lib/browser/index.mjs +31 -82
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/TemplatePlugin.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +17 -4
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +13 -12
- package/src/TemplatePlugin.tsx +15 -64
- package/src/types.ts +12 -6
|
@@ -5,10 +5,7 @@ import {
|
|
|
5
5
|
|
|
6
6
|
// packages/plugins/experimental/plugin-template/src/TemplatePlugin.tsx
|
|
7
7
|
import React2 from "react";
|
|
8
|
-
import {
|
|
9
|
-
import { parseClientPlugin } from "@dxos/plugin-client";
|
|
10
|
-
import { createExtension, isActionGroup } from "@dxos/plugin-graph";
|
|
11
|
-
import { SpaceAction } from "@dxos/plugin-space";
|
|
8
|
+
import { createSurface, createIntent, createResolver } from "@dxos/app-framework";
|
|
12
9
|
import { create } from "@dxos/react-client/echo";
|
|
13
10
|
|
|
14
11
|
// packages/plugins/experimental/plugin-template/src/components/TemplateMain.tsx
|
|
@@ -49,11 +46,21 @@ var translations_default = [
|
|
|
49
46
|
];
|
|
50
47
|
|
|
51
48
|
// packages/plugins/experimental/plugin-template/src/types.ts
|
|
52
|
-
import {
|
|
53
|
-
|
|
49
|
+
import { S } from "@dxos/echo-schema";
|
|
50
|
+
import { isEchoObject, ReactiveObjectSchema } from "@dxos/react-client/echo";
|
|
54
51
|
var TemplateAction;
|
|
55
52
|
(function(TemplateAction2) {
|
|
56
|
-
|
|
53
|
+
const TEMPLATE_ACTION = `${TEMPLATE_PLUGIN}/action`;
|
|
54
|
+
class Create extends S.TaggedClass()(`${TEMPLATE_ACTION}/create`, {
|
|
55
|
+
input: S.Struct({
|
|
56
|
+
name: S.optional(S.String)
|
|
57
|
+
}),
|
|
58
|
+
output: S.Struct({
|
|
59
|
+
object: ReactiveObjectSchema
|
|
60
|
+
})
|
|
61
|
+
}) {
|
|
62
|
+
}
|
|
63
|
+
TemplateAction2.Create = Create;
|
|
57
64
|
})(TemplateAction || (TemplateAction = {}));
|
|
58
65
|
var isObject = (object) => {
|
|
59
66
|
return isEchoObject(object) && object.type === "template";
|
|
@@ -68,6 +75,7 @@ var TemplatePlugin = () => {
|
|
|
68
75
|
metadata: {
|
|
69
76
|
records: {
|
|
70
77
|
[typename]: {
|
|
78
|
+
createObject: (props) => createIntent(TemplateAction.Create, props),
|
|
71
79
|
placeholder: [
|
|
72
80
|
"object placeholder",
|
|
73
81
|
{
|
|
@@ -79,85 +87,26 @@ var TemplatePlugin = () => {
|
|
|
79
87
|
}
|
|
80
88
|
},
|
|
81
89
|
translations: translations_default,
|
|
82
|
-
graph: {
|
|
83
|
-
builder: (plugins) => {
|
|
84
|
-
const client = resolvePlugin(plugins, parseClientPlugin)?.provides.client;
|
|
85
|
-
const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.dispatch;
|
|
86
|
-
if (!client || !dispatch) {
|
|
87
|
-
return [];
|
|
88
|
-
}
|
|
89
|
-
return createExtension({
|
|
90
|
-
id: TemplateAction.CREATE,
|
|
91
|
-
filter: (node) => isActionGroup(node) && node.id.startsWith(SpaceAction.ADD_OBJECT),
|
|
92
|
-
actions: ({ node }) => {
|
|
93
|
-
const id = node.id.split("/").at(-1);
|
|
94
|
-
const [spaceId, objectId] = id?.split(":") ?? [];
|
|
95
|
-
const space = client.spaces.get().find((space2) => space2.id === spaceId);
|
|
96
|
-
const object = objectId && space?.db.getObjectById(objectId);
|
|
97
|
-
const target = objectId ? object : space;
|
|
98
|
-
if (!target) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
return [
|
|
102
|
-
{
|
|
103
|
-
id: `${TEMPLATE_PLUGIN}/create/${node.id}`,
|
|
104
|
-
data: async () => {
|
|
105
|
-
await dispatch([
|
|
106
|
-
{
|
|
107
|
-
plugin: TEMPLATE_PLUGIN,
|
|
108
|
-
action: TemplateAction.CREATE
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
action: SpaceAction.ADD_OBJECT,
|
|
112
|
-
data: {
|
|
113
|
-
target
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
action: NavigationAction.OPEN
|
|
118
|
-
}
|
|
119
|
-
]);
|
|
120
|
-
},
|
|
121
|
-
properties: {
|
|
122
|
-
label: [
|
|
123
|
-
"create object label",
|
|
124
|
-
{
|
|
125
|
-
ns: TEMPLATE_PLUGIN
|
|
126
|
-
}
|
|
127
|
-
],
|
|
128
|
-
icon: "ph--placeholder--regular",
|
|
129
|
-
testId: "templatePlugin.createObject"
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
];
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
90
|
surface: {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
return null;
|
|
147
|
-
}
|
|
91
|
+
definitions: () => createSurface({
|
|
92
|
+
id: TEMPLATE_PLUGIN,
|
|
93
|
+
role: "article",
|
|
94
|
+
filter: (data) => isObject(data.subject),
|
|
95
|
+
component: ({ data }) => /* @__PURE__ */ React2.createElement(TemplateMain, {
|
|
96
|
+
object: data.subject
|
|
97
|
+
})
|
|
98
|
+
})
|
|
148
99
|
},
|
|
149
100
|
intent: {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
};
|
|
158
|
-
}
|
|
101
|
+
resolvers: () => createResolver(TemplateAction.Create, ({ name }) => ({
|
|
102
|
+
// TODO(burdon): Set typename.
|
|
103
|
+
data: {
|
|
104
|
+
object: create({
|
|
105
|
+
type: "template",
|
|
106
|
+
name
|
|
107
|
+
})
|
|
159
108
|
}
|
|
160
|
-
}
|
|
109
|
+
}))
|
|
161
110
|
}
|
|
162
111
|
}
|
|
163
112
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/TemplatePlugin.tsx", "../../../src/components/TemplateMain.tsx", "../../../src/translations.ts", "../../../src/types.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport {
|
|
5
|
-
"mappings": ";;;;;;AAIA,OAAOA,YAAW;AAElB,
|
|
6
|
-
"names": ["React", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { type PluginDefinition, createSurface, createIntent, createResolver } from '@dxos/app-framework';\nimport { create, type ReactiveEchoObject } from '@dxos/react-client/echo';\n\nimport { TemplateMain } from './components';\nimport meta, { TEMPLATE_PLUGIN } from './meta';\nimport translations from './translations';\nimport { TemplateAction, type TemplatePluginProvides, isObject } from './types';\n\nconst typename = 'template'; // Type.schema.typename\n\nexport const TemplatePlugin = (): PluginDefinition<TemplatePluginProvides> => {\n return {\n meta,\n provides: {\n metadata: {\n records: {\n [typename]: {\n createObject: (props: { name?: string }) => createIntent(TemplateAction.Create, props),\n placeholder: ['object placeholder', { ns: TEMPLATE_PLUGIN }],\n icon: 'ph--asterisk--regular',\n },\n },\n },\n translations,\n surface: {\n definitions: () =>\n createSurface({\n id: TEMPLATE_PLUGIN,\n role: 'article',\n filter: (data): data is { subject: ReactiveEchoObject<any> } => isObject(data.subject),\n component: ({ data }) => <TemplateMain object={data.subject} />,\n }),\n },\n intent: {\n resolvers: () =>\n createResolver(TemplateAction.Create, ({ name }) => ({\n // TODO(burdon): Set typename.\n data: { object: create({ type: 'template', name }) },\n })),\n },\n },\n };\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { type FC } from 'react';\n\nimport { PublicKey } from '@dxos/react-client';\nimport { type ReactiveEchoObject, getSpace } from '@dxos/react-client/echo';\nimport { Main } from '@dxos/react-ui';\nimport {\n baseSurface,\n topbarBlockPaddingStart,\n fixedInsetFlexLayout,\n bottombarBlockPaddingEnd,\n} from '@dxos/react-ui-theme';\n\nexport const TemplateMain: FC<{ object: ReactiveEchoObject<any> }> = ({ object }) => {\n const space = getSpace(object);\n\n return (\n // TODO(burdon): Boilerplate.\n <Main.Content classNames={[baseSurface, fixedInsetFlexLayout, topbarBlockPaddingStart, bottombarBlockPaddingEnd]}>\n <pre className='m-4 p-2 ring'>\n <span>{space?.key.truncate()}</span>/<span>{PublicKey.from(object.id).truncate()}</span>\n </pre>\n </Main.Content>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { TEMPLATE_PLUGIN } from './meta';\n\nexport default [\n {\n 'en-US': {\n [TEMPLATE_PLUGIN]: {\n 'plugin name': 'Template',\n 'object placeholder': 'New object',\n 'create object label': 'Create object',\n 'delete object label': 'Delete', // TODO(burdon): Standard for actions menu.\n },\n },\n },\n];\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type {\n IntentResolverProvides,\n TranslationsProvides,\n SurfaceProvides,\n MetadataRecordsProvides,\n} from '@dxos/app-framework';\nimport { S } from '@dxos/echo-schema';\nimport { isEchoObject, ReactiveObjectSchema, type ReactiveEchoObject } from '@dxos/react-client/echo';\n\nimport { TEMPLATE_PLUGIN } from './meta';\n\nexport namespace TemplateAction {\n const TEMPLATE_ACTION = `${TEMPLATE_PLUGIN}/action`;\n\n export class Create extends S.TaggedClass<Create>()(`${TEMPLATE_ACTION}/create`, {\n input: S.Struct({\n name: S.optional(S.String),\n }),\n output: S.Struct({\n object: ReactiveObjectSchema,\n }),\n }) {}\n}\n\nexport type TemplatePluginProvides = SurfaceProvides &\n IntentResolverProvides &\n MetadataRecordsProvides &\n TranslationsProvides;\n\n// TODO(burdon): Warning: Encountered two children with the same key, `dxos.org/plugin/template`.\n// TODO(burdon): Better way to detect?\nexport const isObject = (object: unknown): object is ReactiveEchoObject<any> => {\n return isEchoObject(object) && object.type === 'template';\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;AAIA,OAAOA,YAAW;AAElB,SAAgCC,eAAeC,cAAcC,sBAAsB;AACnF,SAASC,cAAuC;;;ACHhD,OAAOC,WAAwB;AAE/B,SAASC,iBAAiB;AAC1B,SAAkCC,gBAAgB;AAClD,SAASC,YAAY;AACrB,SACEC,aACAC,yBACAC,sBACAC,gCACK;AAEA,IAAMC,eAAwD,CAAC,EAAEC,OAAM,MAAE;AAC9E,QAAMC,QAAQC,SAASF,MAAAA;AAEvB;;IAEE,sBAAA,cAACG,KAAKC,SAAO;MAACC,YAAY;QAACC;QAAaC;QAAsBC;QAAyBC;;OACrF,sBAAA,cAACC,OAAAA;MAAIC,WAAU;OACb,sBAAA,cAACC,QAAAA,MAAMX,OAAOY,IAAIC,SAAAA,CAAAA,GAAkB,KAAC,sBAAA,cAACF,QAAAA,MAAMG,UAAUC,KAAKhB,OAAOiB,EAAE,EAAEH,SAAQ,CAAA,CAAA,CAAA;;AAItF;;;ACrBA,IAAA,uBAAe;EACb;IACE,SAAS;MACP,CAACI,eAAAA,GAAkB;QACjB,eAAe;QACf,sBAAsB;QACtB,uBAAuB;QACvB,uBAAuB;MACzB;IACF;EACF;;;;ACNF,SAASC,SAAS;AAClB,SAASC,cAAcC,4BAAqD;;UAI3DC,iBAAAA;AACf,QAAMC,kBAAkB,GAAGC,eAAAA;EAEpB,MAAMC,eAAeC,EAAEC,YAAW,EAAW,GAAGJ,eAAAA,WAA0B;IAC/EK,OAAOF,EAAEG,OAAO;MACdC,MAAMJ,EAAEK,SAASL,EAAEM,MAAM;IAC3B,CAAA;IACAC,QAAQP,EAAEG,OAAO;MACfK,QAAQC;IACV,CAAA;EACF,CAAA,EAAA;EAAI;kBAPSV,SAAAA;AAQf,GAXiBH,mBAAAA,iBAAAA,CAAAA,EAAAA;AAoBV,IAAMc,WAAW,CAACF,WAAAA;AACvB,SAAOG,aAAaH,MAAAA,KAAWA,OAAOI,SAAS;AACjD;;;AHvBA,IAAMC,WAAW;AAEV,IAAMC,iBAAiB,MAAA;AAC5B,SAAO;IACLC;IACAC,UAAU;MACRC,UAAU;QACRC,SAAS;UACP,CAACL,QAAAA,GAAW;YACVM,cAAc,CAACC,UAA6BC,aAAaC,eAAeC,QAAQH,KAAAA;YAChFI,aAAa;cAAC;cAAsB;gBAAEC,IAAIC;cAAgB;;YAC1DC,MAAM;UACR;QACF;MACF;MACAC;MACAC,SAAS;QACPC,aAAa,MACXC,cAAc;UACZC,IAAIN;UACJO,MAAM;UACNC,QAAQ,CAACC,SAAuDC,SAASD,KAAKE,OAAO;UACrFC,WAAW,CAAC,EAAEH,KAAI,MAAO,gBAAAI,OAAA,cAACC,cAAAA;YAAaC,QAAQN,KAAKE;;QACtD,CAAA;MACJ;MACAK,QAAQ;QACNC,WAAW,MACTC,eAAetB,eAAeC,QAAQ,CAAC,EAAEsB,KAAI,OAAQ;;UAEnDV,MAAM;YAAEM,QAAQK,OAAO;cAAEC,MAAM;cAAYF;YAAK,CAAA;UAAG;QACrD,EAAA;MACJ;IACF;EACF;AACF;",
|
|
6
|
+
"names": ["React", "createSurface", "createIntent", "createResolver", "create", "React", "PublicKey", "getSpace", "Main", "baseSurface", "topbarBlockPaddingStart", "fixedInsetFlexLayout", "bottombarBlockPaddingEnd", "TemplateMain", "object", "space", "getSpace", "Main", "Content", "classNames", "baseSurface", "fixedInsetFlexLayout", "topbarBlockPaddingStart", "bottombarBlockPaddingEnd", "pre", "className", "span", "key", "truncate", "PublicKey", "from", "id", "TEMPLATE_PLUGIN", "S", "isEchoObject", "ReactiveObjectSchema", "TemplateAction", "TEMPLATE_ACTION", "TEMPLATE_PLUGIN", "Create", "S", "TaggedClass", "input", "Struct", "name", "optional", "String", "output", "object", "ReactiveObjectSchema", "isObject", "isEchoObject", "type", "typename", "TemplatePlugin", "meta", "provides", "metadata", "records", "createObject", "props", "createIntent", "TemplateAction", "Create", "placeholder", "ns", "TEMPLATE_PLUGIN", "icon", "translations", "surface", "definitions", "createSurface", "id", "role", "filter", "data", "isObject", "subject", "component", "React", "TemplateMain", "object", "intent", "resolvers", "createResolver", "name", "create", "type"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/plugins/experimental/plugin-template/src/components/TemplateMain.tsx":{"bytes":3412,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-client","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true}],"format":"esm"},"packages/plugins/experimental/plugin-template/src/components/index.ts":{"bytes":540,"imports":[{"path":"packages/plugins/experimental/plugin-template/src/components/TemplateMain.tsx","kind":"import-statement","original":"./TemplateMain"}],"format":"esm"},"packages/plugins/experimental/plugin-template/src/meta.ts":{"bytes":1340,"imports":[],"format":"esm"},"packages/plugins/experimental/plugin-template/src/translations.ts":{"bytes":1513,"imports":[{"path":"packages/plugins/experimental/plugin-template/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/experimental/plugin-template/src/types.ts":{"bytes":
|
|
1
|
+
{"inputs":{"packages/plugins/experimental/plugin-template/src/components/TemplateMain.tsx":{"bytes":3412,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-client","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true}],"format":"esm"},"packages/plugins/experimental/plugin-template/src/components/index.ts":{"bytes":540,"imports":[{"path":"packages/plugins/experimental/plugin-template/src/components/TemplateMain.tsx","kind":"import-statement","original":"./TemplateMain"}],"format":"esm"},"packages/plugins/experimental/plugin-template/src/meta.ts":{"bytes":1340,"imports":[],"format":"esm"},"packages/plugins/experimental/plugin-template/src/translations.ts":{"bytes":1513,"imports":[{"path":"packages/plugins/experimental/plugin-template/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/experimental/plugin-template/src/types.ts":{"bytes":3663,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"packages/plugins/experimental/plugin-template/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/experimental/plugin-template/src/TemplatePlugin.tsx":{"bytes":6223,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"packages/plugins/experimental/plugin-template/src/components/index.ts","kind":"import-statement","original":"./components"},{"path":"packages/plugins/experimental/plugin-template/src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"packages/plugins/experimental/plugin-template/src/translations.ts","kind":"import-statement","original":"./translations"},{"path":"packages/plugins/experimental/plugin-template/src/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"packages/plugins/experimental/plugin-template/src/index.ts":{"bytes":535,"imports":[{"path":"packages/plugins/experimental/plugin-template/src/TemplatePlugin.tsx","kind":"import-statement","original":"./TemplatePlugin"}],"format":"esm"}},"outputs":{"packages/plugins/experimental/plugin-template/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":7001},"packages/plugins/experimental/plugin-template/dist/lib/browser/index.mjs":{"imports":[{"path":"packages/plugins/experimental/plugin-template/dist/lib/browser/chunk-CPSXHPOD.mjs","kind":"import-statement"},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-client","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/react-client/echo","kind":"import-statement","external":true}],"exports":["TemplatePlugin"],"entryPoint":"packages/plugins/experimental/plugin-template/src/index.ts","inputs":{"packages/plugins/experimental/plugin-template/src/TemplatePlugin.tsx":{"bytesInOutput":1291},"packages/plugins/experimental/plugin-template/src/components/TemplateMain.tsx":{"bytesInOutput":876},"packages/plugins/experimental/plugin-template/src/components/index.ts":{"bytesInOutput":0},"packages/plugins/experimental/plugin-template/src/translations.ts":{"bytesInOutput":263},"packages/plugins/experimental/plugin-template/src/types.ts":{"bytesInOutput":603},"packages/plugins/experimental/plugin-template/src/index.ts":{"bytesInOutput":0}},"bytes":3532},"packages/plugins/experimental/plugin-template/dist/lib/browser/meta.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/plugins/experimental/plugin-template/dist/lib/browser/meta.mjs":{"imports":[{"path":"packages/plugins/experimental/plugin-template/dist/lib/browser/chunk-CPSXHPOD.mjs","kind":"import-statement"}],"exports":["TEMPLATE_PLUGIN","default"],"entryPoint":"packages/plugins/experimental/plugin-template/src/meta.ts","inputs":{},"bytes":165},"packages/plugins/experimental/plugin-template/dist/lib/browser/chunk-CPSXHPOD.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":630},"packages/plugins/experimental/plugin-template/dist/lib/browser/chunk-CPSXHPOD.mjs":{"imports":[],"exports":["TEMPLATE_PLUGIN","meta_default"],"inputs":{"packages/plugins/experimental/plugin-template/src/meta.ts":{"bytesInOutput":247}},"bytes":399}}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemplatePlugin.d.ts","sourceRoot":"","sources":["../../../src/TemplatePlugin.tsx"],"names":[],"mappings":"AAMA,OAAO,
|
|
1
|
+
{"version":3,"file":"TemplatePlugin.d.ts","sourceRoot":"","sources":["../../../src/TemplatePlugin.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,gBAAgB,EAA+C,MAAM,qBAAqB,CAAC;AAMzG,OAAO,EAAkB,KAAK,sBAAsB,EAAY,MAAM,SAAS,CAAC;AAIhF,eAAO,MAAM,cAAc,QAAO,gBAAgB,CAAC,sBAAsB,CAgCxE,CAAC"}
|
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IntentResolverProvides, TranslationsProvides, SurfaceProvides, MetadataRecordsProvides } from '@dxos/app-framework';
|
|
2
|
+
import { S } from '@dxos/echo-schema';
|
|
2
3
|
import { type ReactiveEchoObject } from '@dxos/react-client/echo';
|
|
3
|
-
export declare
|
|
4
|
-
|
|
4
|
+
export declare namespace TemplateAction {
|
|
5
|
+
const Create_base: S.TaggedClass<Create, "dxos.org/plugin/template/action/create", {
|
|
6
|
+
readonly _tag: S.tag<"dxos.org/plugin/template/action/create">;
|
|
7
|
+
} & {
|
|
8
|
+
input: S.Struct<{
|
|
9
|
+
name: S.optional<typeof S.String>;
|
|
10
|
+
}>;
|
|
11
|
+
output: S.Struct<{
|
|
12
|
+
object: S.Schema<import("@dxos/react-client/echo").ReactiveObject<any>, import("@dxos/react-client/echo").ReactiveObject<any>, never>;
|
|
13
|
+
}>;
|
|
14
|
+
}>;
|
|
15
|
+
export class Create extends Create_base {
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
5
18
|
}
|
|
6
|
-
export type TemplatePluginProvides = SurfaceProvides & IntentResolverProvides &
|
|
19
|
+
export type TemplatePluginProvides = SurfaceProvides & IntentResolverProvides & MetadataRecordsProvides & TranslationsProvides;
|
|
7
20
|
export declare const isObject: (object: unknown) => object is ReactiveEchoObject<any>;
|
|
8
21
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EACf,uBAAuB,EACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AACtC,OAAO,EAAsC,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAItG,yBAAiB,cAAc,CAAC;;;;;;;;;;;IAG9B,MAAM,OAAO,MAAO,SAAQ,WAO1B;KAAG;;CACN;AAED,MAAM,MAAM,sBAAsB,GAAG,eAAe,GAClD,sBAAsB,GACtB,uBAAuB,GACvB,oBAAoB,CAAC;AAIvB,eAAO,MAAM,QAAQ,WAAY,OAAO,KAAG,MAAM,IAAI,kBAAkB,CAAC,GAAG,CAE1E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"5.7.2"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-template",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5-main.499c70c",
|
|
4
4
|
"description": "Template for new plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -31,12 +31,13 @@
|
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@preact/signals-core": "^1.6.0",
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/plugin-client": "0.7.
|
|
38
|
-
"@dxos/plugin-
|
|
39
|
-
"@dxos/plugin-
|
|
34
|
+
"@dxos/async": "0.7.5-main.499c70c",
|
|
35
|
+
"@dxos/app-framework": "0.7.5-main.499c70c",
|
|
36
|
+
"@dxos/echo-schema": "0.7.5-main.499c70c",
|
|
37
|
+
"@dxos/plugin-client": "0.7.5-main.499c70c",
|
|
38
|
+
"@dxos/plugin-graph": "0.7.5-main.499c70c",
|
|
39
|
+
"@dxos/plugin-space": "0.7.5-main.499c70c",
|
|
40
|
+
"@dxos/react-client": "0.7.5-main.499c70c"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
43
|
"@phosphor-icons/react": "^2.1.5",
|
|
@@ -45,16 +46,16 @@
|
|
|
45
46
|
"react": "~18.2.0",
|
|
46
47
|
"react-dom": "~18.2.0",
|
|
47
48
|
"vite": "5.4.7",
|
|
48
|
-
"@dxos/react-ui": "0.7.
|
|
49
|
-
"@dxos/react-ui-theme": "0.7.
|
|
50
|
-
"@dxos/storybook-utils": "0.7.
|
|
49
|
+
"@dxos/react-ui": "0.7.5-main.499c70c",
|
|
50
|
+
"@dxos/react-ui-theme": "0.7.5-main.499c70c",
|
|
51
|
+
"@dxos/storybook-utils": "0.7.5-main.499c70c"
|
|
51
52
|
},
|
|
52
53
|
"peerDependencies": {
|
|
53
54
|
"@phosphor-icons/react": "^2.1.5",
|
|
54
55
|
"react": "~18.2.0",
|
|
55
56
|
"react-dom": "~18.2.0",
|
|
56
|
-
"@dxos/react-ui": "0.7.
|
|
57
|
-
"@dxos/react-ui-theme": "0.7.
|
|
57
|
+
"@dxos/react-ui": "0.7.5-main.499c70c",
|
|
58
|
+
"@dxos/react-ui-theme": "0.7.5-main.499c70c"
|
|
58
59
|
},
|
|
59
60
|
"publishConfig": {
|
|
60
61
|
"access": "public"
|
package/src/TemplatePlugin.tsx
CHANGED
|
@@ -4,11 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { type ActionGroup, createExtension, isActionGroup } from '@dxos/plugin-graph';
|
|
10
|
-
import { SpaceAction } from '@dxos/plugin-space';
|
|
11
|
-
import { create } from '@dxos/react-client/echo';
|
|
7
|
+
import { type PluginDefinition, createSurface, createIntent, createResolver } from '@dxos/app-framework';
|
|
8
|
+
import { create, type ReactiveEchoObject } from '@dxos/react-client/echo';
|
|
12
9
|
|
|
13
10
|
import { TemplateMain } from './components';
|
|
14
11
|
import meta, { TEMPLATE_PLUGIN } from './meta';
|
|
@@ -24,74 +21,28 @@ export const TemplatePlugin = (): PluginDefinition<TemplatePluginProvides> => {
|
|
|
24
21
|
metadata: {
|
|
25
22
|
records: {
|
|
26
23
|
[typename]: {
|
|
24
|
+
createObject: (props: { name?: string }) => createIntent(TemplateAction.Create, props),
|
|
27
25
|
placeholder: ['object placeholder', { ns: TEMPLATE_PLUGIN }],
|
|
28
26
|
icon: 'ph--asterisk--regular',
|
|
29
27
|
},
|
|
30
28
|
},
|
|
31
29
|
},
|
|
32
30
|
translations,
|
|
33
|
-
graph: {
|
|
34
|
-
builder: (plugins) => {
|
|
35
|
-
const client = resolvePlugin(plugins, parseClientPlugin)?.provides.client;
|
|
36
|
-
const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.dispatch;
|
|
37
|
-
if (!client || !dispatch) {
|
|
38
|
-
return [];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return createExtension({
|
|
42
|
-
id: TemplateAction.CREATE,
|
|
43
|
-
filter: (node): node is ActionGroup => isActionGroup(node) && node.id.startsWith(SpaceAction.ADD_OBJECT),
|
|
44
|
-
actions: ({ node }) => {
|
|
45
|
-
const id = node.id.split('/').at(-1);
|
|
46
|
-
const [spaceId, objectId] = id?.split(':') ?? [];
|
|
47
|
-
const space = client.spaces.get().find((space) => space.id === spaceId);
|
|
48
|
-
const object = objectId && space?.db.getObjectById(objectId);
|
|
49
|
-
const target = objectId ? object : space;
|
|
50
|
-
if (!target) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return [
|
|
55
|
-
{
|
|
56
|
-
id: `${TEMPLATE_PLUGIN}/create/${node.id}`,
|
|
57
|
-
data: async () => {
|
|
58
|
-
await dispatch([
|
|
59
|
-
{ plugin: TEMPLATE_PLUGIN, action: TemplateAction.CREATE },
|
|
60
|
-
{ action: SpaceAction.ADD_OBJECT, data: { target } },
|
|
61
|
-
{ action: NavigationAction.OPEN },
|
|
62
|
-
]);
|
|
63
|
-
},
|
|
64
|
-
properties: {
|
|
65
|
-
label: ['create object label', { ns: TEMPLATE_PLUGIN }],
|
|
66
|
-
icon: 'ph--placeholder--regular',
|
|
67
|
-
testId: 'templatePlugin.createObject',
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
];
|
|
71
|
-
},
|
|
72
|
-
});
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
31
|
surface: {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return null;
|
|
84
|
-
},
|
|
32
|
+
definitions: () =>
|
|
33
|
+
createSurface({
|
|
34
|
+
id: TEMPLATE_PLUGIN,
|
|
35
|
+
role: 'article',
|
|
36
|
+
filter: (data): data is { subject: ReactiveEchoObject<any> } => isObject(data.subject),
|
|
37
|
+
component: ({ data }) => <TemplateMain object={data.subject} />,
|
|
38
|
+
}),
|
|
85
39
|
},
|
|
86
40
|
intent: {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
},
|
|
41
|
+
resolvers: () =>
|
|
42
|
+
createResolver(TemplateAction.Create, ({ name }) => ({
|
|
43
|
+
// TODO(burdon): Set typename.
|
|
44
|
+
data: { object: create({ type: 'template', name }) },
|
|
45
|
+
})),
|
|
95
46
|
},
|
|
96
47
|
},
|
|
97
48
|
};
|
package/src/types.ts
CHANGED
|
@@ -3,25 +3,31 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import type {
|
|
6
|
-
GraphBuilderProvides,
|
|
7
6
|
IntentResolverProvides,
|
|
8
7
|
TranslationsProvides,
|
|
9
8
|
SurfaceProvides,
|
|
10
9
|
MetadataRecordsProvides,
|
|
11
10
|
} from '@dxos/app-framework';
|
|
12
|
-
import {
|
|
11
|
+
import { S } from '@dxos/echo-schema';
|
|
12
|
+
import { isEchoObject, ReactiveObjectSchema, type ReactiveEchoObject } from '@dxos/react-client/echo';
|
|
13
13
|
|
|
14
14
|
import { TEMPLATE_PLUGIN } from './meta';
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
export namespace TemplateAction {
|
|
17
|
+
const TEMPLATE_ACTION = `${TEMPLATE_PLUGIN}/action`;
|
|
17
18
|
|
|
18
|
-
export
|
|
19
|
-
|
|
19
|
+
export class Create extends S.TaggedClass<Create>()(`${TEMPLATE_ACTION}/create`, {
|
|
20
|
+
input: S.Struct({
|
|
21
|
+
name: S.optional(S.String),
|
|
22
|
+
}),
|
|
23
|
+
output: S.Struct({
|
|
24
|
+
object: ReactiveObjectSchema,
|
|
25
|
+
}),
|
|
26
|
+
}) {}
|
|
20
27
|
}
|
|
21
28
|
|
|
22
29
|
export type TemplatePluginProvides = SurfaceProvides &
|
|
23
30
|
IntentResolverProvides &
|
|
24
|
-
GraphBuilderProvides &
|
|
25
31
|
MetadataRecordsProvides &
|
|
26
32
|
TranslationsProvides;
|
|
27
33
|
|