create-mendix-widget-gleam 1.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.
@@ -0,0 +1,10 @@
1
+ name = "{{SNAKE_CASE}}"
2
+ version = "1.0.0"
3
+ target = "javascript"
4
+
5
+ [javascript]
6
+ typescript_declarations = false
7
+ runtime = "node"
8
+
9
+ [dependencies]
10
+ gleam_stdlib = ">= 0.44.0 and < 2.0.0"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Gleam
2
+ # You typically do not need to edit this file
3
+
4
+ packages = [
5
+ { name = "gleam_stdlib", version = "0.70.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "86949BF5D1F0E4AC0AB5B06F235D8A5CC11A2DFC33BF22F752156ED61CA7D0FF" },
6
+ ]
7
+
8
+ [requirements]
9
+ gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" }
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "{{LOWERCASE}}",
3
+ "widgetName": "{{PASCAL_CASE}}",
4
+ "version": "1.0.0",
5
+ "description": "My widget description",
6
+ "copyright": "© Mendix Technology BV 2026. All rights reserved.",
7
+ "author": "",
8
+ "engines": {
9
+ "node": ">=16"
10
+ },
11
+ "license": "Apache-2.0",
12
+ "config": {
13
+ "projectPath": "./tests/testProject",
14
+ "mendixHost": "http://localhost:8080",
15
+ "developmentPort": 3000
16
+ },
17
+ "packagePath": "mendix",
18
+ "scripts": {
19
+ "prerelease": "echo skipping lint"
20
+ },
21
+ "devDependencies": {
22
+ "@mendix/pluggable-widgets-tools": "^11.8.0"
23
+ },
24
+ "dependencies": {
25
+ "classnames": "^2.5.1"
26
+ },
27
+ "resolutions": {
28
+ "react": "^19.0.0",
29
+ "react-dom": "^19.0.0"
30
+ },
31
+ "overrides": {
32
+ "react": "^19.0.0",
33
+ "react-dom": "^19.0.0"
34
+ }
35
+ }
@@ -0,0 +1,6 @@
1
+ const base = require("@mendix/pluggable-widgets-tools/configs/prettier.base.json");
2
+
3
+ module.exports = {
4
+ ...base,
5
+ plugins: [require.resolve("@prettier/plugin-xml")],
6
+ };
@@ -0,0 +1,5 @@
1
+ // 브릿지: Gleam 컴파일 출력을 Mendix editorConfig 진입점으로 연결
2
+ // Gleam(snake_case) → Mendix(camelCase) 이름 변환만 담당
3
+ import { get_properties } from "../build/dev/javascript/{{SNAKE_CASE}}/widget/editor_config.mjs";
4
+
5
+ export const getProperties = get_properties;
@@ -0,0 +1,6 @@
1
+ // 브릿지: Gleam 컴파일 출력을 Mendix 빌드 진입점으로 연결
2
+ // 위젯 로직 없음 - re-export와 CSS import만 담당
3
+ import { widget } from "../build/dev/javascript/{{SNAKE_CASE}}/widget/{{SNAKE_CASE}}.mjs";
4
+ import "./ui/{{PASCAL_CASE}}.css";
5
+
6
+ export const {{PASCAL_CASE}} = widget;
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <widget id="mendix.{{LOWERCASE}}.{{PASCAL_CASE}}" pluginWidget="true" needsEntityContext="true" offlineCapable="true"
3
+ supportedPlatform="Web"
4
+ xmlns="http://www.mendix.com/widget/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
+ xsi:schemaLocation="http://www.mendix.com/widget/1.0/ ../node_modules/mendix/custom_widget.xsd">
6
+ <name>{{DISPLAY_NAME}}</name>
7
+ <description>My widget description</description>
8
+ <icon/>
9
+ <properties>
10
+ <propertyGroup caption="General">
11
+ <property key="sampleText" type="string" required="false">
12
+ <caption>Default value</caption>
13
+ <description>Sample text input</description>
14
+ </property>
15
+ </propertyGroup>
16
+ </properties>
17
+ </widget>
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="utf-8" ?>
2
+ <package xmlns="http://www.mendix.com/package/1.0/">
3
+ <clientModule name="{{PASCAL_CASE}}" version="1.0.0" xmlns="http://www.mendix.com/clientModule/1.0/">
4
+ <widgetFiles>
5
+ <widgetFile path="{{PASCAL_CASE}}.xml"/>
6
+ </widgetFiles>
7
+ <files>
8
+ <file path="mendix/{{LOWERCASE}}"/>
9
+ </files>
10
+ </clientModule>
11
+ </package>
@@ -0,0 +1,8 @@
1
+ // 위젯 프로덕션 빌드 (.mpk 생성)
2
+ // gleam run 시 Gleam 컴파일이 먼저 자동 수행됨
3
+
4
+ import scripts/cmd
5
+
6
+ pub fn main() {
7
+ cmd.exec("{{RUNNER}} pluggable-widgets-tools build:web")
8
+ }
@@ -0,0 +1,4 @@
1
+ // 셸 명령어 실행 유틸리티
2
+
3
+ @external(javascript, "./cmd_ffi.mjs", "exec")
4
+ pub fn exec(command: String) -> Nil
@@ -0,0 +1,6 @@
1
+ // 셸 명령어 실행 FFI 어댑터
2
+ import { execSync } from "node:child_process";
3
+
4
+ export function exec(command) {
5
+ execSync(command, { stdio: "inherit", shell: true });
6
+ }
@@ -0,0 +1,8 @@
1
+ // 개발 서버 시작 (HMR, port 3000)
2
+ // gleam run 시 Gleam 컴파일이 먼저 자동 수행됨
3
+
4
+ import scripts/cmd
5
+
6
+ pub fn main() {
7
+ cmd.exec("{{RUNNER}} pluggable-widgets-tools start:web")
8
+ }
@@ -0,0 +1,8 @@
1
+ // 의존성 설치
2
+ // Gleam 의존성은 gleam run 실행 시 자동으로 다운로드됨
3
+
4
+ import scripts/cmd
5
+
6
+ pub fn main() {
7
+ cmd.exec("{{INSTALL_COMMAND}}")
8
+ }
@@ -0,0 +1,7 @@
1
+ // ESLint 실행
2
+
3
+ import scripts/cmd
4
+
5
+ pub fn main() {
6
+ cmd.exec("{{RUNNER}} pluggable-widgets-tools lint")
7
+ }
@@ -0,0 +1,7 @@
1
+ // ESLint 자동 수정
2
+
3
+ import scripts/cmd
4
+
5
+ pub fn main() {
6
+ cmd.exec("{{RUNNER}} pluggable-widgets-tools lint:fix")
7
+ }
@@ -0,0 +1,8 @@
1
+ // 릴리즈 빌드
2
+ // gleam run 시 Gleam 컴파일이 먼저 자동 수행됨
3
+
4
+ import scripts/cmd
5
+
6
+ pub fn main() {
7
+ cmd.exec("{{RUNNER}} pluggable-widgets-tools release:web")
8
+ }
@@ -0,0 +1,8 @@
1
+ // Mendix 테스트 프로젝트와 연동 개발
2
+ // gleam run 시 Gleam 컴파일이 먼저 자동 수행됨
3
+
4
+ import scripts/cmd
5
+
6
+ pub fn main() {
7
+ cmd.exec("{{RUNNER}} pluggable-widgets-tools start:server")
8
+ }
@@ -0,0 +1,6 @@
1
+ /*
2
+ Place your custom CSS here
3
+ */
4
+ .widget-hello-world {
5
+
6
+ }
@@ -0,0 +1,20 @@
1
+ // Mendix Pluggable Widget - "Hello World"
2
+ // React 함수형 컴포넌트: fn(JsProps) -> ReactElement
3
+
4
+ // 외부 타입 (JS 값의 opaque 핸들)
5
+ pub type ReactElement
6
+
7
+ pub type JsProps
8
+
9
+ // FFI 바인딩
10
+ @external(javascript, "./{{SNAKE_CASE}}_ffi.mjs", "create_div")
11
+ fn create_div(class_name: String, text_content: String) -> ReactElement
12
+
13
+ @external(javascript, "./{{SNAKE_CASE}}_ffi.mjs", "get_string_prop")
14
+ fn get_string_prop(props: JsProps, key: String) -> String
15
+
16
+ /// 위젯 메인 함수 - Mendix 런타임이 React 컴포넌트로 호출
17
+ pub fn widget(props: JsProps) -> ReactElement {
18
+ let sample_text = get_string_prop(props, "sampleText")
19
+ create_div("widget-hello-world", "Hello " <> sample_text)
20
+ }
@@ -0,0 +1,13 @@
1
+ // React FFI 어댑터 - React 원시 함수만 노출
2
+ import * as React from "react";
3
+
4
+ // div 요소에 텍스트 자식을 렌더링
5
+ export function create_div(class_name, text_content) {
6
+ return React.createElement("div", { className: class_name }, text_content);
7
+ }
8
+
9
+ // props 객체에서 문자열 속성값 추출
10
+ export function get_string_prop(props, key) {
11
+ const value = props[key];
12
+ return value !== undefined && value !== null ? String(value) : "";
13
+ }
@@ -0,0 +1,18 @@
1
+ // Mendix Studio Pro 속성 패널 설정
2
+ // getProperties, check, getPreview 등을 정의
3
+
4
+ // 외부 타입 (Mendix가 전달하는 JS 객체)
5
+ pub type Values
6
+
7
+ pub type Properties
8
+
9
+ pub type Target
10
+
11
+ /// 속성 패널 설정 - Studio Pro에서 위젯 속성의 가시성을 제어
12
+ pub fn get_properties(
13
+ _values: Values,
14
+ default_properties: Properties,
15
+ _target: Target,
16
+ ) -> Properties {
17
+ default_properties
18
+ }