@xenosystem/blocks 0.1.1 → 0.2.1
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/auth/index.d.ts +63 -2
- package/dist/auth/index.js +108 -45
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +7 -5
package/dist/auth/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { ReactNode } from 'react';
|
|
|
3
3
|
import { PanelModule, PanelManifest } from '@xenosystem/panel-sdk';
|
|
4
4
|
import { XenoAccountStatus, XenoAccountIdentity, XenoAccountActionKind } from '@xenosystem/panel-account';
|
|
5
5
|
export * from '@xenosystem/panel-account';
|
|
6
|
+
import { BlockDeclaration } from '@xenosystem/block-sdk';
|
|
6
7
|
|
|
7
8
|
interface CreateAuthGatePanelOptions {
|
|
8
9
|
/** What renders behind the gate once it is `open`. A product passes its app; the harness a fixture. */
|
|
@@ -116,7 +117,67 @@ interface AuthGateViewProps {
|
|
|
116
117
|
heroSrc?: string;
|
|
117
118
|
now?: () => number;
|
|
118
119
|
}
|
|
119
|
-
declare function AuthGateView({ controller, productName, children, heroSrc, now }: AuthGateViewProps): react.JSX.Element;
|
|
120
|
+
declare function AuthGateView$1({ controller, productName, children, heroSrc, now }: AuthGateViewProps): react.JSX.Element;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* The auth gate AS A DECLARATION — the first block written the way `xeno-apps/SPEC.md` §8d says every
|
|
124
|
+
* block is: components + bindings + the manifest, with ONE behaviour (`auth/authGateView`) for the only
|
|
125
|
+
* logic it has. The code view (`AuthGateView`) and this declaration render the same door from the same
|
|
126
|
+
* behaviour; `test/auth-gate.declaration.test.tsx` holds them equal in every phase.
|
|
127
|
+
*
|
|
128
|
+
* Inputs: `state` (the host's `XenoAuthGateState` push). Output: `intent` ({ kind }). Config:
|
|
129
|
+
* `productName`. The door opens (renders the app behind it) when `view.open` — a host that mounts the
|
|
130
|
+
* declaration passes its app as the composition's `children` slot.
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
declare const AUTH_GATE_DECLARATION: BlockDeclaration;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* `authGateView` — the gate's ONE behaviour: host state + product → the view model the door renders.
|
|
137
|
+
* Pure. Used by the code view (`AuthGateView`) AND by the declaration (`AUTH_GATE_DECLARATION`,
|
|
138
|
+
* `behaviour: 'auth/authGateView'`), so there is exactly one derivation of copy and offered actions.
|
|
139
|
+
* `xeno-apps/SPEC.md` §8d: "code only where a block genuinely needs a behaviour" — this is that code.
|
|
140
|
+
*/
|
|
141
|
+
|
|
142
|
+
interface AuthGateAction {
|
|
143
|
+
id: string;
|
|
144
|
+
label: string;
|
|
145
|
+
variant: 'primary' | 'quiet';
|
|
146
|
+
disabled?: boolean;
|
|
147
|
+
}
|
|
148
|
+
interface AuthGateView {
|
|
149
|
+
phase: XenoAuthGatePhase;
|
|
150
|
+
open: boolean;
|
|
151
|
+
closed: boolean;
|
|
152
|
+
productName: string;
|
|
153
|
+
rootAttributes: Record<string, string>;
|
|
154
|
+
label: string;
|
|
155
|
+
hero: {
|
|
156
|
+
headline: string;
|
|
157
|
+
lead: string;
|
|
158
|
+
stats: {
|
|
159
|
+
value: string;
|
|
160
|
+
label: string;
|
|
161
|
+
}[];
|
|
162
|
+
};
|
|
163
|
+
tag?: string;
|
|
164
|
+
title: string;
|
|
165
|
+
body: string;
|
|
166
|
+
note?: string;
|
|
167
|
+
warning?: string;
|
|
168
|
+
identity?: string;
|
|
169
|
+
actions: AuthGateAction[];
|
|
170
|
+
}
|
|
171
|
+
declare function authGateView(state: XenoAuthGateState, productName: string, now?: number): AuthGateView;
|
|
172
|
+
declare function plateCopy(phase: XenoAuthGatePhase, product: string, message: string | undefined, since: string | null): {
|
|
173
|
+
tag?: string;
|
|
174
|
+
title: string;
|
|
175
|
+
body: string;
|
|
176
|
+
note?: string;
|
|
177
|
+
};
|
|
178
|
+
declare const BEHAVIOURS: {
|
|
179
|
+
'auth/authGateView': (inputs: Record<string, unknown>, config: Readonly<Record<string, unknown>>) => AuthGateView;
|
|
180
|
+
};
|
|
120
181
|
|
|
121
182
|
/**
|
|
122
183
|
* `mountXenoAuthGate` — the per-product plug, exactly as `XENO AUTH - AUTH GATE DELTA.md` §4 specifies:
|
|
@@ -158,4 +219,4 @@ interface MountedXenoAuthGate {
|
|
|
158
219
|
}
|
|
159
220
|
declare function mountXenoAuthGate(root: HTMLElement, options: MountXenoAuthGateOptions): MountedXenoAuthGate;
|
|
160
221
|
|
|
161
|
-
export { AUTH_GATE_INITIAL, AUTH_GATE_PANEL_ID, AuthGateController, type AuthGateHostBridge, AuthGateView, type AuthGateViewProps, type CreateAuthGatePanelOptions, type MountXenoAuthGateOptions, type MountedXenoAuthGate, PHASE_INTENTS, type XenoAuthGateBridge, type XenoAuthGateIntent, type XenoAuthGateIntentKind, type XenoAuthGatePhase, type XenoAuthGateState, type XenoLicenceState, authGateManifest, authGatePanel, createAuthGatePanel, deriveAuthGatePhase, formatSince, hostContradiction, intentOffered, mountXenoAuthGate };
|
|
222
|
+
export { AUTH_GATE_DECLARATION, AUTH_GATE_INITIAL, AUTH_GATE_PANEL_ID, type AuthGateAction, AuthGateController, type AuthGateHostBridge, AuthGateView$1 as AuthGateView, type AuthGateView as AuthGateViewModel, type AuthGateViewProps, BEHAVIOURS, type CreateAuthGatePanelOptions, type MountXenoAuthGateOptions, type MountedXenoAuthGate, PHASE_INTENTS, type XenoAuthGateBridge, type XenoAuthGateIntent, type XenoAuthGateIntentKind, type XenoAuthGatePhase, type XenoAuthGateState, type XenoLicenceState, authGateManifest, authGatePanel, authGateView, createAuthGatePanel, deriveAuthGatePhase, formatSince, hostContradiction, intentOffered, mountXenoAuthGate, plateCopy };
|
package/dist/auth/index.js
CHANGED
|
@@ -127,15 +127,12 @@ var authGateManifest = {
|
|
|
127
127
|
// src/auth/gate/react/AuthGateView.tsx
|
|
128
128
|
import { useEffect, useState } from "react";
|
|
129
129
|
import { AuthDoor, SignInForm } from "@xenosystem/components/auth";
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
const state = controller.getState();
|
|
137
|
-
const copy = plateCopy(phase, productName, state.message, formatSince(state.lastVerifiedAt, now()));
|
|
138
|
-
const action = (id, label, variant = "primary") => controller.offers(id) ? [{ id, label, variant, onClick: () => controller.intend(id) }] : [];
|
|
130
|
+
|
|
131
|
+
// src/auth/gate/behaviour.ts
|
|
132
|
+
function authGateView(state, productName, now = Date.now()) {
|
|
133
|
+
const phase = deriveAuthGatePhase(state);
|
|
134
|
+
const copy = plateCopy(phase, productName, state.message, formatSince(state.lastVerifiedAt, now));
|
|
135
|
+
const action = (id, label, variant = "primary") => intentOffered(state, id) ? [{ id, label, variant }] : [];
|
|
139
136
|
const actions = [
|
|
140
137
|
...phase === "sign-in" && state.pending ? [{ id: "pending", label: "Finish in your browser\u2026", variant: "primary", disabled: true }] : [],
|
|
141
138
|
...action("signIn", "Sign in to XENO"),
|
|
@@ -145,41 +142,26 @@ function AuthGateView({ controller, productName, children, heroSrc, now = () =>
|
|
|
145
142
|
...action("refresh", phase === "unlicensed" || phase === "expired-offline" ? "Check again" : "Try again", phase === "unlicensed" ? "quiet" : "primary"),
|
|
146
143
|
...action("signOut", "Sign out", "quiet")
|
|
147
144
|
];
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
children: /* @__PURE__ */ jsx(
|
|
169
|
-
SignInForm,
|
|
170
|
-
{
|
|
171
|
-
phase,
|
|
172
|
-
tag: copy.tag,
|
|
173
|
-
title: copy.title,
|
|
174
|
-
body: copy.body,
|
|
175
|
-
actions,
|
|
176
|
-
note: phase === "sign-in" && !state.pending ? `Your browser opens at xenostudio.ai, where you can continue with Google, GitHub or email. ${productName} never sees your password.` : void 0,
|
|
177
|
-
warning: copy.note,
|
|
178
|
-
identity
|
|
179
|
-
}
|
|
180
|
-
)
|
|
181
|
-
}
|
|
182
|
-
);
|
|
145
|
+
return {
|
|
146
|
+
phase,
|
|
147
|
+
open: phase === "open",
|
|
148
|
+
closed: phase !== "open",
|
|
149
|
+
productName,
|
|
150
|
+
rootAttributes: { "data-xeno-auth-gate": phase },
|
|
151
|
+
label: `${productName} sign-in`,
|
|
152
|
+
hero: {
|
|
153
|
+
headline: "One account.\nEvery XENO product.",
|
|
154
|
+
lead: `Sign in once and ${productName} \u2014 and every other XENO app \u2014 runs under your plan, your credits and your files.`,
|
|
155
|
+
stats: [{ value: "1", label: "Account" }, { value: "Yours", label: "Files stay put" }, { value: "Browser", label: "Sign-in, never in-app" }]
|
|
156
|
+
},
|
|
157
|
+
tag: copy.tag,
|
|
158
|
+
title: copy.title,
|
|
159
|
+
body: copy.body,
|
|
160
|
+
note: phase === "sign-in" && !state.pending ? `Your browser opens at xenostudio.ai, where you can continue with Google, GitHub or email. ${productName} never sees your password.` : void 0,
|
|
161
|
+
warning: copy.note,
|
|
162
|
+
identity: state.identity && phase !== "sign-in" ? state.identity.email ?? state.identity.name ?? state.identity.sub : void 0,
|
|
163
|
+
actions
|
|
164
|
+
};
|
|
183
165
|
}
|
|
184
166
|
function plateCopy(phase, product, message, since) {
|
|
185
167
|
switch (phase) {
|
|
@@ -199,6 +181,42 @@ function plateCopy(phase, product, message, since) {
|
|
|
199
181
|
return { title: "", body: "" };
|
|
200
182
|
}
|
|
201
183
|
}
|
|
184
|
+
var AUTH_GATE_INPUT = "auth";
|
|
185
|
+
var BEHAVIOURS = {
|
|
186
|
+
"auth/authGateView": (inputs, config) => authGateView(inputs[AUTH_GATE_INPUT] ?? { account: "unknown", licence: "checking", sdk: "ready" }, typeof config.productName === "string" && config.productName ? config.productName : "XENO")
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
// src/auth/gate/react/AuthGateView.tsx
|
|
190
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
191
|
+
function AuthGateView({ controller, productName, children, heroSrc, now = () => Date.now() }) {
|
|
192
|
+
const [, force] = useState(0);
|
|
193
|
+
useEffect(() => controller.subscribe(() => force((n) => n + 1)), [controller]);
|
|
194
|
+
const phase = controller.getPhase();
|
|
195
|
+
if (phase === "open") return /* @__PURE__ */ jsx(Fragment, { children });
|
|
196
|
+
const v = authGateView(controller.getState(), productName, now());
|
|
197
|
+
const actions = v.actions.map((a) => ({ ...a, onClick: a.disabled ? void 0 : () => controller.intend(a.id) }));
|
|
198
|
+
return /* @__PURE__ */ jsx(
|
|
199
|
+
AuthDoor,
|
|
200
|
+
{
|
|
201
|
+
label: v.label,
|
|
202
|
+
rootAttributes: { "data-xeno-auth-gate": phase },
|
|
203
|
+
hero: { imageSrc: heroSrc, headline: v.hero.headline, lead: v.hero.lead, stats: v.hero.stats },
|
|
204
|
+
children: /* @__PURE__ */ jsx(
|
|
205
|
+
SignInForm,
|
|
206
|
+
{
|
|
207
|
+
phase,
|
|
208
|
+
tag: v.tag,
|
|
209
|
+
title: v.title,
|
|
210
|
+
body: v.body,
|
|
211
|
+
actions,
|
|
212
|
+
note: v.note,
|
|
213
|
+
warning: v.warning,
|
|
214
|
+
identity: v.identity
|
|
215
|
+
}
|
|
216
|
+
)
|
|
217
|
+
}
|
|
218
|
+
);
|
|
219
|
+
}
|
|
202
220
|
|
|
203
221
|
// src/auth/gate/panel.ts
|
|
204
222
|
function createAuthGatePanel(options = {}) {
|
|
@@ -256,6 +274,47 @@ function createAuthGatePanel(options = {}) {
|
|
|
256
274
|
}
|
|
257
275
|
var authGatePanel = createAuthGatePanel();
|
|
258
276
|
|
|
277
|
+
// src/auth/gate/declaration.ts
|
|
278
|
+
var AUTH_GATE_DECLARATION = {
|
|
279
|
+
format: "xeno.block@1",
|
|
280
|
+
manifest: authGateManifest,
|
|
281
|
+
behaviour: "auth/authGateView",
|
|
282
|
+
composition: {
|
|
283
|
+
component: "fragment",
|
|
284
|
+
children: [
|
|
285
|
+
{ component: "slot", when: { input: "view.open" } },
|
|
286
|
+
{
|
|
287
|
+
component: "auth/AuthDoor",
|
|
288
|
+
when: { input: "view.closed" },
|
|
289
|
+
props: {
|
|
290
|
+
label: { input: "view.label" },
|
|
291
|
+
rootAttributes: { input: "view.rootAttributes" },
|
|
292
|
+
hero: { input: "view.hero" }
|
|
293
|
+
},
|
|
294
|
+
children: [
|
|
295
|
+
{
|
|
296
|
+
component: "auth/SignInForm",
|
|
297
|
+
props: {
|
|
298
|
+
phase: { input: "view.phase" },
|
|
299
|
+
tag: { input: "view.tag" },
|
|
300
|
+
title: { input: "view.title" },
|
|
301
|
+
body: { input: "view.body" },
|
|
302
|
+
note: { input: "view.note" },
|
|
303
|
+
warning: { input: "view.warning" },
|
|
304
|
+
identity: { input: "view.identity" },
|
|
305
|
+
actions: { input: "view.actions" },
|
|
306
|
+
animate: { value: false }
|
|
307
|
+
},
|
|
308
|
+
on: {
|
|
309
|
+
onAction: { emit: "intent", value: { arg: "" } }
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
]
|
|
313
|
+
}
|
|
314
|
+
]
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
|
|
259
318
|
// src/auth/gate/mount.ts
|
|
260
319
|
import { createElement as createElement2 } from "react";
|
|
261
320
|
import { createRoot as createRoot2 } from "react-dom/client";
|
|
@@ -289,17 +348,21 @@ function Behind({ render }) {
|
|
|
289
348
|
// src/auth/index.ts
|
|
290
349
|
export * from "@xenosystem/panel-account";
|
|
291
350
|
export {
|
|
351
|
+
AUTH_GATE_DECLARATION,
|
|
292
352
|
AUTH_GATE_INITIAL,
|
|
293
353
|
AUTH_GATE_PANEL_ID,
|
|
294
354
|
AuthGateController,
|
|
295
355
|
AuthGateView,
|
|
356
|
+
BEHAVIOURS,
|
|
296
357
|
PHASE_INTENTS,
|
|
297
358
|
authGateManifest,
|
|
298
359
|
authGatePanel,
|
|
360
|
+
authGateView,
|
|
299
361
|
createAuthGatePanel,
|
|
300
362
|
deriveAuthGatePhase,
|
|
301
363
|
formatSince,
|
|
302
364
|
hostContradiction,
|
|
303
365
|
intentOffered,
|
|
304
|
-
mountXenoAuthGate
|
|
366
|
+
mountXenoAuthGate,
|
|
367
|
+
plateCopy
|
|
305
368
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
* `/agent`. This root re-exports nothing on purpose: import the family you mount, so a product
|
|
5
5
|
* carries only it. Naming rule: `XENO PACKAGE NAMING - STANDARD.md`.
|
|
6
6
|
*/
|
|
7
|
-
declare const BLOCKS_VERSION = "0.
|
|
7
|
+
declare const BLOCKS_VERSION = "0.2.1";
|
|
8
8
|
|
|
9
9
|
export { BLOCKS_VERSION };
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xenosystem/blocks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "XENO Blocks — rung 3 of the front ladder: components composed into a contract-bearing unit (manifest: ports, intents, commands, agent surface), rendered by @xenosystem/workbench. ONE package, one subpath per family (/auth, /edit, /data, /time, /ops, /trust, /agent), one named export per block — XENO PACKAGE NAMING - STANDARD.md.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -26,19 +26,20 @@
|
|
|
26
26
|
"test": "vitest run"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@xenosystem/components": "^0.
|
|
29
|
+
"@xenosystem/components": "^0.6.0",
|
|
30
30
|
"@xenosystem/elements-react": ">=0.0.1",
|
|
31
31
|
"@xenosystem/panel-account": "^0.1.0",
|
|
32
32
|
"@xenosystem/panel-sdk": "^1.1.0",
|
|
33
33
|
"@xenosystem/workbench": "^1.0.0",
|
|
34
34
|
"react": ">=18.0.0",
|
|
35
|
-
"react-dom": ">=18.0.0"
|
|
35
|
+
"react-dom": ">=18.0.0",
|
|
36
|
+
"@xenosystem/block-sdk": "^0.1.0"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"@types/node": "^22.0.0",
|
|
39
40
|
"@types/react": "^19.0.0",
|
|
40
41
|
"@types/react-dom": "^19.0.0",
|
|
41
|
-
"@xenosystem/components": "^0.
|
|
42
|
+
"@xenosystem/components": "^0.6.0",
|
|
42
43
|
"@xenosystem/elements-react": "0.0.1",
|
|
43
44
|
"@xenosystem/panel-account": "^0.1.0",
|
|
44
45
|
"@xenosystem/panel-sdk": "^1.1.0",
|
|
@@ -48,7 +49,8 @@
|
|
|
48
49
|
"react-dom": "^19.0.0",
|
|
49
50
|
"tsup": "^8.0.0",
|
|
50
51
|
"typescript": "^5.4.0",
|
|
51
|
-
"vitest": "^4.1.0"
|
|
52
|
+
"vitest": "^4.1.0",
|
|
53
|
+
"@xenosystem/block-sdk": "^0.1.0"
|
|
52
54
|
},
|
|
53
55
|
"publishConfig": {
|
|
54
56
|
"access": "public"
|