@trypattern/sdk 0.1.2 → 0.1.3

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.
@@ -1,5 +1,5 @@
1
1
  import { spawnSync } from 'node:child_process';
2
- import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
2
+ import { chmodSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
3
3
  import { homedir, hostname, userInfo } from 'node:os';
4
4
  import { basename, dirname, extname, join, matchesGlob, relative } from 'node:path';
5
5
  import { z } from 'zod';
@@ -14,6 +14,9 @@ const POLL_MS = 2000;
14
14
  const LOGIN_WAIT_MS = 120_000;
15
15
  const PUBLISH_WAIT_MS = 300_000;
16
16
  const SESSION_COOKIE = 'pattern_session';
17
+ const LAUNCHER = 'app';
18
+ const STARTER_WORKSPACE = 'pnpm-workspace.yaml';
19
+ const STARTER_BUILD_SETTINGS = 'allowBuilds:\n esbuild: false\n workerd: false\n';
17
20
  const IGNORED_IN_EMPTY_FOLDER = new Set(['.DS_Store', '.claude']);
18
21
  const MIME_TYPES = {
19
22
  '.html': 'text/html',
@@ -278,6 +281,8 @@ export async function pull(io, name, cwd) {
278
281
  writeFileSync(destination, Buffer.from(await value.arrayBuffer()));
279
282
  files += 1;
280
283
  }
284
+ if (existsSync(join(target, LAUNCHER)))
285
+ chmodSync(join(target, LAUNCHER), 0o755);
281
286
  writeFileSync(join(target, PROJECT_FILE), `${JSON.stringify({ name, title: result.title }, null, 2)}\n`);
282
287
  io.say(`✓ Downloaded ${files} files of version ${result.number}`);
283
288
  const install = await io.run('pnpm', ['install'], target);
@@ -377,6 +382,9 @@ function uploadForm(root, io, isStarter) {
377
382
  form.append(`${UPLOAD.migrations}${file}`, fileBlob(join(migrations, file)), file);
378
383
  }
379
384
  const sources = sourceFiles(root);
385
+ if (isStarter && !sources.includes(STARTER_WORKSPACE)) {
386
+ form.append(`${UPLOAD.source}${STARTER_WORKSPACE}`, new Blob([STARTER_BUILD_SETTINGS], { type: 'text/yaml' }), STARTER_WORKSPACE);
387
+ }
380
388
  for (const path of sources) {
381
389
  const full = join(root, path);
382
390
  const contents = isStarter && path === 'package.json'
package/dist/vite/vite.js CHANGED
@@ -11,6 +11,35 @@ import { localWorker } from "./localWorker.js";
11
11
  import { readProjectFile } from "./projectFile.js";
12
12
  import { rootAlias } from "./rootAlias.js";
13
13
  const DEV_SERVER_PORT = 5173;
14
+ const BROWSER_DEPENDENCIES = [
15
+ 'react',
16
+ 'react/jsx-runtime',
17
+ 'react/jsx-dev-runtime',
18
+ 'react-dom',
19
+ 'react-dom/client',
20
+ 'react-router',
21
+ 'react-router/dom',
22
+ 'zod',
23
+ '@stylexjs/stylex',
24
+ ...[
25
+ 'avatar',
26
+ 'button',
27
+ 'context-menu',
28
+ 'dialog',
29
+ 'field',
30
+ 'menu',
31
+ 'radio-group',
32
+ 'radio',
33
+ 'select',
34
+ 'separator',
35
+ 'switch',
36
+ 'tooltip'
37
+ ].map((part) => `@base-ui/react/${part}`)
38
+ ];
39
+ const sdkCompiledByStyleXButItsDependenciesPrebundled = {
40
+ exclude: ['@trypattern/sdk'],
41
+ include: BROWSER_DEPENDENCIES.map((dependency) => `@trypattern/sdk > ${dependency}`)
42
+ };
14
43
  const VISUAL_FLOW_TIMEOUT_MS = 30_000;
15
44
  const CSS_LAYERS_BEFORE_STYLEX = ['reset'];
16
45
  const browsersWithNativeLightDark = {
@@ -58,7 +87,7 @@ export function pattern({ tables, admins, seed = {}, world = {} }) {
58
87
  designFile()
59
88
  ],
60
89
  clearScreen: false,
61
- optimizeDeps: { exclude: ['@trypattern/sdk'] },
90
+ optimizeDeps: sdkCompiledByStyleXButItsDependenciesPrebundled,
62
91
  build: {
63
92
  cssTarget: ['chrome123', 'firefox120', 'safari17.5']
64
93
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trypattern/sdk",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",