@buoy-gg/angular 7.0.64 → 7.0.66
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.
package/README.md
CHANGED
|
@@ -265,7 +265,7 @@ The factory runs once in the app's DI context.
|
|
|
265
265
|
It can read the store with `inject(Store)` too.
|
|
266
266
|
Router, Query, Highlight, and NgRx still get their links.
|
|
267
267
|
The builder still loads each installed tool.
|
|
268
|
-
Custom `apps
|
|
268
|
+
Custom `apps` and a test broker work here too.
|
|
269
269
|
|
|
270
270
|
The merge rules are:
|
|
271
271
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const{createRequire}=require("node:module");const appRequire=createRequire(require("node:path").join(process.cwd(),"package.json"));const ts=appRequire("typescript");const path=require("node:path").posix;const catalog=require("./tools.json");const read=(r,e)=>{const o=ts.parseConfigFileTextToJson(e,r.readText(e));if(o.error)throw new Error(`Cannot read ${e}. Fix its JSON, then run ng add again.`);return o.config};const write=(r,e,o)=>{const
|
|
2
|
-
`+r.readText(e));return
|
|
1
|
+
const{createRequire}=require("node:module");const appRequire=createRequire(require("node:path").join(process.cwd(),"package.json"));const ts=appRequire("typescript");const path=require("node:path").posix;const catalog=require("./tools.json");const read=(r,e)=>{const o=ts.parseConfigFileTextToJson(e,r.readText(e));if(o.error)throw new Error(`Cannot read ${e}. Fix its JSON, then run ng add again.`);return o.config};const write=(r,e,o)=>{const a=JSON.stringify(o,null,2)+"\n";if(!r.exists(e))r.create(e,a);else if(r.readText(e)!==a)r.overwrite(e,a)};function select(r,e){const o=read(r,"/angular.json");const a=Object.keys(o.projects).filter(s=>o.projects[s].projectType==="application");const t=e.project||o.defaultProject||(a.length===1?a[0]:void 0);if(!t||!a.includes(t))throw new Error("Choose an app with --project <name>.");return{workspace:o,name:t,project:o.projects[t]}}function defaults(r){const e={...r.dependencies,...r.devDependencies};const o=["network","console","storage","events","env"];if(e["@angular/router"])o.push("route-events");if(Object.keys(e).some(a=>a.startsWith("@tanstack/angular-query-")))o.push("react-query");if(e["@ngrx/store"]||e["@ngxs/store"])o.push("redux");if(Number((e["@angular/core"]||"").match(/\d+/)?.[0])>=20)o.push("highlight-updates");return o.filter(a=>catalog.some(t=>t.id===a))}function ngAdd(r){return(e,o)=>{const{name:a}=select(e,r);const t=read(e,"/package.json");if(t.buoy?.angular?.[a])return e;r={...r};if(!r.tools?.length)delete r.tools;const s=o.schematic.collection.createSchematic("setup",true);s.description.schemaJson=structuredClone(s.description.schemaJson);s.description.schemaJson.properties.tools.default=defaults(t);return s.call({...r,project:a},appRequire("rxjs").of(e),o)}}function source(r,e){return ts.createSourceFile(e,r.readText(e),ts.ScriptTarget.Latest,true)}function nodes(r,e){const o=[];const a=t=>{if(e(t))o.push(t);ts.forEachChild(t,a)};a(r);return o}function importName(r,e,o,a){const t=source(r,e);for(const l of t.statements)if(ts.isImportDeclaration(l)&&l.moduleSpecifier.text===o){const i=l.importClause?.namedBindings;if(i&&ts.isNamedImports(i)){for(const u of i.elements)if((u.propertyName||u.name).text===a)return u.name.text}}const s=new Set(nodes(t,ts.isIdentifier).map(l=>l.text));let n=a;while(s.has(n))n+="Buoy";r.overwrite(e,`import { ${a}${n!==a?" as "+n:""} } from '${o}';
|
|
2
|
+
`+r.readText(e));return n}function providerFile(r,e){const o=new Set;const a=t=>{if(o.has(t)||!r.exists(t))return;o.add(t);const s=source(r,t);if(nodes(s,n=>ts.isCallExpression(n)&&n.expression.getText(s)==="NgModule").length||nodes(s,n=>ts.isVariableDeclaration(n)&&n.name.getText(s)==="appConfig").length||nodes(s,n=>ts.isCallExpression(n)&&n.expression.getText(s)==="bootstrapApplication"&&n.arguments[1]&&ts.isObjectLiteralExpression(n.arguments[1])).length)return t;for(const n of s.statements)if(ts.isImportDeclaration(n)&&n.moduleSpecifier.text.startsWith(".")){const l=path.join(path.dirname(t),n.moduleSpecifier.text);for(const i of[l+".ts",path.join(l,"index.ts")]){const u=a(i);if(u)return u}}};return a(e)}function providers(r,e,o,a){const t=source(r,e);let s;const n=nodes(t,c=>ts.isCallExpression(c)&&c.expression.getText(t)==="NgModule")[0];if(n)s=n.arguments[0];else s=nodes(t,c=>ts.isVariableDeclaration(c)&&c.name.getText(t)==="appConfig")[0]?.initializer;if(!s)s=nodes(t,c=>ts.isCallExpression(c)&&c.expression.getText(t)==="bootstrapApplication")[0]?.arguments[1];if(!s||!ts.isObjectLiteralExpression(s))throw new Error(`Cannot find a provider list in ${e}. Add provideBuoy() last in your app's providers.`);const l=s.properties.find(c=>c.name?.getText(t)==="providers");const i=r.readText(e);if(!l){const c=s.getEnd()-1;r.overwrite(e,i.slice(0,c)+`${s.properties.length&&!s.properties.hasTrailingComma?",":""}
|
|
3
3
|
providers: [${o}]
|
|
4
|
-
`+i.slice(
|
|
4
|
+
`+i.slice(c));return}if(!ts.isArrayLiteralExpression(l.initializer))throw new Error(`The providers in ${e} use a shared value. Add provideBuoy() last in that list.`);const u=l.initializer;const d=u.elements.map(c=>c.getFullText(t).trim());const y=u.elements.findIndex(c=>nodes(c,v=>ts.isCallExpression(v)&&v.expression.getText(t)===a).length>0);const g=y<0?o:d.splice(y,1)[0];d.push(g);const x=i.includes("\r\n")?"\r\n":"\n";const p=c=>(i.slice(i.lastIndexOf("\n",c-1)+1,c).match(/^[ \t]*/)||[""])[0];const m=p(l.getStart(t));const b=u.elements[0];const h=b&&i.slice(u.getStart(t),b.getStart(t)).includes("\n")?p(b.getStart(t)):"";const $=(i.match(/^[ \t]+(?=\S)/m)||[" "])[0];const j=h||m+$;const T=u.elements.hasTrailingComma||/,\s*\n\s*[}\]]/.test(i);const k="["+x+d.map(c=>j+c).join(","+x)+(T?",":"")+x+m+"]";if(i.slice(u.getStart(t),u.getEnd())!==k)r.overwrite(e,i.slice(0,u.getStart(t))+k+i.slice(u.getEnd()))}function setup(r){return(e,o)=>{const{workspace:a,name:t,project:s}=select(e,r);const n=read(e,"/package.json");const l=[...new Set(r.tools??defaults(n))];for(const p of l)if(!catalog.some(m=>m.id===p))throw new Error(`Unknown Buoy tool: ${p}.`);const i=s.architect||s.targets;if(!i?.build)throw new Error("This app has no build target. Add Buoy by hand.");const u=["@angular/build:application","@buoy-gg/angular:application"].includes(i.build.builder)&&(!i.serve||["@angular/build:dev-server","@buoy-gg/angular:dev-server"].includes(i.serve.builder));const d=s.sourceRoot||path.join(s.root||"","src");const y=i.build.options?.browser||i.build.options?.main||path.join(d,"main.ts");const g=providerFile(e,y)||[path.join(d,"app/app.config.ts"),path.join(d,"app/app.module.ts"),path.join(d,"app/app-module.ts")].find(p=>e.exists(p));if(!g)throw new Error("Cannot find the app entry. Add provideBuoy() last in its providers.");const x=importName(e,g,"@buoy-gg/angular","provideBuoy");if(u){i.build.builder="@buoy-gg/angular:application";if(i.serve)i.serve.builder="@buoy-gg/angular:dev-server";providers(e,g,`${x}()`,x)}else{o.logger.warn(`[Buoy] Kept ${i.build.builder}. It is not an @angular/build builder. Added the manual setup instead.`);const p=path.join(d,"buoy.ts");const m=l.map((f,E)=>`'${f==="notifications"?"push-notifications":f}': await import('@buoy-gg/${f}/web')`).join(",\n ");const b=path.join(d,"environments/buoy.ts");if(!e.exists(b))e.create(b,"export const BUOY_KEY = '';\n");if(!e.exists(p))e.create(p,`import { BUOY_KEY } from './environments/buoy';
|
|
5
5
|
export const buoyOptions = { licenseKey: BUOY_KEY, modules: async () => ({
|
|
6
6
|
${m}
|
|
7
7
|
}) };
|
|
8
|
-
`);let h=path.relative(path.dirname(g),p).replace(/\.ts$/,"");if(!h.startsWith("."))h="./"+h;const $=importName(e,g,h,"buoyOptions");let j=e.readText(g);if(!/declare\s+const\s+ngDevMode/.test(j))e.overwrite(g,"declare const ngDevMode: boolean | undefined;\n"+j);providers(e,g,`(typeof ngDevMode === 'undefined' || ngDevMode) ? ${x}(${$}) : []`,x);const T=e.readText(y);if(!T.includes("'@buoy-gg/angular/register'"))e.overwrite(y,"import '@buoy-gg/angular/register';\n"+T);const k=Number(({...
|
|
8
|
+
`);let h=path.relative(path.dirname(g),p).replace(/\.ts$/,"");if(!h.startsWith("."))h="./"+h;const $=importName(e,g,h,"buoyOptions");let j=e.readText(g);if(!/declare\s+const\s+ngDevMode/.test(j))e.overwrite(g,"declare const ngDevMode: boolean | undefined;\n"+j);providers(e,g,`(typeof ngDevMode === 'undefined' || ngDevMode) ? ${x}(${$}) : []`,x);const T=e.readText(y);if(!T.includes("'@buoy-gg/angular/register'"))e.overwrite(y,"import '@buoy-gg/angular/register';\n"+T);const k=Number(({...n.dependencies,...n.devDependencies}["@angular/core"]||"").match(/\d+/)?.[0]);const c=(i.build.configurations??={}).production??={};const v=path.join(d,"buoy.prod.ts");if(!e.exists(v))e.create(v,"export const buoyOptions = {};\n");c.fileReplacements=[...(c.fileReplacements||[]).filter(f=>f.replace!==p),{replace:p,with:v}];if(k>=20&&!i.build.builder.endsWith(":browser"))c.conditions=[...new Set(["buoy-disabled",...c.conditions||["module","production"]])];else{const f=path.join(d,"buoy-entry.ts"),E=path.join(d,"buoy-entry.prod.ts");if(!e.exists(f))e.create(f,"import '@buoy-gg/angular/register';\nexport { provideBuoy } from '@buoy-gg/angular';\nexport { buoyOptions } from './buoy';\n");if(!e.exists(E))e.create(E,"import { makeEnvironmentProviders } from '@angular/core';\nexport const provideBuoy = (_options?: unknown) => makeEnvironmentProviders([]);\nexport const buoyOptions = {};\n");let w=path.relative(path.dirname(g),f).replace(/\.ts$/,"");if(!w.startsWith("."))w="./"+w;e.overwrite(g,e.readText(g).replace(/from '@buoy-gg\/angular'/,`from '${w}'`).replace(`from '${h}'`,`from '${w}'`));e.overwrite(y,e.readText(y).replace("import '@buoy-gg/angular/register';\n",""));c.fileReplacements=[...(c.fileReplacements||[]).filter(S=>S.replace!==f),{replace:f,with:E}]}}n.devDependencies??={};for(const p of["core",...l]){const m=catalog.find(h=>h.id===p);const b="@buoy-gg/"+p;if(!n.dependencies?.[b]&&!n.devDependencies[b])n.devDependencies[b]="^"+m.version}if(l.includes("react-query")&&!n.dependencies?.["@tanstack/react-query"]&&!n.devDependencies["@tanstack/react-query"]){const p=Object.entries({...n.dependencies,...n.devDependencies}).find(([m])=>m.startsWith("@tanstack/angular-query-"));n.devDependencies["@tanstack/react-query"]=p?.[1]||"^5.0.0"}n.buoy??={};n.buoy.angular??={};n.buoy.angular[t]={tools:l};write(e,"/angular.json",a);write(e,"/package.json",n);if(!r.skipInstall)o.addTask(new(createRequire(appRequire.resolve("@angular/cli/package.json"))("@angular-devkit/schematics/tasks")).NodePackageInstallTask);o.logger.info("[Buoy] Run npx buoy login to sign in.");return e}}module.exports={ngAdd,setup,defaults};
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
"env",
|
|
16
16
|
"events",
|
|
17
17
|
"console",
|
|
18
|
-
"sentry",
|
|
19
18
|
"time-machine",
|
|
20
19
|
"clock",
|
|
21
20
|
"permissions",
|
|
@@ -58,10 +57,6 @@
|
|
|
58
57
|
"value": "console",
|
|
59
58
|
"label": "Console"
|
|
60
59
|
},
|
|
61
|
-
{
|
|
62
|
-
"value": "sentry",
|
|
63
|
-
"label": "Sentry"
|
|
64
|
-
},
|
|
65
60
|
{
|
|
66
61
|
"value": "time-machine",
|
|
67
62
|
"label": "Time Machine"
|
|
@@ -1,110 +1,106 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
3
|
"id": "core",
|
|
4
|
-
"version": "7.0.
|
|
4
|
+
"version": "7.0.66"
|
|
5
5
|
},
|
|
6
6
|
{
|
|
7
7
|
"id": "env",
|
|
8
|
-
"version": "7.0.
|
|
8
|
+
"version": "7.0.66"
|
|
9
9
|
},
|
|
10
10
|
{
|
|
11
11
|
"id": "events",
|
|
12
|
-
"version": "7.0.
|
|
12
|
+
"version": "7.0.66"
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
"id": "console",
|
|
16
|
-
"version": "7.0.
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"id": "sentry",
|
|
20
|
-
"version": "7.0.63"
|
|
16
|
+
"version": "7.0.66"
|
|
21
17
|
},
|
|
22
18
|
{
|
|
23
19
|
"id": "time-machine",
|
|
24
|
-
"version": "7.0.
|
|
20
|
+
"version": "7.0.66"
|
|
25
21
|
},
|
|
26
22
|
{
|
|
27
23
|
"id": "clock",
|
|
28
|
-
"version": "7.0.
|
|
24
|
+
"version": "7.0.66"
|
|
29
25
|
},
|
|
30
26
|
{
|
|
31
27
|
"id": "permissions",
|
|
32
|
-
"version": "7.0.
|
|
28
|
+
"version": "7.0.66"
|
|
33
29
|
},
|
|
34
30
|
{
|
|
35
31
|
"id": "lifecycle",
|
|
36
|
-
"version": "7.0.
|
|
32
|
+
"version": "7.0.66"
|
|
37
33
|
},
|
|
38
34
|
{
|
|
39
35
|
"id": "location",
|
|
40
|
-
"version": "7.0.
|
|
36
|
+
"version": "7.0.66"
|
|
41
37
|
},
|
|
42
38
|
{
|
|
43
39
|
"id": "ask-buoy",
|
|
44
|
-
"version": "7.0.
|
|
40
|
+
"version": "7.0.66"
|
|
45
41
|
},
|
|
46
42
|
{
|
|
47
43
|
"id": "network",
|
|
48
|
-
"version": "7.0.
|
|
44
|
+
"version": "7.0.66"
|
|
49
45
|
},
|
|
50
46
|
{
|
|
51
47
|
"id": "storage",
|
|
52
|
-
"version": "7.0.
|
|
48
|
+
"version": "7.0.66"
|
|
53
49
|
},
|
|
54
50
|
{
|
|
55
51
|
"id": "route-events",
|
|
56
|
-
"version": "7.0.
|
|
52
|
+
"version": "7.0.66"
|
|
57
53
|
},
|
|
58
54
|
{
|
|
59
55
|
"id": "react-query",
|
|
60
|
-
"version": "7.0.
|
|
56
|
+
"version": "7.0.66"
|
|
61
57
|
},
|
|
62
58
|
{
|
|
63
59
|
"id": "redux",
|
|
64
|
-
"version": "7.0.
|
|
60
|
+
"version": "7.0.66"
|
|
65
61
|
},
|
|
66
62
|
{
|
|
67
63
|
"id": "zustand",
|
|
68
|
-
"version": "7.0.
|
|
64
|
+
"version": "7.0.66"
|
|
69
65
|
},
|
|
70
66
|
{
|
|
71
67
|
"id": "jotai",
|
|
72
|
-
"version": "7.0.
|
|
68
|
+
"version": "7.0.66"
|
|
73
69
|
},
|
|
74
70
|
{
|
|
75
71
|
"id": "highlight-updates",
|
|
76
|
-
"version": "7.0.
|
|
72
|
+
"version": "7.0.66"
|
|
77
73
|
},
|
|
78
74
|
{
|
|
79
75
|
"id": "image-overlay",
|
|
80
|
-
"version": "7.0.
|
|
76
|
+
"version": "7.0.66"
|
|
81
77
|
},
|
|
82
78
|
{
|
|
83
79
|
"id": "impersonate",
|
|
84
|
-
"version": "7.0.
|
|
80
|
+
"version": "7.0.66"
|
|
85
81
|
},
|
|
86
82
|
{
|
|
87
83
|
"id": "perf-monitor",
|
|
88
|
-
"version": "7.0.
|
|
84
|
+
"version": "7.0.66"
|
|
89
85
|
},
|
|
90
86
|
{
|
|
91
87
|
"id": "js-top",
|
|
92
|
-
"version": "7.0.
|
|
88
|
+
"version": "7.0.66"
|
|
93
89
|
},
|
|
94
90
|
{
|
|
95
91
|
"id": "images",
|
|
96
|
-
"version": "7.0.
|
|
92
|
+
"version": "7.0.66"
|
|
97
93
|
},
|
|
98
94
|
{
|
|
99
95
|
"id": "assets",
|
|
100
|
-
"version": "7.0.
|
|
96
|
+
"version": "7.0.66"
|
|
101
97
|
},
|
|
102
98
|
{
|
|
103
99
|
"id": "tv-remote",
|
|
104
|
-
"version": "7.0.
|
|
100
|
+
"version": "7.0.66"
|
|
105
101
|
},
|
|
106
102
|
{
|
|
107
103
|
"id": "focus-inspector",
|
|
108
|
-
"version": "7.0.
|
|
104
|
+
"version": "7.0.66"
|
|
109
105
|
}
|
|
110
106
|
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buoy-gg/angular",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.66",
|
|
4
4
|
"description": "Run Buoy in an Angular app.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"react": "^19.2.0",
|
|
49
49
|
"react-dom": "^19.2.0",
|
|
50
50
|
"react-native-web": "^0.21.2",
|
|
51
|
-
"@buoy-gg/
|
|
52
|
-
"@buoy-gg/
|
|
51
|
+
"@buoy-gg/shared-ui": "^7.0.66",
|
|
52
|
+
"@buoy-gg/core": "^7.0.66"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@angular/core": ">=19 <23",
|