one 1.2.62 → 1.2.63

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "one",
3
- "version": "1.2.62",
3
+ "version": "1.2.63",
4
4
  "license": "BSD-3-Clause",
5
5
  "sideEffects": [
6
6
  "setup.mjs",
@@ -139,17 +139,17 @@
139
139
  "@react-navigation/routers": "~7.5.1",
140
140
  "@swc/core": "^1.14.0",
141
141
  "@ungap/structured-clone": "^1.2.0",
142
- "@vxrn/color-scheme": "1.2.62",
143
- "@vxrn/compiler": "1.2.62",
144
- "@vxrn/resolve": "1.2.62",
145
- "@vxrn/tslib-lite": "1.2.62",
146
- "@vxrn/use-isomorphic-layout-effect": "1.2.62",
147
- "@vxrn/vite-plugin-metro": "1.2.62",
142
+ "@vxrn/color-scheme": "1.2.63",
143
+ "@vxrn/compiler": "1.2.63",
144
+ "@vxrn/resolve": "1.2.63",
145
+ "@vxrn/tslib-lite": "1.2.63",
146
+ "@vxrn/use-isomorphic-layout-effect": "1.2.63",
147
+ "@vxrn/vite-plugin-metro": "1.2.63",
148
148
  "babel-dead-code-elimination": "1.0.10",
149
149
  "babel-plugin-module-resolver": "^5.0.2",
150
150
  "citty": "^0.1.6",
151
151
  "core-js": "^3.38.1",
152
- "create-vxrn": "1.2.62",
152
+ "create-vxrn": "1.2.63",
153
153
  "escape-string-regexp": "^5.0.0",
154
154
  "expo-linking": "~8.0.8",
155
155
  "expo-modules-core": "~3.0.24",
@@ -177,7 +177,7 @@
177
177
  "vite": "7.1.12",
178
178
  "vite-plugin-barrel": "^0.4.1",
179
179
  "vite-tsconfig-paths": "^5.1.4",
180
- "vxrn": "1.2.62",
180
+ "vxrn": "1.2.63",
181
181
  "ws": "^8.18.0",
182
182
  "xxhashjs": "^0.2.2"
183
183
  },
package/src/vite/one.ts CHANGED
@@ -2,9 +2,10 @@ import events from 'node:events'
2
2
  import path from 'node:path'
3
3
  import { configureVXRNCompilerPlugin } from '@vxrn/compiler'
4
4
  import { resolvePath } from '@vxrn/resolve'
