@celljs/ta-web 4.13.1 → 4.15.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.en.md +3 -3
- package/README.md +3 -3
- package/esm/browser/assistant/assistant-extension.js +3 -2
- package/esm/browser/assistant/assistant-initiative.js +1 -1
- package/esm/browser/assistant/assistant-state.js +2 -2
- package/esm/browser/components/access-view.js +3 -2
- package/esm/browser/components/account-menu.js +2 -2
- package/esm/browser/components/app-view.js +4 -0
- package/esm/browser/components/auth-view.d.ts +1 -1
- package/esm/browser/components/auth-view.js +38 -10
- package/esm/browser/components/chat-asks.d.ts +8 -0
- package/esm/browser/components/chat-asks.js +10 -0
- package/esm/browser/components/chat-list.js +11 -1
- package/esm/browser/components/composer-box.d.ts +2 -0
- package/esm/browser/components/composer-box.js +2 -1
- package/esm/browser/components/composer.d.ts +3 -1
- package/esm/browser/components/composer.js +16 -4
- package/esm/browser/components/custom-provider-advanced.d.ts +14 -0
- package/esm/browser/components/custom-provider-advanced.js +50 -0
- package/esm/browser/components/custom-provider-util.d.ts +38 -0
- package/esm/browser/components/custom-provider-util.js +103 -0
- package/esm/browser/components/custom-provider-view.d.ts +11 -0
- package/esm/browser/components/custom-provider-view.js +181 -0
- package/esm/browser/components/face.d.ts +13 -1
- package/esm/browser/components/face.js +16 -1
- package/esm/browser/components/host-view.d.ts +1 -1
- package/esm/browser/components/message-list.js +20 -1
- package/esm/browser/components/people.d.ts +32 -0
- package/esm/browser/components/people.js +71 -0
- package/esm/browser/components/session-view.d.ts +1 -1
- package/esm/browser/components/session-view.js +56 -36
- package/esm/browser/components/settings-choices.js +2 -3
- package/esm/browser/components/settings-controls.d.ts +7 -1
- package/esm/browser/components/settings-controls.js +8 -0
- package/esm/browser/components/settings-parts.js +25 -8
- package/esm/browser/components/sign-in-setup.d.ts +16 -0
- package/esm/browser/components/sign-in-setup.js +118 -0
- package/esm/browser/components/use-seen-chats.d.ts +2 -0
- package/esm/browser/components/use-seen-chats.js +2 -2
- package/esm/browser/editor/monaco-loader.js +7 -1
- package/esm/browser/extension/web-api-components.d.ts +12 -0
- package/esm/browser/extension/web-api-contributions.d.ts +3 -0
- package/esm/browser/extension/web-extension-api.d.ts +9 -2
- package/esm/browser/extension/web-extension-context.d.ts +2 -0
- package/esm/browser/extension/web-extension-context.js +19 -0
- package/esm/browser/game/game-loader.js +22 -2
- package/esm/browser/game/game3d-protocol.d.ts +13 -4
- package/esm/browser/i18n/locales.d.ts +90 -1
- package/esm/browser/i18n/locales.js +25 -1
- package/esm/browser/i18n/messages-ja.d.ts +2 -0
- package/esm/browser/i18n/messages-ja.js +972 -0
- package/esm/browser/i18n/messages-zh-tw.d.ts +3 -0
- package/esm/browser/i18n/messages-zh-tw.js +973 -0
- package/esm/browser/i18n/messages.d.ts +85 -0
- package/esm/browser/i18n/messages.js +171 -1
- package/esm/browser/i18n/use-t.js +3 -2
- package/esm/browser/presence/presence-reporter.d.ts +32 -0
- package/esm/browser/presence/presence-reporter.js +71 -0
- package/esm/browser/settings/settings-protocol.d.ts +3 -2
- package/esm/browser/settings/settings-protocol.js +4 -3
- package/esm/browser/style/conversation.d.ts +1 -1
- package/esm/browser/style/conversation.js +24 -0
- package/esm/browser/style/layout.d.ts +1 -1
- package/esm/browser/style/layout.js +8 -0
- package/esm/browser/style/pages.d.ts +1 -1
- package/esm/browser/style/pages.js +53 -1
- package/esm/browser/util/desktop.d.ts +12 -1
- package/esm/browser/util/desktop.js +14 -0
- package/esm/browser/util/voice.d.ts +20 -1
- package/esm/browser/util/voice.js +27 -11
- package/esm/browser/workbench-protocol.d.ts +9 -0
- package/esm/browser/workbench-util.d.ts +4 -0
- package/esm/browser/workbench-util.js +24 -1
- package/esm/browser/workbench.d.ts +3 -0
- package/esm/browser/workbench.js +14 -4
- package/lib/browser/assistant/assistant-extension.js +3 -2
- package/lib/browser/assistant/assistant-initiative.js +1 -1
- package/lib/browser/assistant/assistant-state.js +1 -1
- package/lib/browser/components/access-view.js +3 -2
- package/lib/browser/components/account-menu.js +2 -2
- package/lib/browser/components/app-view.js +4 -0
- package/lib/browser/components/auth-view.d.ts +1 -1
- package/lib/browser/components/auth-view.js +37 -9
- package/lib/browser/components/chat-asks.d.ts +8 -0
- package/lib/browser/components/chat-asks.js +10 -0
- package/lib/browser/components/chat-list.js +11 -1
- package/lib/browser/components/composer-box.d.ts +2 -0
- package/lib/browser/components/composer-box.js +2 -1
- package/lib/browser/components/composer.d.ts +3 -1
- package/lib/browser/components/composer.js +16 -4
- package/lib/browser/components/custom-provider-advanced.d.ts +15 -0
- package/lib/browser/components/custom-provider-advanced.js +86 -0
- package/lib/browser/components/custom-provider-util.d.ts +39 -0
- package/lib/browser/components/custom-provider-util.js +106 -0
- package/lib/browser/components/custom-provider-view.d.ts +12 -0
- package/lib/browser/components/custom-provider-view.js +217 -0
- package/lib/browser/components/face.d.ts +13 -1
- package/lib/browser/components/face.js +16 -1
- package/lib/browser/components/host-view.d.ts +1 -1
- package/lib/browser/components/message-list.js +19 -0
- package/lib/browser/components/people.d.ts +33 -0
- package/lib/browser/components/people.js +109 -0
- package/lib/browser/components/session-view.d.ts +1 -1
- package/lib/browser/components/session-view.js +56 -36
- package/lib/browser/components/settings-choices.js +1 -2
- package/lib/browser/components/settings-controls.d.ts +7 -1
- package/lib/browser/components/settings-controls.js +9 -0
- package/lib/browser/components/settings-parts.js +24 -7
- package/lib/browser/components/sign-in-setup.d.ts +17 -0
- package/lib/browser/components/sign-in-setup.js +155 -0
- package/lib/browser/components/use-seen-chats.d.ts +2 -0
- package/lib/browser/components/use-seen-chats.js +3 -2
- package/lib/browser/editor/monaco-loader.js +7 -1
- package/lib/browser/extension/web-api-components.d.ts +12 -0
- package/lib/browser/extension/web-api-contributions.d.ts +3 -0
- package/lib/browser/extension/web-extension-api.d.ts +9 -2
- package/lib/browser/extension/web-extension-context.d.ts +2 -0
- package/lib/browser/extension/web-extension-context.js +19 -0
- package/lib/browser/game/game-loader.js +22 -2
- package/lib/browser/game/game3d-protocol.d.ts +13 -4
- package/lib/browser/i18n/locales.d.ts +90 -1
- package/lib/browser/i18n/locales.js +25 -1
- package/lib/browser/i18n/messages-ja.d.ts +3 -0
- package/lib/browser/i18n/messages-ja.js +975 -0
- package/lib/browser/i18n/messages-zh-tw.d.ts +4 -0
- package/lib/browser/i18n/messages-zh-tw.js +976 -0
- package/lib/browser/i18n/messages.d.ts +85 -0
- package/lib/browser/i18n/messages.js +174 -2
- package/lib/browser/i18n/use-t.js +2 -1
- package/lib/browser/presence/presence-reporter.d.ts +33 -0
- package/lib/browser/presence/presence-reporter.js +75 -0
- package/lib/browser/settings/settings-protocol.d.ts +3 -2
- package/lib/browser/settings/settings-protocol.js +4 -3
- package/lib/browser/style/conversation.d.ts +1 -1
- package/lib/browser/style/conversation.js +24 -0
- package/lib/browser/style/layout.d.ts +1 -1
- package/lib/browser/style/layout.js +8 -0
- package/lib/browser/style/pages.d.ts +1 -1
- package/lib/browser/style/pages.js +53 -1
- package/lib/browser/util/desktop.d.ts +12 -1
- package/lib/browser/util/desktop.js +14 -0
- package/lib/browser/util/voice.d.ts +20 -1
- package/lib/browser/util/voice.js +27 -11
- package/lib/browser/workbench-protocol.d.ts +9 -0
- package/lib/browser/workbench-util.d.ts +4 -0
- package/lib/browser/workbench-util.js +24 -1
- package/lib/browser/workbench.d.ts +3 -0
- package/lib/browser/workbench.js +14 -4
- package/package.json +10 -10
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Copy, Pencil, Trash2 } from 'lucide-react';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useNotices, useWorkbench } from '../hooks.js';
|
|
4
|
+
import { useT } from '../i18n/use-t.js';
|
|
5
|
+
import { Icon, IconButton } from './icon.js';
|
|
6
|
+
import { Row } from './settings-controls.js';
|
|
7
|
+
import { SignInMark } from './sign-in-marks.js';
|
|
8
|
+
/** The fields of each kind of provider, as TaSignInSetup.fields has them, and its secret's; the optional ones last. */
|
|
9
|
+
const FIELDS = {
|
|
10
|
+
github: { fields: [{ id: 'clientId' }, { id: 'url', optional: true }], secret: 'clientSecret' },
|
|
11
|
+
google: { fields: [{ id: 'clientId' }], secret: 'clientSecret' },
|
|
12
|
+
wechat: { fields: [{ id: 'appId' }], secret: 'appSecret' },
|
|
13
|
+
oidc: { fields: [{ id: 'issuer' }, { id: 'clientId' }, { id: 'name', optional: true }], secret: 'clientSecret' },
|
|
14
|
+
};
|
|
15
|
+
/** The ways to sign in as set up (TaAccessServer.getSignInConfig), for the owner alone: none for a member, nor behind a gateway. */
|
|
16
|
+
export function useSignInConfig() {
|
|
17
|
+
const [workbench, bench] = useWorkbench();
|
|
18
|
+
const [config, setConfig] = React.useState();
|
|
19
|
+
const read = React.useCallback(() => bench.access.getSignInConfig().then(setConfig, () => {
|
|
20
|
+
setConfig(undefined);
|
|
21
|
+
}), [bench]);
|
|
22
|
+
React.useEffect(() => {
|
|
23
|
+
if (workbench.status === 'online') {
|
|
24
|
+
void read();
|
|
25
|
+
}
|
|
26
|
+
}, [workbench.status, read]);
|
|
27
|
+
return { config, read };
|
|
28
|
+
}
|
|
29
|
+
function providerName(setup, t) {
|
|
30
|
+
return setup.id === 'wechat' ? t('ta.signin.wechat') : setup.id === 'oidc' && setup.name === 'SSO' ? t('ta.signInSetup.oidc') : setup.name;
|
|
31
|
+
}
|
|
32
|
+
function SetupForm({ setup, onSave, onCancel }) {
|
|
33
|
+
var _a;
|
|
34
|
+
const t = useT();
|
|
35
|
+
const shape = FIELDS[setup.id];
|
|
36
|
+
const [values, setValues] = React.useState({ ...setup.fields });
|
|
37
|
+
const [busy, setBusy] = React.useState(false);
|
|
38
|
+
const set = (id, value) => setValues(current => ({ ...current, [id]: value }));
|
|
39
|
+
const missing = shape.fields.some(field => { var _a; return !field.optional && !((_a = values[field.id]) === null || _a === void 0 ? void 0 : _a.trim()); }) || (!setup.secret && !((_a = values[shape.secret]) === null || _a === void 0 ? void 0 : _a.trim()));
|
|
40
|
+
return (React.createElement("form", { className: "ta-sign-in-form", onSubmit: event => {
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
setBusy(true);
|
|
43
|
+
void onSave(values).finally(() => setBusy(false));
|
|
44
|
+
} },
|
|
45
|
+
[...shape.fields, { id: shape.secret, secret: true }].map(field => { var _a; return (React.createElement("label", { key: field.id, className: "ta-sign-in-field" },
|
|
46
|
+
React.createElement("span", null, t(`ta.signInSetup.field.${field.id}`)),
|
|
47
|
+
React.createElement("input", { className: "ta-input", type: 'secret' in field ? 'password' : 'text', value: (_a = values[field.id]) !== null && _a !== void 0 ? _a : '', placeholder: 'secret' in field && setup.secret
|
|
48
|
+
? t('ta.signInSetup.secretKept')
|
|
49
|
+
: 'optional' in field && field.optional
|
|
50
|
+
? t('ta.signInSetup.optional')
|
|
51
|
+
: '', autoComplete: "off", spellCheck: false, autoCapitalize: "off", onChange: event => set(field.id, event.target.value) }))); }),
|
|
52
|
+
React.createElement("div", { className: "ta-sign-in-actions" },
|
|
53
|
+
React.createElement("button", { type: "button", className: "ta-button", disabled: busy, onClick: onCancel }, t('ta.cancel')),
|
|
54
|
+
React.createElement("button", { type: "submit", className: `ta-button ta-primary${busy ? ' ta-busy' : ''}`, disabled: busy || missing }, t('ta.signInSetup.save')))));
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Settings, Access: the ways to sign in (docs/design/ta-team.md 17), which those invited use to say who they are and, on
|
|
58
|
+
* a Ta with an address, accounts to sign in to it. Kept in sign-in.json of the agent directory; one the environment of
|
|
59
|
+
* ta serve sets is shown, not changed. The address to register with a provider comes first.
|
|
60
|
+
*/
|
|
61
|
+
export function SignInSetupSettings({ config, onChange }) {
|
|
62
|
+
const t = useT();
|
|
63
|
+
const [, bench] = useWorkbench();
|
|
64
|
+
const [, notices] = useNotices();
|
|
65
|
+
const [editing, setEditing] = React.useState();
|
|
66
|
+
const save = async (id, fields) => {
|
|
67
|
+
try {
|
|
68
|
+
await bench.access.setSignInProvider(id, fields);
|
|
69
|
+
setEditing(undefined);
|
|
70
|
+
notices.notify(fields ? t('ta.signInSetup.saved') : t('ta.signInSetup.removed'), { level: 'success' });
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
notices.error(error);
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
await onChange().catch(() => undefined);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const copy = (text) => { var _a; return void ((_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText(text).then(() => notices.notify(t('ta.signInSetup.copied'), { level: 'success' }))); };
|
|
80
|
+
const callbacks = [config.callbacks.join, config.callbacks.serve].filter((one) => !!one);
|
|
81
|
+
return (React.createElement(React.Fragment, null,
|
|
82
|
+
React.createElement(Row, { label: t('ta.signInSetup.title'), description: t('ta.signInSetup.hint'), stacked: true },
|
|
83
|
+
React.createElement("div", { className: "ta-sign-in-callbacks" },
|
|
84
|
+
React.createElement("span", { className: "ta-setting-description" }, t('ta.signInSetup.callback')),
|
|
85
|
+
callbacks.map(url => (React.createElement("div", { key: url, className: "ta-sign-in-callback" },
|
|
86
|
+
React.createElement("code", { className: "ta-ellipsis" }, url),
|
|
87
|
+
React.createElement(IconButton, { icon: Copy, label: t('ta.signInSetup.copy'), onClick: () => copy(url) })))))),
|
|
88
|
+
config.providers.map(setup => {
|
|
89
|
+
var _a, _b;
|
|
90
|
+
const name = providerName(setup, t);
|
|
91
|
+
const status = setup.source === 'env'
|
|
92
|
+
? t('ta.signInSetup.fromEnv')
|
|
93
|
+
: setup.configured
|
|
94
|
+
? t('ta.signInSetup.on', { id: (_b = (_a = setup.fields.clientId) !== null && _a !== void 0 ? _a : setup.fields.appId) !== null && _b !== void 0 ? _b : '' })
|
|
95
|
+
: setup.source
|
|
96
|
+
? t('ta.signInSetup.incomplete')
|
|
97
|
+
: setup.device
|
|
98
|
+
? t('ta.signInSetup.device')
|
|
99
|
+
: t('ta.signInSetup.off');
|
|
100
|
+
return (React.createElement(Row, { key: setup.id, label: React.createElement("span", { className: "ta-sign-in-name" },
|
|
101
|
+
React.createElement(SignInMark, { provider: setup.id, size: 15 }),
|
|
102
|
+
" ",
|
|
103
|
+
name), description: status, stacked: editing === setup.id }, editing === setup.id ? (React.createElement(SetupForm, { setup: setup, onSave: fields => save(setup.id, fields), onCancel: () => setEditing(undefined) })) : setup.source === 'env' ? null : (React.createElement(React.Fragment, null,
|
|
104
|
+
setup.source === 'file' && (React.createElement(IconButton, { icon: Trash2, label: t('ta.signInSetup.remove', { name }), onClick: () => void notices
|
|
105
|
+
.confirm({
|
|
106
|
+
title: t('ta.signInSetup.removeConfirm', { name }),
|
|
107
|
+
message: t('ta.signInSetup.removeDetail'),
|
|
108
|
+
confirmLabel: t('ta.access.remove'),
|
|
109
|
+
danger: true,
|
|
110
|
+
})
|
|
111
|
+
.then(yes => (yes ? save(setup.id, null) : undefined)) })),
|
|
112
|
+
React.createElement("button", { type: "button", className: "ta-button", onClick: () => setEditing(setup.id) },
|
|
113
|
+
React.createElement(Icon, { icon: Pencil, size: 14 }),
|
|
114
|
+
" ",
|
|
115
|
+
setup.source ? t('ta.signInSetup.edit') : t('ta.signInSetup.add'))))));
|
|
116
|
+
})));
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=sign-in-setup.js.map
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { TaSessionInfo } from '@celljs/ta-protocol';
|
|
2
2
|
import { type ChatSeen } from './chat-seen.js';
|
|
3
|
+
/** Whether the user can see the page: what ends in a tab hidden or on a phone locked is not seen. */
|
|
4
|
+
export declare function usePageVisible(): boolean;
|
|
3
5
|
/**
|
|
4
6
|
* Which conversations the user has seen, as a messenger's unread: the one shown is seen each time it comes to
|
|
5
7
|
* rest in front of them. The first time, everything of before is seen: once the computer said it keeps nothing
|
|
@@ -5,7 +5,7 @@ import { TaState } from '../state/state-protocol.js';
|
|
|
5
5
|
import { ChatListUtil } from './chat-list.js';
|
|
6
6
|
import { ChatSeenUtil, SEEN_CHATS } from './chat-seen.js';
|
|
7
7
|
/** Whether the user can see the page: what ends in a tab hidden or on a phone locked is not seen. */
|
|
8
|
-
function
|
|
8
|
+
export function usePageVisible() {
|
|
9
9
|
const [visible, setVisible] = React.useState(() => typeof document === 'undefined' || document.visibilityState === 'visible');
|
|
10
10
|
React.useEffect(() => {
|
|
11
11
|
const change = () => setVisible(document.visibilityState === 'visible');
|
|
@@ -29,7 +29,7 @@ export function useSeenChats(sessions, shown) {
|
|
|
29
29
|
void state.load(SEEN_CHATS).then(kept => !kept.since && state.set(SEEN_CHATS, { since: Date.now(), at: kept.at }), () => undefined);
|
|
30
30
|
}
|
|
31
31
|
}, [state, online]);
|
|
32
|
-
const visible =
|
|
32
|
+
const visible = usePageVisible();
|
|
33
33
|
const looked = visible && shown ? sessions.find(session => session.sessionId === shown) : undefined;
|
|
34
34
|
const file = looked && ChatListUtil.file(looked);
|
|
35
35
|
const busy = !!(looked === null || looked === void 0 ? void 0 : looked.isStreaming);
|
|
@@ -129,10 +129,16 @@ export var MonacoLoader;
|
|
|
129
129
|
}
|
|
130
130
|
MonacoLoader.load = load;
|
|
131
131
|
async function start(language) {
|
|
132
|
+
// Sets the words Monaco reads as its modules load.
|
|
132
133
|
if (language === 'zh-CN') {
|
|
133
|
-
// Sets the words Monaco reads as its modules load.
|
|
134
134
|
await import('monaco-editor/nls/lang/zh-cn.js');
|
|
135
135
|
}
|
|
136
|
+
else if (language === 'zh-TW') {
|
|
137
|
+
await import('monaco-editor/nls/lang/zh-tw.js');
|
|
138
|
+
}
|
|
139
|
+
else if (language === 'ja-JP') {
|
|
140
|
+
await import('monaco-editor/nls/lang/ja.js');
|
|
141
|
+
}
|
|
136
142
|
return (await import('./monaco.js')).monaco;
|
|
137
143
|
}
|
|
138
144
|
})(MonacoLoader || (MonacoLoader = {}));
|
|
@@ -184,11 +184,23 @@ export interface WebFaceProps {
|
|
|
184
184
|
working?: boolean;
|
|
185
185
|
/** A dot at its corner: green online, grey not; none without. Its ring is `--ta-face-ring` (the page's colour). */
|
|
186
186
|
online?: boolean;
|
|
187
|
+
/**
|
|
188
|
+
* The owner of this Ta: the close-up of its double, the dinosaur the user picked, which changes with it. Newer than
|
|
189
|
+
* some Ta apps, which draw `face` or `seed` instead.
|
|
190
|
+
*/
|
|
191
|
+
double?: boolean;
|
|
192
|
+
/**
|
|
193
|
+
* Another Ta, as its double looks (`look` of TaRoomMember, TaFriend): the close-up of that dinosaur. One this page
|
|
194
|
+
* does not know, or a Ta app of before, draws `face` or `seed`.
|
|
195
|
+
*/
|
|
196
|
+
look?: string;
|
|
187
197
|
}
|
|
188
198
|
export interface WebGroupFaceProps {
|
|
189
199
|
members: readonly {
|
|
190
200
|
face?: number;
|
|
191
201
|
seed?: string;
|
|
202
|
+
look?: string;
|
|
203
|
+
double?: boolean;
|
|
192
204
|
working?: boolean;
|
|
193
205
|
}[];
|
|
194
206
|
size: number;
|
|
@@ -144,9 +144,12 @@ export type WebInitiativeLevel = 'off' | 'digest' | 'ask' | 'act';
|
|
|
144
144
|
export interface WebInitiativeKind {
|
|
145
145
|
/** `<area>.<verb>`: `double.start-task`. */
|
|
146
146
|
id: string;
|
|
147
|
+
/** Traditional Chinese (`tw`) falls back to `zh`, Japanese (`ja`) to `en`. */
|
|
147
148
|
title: {
|
|
148
149
|
en: string;
|
|
149
150
|
zh: string;
|
|
151
|
+
tw?: string;
|
|
152
|
+
ja?: string;
|
|
150
153
|
};
|
|
151
154
|
/** What it does can be taken back: one that cannot never goes past `ask`. */
|
|
152
155
|
reversible: boolean;
|
|
@@ -44,6 +44,13 @@ export interface WebExtensionAPI {
|
|
|
44
44
|
* ta serve. `byUrl` says which way it is; the bytes come sealed, end to end, when it is not.
|
|
45
45
|
*/
|
|
46
46
|
readonly files: TaFiles;
|
|
47
|
+
/**
|
|
48
|
+
* A URL the page can load for a file of the extension's own package, by its path there (`models/rex.glb`): a model
|
|
49
|
+
* of `ui.Game3D`, a picture, a sound. Where the page cannot load the files of ta serve by their URL (`files.byUrl`)
|
|
50
|
+
* it is a `blob:` of the bytes. Throws for a path outside the package, and in a web extension that comes with the
|
|
51
|
+
* page. Newer than some Ta apps: `pi.fileUrl?.(…)`.
|
|
52
|
+
*/
|
|
53
|
+
fileUrl(path: string): Promise<string>;
|
|
47
54
|
/** The other machines of `ssh://` directories (TaLocation): their ports, for a page served there. */
|
|
48
55
|
readonly remote: TaRemoteServer;
|
|
49
56
|
/** pi's settings of ta (`settings.json`): `getSettings(cwd)` also lists the models with credentials, for a model picker. */
|
|
@@ -427,8 +434,8 @@ export interface WebExtensionUI {
|
|
|
427
434
|
}>;
|
|
428
435
|
/**
|
|
429
436
|
* The face of one who is not Ta, as the agents of channels have: a coloured shape with eyes that blink, one of 16,
|
|
430
|
-
* by `face` or the same for the same `seed` (an id) on every device; `online` a dot at its corner
|
|
431
|
-
* some Ta apps: `pi.ui.Face ?? fallback`.
|
|
437
|
+
* by `face` or the same for the same `seed` (an id) on every device; `online` a dot at its corner; `double` the
|
|
438
|
+
* owner of this Ta, drawn as its double; `look` another Ta, as its double looks. Newer than some Ta apps: `pi.ui.Face ?? fallback`.
|
|
432
439
|
*/
|
|
433
440
|
readonly Face: React.ComponentType<WebFaceProps>;
|
|
434
441
|
/** A group, as a channel is drawn: the first of `members` in front, the next behind. Newer than some Ta apps. */
|
|
@@ -50,6 +50,8 @@ export declare class WebExtensionContext {
|
|
|
50
50
|
static marked(server: TaServer, mark: (text: string) => string): TaServer;
|
|
51
51
|
/** A renderer of code whose `send` (a choice tapped in it) says it came from the extension. */
|
|
52
52
|
static replying(Renderer: React.ComponentType<WebCodeRendererProps>, mark: (text: string) => string): React.ComponentType<WebCodeRendererProps>;
|
|
53
|
+
/** A path of a file of a package, relative to it and inside it (`./models/rex.glb`, `models\rex.glb`: `models/rex.glb`). */
|
|
54
|
+
static packagePath(path: string): string;
|
|
53
55
|
/** Monaco and the games in the theme and language of the settings, the same component for every extension. */
|
|
54
56
|
protected readonly codeEditor: (props: CodeEditorProps) => React.FunctionComponentElement<CodeEditorProps & {
|
|
55
57
|
settings: TaSettings;
|
|
@@ -101,6 +101,17 @@ export class WebExtensionContext {
|
|
|
101
101
|
return React.createElement(Renderer, { ...props, send: marked });
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
|
+
/** A path of a file of a package, relative to it and inside it (`./models/rex.glb`, `models\rex.glb`: `models/rex.glb`). */
|
|
105
|
+
static packagePath(path) {
|
|
106
|
+
const parts = path
|
|
107
|
+
.replace(/\\/g, '/')
|
|
108
|
+
.split('/')
|
|
109
|
+
.filter(part => part !== '' && part !== '.');
|
|
110
|
+
if (/^([a-z]:)?[\\/]/i.test(path) || parts.length === 0 || parts.includes('..')) {
|
|
111
|
+
throw new Error(`Not a file inside the package: ${path}`);
|
|
112
|
+
}
|
|
113
|
+
return parts.join('/');
|
|
114
|
+
}
|
|
104
115
|
create(run) {
|
|
105
116
|
const { host } = this;
|
|
106
117
|
const { workbench, files } = host;
|
|
@@ -137,6 +148,14 @@ export class WebExtensionContext {
|
|
|
137
148
|
get files() {
|
|
138
149
|
return files;
|
|
139
150
|
},
|
|
151
|
+
fileUrl: path => live(async () => {
|
|
152
|
+
var _a;
|
|
153
|
+
const root = (_a = run.loaded.info) === null || _a === void 0 ? void 0 : _a.root;
|
|
154
|
+
if (!root) {
|
|
155
|
+
throw new Error(`The web extension ${run.loaded.name} has no files of its own here.`);
|
|
156
|
+
}
|
|
157
|
+
return files.loadable(await workbench.workspace.fileUrl(WebExtensionContext.packagePath(path), root));
|
|
158
|
+
}),
|
|
140
159
|
get remote() {
|
|
141
160
|
return workbench.remote;
|
|
142
161
|
},
|
|
@@ -16,13 +16,33 @@ export var Game3DEngineLoader;
|
|
|
16
16
|
(function (Game3DEngineLoader) {
|
|
17
17
|
let loading;
|
|
18
18
|
function load() {
|
|
19
|
-
// One chunk for the engine, one for
|
|
20
|
-
loading !== null && loading !== void 0 ? loading : (loading = Promise.all([
|
|
19
|
+
// One chunk for the engine, one for each addon.
|
|
20
|
+
loading !== null && loading !== void 0 ? loading : (loading = Promise.all([
|
|
21
|
+
import('three'),
|
|
22
|
+
import('three/addons/controls/OrbitControls.js'),
|
|
23
|
+
import('three/addons/loaders/GLTFLoader.js'),
|
|
24
|
+
import('three/addons/libs/meshopt_decoder.module.js'),
|
|
25
|
+
import('three/addons/utils/SkeletonUtils.js'),
|
|
26
|
+
]).then(([THREE, controls, gltf, meshopt, SkeletonUtils]) => ({
|
|
27
|
+
THREE,
|
|
28
|
+
OrbitControls: controls.OrbitControls,
|
|
29
|
+
GLTFLoader: meshoptLoader(gltf.GLTFLoader, meshopt.MeshoptDecoder),
|
|
30
|
+
SkeletonUtils,
|
|
31
|
+
}), error => {
|
|
21
32
|
loading = undefined;
|
|
22
33
|
throw error;
|
|
23
34
|
}));
|
|
24
35
|
return loading;
|
|
25
36
|
}
|
|
26
37
|
Game3DEngineLoader.load = load;
|
|
38
|
+
/** The loader, its decoder of meshopt set as it is made: what gltfpack and `gltf-transform meshopt` write loads as it is. */
|
|
39
|
+
function meshoptLoader(Loader, decoder) {
|
|
40
|
+
return class extends Loader {
|
|
41
|
+
constructor(...args) {
|
|
42
|
+
super(...args);
|
|
43
|
+
this.setMeshoptDecoder(decoder);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
27
47
|
})(Game3DEngineLoader || (Game3DEngineLoader = {}));
|
|
28
48
|
//# sourceMappingURL=game-loader.js.map
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import type * as ThreeModule from 'three';
|
|
2
2
|
import type { GamePage } from './game-protocol.js';
|
|
3
|
+
/** The addons are ES modules only, and this a CommonJS one. */
|
|
4
|
+
type OrbitControlsClass = typeof import('three/addons/controls/OrbitControls.js', { with: { 'resolution-mode': 'import' } }).OrbitControls;
|
|
5
|
+
type GLTFLoaderClass = typeof import('three/addons/loaders/GLTFLoader.js', { with: { 'resolution-mode': 'import' } }).GLTFLoader;
|
|
6
|
+
type SkeletonUtilsModule = typeof import('three/addons/utils/SkeletonUtils.js', { with: { 'resolution-mode': 'import' } });
|
|
3
7
|
/**
|
|
4
|
-
* Three.js, the 3D engine of the page (docs/design/ta-games.md), with the
|
|
5
|
-
* extensions import
|
|
8
|
+
* Three.js, the 3D engine of the page (docs/design/ta-games.md), with the addons most 3D views need: web
|
|
9
|
+
* extensions import none. It loads the first time a 3D game starts, not with the page.
|
|
6
10
|
*/
|
|
7
|
-
/** The addon is an ES module only, and this a CommonJS one. */
|
|
8
|
-
type OrbitControlsClass = typeof import('three/addons/controls/OrbitControls.js', { with: { 'resolution-mode': 'import' } }).OrbitControls;
|
|
9
11
|
export interface Game3DEngine {
|
|
10
12
|
THREE: typeof ThreeModule;
|
|
11
13
|
OrbitControls: OrbitControlsClass;
|
|
14
|
+
/**
|
|
15
|
+
* Loads models of glTF 2.0 (`.glb`, or `.gltf` beside its files), meshes compressed by meshopt too
|
|
16
|
+
* (EXT_meshopt_compression); not Draco or KTX2. A model of the extension's own package by `pi.fileUrl`.
|
|
17
|
+
*/
|
|
18
|
+
GLTFLoader: GLTFLoaderClass;
|
|
19
|
+
/** `clone` of a skinned model (one with bones), which `object.clone()` breaks: to show a model loaded once several times. */
|
|
20
|
+
SkeletonUtils: SkeletonUtilsModule;
|
|
12
21
|
}
|
|
13
22
|
/**
|
|
14
23
|
* What a 3D game is given to set itself up: a renderer drawing into the component, a scene and a camera (a
|