@plitzi/sdk-shared 0.37.7 → 0.37.9

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 (147) hide show
  1. package/CHANGELOG.md +247 -0
  2. package/dist/actions/functions.d.ts +12 -3
  3. package/dist/actions/functions.mjs +8 -5
  4. package/dist/actions/index.d.ts +1 -1
  5. package/dist/actions/index.mjs +6 -6
  6. package/dist/auth/failureChannel.d.ts +8 -2
  7. package/dist/auth/failureChannel.mjs +1 -3
  8. package/dist/builder/contexts/BuilderContext.d.ts +1 -1
  9. package/dist/builder/contexts/BuilderContext.mjs +2 -3
  10. package/dist/devTools/DevToolsContext.mjs +2 -3
  11. package/dist/elements/ComponentContext.mjs +2 -3
  12. package/dist/helpers/sharedContext.d.ts +14 -0
  13. package/dist/helpers/sharedContext.mjs +9 -0
  14. package/dist/helpers/twigWrapper/Evaluator/Evaluator.d.ts +9 -1
  15. package/dist/helpers/twigWrapper/Evaluator/Evaluator.mjs +13 -8
  16. package/dist/helpers/twigWrapper/Evaluator/index.d.ts +1 -1
  17. package/dist/helpers/twigWrapper/index.d.ts +1 -0
  18. package/dist/helpers/twigWrapper/processTwig/processTwig.d.ts +2 -1
  19. package/dist/helpers/twigWrapper/processTwig/processTwig.mjs +3 -3
  20. package/dist/helpers/utils.mjs +4 -2
  21. package/dist/history/describe.mjs +1 -0
  22. package/dist/history/diff.d.ts +1 -1
  23. package/dist/history/diff.mjs +10 -9
  24. package/dist/history/types.d.ts +1 -1
  25. package/dist/hooks/usePlitziServiceContext.d.ts +1 -2
  26. package/dist/hooks/usePlitziServiceContext.mjs +3 -4
  27. package/dist/index.d.ts +0 -1
  28. package/dist/index.mjs +12 -13
  29. package/dist/network/NetworkContext.mjs +2 -3
  30. package/dist/network/NetworkInternalContext.d.ts +2 -4
  31. package/dist/network/NetworkInternalContext.mjs +2 -3
  32. package/dist/network/graphql/builder/Mutations/Space/components/SpaceAddComponentMutation.d.ts +4 -0
  33. package/dist/network/graphql/builder/Mutations/Space/components/SpaceAddComponentMutation.mjs +4 -0
  34. package/dist/network/graphql/builder/Mutations/Space/components/SpaceDetachInstanceMutation.d.ts +4 -0
  35. package/dist/network/graphql/builder/Mutations/Space/components/SpaceDetachInstanceMutation.mjs +4 -0
  36. package/dist/network/graphql/builder/Mutations/Space/components/SpaceRemoveComponentMutation.d.ts +4 -0
  37. package/dist/network/graphql/builder/Mutations/Space/components/SpaceRemoveComponentMutation.mjs +4 -0
  38. package/dist/network/graphql/builder/Mutations/Space/components/SpaceUpdateComponentMutation.d.ts +4 -0
  39. package/dist/network/graphql/builder/Mutations/Space/components/SpaceUpdateComponentMutation.mjs +4 -0
  40. package/dist/network/graphql/builder/Mutations/index.d.ts +8 -29
  41. package/dist/network/graphql/builder/Mutations/index.mjs +158 -200
  42. package/dist/network/graphql/builder/Queries/InitQuery.d.ts +2 -3
  43. package/dist/network/graphql/builder/Queries/InitQuery.mjs +1 -1
  44. package/dist/network/graphql/builder/Queries/Space/SpaceActionTasksQuery.d.ts +1 -1
  45. package/dist/network/graphql/builder/Queries/Space/SpaceActionTasksQuery.mjs +1 -1
  46. package/dist/network/graphql/builder/Queries/Space/SpaceVersionContentsQuery.d.ts +7 -0
  47. package/dist/network/graphql/builder/Queries/Space/SpaceVersionContentsQuery.mjs +4 -0
  48. package/dist/network/graphql/builder/Queries/index.d.ts +2 -4
  49. package/dist/network/graphql/builder/Queries/index.mjs +36 -38
  50. package/dist/network/graphql/builder/Subscriptions/SpaceEventSubscription.d.ts +1 -1
  51. package/dist/network/graphql/sdk/Queries/InitQuery.d.ts +2 -3
  52. package/dist/network/graphql/sdk/Queries/InitQuery.mjs +1 -1
  53. package/dist/network/graphql/sdk/Queries/index.d.ts +0 -4
  54. package/dist/network/graphql/sdk/Queries/index.mjs +2 -8
  55. package/dist/network/spaceEvents.d.ts +14 -190
  56. package/dist/network/spaceEvents.mjs +48 -132
  57. package/dist/schema/SchemaContext.mjs +2 -3
  58. package/dist/schema/index.mjs +4 -4
  59. package/dist/schema/schemaConstants.d.ts +2 -0
  60. package/dist/schema/schemaConstants.mjs +4 -3
  61. package/dist/server/rsc/refreshRsc.d.ts +3 -1
  62. package/dist/server/rsc/refreshRsc.mjs +15 -14
  63. package/dist/source/export.d.ts +107 -0
  64. package/dist/source/export.mjs +4 -0
  65. package/dist/source/index.d.ts +4 -0
  66. package/dist/source/index.mjs +3 -0
  67. package/dist/source/snapshot.d.ts +51 -0
  68. package/dist/source/snapshot.mjs +80 -0
  69. package/dist/store/index.d.ts +45 -45
  70. package/dist/store/renderSettings.d.ts +1 -0
  71. package/dist/store/renderSettings.mjs +9 -5
  72. package/dist/theme/ThemeScope.mjs +4 -3
  73. package/dist/types/ActionTypes.d.ts +5 -0
  74. package/dist/types/ElementTypes.d.ts +6 -5
  75. package/dist/types/EventBridgeTypes.d.ts +2 -2
  76. package/dist/types/FunctionTypes.d.ts +13 -0
  77. package/dist/types/InteractionTypes.d.ts +5 -0
  78. package/dist/types/SchemaTypes.d.ts +38 -0
  79. package/dist/types/SdkTypes.d.ts +0 -2
  80. package/dist/types/SpaceTypes.d.ts +36 -0
  81. package/dist/types/StoreTypes.d.ts +14 -3
  82. package/dist/types/index.d.ts +0 -1
  83. package/package.json +43 -134
  84. package/dist/network/graphql/builder/Mutations/Segment/SegmentAddMutation.d.ts +0 -4
  85. package/dist/network/graphql/builder/Mutations/Segment/SegmentAddMutation.mjs +0 -4
  86. package/dist/network/graphql/builder/Mutations/Segment/SegmentAddTemplateMutation.d.ts +0 -2
  87. package/dist/network/graphql/builder/Mutations/Segment/SegmentAddTemplateMutation.mjs +0 -4
  88. package/dist/network/graphql/builder/Mutations/Segment/SegmentPublishMutation.d.ts +0 -8
  89. package/dist/network/graphql/builder/Mutations/Segment/SegmentPublishMutation.mjs +0 -4
  90. package/dist/network/graphql/builder/Mutations/Segment/SegmentRemoveMutation.d.ts +0 -2
  91. package/dist/network/graphql/builder/Mutations/Segment/SegmentRemoveMutation.mjs +0 -4
  92. package/dist/network/graphql/builder/Mutations/Segment/SegmentUpdateMutation.d.ts +0 -4
  93. package/dist/network/graphql/builder/Mutations/Segment/SegmentUpdateMutation.mjs +0 -4
  94. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentAddElementMutation.d.ts +0 -2
  95. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentAddElementMutation.mjs +0 -4
  96. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentCloneElementMutation.d.ts +0 -2
  97. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentCloneElementMutation.mjs +0 -4
  98. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentMoveElementMutation.d.ts +0 -2
  99. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentMoveElementMutation.mjs +0 -4
  100. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentRemoveElementMutation.d.ts +0 -2
  101. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentRemoveElementMutation.mjs +0 -4
  102. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentRenameElementMutation.d.ts +0 -3
  103. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentRenameElementMutation.mjs +0 -4
  104. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementMutation.d.ts +0 -2
  105. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementMutation.mjs +0 -4
  106. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementsMutation.d.ts +0 -2
  107. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementsMutation.mjs +0 -4
  108. package/dist/network/graphql/builder/Mutations/Segment/space/variables/SegmentSpaceAddVariableMutation.d.ts +0 -2
  109. package/dist/network/graphql/builder/Mutations/Segment/space/variables/SegmentSpaceAddVariableMutation.mjs +0 -4
  110. package/dist/network/graphql/builder/Mutations/Segment/space/variables/SegmentSpaceRemoveVariableMutation.d.ts +0 -2
  111. package/dist/network/graphql/builder/Mutations/Segment/space/variables/SegmentSpaceRemoveVariableMutation.mjs +0 -4
  112. package/dist/network/graphql/builder/Mutations/Segment/space/variables/SegmentSpaceUpdateVariableMutation.d.ts +0 -2
  113. package/dist/network/graphql/builder/Mutations/Segment/space/variables/SegmentSpaceUpdateVariableMutation.mjs +0 -4
  114. package/dist/network/graphql/builder/Mutations/Segment/style/selectorVariables/SegmentStyleAddSelectorVariableMutation.d.ts +0 -2
  115. package/dist/network/graphql/builder/Mutations/Segment/style/selectorVariables/SegmentStyleAddSelectorVariableMutation.mjs +0 -4
  116. package/dist/network/graphql/builder/Mutations/Segment/style/selectorVariables/SegmentStyleRemoveSelectorVariableMutation.d.ts +0 -2
  117. package/dist/network/graphql/builder/Mutations/Segment/style/selectorVariables/SegmentStyleRemoveSelectorVariableMutation.mjs +0 -4
  118. package/dist/network/graphql/builder/Mutations/Segment/style/selectorVariables/SegmentStyleUpdateSelectorVariableMutation.d.ts +0 -2
  119. package/dist/network/graphql/builder/Mutations/Segment/style/selectorVariables/SegmentStyleUpdateSelectorVariableMutation.mjs +0 -4
  120. package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleAddSelectorMutation.d.ts +0 -2
  121. package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleAddSelectorMutation.mjs +0 -4
  122. package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleRemoveSelectorMutation.d.ts +0 -2
  123. package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleRemoveSelectorMutation.mjs +0 -4
  124. package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleRemoveSelectorsMutation.d.ts +0 -2
  125. package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleRemoveSelectorsMutation.mjs +0 -4
  126. package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleUpdateSelectorMutation.d.ts +0 -2
  127. package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleUpdateSelectorMutation.mjs +0 -4
  128. package/dist/network/graphql/builder/Mutations/Segment/style/variables/SegmentStyleAddVariableMutation.d.ts +0 -2
  129. package/dist/network/graphql/builder/Mutations/Segment/style/variables/SegmentStyleAddVariableMutation.mjs +0 -4
  130. package/dist/network/graphql/builder/Mutations/Segment/style/variables/SegmentStyleRemoveVariableMutation.d.ts +0 -2
  131. package/dist/network/graphql/builder/Mutations/Segment/style/variables/SegmentStyleRemoveVariableMutation.mjs +0 -4
  132. package/dist/network/graphql/builder/Mutations/Segment/style/variables/SegmentStyleUpdateVariableMutation.d.ts +0 -2
  133. package/dist/network/graphql/builder/Mutations/Segment/style/variables/SegmentStyleUpdateVariableMutation.mjs +0 -4
  134. package/dist/network/graphql/builder/Queries/Segment/SegmentQuery.d.ts +0 -6
  135. package/dist/network/graphql/builder/Queries/Segment/SegmentQuery.mjs +0 -4
  136. package/dist/network/graphql/builder/Queries/Segment/SegmentsQuery.d.ts +0 -9
  137. package/dist/network/graphql/builder/Queries/Segment/SegmentsQuery.mjs +0 -4
  138. package/dist/network/graphql/sdk/Queries/Segment/SegmentQuery.d.ts +0 -6
  139. package/dist/network/graphql/sdk/Queries/Segment/SegmentQuery.mjs +0 -4
  140. package/dist/network/graphql/sdk/Queries/Segment/SegmentsQuery.d.ts +0 -9
  141. package/dist/network/graphql/sdk/Queries/Segment/SegmentsQuery.mjs +0 -4
  142. package/dist/segments/SegmentsContext.d.ts +0 -2
  143. package/dist/segments/SegmentsContext.mjs +0 -6
  144. package/dist/segments/index.d.ts +0 -3
  145. package/dist/segments/index.mjs +0 -2
  146. package/dist/types/SegmentTypes.d.ts +0 -41
  147. package/dist/types/SegmentTypes.mjs +0 -0
