@dxos/plugin-template 0.6.7 → 0.6.8-main.046e6cf
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/LICENSE +1 -1
- package/README.md +2 -8
- package/dist/lib/browser/chunk-5WVRC7MV.mjs +17 -0
- package/dist/lib/browser/chunk-5WVRC7MV.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +171 -0
- package/dist/lib/browser/index.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -0
- package/dist/lib/browser/meta.mjs +9 -0
- package/dist/lib/browser/meta.mjs.map +7 -0
- package/dist/types/src/TemplatePlugin.d.ts +4 -0
- package/dist/types/src/TemplatePlugin.d.ts.map +1 -0
- package/dist/types/src/components/TemplateMain.d.ts +6 -0
- package/dist/types/src/components/TemplateMain.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +2 -0
- package/dist/types/src/components/index.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +15 -0
- package/dist/types/src/meta.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +12 -0
- package/dist/types/src/translations.d.ts.map +1 -0
- package/dist/types/src/types.d.ts +8 -0
- package/dist/types/src/types.d.ts.map +1 -0
- package/package.json +47 -29
- package/src/TemplatePlugin.tsx +101 -0
- package/src/components/TemplateMain.tsx +28 -0
- package/src/components/index.ts +5 -0
- package/src/index.ts +5 -0
- package/src/meta.tsx +17 -0
- package/src/translations.ts +18 -0
- package/src/types.ts +32 -0
- package/.eslintrc.js +0 -9
- package/dist/src/README.md.t.d.ts +0 -18
- package/dist/src/README.md.t.d.ts.map +0 -1
- package/dist/src/README.md.t.js +0 -27
- package/dist/src/README.md.t.js.map +0 -1
- package/dist/src/composer/config.ts.t.d.ts +0 -49
- package/dist/src/composer/config.ts.t.d.ts.map +0 -1
- package/dist/src/composer/config.ts.t.js +0 -16
- package/dist/src/composer/config.ts.t.js.map +0 -1
- package/dist/src/composer/main.tsx.t.d.ts +0 -49
- package/dist/src/composer/main.tsx.t.d.ts.map +0 -1
- package/dist/src/composer/main.tsx.t.js +0 -115
- package/dist/src/composer/main.tsx.t.js.map +0 -1
- package/dist/src/composer/shell.html.t.d.ts +0 -18
- package/dist/src/composer/shell.html.t.d.ts.map +0 -1
- package/dist/src/composer/shell.html.t.js +0 -49
- package/dist/src/composer/shell.html.t.js.map +0 -1
- package/dist/src/composer/shell.ts.t.d.ts +0 -49
- package/dist/src/composer/shell.ts.t.d.ts.map +0 -1
- package/dist/src/composer/shell.ts.t.js +0 -18
- package/dist/src/composer/shell.ts.t.js.map +0 -1
- package/dist/src/composer/translations.d.ts +0 -21
- package/dist/src/composer/translations.d.ts.map +0 -1
- package/dist/src/composer/translations.js +0 -27
- package/dist/src/composer/translations.js.map +0 -1
- package/dist/src/package.json.t.d.ts +0 -55
- package/dist/src/package.json.t.d.ts.map +0 -1
- package/dist/src/package.json.t.js +0 -112
- package/dist/src/package.json.t.js.map +0 -1
- package/dist/src/src/index.ts.t.d.ts +0 -18
- package/dist/src/src/index.ts.t.d.ts.map +0 -1
- package/dist/src/src/index.ts.t.js +0 -11
- package/dist/src/src/index.ts.t.js.map +0 -1
- package/dist/src/src/plugin.tsx.t.d.ts +0 -49
- package/dist/src/src/plugin.tsx.t.d.ts.map +0 -1
- package/dist/src/src/plugin.tsx.t.js +0 -68
- package/dist/src/src/plugin.tsx.t.js.map +0 -1
- package/dist/src/template.t.d.ts +0 -16
- package/dist/src/template.t.d.ts.map +0 -1
- package/dist/src/template.t.js +0 -45
- package/dist/src/template.t.js.map +0 -1
- package/dist/src/utils.t/packageJson.d.ts +0 -6
- package/dist/src/utils.t/packageJson.d.ts.map +0 -1
- package/dist/src/utils.t/packageJson.js +0 -6
- package/dist/src/utils.t/packageJson.js.map +0 -1
- package/dist/src/vite.config.ts.t.d.ts +0 -49
- package/dist/src/vite.config.ts.t.d.ts.map +0 -1
- package/dist/src/vite.config.ts.t.js +0 -70
- package/dist/src/vite.config.ts.t.js.map +0 -1
- package/dist/test/scenarios.d.ts +0 -4
- package/dist/test/scenarios.d.ts.map +0 -1
- package/dist/test/scenarios.js +0 -19
- package/dist/test/scenarios.js.map +0 -1
- package/dist/test/template.test.d.ts +0 -2
- package/dist/test/template.test.d.ts.map +0 -1
- package/dist/test/template.test.js +0 -62
- package/dist/test/template.test.js.map +0 -1
- package/project.json +0 -28
- package/src/.npmignore.t.ts +0 -5
- package/src/README.md.t.ts +0 -22
- package/src/composer/config.ts.t.ts +0 -11
- package/src/composer/dx.yml +0 -11
- package/src/composer/index.html +0 -50
- package/src/composer/main.tsx.t.ts +0 -118
- package/src/composer/shell.html.t.ts +0 -44
- package/src/composer/shell.ts.t.ts +0 -13
- package/src/composer/translations.ts +0 -28
- package/src/package.json.t.ts +0 -116
- package/src/src/index.ts.t.ts +0 -7
- package/src/src/plugin.tsx.t.ts +0 -63
- package/src/template.t.ts +0 -40
- package/src/tsconfig.json +0 -17
- package/src/utils.t/packageJson.ts +0 -7
- package/src/vite.config.ts.t.ts +0 -65
- package/test/scenarios.ts +0 -20
- package/test/template.test.ts +0 -43
- package/tsconfig.json +0 -39
- package/tsconfig.plate.json +0 -15
package/LICENSE
CHANGED
|
@@ -5,4 +5,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
|
5
5
|
|
|
6
6
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
7
7
|
|
|
8
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
# @dxos/plugin-template
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
pnpm i @dxos/plugin-template
|
|
9
|
-
```
|
|
3
|
+
Plugin template.
|
|
10
4
|
|
|
11
5
|
## DXOS Resources
|
|
12
6
|
|
|
@@ -18,4 +12,4 @@ pnpm i @dxos/plugin-template
|
|
|
18
12
|
|
|
19
13
|
Your ideas, issues, and code are most welcome. Please take a look at our [community code of conduct](https://github.com/dxos/dxos/blob/main/CODE_OF_CONDUCT.md), the [issue guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-issues), and the [PR contribution guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-prs).
|
|
20
14
|
|
|
21
|
-
License: [MIT](./LICENSE) Copyright
|
|
15
|
+
License: [MIT](./LICENSE) Copyright 2023 © DXOS
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// packages/plugins/experimental/plugin-template/src/meta.tsx
|
|
2
|
+
import { Asterisk } from "@phosphor-icons/react";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { pluginMeta } from "@dxos/app-framework";
|
|
5
|
+
var TEMPLATE_PLUGIN = "dxos.org/plugin/template";
|
|
6
|
+
var meta_default = pluginMeta({
|
|
7
|
+
id: TEMPLATE_PLUGIN,
|
|
8
|
+
name: "Template",
|
|
9
|
+
iconComponent: (props) => /* @__PURE__ */ React.createElement(Asterisk, props),
|
|
10
|
+
iconSymbol: "ph--asterisk--regular"
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
TEMPLATE_PLUGIN,
|
|
15
|
+
meta_default
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=chunk-5WVRC7MV.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/meta.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Asterisk, type IconProps } from '@phosphor-icons/react';\nimport React from 'react';\n\nimport { pluginMeta } from '@dxos/app-framework';\n\nexport const TEMPLATE_PLUGIN = 'dxos.org/plugin/template';\n\nexport default pluginMeta({\n id: TEMPLATE_PLUGIN,\n name: 'Template',\n iconComponent: (props: IconProps) => <Asterisk {...props} />,\n iconSymbol: 'ph--asterisk--regular',\n});\n"],
|
|
5
|
+
"mappings": ";AAIA,SAASA,gBAAgC;AACzC,OAAOC,WAAW;AAElB,SAASC,kBAAkB;AAEpB,IAAMC,kBAAkB;AAE/B,IAAA,eAAeC,WAAW;EACxBC,IAAIF;EACJG,MAAM;EACNC,eAAe,CAACC,UAAqB,sBAAA,cAACC,UAAaD,KAAAA;EACnDE,YAAY;AACd,CAAA;",
|
|
6
|
+
"names": ["Asterisk", "React", "pluginMeta", "TEMPLATE_PLUGIN", "pluginMeta", "id", "name", "iconComponent", "props", "Asterisk", "iconSymbol"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TEMPLATE_PLUGIN,
|
|
3
|
+
meta_default
|
|
4
|
+
} from "./chunk-5WVRC7MV.mjs";
|
|
5
|
+
|
|
6
|
+
// packages/plugins/experimental/plugin-template/src/TemplatePlugin.tsx
|
|
7
|
+
import { Asterisk, Placeholder } from "@phosphor-icons/react";
|
|
8
|
+
import React2 from "react";
|
|
9
|
+
import { resolvePlugin, parseIntentPlugin, NavigationAction } from "@dxos/app-framework";
|
|
10
|
+
import { parseClientPlugin } from "@dxos/plugin-client";
|
|
11
|
+
import { createExtension, isActionGroup } from "@dxos/plugin-graph";
|
|
12
|
+
import { SpaceAction } from "@dxos/plugin-space";
|
|
13
|
+
import { create } from "@dxos/react-client/echo";
|
|
14
|
+
|
|
15
|
+
// packages/plugins/experimental/plugin-template/src/components/TemplateMain.tsx
|
|
16
|
+
import React from "react";
|
|
17
|
+
import { PublicKey } from "@dxos/react-client";
|
|
18
|
+
import { getSpace } from "@dxos/react-client/echo";
|
|
19
|
+
import { Main } from "@dxos/react-ui";
|
|
20
|
+
import { baseSurface, topbarBlockPaddingStart, fixedInsetFlexLayout, bottombarBlockPaddingEnd } from "@dxos/react-ui-theme";
|
|
21
|
+
var TemplateMain = ({ object }) => {
|
|
22
|
+
const space = getSpace(object);
|
|
23
|
+
return (
|
|
24
|
+
// TODO(burdon): Boilerplate.
|
|
25
|
+
/* @__PURE__ */ React.createElement(Main.Content, {
|
|
26
|
+
classNames: [
|
|
27
|
+
baseSurface,
|
|
28
|
+
fixedInsetFlexLayout,
|
|
29
|
+
topbarBlockPaddingStart,
|
|
30
|
+
bottombarBlockPaddingEnd
|
|
31
|
+
]
|
|
32
|
+
}, /* @__PURE__ */ React.createElement("pre", {
|
|
33
|
+
className: "m-4 p-2 ring"
|
|
34
|
+
}, /* @__PURE__ */ React.createElement("span", null, space?.key.truncate()), "/", /* @__PURE__ */ React.createElement("span", null, PublicKey.from(object.id).truncate())))
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// packages/plugins/experimental/plugin-template/src/translations.ts
|
|
39
|
+
var translations_default = [
|
|
40
|
+
{
|
|
41
|
+
"en-US": {
|
|
42
|
+
[TEMPLATE_PLUGIN]: {
|
|
43
|
+
"plugin name": "Template",
|
|
44
|
+
"object placeholder": "New object",
|
|
45
|
+
"create object label": "Create object",
|
|
46
|
+
"delete object label": "Delete"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
// packages/plugins/experimental/plugin-template/src/types.ts
|
|
53
|
+
import { isEchoObject } from "@dxos/react-client/echo";
|
|
54
|
+
var TEMPLATE_ACTION = `${TEMPLATE_PLUGIN}/action`;
|
|
55
|
+
var TemplateAction;
|
|
56
|
+
(function(TemplateAction2) {
|
|
57
|
+
TemplateAction2[TemplateAction2["CREATE"] = `${TEMPLATE_ACTION}/create`] = "CREATE";
|
|
58
|
+
})(TemplateAction || (TemplateAction = {}));
|
|
59
|
+
var isObject = (object) => {
|
|
60
|
+
return isEchoObject(object) && object.type === "template";
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// packages/plugins/experimental/plugin-template/src/TemplatePlugin.tsx
|
|
64
|
+
var typename = "template";
|
|
65
|
+
var TemplatePlugin = () => {
|
|
66
|
+
return {
|
|
67
|
+
meta: meta_default,
|
|
68
|
+
provides: {
|
|
69
|
+
metadata: {
|
|
70
|
+
records: {
|
|
71
|
+
[typename]: {
|
|
72
|
+
placeholder: [
|
|
73
|
+
"object placeholder",
|
|
74
|
+
{
|
|
75
|
+
ns: TEMPLATE_PLUGIN
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
icon: (props) => /* @__PURE__ */ React2.createElement(Asterisk, props),
|
|
79
|
+
iconSymbol: "ph--asterisk--regular"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
translations: translations_default,
|
|
84
|
+
graph: {
|
|
85
|
+
builder: (plugins) => {
|
|
86
|
+
const client = resolvePlugin(plugins, parseClientPlugin)?.provides.client;
|
|
87
|
+
const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.dispatch;
|
|
88
|
+
if (!client || !dispatch) {
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
return createExtension({
|
|
92
|
+
id: TemplateAction.CREATE,
|
|
93
|
+
filter: (node) => isActionGroup(node) && node.id.startsWith(SpaceAction.ADD_OBJECT),
|
|
94
|
+
actions: ({ node }) => {
|
|
95
|
+
const id = node.id.split("/").at(-1);
|
|
96
|
+
const [spaceId, objectId] = id?.split(":") ?? [];
|
|
97
|
+
const space = client.spaces.get().find((space2) => space2.id === spaceId);
|
|
98
|
+
const object = objectId && space?.db.getObjectById(objectId);
|
|
99
|
+
const target = objectId ? object : space;
|
|
100
|
+
if (!target) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
return [
|
|
104
|
+
{
|
|
105
|
+
id: `${TEMPLATE_PLUGIN}/create/${node.id}`,
|
|
106
|
+
data: async () => {
|
|
107
|
+
await dispatch([
|
|
108
|
+
{
|
|
109
|
+
plugin: TEMPLATE_PLUGIN,
|
|
110
|
+
action: TemplateAction.CREATE
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
action: SpaceAction.ADD_OBJECT,
|
|
114
|
+
data: {
|
|
115
|
+
target
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
action: NavigationAction.OPEN
|
|
120
|
+
}
|
|
121
|
+
]);
|
|
122
|
+
},
|
|
123
|
+
properties: {
|
|
124
|
+
label: [
|
|
125
|
+
"create object label",
|
|
126
|
+
{
|
|
127
|
+
ns: TEMPLATE_PLUGIN
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
icon: (props) => /* @__PURE__ */ React2.createElement(Placeholder, props),
|
|
131
|
+
iconSymbol: "ph--placeholder--regular",
|
|
132
|
+
testId: "templatePlugin.createObject"
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
];
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
surface: {
|
|
141
|
+
component: ({ data, role }) => {
|
|
142
|
+
switch (role) {
|
|
143
|
+
case "main": {
|
|
144
|
+
return isObject(data.active) ? /* @__PURE__ */ React2.createElement(TemplateMain, {
|
|
145
|
+
object: data.active
|
|
146
|
+
}) : null;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
intent: {
|
|
153
|
+
resolver: (intent) => {
|
|
154
|
+
switch (intent.action) {
|
|
155
|
+
case TemplateAction.CREATE: {
|
|
156
|
+
return {
|
|
157
|
+
data: create({
|
|
158
|
+
type: "template"
|
|
159
|
+
})
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
export {
|
|
169
|
+
TemplatePlugin
|
|
170
|
+
};
|
|
171
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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 { Asterisk, Placeholder, type IconProps } from '@phosphor-icons/react';\nimport React from 'react';\n\nimport { resolvePlugin, parseIntentPlugin, type PluginDefinition, NavigationAction } from '@dxos/app-framework';\nimport { parseClientPlugin } from '@dxos/plugin-client';\nimport { type ActionGroup, createExtension, isActionGroup } from '@dxos/plugin-graph';\nimport { SpaceAction } from '@dxos/plugin-space';\nimport { create } 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 placeholder: ['object placeholder', { ns: TEMPLATE_PLUGIN }],\n icon: (props: IconProps) => <Asterisk {...props} />,\n iconSymbol: 'ph--asterisk--regular',\n },\n },\n },\n translations,\n graph: {\n builder: (plugins) => {\n const client = resolvePlugin(plugins, parseClientPlugin)?.provides.client;\n const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.dispatch;\n if (!client || !dispatch) {\n return [];\n }\n\n return createExtension({\n id: TemplateAction.CREATE,\n filter: (node): node is ActionGroup => isActionGroup(node) && node.id.startsWith(SpaceAction.ADD_OBJECT),\n actions: ({ node }) => {\n const id = node.id.split('/').at(-1);\n const [spaceId, objectId] = id?.split(':') ?? [];\n const space = client.spaces.get().find((space) => space.id === spaceId);\n const object = objectId && space?.db.getObjectById(objectId);\n const target = objectId ? object : space;\n if (!target) {\n return;\n }\n\n return [\n {\n id: `${TEMPLATE_PLUGIN}/create/${node.id}`,\n data: async () => {\n await dispatch([\n { plugin: TEMPLATE_PLUGIN, action: TemplateAction.CREATE },\n { action: SpaceAction.ADD_OBJECT, data: { target } },\n { action: NavigationAction.OPEN },\n ]);\n },\n properties: {\n label: ['create object label', { ns: TEMPLATE_PLUGIN }],\n icon: (props: IconProps) => <Placeholder {...props} />,\n iconSymbol: 'ph--placeholder--regular',\n testId: 'templatePlugin.createObject',\n },\n },\n ];\n },\n });\n },\n },\n surface: {\n component: ({ data, role }) => {\n switch (role) {\n case 'main': {\n return isObject(data.active) ? <TemplateMain object={data.active} /> : null;\n }\n }\n\n return null;\n },\n },\n intent: {\n resolver: (intent) => {\n switch (intent.action) {\n case TemplateAction.CREATE: {\n // TODO(burdon): Set typename.\n return { data: create({ type: 'template' }) };\n }\n }\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 EchoReactiveObject, 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: EchoReactiveObject<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 GraphBuilderProvides,\n IntentResolverProvides,\n TranslationsProvides,\n SurfaceProvides,\n MetadataRecordsProvides,\n} from '@dxos/app-framework';\nimport { isEchoObject, type EchoReactiveObject } from '@dxos/react-client/echo';\n\nimport { TEMPLATE_PLUGIN } from './meta';\n\nconst TEMPLATE_ACTION = `${TEMPLATE_PLUGIN}/action`;\n\nexport enum TemplateAction {\n CREATE = `${TEMPLATE_ACTION}/create`,\n}\n\nexport type TemplatePluginProvides = SurfaceProvides &\n IntentResolverProvides &\n GraphBuilderProvides &\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 EchoReactiveObject<any> => {\n return isEchoObject(object) && object.type === 'template';\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["Asterisk", "Placeholder", "React", "resolvePlugin", "parseIntentPlugin", "NavigationAction", "parseClientPlugin", "createExtension", "isActionGroup", "SpaceAction", "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", "isEchoObject", "TEMPLATE_ACTION", "TEMPLATE_PLUGIN", "TemplateAction", "isObject", "object", "isEchoObject", "type", "typename", "TemplatePlugin", "meta", "provides", "metadata", "records", "placeholder", "ns", "TEMPLATE_PLUGIN", "icon", "props", "React", "Asterisk", "iconSymbol", "translations", "graph", "builder", "plugins", "client", "resolvePlugin", "parseClientPlugin", "dispatch", "parseIntentPlugin", "intent", "createExtension", "id", "TemplateAction", "CREATE", "filter", "node", "isActionGroup", "startsWith", "SpaceAction", "ADD_OBJECT", "actions", "split", "at", "spaceId", "objectId", "space", "spaces", "get", "find", "object", "db", "getObjectById", "target", "data", "plugin", "action", "NavigationAction", "OPEN", "properties", "label", "Placeholder", "testId", "surface", "component", "role", "isObject", "active", "TemplateMain", "resolver", "create", "type"]
|
|
7
|
+
}
|
|
@@ -0,0 +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.tsx":{"bytes":1766,"imports":[{"path":"@phosphor-icons/react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true}],"format":"esm"},"packages/plugins/experimental/plugin-template/src/translations.ts":{"bytes":1513,"imports":[{"path":"packages/plugins/experimental/plugin-template/src/meta.tsx","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/experimental/plugin-template/src/types.ts":{"bytes":2678,"imports":[{"path":"@dxos/react-client/echo","kind":"import-statement","external":true},{"path":"packages/plugins/experimental/plugin-template/src/meta.tsx","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/experimental/plugin-template/src/TemplatePlugin.tsx":{"bytes":14617,"imports":[{"path":"@phosphor-icons/react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/plugin-client","kind":"import-statement","external":true},{"path":"@dxos/plugin-graph","kind":"import-statement","external":true},{"path":"@dxos/plugin-space","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.tsx","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":10156},"packages/plugins/experimental/plugin-template/dist/lib/browser/index.mjs":{"imports":[{"path":"packages/plugins/experimental/plugin-template/dist/lib/browser/chunk-5WVRC7MV.mjs","kind":"import-statement"},{"path":"@phosphor-icons/react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/plugin-client","kind":"import-statement","external":true},{"path":"@dxos/plugin-graph","kind":"import-statement","external":true},{"path":"@dxos/plugin-space","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/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":3696},"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":381},"packages/plugins/experimental/plugin-template/src/index.ts":{"bytesInOutput":0}},"bytes":5715},"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-5WVRC7MV.mjs","kind":"import-statement"}],"exports":["TEMPLATE_PLUGIN","default"],"entryPoint":"packages/plugins/experimental/plugin-template/src/meta.tsx","inputs":{},"bytes":165},"packages/plugins/experimental/plugin-template/dist/lib/browser/chunk-5WVRC7MV.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":873},"packages/plugins/experimental/plugin-template/dist/lib/browser/chunk-5WVRC7MV.mjs":{"imports":[{"path":"@phosphor-icons/react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true}],"exports":["TEMPLATE_PLUGIN","meta_default"],"inputs":{"packages/plugins/experimental/plugin-template/src/meta.tsx":{"bytesInOutput":376}},"bytes":529}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplatePlugin.d.ts","sourceRoot":"","sources":["../../../src/TemplatePlugin.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAoC,KAAK,gBAAgB,EAAoB,MAAM,qBAAqB,CAAC;AAShH,OAAO,EAAkB,KAAK,sBAAsB,EAAY,MAAM,SAAS,CAAC;AAIhF,eAAO,MAAM,cAAc,QAAO,gBAAgB,CAAC,sBAAsB,CAgFxE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateMain.d.ts","sourceRoot":"","sources":["../../../../src/components/TemplateMain.tsx"],"names":[],"mappings":"AAIA,OAAc,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,EAAE,KAAK,kBAAkB,EAAY,MAAM,yBAAyB,CAAC;AAS5E,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC;IAAE,MAAM,EAAE,kBAAkB,CAAC,GAAG,CAAC,CAAA;CAAE,CAWhE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type IconProps } from '@phosphor-icons/react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export declare const TEMPLATE_PLUGIN = "dxos.org/plugin/template";
|
|
4
|
+
declare const _default: {
|
|
5
|
+
id: string;
|
|
6
|
+
shortId?: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
homePage?: string;
|
|
10
|
+
tags?: string[];
|
|
11
|
+
iconComponent?: React.FC<IconProps>;
|
|
12
|
+
iconSymbol?: string;
|
|
13
|
+
};
|
|
14
|
+
export default _default;
|
|
15
|
+
//# sourceMappingURL=meta.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/meta.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,eAAO,MAAM,eAAe,6BAA6B,CAAC;;;;;;;;;;;AAE1D,wBAKG"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
'en-US': {
|
|
3
|
+
"dxos.org/plugin/template": {
|
|
4
|
+
'plugin name': string;
|
|
5
|
+
'object placeholder': string;
|
|
6
|
+
'create object label': string;
|
|
7
|
+
'delete object label': string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
}[];
|
|
11
|
+
export default _default;
|
|
12
|
+
//# sourceMappingURL=translations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/translations.ts"],"names":[],"mappings":";;;;;;;;;;AAMA,wBAWE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { GraphBuilderProvides, IntentResolverProvides, TranslationsProvides, SurfaceProvides, MetadataRecordsProvides } from '@dxos/app-framework';
|
|
2
|
+
import { type EchoReactiveObject } from '@dxos/react-client/echo';
|
|
3
|
+
export declare enum TemplateAction {
|
|
4
|
+
CREATE = "dxos.org/plugin/template/action/create"
|
|
5
|
+
}
|
|
6
|
+
export type TemplatePluginProvides = SurfaceProvides & IntentResolverProvides & GraphBuilderProvides & MetadataRecordsProvides & TranslationsProvides;
|
|
7
|
+
export declare const isObject: (object: unknown) => object is EchoReactiveObject<any>;
|
|
8
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EACf,uBAAuB,EACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAgB,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAMhF,oBAAY,cAAc;IACxB,MAAM,2CAA8B;CACrC;AAED,MAAM,MAAM,sBAAsB,GAAG,eAAe,GAClD,sBAAsB,GACtB,oBAAoB,GACpB,uBAAuB,GACvB,oBAAoB,CAAC;AAIvB,eAAO,MAAM,QAAQ,WAAY,OAAO,KAAG,MAAM,IAAI,kBAAkB,CAAC,GAAG,CAE1E,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,43 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-template",
|
|
3
|
-
"version": "0.6.
|
|
4
|
-
"description": "
|
|
5
|
-
"keywords": [
|
|
6
|
-
"dxos",
|
|
7
|
-
"plugin",
|
|
8
|
-
"template",
|
|
9
|
-
"composer",
|
|
10
|
-
"local-first",
|
|
11
|
-
"offline",
|
|
12
|
-
"multiplayer"
|
|
13
|
-
],
|
|
3
|
+
"version": "0.6.8-main.046e6cf",
|
|
4
|
+
"description": "Template for new plugin",
|
|
14
5
|
"homepage": "https://dxos.org",
|
|
15
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
16
7
|
"license": "MIT",
|
|
17
|
-
"author": "
|
|
18
|
-
"
|
|
19
|
-
|
|
8
|
+
"author": "DXOS.org",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"browser": "./dist/lib/browser/index.mjs",
|
|
12
|
+
"types": "./dist/types/src/index.d.ts"
|
|
13
|
+
},
|
|
14
|
+
"./meta": {
|
|
15
|
+
"browser": "./dist/lib/browser/meta.mjs",
|
|
16
|
+
"types": "./dist/types/src/meta.d.ts"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"types": "dist/types/src/index.d.ts",
|
|
20
|
+
"typesVersions": {
|
|
21
|
+
"*": {
|
|
22
|
+
"meta": [
|
|
23
|
+
"dist/types/src/meta.d.ts"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"src"
|
|
30
|
+
],
|
|
20
31
|
"dependencies": {
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"@dxos/
|
|
32
|
+
"@preact/signals-core": "^1.6.0",
|
|
33
|
+
"@dxos/app-framework": "0.6.8-main.046e6cf",
|
|
34
|
+
"@dxos/async": "0.6.8-main.046e6cf",
|
|
35
|
+
"@dxos/plugin-graph": "0.6.8-main.046e6cf",
|
|
36
|
+
"@dxos/plugin-space": "0.6.8-main.046e6cf",
|
|
37
|
+
"@dxos/plugin-client": "0.6.8-main.046e6cf",
|
|
38
|
+
"@dxos/react-client": "0.6.8-main.046e6cf"
|
|
25
39
|
},
|
|
26
40
|
"devDependencies": {
|
|
27
41
|
"@phosphor-icons/react": "^2.1.5",
|
|
28
|
-
"@types/
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/
|
|
42
|
+
"@types/react": "~18.2.0",
|
|
43
|
+
"@types/react-dom": "~18.2.0",
|
|
44
|
+
"react": "~18.2.0",
|
|
45
|
+
"react-dom": "~18.2.0",
|
|
46
|
+
"vite": "^5.3.4",
|
|
47
|
+
"@dxos/react-ui-theme": "0.6.8-main.046e6cf",
|
|
48
|
+
"@dxos/react-ui": "0.6.8-main.046e6cf",
|
|
49
|
+
"@dxos/storybook-utils": "0.6.8-main.046e6cf"
|
|
50
|
+
},
|
|
51
|
+
"optionalDependencies": {
|
|
52
|
+
"@phosphor-icons/react": "^2.1.5",
|
|
53
|
+
"react": "^18.0.0",
|
|
54
|
+
"react-dom": "^18.0.0",
|
|
55
|
+
"@dxos/react-ui": "0.6.8-main.046e6cf",
|
|
56
|
+
"@dxos/react-ui-theme": "0.6.8-main.046e6cf"
|
|
36
57
|
},
|
|
37
58
|
"publishConfig": {
|
|
38
59
|
"access": "public"
|
|
39
|
-
},
|
|
40
|
-
"scripts": {
|
|
41
|
-
"build": "tsc"
|
|
42
60
|
}
|
|
43
61
|
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Asterisk, Placeholder, type IconProps } from '@phosphor-icons/react';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { resolvePlugin, parseIntentPlugin, type PluginDefinition, NavigationAction } from '@dxos/app-framework';
|
|
9
|
+
import { parseClientPlugin } from '@dxos/plugin-client';
|
|
10
|
+
import { type ActionGroup, createExtension, isActionGroup } from '@dxos/plugin-graph';
|
|
11
|
+
import { SpaceAction } from '@dxos/plugin-space';
|
|
12
|
+
import { create } from '@dxos/react-client/echo';
|
|
13
|
+
|
|
14
|
+
import { TemplateMain } from './components';
|
|
15
|
+
import meta, { TEMPLATE_PLUGIN } from './meta';
|
|
16
|
+
import translations from './translations';
|
|
17
|
+
import { TemplateAction, type TemplatePluginProvides, isObject } from './types';
|
|
18
|
+
|
|
19
|
+
const typename = 'template'; // Type.schema.typename
|
|
20
|
+
|
|
21
|
+
export const TemplatePlugin = (): PluginDefinition<TemplatePluginProvides> => {
|
|
22
|
+
return {
|
|
23
|
+
meta,
|
|
24
|
+
provides: {
|
|
25
|
+
metadata: {
|
|
26
|
+
records: {
|
|
27
|
+
[typename]: {
|
|
28
|
+
placeholder: ['object placeholder', { ns: TEMPLATE_PLUGIN }],
|
|
29
|
+
icon: (props: IconProps) => <Asterisk {...props} />,
|
|
30
|
+
iconSymbol: 'ph--asterisk--regular',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
translations,
|
|
35
|
+
graph: {
|
|
36
|
+
builder: (plugins) => {
|
|
37
|
+
const client = resolvePlugin(plugins, parseClientPlugin)?.provides.client;
|
|
38
|
+
const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.dispatch;
|
|
39
|
+
if (!client || !dispatch) {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return createExtension({
|
|
44
|
+
id: TemplateAction.CREATE,
|
|
45
|
+
filter: (node): node is ActionGroup => isActionGroup(node) && node.id.startsWith(SpaceAction.ADD_OBJECT),
|
|
46
|
+
actions: ({ node }) => {
|
|
47
|
+
const id = node.id.split('/').at(-1);
|
|
48
|
+
const [spaceId, objectId] = id?.split(':') ?? [];
|
|
49
|
+
const space = client.spaces.get().find((space) => space.id === spaceId);
|
|
50
|
+
const object = objectId && space?.db.getObjectById(objectId);
|
|
51
|
+
const target = objectId ? object : space;
|
|
52
|
+
if (!target) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return [
|
|
57
|
+
{
|
|
58
|
+
id: `${TEMPLATE_PLUGIN}/create/${node.id}`,
|
|
59
|
+
data: async () => {
|
|
60
|
+
await dispatch([
|
|
61
|
+
{ plugin: TEMPLATE_PLUGIN, action: TemplateAction.CREATE },
|
|
62
|
+
{ action: SpaceAction.ADD_OBJECT, data: { target } },
|
|
63
|
+
{ action: NavigationAction.OPEN },
|
|
64
|
+
]);
|
|
65
|
+
},
|
|
66
|
+
properties: {
|
|
67
|
+
label: ['create object label', { ns: TEMPLATE_PLUGIN }],
|
|
68
|
+
icon: (props: IconProps) => <Placeholder {...props} />,
|
|
69
|
+
iconSymbol: 'ph--placeholder--regular',
|
|
70
|
+
testId: 'templatePlugin.createObject',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
surface: {
|
|
79
|
+
component: ({ data, role }) => {
|
|
80
|
+
switch (role) {
|
|
81
|
+
case 'main': {
|
|
82
|
+
return isObject(data.active) ? <TemplateMain object={data.active} /> : null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return null;
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
intent: {
|
|
90
|
+
resolver: (intent) => {
|
|
91
|
+
switch (intent.action) {
|
|
92
|
+
case TemplateAction.CREATE: {
|
|
93
|
+
// TODO(burdon): Set typename.
|
|
94
|
+
return { data: create({ type: 'template' }) };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { type FC } from 'react';
|
|
6
|
+
|
|
7
|
+
import { PublicKey } from '@dxos/react-client';
|
|
8
|
+
import { type EchoReactiveObject, getSpace } from '@dxos/react-client/echo';
|
|
9
|
+
import { Main } from '@dxos/react-ui';
|
|
10
|
+
import {
|
|
11
|
+
baseSurface,
|
|
12
|
+
topbarBlockPaddingStart,
|
|
13
|
+
fixedInsetFlexLayout,
|
|
14
|
+
bottombarBlockPaddingEnd,
|
|
15
|
+
} from '@dxos/react-ui-theme';
|
|
16
|
+
|
|
17
|
+
export const TemplateMain: FC<{ object: EchoReactiveObject<any> }> = ({ object }) => {
|
|
18
|
+
const space = getSpace(object);
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
// TODO(burdon): Boilerplate.
|
|
22
|
+
<Main.Content classNames={[baseSurface, fixedInsetFlexLayout, topbarBlockPaddingStart, bottombarBlockPaddingEnd]}>
|
|
23
|
+
<pre className='m-4 p-2 ring'>
|
|
24
|
+
<span>{space?.key.truncate()}</span>/<span>{PublicKey.from(object.id).truncate()}</span>
|
|
25
|
+
</pre>
|
|
26
|
+
</Main.Content>
|
|
27
|
+
);
|
|
28
|
+
};
|
package/src/index.ts
ADDED
package/src/meta.tsx
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Asterisk, type IconProps } from '@phosphor-icons/react';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { pluginMeta } from '@dxos/app-framework';
|
|
9
|
+
|
|
10
|
+
export const TEMPLATE_PLUGIN = 'dxos.org/plugin/template';
|
|
11
|
+
|
|
12
|
+
export default pluginMeta({
|
|
13
|
+
id: TEMPLATE_PLUGIN,
|
|
14
|
+
name: 'Template',
|
|
15
|
+
iconComponent: (props: IconProps) => <Asterisk {...props} />,
|
|
16
|
+
iconSymbol: 'ph--asterisk--regular',
|
|
17
|
+
});
|