5
- import type {
6
- ExpoManifestRequestHandlerPluginPluginOptions,
7
- MetroPluginOptions,
5
+ import {
6
+ type ExpoManifestRequestHandlerPluginPluginOptions,
7
+ type MetroPluginOptions,
8
+ getPlatformEnvDefine,
8
9
  } from '@vxrn/vite-plugin-metro'
9
10
  import type { Plugin, PluginOption } from 'vite'
10
11
  import { barrel } from 'vite-plugin-barrel'
@@ -302,17 +303,55 @@ export function one(options: One.PluginOptions = {}): PluginOption {
302
303
  name: 'one:init-config',
303
304
 
304
305
  config() {
306
+ const setupFileDefines = (() => {
307
+ if (!options.setupFile) return {}
308
+
309
+ let setupFiles: {
310
+ client?: string
311
+ server?: string
312
+ ios?: string
313
+ android?: string
314
+ }
315
+
316
+ if (typeof options.setupFile === 'string') {
317
+ setupFiles = {
318
+ client: options.setupFile,
319
+ server: options.setupFile,
320
+ ios: options.setupFile,
321
+ android: options.setupFile,
322
+ }
323
+ } else if ('native' in options.setupFile) {
324
+ setupFiles = {
325
+ client: options.setupFile.client,
326
+ server: options.setupFile.server,
327
+ ios: options.setupFile.native,
328
+ android: options.setupFile.native,
329
+ }
330
+ } else {
331
+ setupFiles = options.setupFile
332
+ }
333
+
334
+ return {
335
+ ...(setupFiles.client && {
336
+ 'process.env.ONE_SETUP_FILE_CLIENT': JSON.stringify(setupFiles.client),
337
+ }),
338
+ ...(setupFiles.server && {
339
+ 'process.env.ONE_SETUP_FILE_SERVER': JSON.stringify(setupFiles.server),
340
+ }),
341
+ ...(setupFiles.ios && {
342
+ 'process.env.ONE_SETUP_FILE_IOS': JSON.stringify(setupFiles.ios),
343
+ }),
344
+ ...(setupFiles.android && {
345
+ 'process.env.ONE_SETUP_FILE_ANDROID': JSON.stringify(setupFiles.android),
346
+ }),
347
+ }
348
+ })()
349
+
305
350
  return {
351
+ // Platform env defined at root level for client (workaround for Vite bug with environment.client.define)
306
352
  define: {
307
- // we define this not in environment.client because there must be a bug in vite
308
- // it doesnt define the import.meta.env at all if you do that
309
- 'process.env.TAMAGUI_ENVIRONMENT': '"client"',
310
- 'process.env.VITE_ENVIRONMENT': '"client"',
311
- 'import.meta.env.VITE_ENVIRONMENT': '"client"',
312
- 'process.env.VITE_PLATFORM': '"web"',
313
- 'import.meta.env.VITE_PLATFORM': '"web"',
314
- 'process.env.EXPO_OS': '"web"',
315
- 'import.meta.env.EXPO_OS': '"web"',
353
+ ...getPlatformEnvDefine('client'),
354
+ ...setupFileDefines,
316
355
 
317
356
  ...(options.web?.defaultRenderMode && {
318
357
  'process.env.ONE_DEFAULT_RENDER_MODE': JSON.stringify(
@@ -323,53 +362,6 @@ export function one(options: One.PluginOptions = {}): PluginOption {
323
362
  ),
324
363
  }),
325
364
 
326
- ...(() => {
327
- if (!options.setupFile) return {}
328
-
329
- // normalize setupFile to object format
330
- let setupFiles: {
331
- client?: string
332
- server?: string
333
- ios?: string
334
- android?: string
335
- }
336
-
337
- if (typeof options.setupFile === 'string') {
338
- setupFiles = {
339
- client: options.setupFile,
340
- server: options.setupFile,
341
- ios: options.setupFile,
342
- android: options.setupFile,
343
- }
344
- } else if ('native' in options.setupFile) {
345
- setupFiles = {
346
- client: options.setupFile.client,
347
- server: options.setupFile.server,
348
- ios: options.setupFile.native,
349
- android: options.setupFile.native,
350
- }
351
- } else {
352
- setupFiles = options.setupFile
353
- }
354
-
355
- return {
356
- ...(setupFiles.client && {
357
- 'process.env.ONE_SETUP_FILE_CLIENT': JSON.stringify(setupFiles.client),
358
- }),
359
- ...(setupFiles.server && {
360
- 'process.env.ONE_SETUP_FILE_SERVER': JSON.stringify(setupFiles.server),
361
- }),
362
- ...(setupFiles.ios && {
363
- 'process.env.ONE_SETUP_FILE_IOS': JSON.stringify(setupFiles.ios),
364
- }),
365
- ...(setupFiles.android && {
366
- 'process.env.ONE_SETUP_FILE_ANDROID': JSON.stringify(
367
- setupFiles.android
368
- ),
369
- }),
370
- }
371
- })(),
372
-
373
365
  ...(process.env.NODE_ENV !== 'production' &&
374
366
  vxrnOptions && {
375
367
  'process.env.ONE_SERVER_URL': JSON.stringify(vxrnOptions.server.url),
@@ -378,47 +370,14 @@ export function one(options: One.PluginOptions = {}): PluginOption {
378
370
  },
379
371
 
380
372
  environments: {
381
- // we define client vars not in environment.client because there must be a bug in vite
382
- // it doesnt define the import.meta.env at all if you do that
383
- // client: {
384
- // define: {
385
- // },
386
- // },
387
-
388
373
  ssr: {
389
- define: {
390
- 'process.env.TAMAGUI_ENVIRONMENT': '"ssr"',
391
- 'process.env.VITE_ENVIRONMENT': '"ssr"', // Note that we are also setting `process.env.VITE_ENVIRONMENT = 'ssr'` for this current process. See `setServerGlobals()` and `setupServerGlobals.ts`.
392
- 'import.meta.env.VITE_ENVIRONMENT': '"ssr"',
393
- 'process.env.VITE_PLATFORM': '"web"',
394
- 'import.meta.env.VITE_PLATFORM': '"web"',
395
- 'process.env.EXPO_OS': '"web"',
396
- 'import.meta.env.EXPO_OS': '"web"',
397
- },
374
+ define: getPlatformEnvDefine('ssr'),
398
375
  },
399
-
400
376
  ios: {
401
- define: {
402
- 'process.env.TAMAGUI_ENVIRONMENT': '"ios"',
403
- 'process.env.VITE_ENVIRONMENT': '"ios"',
404
- 'import.meta.env.VITE_ENVIRONMENT': '"ios"',
405
- 'process.env.VITE_PLATFORM': '"native"',
406
- 'import.meta.env.VITE_PLATFORM': '"native"',
407
- 'process.env.EXPO_OS': '"ios"',
408
- 'import.meta.env.EXPO_OS': '"ios"',
409
- },
377
+ define: getPlatformEnvDefine('ios'),
410
378
  },
411
-
412
379
  android: {
413
- define: {
414
- 'process.env.TAMAGUI_ENVIRONMENT': '"android"',
415
- 'process.env.VITE_ENVIRONMENT': '"android"',
416
- 'import.meta.env.VITE_ENVIRONMENT': '"android"',
417
- 'process.env.VITE_PLATFORM': '"native"',
418
- 'import.meta.env.VITE_PLATFORM': '"native"',
419
- 'process.env.EXPO_OS': '"android"',
420
- 'import.meta.env.EXPO_OS': '"android"',
421
- },
380
+ define: getPlatformEnvDefine('android'),
422
381
  },
423
382
  },
424
383
  }
@@ -1 +1 @@
1
- {"version":3,"file":"one.d.ts","sourceRoot":"","sources":["../../src/vite/one.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAU,YAAY,EAAE,MAAM,MAAM,CAAA;AAOhD,OAAO,qBAAqB,CAAA;AAa5B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAoBlC,wBAAgB,GAAG,CAAC,OAAO,GAAE,GAAG,CAAC,aAAkB,GAAG,YAAY,CAsoBjE"}
1
+ {"version":3,"file":"one.d.ts","sourceRoot":"","sources":["../../src/vite/one.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAU,YAAY,EAAE,MAAM,MAAM,CAAA;AAOhD,OAAO,qBAAqB,CAAA;AAa5B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAoBlC,wBAAgB,GAAG,CAAC,OAAO,GAAE,GAAG,CAAC,aAAkB,GAAG,YAAY,CA4lBjE"}