zitejs 0.9.153 → 0.9.154

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 (393) hide show
  1. package/dist/cjs/auth/actions.d.ts +28 -0
  2. package/dist/cjs/auth/actions.js +93 -0
  3. package/dist/cjs/auth/client.d.ts +357 -0
  4. package/dist/cjs/auth/client.js +66 -0
  5. package/dist/cjs/auth/config.js +9 -3
  6. package/dist/cjs/auth/index.d.ts +2 -249
  7. package/dist/cjs/auth/index.js +11 -108
  8. package/dist/cjs/auth/index.test.js +60 -0
  9. package/dist/cjs/auth/previewClaim.d.ts +7 -0
  10. package/dist/cjs/auth/previewClaim.js +16 -0
  11. package/dist/cjs/auth/profileUpdates.d.ts +9 -0
  12. package/dist/cjs/auth/profileUpdates.js +11 -0
  13. package/dist/cjs/backend/index.d.ts +6 -6
  14. package/dist/cjs/backend/index.js +13 -13
  15. package/dist/cjs/backend/index.test.js +102 -102
  16. package/dist/cjs/bundle/index.js +29 -16
  17. package/dist/cjs/caller/index.js +43 -43
  18. package/dist/cjs/check/index.d.ts +44 -1
  19. package/dist/cjs/check/index.js +198 -61
  20. package/dist/cjs/check/start/routeTree.d.ts +8 -0
  21. package/dist/cjs/check/start/routeTree.js +118 -0
  22. package/dist/cjs/check/start/tsgo.d.ts +2 -0
  23. package/dist/cjs/check/start/tsgo.js +35 -0
  24. package/dist/cjs/cli.js +19 -6
  25. package/dist/cjs/client/index.d.ts +2 -2
  26. package/dist/cjs/client/index.js +25 -25
  27. package/dist/cjs/dev/index.js +81 -53
  28. package/dist/cjs/dev/signin.d.ts +16 -0
  29. package/dist/cjs/dev/signin.js +84 -0
  30. package/dist/cjs/index.d.ts +5 -5
  31. package/dist/cjs/integrations/client.d.ts +3 -3
  32. package/dist/cjs/integrations/client.js +5 -4
  33. package/dist/cjs/integrations/client.test-d.js +15 -15
  34. package/dist/cjs/integrations/index.d.ts +2 -2
  35. package/dist/cjs/integrations/rules.js +42 -42
  36. package/dist/cjs/integrations/rules.test.js +60 -55
  37. package/dist/cjs/internal/appMode.d.ts +14 -0
  38. package/dist/cjs/internal/appMode.js +19 -0
  39. package/dist/cjs/internal/env.js +3 -2
  40. package/dist/cjs/internal/platformFetch.d.ts +2 -0
  41. package/dist/cjs/internal/platformFetch.js +14 -0
  42. package/dist/cjs/internal/reservedIds.d.ts +8 -0
  43. package/dist/cjs/internal/reservedIds.js +14 -0
  44. package/dist/cjs/internal/serviceUrls.d.ts +5 -0
  45. package/dist/cjs/internal/serviceUrls.js +14 -0
  46. package/dist/cjs/pdf/index.js +2 -1
  47. package/dist/cjs/runtime/filterConditionTypes.test-d.js +11 -11
  48. package/dist/cjs/runtime/index.d.ts +22 -22
  49. package/dist/cjs/runtime/index.js +28 -28
  50. package/dist/cjs/runtime/index.test.js +34 -34
  51. package/dist/cjs/runtime/sendEmailParamsTypes.test-d.js +29 -29
  52. package/dist/cjs/runtime/writeResultTypes.test-d.js +8 -8
  53. package/dist/cjs/sourceRoots.js +15 -15
  54. package/dist/cjs/sourceRoots.test.js +29 -27
  55. package/dist/cjs/start/build/entries.d.ts +25 -0
  56. package/dist/cjs/start/build/entries.js +121 -0
  57. package/dist/cjs/start/build/placeholders/devApp.d.ts +1 -0
  58. package/dist/cjs/start/build/placeholders/devApp.js +6 -0
  59. package/dist/cjs/start/describe/describeBuilt.d.ts +5 -0
  60. package/dist/cjs/start/describe/describeBuilt.js +144 -0
  61. package/dist/cjs/start/platform/aiUsage.d.ts +29 -0
  62. package/dist/cjs/start/platform/aiUsage.js +215 -0
  63. package/dist/cjs/start/platform/airtable/cache.d.ts +17 -0
  64. package/dist/cjs/start/platform/airtable/cache.js +93 -0
  65. package/dist/cjs/start/protocol.d.ts +19 -0
  66. package/dist/cjs/start/protocol.js +33 -0
  67. package/dist/cjs/start/serve/local/provider.d.ts +25 -0
  68. package/dist/cjs/start/serve/local/provider.js +196 -0
  69. package/dist/cjs/start/serve/provider.d.ts +19 -0
  70. package/dist/cjs/start/serve/provider.js +86 -0
  71. package/dist/cjs/start/types.d.ts +373 -0
  72. package/dist/cjs/start/types.js +2 -0
  73. package/dist/cjs/steps/index.d.ts +8 -8
  74. package/dist/cjs/steps/index.js +53 -53
  75. package/dist/cjs/steps/index.test.js +218 -218
  76. package/dist/cjs/sync/index.d.ts +1 -1
  77. package/dist/cjs/sync/index.js +28 -27
  78. package/dist/cjs/sync/lib.d.ts +15 -8
  79. package/dist/cjs/sync/lib.js +651 -665
  80. package/dist/cjs/sync/lib.test.js +81 -14
  81. package/dist/cjs/sync/sdkNames.d.ts +67 -9
  82. package/dist/cjs/sync/sdkNames.js +97 -31
  83. package/dist/cjs/sync/sdkNames.test.js +189 -113
  84. package/dist/cjs/types/fields.d.ts +1 -1
  85. package/dist/cjs/types/fields.js +105 -97
  86. package/dist/cjs/types/index.d.ts +2 -2
  87. package/dist/cjs/types/tables.d.ts +1 -1
  88. package/dist/cjs/upload/index.js +89 -24
  89. package/dist/cjs/upload/index.test.js +104 -1
  90. package/dist/cjs/vite/domTagNames.js +252 -252
  91. package/dist/cjs/vite/index.d.ts +1 -1
  92. package/dist/cjs/vite/index.js +51 -42
  93. package/dist/cjs/vite/index.test.js +10 -2
  94. package/dist/esm/auth/actions.d.ts +28 -0
  95. package/dist/esm/auth/actions.js +55 -0
  96. package/dist/esm/auth/client.d.ts +357 -0
  97. package/dist/esm/auth/client.js +62 -0
  98. package/dist/esm/auth/config.js +9 -3
  99. package/dist/esm/auth/index.d.ts +2 -249
  100. package/dist/esm/auth/index.js +2 -103
  101. package/dist/esm/auth/index.test.js +60 -0
  102. package/dist/esm/auth/previewClaim.d.ts +7 -0
  103. package/dist/esm/auth/previewClaim.js +12 -0
  104. package/dist/esm/auth/profileUpdates.d.ts +9 -0
  105. package/dist/esm/auth/profileUpdates.js +6 -0
  106. package/dist/esm/backend/index.d.ts +6 -6
  107. package/dist/esm/backend/index.js +13 -13
  108. package/dist/esm/backend/index.test.js +106 -106
  109. package/dist/esm/bundle/index.js +29 -16
  110. package/dist/esm/caller/index.js +44 -44
  111. package/dist/esm/check/index.d.ts +44 -1
  112. package/dist/esm/check/index.js +194 -61
  113. package/dist/esm/check/start/routeTree.d.ts +8 -0
  114. package/dist/esm/check/start/routeTree.js +77 -0
  115. package/dist/esm/check/start/tsgo.d.ts +2 -0
  116. package/dist/esm/check/start/tsgo.js +29 -0
  117. package/dist/esm/cli.js +19 -6
  118. package/dist/esm/client/index.d.ts +2 -2
  119. package/dist/esm/client/index.js +25 -25
  120. package/dist/esm/dev/index.js +88 -60
  121. package/dist/esm/dev/signin.d.ts +16 -0
  122. package/dist/esm/dev/signin.js +80 -0
  123. package/dist/esm/index.d.ts +5 -5
  124. package/dist/esm/index.js +3 -3
  125. package/dist/esm/integrations/client.d.ts +3 -3
  126. package/dist/esm/integrations/client.js +6 -5
  127. package/dist/esm/integrations/client.test-d.js +19 -19
  128. package/dist/esm/integrations/index.d.ts +2 -2
  129. package/dist/esm/integrations/index.js +1 -1
  130. package/dist/esm/integrations/rules.js +42 -42
  131. package/dist/esm/integrations/rules.test.js +62 -57
  132. package/dist/esm/internal/appMode.d.ts +14 -0
  133. package/dist/esm/internal/appMode.js +13 -0
  134. package/dist/esm/internal/env.js +3 -2
  135. package/dist/esm/internal/platformFetch.d.ts +2 -0
  136. package/dist/esm/internal/platformFetch.js +9 -0
  137. package/dist/esm/internal/reservedIds.d.ts +8 -0
  138. package/dist/esm/internal/reservedIds.js +10 -0
  139. package/dist/esm/internal/serviceUrls.d.ts +5 -0
  140. package/dist/esm/internal/serviceUrls.js +10 -0
  141. package/dist/esm/pdf/index.js +2 -1
  142. package/dist/esm/runtime/filterConditionTypes.test-d.js +12 -12
  143. package/dist/esm/runtime/index.d.ts +22 -22
  144. package/dist/esm/runtime/index.js +31 -31
  145. package/dist/esm/runtime/index.test.js +36 -36
  146. package/dist/esm/runtime/sendEmailParamsTypes.test-d.js +30 -30
  147. package/dist/esm/runtime/writeResultTypes.test-d.js +9 -9
  148. package/dist/esm/signin/conformance.d.ts +100 -0
  149. package/dist/esm/signin/conformance.js +616 -0
  150. package/dist/esm/signin/cookies.d.ts +28 -0
  151. package/dist/esm/signin/cookies.js +67 -0
  152. package/dist/esm/signin/encoding.d.ts +1 -0
  153. package/dist/esm/signin/encoding.js +12 -0
  154. package/dist/esm/signin/endpoints.d.ts +12 -0
  155. package/dist/esm/signin/endpoints.js +32 -0
  156. package/dist/esm/signin/http.d.ts +25 -0
  157. package/dist/esm/signin/http.js +106 -0
  158. package/dist/esm/signin/index.d.ts +8 -0
  159. package/dist/esm/signin/index.js +9 -0
  160. package/dist/esm/signin/keys.d.ts +35 -0
  161. package/dist/esm/signin/keys.js +230 -0
  162. package/dist/esm/signin/paths.d.ts +2 -0
  163. package/dist/esm/signin/paths.js +5 -0
  164. package/dist/esm/signin/seal.d.ts +19 -0
  165. package/dist/esm/signin/seal.js +47 -0
  166. package/dist/esm/signin/signin.d.ts +60 -0
  167. package/dist/esm/signin/signin.js +447 -0
  168. package/dist/esm/signin/transport.d.ts +112 -0
  169. package/dist/esm/signin/transport.js +1 -0
  170. package/dist/esm/signin/verifier.d.ts +2 -0
  171. package/dist/esm/signin/verifier.js +4 -0
  172. package/dist/esm/signin/verify.d.ts +83 -0
  173. package/dist/esm/signin/verify.js +142 -0
  174. package/dist/esm/sourceRoots.js +17 -17
  175. package/dist/esm/sourceRoots.test.js +34 -32
  176. package/dist/esm/start/access.d.ts +19 -0
  177. package/dist/esm/start/access.js +43 -0
  178. package/dist/esm/start/auth.d.ts +28 -0
  179. package/dist/esm/start/auth.js +33 -0
  180. package/dist/esm/start/automations/quiet.d.ts +2 -0
  181. package/dist/esm/start/automations/quiet.js +36 -0
  182. package/dist/esm/start/automations/registration.d.ts +13 -0
  183. package/dist/esm/start/automations/registration.js +25 -0
  184. package/dist/esm/start/automations/steps.d.ts +29 -0
  185. package/dist/esm/start/automations/steps.js +95 -0
  186. package/dist/esm/start/automations/workflow.d.ts +83 -0
  187. package/dist/esm/start/automations/workflow.js +36 -0
  188. package/dist/esm/start/automations/workflow.test-d.d.ts +1 -0
  189. package/dist/esm/start/automations/workflow.test-d.js +130 -0
  190. package/dist/esm/start/automations/workflowRun.d.ts +130 -0
  191. package/dist/esm/start/automations/workflowRun.js +185 -0
  192. package/dist/esm/start/barrel.test-d.d.ts +10 -0
  193. package/dist/esm/start/barrel.test-d.js +6 -0
  194. package/dist/esm/start/build/entries.d.ts +25 -0
  195. package/dist/esm/start/build/entries.js +109 -0
  196. package/dist/esm/start/build/placeholders/authHooksModule.d.ts +1 -0
  197. package/dist/esm/start/build/placeholders/authHooksModule.js +3 -0
  198. package/dist/esm/start/build/placeholders/devApp.d.ts +1 -0
  199. package/dist/esm/start/build/placeholders/devApp.js +3 -0
  200. package/dist/esm/start/build/placeholders/devSignIn.d.ts +1 -0
  201. package/dist/esm/start/build/placeholders/devSignIn.js +3 -0
  202. package/dist/esm/start/build/placeholders/siteHead.d.ts +2 -0
  203. package/dist/esm/start/build/placeholders/siteHead.js +3 -0
  204. package/dist/esm/start/build/placeholders/workflowModules.d.ts +1 -0
  205. package/dist/esm/start/build/placeholders/workflowModules.js +3 -0
  206. package/dist/esm/start/build/placeholders/workspaceSchema.d.ts +2 -0
  207. package/dist/esm/start/build/placeholders/workspaceSchema.js +3 -0
  208. package/dist/esm/start/build/registrationHash.d.ts +11 -0
  209. package/dist/esm/start/build/registrationHash.js +88 -0
  210. package/dist/esm/start/build/sdk/axios.d.ts +76 -0
  211. package/dist/esm/start/build/sdk/axios.js +253 -0
  212. package/dist/esm/start/build/sdk/nodeFetch.d.ts +41 -0
  213. package/dist/esm/start/build/sdk/nodeFetch.js +35 -0
  214. package/dist/esm/start/build/sdk/undici.d.ts +34 -0
  215. package/dist/esm/start/build/sdk/undici.js +18 -0
  216. package/dist/esm/start/build/sdkPatches.d.ts +22 -0
  217. package/dist/esm/start/build/sdkPatches.js +430 -0
  218. package/dist/esm/start/build/siteHead.d.ts +26 -0
  219. package/dist/esm/start/build/siteHead.js +88 -0
  220. package/dist/esm/start/build/vite.d.ts +50 -0
  221. package/dist/esm/start/build/vite.js +487 -0
  222. package/dist/esm/start/classicOnly.d.ts +1 -0
  223. package/dist/esm/start/classicOnly.js +4 -0
  224. package/dist/esm/start/clientErrorMessage.test.d.ts +1 -0
  225. package/dist/esm/start/clientErrorMessage.test.js +105 -0
  226. package/dist/esm/start/describe/describe.d.ts +120 -0
  227. package/dist/esm/start/describe/describe.js +372 -0
  228. package/dist/esm/start/describe/describeBuilt.d.ts +5 -0
  229. package/dist/esm/start/describe/describeBuilt.js +102 -0
  230. package/dist/esm/start/describe/descriptions.d.ts +4 -0
  231. package/dist/esm/start/describe/descriptions.js +54 -0
  232. package/dist/esm/start/errors.d.ts +62 -0
  233. package/dist/esm/start/errors.js +163 -0
  234. package/dist/esm/start/errors.test.d.ts +1 -0
  235. package/dist/esm/start/errors.test.js +54 -0
  236. package/dist/esm/start/factories.d.ts +14 -0
  237. package/dist/esm/start/factories.js +23 -0
  238. package/dist/esm/start/factories.test-d.d.ts +2 -0
  239. package/dist/esm/start/factories.test-d.js +60 -0
  240. package/dist/esm/start/failures.d.ts +7 -0
  241. package/dist/esm/start/failures.js +62 -0
  242. package/dist/esm/start/fnFactory.d.ts +16 -0
  243. package/dist/esm/start/fnFactory.js +1 -0
  244. package/dist/esm/start/host.d.ts +3 -0
  245. package/dist/esm/start/host.js +4 -0
  246. package/dist/esm/start/index.d.ts +10 -0
  247. package/dist/esm/start/index.js +7 -0
  248. package/dist/esm/start/login.d.ts +5 -0
  249. package/dist/esm/start/login.js +29 -0
  250. package/dist/esm/start/middlewareKind.d.ts +13 -0
  251. package/dist/esm/start/middlewareKind.js +9 -0
  252. package/dist/esm/start/platform/aiUsage.d.ts +29 -0
  253. package/dist/esm/start/platform/aiUsage.js +210 -0
  254. package/dist/esm/start/platform/airtable/arrayFields.d.ts +10 -0
  255. package/dist/esm/start/platform/airtable/arrayFields.js +30 -0
  256. package/dist/esm/start/platform/airtable/built.d.ts +2 -0
  257. package/dist/esm/start/platform/airtable/built.js +3 -0
  258. package/dist/esm/start/platform/airtable/cache.d.ts +17 -0
  259. package/dist/esm/start/platform/airtable/cache.js +89 -0
  260. package/dist/esm/start/platform/airtable/dispatch.d.ts +57 -0
  261. package/dist/esm/start/platform/airtable/dispatch.js +541 -0
  262. package/dist/esm/start/platform/airtable/formulas.d.ts +70 -0
  263. package/dist/esm/start/platform/airtable/formulas.js +261 -0
  264. package/dist/esm/start/platform/airtable/index.d.ts +6 -0
  265. package/dist/esm/start/platform/airtable/index.js +51 -0
  266. package/dist/esm/start/platform/airtable/settings.d.ts +37 -0
  267. package/dist/esm/start/platform/airtable/settings.js +138 -0
  268. package/dist/esm/start/platform/analytics.d.ts +3 -0
  269. package/dist/esm/start/platform/analytics.js +59 -0
  270. package/dist/esm/start/platform/calls.d.ts +5 -0
  271. package/dist/esm/start/platform/calls.js +104 -0
  272. package/dist/esm/start/platform/caps.d.ts +9 -0
  273. package/dist/esm/start/platform/caps.js +35 -0
  274. package/dist/esm/start/platform/connections.d.ts +25 -0
  275. package/dist/esm/start/platform/connections.js +198 -0
  276. package/dist/esm/start/platform/data/baseRunner.d.ts +97 -0
  277. package/dist/esm/start/platform/data/baseRunner.js +117 -0
  278. package/dist/esm/start/platform/data/dispatch.d.ts +17 -0
  279. package/dist/esm/start/platform/data/dispatch.js +216 -0
  280. package/dist/esm/start/platform/data/fetch.d.ts +7 -0
  281. package/dist/esm/start/platform/data/fetch.js +9 -0
  282. package/dist/esm/start/platform/data/index.d.ts +27 -0
  283. package/dist/esm/start/platform/data/index.js +75 -0
  284. package/dist/esm/start/platform/data/names.d.ts +7 -0
  285. package/dist/esm/start/platform/data/names.js +18 -0
  286. package/dist/esm/start/platform/data/sqlNameMappings.d.ts +58 -0
  287. package/dist/esm/start/platform/data/sqlNameMappings.js +92 -0
  288. package/dist/esm/start/platform/data/transformations.d.ts +97 -0
  289. package/dist/esm/start/platform/data/transformations.js +262 -0
  290. package/dist/esm/start/platform/data/types.d.ts +94 -0
  291. package/dist/esm/start/platform/data/types.js +14 -0
  292. package/dist/esm/start/platform/local.d.ts +6 -0
  293. package/dist/esm/start/platform/local.js +18 -0
  294. package/dist/esm/start/platform/meta.d.ts +3 -0
  295. package/dist/esm/start/platform/meta.js +33 -0
  296. package/dist/esm/start/platform/outbound.d.ts +17 -0
  297. package/dist/esm/start/platform/outbound.js +510 -0
  298. package/dist/esm/start/platform/redactSecrets.d.ts +13 -0
  299. package/dist/esm/start/platform/redactSecrets.js +156 -0
  300. package/dist/esm/start/platform/redactSecrets.test.d.ts +1 -0
  301. package/dist/esm/start/platform/redactSecrets.test.js +151 -0
  302. package/dist/esm/start/platform/requestSecrets.d.ts +15 -0
  303. package/dist/esm/start/platform/requestSecrets.js +41 -0
  304. package/dist/esm/start/platform/runLog.d.ts +40 -0
  305. package/dist/esm/start/platform/runLog.js +149 -0
  306. package/dist/esm/start/platform/services.d.ts +7 -0
  307. package/dist/esm/start/platform/services.js +46 -0
  308. package/dist/esm/start/platform/steps.d.ts +9 -0
  309. package/dist/esm/start/platform/steps.js +60 -0
  310. package/dist/esm/start/platform/telemetry.d.ts +13 -0
  311. package/dist/esm/start/platform/telemetry.js +71 -0
  312. package/dist/esm/start/platform/transport.d.ts +28 -0
  313. package/dist/esm/start/platform/transport.js +59 -0
  314. package/dist/esm/start/platformHead.d.ts +23 -0
  315. package/dist/esm/start/platformHead.js +133 -0
  316. package/dist/esm/start/previewClaim.d.ts +6 -0
  317. package/dist/esm/start/previewClaim.js +24 -0
  318. package/dist/esm/start/protocol.d.ts +19 -0
  319. package/dist/esm/start/protocol.js +27 -0
  320. package/dist/esm/start/roles.d.ts +12 -0
  321. package/dist/esm/start/roles.js +27 -0
  322. package/dist/esm/start/router.d.ts +44 -0
  323. package/dist/esm/start/router.js +280 -0
  324. package/dist/esm/start/serve/authHooks.d.ts +7 -0
  325. package/dist/esm/start/serve/authHooks.js +18 -0
  326. package/dist/esm/start/serve/demo.d.ts +9 -0
  327. package/dist/esm/start/serve/demo.js +24 -0
  328. package/dist/esm/start/serve/fetch.d.ts +1 -0
  329. package/dist/esm/start/serve/fetch.js +6 -0
  330. package/dist/esm/start/serve/instance.d.ts +12 -0
  331. package/dist/esm/start/serve/instance.js +134 -0
  332. package/dist/esm/start/serve/invoke.d.ts +13 -0
  333. package/dist/esm/start/serve/invoke.js +126 -0
  334. package/dist/esm/start/serve/local/load.d.ts +8 -0
  335. package/dist/esm/start/serve/local/load.js +44 -0
  336. package/dist/esm/start/serve/local/provider.d.ts +25 -0
  337. package/dist/esm/start/serve/local/provider.js +188 -0
  338. package/dist/esm/start/serve/local/signIn.d.ts +28 -0
  339. package/dist/esm/start/serve/local/signIn.js +123 -0
  340. package/dist/esm/start/serve/pageHead.d.ts +20 -0
  341. package/dist/esm/start/serve/pageHead.js +34 -0
  342. package/dist/esm/start/serve/provider.d.ts +19 -0
  343. package/dist/esm/start/serve/provider.js +78 -0
  344. package/dist/esm/start/serve/requestEnv.d.ts +2 -0
  345. package/dist/esm/start/serve/requestEnv.js +84 -0
  346. package/dist/esm/start/serve/scope.d.ts +18 -0
  347. package/dist/esm/start/serve/scope.js +67 -0
  348. package/dist/esm/start/serve/server.d.ts +56 -0
  349. package/dist/esm/start/serve/server.js +297 -0
  350. package/dist/esm/start/serve/uploads.d.ts +2 -0
  351. package/dist/esm/start/serve/uploads.js +49 -0
  352. package/dist/esm/start/serve/worker.d.ts +6 -0
  353. package/dist/esm/start/serve/worker.js +12 -0
  354. package/dist/esm/start/types.d.ts +373 -0
  355. package/dist/esm/start/types.js +1 -0
  356. package/dist/esm/start/version.d.ts +1 -0
  357. package/dist/esm/start/version.js +2 -0
  358. package/dist/esm/steps/index.d.ts +8 -8
  359. package/dist/esm/steps/index.js +54 -54
  360. package/dist/esm/steps/index.test.js +220 -220
  361. package/dist/esm/sync/index.d.ts +1 -1
  362. package/dist/esm/sync/index.js +32 -31
  363. package/dist/esm/sync/lib.d.ts +15 -8
  364. package/dist/esm/sync/lib.js +655 -669
  365. package/dist/esm/sync/lib.test.js +81 -14
  366. package/dist/esm/sync/sdkNames.d.ts +67 -9
  367. package/dist/esm/sync/sdkNames.js +94 -30
  368. package/dist/esm/sync/sdkNames.test.js +192 -116
  369. package/dist/esm/types/fields.d.ts +1 -1
  370. package/dist/esm/types/fields.js +106 -98
  371. package/dist/esm/types/index.d.ts +2 -2
  372. package/dist/esm/types/index.js +2 -2
  373. package/dist/esm/types/tables.d.ts +1 -1
  374. package/dist/esm/types/tables.js +2 -2
  375. package/dist/esm/upload/index.js +89 -24
  376. package/dist/esm/upload/index.test.js +104 -1
  377. package/dist/esm/vite/domTagNames.js +252 -252
  378. package/dist/esm/vite/index.d.ts +1 -1
  379. package/dist/esm/vite/index.js +56 -47
  380. package/dist/esm/vite/index.test.js +10 -2
  381. package/package.json +129 -16
  382. package/dist/cjs/auth-server/index.d.ts +0 -369
  383. package/dist/cjs/auth-server/index.js +0 -119
  384. package/dist/cjs/meta/index.d.ts +0 -14
  385. package/dist/cjs/meta/index.js +0 -12
  386. package/dist/cjs/notifications/index.d.ts +0 -25
  387. package/dist/cjs/notifications/index.js +0 -12
  388. package/dist/esm/auth-server/index.d.ts +0 -369
  389. package/dist/esm/auth-server/index.js +0 -116
  390. package/dist/esm/meta/index.d.ts +0 -14
  391. package/dist/esm/meta/index.js +0 -8
  392. package/dist/esm/notifications/index.d.ts +0 -25
  393. package/dist/esm/notifications/index.js +0 -8
