@hanzogui/metro-plugin 2.0.0
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/LICENSE +21 -0
- package/dist/cjs/index.js +38 -0
- package/dist/cjs/index.js.map +6 -0
- package/dist/esm/index.js +21 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index.mjs +21 -0
- package/dist/esm/index.mjs.map +1 -0
- package/package.json +29 -0
- package/src/index.ts +71 -0
- package/types/index.d.ts +39 -0
- package/types/index.d.ts.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Nate Wienert
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
+
var index_exports = {};
|
|
16
|
+
__export(index_exports, {
|
|
17
|
+
withGui: () => withGui
|
|
18
|
+
});
|
|
19
|
+
module.exports = __toCommonJS(index_exports);
|
|
20
|
+
var import_static = require("@hanzogui/static");
|
|
21
|
+
function withGui(metroConfig, optionsIn) {
|
|
22
|
+
const { cssInterop, ...guiOptionsIn } = optionsIn || {};
|
|
23
|
+
cssInterop && console.warn(
|
|
24
|
+
"[@hanzogui/metro-plugin] cssInterop option is deprecated. Use `gui generate` to pre-generate CSS instead."
|
|
25
|
+
);
|
|
26
|
+
const options = {
|
|
27
|
+
...guiOptionsIn,
|
|
28
|
+
...(0, import_static.loadGuiBuildConfigSync)(guiOptionsIn)
|
|
29
|
+
};
|
|
30
|
+
return metroConfig.resolver = {
|
|
31
|
+
...metroConfig.resolver,
|
|
32
|
+
sourceExts: [.../* @__PURE__ */ new Set([...metroConfig.resolver?.sourceExts || [], "css"])]
|
|
33
|
+
}, metroConfig.transformer = {
|
|
34
|
+
...metroConfig.transformer,
|
|
35
|
+
gui: options
|
|
36
|
+
}, metroConfig;
|
|
37
|
+
}
|
|
38
|
+
//# 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,oBAAwD;AAwCjD,SAAS,QACd,aACA,WACkB;AAClB,QAAM,EAAE,YAAY,GAAG,aAAa,IAAI,aAAa,CAAC;AAEtD,EAAI,cACF,QAAQ;AAAA,IACN;AAAA,EACF;AAGF,QAAM,UAAU;AAAA,IACd,GAAG;AAAA,IACH,OAAG,sCAAuB,YAAY;AAAA,EACxC;AAGA,qBAAY,WAAW;AAAA,IACrB,GAAI,YAAY;AAAA,IAChB,YAAY,CAAC,GAAG,oBAAI,IAAI,CAAC,GAAI,YAAY,UAAU,cAAc,CAAC,GAAI,KAAK,CAAC,CAAC;AAAA,EAC/E,GAGA,YAAY,cAAc;AAAA,IACxB,GAAG,YAAY;AAAA,IACf,KAAK;AAAA,EACP,GAEO;AACT;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { loadGuiBuildConfigSync } from "@hanzogui/static";
|
|
2
|
+
function withGui(metroConfig, optionsIn) {
|
|
3
|
+
const {
|
|
4
|
+
cssInterop,
|
|
5
|
+
...guiOptionsIn
|
|
6
|
+
} = optionsIn || {};
|
|
7
|
+
cssInterop && console.warn("[@hanzogui/metro-plugin] cssInterop option is deprecated. Use `gui generate` to pre-generate CSS instead.");
|
|
8
|
+
const options = {
|
|
9
|
+
...guiOptionsIn,
|
|
10
|
+
...loadGuiBuildConfigSync(guiOptionsIn)
|
|
11
|
+
};
|
|
12
|
+
return metroConfig.resolver = {
|
|
13
|
+
...metroConfig.resolver,
|
|
14
|
+
sourceExts: [... /* @__PURE__ */new Set([...(metroConfig.resolver?.sourceExts || []), "css"])]
|
|
15
|
+
}, metroConfig.transformer = {
|
|
16
|
+
...metroConfig.transformer,
|
|
17
|
+
gui: options
|
|
18
|
+
}, metroConfig;
|
|
19
|
+
}
|
|
20
|
+
export { withGui };
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["loadGuiBuildConfigSync","withGui","metroConfig","optionsIn","cssInterop","guiOptionsIn","console","warn","options","resolver","sourceExts","Set","transformer","gui"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,sBAAA,QAA+C;AAwCjD,SAASC,QACdC,WAAA,EACAC,SAAA,EACkB;EAClB,MAAM;IAAEC,UAAA;IAAY,GAAGC;EAAa,IAAIF,SAAA,IAAa,CAAC;EAElDC,UAAA,IACFE,OAAA,CAAQC,IAAA,CACN,2GACF;EAGF,MAAMC,OAAA,GAAU;IACd,GAAGH,YAAA;IACH,GAAGL,sBAAA,CAAuBK,YAAY;EACxC;EAGA,OAAAH,WAAA,CAAYO,QAAA,GAAW;IACrB,GAAIP,WAAA,CAAYO,QAAA;IAChBC,UAAA,EAAY,CAAC,IAAG,mBAAIC,GAAA,CAAI,CAAC,IAAIT,WAAA,CAAYO,QAAA,EAAUC,UAAA,IAAc,EAAC,GAAI,KAAK,CAAC,CAAC;EAC/E,GAGAR,WAAA,CAAYU,WAAA,GAAc;IACxB,GAAGV,WAAA,CAAYU,WAAA;IACfC,GAAA,EAAKL;EACP,GAEON,WAAA;AACT","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { loadGuiBuildConfigSync } from "@hanzogui/static";
|
|
2
|
+
function withGui(metroConfig, optionsIn) {
|
|
3
|
+
const {
|
|
4
|
+
cssInterop,
|
|
5
|
+
...guiOptionsIn
|
|
6
|
+
} = optionsIn || {};
|
|
7
|
+
cssInterop && console.warn("[@hanzogui/metro-plugin] cssInterop option is deprecated. Use `gui generate` to pre-generate CSS instead.");
|
|
8
|
+
const options = {
|
|
9
|
+
...guiOptionsIn,
|
|
10
|
+
...loadGuiBuildConfigSync(guiOptionsIn)
|
|
11
|
+
};
|
|
12
|
+
return metroConfig.resolver = {
|
|
13
|
+
...metroConfig.resolver,
|
|
14
|
+
sourceExts: [... /* @__PURE__ */new Set([...(metroConfig.resolver?.sourceExts || []), "css"])]
|
|
15
|
+
}, metroConfig.transformer = {
|
|
16
|
+
...metroConfig.transformer,
|
|
17
|
+
gui: options
|
|
18
|
+
}, metroConfig;
|
|
19
|
+
}
|
|
20
|
+
export { withGui };
|
|
21
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["loadGuiBuildConfigSync","withGui","metroConfig","optionsIn","cssInterop","guiOptionsIn","console","warn","options","resolver","sourceExts","Set","transformer","gui"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,sBAAA,QAA+C;AAwCjD,SAASC,QACdC,WAAA,EACAC,SAAA,EACkB;EAClB,MAAM;IAAEC,UAAA;IAAY,GAAGC;EAAa,IAAIF,SAAA,IAAa,CAAC;EAElDC,UAAA,IACFE,OAAA,CAAQC,IAAA,CACN,2GACF;EAGF,MAAMC,OAAA,GAAU;IACd,GAAGH,YAAA;IACH,GAAGL,sBAAA,CAAuBK,YAAY;EACxC;EAGA,OAAAH,WAAA,CAAYO,QAAA,GAAW;IACrB,GAAIP,WAAA,CAAYO,QAAA;IAChBC,UAAA,EAAY,CAAC,IAAG,mBAAIC,GAAA,CAAI,CAAC,IAAIT,WAAA,CAAYO,QAAA,EAAUC,UAAA,IAAc,EAAC,GAAI,KAAK,CAAC,CAAC;EAC/E,GAGAR,WAAA,CAAYU,WAAA,GAAc;IACxB,GAAGV,WAAA,CAAYU,WAAA;IACfC,GAAA,EAAKL;EACP,GAEON,WAAA;AACT","ignoreList":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hanzogui/metro-plugin",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"source": "src/index.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"src",
|
|
8
|
+
"types",
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"main": "dist/cjs/index.js",
|
|
12
|
+
"module": "dist/esm",
|
|
13
|
+
"types": "./types/index.d.ts",
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "hanzo-gui-build --skip-native",
|
|
19
|
+
"watch": "hanzo-gui-build --skip-native --watch",
|
|
20
|
+
"clean": "hanzo-gui-build clean",
|
|
21
|
+
"clean:build": "hanzo-gui-build clean:build"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@hanzogui/static": "workspace:*"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@hanzogui/build": "workspace:*"
|
|
28
|
+
}
|
|
29
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { loadGuiBuildConfigSync, type GuiOptions } from '@hanzogui/static'
|
|
2
|
+
|
|
3
|
+
export type MetroGuiOptions = GuiOptions & {
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated CSS interop is no longer supported. Use `gui generate` instead.
|
|
6
|
+
*/
|
|
7
|
+
cssInterop?: boolean
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Use a loose type for metro config to avoid version-specific type incompatibilities
|
|
11
|
+
type MetroConfigInput = {
|
|
12
|
+
resolver?: any
|
|
13
|
+
transformer?: any
|
|
14
|
+
transformerPath?: string
|
|
15
|
+
[key: string]: any
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Configure Metro for Gui.
|
|
20
|
+
*
|
|
21
|
+
* This is now a simplified wrapper that just ensures CSS is enabled and
|
|
22
|
+
* loads your Hanzo GUI config. For CSS generation, use the CLI:
|
|
23
|
+
*
|
|
24
|
+
* 1. Create a `gui.build.ts` with `outputCSS` option
|
|
25
|
+
* 2. Run `gui generate` before your build
|
|
26
|
+
* 3. Import the generated CSS in your app's layout
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```js
|
|
30
|
+
* // metro.config.js
|
|
31
|
+
* const { getDefaultConfig } = require('expo/metro-config')
|
|
32
|
+
* const { withGui } = require('@hanzogui/metro-plugin')
|
|
33
|
+
*
|
|
34
|
+
* const config = getDefaultConfig(__dirname, { isCSSEnabled: true })
|
|
35
|
+
* module.exports = withGui(config, {
|
|
36
|
+
* components: ['@hanzo/gui'],
|
|
37
|
+
* config: './gui.config.ts',
|
|
38
|
+
* })
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export function withGui(
|
|
42
|
+
metroConfig: MetroConfigInput,
|
|
43
|
+
optionsIn?: MetroGuiOptions
|
|
44
|
+
): MetroConfigInput {
|
|
45
|
+
const { cssInterop, ...guiOptionsIn } = optionsIn || {}
|
|
46
|
+
|
|
47
|
+
if (cssInterop) {
|
|
48
|
+
console.warn(
|
|
49
|
+
'[@hanzogui/metro-plugin] cssInterop option is deprecated. Use `gui generate` to pre-generate CSS instead.'
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const options = {
|
|
54
|
+
...guiOptionsIn,
|
|
55
|
+
...loadGuiBuildConfigSync(guiOptionsIn),
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Ensure CSS files can be resolved
|
|
59
|
+
metroConfig.resolver = {
|
|
60
|
+
...(metroConfig.resolver as any),
|
|
61
|
+
sourceExts: [...new Set([...(metroConfig.resolver?.sourceExts || []), 'css'])],
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Store hanzo-gui options for potential use by other tools
|
|
65
|
+
metroConfig.transformer = {
|
|
66
|
+
...metroConfig.transformer,
|
|
67
|
+
gui: options,
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return metroConfig
|
|
71
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type GuiOptions } from '@hanzogui/static';
|
|
2
|
+
export type MetroGuiOptions = GuiOptions & {
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated CSS interop is no longer supported. Use `gui generate` instead.
|
|
5
|
+
*/
|
|
6
|
+
cssInterop?: boolean;
|
|
7
|
+
};
|
|
8
|
+
type MetroConfigInput = {
|
|
9
|
+
resolver?: any;
|
|
10
|
+
transformer?: any;
|
|
11
|
+
transformerPath?: string;
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Configure Metro for Gui.
|
|
16
|
+
*
|
|
17
|
+
* This is now a simplified wrapper that just ensures CSS is enabled and
|
|
18
|
+
* loads your Hanzo GUI config. For CSS generation, use the CLI:
|
|
19
|
+
*
|
|
20
|
+
* 1. Create a `gui.build.ts` with `outputCSS` option
|
|
21
|
+
* 2. Run `gui generate` before your build
|
|
22
|
+
* 3. Import the generated CSS in your app's layout
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```js
|
|
26
|
+
* // metro.config.js
|
|
27
|
+
* const { getDefaultConfig } = require('expo/metro-config')
|
|
28
|
+
* const { withGui } = require('@hanzogui/metro-plugin')
|
|
29
|
+
*
|
|
30
|
+
* const config = getDefaultConfig(__dirname, { isCSSEnabled: true })
|
|
31
|
+
* module.exports = withGui(config, {
|
|
32
|
+
* components: ['@hanzo/gui'],
|
|
33
|
+
* config: './gui.config.ts',
|
|
34
|
+
* })
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function withGui(metroConfig: MetroConfigInput, optionsIn?: MetroGuiOptions): MetroConfigInput;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE1E,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG;IACzC;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAA;AAGD,KAAK,gBAAgB,GAAG;IACtB,QAAQ,CAAC,EAAE,GAAG,CAAA;IACd,WAAW,CAAC,EAAE,GAAG,CAAA;IACjB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,OAAO,CACrB,WAAW,EAAE,gBAAgB,EAC7B,SAAS,CAAC,EAAE,eAAe,GAC1B,gBAAgB,CA2BlB"}
|