{"_id":"@cather/kwc-template-compiler","name":"@cather/kwc-template-compiler","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"//":["THIS FILE IS AUTOGENERATED. If you modify it, it will be rewritten by check-and-rewrite-package-json.js","You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."],"name":"@cather/kwc-template-compiler","version":"1.0.0","description":"Template compiler package","keywords":["kwc"],"homepage":"https://kwc.dev","repository":{"type":"git","url":"git+https://github.com/kingdee/kwc.git","directory":"packages/@kwc/template-compiler"},"bugs":{"url":"https://github.com/kingdee/kwc/issues"},"license":"MIT","publishConfig":{"access":"public"},"volta":{"extends":"../../../package.json"},"main":"dist/index.cjs.js","module":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"rollup --config ../../../scripts/rollup/rollup.config.js","dev":"rollup  --config ../../../scripts/rollup/rollup.config.js --watch --no-watch.clearScreen"},"nx":{"targets":{"build":{"outputs":["{projectRoot}/dist"]}}},"dependencies":{"@cather/kwc-errors":"1.0.0","@cather/kwc-shared":"1.0.0","acorn":"~8.15.0","astring":"~1.9.0","he":"~1.2.0"},"devDependencies":{"@parse5/tools":"^0.7.0","@types/estree":"^1.0.8","@types/he":"^1.2.3","estree-walker":"~3.0.3","parse5":"^8.0.0"},"_id":"@cather/kwc-template-compiler@1.0.0","_nodeVersion":"20.19.4","_npmVersion":"10.8.2","dist":{"integrity":"sha512-KNC02/QuaYFM52hcRW+h82KZZ0b/hbdcOloWTMsA+7xmArS3rTJ9Qa8Dc9xaW1GxNVGzdeyuH5C2AagUu6l/kA==","shasum":"fdd63e00f30f888e381e3ebe1433c0ce15f7655e","tarball":"https://registry.npmjs.org/@cather/kwc-template-compiler/-/kwc-template-compiler-1.0.0.tgz","fileCount":39,"unpackedSize":1254851,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIGVeWNahDIF6dvPtdLMbwJ7iwudkiIes3PtkuCvVAIgLAiBR2eTNq31m7XaObfxQrWu8rgM1A+jtN0eTJeEaK8V6tA=="}]},"_npmUser":{"name":"catherine2020","email":"303673522@qq.com"},"directories":{},"maintainers":[{"name":"catherine2020","email":"303673522@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/kwc-template-compiler_1.0.0_1755878665055_0.3836416955790949"},"_hasShrinkwrap":false}},"time":{"created":"2025-08-22T16:04:24.942Z","1.0.0":"2025-08-22T16:04:25.320Z","modified":"2025-08-22T16:04:25.619Z"},"maintainers":[{"name":"catherine2020","email":"303673522@qq.com"}],"description":"Template compiler package","homepage":"https://kwc.dev","keywords":["kwc"],"repository":{"type":"git","url":"git+https://github.com/kingdee/kwc.git","directory":"packages/@kwc/template-compiler"},"bugs":{"url":"https://github.com/kingdee/kwc/issues"},"license":"MIT","readme":"# @cather/kwc-template-compiler\n\nCompile KWC HTML template for consumption at runtime.\n\n## Installation\n\n```sh\nyarn add --dev @cather/kwc-template-compiler\n```\n\n## Usage\n\n```js\nimport { compile } from '@cather/kwc-template-compiler';\n\nconst filename = 'component.html';\nconst options = {};\nconst { code, warnings } = compile(\n    `\n    <template>\n        <h1>Hello World!</h1>\n    </template>\n`,\n    filename,\n    options\n);\n\nfor (let warning of warnings) {\n    console.log(warning.message);\n}\n\nconsole.log(code);\n```\n\n## APIs\n\n### `compile`\n\nCompile a KWC template to javascript source code consumable by the engine.\n\n```js\nimport { compile } from '@cather/kwc-template-compiler';\nconst { code, warnings } = compile(`<template><h1>Hello World!</h1></template>`, {});\n```\n\n**Parameters:**\n\n- `source` (string, required) - the HTML template source to compile.\n- `filename` (string, required) - the source filename with extension.\n- `options` (object, required) - the options to used to compile the HTML template source.\n\n**Options:**\n\n- `name` (type: `string`, optional, `undefined` by default) - name of the component, e.g. `foo` in `x/foo`.\n- `namespace` (type: `string`, optional, `undefined` by default) - namespace of the component, e.g. `x` in `x/foo`.\n- `experimentalComputedMemberExpression` (boolean, optional, `false` by default) - set to `true` to enable computed member expression in the template, eg: `{list[0].name}`.\n- `experimentalComplexExpressions` (boolean, optional, `false` by default) - set to `true` to enable use of (a subset of) JavaScript expressions in place of template bindings.\n- `experimentalDynamicDirective` (boolean, optional, `false` by default) - set to `true` to allow the usage of `kwc:dynamic` directives in the template.\n- `enableDynamicComponents` (boolean, optional, `false` by default) - set to `true` to enable `kwc:is` directive in the template.\n- `preserveHtmlComments` (boolean, optional, `false` by default) - set to `true` to disable the default behavior of stripping HTML comments.\n- `enableStaticContentOptimization` (boolean, optional, `true` by default) - set to `false` to disable static content optimizations.\n- `enableKwcSpread` (boolean, optional, `true` by default) - Deprecated. Ignored by template-compiler. `kwc:spread` is always enabled.\n- `enableKwcOn` (boolean, optional, `false` by default) - set to `true` to enable `kwc:on` directive in the template.\n- `customRendererConfig` (CustomRendererConfig, optional) - specifies a configuration to use to match elements. Matched elements will get a custom renderer hook in the generated template.\n- `instrumentation` (InstrumentationObject, optional) - instrumentation object to gather metrics and non-error logs for internal use. See the `@cather/kwc-errors` package for details on the interface.\n- `disableSyntheticShadowSupport` (type: `boolean`, default: `false`) - Set to true if synthetic shadow DOM support is not needed, which can result in smaller/faster output.\n    - Example 1: Config to match `<use>` elements under the `svg` namespace and have `href` attribute set.\n\n        ```\n        {\n            customRendererConfig: {\n                directives: [],\n                elements: [\n                    {\n                        tagName: 'use',\n                        namespace: 'http://www.w3.org/2000/svg',\n                        attributes: ['href']\n                    }\n                ]\n            }\n        }\n        ```\n\n    - Example 2: Config to match `<script>` elements regardless of the attribute set. _Note:_ When `attributes` is not specified, attribute matching is skipped.\n        ```\n        {\n            customRendererConfig: {\n                directives: [],\n                elements: [\n                    {\n                        tagName: 'script'\n                    }\n                ]\n            }\n        }\n        ```\n\n- `apiVersion` (type: `number`, optional) - API version to associate with the compiled template.\n\n**Return:**\nThe method returns an object with the following fields:\n\n- `code` (string) - the compiled template.\n- `warnings` (array) - the list of warnings produced when compiling the template. Each warning has the following fields:\n    - message (string) - the warning message.\n    - level (string) - the severity of the warning: `info`, `warning`, `error`.\n    - start (number) - the start index in the source code producing the warning.\n    - length (number) - the character length in the source code producing the warning.\n","readmeFilename":"README.md","_rev":"1-f3199c7db5045ec2394f38f19efcbda4"}