@hanzogui/static-sync 8.3.0 → 8.3.2
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/cjs/here.js +7 -0
- package/dist/cjs/here.js.map +1 -0
- package/dist/cjs/index.js +93 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/here.js +6 -0
- package/dist/esm/here.js.map +1 -0
- package/dist/esm/index.js +86 -0
- package/dist/esm/index.js.map +1 -0
- package/package.json +16 -14
- package/src/here.cjs.ts +5 -0
- package/src/here.ts +7 -0
- package/src/index.ts +10 -17
- package/types/here.d.ts +3 -0
- package/types/here.d.ts.map +1 -0
- package/types/index.d.ts +2 -2
- package/types/index.d.ts.map +1 -1
- package/dist/index.cjs +0 -112
package/dist/cjs/here.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.worker = exports.url = void 0;
|
|
4
|
+
const node_url_1 = require("node:url");
|
|
5
|
+
exports.url = (0, node_url_1.pathToFileURL)(__filename).href;
|
|
6
|
+
exports.worker = require.resolve('@hanzogui/static/worker');
|
|
7
|
+
//# sourceMappingURL=here.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"here.cjs.js","sourceRoot":"","sources":["../../src/here.cjs.ts"],"names":[],"mappings":";;;AAAA,uCAAwC;AAE3B,QAAA,GAAG,GAAG,IAAA,wBAAa,EAAC,UAAU,CAAC,CAAC,IAAI,CAAA;AAEpC,QAAA,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAA"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @hanzogui/static-sync
|
|
4
|
+
*
|
|
5
|
+
* Synchronous API for Gui static extraction using synckit.
|
|
6
|
+
* Wraps @hanzogui/static's worker implementation to provide sync APIs
|
|
7
|
+
* required by Babel plugins which cannot use async functions.
|
|
8
|
+
*
|
|
9
|
+
* This package uses synckit to convert async worker calls into synchronous ones.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getPragmaOptions = void 0;
|
|
13
|
+
exports.extractToClassNamesSync = extractToClassNamesSync;
|
|
14
|
+
exports.extractToNativeSync = extractToNativeSync;
|
|
15
|
+
exports.getBabelPlugin = getBabelPlugin;
|
|
16
|
+
const synckit_1 = require("synckit");
|
|
17
|
+
const node_module_1 = require("node:module");
|
|
18
|
+
const here_ts_1 = require("./here.js");
|
|
19
|
+
const need = (0, node_module_1.createRequire)(here_ts_1.url);
|
|
20
|
+
// The worker file, by this package's own resolution of it.
|
|
21
|
+
const getWorkerPath = () => here_ts_1.worker;
|
|
22
|
+
// Create sync function that calls the worker's runTask function
|
|
23
|
+
const runTaskSync = (0, synckit_1.createSyncFn)(getWorkerPath(), {
|
|
24
|
+
timeout: 60000, // 60s timeout for sync operations
|
|
25
|
+
});
|
|
26
|
+
const getPragmaOptions = (props) => {
|
|
27
|
+
// This doesn't need worker, just use static directly
|
|
28
|
+
const { default: Static } = need('@hanzogui/static');
|
|
29
|
+
return Static.getPragmaOptions(props);
|
|
30
|
+
};
|
|
31
|
+
exports.getPragmaOptions = getPragmaOptions;
|
|
32
|
+
/**
|
|
33
|
+
* Extract Gui components to className-based CSS for web (synchronous)
|
|
34
|
+
*/
|
|
35
|
+
function extractToClassNamesSync(params) {
|
|
36
|
+
const { source, sourcePath = '', options, shouldPrintDebug = false } = params;
|
|
37
|
+
if (typeof source !== 'string') {
|
|
38
|
+
throw new Error('`source` must be a string of javascript');
|
|
39
|
+
}
|
|
40
|
+
const task = {
|
|
41
|
+
type: 'extractToClassNames',
|
|
42
|
+
source,
|
|
43
|
+
sourcePath,
|
|
44
|
+
options,
|
|
45
|
+
shouldPrintDebug,
|
|
46
|
+
};
|
|
47
|
+
const result = runTaskSync(task);
|
|
48
|
+
if (!result.success) {
|
|
49
|
+
const errorMessage = [
|
|
50
|
+
`[hanzogui-extract] Error processing file: ${sourcePath || '(unknown)'}`,
|
|
51
|
+
``,
|
|
52
|
+
result.error,
|
|
53
|
+
result.stack ? `\n${result.stack}` : '',
|
|
54
|
+
]
|
|
55
|
+
.filter(Boolean)
|
|
56
|
+
.join('\n');
|
|
57
|
+
throw new Error(errorMessage);
|
|
58
|
+
}
|
|
59
|
+
return result.data;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Extract Gui components to React Native StyleSheet format (synchronous)
|
|
63
|
+
*/
|
|
64
|
+
function extractToNativeSync(sourceFileName, sourceCode, options) {
|
|
65
|
+
const task = {
|
|
66
|
+
type: 'extractToNative',
|
|
67
|
+
sourceFileName,
|
|
68
|
+
sourceCode,
|
|
69
|
+
options,
|
|
70
|
+
};
|
|
71
|
+
const result = runTaskSync(task);
|
|
72
|
+
if (!result.success) {
|
|
73
|
+
const errorMessage = [
|
|
74
|
+
`[hanzogui-extract] Error processing file: ${sourceFileName || '(unknown)'}`,
|
|
75
|
+
``,
|
|
76
|
+
result.error,
|
|
77
|
+
result.stack ? `\n${result.stack}` : '',
|
|
78
|
+
]
|
|
79
|
+
.filter(Boolean)
|
|
80
|
+
.join('\n');
|
|
81
|
+
throw new Error(errorMessage);
|
|
82
|
+
}
|
|
83
|
+
return result.data;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get babel plugin that uses synchronous extraction
|
|
87
|
+
*/
|
|
88
|
+
function getBabelPlugin() {
|
|
89
|
+
// We need to wrap the babel plugin to use sync extraction
|
|
90
|
+
const { default: Static } = need('@hanzogui/static');
|
|
91
|
+
return Static.getBabelPlugin();
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;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AE,CAAC,CAAC,CAAC,EAAE;SACxC;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,IAAI,CAAC,CAAA;QAEb,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAA;IAC/B,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAA;AACpB,CAAC;AAED;;GAEG;AACH,6BACE,cAAsB,EACtB,UAAkB,EAClB,OAAmB;IAEnB,MAAM,IAAI,GAAG;QACX,IAAI,EAAE,iBAAiB;QACvB,cAAc;QACd,UAAU;QACV,OAAO;KACR,CAAA;IAED,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAQ,CAAA;IAEvC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,YAAY,GAAG;YACnB,6CAA6C,cAAc,IAAI,WAAW,EAAE;YAC5E,EAAE;YACF,MAAM,CAAC,KAAK;YACZ,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE;SACxC;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,IAAI,CAAC,CAAA;QAEb,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAA;IAC/B,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAA;AACpB,CAAC;AAED;;GAEG;AACH;IACE,0DAA0D;IAC1D,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,kBAAkB,CAAC,CAAA;IACpD,OAAO,MAAM,CAAC,cAAc,EAAE,CAAA;AAChC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "type": "commonjs" }
|
package/dist/esm/here.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
// This module's own URL. A require made from it resolves from this package.
|
|
3
|
+
export const url = import.meta.url;
|
|
4
|
+
// The worker file of the same kind as this emit, so an ESM host runs the ESM worker.
|
|
5
|
+
export const worker = fileURLToPath(import.meta.resolve('@hanzogui/static/worker'));
|
|
6
|
+
//# sourceMappingURL=here.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"here.js","sourceRoot":"","sources":["../../src/here.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,4EAA4E;AAC5E,MAAM,CAAC,MAAM,GAAG,GAAG,OAAO,IAAI,CAAC,GAAG,CAAA;AAElC,qFAAqF;AACrF,MAAM,CAAC,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hanzogui/static-sync
|
|
3
|
+
*
|
|
4
|
+
* Synchronous API for Gui static extraction using synckit.
|
|
5
|
+
* Wraps @hanzogui/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 { createSyncFn } from 'synckit';
|
|
11
|
+
import { createRequire } from 'node:module';
|
|
12
|
+
import { url, worker } from './here.js';
|
|
13
|
+
const need = createRequire(url);
|
|
14
|
+
// The worker file, by this package's own resolution of it.
|
|
15
|
+
const getWorkerPath = () => worker;
|
|
16
|
+
// Create sync function that calls the worker's runTask function
|
|
17
|
+
const runTaskSync = createSyncFn(getWorkerPath(), {
|
|
18
|
+
timeout: 60000, // 60s timeout for sync operations
|
|
19
|
+
});
|
|
20
|
+
export const getPragmaOptions = (props) => {
|
|
21
|
+
// This doesn't need worker, just use static directly
|
|
22
|
+
const { default: Static } = need('@hanzogui/static');
|
|
23
|
+
return Static.getPragmaOptions(props);
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Extract Gui components to className-based CSS for web (synchronous)
|
|
27
|
+
*/
|
|
28
|
+
export function extractToClassNamesSync(params) {
|
|
29
|
+
const { source, sourcePath = '', options, shouldPrintDebug = false } = params;
|
|
30
|
+
if (typeof source !== 'string') {
|
|
31
|
+
throw new Error('`source` must be a string of javascript');
|
|
32
|
+
}
|
|
33
|
+
const task = {
|
|
34
|
+
type: 'extractToClassNames',
|
|
35
|
+
source,
|
|
36
|
+
sourcePath,
|
|
37
|
+
options,
|
|
38
|
+
shouldPrintDebug,
|
|
39
|
+
};
|
|
40
|
+
const result = runTaskSync(task);
|
|
41
|
+
if (!result.success) {
|
|
42
|
+
const errorMessage = [
|
|
43
|
+
`[hanzogui-extract] Error processing file: ${sourcePath || '(unknown)'}`,
|
|
44
|
+
``,
|
|
45
|
+
result.error,
|
|
46
|
+
result.stack ? `\n${result.stack}` : '',
|
|
47
|
+
]
|
|
48
|
+
.filter(Boolean)
|
|
49
|
+
.join('\n');
|
|
50
|
+
throw new Error(errorMessage);
|
|
51
|
+
}
|
|
52
|
+
return result.data;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Extract Gui components to React Native StyleSheet format (synchronous)
|
|
56
|
+
*/
|
|
57
|
+
export function extractToNativeSync(sourceFileName, sourceCode, options) {
|
|
58
|
+
const task = {
|
|
59
|
+
type: 'extractToNative',
|
|
60
|
+
sourceFileName,
|
|
61
|
+
sourceCode,
|
|
62
|
+
options,
|
|
63
|
+
};
|
|
64
|
+
const result = runTaskSync(task);
|
|
65
|
+
if (!result.success) {
|
|
66
|
+
const errorMessage = [
|
|
67
|
+
`[hanzogui-extract] Error processing file: ${sourceFileName || '(unknown)'}`,
|
|
68
|
+
``,
|
|
69
|
+
result.error,
|
|
70
|
+
result.stack ? `\n${result.stack}` : '',
|
|
71
|
+
]
|
|
72
|
+
.filter(Boolean)
|
|
73
|
+
.join('\n');
|
|
74
|
+
throw new Error(errorMessage);
|
|
75
|
+
}
|
|
76
|
+
return result.data;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get babel plugin that uses synchronous extraction
|
|
80
|
+
*/
|
|
81
|
+
export function getBabelPlugin() {
|
|
82
|
+
// We need to wrap the babel plugin to use sync extraction
|
|
83
|
+
const { default: Static } = need('@hanzogui/static');
|
|
84
|
+
return Static.getBabelPlugin();
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAEvC,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,CAAA;AAK/B,2DAA2D;AAC3D,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,MAAM,CAAA;AAElC,gEAAgE;AAChE,MAAM,WAAW,GAAG,YAAY,CAAC,aAAa,EAAE,EAAE;IAChD,OAAO,EAAE,KAAK,EAAE,kCAAkC;CACnD,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAuC,EAAE,EAAE;IAC1E,qDAAqD;IACrD,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,kBAAkB,CAAC,CAAA;IACpD,OAAO,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;AACvC,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAKvC;IACC,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,EAAE,EAAE,OAAO,EAAE,gBAAgB,GAAG,KAAK,EAAE,GAAG,MAAM,CAAA;IAE7E,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,yCA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CAAC,IAAI,CAAA;AACpB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,0DAA0D;IAC1D,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,kBAAkB,CAAC,CAAA;IACpD,OAAO,MAAM,CAAC,cAAc,EAAE,CAAA;AAChC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzogui/static-sync",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"files": [
|
|
@@ -8,36 +8,38 @@
|
|
|
8
8
|
"types",
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
|
-
"type": "
|
|
12
|
-
"main": "dist",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "./dist/cjs/index.js",
|
|
13
|
+
"module": "./dist/esm/index.js",
|
|
13
14
|
"types": "./types/index.d.ts",
|
|
14
15
|
"exports": {
|
|
15
16
|
"./package.json": "./package.json",
|
|
16
17
|
".": {
|
|
17
18
|
"types": "./types/index.d.ts",
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
19
|
+
"react-native": "./dist/esm/index.js",
|
|
20
|
+
"browser": "./dist/esm/index.js",
|
|
21
|
+
"module": "./dist/esm/index.js",
|
|
22
|
+
"import": "./dist/esm/index.js",
|
|
23
|
+
"require": "./dist/cjs/index.js",
|
|
24
|
+
"default": "./dist/esm/index.js"
|
|
22
25
|
}
|
|
23
26
|
},
|
|
24
27
|
"publishConfig": {
|
|
25
28
|
"access": "public"
|
|
26
29
|
},
|
|
27
30
|
"scripts": {
|
|
28
|
-
"build": "hanzogui-build --skip-native
|
|
29
|
-
"watch": "bun run build --watch",
|
|
31
|
+
"build": "hanzogui-build --skip-native",
|
|
30
32
|
"clean": "hanzogui-build clean",
|
|
31
33
|
"clean:build": "hanzogui-build clean:build"
|
|
32
34
|
},
|
|
33
35
|
"dependencies": {
|
|
34
|
-
"@babel/core": "^
|
|
35
|
-
"@hanzogui/static": "8.3.
|
|
36
|
-
"@hanzogui/types": "8.3.
|
|
37
|
-
"synckit": "^0.
|
|
36
|
+
"@babel/core": "^8.0.1",
|
|
37
|
+
"@hanzogui/static": "8.3.2",
|
|
38
|
+
"@hanzogui/types": "8.3.2",
|
|
39
|
+
"synckit": "^0.11.13"
|
|
38
40
|
},
|
|
39
41
|
"devDependencies": {
|
|
40
|
-
"@hanzogui/build": "8.3.
|
|
42
|
+
"@hanzogui/build": "8.3.2"
|
|
41
43
|
},
|
|
42
44
|
"repository": {
|
|
43
45
|
"type": "git",
|
package/src/here.cjs.ts
ADDED
package/src/here.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url'
|
|
2
|
+
|
|
3
|
+
// This module's own URL. A require made from it resolves from this package.
|
|
4
|
+
export const url = import.meta.url
|
|
5
|
+
|
|
6
|
+
// The worker file of the same kind as this emit, so an ESM host runs the ESM worker.
|
|
7
|
+
export const worker = fileURLToPath(import.meta.resolve('@hanzogui/static/worker'))
|
package/src/index.ts
CHANGED
|
@@ -8,26 +8,19 @@
|
|
|
8
8
|
* This package uses synckit to convert async worker calls into synchronous ones.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import type {
|
|
11
|
+
import type { FileResult } from '@babel/core'
|
|
12
12
|
import type { GuiOptions } from '@hanzogui/types'
|
|
13
13
|
import { createSyncFn } from 'synckit'
|
|
14
|
-
import {
|
|
14
|
+
import { createRequire } from 'node:module'
|
|
15
|
+
import { url, worker } from './here.ts'
|
|
16
|
+
|
|
17
|
+
const need = createRequire(url)
|
|
15
18
|
|
|
16
19
|
export type { ExtractedResponse, GuiProjectInfo } from '@hanzogui/static'
|
|
17
20
|
export type { GuiOptions } from '@hanzogui/types'
|
|
18
21
|
|
|
19
|
-
//
|
|
20
|
-
const getWorkerPath = () =>
|
|
21
|
-
// Use the CommonJS .js version which works for synckit
|
|
22
|
-
if (typeof import.meta !== 'undefined' && import.meta.url) {
|
|
23
|
-
const workerPath = fileURLToPath(import.meta.resolve('@hanzogui/static/worker'))
|
|
24
|
-
// Replace .mjs with .js for CommonJS compatibility
|
|
25
|
-
return workerPath.replace(/\.mjs$/, '.js')
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Fallback for CJS
|
|
29
|
-
return require.resolve('@hanzogui/static/worker').replace(/\.mjs$/, '.js')
|
|
30
|
-
}
|
|
22
|
+
// The worker file, by this package's own resolution of it.
|
|
23
|
+
const getWorkerPath = () => worker
|
|
31
24
|
|
|
32
25
|
// Create sync function that calls the worker's runTask function
|
|
33
26
|
const runTaskSync = createSyncFn(getWorkerPath(), {
|
|
@@ -36,7 +29,7 @@ const runTaskSync = createSyncFn(getWorkerPath(), {
|
|
|
36
29
|
|
|
37
30
|
export const getPragmaOptions = (props: { source: string; path: string }) => {
|
|
38
31
|
// This doesn't need worker, just use static directly
|
|
39
|
-
const { default: Static } =
|
|
32
|
+
const { default: Static } = need('@hanzogui/static')
|
|
40
33
|
return Static.getPragmaOptions(props)
|
|
41
34
|
}
|
|
42
35
|
|
|
@@ -88,7 +81,7 @@ export function extractToNativeSync(
|
|
|
88
81
|
sourceFileName: string,
|
|
89
82
|
sourceCode: string,
|
|
90
83
|
options: GuiOptions
|
|
91
|
-
):
|
|
84
|
+
): FileResult {
|
|
92
85
|
const task = {
|
|
93
86
|
type: 'extractToNative',
|
|
94
87
|
sourceFileName,
|
|
@@ -119,6 +112,6 @@ export function extractToNativeSync(
|
|
|
119
112
|
*/
|
|
120
113
|
export function getBabelPlugin() {
|
|
121
114
|
// We need to wrap the babel plugin to use sync extraction
|
|
122
|
-
const { default: Static } =
|
|
115
|
+
const { default: Static } = need('@hanzogui/static')
|
|
123
116
|
return Static.getBabelPlugin()
|
|
124
117
|
}
|
package/types/here.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"here.d.ts","sourceRoot":"","sources":["../src/here.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,GAAG,QAAkB,CAAA;AAGlC,eAAO,MAAM,MAAM,QAAgE,CAAA"}
|
package/types/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* This package uses synckit to convert async worker calls into synchronous ones.
|
|
9
9
|
*/
|
|
10
|
-
import type {
|
|
10
|
+
import type { FileResult } from '@babel/core';
|
|
11
11
|
import type { GuiOptions } from '@hanzogui/types';
|
|
12
12
|
export type { ExtractedResponse, GuiProjectInfo } from '@hanzogui/static';
|
|
13
13
|
export type { GuiOptions } from '@hanzogui/types';
|
|
@@ -27,7 +27,7 @@ export declare function extractToClassNamesSync(params: {
|
|
|
27
27
|
/**
|
|
28
28
|
* Extract Gui components to React Native StyleSheet format (synchronous)
|
|
29
29
|
*/
|
|
30
|
-
export declare function extractToNativeSync(sourceFileName: string, sourceCode: string, options: GuiOptions):
|
|
30
|
+
export declare function extractToNativeSync(sourceFileName: string, sourceCode: string, options: GuiOptions): FileResult;
|
|
31
31
|
/**
|
|
32
32
|
* Get babel plugin that uses synchronous extraction
|
|
33
33
|
*/
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAOjD,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACzE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAUjD,eAAO,MAAM,gBAAgB,UAAW;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,QAIvE,CAAA;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE;IAC9C,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,UAAU,CAAA;IACnB,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,UAAU,GAClB,UAAU,CAwBZ;AAED;;GAEG;AACH,wBAAgB,cAAc,QAI7B"}
|
package/dist/index.cjs
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
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;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
|
|
29
|
-
// src/index.ts
|
|
30
|
-
var index_exports = {};
|
|
31
|
-
__export(index_exports, {
|
|
32
|
-
extractToClassNamesSync: () => extractToClassNamesSync,
|
|
33
|
-
extractToNativeSync: () => extractToNativeSync,
|
|
34
|
-
getBabelPlugin: () => getBabelPlugin,
|
|
35
|
-
getPragmaOptions: () => getPragmaOptions
|
|
36
|
-
});
|
|
37
|
-
module.exports = __toCommonJS(index_exports);
|
|
38
|
-
var import_synckit = require("synckit");
|
|
39
|
-
var import_node_url = require("node:url");
|
|
40
|
-
var import_meta = {};
|
|
41
|
-
var getWorkerPath = () => {
|
|
42
|
-
if (typeof import_meta !== "undefined" && import_meta.url) {
|
|
43
|
-
const workerPath = (0, import_node_url.fileURLToPath)(import_meta.resolve("@hanzogui/static/worker"));
|
|
44
|
-
return workerPath.replace(/\.mjs$/, ".js");
|
|
45
|
-
}
|
|
46
|
-
return require.resolve("@hanzogui/static/worker").replace(/\.mjs$/, ".js");
|
|
47
|
-
};
|
|
48
|
-
var runTaskSync = (0, import_synckit.createSyncFn)(getWorkerPath(), {
|
|
49
|
-
timeout: 6e4
|
|
50
|
-
// 60s timeout for sync operations
|
|
51
|
-
});
|
|
52
|
-
var getPragmaOptions = (props) => {
|
|
53
|
-
const { default: Static } = require("@hanzogui/static");
|
|
54
|
-
return Static.getPragmaOptions(props);
|
|
55
|
-
};
|
|
56
|
-
function extractToClassNamesSync(params) {
|
|
57
|
-
const { source, sourcePath = "", options, shouldPrintDebug = false } = params;
|
|
58
|
-
if (typeof source !== "string") {
|
|
59
|
-
throw new Error("`source` must be a string of javascript");
|
|
60
|
-
}
|
|
61
|
-
const task = {
|
|
62
|
-
type: "extractToClassNames",
|
|
63
|
-
source,
|
|
64
|
-
sourcePath,
|
|
65
|
-
options,
|
|
66
|
-
shouldPrintDebug
|
|
67
|
-
};
|
|
68
|
-
const result = runTaskSync(task);
|
|
69
|
-
if (!result.success) {
|
|
70
|
-
const errorMessage = [
|
|
71
|
-
`[hanzogui-extract] Error processing file: ${sourcePath || "(unknown)"}`,
|
|
72
|
-
``,
|
|
73
|
-
result.error,
|
|
74
|
-
result.stack ? `
|
|
75
|
-
${result.stack}` : ""
|
|
76
|
-
].filter(Boolean).join("\n");
|
|
77
|
-
throw new Error(errorMessage);
|
|
78
|
-
}
|
|
79
|
-
return result.data;
|
|
80
|
-
}
|
|
81
|
-
function extractToNativeSync(sourceFileName, sourceCode, options) {
|
|
82
|
-
const task = {
|
|
83
|
-
type: "extractToNative",
|
|
84
|
-
sourceFileName,
|
|
85
|
-
sourceCode,
|
|
86
|
-
options
|
|
87
|
-
};
|
|
88
|
-
const result = runTaskSync(task);
|
|
89
|
-
if (!result.success) {
|
|
90
|
-
const errorMessage = [
|
|
91
|
-
`[hanzogui-extract] Error processing file: ${sourceFileName || "(unknown)"}`,
|
|
92
|
-
``,
|
|
93
|
-
result.error,
|
|
94
|
-
result.stack ? `
|
|
95
|
-
${result.stack}` : ""
|
|
96
|
-
].filter(Boolean).join("\n");
|
|
97
|
-
throw new Error(errorMessage);
|
|
98
|
-
}
|
|
99
|
-
return result.data;
|
|
100
|
-
}
|
|
101
|
-
function getBabelPlugin() {
|
|
102
|
-
const { default: Static } = require("@hanzogui/static");
|
|
103
|
-
return Static.getBabelPlugin();
|
|
104
|
-
}
|
|
105
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
106
|
-
0 && (module.exports = {
|
|
107
|
-
extractToClassNamesSync,
|
|
108
|
-
extractToNativeSync,
|
|
109
|
-
getBabelPlugin,
|
|
110
|
-
getPragmaOptions
|
|
111
|
-
});
|
|
112
|
-
//# sourceMappingURL=index.js.map
|