@public-ui/kolibri-cli 4.0.0-alpha.7 → 4.0.0-alpha.9

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.
@@ -2,11 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.v4Tasks = void 0;
4
4
  const id_1 = require("./id");
5
+ const link_1 = require("./link");
5
6
  const loader_1 = require("./loader");
6
7
  const msg_1 = require("./msg");
7
8
  const toast_1 = require("./toast");
8
9
  const toaster_1 = require("./toaster");
9
10
  exports.v4Tasks = [];
11
+ exports.v4Tasks.push(...link_1.MapVariantStandaloneToInlineTasks);
10
12
  exports.v4Tasks.push(...id_1.RemoveIdPropTasks);
11
13
  exports.v4Tasks.push(...msg_1.RemoveMsgPropsTasks);
12
14
  exports.v4Tasks.push(toast_1.RemoveToastVariantTask.getInstance('^4'));
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.MapVariantStandaloneToInlineTasks = exports.MapLinkVariantStandaloneToInlineTask = exports.MapButtonLinkVariantStandaloneToInlineTask = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const types_1 = require("../../../../types");
9
+ const reuse_1 = require("../../../shares/reuse");
10
+ const abstract_task_1 = require("../../abstract-task");
11
+ class MapVariantStandaloneToInlineTask extends abstract_task_1.AbstractTask {
12
+ tag;
13
+ tagCapitalCase;
14
+ variantStandaloneRegExp = /\s_variant\s*=\s*(\{["'`]standalone["'`]\}|["'`]standalone["'`])/;
15
+ constructor(identifier, tag, versionRange, dependentTasks, options) {
16
+ super(identifier, `Map "_variant=standalone" to "_inline" for "${tag}"`, types_1.MARKUP_EXTENSIONS, versionRange, dependentTasks, options);
17
+ this.tag = tag;
18
+ this.tagCapitalCase = (0, reuse_1.kebabToCapitalCase)(tag);
19
+ }
20
+ static getInstance(tag, versionRange, dependentTasks, options) {
21
+ const identifier = `${tag}-map-variant-standalone-to-inline`;
22
+ if (!this.instances.has(identifier)) {
23
+ this.instances.set(identifier, new MapVariantStandaloneToInlineTask(identifier, tag, versionRange, dependentTasks, options));
24
+ }
25
+ return this.instances.get(identifier);
26
+ }
27
+ run(baseDir) {
28
+ this.transpileComponentFiles(baseDir);
29
+ this.transpileCustomElementFiles(baseDir);
30
+ }
31
+ transpileComponentFiles(baseDir) {
32
+ const tagRegExp = new RegExp(`<${this.tagCapitalCase}[^>]*_variant[^>]*>`, 'g');
33
+ (0, reuse_1.filterFilesByExt)(baseDir, types_1.COMPONENT_FILE_EXTENSIONS).forEach((file) => {
34
+ const content = fs_1.default.readFileSync(file, 'utf8');
35
+ const newContent = content.replace(tagRegExp, (componentTag) => this.rewriteTag(componentTag, true));
36
+ if (content !== newContent) {
37
+ reuse_1.MODIFIED_FILES.add(file);
38
+ fs_1.default.writeFileSync(file, newContent);
39
+ }
40
+ });
41
+ }
42
+ transpileCustomElementFiles(baseDir) {
43
+ const tagRegExp = new RegExp(`<${this.tag}[^>]*_variant[^>]*>`, 'g');
44
+ (0, reuse_1.filterFilesByExt)(baseDir, types_1.CUSTOM_ELEMENT_FILE_EXTENSIONS).forEach((file) => {
45
+ const content = fs_1.default.readFileSync(file, 'utf8');
46
+ const newContent = content.replace(tagRegExp, (componentTag) => this.rewriteTag(componentTag, false));
47
+ if (content !== newContent) {
48
+ reuse_1.MODIFIED_FILES.add(file);
49
+ fs_1.default.writeFileSync(file, newContent);
50
+ }
51
+ });
52
+ }
53
+ rewriteTag(componentTag, isComponent) {
54
+ if (!this.variantStandaloneRegExp.test(componentTag)) {
55
+ return componentTag;
56
+ }
57
+ const inlineReplacement = isComponent ? ' _inline={false}' : ' _inline="false"';
58
+ if (/\s_inline\s*=/.test(componentTag)) {
59
+ return componentTag.replace(this.variantStandaloneRegExp, '');
60
+ }
61
+ return componentTag.replace(this.variantStandaloneRegExp, inlineReplacement);
62
+ }
63
+ }
64
+ exports.MapButtonLinkVariantStandaloneToInlineTask = MapVariantStandaloneToInlineTask.getInstance('kol-button-link', '^4');
65
+ exports.MapLinkVariantStandaloneToInlineTask = MapVariantStandaloneToInlineTask.getInstance('kol-link', '^4');
66
+ exports.MapVariantStandaloneToInlineTasks = [exports.MapButtonLinkVariantStandaloneToInlineTask, exports.MapLinkVariantStandaloneToInlineTask];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@public-ui/kolibri-cli",
3
- "version": "4.0.0-alpha.7",
3
+ "version": "4.0.0-alpha.9",
4
4
  "license": "EUPL-1.2",
5
5
  "homepage": "https://public-ui.github.io",
6
6
  "repository": {
@@ -26,7 +26,7 @@
26
26
  "deepmerge": "4.3.1",
27
27
  "gradient-string": "3.0.0",
28
28
  "loglevel": "1.9.2",
29
- "prettier": "3.7.3",
29
+ "prettier": "3.7.4",
30
30
  "prettier-plugin-organize-imports": "4.3.0",
31
31
  "semver": "7.7.3",
32
32
  "typed-bem": "1.0.2"
@@ -50,7 +50,7 @@
50
50
  "rimraf": "6.1.2",
51
51
  "ts-node": "10.9.2",
52
52
  "typescript": "5.9.3",
53
- "@public-ui/components": "4.0.0-alpha.7"
53
+ "@public-ui/components": "4.0.0-alpha.9"
54
54
  },
55
55
  "files": [
56
56
  "dist"