@plitzi/sdk-elements 0.38.20 → 0.38.22

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/CHANGELOG.md CHANGED
@@ -1,5 +1,154 @@
1
1
  # @plitzi/sdk-elements
2
2
 
3
+ ## 0.38.22
4
+
5
+ ### Patch Changes
6
+
7
+ - 19fbc45: ## Server
8
+
9
+ - **`ctx.oauth`, after a project moved onto it** (`@plitzi/sdk-server`, `@plitzi/sdk-shared`) — PZ-155..158.
10
+ `functions.oauth.callbackOrigin` fixes the one address providers send a visitor back to, on a server of one space
11
+ reached on several: `serveProject` sets it to the address people reach it on, or its loopback `127.0.0.1` when that is
12
+ plain HTTP (providers refuse `http` past loopback, and `localhost`), and prints it as it starts; the callback then sends
13
+ the visitor on to `returnTo` on the address they started from — its `location` is absolute now. `connect(name,
14
+ { returnTo, authorizeParams })` adds to the connection's parameters for one consent (`prompt: 'select_account'`), and
15
+ refuses one the platform writes. `ctx.fetch` and `ctx.oauth.fetch` take `init.signal`: in the sandbox and a runtime the
16
+ request is numbered and the code's `abort` cuts it on the platform. `ActionRefusal` takes `{ code }`; `ctx.oauth`
17
+ refuses with `oauth-not-connected` and `oauth-no-owner`.
18
+ - **A refusal of the platform's stays one across the sandbox** (`@plitzi/sdk-server`). A call answered with an
19
+ `ActionRefusal` crossed the isolate, the runner service and a runtime as a plain error: caught, the code could not tell
20
+ it apart; uncaught, a route answered 500 `This route failed` instead of 400 and the reason. The answer carries
21
+ `refused` and `code` now, and the code catches the refusal it was thrown.
22
+
23
+ - Updated dependencies [19fbc45]
24
+ - @plitzi/sdk-auth@0.38.22
25
+ - @plitzi/sdk-event-bridge@0.38.22
26
+ - @plitzi/sdk-interactions@0.38.22
27
+ - @plitzi/sdk-navigation@0.38.22
28
+ - @plitzi/sdk-schema@0.38.22
29
+ - @plitzi/sdk-shared@0.38.22
30
+
31
+ ## 0.38.21
32
+
33
+ ### Patch Changes
34
+
35
+ - 19fbc45: ## Server
36
+
37
+ - **Jobs: work longer than a request** (`@plitzi/sdk-server`, `@plitzi/sdk-shared`, `@plitzi/sdk-elements`,
38
+ `@plitzi/plitzi-sdk`, `@plitzi/sdk-authoring`) — PZ-136. A space's code declares them in
39
+ `defineFunctions({ jobs: { train: { watch, maxSeconds, run(input, job, ctx) } } })` and starts them with
40
+ `ctx.jobs.start(name, input, { key })` (`get`, `pause`, `resume`, `cancel` beside it). They run in the actions' durable
41
+ queue — leased, taken over when a server dies, retried with backoff — slice by slice, in the sandbox, in a space's
42
+ runtime and natively alike: `job.save(state)` is the one checkpoint and the next slice starts with `job.state`;
43
+ `job.report(fraction, step)` says how far it is; on `job.signal` (`job.stopping`: `pause`, `cancel`, `limit`,
44
+ `shutdown`) the code has 5 s to save and return. A sandbox slice runs at most `sliceMs` and goes on in the next if it
45
+ saved since it began — one that saved nothing fails, so a job cannot loop forever; a runtime's runs until the job's
46
+ time is up. A real pause: `paused` keeps what it saved until resumed. Who may watch it is RBAC: whoever started it, and
47
+ whoever its `watch` (a channel's access) lets in, on `$job:<id>` — the platform's topic, retained — read with
48
+ `useJob(id)` or a `channel` element on `$job:{{ id }}`; the view never carries its input, its state, or an error other
49
+ than the code's own refusal. Limits per space (its plan) through `functions.jobs.limitsFor` —
50
+ `DEFAULT_FUNCTION_JOB_LIMITS` otherwise: 10 running across the account's spaces (`pool`, the oldest first), 1,000
51
+ waiting, 6 h, slices of 5 min / 30 s CPU / 10,000 calls, 1 MB of state.
52
+ - **The queue's types are the queue's** (`@plitzi/sdk-shared`, `@plitzi/sdk-server`): `ActionJobQueue`, `ActionJob`,
53
+ `ActionJobInput`, `ActionJobStatus`, `ActionJobAttempt`, `ActionJobSettlement`, `ActionJobQuery` are `JobQueue`, `Job`,
54
+ `JobInput`, `JobStatus`, `JobAttempt`, `JobSettlement`, `JobQuery` (`ACTION_JOB_STATUSES` → `JOB_STATUSES`,
55
+ `isJobStatus`, `TERMINAL_JOB_STATUSES`) — the queue holds a schedule's fires, the runs set for later and the jobs of
56
+ the spaces' functions. **What a job runs is its `target`**: `{ kind: 'action', name, trigger }` or
57
+ `{ kind: 'function', name, user, watch, at }`, in place of `actionId`, `trigger` and `function`; `listJobs` filters
58
+ by `kind` and `name`. Also on the queue: `paused` with `pause`/`resume`, `write` for what a running job saves and
59
+ reports, `state`/`progress`/`result`/`activeMs`, `heartbeat` answering `{ jobId, stop: 'cancel' | 'pause' }[]`, a
60
+ settlement's explicit `refund`, `requeue(…, { input, fresh })`. The helpers bring a store a release before left up
61
+ to it by themselves: MySQL's `ensureJobTables` gives each job its target from `action_id`/`trigger_type` and drops
62
+ them (`mysqlJobSchemaUpgrades` lists the statements for a deployment's own migrations); Mongo's queue does the same
63
+ to the documents on first use and drops the `spaceId_1_actionId_1_updatedAt_-1` index. A deployment with a queue of
64
+ its own: the contract tests (`describeJobQueue`) say what it must now do.
65
+ - **A runtime's routes stream** (`@plitzi/sdk-server`): a route under `/fn/` answered by a space's runtime is passed on
66
+ as it is written — its head at once, its body as the code writes it, with the platform's `ctx` — over the functions
67
+ protocol's new `head`/`chunk` messages, with no time limit once it answered; the deployment's own routes stream too.
68
+ A runtime's `endpoints` are for addresses outside `/fn/` (an MCP server at `/mcp`); anything that can live under
69
+ `/fn/` is a route. A sandbox's routes are answered whole, as before.
70
+ - **`createJobControl({ queue, realtime: { pubsub, kv } })`** (`@plitzi/sdk-server/actions`): an operator's
71
+ `pause`/`resume`/`cancel`/`requeue` from a process that serves no pages — a Queue panel's API — each said on
72
+ `$job:<id>` through the page server's own pub/sub and retained store, so a watcher hears what an operator did.
73
+ - **A run's user carries no session** (`RunUser`): what a step, a function and a job see of who asked.
74
+ - **The builder shows the jobs** (`@plitzi/plitzi-builder`, `@plitzi/sdk-shared`): **Server → Functions** lists the
75
+ jobs the code declares as it is typed (how long each may run; one spread in or built by a call is counted, not
76
+ guessed), and the inspector of one says how it is started and who may watch it, with the space's runs of it — live
77
+ while one moves, progress and step as its code reported them — and **Pause**, **Resume**, **Cancel** and **Run
78
+ again**. Through two new builder operations, `SpaceJobs(kind, name, status, page, pageSize)` — a `SpaceJob` each:
79
+ what it runs, where it is and how far, never its input, state or result — and `SpaceControlJob(jobId, control)`
80
+ (`JobControlAction`). Beside them in `@plitzi/sdk-shared/actions`: `JOB_KINDS`/`isJobKind`, and `actionAccessOf`, the
81
+ one reading of a channel's access, which the functions' manifest now reads a job's `watch` with too.
82
+
83
+ - **`ctx.oauth.token` for an SDK in the page** (`@plitzi/sdk-server`, `@plitzi/sdk-shared`): Spotify's Web Playback,
84
+ Google's Picker and their kind ask the page for the access token themselves, and `ctx.oauth` kept every token on the
85
+ server. A connection that declares `exposeToken: true` now answers `ctx.oauth.token(name, { owner })` —
86
+ `{ token, type, expiresAt, scopes }`, renewed first when about to lapse — for a route of the code to hand to the
87
+ connection's owner. The refresh token never leaves; a connection without `exposeToken` refuses `token`, naming the
88
+ field. Through the sandbox's protocol and natively alike.
89
+
90
+ - **A page for some permissions, kept by the server** (`@plitzi/sdk-shared`, `@plitzi/sdk-server`,
91
+ `@plitzi/sdk-authoring`, `@plitzi/sdk-elements`, `@plitzi/plitzi-builder`): a page says
92
+ `access: { permissions: [...] }`, and a visitor without every one is answered 401 (or the page's sign-in redirect) or
93
+ 403 with a refusal drawn in the page's layout. Its content is withheld from everything that visitor is sent — the
94
+ render, the hydration payload, the space document (and a document built for somebody with access is not handed to
95
+ somebody without it by its name) and the page's server data. The builder's page settings take the permissions;
96
+ authoring refuses an `access` the server could not keep (`page-access`). A space read back as code — `plitzi create
97
+ --from`, the Export — keeps each page's `access`, so a protected page is never exported open. A page's handle carries
98
+ its `access` too, and a project's `visual/home.spec.ts` leaves such a page to a test that signs in, as it does a page
99
+ behind a session (`plitzi upgrade` rewrites an untouched one).
100
+ - **A project's first plugin is picked up while it runs** (`@plitzi/sdk-server`): `start:dev` registers a plugin folder
101
+ added under `src/plugins/` and reloads the open pages — but only watched that folder when it existed at boot, so a
102
+ project with no plugin yet (one taken out of a space that had none) showed nothing of its first `plitzi plugin add`
103
+ until a restart. With no folder, the server waits for it to appear and takes what it holds then.
104
+
105
+ ## Packaging
106
+ - **No package ships the declarations of its tests** (`@plitzi/sdk-server`, `@plitzi/sdk-mcp`, `@plitzi/plitzi-sdk`,
107
+ `@plitzi/plitzi-builder`, `@plitzi/sdk-elements`, `@plitzi/sdk-shared`): each app wrote its declarations with its own
108
+ `dts({ exclude })`, and the ones that left the tests out of it shipped a `.test.d.ts` beside their modules — 148 in
109
+ sdk-server alone — and the base config let a `.bench.d.ts` through. Every `dts()` now excludes
110
+ `'**/*.(test|bench).(ts|tsx)'`, and `yarn check:dist-exports` (CI, after `build:prod`) fails a build of any published
111
+ package that holds one.
112
+ - **`@plitzi/plitzi-builder` depends on `graphql` ^16** (was ^17): Apollo Server — the builder's API — supports only
113
+ 16, so a host installing the builder beside it got two copies. The builder uses nothing of 17's.
114
+
115
+ ## Elements
116
+ - **A dropdown closes when a link in it is chosen** (`@plitzi/sdk-elements`): a link stops its click from bubbling,
117
+ and the popup listened for clicks on the way up — so no menu of links ever closed, and a click that did reach it was
118
+ cancelled, which would have kept an external link from going anywhere. The popup now hears the click as it goes down
119
+ and lets it through.
120
+
121
+ ## CLI
122
+ - **A refused push says why** (`@plitzi/cli`): `space push functions` and the data push read any 409 as "changed since
123
+ your pull" — and the platform also answers 409 when the space has no private bucket to keep its code or data in, so
124
+ a first push to a space with no storage sent its author to pull, which changed nothing. The CLI now names a conflict
125
+ only when the refusal says `version`, and prints the platform's own words otherwise (where to add the bucket).
126
+ - **`create` points at the Academy** (`@plitzi/cli`): its last lines name the docs' Academy,
127
+ `https://docs.plitzi.com/academy`, for whoever is new to Plitzi — and the README the docs themselves.
128
+
129
+ ## Builder
130
+ - **A space served by Plitzi has a server, and the builder says so** (`@plitzi/plitzi-builder`, `@plitzi/sdk-shared`):
131
+ whether a space can run its actions and resolve its connectors was read off an SSR _credential_, which only a space
132
+ deployed to a page server of its own has — so every space served at `<space>.plitzi.app` showed "No server-rendered
133
+ deployment" over Server and counted its actions unavailable, while they ran. The deployments now carry what serves
134
+ them (`provider`), and a deployment served by SSR — Plitzi's or the space's — counts.
135
+ - **New Layout saves the layout** (`@plitzi/sdk-schema`): a layout is a root of the pages' tree, added with no anchor,
136
+ and `flatMapOf` found no tree for an empty anchor — so the server refused every new layout, saying it was "already
137
+ added". A root now goes into the pages' tree, and the refusal says which of the two it is.
138
+ - **Settings → Realtime: a space's channels, declared by hand** (`@plitzi/plitzi-builder`): `settings.channels` was
139
+ written only in code or by an agent over MCP, so a space made in the builder could not open a channel. The section
140
+ lists the channels with who may join (anyone, signed-in visitors, visitors with permissions), who may speak (pages, or
141
+ only the server's `Publish On Channel`), presence, a grant, keeping the last message and the two limits — saved only
142
+ when `channelProblems` passes, with what is wrong said under the channel otherwise.
143
+
144
+ - Updated dependencies [19fbc45]
145
+ - @plitzi/sdk-auth@0.38.21
146
+ - @plitzi/sdk-event-bridge@0.38.21
147
+ - @plitzi/sdk-interactions@0.38.21
148
+ - @plitzi/sdk-navigation@0.38.21
149
+ - @plitzi/sdk-schema@0.38.21
150
+ - @plitzi/sdk-shared@0.38.21
151
+
3
152
  ## 0.38.20
4
153
 
5
154
  ### Patch Changes
@@ -13,7 +13,7 @@ var c = ({ ref: e, className: c = "", children: l }) => {
13
13
  ref: u,
14
14
  className: o("plitzi-component__dropdown-popup", c, { "popup-container--no-visible": !d || !f }),
15
15
  style: f,
16
- onClick: p,
16
+ onClickCapture: p,
17
17
  children: l
18
18
  });
19
19
  return m ? s(h, m) : h;
@@ -15,8 +15,8 @@ var a = ({ ref: a, popupRef: o, open: s, placement: c = "bottom", disabled: l =
15
15
  u,
16
16
  o,
17
17
  S
18
- ]), w = e((e) => {
19
- l || u || !d || (e.stopPropagation(), e.preventDefault(), S());
18
+ ]), w = e(() => {
19
+ l || u || !d || S();
20
20
  }, [
21
21
  d,
22
22
  l,
@@ -3025,6 +3025,8 @@ export declare const elementDeclarations: {
3025
3025
  seoPageTitle?: string | undefined;
3026
3026
  seoPageDescription?: string | undefined;
3027
3027
  documentScroll?: (import('.').DocumentScroll | "") | undefined;
3028
+ withheld?: import('@plitzi/sdk-shared/schema').PageWithheld | undefined;
3029
+ access?: import('@plitzi/sdk-shared/schema').PageAccess | undefined;
3028
3030
  }>>;
3029
3031
  readonly Pagination: import('@plitzi/sdk-shared/authoring').DeclaredElement<{
3030
3032
  readonly type: "pagination";
@@ -1,4 +1,5 @@
1
1
  import { DocumentScroll } from './declaration';
2
+ import { PageAccess, PageWithheld as WithheldReason } from '@plitzi/sdk-shared/schema';
2
3
  import { ReactNode, RefObject } from 'react';
3
4
  export type PageProps = {
4
5
  ref?: RefObject<HTMLElement>;
@@ -20,12 +21,22 @@ export type PageProps = {
20
21
  * inside another space is embedded in, nor the builder's.
21
22
  */
22
23
  documentScroll?: DocumentScroll | '';
24
+ /**
25
+ * The permissions a visitor must hold to see this page — read by the server, which withholds the page from anybody
26
+ * without them. Nothing for the page itself to do with.
27
+ */
28
+ access?: PageAccess;
29
+ /**
30
+ * Set by the server on a page it withheld from this visitor (`access` they do not meet): the content was not sent,
31
+ * and the page says why instead. Never authored.
32
+ */
33
+ withheld?: WithheldReason;
23
34
  className?: string;
24
35
  layout?: string;
25
36
  layoutContainer?: string;
26
37
  children?: ReactNode;
27
38
  };
28
- declare const Page: ({ ref, seoEnabled, seoPageTitle, seoPageDescription, documentScroll, className, layout, layoutContainer, children }: PageProps) => import('react').JSX.Element;
39
+ declare const Page: ({ ref, seoEnabled, seoPageTitle, seoPageDescription, documentScroll, withheld, className, layout, layoutContainer, children }: PageProps) => import('react').JSX.Element;
29
40
  declare const _default: {
30
41
  (props: import('../../..').WithElementProps<PageProps>): import('react').JSX.Element;
31
42
  displayName: string;
@@ -6,66 +6,68 @@ import { RootElement as i } from "../../../Element/RootElement.mjs";
6
6
  import a from "../LayoutContainer/index.mjs";
7
7
  import o from "../../../Element/hooks/useLayoutChain.mjs";
8
8
  import s from "./PageHead.mjs";
9
- import { use as c, useEffect as l, useMemo as u } from "react";
10
- import { usePlitzi as d } from "@plitzi/sdk-shared/hooks";
11
- import { useRenderSettings as f, useSdkStore as p } from "@plitzi/sdk-shared/store";
12
- import { jsx as m, jsxs as h } from "react/jsx-runtime";
13
- import g from "clsx";
14
- import { InteractionsContext as _ } from "@plitzi/sdk-interactions";
9
+ import c from "./PageWithheld.mjs";
10
+ import { use as l, useEffect as u, useMemo as d } from "react";
11
+ import { usePlitzi as f } from "@plitzi/sdk-shared/hooks";
12
+ import { useRenderSettings as p, useSdkStore as m } from "@plitzi/sdk-shared/store";
13
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
14
+ import _ from "clsx";
15
+ import { InteractionsContext as v } from "@plitzi/sdk-interactions";
15
16
  //#region src/elements/internal/Page/Page.tsx
16
- var v = {
17
+ var y = {
17
18
  locked: "html,body{height:100%;overflow:hidden;overscroll-behavior:none}",
18
19
  noBounce: "html,body{overscroll-behavior:none}"
19
- }, y = (e) => e.map((e) => ({
20
+ }, b = (e) => e.map((e) => ({
20
21
  ...e,
21
22
  plitziElementLayout: {
22
23
  slots: [e.slot],
23
24
  rootId: e.slot,
24
25
  type: "layout"
25
26
  }
26
- })), b = (t, n, r) => t.reduce((t, { layout: r, slot: i, plitziElementLayout: o }) => /* @__PURE__ */ m(e, {
27
+ })), x = (t, n, r) => t.reduce((t, { layout: r, slot: i, plitziElementLayout: o }) => /* @__PURE__ */ h(e, {
27
28
  bodies: { [i]: t },
28
- children: /* @__PURE__ */ m(a, { internalProps: {
29
+ children: /* @__PURE__ */ h(a, { internalProps: {
29
30
  id: r,
30
31
  rootId: n,
31
32
  plitziElementLayout: o
32
33
  } })
33
- }, i), r), x = ({ ref: e, seoEnabled: n = !1, seoPageTitle: a = "Title", seoPageDescription: x = "Description", documentScroll: S = "", className: C = "", layout: w = "", layoutContainer: T = "", children: E }) => {
34
- let { id: D } = r(), { settings: { previewMode: O } } = d(), { interactionsManager: k } = c(_), { ownsHead: A, renderMode: j } = f(), M = A && j !== "widget", [[N, P]] = p(["navigation.routeParams", "navigation.queryParams"]), F = o(w, T), I = u(() => y(F), [F]), L = u(() => b(I, D, E), [
35
- I,
36
- D,
37
- E
34
+ }, i), r), S = ({ ref: e, seoEnabled: n = !1, seoPageTitle: a = "Title", seoPageDescription: S = "Description", documentScroll: C = "", withheld: w, className: T = "", layout: E = "", layoutContainer: D = "", children: O }) => {
35
+ let { id: k } = r(), { settings: { previewMode: A } } = f(), { interactionsManager: j } = l(v), { ownsHead: M, renderMode: N } = p(), P = M && N !== "widget", [[F, I]] = m(["navigation.routeParams", "navigation.queryParams"]), L = o(E, D), R = d(() => b(L), [L]), z = d(() => x(R, k, w ? /* @__PURE__ */ h(c, { reason: w }) : O), [
36
+ R,
37
+ k,
38
+ O,
39
+ w
38
40
  ]);
39
- return l(() => {
41
+ return u(() => {
40
42
  let e = !1;
41
43
  return queueMicrotask(() => {
42
- e || k.interactionTrigger(D, "onPageLoad", {
43
- pageId: D,
44
- routeParams: N,
45
- queryParams: P
44
+ e || j.interactionTrigger(k, "onPageLoad", {
45
+ pageId: k,
46
+ routeParams: F,
47
+ queryParams: I
46
48
  });
47
49
  }), () => {
48
50
  e = !0;
49
51
  };
50
52
  }, [
51
- D,
52
53
  k,
53
- P,
54
- N
55
- ]), /* @__PURE__ */ h(i, {
54
+ j,
55
+ I,
56
+ F
57
+ ]), /* @__PURE__ */ g(i, {
56
58
  ref: e,
57
- className: g("plitzi-component__page", C),
59
+ className: _("plitzi-component__page", T),
58
60
  interactionTriggers: t.triggers,
59
61
  children: [
60
- n && O && A && /* @__PURE__ */ m(s, {
61
- pageId: D,
62
+ n && A && M && /* @__PURE__ */ h(s, {
63
+ pageId: k,
62
64
  title: a,
63
- description: x
65
+ description: S
64
66
  }),
65
- S && M && /* @__PURE__ */ m("style", { children: v[S] }),
66
- L
67
+ C && P && /* @__PURE__ */ h("style", { children: y[C] }),
68
+ z
67
69
  ]
68
70
  });
69
- }, S = n(x);
71
+ }, C = n(S);
70
72
  //#endregion
71
- export { x as Page, S as default };
73
+ export { S as Page, C as default };
@@ -0,0 +1,10 @@
1
+ import { PageWithheld as Reason } from '@plitzi/sdk-shared/schema';
2
+ export type PageWithheldProps = {
3
+ reason: Reason;
4
+ };
5
+ /**
6
+ * What a page the server withheld from this visitor shows instead of its content — which was never sent: why, in a
7
+ * sentence, inside the page's own layout so the site around it still works. The server answers it with 401 or 403.
8
+ */
9
+ declare const PageWithheld: ({ reason }: PageWithheldProps) => import('react').JSX.Element;
10
+ export default PageWithheld;
@@ -0,0 +1,43 @@
1
+ import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
+ //#region src/elements/internal/Page/PageWithheld.tsx
3
+ var n = {
4
+ unauthenticated: {
5
+ title: "Sign in to see this page",
6
+ text: "This page is for people who are signed in and have access to it."
7
+ },
8
+ forbidden: {
9
+ title: "This page is not available to you",
10
+ text: "It is for people with access you do not have. If you think you should, ask whoever runs this site."
11
+ }
12
+ }, r = {
13
+ display: "flex",
14
+ flexDirection: "column",
15
+ gap: "8px",
16
+ maxWidth: "560px",
17
+ margin: "64px auto",
18
+ padding: "0 16px",
19
+ textAlign: "center",
20
+ color: "var(--foreground, inherit)"
21
+ }, i = {
22
+ margin: 0,
23
+ fontSize: "24px",
24
+ lineHeight: 1.25
25
+ }, a = {
26
+ margin: 0,
27
+ color: "var(--muted, inherit)",
28
+ fontSize: "16px",
29
+ lineHeight: 1.55
30
+ }, o = ({ reason: o }) => /* @__PURE__ */ t("section", {
31
+ className: "plitzi-component__page-withheld",
32
+ style: r,
33
+ "data-withheld": o,
34
+ children: [/* @__PURE__ */ e("h1", {
35
+ style: i,
36
+ children: n[o].title
37
+ }), /* @__PURE__ */ e("p", {
38
+ style: a,
39
+ children: n[o].text
40
+ })]
41
+ });
42
+ //#endregion
43
+ export { o as default };
@@ -1,4 +1,5 @@
1
1
  import { DocumentScroll } from './declaration';
2
+ import { PageAccess } from '@plitzi/sdk-shared/schema';
2
3
  type SettingsProps = {
3
4
  id?: string;
4
5
  seoEnabled?: boolean;
@@ -14,7 +15,8 @@ type SettingsProps = {
14
15
  unauthorizedBehaviour?: '' | 'redirect';
15
16
  unauthorizedPageRedirect?: string;
16
17
  documentScroll?: DocumentScroll | '';
17
- onUpdate?: (key: string, value: string | boolean | number) => void;
18
+ access?: PageAccess | '';
19
+ onUpdate?: (key: string, value: string | boolean | number | PageAccess) => void;
18
20
  };
19
- declare const Settings: ({ id, seoEnabled, enabled, name, folder, seoPageTitle, seoPageDescription, slug, layout, layoutContainer, accessLevel, unauthorizedBehaviour, unauthorizedPageRedirect, documentScroll, onUpdate }: SettingsProps) => import('react').JSX.Element;
21
+ declare const Settings: ({ id, seoEnabled, enabled, name, folder, seoPageTitle, seoPageDescription, slug, layout, layoutContainer, accessLevel, unauthorizedBehaviour, unauthorizedPageRedirect, documentScroll, access, onUpdate }: SettingsProps) => import('react').JSX.Element;
20
22
  export default Settings;
@@ -1,243 +1,266 @@
1
1
  import e from "../../useSettingsUpdate.mjs";
2
2
  import t from "../LayoutPicker/index.mjs";
3
- import { useCallback as n, useMemo as r } from "react";
4
- import { useCommonStore as i } from "@plitzi/sdk-shared/store";
5
- import { get as a, pick as o } from "@plitzi/plitzi-ui/helpers";
6
- import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
7
- import { getPageFullPath as u } from "@plitzi/sdk-navigation";
8
- import d from "@plitzi/plitzi-ui/Alert";
9
- import f from "@plitzi/plitzi-ui/Checkbox";
10
- import p from "@plitzi/plitzi-ui/Input";
11
- import m from "@plitzi/plitzi-ui/TextArea";
12
- import h from "@plitzi/plitzi-ui/Select";
13
- import g from "@plitzi/plitzi-ui/Select2";
3
+ import { useCallback as n, useEffect as r, useMemo as i, useState as a } from "react";
4
+ import { useCommonStore as o } from "@plitzi/sdk-shared/store";
5
+ import { get as s, pick as c } from "@plitzi/plitzi-ui/helpers";
6
+ import { pageAccessOf as l } from "@plitzi/sdk-shared/schema";
7
+ import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
8
+ import { getPageFullPath as p } from "@plitzi/sdk-navigation";
9
+ import m from "@plitzi/plitzi-ui/Alert";
10
+ import h from "@plitzi/plitzi-ui/Checkbox";
11
+ import g from "@plitzi/plitzi-ui/Input";
12
+ import _ from "@plitzi/plitzi-ui/TextArea";
13
+ import v from "@plitzi/plitzi-ui/Select";
14
+ import y from "@plitzi/plitzi-ui/Select2";
14
15
  //#region src/elements/internal/Page/Settings.tsx
15
- var _ = ({ id: _ = "", seoEnabled: v = !1, enabled: y = !0, name: b = "", folder: x = "", seoPageTitle: S = "Title", seoPageDescription: C = "Description", slug: w = "", layout: T = "", layoutContainer: E = "", accessLevel: D = "", unauthorizedBehaviour: O = "", unauthorizedPageRedirect: k = "", documentScroll: A = "", onUpdate: j }) => {
16
- let [[M, N, P]] = i([
16
+ var b = ({ id: b = "", seoEnabled: x = !1, enabled: S = !0, name: C = "", folder: w = "", seoPageTitle: T = "Title", seoPageDescription: E = "Description", slug: D = "", layout: O = "", layoutContainer: k = "", accessLevel: A = "", unauthorizedBehaviour: j = "", unauthorizedPageRedirect: M = "", documentScroll: N = "", access: P = "", onUpdate: F }) => {
17
+ let I = l({ access: P })?.permissions.join(", ") ?? "", [L, R] = a(I);
18
+ r(() => R(I), [I]);
19
+ let [[z, B, V]] = o([
17
20
  "schema.flat",
18
21
  "schema.pages",
19
22
  "schema.pageFolders"
20
- ]), F = r(() => Object.values(o(M, N.filter((e) => e !== _))), [
21
- M,
22
- _,
23
- N
24
- ]), I = e(j), L = n((e) => {
25
- j?.("name", e);
26
- let t = b.replaceAll(" ", "-").toLowerCase().replaceAll(/([^a-z0-9]+)/gi, "");
27
- (!w || w === t) && j?.("slug", e.replaceAll(" ", "-").toLowerCase().replaceAll(/([^a-z0-9-]+)/gi, ""));
23
+ ]), H = i(() => Object.values(c(z, B.filter((e) => e !== b))), [
24
+ z,
25
+ b,
26
+ B
27
+ ]), U = e(F), W = n((e) => {
28
+ F?.("name", e);
29
+ let t = C.replaceAll(" ", "-").toLowerCase().replaceAll(/([^a-z0-9]+)/gi, "");
30
+ (!D || D === t) && F?.("slug", e.replaceAll(" ", "-").toLowerCase().replaceAll(/([^a-z0-9-]+)/gi, ""));
28
31
  }, [
29
- j,
30
- w,
31
- b
32
- ]), R = n((e) => {
32
+ F,
33
+ D,
34
+ C
35
+ ]), G = n((e) => {
33
36
  if (/^[a-zA-Z0-9:*/_-]+$/gim.test(e) || !e) {
34
37
  let t = e.replaceAll("//", "/");
35
- j?.("slug", t);
38
+ F?.("slug", t);
36
39
  }
37
- }, [j]), z = n((e) => {
38
- j?.("accessLevel", e), j?.("unauthorizedBehaviour", ""), j?.("unauthorizedPageRedirect", "");
39
- }, [j]), B = n((e) => j?.("seoEnabled", e.target.checked), [j]), V = n((e) => j?.("enabled", e.target.checked), [j]), H = n((e) => j?.("folder", e?.value ?? ""), [j]), U = r(() => [{
40
+ }, [F]), K = n((e) => {
41
+ F?.("accessLevel", e), F?.("unauthorizedBehaviour", ""), F?.("unauthorizedPageRedirect", "");
42
+ }, [F]), q = n(() => {
43
+ let e = L.split(",").map((e) => e.trim()).filter(Boolean);
44
+ F?.("access", e.length > 0 ? { permissions: e } : "");
45
+ }, [F, L]), J = n((e) => F?.("seoEnabled", e.target.checked), [F]), Y = n((e) => F?.("enabled", e.target.checked), [F]), X = n((e) => F?.("folder", e?.value ?? ""), [F]), Z = i(() => [{
40
46
  value: "",
41
47
  label: "None"
42
- }, ...P.map(({ id: e, name: t }) => ({
48
+ }, ...V.map(({ id: e, name: t }) => ({
43
49
  value: e,
44
50
  label: t
45
- }))], [P]), W = r(() => u(M, P, _, !0), [
46
- M,
47
- P,
48
- _
51
+ }))], [V]), Q = i(() => p(z, V, b, !0), [
52
+ z,
53
+ V,
54
+ b
49
55
  ]);
50
- return /* @__PURE__ */ l("div", {
56
+ return /* @__PURE__ */ f("div", {
51
57
  className: "flex flex-col gap-4 py-2",
52
58
  children: [
53
- !y && /* @__PURE__ */ c(d, {
59
+ !S && /* @__PURE__ */ d(m, {
54
60
  intent: "info",
55
61
  size: "xs",
56
62
  solid: !1,
57
- children: /* @__PURE__ */ c("span", {
63
+ children: /* @__PURE__ */ d("span", {
58
64
  className: "text-xs",
59
65
  children: "When this option is disable, this page wont be accesible"
60
66
  })
61
67
  }),
62
- /* @__PURE__ */ c(f, {
68
+ /* @__PURE__ */ d(h, {
63
69
  label: " Page Enabled",
64
- checked: y,
65
- onChange: V,
70
+ checked: S,
71
+ onChange: Y,
66
72
  size: "xs"
67
73
  }),
68
- /* @__PURE__ */ c(p, {
69
- value: b,
74
+ /* @__PURE__ */ d(g, {
75
+ value: C,
70
76
  label: "Page Name",
71
- onChange: L,
77
+ onChange: W,
72
78
  size: "xs"
73
79
  }),
74
- /* @__PURE__ */ c(d, {
80
+ /* @__PURE__ */ d(m, {
75
81
  intent: "info",
76
82
  size: "xs",
77
83
  solid: !1,
78
- children: /* @__PURE__ */ c("span", {
84
+ children: /* @__PURE__ */ d("span", {
79
85
  className: "text-xs",
80
86
  children: "Slug is a combination of letters, numbers and _ - : / *"
81
87
  })
82
88
  }),
83
- /* @__PURE__ */ l("div", {
89
+ /* @__PURE__ */ f("div", {
84
90
  className: "flex flex-col",
85
- children: [/* @__PURE__ */ c(p, {
86
- value: w,
87
- onChange: R,
91
+ children: [/* @__PURE__ */ d(g, {
92
+ value: D,
93
+ onChange: G,
88
94
  label: "Slug / Path",
89
95
  className: { inputContainer: "rounded-none rounded-tl rounded-tr" },
90
96
  size: "xs"
91
- }), /* @__PURE__ */ l("div", {
97
+ }), /* @__PURE__ */ f("div", {
92
98
  className: "truncate rounded-b border-x border-b border-gray-200 px-1 py-0.5 text-xs",
93
- title: W,
94
- children: ["Full Path: ", /* @__PURE__ */ c("span", {
99
+ title: Q,
100
+ children: ["Full Path: ", /* @__PURE__ */ d("span", {
95
101
  className: "font-bold",
96
- children: W
102
+ children: Q
97
103
  })]
98
104
  })]
99
105
  }),
100
- /* @__PURE__ */ c(g, {
106
+ /* @__PURE__ */ d(y, {
101
107
  label: "Folder",
102
- value: x,
103
- options: U,
108
+ value: w,
109
+ options: Z,
104
110
  placeholder: "None",
105
- onChange: H,
111
+ onChange: X,
106
112
  size: "xs"
107
113
  }),
108
- /* @__PURE__ */ c(t, {
109
- layout: T,
110
- layoutContainer: E,
111
- onUpdate: j
114
+ /* @__PURE__ */ d(t, {
115
+ layout: O,
116
+ layoutContainer: k,
117
+ onUpdate: F
112
118
  }),
113
- /* @__PURE__ */ l(h, {
114
- value: D,
119
+ /* @__PURE__ */ f(v, {
120
+ value: A,
115
121
  label: "Restrict Access",
116
- onChange: z,
122
+ onChange: K,
117
123
  placeholder: "None",
118
124
  size: "xs",
119
- children: [/* @__PURE__ */ c("option", {
125
+ children: [/* @__PURE__ */ d("option", {
120
126
  value: "public",
121
127
  children: "Public"
122
- }), /* @__PURE__ */ c("option", {
128
+ }), /* @__PURE__ */ d("option", {
123
129
  value: "authenticated",
124
130
  children: "Authenticated"
125
131
  })]
126
132
  }),
127
- D === "" && /* @__PURE__ */ c(d, {
133
+ A === "" && /* @__PURE__ */ d(m, {
128
134
  intent: "info",
129
135
  solid: !1,
130
136
  size: "xs",
131
- children: /* @__PURE__ */ c("span", {
137
+ children: /* @__PURE__ */ d("span", {
132
138
  className: "text-xs",
133
139
  children: "Anyone on the internet can access this page"
134
140
  })
135
141
  }),
136
- D === "public" && /* @__PURE__ */ c(d, {
142
+ A === "public" && /* @__PURE__ */ d(m, {
137
143
  intent: "info",
138
144
  solid: !1,
139
145
  size: "xs",
140
- children: /* @__PURE__ */ c("span", {
146
+ children: /* @__PURE__ */ d("span", {
141
147
  className: "text-xs",
142
148
  children: "Only Guest can access this page"
143
149
  })
144
150
  }),
145
- D !== "" && /* @__PURE__ */ c(h, {
151
+ /* @__PURE__ */ d(g, {
152
+ label: "Required permissions",
153
+ value: L,
154
+ onChange: R,
155
+ onBlur: q,
156
+ placeholder: "None — anybody this page is for",
157
+ size: "xs"
158
+ }),
159
+ I !== "" && /* @__PURE__ */ d(m, {
160
+ intent: "info",
161
+ solid: !1,
162
+ size: "xs",
163
+ children: /* @__PURE__ */ d("span", {
164
+ className: "text-xs",
165
+ children: "Only visitors holding every one of these see this page. Anybody else is answered 401 or 403, and the server never sends them its content"
166
+ })
167
+ }),
168
+ (A !== "" || I !== "") && /* @__PURE__ */ d(v, {
146
169
  label: "Unauthorized Behaviour",
147
- value: O,
148
- onChange: I.text("unauthorizedBehaviour"),
170
+ value: j,
171
+ onChange: U.text("unauthorizedBehaviour"),
149
172
  placeholder: "None",
150
173
  size: "xs",
151
- children: /* @__PURE__ */ c("option", {
174
+ children: /* @__PURE__ */ d("option", {
152
175
  value: "redirect",
153
176
  children: "Redirect"
154
177
  })
155
178
  }),
156
- O === "redirect" && /* @__PURE__ */ c(h, {
157
- value: k,
179
+ j === "redirect" && /* @__PURE__ */ d(v, {
180
+ value: M,
158
181
  label: "Redirect Page",
159
- onChange: I.text("unauthorizedPageRedirect"),
182
+ onChange: U.text("unauthorizedPageRedirect"),
160
183
  placeholder: "None",
161
184
  size: "xs",
162
- children: F.map((e) => /* @__PURE__ */ c("option", {
185
+ children: H.map((e) => /* @__PURE__ */ d("option", {
163
186
  value: e.id,
164
- children: a(e, "attributes.name")
187
+ children: s(e, "attributes.name")
165
188
  }, e.id))
166
189
  }),
167
- /* @__PURE__ */ l(h, {
168
- value: A,
190
+ /* @__PURE__ */ f(v, {
191
+ value: N,
169
192
  label: "Document Scroll",
170
- onChange: I.text("documentScroll"),
193
+ onChange: U.text("documentScroll"),
171
194
  placeholder: "Scrolls",
172
195
  size: "xs",
173
- children: [/* @__PURE__ */ c("option", {
196
+ children: [/* @__PURE__ */ d("option", {
174
197
  value: "noBounce",
175
198
  children: "No bounce"
176
- }), /* @__PURE__ */ c("option", {
199
+ }), /* @__PURE__ */ d("option", {
177
200
  value: "locked",
178
201
  children: "Locked"
179
202
  })]
180
203
  }),
181
- A === "noBounce" && /* @__PURE__ */ c(d, {
204
+ N === "noBounce" && /* @__PURE__ */ d(m, {
182
205
  intent: "info",
183
206
  solid: !1,
184
207
  size: "xs",
185
- children: /* @__PURE__ */ c("span", {
208
+ children: /* @__PURE__ */ d("span", {
186
209
  className: "text-xs",
187
210
  children: "The page scrolls, but a finger pulled past either end no longer bounces it or reloads it"
188
211
  })
189
212
  }),
190
- A === "locked" && /* @__PURE__ */ c(d, {
213
+ N === "locked" && /* @__PURE__ */ d(m, {
191
214
  intent: "info",
192
215
  solid: !1,
193
216
  size: "xs",
194
- children: /* @__PURE__ */ c("span", {
217
+ children: /* @__PURE__ */ d("span", {
195
218
  className: "text-xs",
196
219
  children: "The page holds still: only the parts set to scroll on their own (overflow auto) move. For a screen that fills the window — a dashboard, a board"
197
220
  })
198
221
  }),
199
- /* @__PURE__ */ c(f, {
222
+ /* @__PURE__ */ d(h, {
200
223
  label: " SEO Enabled",
201
- checked: v,
202
- onChange: B,
224
+ checked: x,
225
+ onChange: J,
203
226
  size: "xs"
204
227
  }),
205
- v && /* @__PURE__ */ l(s, { children: [
206
- /* @__PURE__ */ c(p, {
207
- value: S,
228
+ x && /* @__PURE__ */ f(u, { children: [
229
+ /* @__PURE__ */ d(g, {
230
+ value: T,
208
231
  label: "SEO Title",
209
- onChange: I.text("seoPageTitle"),
232
+ onChange: U.text("seoPageTitle"),
210
233
  size: "xs"
211
234
  }),
212
- /* @__PURE__ */ c(m, {
235
+ /* @__PURE__ */ d(_, {
213
236
  label: "SEO Description",
214
- value: C,
215
- onChange: I.text("seoPageDescription"),
237
+ value: E,
238
+ onChange: U.text("seoPageDescription"),
216
239
  rows: 3,
217
240
  size: "xs"
218
241
  }),
219
- /* @__PURE__ */ l("div", {
242
+ /* @__PURE__ */ f("div", {
220
243
  className: "flex flex-col",
221
244
  children: [
222
- /* @__PURE__ */ c("p", {
245
+ /* @__PURE__ */ d("p", {
223
246
  className: "mb-4 text-xs",
224
247
  children: "Specify this page's title and description. You can see how they'll look in search engine results pages (SERPs) in the preview below."
225
248
  }),
226
- /* @__PURE__ */ c("label", { children: "Search Result Preview" }),
227
- /* @__PURE__ */ l("div", {
249
+ /* @__PURE__ */ d("label", { children: "Search Result Preview" }),
250
+ /* @__PURE__ */ f("div", {
228
251
  className: "rounded border border-gray-300 px-2 py-1",
229
252
  children: [
230
- /* @__PURE__ */ c("div", {
253
+ /* @__PURE__ */ d("div", {
231
254
  className: "mb-1 pt-1 text-xl text-[#1a0dab]",
232
- children: /* @__PURE__ */ c("label", { children: S })
255
+ children: /* @__PURE__ */ d("label", { children: T })
233
256
  }),
234
- /* @__PURE__ */ c("div", {
257
+ /* @__PURE__ */ d("div", {
235
258
  className: "text-sm text-[#006621]",
236
- children: /* @__PURE__ */ c("span", { children: "www.url.com" })
259
+ children: /* @__PURE__ */ d("span", { children: "www.url.com" })
237
260
  }),
238
- /* @__PURE__ */ c("div", {
261
+ /* @__PURE__ */ d("div", {
239
262
  className: "settings-seo__description mb-1 pt-1 text-sm",
240
- children: `${C.slice(0, 160)}...`
263
+ children: `${E.slice(0, 160)}...`
241
264
  })
242
265
  ]
243
266
  })
@@ -248,4 +271,4 @@ var _ = ({ id: _ = "", seoEnabled: v = !1, enabled: y = !0, name: b = "", folder
248
271
  });
249
272
  };
250
273
  //#endregion
251
- export { _ as default };
274
+ export { b as default };
@@ -81,5 +81,7 @@ declare const declaration: import('@plitzi/sdk-shared/authoring').DeclaredElemen
81
81
  seoPageTitle?: string | undefined;
82
82
  seoPageDescription?: string | undefined;
83
83
  documentScroll?: (DocumentScroll | "") | undefined;
84
+ withheld?: import('@plitzi/sdk-shared/schema').PageWithheld | undefined;
85
+ access?: import('@plitzi/sdk-shared/schema').PageAccess | undefined;
84
86
  }>>;
85
87
  export default declaration;
@@ -75,5 +75,7 @@ declare const Page: {
75
75
  seoPageTitle?: string | undefined;
76
76
  seoPageDescription?: string | undefined;
77
77
  documentScroll?: (import('./declaration').DocumentScroll | "") | undefined;
78
+ withheld?: import('@plitzi/sdk-shared/schema').PageWithheld | undefined;
79
+ access?: import('@plitzi/sdk-shared/schema').PageAccess | undefined;
78
80
  }>>;
79
81
  export default Page;
package/dist/index.d.ts CHANGED
@@ -716,6 +716,8 @@ export declare const defaultElements: {
716
716
  seoPageTitle?: string | undefined;
717
717
  seoPageDescription?: string | undefined;
718
718
  documentScroll?: (import('./elements/declarations').DocumentScroll | "") | undefined;
719
+ withheld?: import('@plitzi/sdk-shared/schema').PageWithheld | undefined;
720
+ access?: import('@plitzi/sdk-shared/schema').PageAccess | undefined;
719
721
  }>>;
720
722
  container: {
721
723
  (props: import('.').WithElementProps<import('./elements/structure/Container/Container').ContainerProps>): import('react').JSX.Element;
@@ -3731,6 +3733,7 @@ export declare const defaultElements: {
3731
3733
  };
3732
3734
  export { useRscData, elements, JsxManager };
3733
3735
  export { default as useChannel } from './realtime/useChannel';
3736
+ export { default as useJob } from './realtime/useJob';
3734
3737
  export { default as useFlag } from './dataSource/useFlag';
3735
3738
  export type { ChannelHandle, UseChannelOptions } from './realtime/useChannel';
3736
3739
  export { default as withElement } from './Element/hocs/withElement';
package/dist/index.mjs CHANGED
@@ -43,12 +43,13 @@ import V from "./elements/structure/ModalContainer/index.mjs";
43
43
  import H from "./elements/structure/Pagination/index.mjs";
44
44
  import U from "./elements/structure/TabContainer/index.mjs";
45
45
  import { elements_exports as W } from "./elements/index.mjs";
46
- import G from "./dataSource/useFlag.mjs";
47
- import K from "./Element/helpers/elementChildren.mjs";
48
- import q from "./Element/hooks/useElementVisible.mjs";
49
- import J from "./Element/hooks/usePluginTrigger.mjs";
46
+ import G from "./realtime/useJob.mjs";
47
+ import K from "./dataSource/useFlag.mjs";
48
+ import q from "./Element/helpers/elementChildren.mjs";
49
+ import J from "./Element/hooks/useElementVisible.mjs";
50
+ import Y from "./Element/hooks/usePluginTrigger.mjs";
50
51
  //#region src/index.ts
51
- var Y = {
52
+ var X = {
52
53
  dropdown: h,
53
54
  notFound: D,
54
55
  loading: E,
@@ -85,4 +86,4 @@ var Y = {
85
86
  channel: I
86
87
  };
87
88
  //#endregion
88
- export { P as ApiContainer, s as BlockHtml, c as BlockJsx, m as Button, L as Carousel, I as Channel, R as Container, l as Custom, z as DialogContainer, h as Dropdown, e as ElementContext, k as Embed, A as FontAwesome, C as Form, w as FormControl, g as Heading, j as Image, o as JsxManager, T as LayoutContainer, _ as Link, B as List, E as Loading, v as Markdown, V as ModalContainer, u as NodeHtml, D as NotFound, O as Page, H as Pagination, y as Paragraph, d as PluginManager, t as PluginRemote, p as Reference, f as ReplicaProvider, b as RichText, a as RootElement, M as Svg, U as TabContainer, x as Text, S as ThemeToggle, N as Video, Y as defaultElements, K as elementChildren, W as elements, F as useChannel, r as useElement, q as useElementVisible, G as useFlag, J as usePluginTrigger, i as useRscData, n as withElement };
89
+ export { P as ApiContainer, s as BlockHtml, c as BlockJsx, m as Button, L as Carousel, I as Channel, R as Container, l as Custom, z as DialogContainer, h as Dropdown, e as ElementContext, k as Embed, A as FontAwesome, C as Form, w as FormControl, g as Heading, j as Image, o as JsxManager, T as LayoutContainer, _ as Link, B as List, E as Loading, v as Markdown, V as ModalContainer, u as NodeHtml, D as NotFound, O as Page, H as Pagination, y as Paragraph, d as PluginManager, t as PluginRemote, p as Reference, f as ReplicaProvider, b as RichText, a as RootElement, M as Svg, U as TabContainer, x as Text, S as ThemeToggle, N as Video, X as defaultElements, q as elementChildren, W as elements, F as useChannel, r as useElement, J as useElementVisible, K as useFlag, G as useJob, Y as usePluginTrigger, i as useRscData, n as withElement };
@@ -1,65 +1,65 @@
1
1
  import { useCallback as e, useEffect as t, useMemo as n, useRef as r, useState as i } from "react";
2
2
  import { useCommonStore as a } from "@plitzi/sdk-shared/store";
3
- import { REVOKED_TYPE as o, isValidTopic as s, matchChannel as c, realtimeClientFor as l, trackPresence as u } from "@plitzi/sdk-shared/realtime";
3
+ import { REVOKED_TYPE as o, isValidTopic as s, jobOfTopic as c, matchChannel as l, realtimeClientFor as u, trackPresence as d } from "@plitzi/sdk-shared/realtime";
4
4
  //#region src/realtime/useChannel.ts
5
- var d = (e, t) => {
5
+ var f = (e, t) => {
6
6
  if (Object.hasOwn(e, t.type) && e[t.type].at > t.at) return e;
7
7
  let n = Object.fromEntries(Object.entries(e).filter(([e]) => e !== t.type));
8
8
  return t.data === null ? n : {
9
9
  ...n,
10
10
  [t.type]: t
11
11
  };
12
- }, f = (f, { grant: p, presence: m, onMessage: h, onJoin: g, onLeave: _ } = {}) => {
13
- let [v] = a("schema.settings.channels"), y = f && (v ? c(f, v) : s(f)) ? f : void 0, [b] = a("realtime.endpoint"), [x] = a("realtime.transport"), S = n(() => b && typeof window < "u" ? l(b, x) : void 0, [b, x]), [C, w] = i(!1), [T, E] = i([]), [D, O] = i({}), k = r(void 0), A = r({
14
- onMessage: h,
15
- onJoin: g,
16
- onLeave: _
12
+ }, p = (p, { grant: m, presence: h, onMessage: g, onJoin: _, onLeave: v } = {}) => {
13
+ let [y] = a("schema.settings.channels"), b = p && (c(p) !== void 0 || (y ? l(p, y) : s(p))) ? p : void 0, [x] = a("realtime.endpoint"), [S] = a("realtime.transport"), C = n(() => x && typeof window < "u" ? u(x, S) : void 0, [x, S]), [w, T] = i(!1), [E, D] = i([]), [O, k] = i({}), A = r(void 0), j = r({
14
+ onMessage: g,
15
+ onJoin: _,
16
+ onLeave: v
17
17
  });
18
18
  t(() => {
19
- A.current = {
20
- onMessage: h,
21
- onJoin: g,
22
- onLeave: _
19
+ j.current = {
20
+ onMessage: g,
21
+ onJoin: _,
22
+ onLeave: v
23
23
  };
24
24
  }), t(() => {
25
- S && y && p && S.grant(y, p);
25
+ C && b && m && C.grant(b, m);
26
26
  }, [
27
- S,
28
- y,
29
- p
27
+ C,
28
+ b,
29
+ m
30
30
  ]), t(() => {
31
- if (!S || !y) return;
32
- let e = u(S, y, {
33
- onChange: E,
31
+ if (!C || !b) return;
32
+ let e = d(C, b, {
33
+ onChange: D,
34
34
  onMessage: (e) => {
35
- e.type === o && e.from === "server" && w(!1), e.retained === !0 && e.from === "server" && O((t) => d(t, e)), A.current.onMessage?.(e);
35
+ e.type === o && e.from === "server" && T(!1), e.retained === !0 && e.from === "server" && k((t) => f(t, e)), j.current.onMessage?.(e);
36
36
  },
37
- onArrive: (e) => A.current.onJoin?.(e),
38
- onDepart: (e) => A.current.onLeave?.(e)
37
+ onArrive: (e) => j.current.onJoin?.(e),
38
+ onDepart: (e) => j.current.onLeave?.(e)
39
39
  });
40
- k.current = e, w(S.status === "open" && !S.refusal(y));
41
- let t = S.onStatus((e) => w(e === "open" && !S.refusal(y)));
40
+ A.current = e, T(C.status === "open" && !C.refusal(b));
41
+ let t = C.onStatus((e) => T(e === "open" && !C.refusal(b)));
42
42
  return () => {
43
- t(), e.stop(), k.current = void 0, E([]), O({}), w(!1);
43
+ t(), e.stop(), A.current = void 0, D([]), k({}), T(!1);
44
44
  };
45
- }, [S, y]);
46
- let j = m === void 0 ? void 0 : JSON.stringify(m);
45
+ }, [C, b]);
46
+ let M = h === void 0 ? void 0 : JSON.stringify(h);
47
47
  t(() => {
48
- j !== void 0 && k.current?.set(JSON.parse(j));
48
+ M !== void 0 && A.current?.set(JSON.parse(M));
49
49
  }, [
50
- j,
51
- S,
52
- y
50
+ M,
51
+ C,
52
+ b
53
53
  ]);
54
- let M = e((e, t, n) => S && y ? S.publish(y, e, t, n) : Promise.resolve(!1), [S, y]), N = e((e) => k.current?.set(e), []), P = n(() => Object.fromEntries(Object.entries(D).map(([e, t]) => [e, t.data])), [D]);
54
+ let N = e((e, t, n) => C && b ? C.publish(b, e, t, n) : Promise.resolve(!1), [C, b]), P = e((e) => A.current?.set(e), []), F = n(() => Object.fromEntries(Object.entries(O).map(([e, t]) => [e, t.data])), [O]);
55
55
  return {
56
- connected: C,
57
- me: C ? S?.me : void 0,
58
- members: T,
59
- retained: P,
60
- publish: M,
61
- setPresence: N
56
+ connected: w,
57
+ me: w ? C?.me : void 0,
58
+ members: E,
59
+ retained: F,
60
+ publish: N,
61
+ setPresence: P
62
62
  };
63
63
  };
64
64
  //#endregion
65
- export { f as default };
65
+ export { p as default };
@@ -0,0 +1,8 @@
1
+ import { FunctionJobView } from '@plitzi/sdk-shared';
2
+ /**
3
+ * One of the space's jobs (`ctx.jobs.start` in its functions), live: its status, how far it is (`progress`, `step`),
4
+ * and its `result` or `error` once it ends — as whoever the job lets watch it sees it, on `$job:<id>`. The latest is
5
+ * there as the page joins, however late. `undefined` until it is heard — or when the job is not this visitor's to watch.
6
+ */
7
+ declare const useJob: (id: string | undefined) => FunctionJobView | undefined;
8
+ export default useJob;
@@ -0,0 +1,10 @@
1
+ import e from "./useChannel.mjs";
2
+ import { isRecord as t } from "@plitzi/sdk-shared/helpers";
3
+ import { JOB_TYPE as n, jobTopic as r } from "@plitzi/sdk-shared/realtime";
4
+ //#region src/realtime/useJob.ts
5
+ var i = (e) => t(e) && typeof e.id == "string" && typeof e.name == "string" && typeof e.status == "string", a = (t) => {
6
+ let { retained: a } = e(t ? r(t) : void 0), o = a[n];
7
+ return i(o) && o.id === t ? o : void 0;
8
+ };
9
+ //#endregion
10
+ export { a as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plitzi/sdk-elements",
3
- "version": "0.38.20",
3
+ "version": "0.38.22",
4
4
  "license": "AGPL-3.0",
5
5
  "files": [
6
6
  "dist"
@@ -33,12 +33,12 @@
33
33
  "@dr.pogodin/react-helmet": "^3.3.2",
34
34
  "@plitzi/nexus": "^1.4.0",
35
35
  "@plitzi/plitzi-ui": "^1.6.34",
36
- "@plitzi/sdk-auth": "0.38.20",
37
- "@plitzi/sdk-event-bridge": "0.38.20",
38
- "@plitzi/sdk-interactions": "0.38.20",
39
- "@plitzi/sdk-navigation": "0.38.20",
40
- "@plitzi/sdk-schema": "0.38.20",
41
- "@plitzi/sdk-shared": "0.38.20",
36
+ "@plitzi/sdk-auth": "0.38.22",
37
+ "@plitzi/sdk-event-bridge": "0.38.22",
38
+ "@plitzi/sdk-interactions": "0.38.22",
39
+ "@plitzi/sdk-navigation": "0.38.22",
40
+ "@plitzi/sdk-schema": "0.38.22",
41
+ "@plitzi/sdk-shared": "0.38.22",
42
42
  "clsx": "^2.1.1",
43
43
  "immer": "^11.1.21",
44
44
  "react-markdown": "^10.1.0",
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- import { ElementContextValue } from '../Element/ElementContext';
2
- declare const elementEntry: (id: string, overrides?: Partial<ElementContextValue>) => ElementContextValue;
3
- declare const skipHocEntry: (id?: string) => ElementContextValue;
4
- export { elementEntry, skipHocEntry };