everything-dev 1.27.0 → 1.28.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.
Files changed (114) hide show
  1. package/dist/cli/infra.cjs +1 -1
  2. package/dist/cli/infra.mjs +1 -1
  3. package/dist/cli/init.cjs +34 -9
  4. package/dist/cli/init.cjs.map +1 -1
  5. package/dist/cli/init.d.cts +2 -1
  6. package/dist/cli/init.d.cts.map +1 -1
  7. package/dist/cli/init.d.mts +2 -1
  8. package/dist/cli/init.d.mts.map +1 -1
  9. package/dist/cli/init.mjs +34 -9
  10. package/dist/cli/init.mjs.map +1 -1
  11. package/dist/cli/prompts.cjs +28 -24
  12. package/dist/cli/prompts.cjs.map +1 -1
  13. package/dist/cli/prompts.mjs +27 -24
  14. package/dist/cli/prompts.mjs.map +1 -1
  15. package/dist/cli/sync.cjs +40 -3
  16. package/dist/cli/sync.cjs.map +1 -1
  17. package/dist/cli/sync.mjs +40 -3
  18. package/dist/cli/sync.mjs.map +1 -1
  19. package/dist/cli.cjs +187 -12
  20. package/dist/cli.cjs.map +1 -1
  21. package/dist/cli.mjs +186 -11
  22. package/dist/cli.mjs.map +1 -1
  23. package/dist/config.cjs +1 -0
  24. package/dist/config.cjs.map +1 -1
  25. package/dist/config.d.cts.map +1 -1
  26. package/dist/config.d.mts.map +1 -1
  27. package/dist/config.mjs +1 -0
  28. package/dist/config.mjs.map +1 -1
  29. package/dist/contract.cjs +1 -1
  30. package/dist/contract.cjs.map +1 -1
  31. package/dist/contract.d.cts +38 -34
  32. package/dist/contract.d.cts.map +1 -1
  33. package/dist/contract.d.mts +38 -34
  34. package/dist/contract.d.mts.map +1 -1
  35. package/dist/contract.mjs +1 -0
  36. package/dist/contract.mjs.map +1 -1
  37. package/dist/dev-session.cjs +0 -1
  38. package/dist/dev-session.mjs +1 -1
  39. package/dist/index.cjs +0 -2
  40. package/dist/index.d.cts +2 -2
  41. package/dist/index.d.mts +2 -2
  42. package/dist/index.mjs +0 -1
  43. package/dist/near-cli.cjs +1 -1
  44. package/dist/near-cli.mjs +1 -1
  45. package/dist/orchestrator.cjs +1 -1
  46. package/dist/orchestrator.mjs +1 -1
  47. package/dist/plugin.cjs +183 -151
  48. package/dist/plugin.cjs.map +1 -1
  49. package/dist/plugin.d.cts +67 -34
  50. package/dist/plugin.d.cts.map +1 -1
  51. package/dist/plugin.d.mts +66 -34
  52. package/dist/plugin.d.mts.map +1 -1
  53. package/dist/plugin.mjs +173 -142
  54. package/dist/plugin.mjs.map +1 -1
  55. package/dist/service-descriptor.d.cts +34 -0
  56. package/dist/service-descriptor.d.cts.map +1 -0
  57. package/dist/service-descriptor.d.mts +36 -0
  58. package/dist/service-descriptor.d.mts.map +1 -0
  59. package/dist/types.d.cts +2 -2
  60. package/dist/types.d.mts +2 -2
  61. package/dist/utils/run.cjs +9 -20
  62. package/dist/utils/run.cjs.map +1 -1
  63. package/dist/utils/run.mjs +9 -20
  64. package/dist/utils/run.mjs.map +1 -1
  65. package/package.json +2 -2
  66. package/src/api-contract.ts +0 -623
  67. package/src/app.ts +0 -193
  68. package/src/cli/catalog.ts +0 -49
  69. package/src/cli/framework-version.ts +0 -61
  70. package/src/cli/help.ts +0 -13
  71. package/src/cli/infra.ts +0 -190
  72. package/src/cli/init.ts +0 -1145
  73. package/src/cli/parse.ts +0 -147
  74. package/src/cli/prompts.ts +0 -135
  75. package/src/cli/snapshot.ts +0 -46
  76. package/src/cli/status.ts +0 -99
  77. package/src/cli/sync.ts +0 -429
  78. package/src/cli/timing.ts +0 -63
  79. package/src/cli/upgrade.ts +0 -869
  80. package/src/cli.ts +0 -516
  81. package/src/components/dev-view.tsx +0 -352
  82. package/src/components/streaming-view.ts +0 -177
  83. package/src/config.ts +0 -893
  84. package/src/contract.meta.ts +0 -140
  85. package/src/contract.ts +0 -326
  86. package/src/dev-logs.ts +0 -92
  87. package/src/dev-session.ts +0 -283
  88. package/src/fastkv.ts +0 -181
  89. package/src/index.ts +0 -8
  90. package/src/integrity.ts +0 -138
  91. package/src/internal/manifest-normalizer.ts +0 -290
  92. package/src/merge.ts +0 -187
  93. package/src/mf.ts +0 -147
  94. package/src/near-cli.ts +0 -259
  95. package/src/network.ts +0 -3
  96. package/src/orchestrator.ts +0 -493
  97. package/src/plugin.ts +0 -1799
  98. package/src/sdk.ts +0 -14
  99. package/src/service-descriptor.ts +0 -281
  100. package/src/shared.ts +0 -249
  101. package/src/sidebar.ts +0 -140
  102. package/src/types.ts +0 -330
  103. package/src/ui/head.ts +0 -83
  104. package/src/ui/index.ts +0 -5
  105. package/src/ui/metadata.ts +0 -95
  106. package/src/ui/router.ts +0 -88
  107. package/src/ui/runtime.ts +0 -42
  108. package/src/ui/types.ts +0 -65
  109. package/src/utils/banner.ts +0 -21
  110. package/src/utils/linkify.ts +0 -11
  111. package/src/utils/path-match.ts +0 -16
  112. package/src/utils/run.ts +0 -31
  113. package/src/utils/save-config.ts +0 -20
  114. package/src/utils/theme.ts +0 -39
