@blotch/angular-lynx 22.2.1 → 22.2.2

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,58 +2,135 @@
2
2
  "$schema": "http://json-schema.org/draft-07/schema",
3
3
  "$id": "SchematicsAngularLynxComponent",
4
4
  "title": "AngularLynx component schematic",
5
+ "description": "Generates a component with Angular's component schematic, then makes it a Lynx one: its template uses Lynx elements and it imports LYNX_ELEMENTS. The options are Angular's (a test keeps them in step); left out, they take the defaults angular.json sets for @schematics/angular:component, then Angular's.",
5
6
  "type": "object",
6
7
  "additionalProperties": false,
7
- "description": "Generates a standalone Angular component with Lynx element template.",
8
8
  "properties": {
9
- "name": {
10
- "type": "string",
11
- "description": "The name of the component.",
12
- "$default": {
13
- "$source": "argv",
14
- "index": 0
15
- },
16
- "x-prompt": "What name would you like to use for the component?"
17
- },
18
9
  "path": {
19
10
  "type": "string",
20
11
  "format": "path",
21
- "description": "The path at which to create the component, relative to the source root.",
12
+ "$default": {
13
+ "$source": "workingDirectory"
14
+ },
15
+ "description": "The path where the component files should be created, relative to the current workspace. If not provided, a folder with the same name as the component will be created in the project's `src/app` directory.",
22
16
  "visible": false
23
17
  },
24
18
  "project": {
25
19
  "type": "string",
26
- "description": "The name of the project.",
20
+ "description": "The name of the project where the component should be added. If not specified, the CLI will determine the project from the current directory.",
27
21
  "$default": {
28
22
  "$source": "projectName"
29
23
  }
30
24
  },
31
- "prefix": {
25
+ "name": {
32
26
  "type": "string",
33
- "description": "The selector prefix to use. Defaults to the project prefix from angular.json."
27
+ "description": "The name for the new component. This will be used to create the component's class, template, and stylesheet files. For example, if you provide `my-component`, the files will be named `my-component.ts`, `my-component.html`, and `my-component.css`.",
28
+ "$default": {
29
+ "$source": "argv",
30
+ "index": 0
31
+ },
32
+ "x-prompt": "What name would you like to use for the component?"
33
+ },
34
+ "displayBlock": {
35
+ "description": "Adds `:host { display: block; }` to the component's stylesheet, ensuring the component renders as a block-level element. This is useful for layout purposes.",
36
+ "type": "boolean",
37
+ "alias": "b"
34
38
  },
35
39
  "inlineStyle": {
40
+ "description": "Include the component's styles directly in the `component.ts` file. By default, a separate stylesheet file (e.g., `my-component.css`) is created.",
36
41
  "type": "boolean",
37
- "description": "Include styles inline in the component.ts file.",
38
- "default": true,
39
- "alias": "s"
42
+ "alias": "s",
43
+ "x-user-analytics": "ep.ng_inline_style"
40
44
  },
41
45
  "inlineTemplate": {
46
+ "description": "Include the component's HTML template directly in the `component.ts` file. By default, a separate template file (e.g., `my-component.html`) is created.",
47
+ "type": "boolean",
48
+ "alias": "t",
49
+ "x-user-analytics": "ep.ng_inline_template"
50
+ },
51
+ "standalone": {
52
+ "description": "Generate a standalone component. Standalone components are self-contained and don't need to be declared in an NgModule. They can be used independently or imported directly into other standalone components.",
53
+ "type": "boolean",
54
+ "x-user-analytics": "ep.ng_standalone"
55
+ },
56
+ "viewEncapsulation": {
57
+ "description": "Sets the view encapsulation mode for the component. This determines how the component's styles are scoped and applied.",
58
+ "enum": ["Emulated", "None", "ShadowDom"],
59
+ "type": "string",
60
+ "alias": "v"
61
+ },
62
+ "changeDetection": {
63
+ "description": "Configures the change detection strategy for the component.",
64
+ "enum": ["Eager", "OnPush"],
65
+ "type": "string",
66
+ "alias": "c"
67
+ },
68
+ "prefix": {
69
+ "type": "string",
70
+ "description": "A prefix to be added to the component's selector. For example, if the prefix is `app` and the component name is `my-component`, the selector will be `app-my-component`.",
71
+ "alias": "p",
72
+ "oneOf": [
73
+ {
74
+ "maxLength": 0
75
+ },
76
+ {
77
+ "minLength": 1,
78
+ "format": "html-selector"
79
+ }
80
+ ]
81
+ },
82
+ "style": {
83
+ "description": "Specify the type of stylesheet to be created for the component, or `none` to skip creating a stylesheet.",
84
+ "type": "string",
85
+ "enum": ["css", "scss", "sass", "less", "none"],
86
+ "x-user-analytics": "ep.ng_style"
87
+ },
88
+ "type": {
89
+ "type": "string",
90
+ "description": "Append a custom type to the component's filename. For example, if you set the type to `container`, the file will be named `my-component.container.ts`."
91
+ },
92
+ "addTypeToClassName": {
42
93
  "type": "boolean",
43
- "description": "Include template inline in the component.ts file.",
44
- "default": true,
45
- "alias": "t"
94
+ "description": "When true, the 'type' option will be appended to the generated class name. When false, only the file name will include the type."
46
95
  },
47
96
  "skipTests": {
48
97
  "type": "boolean",
49
- "description": "Do not generate a spec file.",
50
- "default": false
98
+ "description": "Skip the generation of unit test files `spec.ts`."
51
99
  },
52
100
  "flat": {
53
101
  "type": "boolean",
54
- "description": "Create the component files at the top level of the path, without a subdirectory.",
55
- "default": false
102
+ "description": "Create the component files directly in the project's `src/app` directory instead of creating a new folder for them."
103
+ },
104
+ "skipImport": {
105
+ "type": "boolean",
106
+ "description": "Do not automatically import the new component into its closest NgModule."
107
+ },
108
+ "selector": {
109
+ "type": "string",
110
+ "format": "html-selector",
111
+ "description": "The HTML selector to use for this component. If not provided, a selector will be generated based on the component name (e.g., `app-my-component`)."
112
+ },
113
+ "skipSelector": {
114
+ "type": "boolean",
115
+ "description": "Skip the generation of an HTML selector for the component."
116
+ },
117
+ "module": {
118
+ "type": "string",
119
+ "description": "Specify the NgModule where the component should be declared. If not provided, the CLI will attempt to find the closest NgModule in the component's path.",
120
+ "alias": "m"
121
+ },
122
+ "export": {
123
+ "type": "boolean",
124
+ "description": "Automatically export the component from the specified NgModule, making it accessible to other modules in the application."
125
+ },
126
+ "exportDefault": {
127
+ "type": "boolean",
128
+ "description": "Use a default export for the component in its TypeScript file instead of a named export."
129
+ },
130
+ "ngHtml": {
131
+ "type": "boolean",
132
+ "description": "Generate component template files with an '.ng.html' file extension instead of '.html'."
56
133
  }
57
134
  },
58
- "required": ["name"]
135
+ "required": ["name", "project"]
59
136
  }
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const workspace_1 = require("@schematics/angular/utility/workspace");
6
+ const node_fs_1 = require("node:fs");
7
+ const node_module_1 = require("node:module");
8
+ const node_path_1 = tslib_1.__importDefault(require("node:path"));
9
+ const node_url_1 = require("node:url");
10
+ /**
11
+ * A real dynamic import. The schematics compile to CommonJS, where TypeScript
12
+ * rewrites `import()` into `require()`, and the native builder is ESM-only
13
+ * (the same reason Angular CLI keeps its own `loadEsmModule`).
14
+ */
15
+ const importEsm = new Function('specifier', 'return import(specifier)');
16
+ /**
17
+ * Loads the native builder that `ng build --platform` uses, so the ejected
18
+ * project is exactly the one it would have generated. It is a dependency of
19
+ * @blotch/angular-lynx-build rather than of the app, so it is resolved from
20
+ * there: pnpm doesn't link it into the app's own node_modules.
21
+ */
22
+ const loadNative = async (workspaceRoot) => {
23
+ const fromApp = (0, node_module_1.createRequire)(node_path_1.default.join(workspaceRoot, 'package.json'));
24
+ let buildersPackageJson;
25
+ try {
26
+ buildersPackageJson = (0, node_fs_1.realpathSync)(fromApp.resolve('@blotch/angular-lynx-build/package.json'));
27
+ }
28
+ catch {
29
+ throw new schematics_1.SchematicsException('@blotch/angular-lynx-build is not installed. Install it first: npm install --save-dev @blotch/angular-lynx-build');
30
+ }
31
+ const packageJsonPath = (0, node_module_1.createRequire)(buildersPackageJson).resolve('@blotch/angular-lynx-native/package.json');
32
+ const entry = JSON.parse((0, node_fs_1.readFileSync)(packageJsonPath, 'utf8')).exports['.']
33
+ .import;
34
+ return (await importEsm((0, node_url_1.pathToFileURL)(node_path_1.default.join(node_path_1.default.dirname(packageJsonPath), entry)).href));
35
+ };
36
+ /**
37
+ * `ng generate @blotch/angular-lynx:eject`: writes the native projects that
38
+ * `ng build --platform` generates into `ios/` and `android/`, for apps that
39
+ * need native changes the builder options don't cover. The builder then
40
+ * builds those folders as they are.
41
+ *
42
+ * One-way on purpose, like Expo's bare workflow: once a project is ejected,
43
+ * keeping it in step with Lynx, Xcode and Google Play is the app's job.
44
+ */
45
+ exports.default = (options) => async (tree, context) => {
46
+ const workspace = await (0, workspace_1.getWorkspace)(tree);
47
+ const projectName = options.project ?? [...workspace.projects.keys()][0];
48
+ const project = projectName
49
+ ? workspace.projects.get(projectName)
50
+ : undefined;
51
+ if (!projectName || !project) {
52
+ throw new schematics_1.SchematicsException(`Project "${options.project ?? ''}" not found in angular.json.`);
53
+ }
54
+ const projectRoot = project.root;
55
+ const platforms = !options.platform || options.platform === 'all'
56
+ ? ['ios', 'android']
57
+ : [options.platform];
58
+ for (const platform of platforms) {
59
+ const dir = node_path_1.default.posix.join(projectRoot || '', platform);
60
+ if (tree.getDir(dir).subfiles.length > 0 ||
61
+ tree.getDir(dir).subdirs.length > 0) {
62
+ throw new schematics_1.SchematicsException(`${dir}/ already exists. Delete it first to eject ${platform} again.`);
63
+ }
64
+ }
65
+ // The schematic runs from the workspace root, where Angular CLI resolved
66
+ // this package too.
67
+ const workspaceRoot = process.cwd();
68
+ const native = await loadNative(workspaceRoot);
69
+ const app = (project.targets.get('build')?.options ?? {});
70
+ const packageVersion = tree.exists('/package.json')
71
+ ? JSON.parse(tree.readText('/package.json')).version
72
+ : undefined;
73
+ for (const platform of platforms) {
74
+ const files = native.renderEjectedProject({
75
+ platform,
76
+ projectRoot: node_path_1.default.join(workspaceRoot, projectRoot),
77
+ projectName,
78
+ packageVersion,
79
+ app,
80
+ generatorVersion: native.PACKAGE_VERSION,
81
+ });
82
+ for (const [file, content] of files) {
83
+ tree.create(node_path_1.default.posix.join(projectRoot || '', platform, file), content);
84
+ }
85
+ context.logger.info(`Ejected ${platform}/. \`ng build --platform ${platform}\` now builds it as it is: edit it freely, but angular.json app options no longer apply to it, and Lynx, Xcode and Google Play upgrades are yours to make.`);
86
+ }
87
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,24 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "SchematicsAngularLynxEject",
4
+ "title": "AngularLynx eject schematic",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "description": "Writes the generated iOS and Android projects into ios/ and android/, where you own and edit them. One-way: angular.json app options stop applying to an ejected project.",
8
+ "properties": {
9
+ "project": {
10
+ "type": "string",
11
+ "description": "The project to eject.",
12
+ "$default": {
13
+ "$source": "projectName"
14
+ }
15
+ },
16
+ "platform": {
17
+ "type": "string",
18
+ "enum": ["ios", "android", "all"],
19
+ "default": "all",
20
+ "description": "Which native project to eject."
21
+ }
22
+ },
23
+ "required": []
24
+ }
@@ -1 +1 @@
1
- /// <reference types="@lynx-js/rspeedy/client" />
1
+ /// <reference types="@blotch/angular-lynx-build/client" />
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "../node_modules/@angular-devkit/schematics/collection-schema.json",
3
+ "schematics": {}
4
+ }