@plitzi/sdk-shared 0.38.15 → 0.38.17

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.
Files changed (91) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/dist/actions/cron.mjs +5 -9
  3. package/dist/actions/validateDocument.mjs +24 -50
  4. package/dist/activity/describe.d.ts +6 -0
  5. package/dist/activity/describe.mjs +22 -0
  6. package/dist/activity/guard.d.ts +6 -0
  7. package/dist/activity/guard.mjs +13 -0
  8. package/dist/activity/index.d.ts +3 -0
  9. package/dist/activity/index.mjs +4 -0
  10. package/dist/activity/types.d.ts +94 -0
  11. package/dist/activity/types.mjs +4 -0
  12. package/dist/connectors/validateManifest.mjs +28 -73
  13. package/dist/dataSource/helpers/index.mjs +1 -2
  14. package/dist/dataSource/index.d.ts +1 -1
  15. package/dist/dataSource/index.mjs +6 -8
  16. package/dist/dataSource/utility/index.d.ts +1 -0
  17. package/dist/dataSource/utility/index.mjs +16 -15
  18. package/dist/devTools/utils/PlitziConsole.mjs +8 -12
  19. package/dist/elements/index.mjs +1 -2
  20. package/dist/flags/index.d.ts +2 -0
  21. package/dist/flags/index.mjs +2 -1
  22. package/dist/flags/useFlagResolution.mjs +6 -6
  23. package/dist/helpers/index.d.ts +8 -0
  24. package/dist/helpers/index.mjs +21 -13
  25. package/dist/helpers/keys.mjs +4 -8
  26. package/dist/helpers/twigWrapper/Evaluator/index.mjs +1 -2
  27. package/dist/helpers/twigWrapper/Parser/ExpressionParser.mjs +12 -26
  28. package/dist/helpers/twigWrapper/Parser/index.mjs +1 -2
  29. package/dist/helpers/twigWrapper/TemplateCache/index.mjs +1 -2
  30. package/dist/helpers/twigWrapper/charClass.mjs +2 -6
  31. package/dist/helpers/twigWrapper/filters/index.mjs +1 -2
  32. package/dist/helpers/twigWrapper/templateRoots.mjs +3 -8
  33. package/dist/hooks/useNetwork.mjs +1 -4
  34. package/dist/index.d.ts +5 -18
  35. package/dist/index.mjs +3 -96
  36. package/dist/network/graphql/builder/Mutations/index.d.ts +1 -0
  37. package/dist/network/graphql/builder/Mutations/index.mjs +148 -148
  38. package/dist/network/graphql/builder/Queries/index.mjs +4 -4
  39. package/dist/network/index.mjs +8 -8
  40. package/dist/plugins/{bundle.mjs → bundle/bundle.mjs} +1 -1
  41. package/dist/plugins/bundle/index.d.ts +2 -0
  42. package/dist/plugins/bundle/index.mjs +1 -0
  43. package/dist/plugins/index.d.ts +4 -0
  44. package/dist/plugins/index.mjs +3 -0
  45. package/dist/project/index.d.ts +8 -0
  46. package/dist/project/index.mjs +5 -0
  47. package/dist/project/layout.mjs +4 -4
  48. package/dist/queries/queryCache.mjs +1 -7
  49. package/dist/realtime/client.mjs +3 -12
  50. package/dist/schema/index.d.ts +5 -0
  51. package/dist/schema/index.mjs +12 -7
  52. package/dist/server/actions/useActionsSync.mjs +1 -1
  53. package/dist/server/actions/useImagesSync.mjs +1 -1
  54. package/dist/server/actions/useRealtimeSync.mjs +1 -1
  55. package/dist/server/index.d.ts +4 -0
  56. package/dist/server/index.mjs +8 -4
  57. package/dist/server/rsc/refreshRsc.mjs +11 -11
  58. package/dist/server/rsc/useRscSync.mjs +1 -1
  59. package/dist/server/usePluginRoute.mjs +1 -1
  60. package/dist/state/runtimeStatePersist.mjs +9 -15
  61. package/dist/store/index.d.ts +1 -193
  62. package/dist/store/index.mjs +6 -9
  63. package/dist/store/renderSettings.mjs +1 -1
  64. package/dist/store/storeHooks.d.ts +193 -0
  65. package/dist/store/storeHooks.mjs +5 -0
  66. package/dist/store/tracing/tracingCollector.mjs +1 -5
  67. package/dist/style/fonts.mjs +17 -25
  68. package/dist/style/index.d.ts +4 -0
  69. package/dist/style/index.mjs +19 -15
  70. package/dist/style/stylePseudos.mjs +2 -5
  71. package/dist/style/styleTarget.mjs +6 -6
  72. package/dist/theme/ThemeProvider.mjs +1 -1
  73. package/dist/theme/index.d.ts +1 -0
  74. package/dist/theme/index.mjs +4 -4
  75. package/dist/types/BuilderTypes.d.ts +8 -0
  76. package/dist/types/SchemaTypes.d.ts +2 -1
  77. package/dist/types/ServerTypes.d.ts +10 -1
  78. package/dist/websockets/index.mjs +1 -2
  79. package/package.json +21 -1587
  80. package/vite.config.ts +20 -4
  81. package/dist/auth/authFailureLink.d.ts +0 -9
  82. package/dist/auth/authFailureLink.mjs +0 -20
  83. package/dist/dataSource/hooks/index.d.ts +0 -4
  84. package/dist/dataSource/hooks/index.mjs +0 -3
  85. package/dist/dataSource/hooks/useRegisterSource.d.ts +0 -9
  86. package/dist/dataSource/hooks/useRegisterSource.mjs +0 -40
  87. package/dist/dataSource/hooks/useResolvedVariables.d.ts +0 -12
  88. package/dist/dataSource/hooks/useResolvedVariables.mjs +0 -28
  89. package/dist/helpers/stripTypename.d.ts +0 -15
  90. package/dist/helpers/stripTypename.mjs +0 -41
  91. /package/dist/plugins/{bundle.d.ts → bundle/bundle.d.ts} +0 -0