@@ -0,0 +1,35 @@
1
+ /**
2
+ * What `node-fetch` resolves to in a Start server build: workerd's own fetch. node-fetch's Node transport doesn't survive
3
+ * workerd's `node:http`: v2 throws on a POST and v3 never sees a response header, so it hands back gzip bytes.
4
+ */
5
+ const REDIRECT_STATUSES = new Set([301, 302, 303, 307, 308]);
6
+ // Looked up per call, so zitejs's outbound wrapper sees every request.
7
+ async function nodeFetch(input, init) {
8
+ const res = await globalThis.fetch(input, init);
9
+ // node-fetch 2's body reader, which HubSpot's binary responses call.
10
+ return Object.assign(res, {
11
+ buffer: async () => Buffer.from(await res.arrayBuffer()),
12
+ });
13
+ }
14
+ class FetchError extends Error {
15
+ type;
16
+ code;
17
+ constructor(message, type, systemError) {
18
+ super(message);
19
+ this.name = 'FetchError';
20
+ this.type = type;
21
+ if (systemError?.code)
22
+ this.code = systemError.code;
23
+ }
24
+ }
25
+ class AbortError extends Error {
26
+ type = 'aborted';
27
+ constructor(message) {
28
+ super(message);
29
+ this.name = 'AbortError';
30
+ }
31
+ }
32
+ const isRedirect = (status) => REDIRECT_STATUSES.has(status);
33
+ const { Headers, Request, Response, Blob, FormData } = globalThis;
34
+ export default nodeFetch;
35
+ export { AbortError, Blob, FetchError, FormData, Headers, isRedirect, Request, Response, };
@@ -0,0 +1,34 @@
1
+ /**
2
+ * What `undici` resolves to inside jsforce (3.13 and later) in a Start server build: the parts of its API jsforce uses, on
3
+ * workerd's fetch. undici's own fetch opens TLS sockets with options workerd's `node:tls` doesn't implement.
4
+ */
5
+ export declare const fetch: (input: RequestInfo | URL, init?: RequestInit & {
6
+ dispatcher?: unknown;
7
+ }) => Promise<Response>;
8
+ export declare class Agent {
9
+ constructor(_options?: unknown);
10
+ }
11
+ export declare class ProxyAgent extends Agent {
12
+ }
13
+ declare class SocketError extends Error {
14
+ }
15
+ export declare const errors: {
16
+ SocketError: typeof SocketError;
17
+ };
18
+ export declare const Headers: {
19
+ new (init?: HeadersInit): Headers;
20
+ prototype: Headers;
21
+ }, Request: {
22
+ new (input: RequestInfo | URL, init?: RequestInit): Request;
23
+ prototype: Request;
24
+ }, Response: {
25
+ new (body?: BodyInit | null, init?: ResponseInit): Response;
26
+ prototype: Response;
27
+ error(): Response;
28
+ json(data: any, init?: ResponseInit): Response;
29
+ redirect(url: string | URL, status?: number): Response;
30
+ }, FormData: {
31
+ new (form?: HTMLFormElement, submitter?: HTMLElement | null): FormData;
32
+ prototype: FormData;
33
+ };
34
+ export {};
@@ -0,0 +1,18 @@
1
+ /**
2
+ * What `undici` resolves to inside jsforce (3.13 and later) in a Start server build: the parts of its API jsforce uses, on
3
+ * workerd's fetch. undici's own fetch opens TLS sockets with options workerd's `node:tls` doesn't implement.
4
+ */
5
+ // Looked up per call, so zitejs's outbound wrapper sees every request. Dispatchers are undici's; workerd has none.
6
+ export const fetch = (input, init) => {
7
+ const { dispatcher: _dispatcher, ...rest } = init ?? {};
8
+ return globalThis.fetch(input, rest);
9
+ };
10
+ export class Agent {
11
+ constructor(_options) { }
12
+ }
13
+ export class ProxyAgent extends Agent {
14
+ }
15
+ class SocketError extends Error {
16
+ }
17
+ export const errors = { SocketError };
18
+ export const { Headers, Request, Response, FormData } = globalThis;
@@ -0,0 +1,22 @@
1
+ import { type Plugin } from 'vite';
2
+ type Package = {
3
+ name: string;
4
+ version: string;
5
+ dir: string;
6
+ browser?: Record<string, string | false>;
7
+ };
8
+ /** @internal The installed package a module file belongs to, from its innermost `node_modules`. */
9
+ export declare const packageOf: (file: string) => Package | undefined;
10
+ /** @internal googleapis-common's `apirequest.js` with binary multipart uploads fixed; null when its shape has changed. */
11
+ export declare const patchGoogleMultipart: (code: string) => string | null;
12
+ /** @internal jsforce's `request.js` on fetch bodies; null when its shape has changed. */
13
+ export declare const patchJsforceRequest: (code: string) => string | null;
14
+ /** The SDK patches a Start server build needs in workerd, as classic's prebundle applied them. */
15
+ export declare function sdkPatches(): Plugin;
16
+ /** @internal Where a package's `browser` field sends one of its files: a path, false for an empty module, or none. */
17
+ export declare const awsBrowserTarget: (pkg: Package, file: string) => string | false | undefined;
18
+ /** @internal The package a bare specifier names, scoped or not; null for a relative or absolute one. */
19
+ export declare const packageName: (source: string) => string | null;
20
+ /** @internal pdfkit's browser build with a fixed module URL and the 14 standard fonts registered; null when its shape has changed. */
21
+ export declare const patchPdfkitBrowser: (code: string, fontModules: string[]) => string | null;
22
+ export {};
@@ -0,0 +1,430 @@
1
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
2
+ import path from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { transformWithOxc } from 'vite';
5
+ /**
6
+ * Classic's cloudflare-lambda prebundle (restly `apps/cloudflare-lambda/scripts/prebundle.ts`) fixed its SDKs for workerd
7
+ * inside each SDK's own bundle; Azure Blob, jimp and pdfkit need the same kind of fix. A Start server is one bundle with
8
+ * React, TanStack and the app, so every patch here is scoped to the modules of the package it fixes, or to the imports
9
+ * those modules make. The one exception is `node-fetch`, whose transport is broken in workerd for every caller.
10
+ */
11
+ const SHIMS = path.join(path.dirname(fileURLToPath(import.meta.url)), 'sdk');
12
+ const NODE_FETCH_SHIM = path.join(SHIMS, 'nodeFetch.js');
13
+ const SLACK_AXIOS_SHIM = path.join(SHIMS, 'axios.js');
14
+ const JSFORCE_UNDICI_SHIM = path.join(SHIMS, 'undici.js');
15
+ const EMPTY_MODULE = '\0zite-sdk:empty';
16
+ const PACKAGE_DIR = /[\\/]node_modules[\\/](?:@[^\\/]+[\\/])?[^\\/]+(?=[\\/])/g;
17
+ const packages = new Map();
18
+ /** @internal The installed package a module file belongs to, from its innermost `node_modules`. */
19
+ export const packageOf = (file) => {
20
+ let dir;
21
+ for (const match of file.matchAll(PACKAGE_DIR))
22
+ dir = file.slice(0, match.index + match[0].length);
23
+ if (!dir)
24
+ return undefined;
25
+ if (!packages.has(dir)) {
26
+ try {
27
+ const json = JSON.parse(readFileSync(path.join(dir, 'package.json'), 'utf-8'));
28
+ const browser = typeof json.browser === 'object' && json.browser !== null
29
+ ? json.browser
30
+ : undefined;
31
+ packages.set(dir, {
32
+ name: json.name ?? path.basename(dir),
33
+ version: json.version ?? 'unknown',
34
+ dir,
35
+ browser,
36
+ });
37
+ }
38
+ catch {
39
+ packages.set(dir, null);
40
+ }
41
+ }
42
+ return packages.get(dir) ?? undefined;
43
+ };
44
+ const describePackage = (pkg) => `${pkg.name} ${pkg.version}`;
45
+ const cleanId = (id) => id.split('?')[0];
46
+ // googleapis-common builds a multipart upload by hand. Its browser path, which the `window` rewrite below selects, appends
47
+ // a part only `if (typeof part.body === 'string')`, so every binary media upload lands as a 0-byte file. Its Node path
48
+ // builds a `stream.PassThrough`, which workerd sends as "[object Object]". This rebuilds the body as a Blob (ZIT-5059).
49
+ const MULTIPART_OPEN = ' function browserMultipartUpload(multipart) {';
50
+ const MULTIPART_PATCHED = `function browserMultipartUpload(multipart) {
51
+ const boundary = randomUUID();
52
+ const finale = \`--\${boundary}--\`;
53
+ headers['content-type'] = \`multipart/related; boundary=\${boundary}\`;
54
+ return (async () => {
55
+ const parts = [];
56
+ for (const part of multipart) {
57
+ parts.push(\`--\${boundary}\\r\\ncontent-type: \${part['content-type']}\\r\\n\\r\\n\`);
58
+ parts.push(await __zitePartToBlobPart(part.body));
59
+ parts.push('\\r\\n');
60
+ }
61
+ parts.push(finale);
62
+ options.data = new Blob(parts);
63
+ })();
64
+ }
65
+ async function __zitePartToBlobPart(body) {
66
+ if (typeof body === 'string' || body instanceof Blob) return body;
67
+ if (body instanceof ArrayBuffer || ArrayBuffer.isView(body)) return body;
68
+ if (body && typeof body.getReader === 'function') return new Blob([await new Response(body).arrayBuffer()]);
69
+ if (body && typeof body[Symbol.asyncIterator] === 'function') {
70
+ const chunks = [];
71
+ for await (const chunk of body) chunks.push(typeof chunk === 'string' ? chunk : new Uint8Array(chunk));
72
+ return new Blob(chunks);
73
+ }
74
+ throw new Error(
75
+ 'Unsupported media.body type for a Google multipart upload: ' +
76
+ (body === null || body === undefined ? String(body) : body.constructor?.name || typeof body) +
77
+ '. Pass a string, Buffer, Uint8Array, ArrayBuffer, Blob, or a stream.',
78
+ );
79
+ }`;
80
+ /** @internal googleapis-common's `apirequest.js` with binary multipart uploads fixed; null when its shape has changed. */
81
+ export const patchGoogleMultipart = (code) => {
82
+ const start = code.indexOf(MULTIPART_OPEN);
83
+ // Anchored on the declaration: `multipartUpload` above it has the same string guard.
84
+ const end = start === -1 ? -1 : code.indexOf('\n }\n', start);
85
+ const callSite = 'browserMultipartUpload(multipart);';
86
+ if (end === -1 ||
87
+ !code.slice(start, end).includes("if (typeof part.body === 'string') {") ||
88
+ !code.includes(callSite))
89
+ return null;
90
+ // Now async, and called from inside `async createAPIRequestAsync`.
91
+ return `${code.slice(0, start)} ${MULTIPART_PATCHED}${code.slice(end + '\n }'.length)}`.replace(callSite, `await ${callSite}`);
92
+ };
93
+ // jsforce hands fetch a Node PassThrough as the request body, which workerd's fetch can't read, and pipes the response
94
+ // body into a Node stream, which hangs in workerd or, on a fetch Response, has no `.pipe()` at all.
95
+ const JSFORCE_REQUEST_BODY = /\bbody: input\b/;
96
+ const JSFORCE_RESPONSE_BODY = /readWhatwgReadableStream\(res\.body,\s*output\)|(?:[\w$]+\.)?Readable\.fromWeb\(res\.body\)\.pipe\(output\)|res\.body\.pipe\(output\)/;
97
+ const JSFORCE_READ_TEXT = 'res.text().then(function (t) { output.write(t); output.end(); }).catch(function (e) { output.destroy(e); })';
98
+ /** @internal jsforce's `request.js` on fetch bodies; null when its shape has changed. */
99
+ export const patchJsforceRequest = (code) => JSFORCE_REQUEST_BODY.test(code) && JSFORCE_RESPONSE_BODY.test(code)
100
+ ? code
101
+ .replace(JSFORCE_REQUEST_BODY, 'body: request.body')
102
+ .replace(JSFORCE_RESPONSE_BODY, JSFORCE_READ_TEXT)
103
+ : null;
104
+ const SLACK_REDIRECT_ERROR = /redirect:\s*(["'])error\1/g;
105
+ // By package name rather than path, so an aliased or nested install is patched too.
106
+ const TRANSFORMED = new Set([
107
+ 'googleapis-common',
108
+ 'jsforce',
109
+ 'stripe',
110
+ '@slack/web-api',
111
+ 'pdfkit',
112
+ ]);
113
+ const AWS_PACKAGE = /^@(?:aws-sdk|smithy|aws-crypto)\//;
114
+ const NODE_ENTRY_PACKAGE = /^(?:@azure\/|@typespec\/|@jimp\/|jimp$)/;
115
+ const AWS_PATH = /[\\/]node_modules[\\/]@(?:aws-sdk|smithy|aws-crypto)[\\/]/;
116
+ // What each package must have had patched by the end of a build that loaded it, and what a miss costs.
117
+ const EXPECTED = {
118
+ 'googleapis-common': {
119
+ isBrowser: 'isbrowser.js no longer checks `window`, so uploads take the Node path, which workerd sends as "[object Object]"',
120
+ multipart: 'browserMultipartUpload no longer matches, so binary media uploads send 0 bytes',
121
+ },
122
+ jsforce: {
123
+ request: 'request.js no longer matches, so requests with a body hang and responses fail to read',
124
+ },
125
+ pdfkit: {
126
+ 'browser build': 'its browser build no longer matches, so it throws as it loads or has no standard fonts',
127
+ },
128
+ '@slack/web-api': {
129
+ transport: "it neither imports axios nor sends `redirect: 'error'`, so its transport is unknown to the patch",
130
+ },
131
+ stripe: {
132
+ 'node entry': "its ESM worker entry wasn't reached or has no Node sibling, so webhooks.constructEvent stays async-only",
133
+ },
134
+ };
135
+ /** The SDK patches a Start server build needs in workerd, as classic's prebundle applied them. */
136
+ export function sdkPatches() {
137
+ const seen = new Map();
138
+ const note = (pkg, patch) => {
139
+ const entry = seen.get(pkg.dir) ?? { pkg, done: new Set() };
140
+ if (patch)
141
+ entry.done.add(patch);
142
+ seen.set(pkg.dir, entry);
143
+ };
144
+ const core = {
145
+ name: 'zite:sdk-patches',
146
+ buildStart() {
147
+ seen.clear();
148
+ },
149
+ async resolveId(source, importer, options) {
150
+ if (!importer)
151
+ return undefined;
152
+ const resolveOptions = {
153
+ kind: options.kind,
154
+ isEntry: options.isEntry,
155
+ custom: options.custom,
156
+ skipSelf: true,
157
+ };
158
+ if (source === 'node-fetch')
159
+ return NODE_FETCH_SHIM;
160
+ // Real axios and undici for the app; Slack 7's and jsforce's own imports get shims.
161
+ if (source === 'axios' || source === 'undici') {
162
+ const pkg = packageOf(importer);
163
+ if (source === 'axios' && pkg?.name === '@slack/web-api') {
164
+ note(pkg, 'transport');
165
+ return SLACK_AXIOS_SHIM;
166
+ }
167
+ return source === 'undici' && pkg?.name === 'jsforce'
168
+ ? JSFORCE_UNDICI_SHIM
169
+ : undefined;
170
+ }
171
+ // These pick their build through a `browser` export condition, which Cloudflare's conditions select: Azure's touches
172
+ // `document` as it loads, and jimp's is an empty stub. Their Node `import` entries run in workerd.
173
+ const name = packageName(source);
174
+ if (name && NODE_ENTRY_PACKAGE.test(name)) {
175
+ const resolved = await this.resolve(source, importer, resolveOptions);
176
+ const pkg = resolved && !resolved.external
177
+ ? packageOf(cleanId(resolved.id))
178
+ : undefined;
179
+ if (!resolved || !pkg || pkg.name !== name)
180
+ return resolved;
181
+ const subpath = `.${source.slice(name.length)}`;
182
+ const target = nodeImportEntry(pkg, subpath);
183
+ if (!target && subpath === '.')
184
+ this.warn(`[zite] ${describePackage(pkg)}: no Node \`import\` entry in its exports, so it keeps its browser build`);
185
+ return target ?? resolved;
186
+ }
187
+ // The AWS SDK swaps its Node wiring for fetch and WebCrypto through the package.json `browser` field, which a server
188
+ // build doesn't read. Without it a client loads its Node runtime config against @aws-sdk/core's browser entry and
189
+ // throws as it's constructed.
190
+ if (AWS_PATH.test(importer) || AWS_PACKAGE.test(source)) {
191
+ const resolved = await this.resolve(source, importer, resolveOptions);
192
+ if (!resolved || resolved.external)
193
+ return resolved;
194
+ const file = cleanId(resolved.id);
195
+ const pkg = packageOf(file);
196
+ if (!pkg || !AWS_PACKAGE.test(pkg.name))
197
+ return resolved;
198
+ const target = awsBrowserTarget(pkg, file);
199
+ if (target === false)
200
+ return EMPTY_MODULE;
201
+ if (target)
202
+ return ((await this.resolve(target, importer, resolveOptions)) ?? resolved);
203
+ if (/^@aws-sdk\/client-/.test(pkg.name) &&
204
+ /[\\/]runtimeConfig\.js$/.test(file)) {
205
+ this.warn(`[zite] ${describePackage(pkg)}: no browser runtime config, so the client loads its Node one and fails in workerd`);
206
+ }
207
+ return resolved;
208
+ }
209
+ return undefined;
210
+ },
211
+ load(id) {
212
+ return id === EMPTY_MODULE ? 'module.exports = {};\n' : undefined;
213
+ },
214
+ async transform(code, id) {
215
+ const file = cleanId(id);
216
+ const pkg = packageOf(file);
217
+ if (!pkg || !TRANSFORMED.has(pkg.name))
218
+ return undefined;
219
+ note(pkg);
220
+ let out = code;
221
+ // Stripe's worker entry pairs fetch with WebCrypto, which can't verify a webhook synchronously, so
222
+ // `webhooks.constructEvent` throws. Classic ran its Node entry with the fetch client as the default.
223
+ if (pkg.name === 'stripe') {
224
+ const entries = stripeEntries(pkg);
225
+ if (entries && file === entries.worker) {
226
+ note(pkg, 'node entry');
227
+ return {
228
+ code: stripeWrapper(entries.worker, entries.node),
229
+ map: null,
230
+ };
231
+ }
232
+ return undefined;
233
+ }
234
+ // Cloudflare's conditions give pdfkit's browser build, which reads `import.meta.url` as it loads (undefined in workerd)
235
+ // and, unlike its Node build, has no standard fonts until the app registers them.
236
+ if (pkg.name === 'pdfkit') {
237
+ if (!/[\\/]pdfkit\.browser\.mjs$/.test(file))
238
+ return undefined;
239
+ const patched = patchPdfkitBrowser(code, standardFontModules(file));
240
+ if (!patched)
241
+ return undefined;
242
+ note(pkg, 'browser build');
243
+ return { code: patched, map: null };
244
+ }
245
+ // Slack 8 calls fetch with `redirect: 'error'`, which workerd refuses outright. Slack throws on any status but 200, so
246
+ // a redirect still fails the call.
247
+ if (pkg.name === '@slack/web-api') {
248
+ const patched = code.replace(SLACK_REDIRECT_ERROR, "redirect: 'manual'");
249
+ if (patched === code)
250
+ return undefined;
251
+ note(pkg, 'transport');
252
+ return { code: patched, map: null };
253
+ }
254
+ if (pkg.name === 'googleapis-common' &&
255
+ /[\\/]apirequest\.js$/.test(file)) {
256
+ const patched = patchGoogleMultipart(out);
257
+ if (patched) {
258
+ out = patched;
259
+ note(pkg, 'multipart');
260
+ }
261
+ }
262
+ if (pkg.name === 'jsforce' &&
263
+ /[\\/]request\.js$/.test(file) &&
264
+ !/[\\/]browser[\\/]browser[\\/]/.test(file)) {
265
+ const patched = patchJsforceRequest(out);
266
+ if (patched) {
267
+ out = patched;
268
+ note(pkg, 'request');
269
+ }
270
+ }
271
+ // googleapis-common picks its multipart path by testing `window`. Classic defined `window` as `globalThis` for its
272
+ // whole googleapis bundle; here only this package's modules see it.
273
+ if (pkg.name === 'googleapis-common' && /\bwindow\b/.test(out)) {
274
+ if (/[\\/]isbrowser\.js$/.test(file) && /typeof window/.test(out))
275
+ note(pkg, 'isBrowser');
276
+ const result = await transformWithOxc(out, file, {
277
+ lang: 'js',
278
+ sourceType: 'unambiguous',
279
+ define: { window: 'globalThis' },
280
+ sourcemap: true,
281
+ });
282
+ return { code: result.code, map: result.map };
283
+ }
284
+ return out === code ? undefined : { code: out, map: null };
285
+ },
286
+ buildEnd() {
287
+ for (const { pkg, done } of seen.values()) {
288
+ for (const [patch, consequence] of Object.entries(EXPECTED[pkg.name] ?? {})) {
289
+ if (!done.has(patch))
290
+ this.warn(`[zite] ${describePackage(pkg)} is unpatched for workerd: ${consequence}`);
291
+ }
292
+ }
293
+ },
294
+ };
295
+ return {
296
+ ...core,
297
+ enforce: 'pre',
298
+ // Server code only: browsers run these SDKs as published.
299
+ applyToEnvironment: environment => environment.config.consumer === 'server',
300
+ // `vite dev` pre-bundles dependencies apart from the plugin pipeline, so the same hooks join that build.
301
+ configEnvironment: (name, _config, { command }) => name === 'ssr' && command === 'serve'
302
+ ? { optimizeDeps: { rolldownOptions: { plugins: [core] } } }
303
+ : undefined,
304
+ };
305
+ }
306
+ // The ESM entries the workerd and Node conditions pick, from Stripe's own exports.
307
+ const stripeEntryCache = new Map();
308
+ const stripeEntries = (pkg) => {
309
+ if (!stripeEntryCache.has(pkg.dir))
310
+ stripeEntryCache.set(pkg.dir, readStripeEntries(pkg));
311
+ return stripeEntryCache.get(pkg.dir) ?? null;
312
+ };
313
+ const readStripeEntries = (pkg) => {
314
+ try {
315
+ const { exports } = JSON.parse(readFileSync(path.join(pkg.dir, 'package.json'), 'utf-8'));
316
+ const worker = importTarget(exports?.workerd);
317
+ const node = importTarget(exports?.default);
318
+ return worker && node && existsSync(path.join(pkg.dir, node))
319
+ ? { worker: path.join(pkg.dir, worker), node: path.join(pkg.dir, node) }
320
+ : null;
321
+ }
322
+ catch {
323
+ return null;
324
+ }
325
+ };
326
+ // An exports condition's ESM file, whether it's `{ import: file }` or `{ import: { types, default: file } }`.
327
+ const importTarget = (condition) => {
328
+ if (typeof condition === 'string')
329
+ return condition;
330
+ if (typeof condition !== 'object' || condition === null)
331
+ return undefined;
332
+ const branches = condition;
333
+ return importTarget(branches.import ?? branches.default);
334
+ };
335
+ // Classic's `stripeFetchWrapper`, in place of the worker entry: the Node entry, so the synchronous webhook verifier keeps
336
+ // node:crypto, with the fetch client as the default, because the Node client waits on a socket event workerd never sends.
337
+ const stripeWrapper = (workerEntry, nodeEntry) => {
338
+ const relative = path
339
+ .relative(path.dirname(workerEntry), nodeEntry)
340
+ .split(path.sep)
341
+ .join('/');
342
+ return `import StripeNode from ${JSON.stringify(relative.startsWith('.') ? relative : `./${relative}`)};
343
+ function Stripe(key, config) {
344
+ // stripe-node still takes a bare API version string as its config.
345
+ const options = typeof config === "string" ? { apiVersion: config } : config ?? {};
346
+ return new StripeNode(key, { httpClient: StripeNode.createFetchHttpClient(), ...options });
347
+ }
348
+ Object.setPrototypeOf(Stripe, StripeNode);
349
+ Stripe.prototype = StripeNode.prototype;
350
+ Stripe.Stripe = Stripe;
351
+ Stripe.default = Stripe;
352
+ export { Stripe };
353
+ export default Stripe;
354
+ `;
355
+ };
356
+ /** @internal Where a package's `browser` field sends one of its files: a path, false for an empty module, or none. */
357
+ export const awsBrowserTarget = (pkg, file) => {
358
+ const rel = `./${path.relative(pkg.dir, file).split(path.sep).join('/')}`;
359
+ // xml-builder's browser parser is built on DOMParser, which workerd lacks; its default parser is plain JS.
360
+ if (pkg.name === '@aws-sdk/xml-builder') {
361
+ const plain = file.replace(/xml-parser\.browser\.js$/, 'xml-parser.js');
362
+ return plain !== file && existsSync(plain) ? plain : undefined;
363
+ }
364
+ for (const [key, value] of Object.entries(pkg.browser ?? {})) {
365
+ if (!key.startsWith('./'))
366
+ continue;
367
+ if (key === rel || `${key}.js` === rel || `${key}/index.js` === rel)
368
+ return value === false ? false : path.join(pkg.dir, value);
369
+ }
370
+ return undefined;
371
+ };
372
+ /** @internal The package a bare specifier names, scoped or not; null for a relative or absolute one. */
373
+ export const packageName = (source) => {
374
+ if (source.startsWith('.') ||
375
+ source.startsWith('/') ||
376
+ source.startsWith('\0') ||
377
+ source.includes(':'))
378
+ return null;
379
+ const parts = source.split('/');
380
+ return source.startsWith('@')
381
+ ? parts.length > 1
382
+ ? parts.slice(0, 2).join('/')
383
+ : null
384
+ : parts[0];
385
+ };
386
+ // A package's own exports for one subpath, with its `browser` and `react-native` conditions passed over.
387
+ const nodeImportEntry = (pkg, subpath) => {
388
+ try {
389
+ const { exports } = JSON.parse(readFileSync(path.join(pkg.dir, 'package.json'), 'utf-8'));
390
+ const entry = typeof exports === 'object' && exports !== null && '.' in exports
391
+ ? exports[subpath]
392
+ : subpath === '.'
393
+ ? exports
394
+ : undefined;
395
+ const target = importTarget(entry);
396
+ return target && existsSync(path.join(pkg.dir, target))
397
+ ? path.join(pkg.dir, target)
398
+ : undefined;
399
+ }
400
+ catch {
401
+ return undefined;
402
+ }
403
+ };
404
+ const standardFontModules = (browserBuild) => {
405
+ try {
406
+ return readdirSync(path.join(path.dirname(browserBuild), 'standard-fonts')).filter(file => file.endsWith('.mjs'));
407
+ }
408
+ catch {
409
+ return [];
410
+ }
411
+ };
412
+ /** @internal pdfkit's browser build with a fixed module URL and the 14 standard fonts registered; null when its shape has changed. */
413
+ export const patchPdfkitBrowser = (code, fontModules) => {
414
+ if (!code.includes('import.meta.url') ||
415
+ !/\bregisterStdFonts\b/.test(code) ||
416
+ fontModules.length === 0)
417
+ return null;
418
+ // Only a key for its in-memory files, so any URL that parses will do.
419
+ const located = code.replaceAll('import.meta.url', JSON.stringify('file:///bundle/node_modules/pdfkit/js/pdfkit.browser.mjs'));
420
+ const fonts = fontModules.map((file, i) => ({
421
+ name: `__ziteStdFont${i}`,
422
+ file,
423
+ }));
424
+ return [
425
+ ...fonts.map(({ name, file }) => `import ${name} from ${JSON.stringify(`./standard-fonts/${file}`)};`),
426
+ located,
427
+ `registerStdFonts(${fonts.map(({ name }) => name).join(', ')});`,
428
+ '',
429
+ ].join('\n');
430
+ };
@@ -0,0 +1,26 @@
1
+ import { z } from 'zod';
2
+ import type { SiteHead, WebManifest } from '../types.js';
3
+ declare const settings: z.ZodObject<{
4
+ seoSettings: z.ZodCatch<z.ZodOptional<z.ZodObject<{
5
+ title: z.ZodCatch<z.ZodOptional<z.ZodString>>;
6
+ description: z.ZodCatch<z.ZodOptional<z.ZodString>>;
7
+ thumbnailUrl: z.ZodCatch<z.ZodOptional<z.ZodString>>;
8
+ faviconUrl: z.ZodCatch<z.ZodOptional<z.ZodString>>;
9
+ }, z.core.$strip>>>;
10
+ pwaSettings: z.ZodCatch<z.ZodOptional<z.ZodObject<{
11
+ enabled: z.ZodCatch<z.ZodOptional<z.ZodBoolean>>;
12
+ title: z.ZodCatch<z.ZodOptional<z.ZodString>>;
13
+ backgroundColor: z.ZodCatch<z.ZodOptional<z.ZodString>>;
14
+ icons: z.ZodCatch<z.ZodOptional<z.ZodObject<{
15
+ icon192Url: z.ZodCatch<z.ZodOptional<z.ZodString>>;
16
+ icon512Url: z.ZodCatch<z.ZodOptional<z.ZodString>>;
17
+ appleTouchIconUrl: z.ZodCatch<z.ZodOptional<z.ZodString>>;
18
+ }, z.core.$strip>>>;
19
+ }, z.core.$strip>>>;
20
+ }, z.core.$strip>;
21
+ type PwaSettings = NonNullable<z.infer<typeof settings>['pwaSettings']>;
22
+ /** An installable app's manifest: one whose settings name all three icons and that isn't switched off. */
23
+ export declare const webManifestOf: (pwa: PwaSettings | undefined, title: string | undefined) => WebManifest | undefined;
24
+ /** What an app's zite.config.json sets of its pages' heads; nothing it leaves out. */
25
+ export declare const siteHeadOf: (config: unknown) => SiteHead;
26
+ export {};
@@ -0,0 +1,88 @@
1
+ // The app's Settings off Zite, baked into the server build from its zite.config.json: what the platform sends each
2
+ // request on Zite (restly's startPagePlan and createZiteWebManifest), less the fallbacks only it knows, the app's name,
3
+ // screenshot and brand kit. Keep the two in step.
4
+ import { z } from 'zod';
5
+ const DEFAULT_PWA_BACKGROUND_COLOR = '#ffffff';
6
+ const HEX_COLOR = /^#[0-9A-Fa-f]{6}$/;
7
+ const MAX_SHORT_NAME_LENGTH = 12;
8
+ const text = z.string().optional().catch(undefined);
9
+ const settings = z.object({
10
+ seoSettings: z
11
+ .object({
12
+ title: text,
13
+ description: text,
14
+ thumbnailUrl: text,
15
+ faviconUrl: text,
16
+ })
17
+ .optional()
18
+ .catch(undefined),
19
+ pwaSettings: z
20
+ .object({
21
+ enabled: z.boolean().optional().catch(undefined),
22
+ title: text,
23
+ backgroundColor: text,
24
+ icons: z
25
+ .object({ icon192Url: text, icon512Url: text, appleTouchIconUrl: text })
26
+ .optional()
27
+ .catch(undefined),
28
+ })
29
+ .optional()
30
+ .catch(undefined),
31
+ });
32
+ /** An installable app's manifest: one whose settings name all three icons and that isn't switched off. */
33
+ export const webManifestOf = (pwa, title) => {
34
+ const icons = pwa?.icons;
35
+ if (!pwa ||
36
+ pwa.enabled === false ||
37
+ !icons?.icon192Url ||
38
+ !icons.icon512Url ||
39
+ !icons.appleTouchIconUrl)
40
+ return undefined;
41
+ const name = pwa.title?.trim() || title?.trim() || 'Zite App';
42
+ const background = pwa.backgroundColor && HEX_COLOR.test(pwa.backgroundColor)
43
+ ? pwa.backgroundColor
44
+ : DEFAULT_PWA_BACKGROUND_COLOR;
45
+ return {
46
+ name,
47
+ short_name: name.length <= MAX_SHORT_NAME_LENGTH
48
+ ? name
49
+ : name.slice(0, MAX_SHORT_NAME_LENGTH).trim(),
50
+ start_url: '/',
51
+ scope: '/',
52
+ display: 'standalone',
53
+ background_color: background,
54
+ theme_color: background,
55
+ icons: [
56
+ {
57
+ src: icons.icon192Url,
58
+ sizes: '192x192',
59
+ type: 'image/png',
60
+ purpose: 'any',
61
+ },
62
+ {
63
+ src: icons.icon512Url,
64
+ sizes: '512x512',
65
+ type: 'image/png',
66
+ purpose: 'any',
67
+ },
68
+ ],
69
+ };
70
+ };
71
+ /** What an app's zite.config.json sets of its pages' heads; nothing it leaves out. */
72
+ export const siteHeadOf = (config) => {
73
+ const parsed = settings.safeParse(config);
74
+ const { seoSettings: seo, pwaSettings: pwa } = parsed.success
75
+ ? parsed.data
76
+ : {};
77
+ const manifest = webManifestOf(pwa, seo?.title);
78
+ return {
79
+ ...(seo?.title && { title: seo.title }),
80
+ ...(seo?.description && { description: seo.description }),
81
+ ...(seo?.thumbnailUrl && { image: seo.thumbnailUrl }),
82
+ ...(seo?.faviconUrl && { icon: seo.faviconUrl }),
83
+ ...(manifest && {
84
+ manifest,
85
+ appleTouchIcon: pwa?.icons?.appleTouchIconUrl,
86
+ }),
87
+ };
88
+ };