UNPKG

@lifeart/gxt

Version:

<img align="right" width="95" height="95" alt="Philosopher’s stone, logo of PostCSS" src="./public/logo.png">

2 lines (1 loc) • 6.9 kB
function e(e){null!==D()&&function(e){let t=ae.get(e);return void 0===t&&(t=W(0,void 0),ae.set(e,t)),t}(e).value}function t(e){const t=ae.get(e);void 0!==t&&t.update(t.value+1)}function o(){const o=globalThis;Object.entries(le).forEach(([e,t])=>{o[e]=t}),o.$SLOTS_SYMBOL=k,o.$PROPS_SYMBOL=V,o.$args="args",o.__gxtCellFor=z,o.__gxtFormula=B,o.__gxtCell=W,o.__gxtEffect=U,o.__gxtSyncDom=Y,o.__gxtClearTagsToRevalidate=()=>Z.clear(),o.__gxtCellsMap=X,function(){if(ie)return;ie=!0;const o=Map.prototype.set,r=Map.prototype.delete,n=Map.prototype.clear;Map.prototype.set=function(e,r){const n=o.call(this,e,r);return t(this),n},Map.prototype.delete=function(e){const o=r.call(this,e);return o&&t(this),o},Map.prototype.clear=function(){const e=this.size>0;n.call(this),e&&t(this)};const s=Map.prototype.entries,a=Map.prototype.keys,i=Map.prototype.values,l=Map.prototype[Symbol.iterator];Map.prototype.entries=function(){return e(this),s.call(this)},Map.prototype.keys=function(){return e(this),a.call(this)},Map.prototype.values=function(){return e(this),i.call(this)},Map.prototype[Symbol.iterator]=function(){return e(this),l.call(this)};const c=Set.prototype.add,p=Set.prototype.delete,_=Set.prototype.clear,u=Set.prototype.entries,f=Set.prototype.keys,m=Set.prototype.values,d=Set.prototype.has,h=Set.prototype[Symbol.iterator];Set.prototype.add=function(e){const o=d.call(this,e),r=c.call(this,e);return o||t(this),r},Set.prototype.delete=function(e){const o=p.call(this,e);return o&&t(this),o},Set.prototype.clear=function(){const e=this.size>0;_.call(this),e&&t(this)},Set.prototype.entries=function(){return e(this),u.call(this)},Set.prototype.keys=function(){return e(this),f.call(this)},Set.prototype.values=function(){return e(this),m.call(this)},Set.prototype[Symbol.iterator]=function(){return e(this),h.call(this)}}(),o.__GXT_RUNTIME_INITIALIZED__=!0}function r(){return!0===globalThis.__GXT_RUNTIME_INITIALIZED__}function n(e,t={}){r()||o();const n={IS_GLIMMER_COMPAT_MODE:!0,WITH_EMBER_INTEGRATION:!0,WITH_HELPER_MANAGER:!0,WITH_MODIFIER_MANAGER:!0,WITH_CONTEXT_API:!0,TRY_CATCH_ERROR_HANDLING:!1,...t.flags},s={filename:t.moduleName||"runtime-template",bindings:t.bindings||/* @__PURE__ */new Set,flags:n},a=c(e,s);if(a.errors.length>0)return console.error("[gxt-runtime-compiler] Compilation errors:",a.errors),{templateFn:()=>[],code:a.code,errors:a.errors,warnings:a.warnings};let i;try{const e=t.scopeValues||{},o=Object.keys(e),r=Object.values(e),n=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/;for(const t of o)if(!n.test(t))throw Error(`[gxt-runtime-compiler] Invalid scope name: "${t}". Scope names must be valid JavaScript identifiers.`);const s=a.code.includes("$a."),l=a.code.includes(", $slots,")||a.code.includes(", $slots)"),c=a.code.includes(", $fw,")||a.code.includes(", $fw]")||a.code.includes("...$fw["),_=`\n "use strict";\n return function() {\n ${p.$_GET_ARGS}(this, arguments);\n ${s?"const $a = this[$args];":""}\n ${l?"const $slots = "+p.$_GET_SLOTS+"(this, arguments);":""}\n ${c?"const $fw = "+p.$_GET_FW+"(this, arguments);":""}\n return ${a.code};\n };\n `;i=Function(...o,_)(...r)}catch(l){return console.error("[gxt-runtime-compiler] Failed to create template function:",l),console.error("[gxt-runtime-compiler] Generated code:",a.code),{templateFn:()=>[],code:a.code,errors:[{message:"Failed to create template function: "+l.message,code:"RUNTIME_EVAL_ERROR"}],warnings:a.warnings}}return{templateFn:i,code:a.code,errors:a.errors,warnings:a.warnings}}function s(e,t={}){const o=n(e,t);if(o.errors.length>0){const e=o.errors.map(e=>e.message).join("\n");throw Error("Template compilation failed:\n"+e)}return o.templateFn}function a(e,t={}){function o(t){const o=t.bindings,r=t.scopeValues;return{...i,...t,bindings:o?/* @__PURE__ */new Set([...c,...o]):new Set(c),scopeValues:r?{...e,...r}:e}}function r(e,t={}){const r=n(e,o(t));if((t.throwOnError??s)&&r.errors.length>0){const e=r.errors.map(e=>e.message).join("\n");throw Error("Template compilation failed:\n"+e)}return r.templateFn}const{throwOnError:s=!0,...i}=t,l=Object.keys(e),c=i.bindings?[...i.bindings,...l]:l,p=Object.freeze({...e});return r.withMeta=function(e,t={}){return n(e,o(t))},Object.defineProperty(r,"scope",{value:p,writable:!1,enumerable:!0}),r.extend=function(o){return a({...e,...o},t)},r}function i(e,t={}){const o=n(e,t),r=t.moduleName||"runtime-template";return{__gxtCompiled:!0,__gxtRuntimeCompiled:!0,moduleName:r,render(e,t){if(o.errors.length>0)return console.error(`[gxt-runtime] Compilation errors for ${r}:`,o.errors),{nodes:[],ctx:e};try{const r=o.templateFn.call(e);if(t&&Array.isArray(r))for(const e of r)if(e instanceof Node)t.appendChild(e);else if(e&&"object"==typeof e&&"$nodes"in e)for(const o of e.$nodes||[])o instanceof Node&&t.appendChild(o);return{nodes:Array.isArray(r)?r:[],ctx:e}}catch(n){return console.error(`[gxt-runtime] Render error for ${r}:`,n),{nodes:[],ctx:e}}}}}function l(e,t){function o(e,t){if(this){p&&(this.$_eval=p);const e=globalThis.$_eval;globalThis.$_eval=p;try{return m(c.call(this),this)}finally{globalThis.$_eval=e}}return{[ce]:o,[pe]:e||{},$_eval:p}}const{scope:r,eval:s,...a}=t||{},i=r?Object.keys(r):[],l=n(e,{...a,scopeValues:r?{...a.scopeValues,...r}:a.scopeValues,bindings:i.length>0?/* @__PURE__ */new Set([...a.bindings||[],...i]):a.bindings,flags:{IS_GLIMMER_COMPAT_MODE:!0,...a.flags,...s?{WITH_EVAL_SUPPORT:!0}:{}}});if(l.errors.length>0){const e=l.errors.map(e=>e.message).join("\n");throw Error("Template compilation failed:\n"+e)}const c=l.templateFn,p=s;return o.prototype=void 0,o.__templateOnly=!0,o}import{c}from"./compile-CP5JuT5D.js";import{S as p}from"./symbols-CMiKXAxp.js";export{C as CONSTANTS,E as EVENT_TYPE}from"./symbols-CMiKXAxp.js";import{h as _,i as u,f,u as m,G as d,A as h,C as $,B as g,v as y,w as T,y as S,D as M,o as b,c as O,b as v,e as I,j as w,p as A,k as R,l as x,s as N,E as j,r as G,q as F,z as L,m as P,F as H,a as k,$ as V}from"./dom-BiflCx2O.js";import{j as D,e as W,f as z,i as B,h as U,m as Y,o as Z,p as X}from"./vm-CFZXVoe9.js";import{$ as q,i as J,d as K,e as Q,a as ee,g as te,b as oe,h as re,c as ne,f as se}from"./and-JxXfJ1c1.js";const ae=/* @__PURE__ */new WeakMap;let ie=!1;const le={$_tag:H,$_c:P,$_if:L,$_each:F,$_eachSync:G,$_slot:j,$_edp:N,$_args:x,$_api:R,$_dc:A,$_TO_VALUE:w,$_GET_SLOTS:I,$_GET_ARGS:v,$_GET_FW:O,$_componentHelper:b,$_modifierHelper:M,$_helperHelper:S,$_hasBlockParams:T,$_hasBlock:y,$_maybeHelper:g,$_maybeModifier:$,$_inElement:h,$_ucw:d,$_fin:m,$__if:se,$__eq:ne,$__not:re,$__debugger:oe,$__log:te,$__array:ee,$__hash:Q,$__fn:K,$__or:J,$__and:q,$_HTMLProvider:f,$_SVGProvider:u,$_MathMLProvider:_},ce="template",pe="args";export{le as GXT_RUNTIME_SYMBOLS,p as SYMBOLS,s as compile,n as compileTemplate,a as createCompiler,i as createTemplateFactory,r as isGlobalScopeReady,o as setupGlobalScope,l as template};