@tamagui/static-sync 1.136.7

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/dist/index.cjs ADDED
@@ -0,0 +1,101 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
11
+ for (let key of __getOwnPropNames(from))
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ return to;
14
+ };
15
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
+ // If the importer is in node compatibility mode or this is not an ESM
17
+ // file that has been converted to a CommonJS file using a Babel-
18
+ // compatible transform (i.e. "__esModule" has not been set), then set
19
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
+ mod
22
+ )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
+
24
+ // src/index.ts
25
+ var index_exports = {};
26
+ __export(index_exports, {
27
+ extractToClassNamesSync: () => extractToClassNamesSync,
28
+ extractToNativeSync: () => extractToNativeSync,
29
+ getBabelPlugin: () => getBabelPlugin,
30
+ getPragmaOptions: () => getPragmaOptions,
31
+ loadTamaguiBuildConfigSync: () => loadTamaguiBuildConfigSync
32
+ });
33
+ module.exports = __toCommonJS(index_exports);
34
+ var import_synckit = require("synckit"), import_node_url = require("node:url"), import_meta = {}, getWorkerPath = () => typeof import_meta < "u" && import_meta.url ? (0, import_node_url.fileURLToPath)(import_meta.resolve("@tamagui/static/worker")).replace(/\.mjs$/, ".js") : require.resolve("@tamagui/static/worker").replace(/\.mjs$/, ".js"), runTaskSync = (0, import_synckit.createSyncFn)(getWorkerPath(), {
35
+ timeout: 6e4
36
+ // 60s timeout for sync operations
37
+ }), getPragmaOptions = (props) => {
38
+ let { default: Static } = require("@tamagui/static");
39
+ return Static.getPragmaOptions(props);
40
+ };
41
+ function loadTamaguiBuildConfigSync(tamaguiOptions) {
42
+ let { default: Static } = require("@tamagui/static");
43
+ return Static.loadTamaguiBuildConfigSync(tamaguiOptions);
44
+ }
45
+ function extractToClassNamesSync(params) {
46
+ let { source, sourcePath = "", options, shouldPrintDebug = !1 } = params;
47
+ if (typeof source != "string")
48
+ throw new Error("`source` must be a string of javascript");
49
+ let result = runTaskSync({
50
+ type: "extractToClassNames",
51
+ source,
52
+ sourcePath,
53
+ options,
54
+ shouldPrintDebug
55
+ });
56
+ if (!result.success) {
57
+ let errorMessage = [
58
+ `[tamagui-extract] Error processing file: ${sourcePath || "(unknown)"}`,
59
+ "",
60
+ result.error,
61
+ result.stack ? `
62
+ ${result.stack}` : ""
63
+ ].filter(Boolean).join(`
64
+ `);
65
+ throw new Error(errorMessage);
66
+ }
67
+ return result.data;
68
+ }
69
+ function extractToNativeSync(sourceFileName, sourceCode, options) {
70
+ let result = runTaskSync({
71
+ type: "extractToNative",
72
+ sourceFileName,
73
+ sourceCode,
74
+ options
75
+ });
76
+ if (!result.success) {
77
+ let errorMessage = [
78
+ `[tamagui-extract] Error processing file: ${sourceFileName || "(unknown)"}`,
79
+ "",
80
+ result.error,
81
+ result.stack ? `
82
+ ${result.stack}` : ""
83
+ ].filter(Boolean).join(`
84
+ `);
85
+ throw new Error(errorMessage);
86
+ }
87
+ return result.data;
88
+ }
89
+ function getBabelPlugin() {
90
+ let { default: Static } = require("@tamagui/static");
91
+ return Static.getBabelPlugin();
92
+ }
93
+ // Annotate the CommonJS export names for ESM import in node:
94
+ 0 && (module.exports = {
95
+ extractToClassNamesSync,
96
+ extractToNativeSync,
97
+ getBabelPlugin,
98
+ getPragmaOptions,
99
+ loadTamaguiBuildConfigSync
100
+ });
101
+ //# sourceMappingURL=index.js.map
package/dist/index.js ADDED
@@ -0,0 +1,101 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
11
+ for (let key of __getOwnPropNames(from))
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ return to;
14
+ };
15
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
+ // If the importer is in node compatibility mode or this is not an ESM
17
+ // file that has been converted to a CommonJS file using a Babel-
18
+ // compatible transform (i.e. "__esModule" has not been set), then set
19
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
+ mod
22
+ )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
+
24
+ // src/index.ts
25
+ var index_exports = {};
26
+ __export(index_exports, {
27
+ extractToClassNamesSync: () => extractToClassNamesSync,
28
+ extractToNativeSync: () => extractToNativeSync,
29
+ getBabelPlugin: () => getBabelPlugin,
30
+ getPragmaOptions: () => getPragmaOptions,
31
+ loadTamaguiBuildConfigSync: () => loadTamaguiBuildConfigSync
32
+ });
33
+ module.exports = __toCommonJS(index_exports);
34
+ var import_synckit = require("synckit"), import_node_url = require("node:url"), import_meta = {}, getWorkerPath = () => typeof import_meta < "u" && import_meta.url ? (0, import_node_url.fileURLToPath)(import_meta.resolve("@tamagui/static/worker")).replace(/\.mjs$/, ".js") : require.resolve("@tamagui/static/worker").replace(/\.mjs$/, ".js"), runTaskSync = (0, import_synckit.createSyncFn)(getWorkerPath(), {
35
+ timeout: 6e4
36
+ // 60s timeout for sync operations
37
+ }), getPragmaOptions = (props) => {
38
+ let { default: Static } = require("@tamagui/static");
39
+ return Static.getPragmaOptions(props);
40
+ };
41
+ function loadTamaguiBuildConfigSync(tamaguiOptions) {
42
+ let { default: Static } = require("@tamagui/static");
43
+ return Static.loadTamaguiBuildConfigSync(tamaguiOptions);
44
+ }
45
+ function extractToClassNamesSync(params) {
46
+ let { source, sourcePath = "", options, shouldPrintDebug = !1 } = params;
47
+ if (typeof source != "string")
48
+ throw new Error("`source` must be a string of javascript");
49
+ let result = runTaskSync({
50
+ type: "extractToClassNames",
51
+ source,
52
+ sourcePath,
53
+ options,
54
+ shouldPrintDebug
55
+ });
56
+ if (!result.success) {
57
+ let errorMessage = [
58
+ `[tamagui-extract] Error processing file: ${sourcePath || "(unknown)"}`,
59
+ "",
60
+ result.error,
61
+ result.stack ? `
62
+ ${result.stack}` : ""
63
+ ].filter(Boolean).join(`
64
+ `);
65
+ throw new Error(errorMessage);
66
+ }
67
+ return result.data;
68
+ }
69
+ function extractToNativeSync(sourceFileName, sourceCode, options) {
70
+ let result = runTaskSync({
71
+ type: "extractToNative",
72
+ sourceFileName,
73
+ sourceCode,
74
+ options
75
+ });
76
+ if (!result.success) {
77
+ let errorMessage = [
78
+ `[tamagui-extract] Error processing file: ${sourceFileName || "(unknown)"}`,
79
+ "",
80
+ result.error,
81
+ result.stack ? `
82
+ ${result.stack}` : ""
83
+ ].filter(Boolean).join(`
84
+ `);
85
+ throw new Error(errorMessage);
86
+ }
87
+ return result.data;
88
+ }
89
+ function getBabelPlugin() {
90
+ let { default: Static } = require("@tamagui/static");
91
+ return Static.getBabelPlugin();
92
+ }
93
+ // Annotate the CommonJS export names for ESM import in node:
94
+ 0 && (module.exports = {
95
+ extractToClassNamesSync,
96
+ extractToNativeSync,
97
+ getBabelPlugin,
98
+ getPragmaOptions,
99
+ loadTamaguiBuildConfigSync
100
+ });
101
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,qBAA6B,oBAC7B,kBAA8B,qBAb9B,kBAsBM,gBAAgB,MAEhB,OAAO,cAAgB,OAAe,YAAY,UACjC,+BAAc,YAAY,QAAQ,wBAAwB,CAAC,EAE5D,QAAQ,UAAU,KAAK,IAIpC,gBAAgB,wBAAwB,EAAE,QAAQ,UAAU,KAAK,GAIpE,kBAAc,6BAAa,cAAc,GAAG;AAAA,EAChD,SAAS;AAAA;AACX,CAAC,GAEY,mBAAmB,CAAC,UAG3B;AAEJ,MAAM,EAAE,SAAS,OAAO,IAAI,QAAQ,iBAAiB;AACrD,SAAO,OAAO,iBAAiB,KAAK;AACtC;AAMO,SAAS,2BACd,gBACgB;AAEhB,MAAM,EAAE,SAAS,OAAO,IAAI,QAAQ,iBAAiB;AACrD,SAAO,OAAO,2BAA2B,cAAc;AACzD;AAKO,SAAS,wBAAwB,QAKhC;AACN,MAAM,EAAE,QAAQ,aAAa,IAAI,SAAS,mBAAmB,GAAM,IAAI;AAEvE,MAAI,OAAO,UAAW;AACpB,UAAM,IAAI,MAAM,yCAAyC;AAW3D,MAAM,SAAS,YARF;AAAA,IACX,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAE+B;AAE/B,MAAI,CAAC,OAAO,SAAS;AACnB,QAAM,eAAe;AAAA,MACnB,4CAA4C,cAAc,WAAW;AAAA,MACrE;AAAA,MACA,OAAO;AAAA,MACP,OAAO,QAAQ;AAAA,EAAK,OAAO,KAAK,KAAK;AAAA,IACvC,EACG,OAAO,OAAO,EACd,KAAK;AAAA,CAAI;AAEZ,UAAM,IAAI,MAAM,YAAY;AAAA,EAC9B;AAEA,SAAO,OAAO;AAChB;AAKO,SAAS,oBACd,gBACA,YACA,SACiB;AAQjB,MAAM,SAAS,YAPF;AAAA,IACX,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAE+B;AAE/B,MAAI,CAAC,OAAO,SAAS;AACnB,QAAM,eAAe;AAAA,MACnB,4CAA4C,kBAAkB,WAAW;AAAA,MACzE;AAAA,MACA,OAAO;AAAA,MACP,OAAO,QAAQ;AAAA,EAAK,OAAO,KAAK,KAAK;AAAA,IACvC,EACG,OAAO,OAAO,EACd,KAAK;AAAA,CAAI;AAEZ,UAAM,IAAI,MAAM,YAAY;AAAA,EAC9B;AAEA,SAAO,OAAO;AAChB;AAKO,SAAS,iBAAiB;AAE/B,MAAM,EAAE,SAAS,OAAO,IAAI,QAAQ,iBAAiB;AACrD,SAAO,OAAO,eAAe;AAC/B;",
5
+ "names": []
6
+ }
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@tamagui/static-sync",
3
+ "version": "1.136.7",
4
+ "source": "src/index.ts",
5
+ "types": "./types/index.d.ts",
6
+ "type": "commonjs",
7
+ "main": "dist",
8
+ "files": [
9
+ "src",
10
+ "types",
11
+ "dist"
12
+ ],
13
+ "scripts": {
14
+ "build": "tamagui-build --skip-native --bundle --bundle-modules",
15
+ "watch": "yarn build --watch",
16
+ "clean": "tamagui-build clean",
17
+ "clean:build": "tamagui-build clean:build",
18
+ "lint": "biome check src",
19
+ "lint:fix": "biome check --write src"
20
+ },
21
+ "exports": {
22
+ "./package.json": "./package.json",
23
+ ".": {
24
+ "types": "./types/index.d.ts",
25
+ "require": "./dist/index.cjs",
26
+ "import": "./dist/index.cjs"
27
+ }
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "license": "MIT",
33
+ "dependencies": {
34
+ "@babel/core": "^7.25.2",
35
+ "@tamagui/static": "1.136.7",
36
+ "@tamagui/types": "1.136.7",
37
+ "synckit": "^0.9.2"
38
+ },
39
+ "devDependencies": {
40
+ "@tamagui/build": "1.136.7"
41
+ }
42
+ }
package/src/index.ts ADDED
@@ -0,0 +1,142 @@
1
+ /**
2
+ * @tamagui/static-sync
3
+ *
4
+ * Synchronous API for Tamagui static extraction using synckit.
5
+ * Wraps @tamagui/static's worker implementation to provide sync APIs
6
+ * required by Babel plugins which cannot use async functions.
7
+ *
8
+ * This package uses synckit to convert async worker calls into synchronous ones.
9
+ */
10
+
11
+ import type { BabelFileResult } from '@babel/core'
12
+ import type { TamaguiOptions } from '@tamagui/types'
13
+ import { createSyncFn } from 'synckit'
14
+ import { fileURLToPath } from 'node:url'
15
+
16
+ export type {
17
+ ExtractedResponse,
18
+ TamaguiProjectInfo,
19
+ } from '@tamagui/static'
20
+ export type { TamaguiOptions } from '@tamagui/types'
21
+
22
+ // Resolve worker path - works for both CJS and ESM
23
+ const getWorkerPath = () => {
24
+ // Use the CommonJS .js version which works for synckit
25
+ if (typeof import.meta !== 'undefined' && import.meta.url) {
26
+ const workerPath = fileURLToPath(import.meta.resolve('@tamagui/static/worker'))
27
+ // Replace .mjs with .js for CommonJS compatibility
28
+ return workerPath.replace(/\.mjs$/, '.js')
29
+ }
30
+
31
+ // Fallback for CJS
32
+ return require.resolve('@tamagui/static/worker').replace(/\.mjs$/, '.js')
33
+ }
34
+
35
+ // Create sync function that calls the worker's runTask function
36
+ const runTaskSync = createSyncFn(getWorkerPath(), {
37
+ timeout: 60000, // 60s timeout for sync operations
38
+ })
39
+
40
+ export const getPragmaOptions = (props: {
41
+ source: string
42
+ path: string
43
+ }) => {
44
+ // This doesn't need worker, just use static directly
45
+ const { default: Static } = require('@tamagui/static')
46
+ return Static.getPragmaOptions(props)
47
+ }
48
+
49
+ /**
50
+ * Load Tamagui build configuration synchronously
51
+ * This is only used for loading tamagui.build.ts config
52
+ */
53
+ export function loadTamaguiBuildConfigSync(
54
+ tamaguiOptions: Partial<TamaguiOptions> | undefined
55
+ ): TamaguiOptions {
56
+ // Import from static package for this sync operation
57
+ const { default: Static } = require('@tamagui/static')
58
+ return Static.loadTamaguiBuildConfigSync(tamaguiOptions)
59
+ }
60
+
61
+ /**
62
+ * Extract Tamagui components to className-based CSS for web (synchronous)
63
+ */
64
+ export function extractToClassNamesSync(params: {
65
+ source: string | Buffer
66
+ sourcePath?: string
67
+ options: TamaguiOptions
68
+ shouldPrintDebug?: boolean | 'verbose'
69
+ }): any {
70
+ const { source, sourcePath = '', options, shouldPrintDebug = false } = params
71
+
72
+ if (typeof source !== 'string') {
73
+ throw new Error('`source` must be a string of javascript')
74
+ }
75
+
76
+ const task = {
77
+ type: 'extractToClassNames',
78
+ source,
79
+ sourcePath,
80
+ options,
81
+ shouldPrintDebug,
82
+ }
83
+
84
+ const result = runTaskSync(task) as any
85
+
86
+ if (!result.success) {
87
+ const errorMessage = [
88
+ `[tamagui-extract] Error processing file: ${sourcePath || '(unknown)'}`,
89
+ ``,
90
+ result.error,
91
+ result.stack ? `\n${result.stack}` : '',
92
+ ]
93
+ .filter(Boolean)
94
+ .join('\n')
95
+
96
+ throw new Error(errorMessage)
97
+ }
98
+
99
+ return result.data
100
+ }
101
+
102
+ /**
103
+ * Extract Tamagui components to React Native StyleSheet format (synchronous)
104
+ */
105
+ export function extractToNativeSync(
106
+ sourceFileName: string,
107
+ sourceCode: string,
108
+ options: TamaguiOptions
109
+ ): BabelFileResult {
110
+ const task = {
111
+ type: 'extractToNative',
112
+ sourceFileName,
113
+ sourceCode,
114
+ options,
115
+ }
116
+
117
+ const result = runTaskSync(task) as any
118
+
119
+ if (!result.success) {
120
+ const errorMessage = [
121
+ `[tamagui-extract] Error processing file: ${sourceFileName || '(unknown)'}`,
122
+ ``,
123
+ result.error,
124
+ result.stack ? `\n${result.stack}` : '',
125
+ ]
126
+ .filter(Boolean)
127
+ .join('\n')
128
+
129
+ throw new Error(errorMessage)
130
+ }
131
+
132
+ return result.data
133
+ }
134
+
135
+ /**
136
+ * Get babel plugin that uses synchronous extraction
137
+ */
138
+ export function getBabelPlugin() {
139
+ // We need to wrap the babel plugin to use sync extraction
140
+ const { default: Static } = require('@tamagui/static')
141
+ return Static.getBabelPlugin()
142
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @tamagui/static-sync
3
+ *
4
+ * Synchronous API for Tamagui static extraction using synckit.
5
+ * Wraps @tamagui/static's worker implementation to provide sync APIs
6
+ * required by Babel plugins which cannot use async functions.
7
+ *
8
+ * This package uses synckit to convert async worker calls into synchronous ones.
9
+ */
10
+ import type { BabelFileResult } from '@babel/core';
11
+ import type { TamaguiOptions } from '@tamagui/types';
12
+ export type { ExtractedResponse, TamaguiProjectInfo, } from '@tamagui/static';
13
+ export type { TamaguiOptions } from '@tamagui/types';
14
+ export declare const getPragmaOptions: (props: {
15
+ source: string;
16
+ path: string;
17
+ }) => any;
18
+ /**
19
+ * Load Tamagui build configuration synchronously
20
+ * This is only used for loading tamagui.build.ts config
21
+ */
22
+ export declare function loadTamaguiBuildConfigSync(tamaguiOptions: Partial<TamaguiOptions> | undefined): TamaguiOptions;
23
+ /**
24
+ * Extract Tamagui components to className-based CSS for web (synchronous)
25
+ */
26
+ export declare function extractToClassNamesSync(params: {
27
+ source: string | Buffer;
28
+ sourcePath?: string;
29
+ options: TamaguiOptions;
30
+ shouldPrintDebug?: boolean | 'verbose';
31
+ }): any;
32
+ /**
33
+ * Extract Tamagui components to React Native StyleSheet format (synchronous)
34
+ */
35
+ export declare function extractToNativeSync(sourceFileName: string, sourceCode: string, options: TamaguiOptions): BabelFileResult;
36
+ /**
37
+ * Get babel plugin that uses synchronous extraction
38
+ */
39
+ export declare function getBabelPlugin(): any;
40
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAIpD,YAAY,EACV,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,iBAAiB,CAAA;AACxB,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAoBpD,eAAO,MAAM,gBAAgB,GAAI,OAAO;IACtC,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;CACb,QAIA,CAAA;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,cAAc,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,SAAS,GAClD,cAAc,CAIhB;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE;IAC9C,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,cAAc,CAAA;IACvB,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CACvC,GAAG,GAAG,CA+BN;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,cAAc,GACtB,eAAe,CAwBjB;AAED;;GAEG;AACH,wBAAgB,cAAc,QAI7B"}