112 lines
2.6 KiB
Plaintext
112 lines
2.6 KiB
Plaintext
{% import "github.com/delaneyj/toolbelt" %}
|
|
|
|
{%- func datastarClientConsts(data *ConstTemplateData) -%}
|
|
// {%s data.DoNotEdit %}
|
|
const lol = /🖕JS_DS🚀/.source
|
|
export const DSP = lol.slice(0, 5)
|
|
export const DSS = lol.slice(4)
|
|
|
|
export const DATASTAR = "{%s data.DatastarKey %}";
|
|
export const DATASTAR_REQUEST = "{%s toolbelt.Pascal( data.DatastarKey) %}-Request";
|
|
|
|
// #region Defaults
|
|
|
|
// #region Default durations
|
|
|
|
{%- for _, d := range data.DefaultDurations -%}
|
|
// {%s= d.Description %}
|
|
export const Default{%s d.Name.Pascal %}Ms = {%d durationToMs(d.Duration) %};
|
|
{%- endfor -%}
|
|
|
|
// #endregion
|
|
|
|
|
|
// #region Default strings
|
|
|
|
{%- for _, s := range data.DefaultStrings -%}
|
|
// {%s= s.Description %}
|
|
export const Default{%s s.Name.Pascal %} = "{%s s.Value %}";
|
|
{%- endfor -%}
|
|
|
|
// #endregion
|
|
|
|
|
|
// #region Default booleans
|
|
|
|
{%- for _, b := range data.DefaultBools -%}
|
|
// {%s= b.Description %}
|
|
export const Default{%s b.Name.Pascal %} = {%v b.Value %};
|
|
|
|
{%- endfor -%}
|
|
// #endregion
|
|
|
|
|
|
// #region Enums
|
|
|
|
{%- for _, enum := range data.Enums -%}
|
|
// {%s= enum.Description %}
|
|
export const {%s enum.Name.Pascal %}s = {
|
|
{%- for _, entry := range enum.Values -%}
|
|
// {%s= entry.Description %}
|
|
{%s entry.Name.Pascal %}: "{%s entry.Value %}",
|
|
{%- endfor -%}
|
|
} as const;
|
|
{%- if enum.Default != nil -%}
|
|
|
|
// Default value for {%s enum.Name.Pascal %}
|
|
export const Default{%s enum.Name.Pascal %} = {%s enum.Name.Pascal %}s.{%s enum.Default.Name.Pascal %};
|
|
|
|
{%- endif -%}
|
|
{%- endfor -%}
|
|
// #endregion
|
|
|
|
// #endregion
|
|
{%- endfunc -%}
|
|
|
|
{%- func datastarClientPackageJSON(data *ConstTemplateData) -%}
|
|
{
|
|
"name": "@starfederation/datastar",
|
|
"author": "Delaney Gillilan",
|
|
"description": "The hypermedia framework.",
|
|
"version": "{%s data.Version %}",
|
|
"license": "MIT",
|
|
"private": false,
|
|
"homepage": "https://data-star.dev",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "git+https://github.com/starfederation/datastar.git"
|
|
},
|
|
"bugs": {
|
|
"url": "https://github.com/starfederation/datastar/issues"
|
|
},
|
|
"files": [
|
|
"dist"
|
|
],
|
|
"module": "dist/index.js",
|
|
"types": "dist/index.d.ts",
|
|
"exports": {
|
|
".": {
|
|
"import": "./dist/index.js",
|
|
"types": "./dist/index.d.ts"
|
|
},
|
|
"./plugins": {
|
|
"import": "./dist/plugins/index.js",
|
|
"types": "./dist/plugins/index.d.ts"
|
|
},
|
|
"./types": {
|
|
"import": "./dist/engine/types.js",
|
|
"types": "./dist/engine/types.d.ts"
|
|
},
|
|
"./bundles/*": {
|
|
"import": "./dist/bundles/*.js",
|
|
"types": "./dist/bundles/*.d.ts"
|
|
}
|
|
},
|
|
"scripts": {
|
|
"build": "tsc"
|
|
},
|
|
"devDependencies": {
|
|
"typescript": "^5.6.3"
|
|
}
|
|
}
|
|
{%- endfunc -%} |