package/src/types.ts DELETED
@@ -1,330 +0,0 @@
1
- import * as z from "zod";
2
-
3
- export const ExtendsSchema = z.union([
4
- z.string(),
5
- z.object({
6
- development: z.string().optional(),
7
- production: z.string().optional(),
8
- staging: z.string().optional(),
9
- }),
10
- ]);
11
- export type Extends = z.infer<typeof ExtendsSchema>;
12
- export type ExtendsConfig = Extract<Extends, Record<string, string | undefined>>;
13
-
14
- export const SourceModeSchema = z.enum(["local", "remote"]);
15
- export type SourceMode = z.infer<typeof SourceModeSchema>;
16
-
17
- export const SharedConfigSchema = z.object({
18
- version: z.string(),
19
- requiredVersion: z.string().optional(),
20
- singleton: z.boolean().optional(),
21
- eager: z.boolean().optional(),
22
- strictVersion: z.boolean().optional(),
23
- shareScope: z.string().optional(),
24
- });
25
- export type SharedConfig = z.infer<typeof SharedConfigSchema>;
26
- export type SharedDepConfig = SharedConfig;
27
- export const SharedDepConfigSchema = SharedConfigSchema;
28
-
29
- export const FederationEntrySchema = z.object({
30
- name: z.string(),
31
- url: z.string(),
32
- entry: z.string(),
33
- source: SourceModeSchema,
34
- integrity: z.string().optional(),
35
- });
36
- export type FederationEntry = z.infer<typeof FederationEntrySchema>;
37
-
38
- export const SidebarRoleSchema = z.enum(["anon", "member", "admin"]);
39
- export type SidebarRole = z.infer<typeof SidebarRoleSchema>;
40
-
41
- export const SidebarItemSchema = z.object({
42
- icon: z.string(),
43
- label: z.string(),
44
- to: z.string().optional(),
45
- roleRequired: SidebarRoleSchema.optional(),
46
- });
47
- export type SidebarItem = z.infer<typeof SidebarItemSchema>;
48
-
49
- export const ComposableAppEntrySchema = z.object({
50
- extends: ExtendsSchema.optional(),
51
- name: z.string().optional(),
52
- development: z.string().optional(),
53
- production: z.string().optional(),
54
- integrity: z.string().optional(),
55
- proxy: z.string().optional(),
56
- variables: z.record(z.string(), z.string()).optional(),
57
- secrets: z.array(z.string()).optional(),
58
- sidebar: z.array(SidebarItemSchema).optional(),
59
- routes: z.array(z.string()).optional(),
60
- });
61
- export type ComposableAppEntry = z.infer<typeof ComposableAppEntrySchema>;
62
-
63
- export const ApiPluginConfigSchema = ComposableAppEntrySchema;
64
- export type ApiPluginConfig = z.infer<typeof ApiPluginConfigSchema>;
65
-
66
- export const PluginUiConfigSchema = z.object({
67
- name: z.string(),
68
- development: z.string().optional(),
69
- production: z.string().optional(),
70
- integrity: z.string().optional(),
71
- });
72
- export type PluginUiConfig = z.infer<typeof PluginUiConfigSchema>;
73
-
74
- export const BosPluginRefSchema = ComposableAppEntrySchema.extend({
75
- version: z.string().optional(),
76
- app: z.record(z.string(), z.unknown()).optional(),
77
- shared: z.record(z.string(), z.record(z.string(), SharedConfigSchema)).optional(),
78
- plugins: z.record(z.string(), z.unknown()).optional(),
79
- });
80
- export type BosPluginRef = z.infer<typeof BosPluginRefSchema>;
81
- export type PluginEntryValue = string | BosPluginRef;
82
- export type PluginEntries = Record<string, PluginEntryValue>;
83
-
84
- const PluginRuntimeUiSchema = z.object({
85
- name: z.string(),
86
- url: z.string(),
87
- entry: z.string(),
88
- source: SourceModeSchema,
89
- localPath: z.string().optional(),
90
- port: z.number().optional(),
91
- integrity: z.string().optional(),
92
- });
93
- export type PluginRuntimeUi = z.infer<typeof PluginRuntimeUiSchema>;
94
-
95
- export const RuntimePluginConfigSchema = z.object({
96
- name: z.string(),
97
- url: z.string(),
98
- entry: z.string(),
99
- source: SourceModeSchema,
100
- localPath: z.string().optional(),
101
- port: z.number().optional(),
102
- proxy: z.string().optional(),
103
- variables: z.record(z.string(), z.string()).optional(),
104
- secrets: z.array(z.string()).optional(),
105
- integrity: z.string().optional(),
106
- ui: PluginRuntimeUiSchema.optional(),
107
- sidebar: z.array(SidebarItemSchema).optional(),
108
- routes: z.array(z.string()).optional(),
109
- });
110
- export type RuntimePluginConfig = z.infer<typeof RuntimePluginConfigSchema>;
111
-
112
- export const UiConfigSchema = z.object({
113
- name: z.string(),
114
- development: z.string().optional(),
115
- production: z.string().optional(),
116
- integrity: z.string().optional(),
117
- ssr: z.string().optional(),
118
- ssrIntegrity: z.string().optional(),
119
- });
120
- export type UiConfig = z.infer<typeof UiConfigSchema>;
121
-
122
- export const HostConfigSchema = z.object({
123
- development: z.string(),
124
- production: z.string(),
125
- integrity: z.string().optional(),
126
- secrets: z.array(z.string()).optional(),
127
- });
128
- export type HostConfig = z.infer<typeof HostConfigSchema>;
129
-
130
- export const ClientRuntimeInfoSchema = z.object({
131
- accountId: z.string(),
132
- gatewayId: z.string(),
133
- runtimeBasePath: z.string(),
134
- title: z.string().nullable(),
135
- description: z.string().nullable(),
136
- hostUrl: z.string().nullable(),
137
- });
138
- export type ClientRuntimeInfo = z.infer<typeof ClientRuntimeInfoSchema>;
139
-
140
- export const BosStagingSchema = z.object({
141
- domain: z.string(),
142
- });
143
- export type BosStaging = z.infer<typeof BosStagingSchema>;
144
-
145
- const BosConfigInputAppEntrySchema = z.record(z.string(), z.unknown());
146
- export type BosConfigInputAppEntry = z.infer<typeof BosConfigInputAppEntrySchema>;
147
-
148
- export const BosConfigInputSchema: z.ZodType<BosConfigInput> = z.lazy(() =>
149
- z.object({
150
- extends: ExtendsSchema.optional(),
151
- account: z.string().optional(),
152
- domain: z.string().optional(),
153
- testnet: z.string().optional(),
154
- template: z.string().optional(),
155
- gateway: z
156
- .object({
157
- development: z.string().optional(),
158
- production: z.string().optional(),
159
- account: z.string().optional(),
160
- })
161
- .optional(),
162
- development: z.string().optional(),
163
- production: z.string().optional(),
164
- integrity: z.string().optional(),
165
- name: z.string().optional(),
166
- version: z.string().optional(),
167
- proxy: z.string().optional(),
168
- variables: z.record(z.string(), z.string()).optional(),
169
- secrets: z.array(z.string()).optional(),
170
- routes: z.array(z.string()).optional(),
171
- sidebar: z.array(SidebarItemSchema).optional(),
172
- app: z.record(z.string(), BosConfigInputAppEntrySchema).optional(),
173
- shared: z.record(z.string(), z.record(z.string(), SharedConfigSchema)).optional(),
174
- plugins: z.record(z.string(), z.union([z.string(), BosConfigInputSchema])).optional(),
175
- }),
176
- );
177
-
178
- export interface BosConfigInput {
179
- extends?: string | ExtendsConfig;
180
- account?: string;
181
- domain?: string;
182
- title?: string;
183
- description?: string;
184
- testnet?: string;
185
- template?: string;
186
- gateway?: {
187
- development?: string;
188
- production?: string;
189
- account?: string;
190
- };
191
- development?: string;
192
- production?: string;
193
- integrity?: string;
194
- name?: string;
195
- version?: string;
196
- proxy?: string;
197
- variables?: Record<string, string>;
198
- secrets?: string[];
199
- routes?: string[];
200
- sidebar?: SidebarItem[];
201
- app?: Record<string, BosConfigInputAppEntry>;
202
- shared?: Record<string, Record<string, SharedDepConfig>>;
203
- plugins?: Record<string, string | BosConfigInput>;
204
- }
205
-
206
- export const BosConfigSchema = z.object({
207
- account: z.string(),
208
- extends: ExtendsSchema.optional(),
209
- domain: z.string().optional(),
210
- title: z.string().optional(),
211
- description: z.string().optional(),
212
- testnet: z.string().optional(),
213
- staging: BosStagingSchema.optional(),
214
- repository: z.string().optional(),
215
- shared: z.record(z.string(), z.record(z.string(), SharedConfigSchema)).optional(),
216
- plugins: z.record(z.string(), z.union([z.string(), BosPluginRefSchema])).optional(),
217
- app: z.object({
218
- host: HostConfigSchema,
219
- ui: UiConfigSchema,
220
- api: ComposableAppEntrySchema,
221
- auth: ComposableAppEntrySchema.optional(),
222
- }),
223
- });
224
- export type BosConfig = z.infer<typeof BosConfigSchema>;
225
-
226
- export const RuntimeConfigSchema = z.object({
227
- env: z.enum(["development", "production", "staging"]),
228
- account: z.string(),
229
- domain: z.string().optional(),
230
- networkId: z.enum(["mainnet", "testnet"]),
231
- title: z.string().optional(),
232
- description: z.string().optional(),
233
- repository: z.string().optional(),
234
- host: FederationEntrySchema.extend({
235
- localPath: z.string().optional(),
236
- port: z.number().optional(),
237
- secrets: z.array(z.string()).optional(),
238
- remoteUrl: z.string().optional(),
239
- }),
240
- shared: z
241
- .object({
242
- ui: z.record(z.string(), SharedConfigSchema).optional(),
243
- plugins: z.record(z.string(), SharedConfigSchema).optional(),
244
- })
245
- .optional(),
246
- ui: FederationEntrySchema.extend({
247
- localPath: z.string().optional(),
248
- port: z.number().optional(),
249
- ssrUrl: z.string().optional(),
250
- ssrIntegrity: z.string().optional(),
251
- }),
252
- api: FederationEntrySchema.extend({
253
- localPath: z.string().optional(),
254
- port: z.number().optional(),
255
- proxy: z.string().optional(),
256
- variables: z.record(z.string(), z.string()).optional(),
257
- secrets: z.array(z.string()).optional(),
258
- }),
259
- auth: FederationEntrySchema.extend({
260
- localPath: z.string().optional(),
261
- port: z.number().optional(),
262
- proxy: z.string().optional(),
263
- variables: z.record(z.string(), z.string()).optional(),
264
- secrets: z.array(z.string()).optional(),
265
- sidebar: z.array(SidebarItemSchema).optional(),
266
- }).optional(),
267
- plugins: z.record(z.string(), RuntimePluginConfigSchema).optional(),
268
- });
269
- export type RuntimeConfig = z.infer<typeof RuntimeConfigSchema>;
270
-
271
- export const ClientRuntimeConfigSchema = z.object({
272
- cspNonce: z.string().optional(),
273
- env: z.enum(["development", "production", "staging"]),
274
- account: z.string(),
275
- networkId: z.enum(["mainnet", "testnet"]),
276
- hostUrl: z.string().optional(),
277
- assetsUrl: z.string(),
278
- apiBase: z.string(),
279
- rpcBase: z.string(),
280
- repository: z.string().optional(),
281
- authAvailable: z.boolean().optional(),
282
- runtime: ClientRuntimeInfoSchema.optional(),
283
- ui: z
284
- .object({
285
- name: z.string(),
286
- url: z.string(),
287
- entry: z.string(),
288
- integrity: z.string().optional(),
289
- })
290
- .optional(),
291
- api: z
292
- .object({
293
- name: z.string(),
294
- url: z.string(),
295
- entry: z.string(),
296
- integrity: z.string().optional(),
297
- })
298
- .optional(),
299
- auth: z
300
- .object({
301
- name: z.string(),
302
- url: z.string(),
303
- entry: z.string(),
304
- integrity: z.string().optional(),
305
- sidebar: z.array(SidebarItemSchema).optional(),
306
- })
307
- .optional(),
308
- plugins: z
309
- .record(
310
- z.string(),
311
- z.object({
312
- name: z.string(),
313
- url: z.string(),
314
- entry: z.string(),
315
- integrity: z.string().optional(),
316
- ui: z
317
- .object({
318
- name: z.string(),
319
- url: z.string(),
320
- entry: z.string(),
321
- source: SourceModeSchema,
322
- integrity: z.string().optional(),
323
- })
324
- .optional(),
325
- sidebar: z.array(SidebarItemSchema).optional(),
326
- }),
327
- )
328
- .optional(),
329
- });
330
- export type ClientRuntimeConfig = z.infer<typeof ClientRuntimeConfigSchema>;
package/src/ui/head.ts DELETED
@@ -1,83 +0,0 @@
1
- import type { ClientRuntimeConfig } from "../types";
2
- import type { HeadScript } from "./types";
3
-
4
- export interface RemoteScriptsOptions {
5
- assetsUrl: string;
6
- runtimeConfig?: Partial<ClientRuntimeConfig>;
7
- containerName?: string;
8
- hydratePath?: string;
9
- integrity?: string;
10
- }
11
-
12
- export function getRemoteEntryScript(assetsUrl: string, integrity?: string): HeadScript {
13
- const script: HeadScript = {
14
- src: `${assetsUrl}/remoteEntry.js`,
15
- };
16
- if (integrity) {
17
- script.integrity = integrity;
18
- script.crossOrigin = "anonymous";
19
- }
20
- return script;
21
- }
22
-
23
- export function getThemeInitScript(): HeadScript {
24
- return {
25
- children:
26
- "(function(){var t=localStorage.getItem('theme');if(t==='dark'||(!t&&window.matchMedia('(prefers-color-scheme: dark)').matches)){document.documentElement.classList.add('dark');}})();",
27
- };
28
- }
29
-
30
- export function getHydrateScript(
31
- runtimeConfig: Partial<ClientRuntimeConfig> | undefined,
32
- containerName = "ui",
33
- hydratePath = "./Hydrate",
34
- ): HeadScript {
35
- return {
36
- children: `
37
- window.__RUNTIME_CONFIG__=${JSON.stringify(runtimeConfig)};
38
- function __hydrate(){
39
- var container = window['${containerName}'];
40
- if (!container) {
41
- console.warn('[Hydrate] Container not ready yet, waiting...');
42
- window.__hydrateRetry = window.__hydrateRetry || 0;
43
- if (window.__hydrateRetry < 10) {
44
- window.__hydrateRetry++;
45
- setTimeout(__hydrate, 100);
46
- return;
47
- }
48
- console.error('[Hydrate] Container not found after 10 retries');
49
- return;
50
- }
51
- console.log('[Hydrate] Container available, starting init...');
52
- container.init({}).then(function(){
53
- return container.get('${hydratePath}');
54
- }).then(function(mod){
55
- return mod().hydrate();
56
- }).catch(function(e){
57
- console.error('[Hydrate] Failed:', e);
58
- });
59
- }
60
- if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',__hydrate);}else{__hydrate();}
61
- `.trim(),
62
- };
63
- }
64
-
65
- export function getRemoteScripts(options: RemoteScriptsOptions): HeadScript[] {
66
- const { assetsUrl, runtimeConfig, containerName, hydratePath, integrity } = options;
67
-
68
- return [
69
- getRemoteEntryScript(assetsUrl, integrity),
70
- getThemeInitScript(),
71
- getHydrateScript(runtimeConfig, containerName, hydratePath),
72
- ];
73
- }
74
-
75
- export function getBaseStyles(): string {
76
- return `
77
- *, *::before, *::after { box-sizing: border-box; }
78
- html { height: 100%; height: 100dvh; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; color-scheme: light dark; }
79
- body { min-height: 100%; min-height: 100dvh; margin: 0; background-color: var(--background); color: var(--foreground); -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
80
- #root { min-height: 100vh; }
81
- @supports (min-height: 100dvh) { #root { min-height: 100dvh; } }
82
- `.trim();
83
- }
package/src/ui/index.ts DELETED
@@ -1,5 +0,0 @@
1
- export * from "./head";
2
- export * from "./metadata";
3
- export * from "./router";
4
- export * from "./runtime";
5
- export * from "./types";
@@ -1,95 +0,0 @@
1
- export const SOCIAL_IMAGE_WIDTH = 1200;
2
- export const SOCIAL_IMAGE_HEIGHT = 630;
3
-
4
- export interface SocialImageMetaOptions {
5
- imageUrl: string;
6
- title: string;
7
- description: string;
8
- siteName?: string;
9
- siteUrl?: string;
10
- type?: string;
11
- alt?: string;
12
- width?: number;
13
- height?: number;
14
- mimeType?: string;
15
- }
16
-
17
- export function getSocialImageMeta(options: SocialImageMetaOptions) {
18
- const {
19
- imageUrl,
20
- title,
21
- description,
22
- siteName,
23
- siteUrl,
24
- type = "website",
25
- alt,
26
- width = SOCIAL_IMAGE_WIDTH,
27
- height = SOCIAL_IMAGE_HEIGHT,
28
- mimeType = "image/png",
29
- } = options;
30
-
31
- return [
32
- { property: "og:title", content: title },
33
- { property: "og:description", content: description },
34
- { property: "og:type", content: type },
35
- { property: "og:image", content: imageUrl },
36
- { property: "og:image:type", content: mimeType },
37
- { property: "og:image:width", content: String(width) },
38
- { property: "og:image:height", content: String(height) },
39
- ...(alt ? [{ property: "og:image:alt", content: alt }] : []),
40
- ...(siteName ? [{ property: "og:site_name", content: siteName }] : []),
41
- ...(siteUrl ? [{ property: "og:url", content: siteUrl }] : []),
42
- { name: "twitter:card", content: "summary_large_image" },
43
- { name: "twitter:title", content: title },
44
- { name: "twitter:description", content: description },
45
- { name: "twitter:image", content: imageUrl },
46
- ...(alt ? [{ name: "twitter:image:alt", content: alt }] : []),
47
- ];
48
- }
49
-
50
- export interface DotIconSvgOptions {
51
- size?: number;
52
- color?: string;
53
- radius?: number;
54
- background?: string;
55
- }
56
-
57
- export function createDotIconSvg(options: DotIconSvgOptions = {}) {
58
- const {
59
- size = 64,
60
- color = "#111111",
61
- radius = size * 0.34,
62
- background = "transparent",
63
- } = options;
64
- const center = size / 2;
65
-
66
- return `<?xml version="1.0" encoding="UTF-8"?>
67
- <svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" viewBox="0 0 ${size} ${size}">
68
- <rect width="${size}" height="${size}" fill="${background}" />
69
- <circle cx="${center}" cy="${center}" r="${radius}" fill="${color}" />
70
- </svg>`;
71
- }
72
-
73
- export function createPngIcoBuffer(png: Uint8Array, width: number, height: number) {
74
- const header = new Uint8Array(22);
75
- const view = new DataView(header.buffer);
76
-
77
- view.setUint16(0, 0, true);
78
- view.setUint16(2, 1, true);
79
- view.setUint16(4, 1, true);
80
-
81
- header[6] = width >= 256 ? 0 : width;
82
- header[7] = height >= 256 ? 0 : height;
83
- header[8] = 0;
84
- header[9] = 0;
85
-
86
- view.setUint16(10, 1, true);
87
- view.setUint16(12, 32, true);
88
- view.setUint32(14, png.byteLength, true);
89
- view.setUint32(18, 22, true);
90
-
91
- const ico = new Uint8Array(22 + png.byteLength);
92
- ico.set(header, 0);
93
- ico.set(png, 22);
94
- return ico;
95
- }
package/src/ui/router.ts DELETED
@@ -1,88 +0,0 @@
1
- import type { AnyRouter } from "@tanstack/react-router";
2
- import type { HeadData, HeadLink, HeadMeta, HeadScript } from "./types";
3
-
4
- export function getMetaKey(meta: HeadMeta): string {
5
- if (!meta) return "null";
6
- if ("title" in meta) return "title";
7
- if ("charSet" in meta) return "charSet";
8
- if ("name" in meta) return `name:${(meta as { name: string }).name}`;
9
- if ("property" in meta) {
10
- return `property:${(meta as { property: string }).property}`;
11
- }
12
- if ("httpEquiv" in meta) {
13
- return `httpEquiv:${(meta as { httpEquiv: string }).httpEquiv}`;
14
- }
15
- return JSON.stringify(meta);
16
- }
17
-
18
- export function getLinkKey(link: HeadLink): string {
19
- const rel = (link as { rel?: string }).rel ?? "";
20
- const href = (link as { href?: string }).href ?? "";
21
- return `${rel}:${href}`;
22
- }
23
-
24
- export function getScriptKey(script: HeadScript): string {
25
- if (!script) return "null";
26
- if ("src" in script && script.src) return `src:${script.src}`;
27
- if ("children" in script && script.children) {
28
- return `children:${typeof script.children === "string" ? script.children : JSON.stringify(script.children)}`;
29
- }
30
- return JSON.stringify(script);
31
- }
32
-
33
- export async function collectHeadData(router: AnyRouter): Promise<HeadData> {
34
- await router.load();
35
-
36
- const metaMap = new Map<string, HeadMeta>();
37
- const linkMap = new Map<string, HeadLink>();
38
- const scriptMap = new Map<string, HeadScript>();
39
-
40
- for (const match of router.state.matches) {
41
- const route =
42
- (
43
- router as AnyRouter & {
44
- routesById?: Record<string, { options?: { head?: (...args: unknown[]) => unknown } }>;
45
- }
46
- ).routesById?.[(match as { routeId: string }).routeId] ??
47
- (match as { route?: { options?: { head?: (...args: unknown[]) => unknown } } }).route;
48
- const headFn = route?.options?.head;
49
- if (!headFn) continue;
50
-
51
- try {
52
- const headResult = (await headFn({
53
- loaderData: match.loaderData,
54
- matches: router.state.matches,
55
- match,
56
- params: match.params,
57
- })) as {
58
- meta?: HeadMeta[];
59
- links?: HeadLink[];
60
- scripts?: HeadScript[];
61
- };
62
-
63
- if (headResult?.meta) {
64
- for (const meta of headResult.meta) {
65
- metaMap.set(getMetaKey(meta), meta);
66
- }
67
- }
68
- if (headResult?.links) {
69
- for (const link of headResult.links) {
70
- linkMap.set(getLinkKey(link), link);
71
- }
72
- }
73
- if (headResult?.scripts) {
74
- for (const script of headResult.scripts) {
75
- scriptMap.set(getScriptKey(script), script);
76
- }
77
- }
78
- } catch (error) {
79
- console.warn(`[collectHeadData] head() failed for ${match.routeId}:`, error);
80
- }
81
- }
82
-
83
- return {
84
- meta: [...metaMap.values()],
85
- links: [...linkMap.values()],
86
- scripts: [...scriptMap.values()],
87
- };
88
- }
package/src/ui/runtime.ts DELETED
@@ -1,42 +0,0 @@
1
- import type { ClientRuntimeConfig } from "../types";
2
-
3
- export type { ClientRuntimeInfo } from "../types";
4
-
5
- declare global {
6
- interface Window {
7
- __RUNTIME_CONFIG__?: ClientRuntimeConfig;
8
- }
9
- }
10
-
11
- export function getRuntimeConfig(): ClientRuntimeConfig {
12
- if (typeof window === "undefined") {
13
- throw new Error("Runtime config is only available in the browser");
14
- }
15
-
16
- if (!window.__RUNTIME_CONFIG__) {
17
- throw new Error("Missing runtime config");
18
- }
19
-
20
- return window.__RUNTIME_CONFIG__;
21
- }
22
-
23
- export function buildRuntimeHref(pathname: string, runtimeConfig?: Partial<ClientRuntimeConfig>) {
24
- const basePath = runtimeConfig?.runtime?.runtimeBasePath ?? "/";
25
- if (basePath === "/") {
26
- return pathname;
27
- }
28
-
29
- if (!pathname.startsWith("/")) {
30
- return `${basePath}/${pathname}`;
31
- }
32
-
33
- return pathname === "/" ? basePath : `${basePath}${pathname}`;
34
- }
35
-
36
- export function buildPublishedAccountHref(accountId: string) {
37
- return `/apps/${encodeURIComponent(accountId)}`;
38
- }
39
-
40
- export function buildPublishedGatewayHref(accountId: string, gatewayId: string) {
41
- return `${buildPublishedAccountHref(accountId)}/${encodeURIComponent(gatewayId)}`;
42
- }