package/vite.config.ts CHANGED
@@ -5,7 +5,7 @@ import fs from 'node:fs';
5
5
  import path from 'node:path';
6
6
 
7
7
  import react from '@vitejs/plugin-react';
8
- import { defineConfig } from 'vite';
8
+ import { defaultClientConditions, defaultServerConditions, defineConfig } from 'vite';
9
9
  import dts from 'vite-plugin-dts';
10
10
 
11
11
  /**
@@ -28,6 +28,15 @@ const skipUnchangedDts = (filePath: string, content: string) => {
28
28
 
29
29
  const importedPackages = new Set();
30
30
 
31
+ /**
32
+ * Under test, a workspace package is read from its sources (`@plitzi/source` in its `exports`), not from `dist`: a test
33
+ * then runs against the code of the packages it depends on as it is now, with no build first and no stale one to
34
+ * mislead it. Builds never resolve it, so what is bundled and published is unchanged.
35
+ */
36
+ const SOURCE_CONDITION = '@plitzi/source';
37
+ const testConditions = (defaults: readonly string[]) =>
38
+ process.env.VITEST ? [SOURCE_CONDITION, ...defaults] : undefined;
39
+
31
40
  type Options = {
32
41
  root?: string;
33
42
  pattern?: RegExp;
@@ -39,9 +48,9 @@ type Options = {
39
48
  *
40
49
  * `preserveModules` writes one file per module either way, so this changes no path — what it changes is the export
41
50
  * list. A module rollup considers internal is re-exported only for the bindings its in-package importers happen to
42
- * use, while `generate-exports.mjs` publishes it as a public subpath all the same and `vite-plugin-dts` writes the
43
- * FULL declaration beside it. The result type-checks against exports the runtime file does not have, and the
44
- * consumer finds out on import: "does not provide an export named ...".
51
+ * use, while a folder barrel is public all the same (`"./*"`) and `vite-plugin-dts` writes the FULL declaration
52
+ * beside it. The result type-checks against exports the runtime file does not have, and the consumer finds out on
53
+ * import: "does not provide an export named ...".
45
54
  */
46
55
  const SOURCE_MODULE = /\.(ts|tsx|js|mjs)$/;
47
56
  /** Matched against the path under `src`, so a whole test-only folder is excluded, not just suffixed file names. */
@@ -91,6 +100,9 @@ export default defineConfig(({ mode, command }) => {
91
100
  entryRoot: 'src',
92
101
  exclude: ['**/*.test.(ts|tsx)', '**/*.stories.(ts|tsx)', 'vite.config.ts', 'setupTests.ts'],
93
102
  tsconfigPath: './tsconfig.app.json',
103
+ // The declarations are written against the other packages' declarations, as a consumer reads them: through
104
+ // their sources they would be compiled under this package's settings and their paths written into its types.
105
+ compilerOptions: { customConditions: [] },
94
106
  beforeWriteFile: skipUnchangedDts
95
107
  }),
96
108
  {
@@ -119,6 +131,7 @@ export default defineConfig(({ mode, command }) => {
119
131
  }
120
132
  ],
121
133
  resolve: {
134
+ conditions: testConditions(defaultClientConditions),
122
135
  alias: {
123
136
  // '@icons': resolve(__dirname, './src/icons'),
124
137
  // '@components': path.resolve(__dirname, './src/components'),
@@ -143,6 +156,9 @@ export default defineConfig(({ mode, command }) => {
143
156
  '@lezer/lr'
144
157
  ]
145
158
  },
159
+ ssr: {
160
+ resolve: { conditions: testConditions(defaultServerConditions) }
161
+ },
146
162
  build: {
147
163
  // outDir: 'dist/src',
148
164
  lib: {
@@ -1,9 +0,0 @@
1
- import { ErrorLink } from '@apollo/client/link/error';
2
- /**
3
- * Turns a GraphQL transport refusal into a session signal. A session dies at the server — revoked from another
4
- * device, an account deactivated — and the client finds out from whichever request happens to be refused next. This
5
- * is what makes that request count for something instead of surfacing as one failed query.
6
- *
7
- * Only transport-level refusals are read: a GraphQL error inside a 200 is the schema's business, not the session's.
8
- */
9
- export declare const createAuthFailureLink: (uri?: string) => ErrorLink;
@@ -1,20 +0,0 @@
1
- import { authFailureFromResponse as e, reportAuthFailure as t } from "./failureChannel.mjs";
2
- import { ServerError as n } from "@apollo/client";
3
- import { ErrorLink as r } from "@apollo/client/link/error";
4
- //#region src/auth/authFailureLink.ts
5
- var i = (e) => {
6
- try {
7
- return JSON.parse(e);
8
- } catch {
9
- return;
10
- }
11
- }, a = (a) => new r(({ error: r }) => {
12
- if (!n.is(r)) return;
13
- let o = e(r.statusCode, i(r.bodyText));
14
- o && t({
15
- reason: o,
16
- url: a
17
- });
18
- });
19
- //#endregion
20
- export { a as createAuthFailureLink };
@@ -1,4 +0,0 @@
1
- import { default as useRegisterSource } from './useRegisterSource';
2
- import { default as useResolvedVariables } from './useResolvedVariables';
3
- export * from './useRegisterSource';
4
- export { useRegisterSource, useResolvedVariables };
@@ -1,3 +0,0 @@
1
- import e from "./useRegisterSource.mjs";
2
- import t from "./useResolvedVariables.mjs";
3
- export { e as useRegisterSource, t as useResolvedVariables };
@@ -1,9 +0,0 @@
1
- import { SourceMeta } from '../../types';
2
- export type UseRegisterSourceProps = {
3
- id?: string;
4
- source: string;
5
- name: string;
6
- fields?: SourceMeta['fields'];
7
- };
8
- declare const useRegisterSource: ({ id, source, name, fields }: UseRegisterSourceProps) => void;
9
- export default useRegisterSource;
@@ -1,40 +0,0 @@
1
- import { makeId as e } from "../../helpers/utils.mjs";
2
- import { useEffect as t, useEffectEvent as n, useMemo as r } from "react";
3
- import { createStoreHook as i } from "@plitzi/nexus/react";
4
- //#region src/dataSource/hooks/useRegisterSource.ts
5
- var a = ({ id: a = "", source: o, name: s, fields: c = [] }) => {
6
- let { useStoreSetter: l } = i(), u = l(), d = r(() => `${a}_${e(8)}`, [a]), f = n(() => {
7
- u(`sources.${d}`, {
8
- id: d,
9
- meta: {
10
- id: a,
11
- source: o,
12
- name: s,
13
- fields: c
14
- }
15
- });
16
- });
17
- t(() => {
18
- if (o) return f(), () => u(`sources.${d}`, void 0, { unmount: !0 });
19
- }, [
20
- d,
21
- o,
22
- u
23
- ]), t(() => {
24
- o && u(`sources.${d}.meta.name`, s);
25
- }, [
26
- s,
27
- o,
28
- d,
29
- u
30
- ]), t(() => {
31
- o && u(`sources.${d}.meta.fields`, c, { raw: !0 });
32
- }, [
33
- c,
34
- o,
35
- d,
36
- u
37
- ]);
38
- };
39
- //#endregion
40
- export { a as default };
@@ -1,12 +0,0 @@
1
- import { SchemaVariableValue } from '../../types';
2
- /**
3
- * The space's variables, resolved for where the visitor is — from `schema.variables` and the route, never from the
4
- * published `runtime.sources.variables`.
5
- *
6
- * `GlobalSources` publishes that map while it renders, which is below the SDK's own stylesheet: on the server the sheet
7
- * is already written by then, without them, and in the browser the store has changed in the middle of hydration, so
8
- * React drew the sheet again with them — a hydration error on every space that declares a variable. Everything that
9
- * renders above the provider, or must render the same on both sides, resolves them here instead.
10
- */
11
- declare const useResolvedVariables: () => Record<string, SchemaVariableValue>;
12
- export default useResolvedVariables;
@@ -1,28 +0,0 @@
1
- import e from "../../hooks/useStableValue.mjs";
2
- import t from "../../store/renderSettings.mjs";
3
- import { useCommonStore as n } from "../../store/index.mjs";
4
- import r from "../resolveVariables.mjs";
5
- import { useMemo as i } from "react";
6
- //#region src/dataSource/hooks/useResolvedVariables.ts
7
- var a = () => {
8
- let { environment: a } = t(), [[o, s, c, l]] = n([
9
- "schema.variables",
10
- "navigation.routeParams",
11
- "navigation.queryParams",
12
- "navigation.hostname"
13
- ]);
14
- return e(i(() => r(o, {
15
- routeParams: s,
16
- queryParams: c,
17
- hostname: l,
18
- environment: a
19
- }), [
20
- a,
21
- l,
22
- c,
23
- s,
24
- o
25
- ]));
26
- };
27
- //#endregion
28
- export { a as default };
@@ -1,15 +0,0 @@
1
- import { ApolloLink } from '@apollo/client/core';
2
- type WithoutTypename<T> = T extends Array<infer U> ? Array<WithoutTypename<U>> : T extends object ? {
3
- [K in keyof T as K extends '__typename' ? never : K]: WithoutTypename<T[K]>;
4
- } : T;
5
- /**
6
- * Recursively removes __typename from objects and arrays.
7
- * Optimized to avoid creating new objects/arrays if not needed.
8
- */
9
- export declare function stripTypenameDeep<T>(value: T): WithoutTypename<T>;
10
- /**
11
- * ApolloLink that strips __typename from the result data.
12
- * Uses optimized stripTypenameDeep.
13
- */
14
- export declare const createStripTypenameLink: () => ApolloLink;
15
- export {};
@@ -1,41 +0,0 @@
1
- import { ApolloLink as e, Observable as t } from "@apollo/client/core";
2
- //#region src/helpers/stripTypename.ts
3
- function n(e) {
4
- if (Array.isArray(e)) {
5
- let t = !1, r = e.map((e) => {
6
- let r = n(e);
7
- return r !== e && (t = !0), r;
8
- });
9
- return t ? r : e;
10
- }
11
- if (typeof e == "object" && e) {
12
- let t = {}, r = !1;
13
- for (let i in e) {
14
- if (i === "__typename") {
15
- r = !0;
16
- continue;
17
- }
18
- let a = e[i], o = n(a);
19
- o !== a && (r = !0), t[i] = o;
20
- }
21
- return r ? t : e;
22
- }
23
- return e;
24
- }
25
- var r = () => new e((e, r) => new t((t) => {
26
- let i = r(e).subscribe({
27
- next: (e) => {
28
- t.next(e.data ? {
29
- ...e,
30
- data: n(e.data)
31
- } : e);
32
- },
33
- error: (e) => t.error(e),
34
- complete: () => t.complete()
35
- });
36
- return () => {
37
- i.unsubscribe();
38
- };
39
- }));
40
- //#endregion
41
- export { r as createStripTypenameLink, n as stripTypenameDeep };