@@ -0,0 +1,107 @@
1
+ import { SpaceVersionContents } from '../types';
2
+ /**
3
+ * A space taken back out as a project (docs/en/projects-from-spaces.md): everything it is made of that Plitzi keeps, as
4
+ * `GET /spaces/:spaceId/export` answers it and `plitzi create --from` writes it. One shape for both ends.
5
+ */
6
+ export declare const SPACE_EXPORT_FORMAT = 1;
7
+ /** A file the project downloads once and serves itself: where it is on the space's CDN, and where it goes. */
8
+ export type SpaceExportFile = {
9
+ /** Its address on the space's CDN, today. */
10
+ url: string;
11
+ /** Where it goes in the project, relative to the folder it is served from: `assets/85a7_world.json`. */
12
+ path: string;
13
+ };
14
+ /** A path the merge of the source snapshots met more than once, with different content. */
15
+ export type SpaceExportConflict = {
16
+ path: string;
17
+ /** The artifact whose copy was kept: the newest snapshot holding the path. */
18
+ kept: string;
19
+ /** The others that held a different copy. */
20
+ others: string[];
21
+ };
22
+ export type SpaceExport = {
23
+ format: typeof SPACE_EXPORT_FORMAT;
24
+ space: {
25
+ id: number;
26
+ name: string;
27
+ permanentUrl: string;
28
+ };
29
+ /** The version taken out: the draft (`main`, revision 0), or a snapshot an environment holds. */
30
+ version: Pick<SpaceVersionContents, 'environment' | 'revision' | 'snapshot'>;
31
+ /** The space as authoring code, by path (`index.ts`, a file per page): none for a project that reads it from Plitzi. */
32
+ authoring: {
33
+ exportName: string;
34
+ files: Record<string, string>;
35
+ } | null;
36
+ /**
37
+ * The server-side documents, as they are kept: a flow and a connector name steps and credentials. Whether an action
38
+ * is on is its trigger steps', so nothing beside the document says it.
39
+ */
40
+ actions: {
41
+ identifier: string;
42
+ name: string;
43
+ document: unknown;
44
+ }[];
45
+ connectors: {
46
+ identifier: string;
47
+ name: string;
48
+ manifest: unknown;
49
+ }[];
50
+ /**
51
+ * The space's functions, by path in `functions/`, and the version of them this is — what `plitzi functions push`
52
+ * checks the space's copy has not moved on from.
53
+ */
54
+ functions: {
55
+ version: string;
56
+ files: Record<string, string>;
57
+ };
58
+ /**
59
+ * The source its plugins and runtime were built from, merged: every file by its path in the project (bytes in
60
+ * base64), the packages they need, and where each build starts.
61
+ */
62
+ source: {
63
+ files: Record<string, string>;
64
+ dependencies: Record<string, string>;
65
+ runtime: {
66
+ entries: string[];
67
+ } | null;
68
+ plugins: {
69
+ type: string;
70
+ entries: string[];
71
+ }[];
72
+ };
73
+ /** What there is no source of: kept built, so the project runs it as it is and cannot change it. */
74
+ builtOnly: {
75
+ plugins: {
76
+ type: string;
77
+ files: SpaceExportFile[];
78
+ }[];
79
+ /** The packed runtime, in base64 — what `@plitzi/sdk-server/runtime` loads. */
80
+ runtime: string | null;
81
+ };
82
+ /** The space's files on its CDN — pictures, fonts, data — for the project to serve itself. */
83
+ assets: SpaceExportFile[];
84
+ /** Names the project is given values for: never the values, which stay on the platform. */
85
+ variables: string[];
86
+ credentials: {
87
+ identifier: string;
88
+ name: string;
89
+ provider: string;
90
+ }[];
91
+ /**
92
+ * The roles the space declares for its visitors (`settings.visitorRoles`), by name. Who holds them stays on Plitzi:
93
+ * they are people's addresses, and a server of its own signs people in itself.
94
+ */
95
+ visitorRoles: string[];
96
+ report: {
97
+ conflicts: SpaceExportConflict[];
98
+ /** Packages two snapshots ask for at different ranges: the newest's is the one written. */
99
+ rangeConflicts: {
100
+ name: string;
101
+ kept: string;
102
+ others: string[];
103
+ }[];
104
+ /** What the authoring export repaired on the way, in words. */
105
+ corrections: string[];
106
+ };
107
+ };
@@ -0,0 +1,4 @@
1
+ //#region src/source/export.ts
2
+ var e = 1;
3
+ //#endregion
4
+ export { e as SPACE_EXPORT_FORMAT };
@@ -0,0 +1,4 @@
1
+ export { readSourceSnapshot, secretIn, sourcePathProblem, SOURCE_SNAPSHOT_FORMAT, SOURCE_SNAPSHOT_LIMITS } from './snapshot';
2
+ export { SPACE_EXPORT_FORMAT } from './export';
3
+ export type { SourceSnapshot, SourceSnapshotKind, SourceSnapshotReading } from './snapshot';
4
+ export type { SpaceExport, SpaceExportConflict, SpaceExportFile } from './export';
@@ -0,0 +1,3 @@
1
+ import { SPACE_EXPORT_FORMAT as e } from "./export.mjs";
2
+ import { SOURCE_SNAPSHOT_FORMAT as t, SOURCE_SNAPSHOT_LIMITS as n, readSourceSnapshot as r, secretIn as i, sourcePathProblem as a } from "./snapshot.mjs";
3
+ export { t as SOURCE_SNAPSHOT_FORMAT, n as SOURCE_SNAPSHOT_LIMITS, e as SPACE_EXPORT_FORMAT, r as readSourceSnapshot, i as secretIn, a as sourcePathProblem };
@@ -0,0 +1,51 @@
1
+ /**
2
+ * A source snapshot: the files of a project that one artifact — a plugin, a runtime — was built from, as the platform
3
+ * keeps them beside what was built, so the space can be taken back out as a project (`plitzi create --from`).
4
+ *
5
+ * The files are the ones the build reached from its entries, by their path in the project: a plugin and a runtime that
6
+ * import the same `board/model.ts` each carry it under that one path, and a project put back together from both has it
7
+ * once. Nothing under `node_modules` is in one — the packages are `dependencies`, by name and range.
8
+ *
9
+ * One shape for everybody that touches one: the CLI that packs it, the seeder, and the platform that refuses one it
10
+ * should not keep.
11
+ */
12
+ export declare const SOURCE_SNAPSHOT_FORMAT = 1;
13
+ export type SourceSnapshotKind = 'plugin' | 'runtime';
14
+ export type SourceSnapshot = {
15
+ format: typeof SOURCE_SNAPSHOT_FORMAT;
16
+ kind: SourceSnapshotKind;
17
+ /** The plugin's type, or `runtime`. */
18
+ name: string;
19
+ /** Where the build started, by path in the project: a plugin of several elements has one per element. */
20
+ entries: string[];
21
+ /** Every file the build reached, by path in the project, its bytes in base64 — fonts and pictures travel too. */
22
+ files: Record<string, string>;
23
+ /** The packages those files import, by name, with the range the project asked for. */
24
+ dependencies: Record<string, string>;
25
+ };
26
+ /** How much one snapshot may hold: source, not data. */
27
+ export declare const SOURCE_SNAPSHOT_LIMITS: {
28
+ files: number;
29
+ fileBytes: number;
30
+ totalBytes: number;
31
+ };
32
+ /**
33
+ * Why `file` is not a path a snapshot may hold, or nothing: relative to the project, inside it, never in a package or a
34
+ * repository's own folder, and never a file of credentials.
35
+ */
36
+ export declare const sourcePathProblem: (file: string) => string | undefined;
37
+ /** What in `text` looks like a credential, by what it is — or nothing. */
38
+ export declare const secretIn: (text: string) => string | undefined;
39
+ export type SourceSnapshotReading = {
40
+ ok: true;
41
+ snapshot: SourceSnapshot;
42
+ } | {
43
+ ok: false;
44
+ problems: string[];
45
+ };
46
+ /**
47
+ * A snapshot read from what was sent, checked whole: its shape, every path, the limits, and no credentials in any file
48
+ * — `decode` turns a file's base64 into text for that last check, since how is the reader's (Node or the browser).
49
+ * Every problem is said at once, so one round fixes them all.
50
+ */
51
+ export declare const readSourceSnapshot: (value: unknown, decode: (base64: string) => string) => SourceSnapshotReading;
@@ -0,0 +1,80 @@
1
+ //#region src/source/snapshot.ts
2
+ var e = 1, t = {
3
+ files: 2e3,
4
+ fileBytes: 4194304,
5
+ totalBytes: 25165824
6
+ }, n = ["plugin", "runtime"], r = [
7
+ /(^|\/)\.env(\.|$)/,
8
+ /\.(pem|key|p12|pfx)$/i,
9
+ /(^|\/)id_(rsa|dsa|ecdsa|ed25519)$/
10
+ ], i = [
11
+ {
12
+ what: "a private key",
13
+ pattern: /-----BEGIN (?:[A-Z]+ )?PRIVATE KEY-----/
14
+ },
15
+ {
16
+ what: "an AWS access key",
17
+ pattern: /\bAKIA[0-9A-Z]{16}\b/
18
+ },
19
+ {
20
+ what: "a Stripe live key",
21
+ pattern: /\b[sr]k_live_[0-9a-zA-Z]{20,}\b/
22
+ },
23
+ {
24
+ what: "a GitHub token",
25
+ pattern: /\bgh[pousr]_[A-Za-z0-9]{36,}\b/
26
+ },
27
+ {
28
+ what: "a Slack token",
29
+ pattern: /\bxox[baprs]-[A-Za-z0-9-]{10,}\b/
30
+ }
31
+ ], a = (e) => {
32
+ let t = e.split("/");
33
+ if (!e || e.startsWith("/") || /^[a-zA-Z]:/.test(e) || e.includes("\\")) return `"${e}" is not a path relative to the project, with forward slashes`;
34
+ if (t.some((e) => e === "" || e === "." || e === "..")) return `"${e}" climbs out of the project, or has an empty part`;
35
+ if (t.some((e) => e === "node_modules" || e === ".git")) return `"${e}" is in node_modules or .git: a package is a dependency, not a file of the project`;
36
+ if (r.some((t) => t.test(e))) return `"${e}" is a file of credentials: they stay where the project runs, never in what Plitzi keeps`;
37
+ }, o = (e) => i.find(({ pattern: t }) => t.test(e))?.what, s = (e) => typeof e == "string" && n.some((t) => t === e), c = (e) => typeof e == "string" && /^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(e), l = (e) => Array.isArray(e) && e.length > 0 && e.every((e) => typeof e == "string"), u = (e) => typeof e == "object" && !!e && !Array.isArray(e), d = (e) => u(e) && Object.values(e).every((e) => typeof e == "string"), f = (e) => Math.floor(e.length * 3 / 4) - (e.endsWith("==") ? 2 : +!!e.endsWith("=")), p = (e, r) => {
38
+ if (!u(e) || e.format !== 1) return {
39
+ ok: !1,
40
+ problems: ["Not a source snapshot of format 1"]
41
+ };
42
+ let { kind: i, name: p, entries: m, files: h, dependencies: g } = e, _ = [];
43
+ if (s(i) || _.push(`Its kind is one of ${n.join(", ")}`), c(p) || _.push("Its name is a plugin type or \"runtime\": letters, digits, dashes and underscores"), !d(h) || !d(g)) return {
44
+ ok: !1,
45
+ problems: [..._, "Its files and dependencies are maps of text"]
46
+ };
47
+ l(m) ? m.filter((e) => !Object.hasOwn(h, e)).forEach((e) => _.push(`Its entry "${e}" is not among its files`)) : _.push("It names at least one entry");
48
+ let v = Object.keys(h);
49
+ v.length > t.files && _.push(`It holds ${String(v.length)} files; a snapshot holds at most ${String(t.files)}`);
50
+ let y = 0;
51
+ return v.forEach((e) => {
52
+ let n = a(e);
53
+ if (n) {
54
+ _.push(n);
55
+ return;
56
+ }
57
+ let i = f(h[e]);
58
+ if (y += i, i > t.fileBytes) {
59
+ _.push(`"${e}" is ${(i / 1024 / 1024).toFixed(1)} MB; a file of source is at most 4 MB`);
60
+ return;
61
+ }
62
+ let s = o(r(h[e]));
63
+ s && _.push(`"${e}" holds ${s}: take it out of the code and give it to the project as a variable`);
64
+ }), y > t.totalBytes && _.push(`It holds ${(y / 1024 / 1024).toFixed(1)} MB of files; a snapshot holds at most 24 MB`), _.length > 0 || !s(i) || !c(p) || !l(m) ? {
65
+ ok: !1,
66
+ problems: _
67
+ } : {
68
+ ok: !0,
69
+ snapshot: {
70
+ format: 1,
71
+ kind: i,
72
+ name: p,
73
+ entries: m,
74
+ files: h,
75
+ dependencies: g
76
+ }
77
+ };
78
+ };
79
+ //#endregion
80
+ export { e as SOURCE_SNAPSHOT_FORMAT, t as SOURCE_SNAPSHOT_LIMITS, p as readSourceSnapshot, o as secretIn, a as sourcePathProblem };