@jskit-ai/kernel 0.1.37 → 0.1.38

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/client/index.d.ts CHANGED
@@ -34,6 +34,7 @@ export function bootstrapClientShellApp(options?: {
34
34
  rootComponent: any;
35
35
  appConfig?: Record<string, any>;
36
36
  appPlugins?: any[];
37
+ pinia?: any;
37
38
  router: any;
38
39
  bootClientModules: (context: any) => Promise<any>;
39
40
  surfaceRuntime: any;
@@ -482,6 +482,7 @@ function normalizeClientModuleEntries(clientModules) {
482
482
  function createClientRuntimeApp({
483
483
  profile = "client",
484
484
  app,
485
+ pinia = null,
485
486
  router,
486
487
  env,
487
488
  logger,
@@ -496,6 +497,7 @@ function createClientRuntimeApp({
496
497
  runtimeApp.instance("jskit.client.runtime.app", runtimeApp);
497
498
  runtimeApp.instance("jskit.client.router", router || null);
498
499
  runtimeApp.instance("jskit.client.vue.app", app || null);
500
+ runtimeApp.instance("jskit.client.pinia", pinia);
499
501
  runtimeApp.instance("jskit.client.env", isRecord(env) ? { ...env } : {});
500
502
  runtimeApp.instance("jskit.client.surface.runtime", surfaceRuntime || null);
501
503
  runtimeApp.instance("jskit.client.surface.mode", String(surfaceMode || "").trim());
@@ -507,6 +509,7 @@ function createClientRuntimeApp({
507
509
  async function bootClientModules({
508
510
  clientModules = [],
509
511
  app,
512
+ pinia = null,
510
513
  router,
511
514
  surfaceRuntime,
512
515
  surfaceMode,
@@ -525,6 +528,7 @@ async function bootClientModules({
525
528
  const runtimeApp = createClientRuntimeApp({
526
529
  profile: String(surfaceRuntime.normalizeSurfaceMode(surfaceMode) || "client"),
527
530
  app,
531
+ pinia,
528
532
  router,
529
533
  env,
530
534
  logger: log,
@@ -112,11 +112,14 @@ test("bootClientModules registers descriptor and clientRoutes with providers onl
112
112
  const surfaceRuntime = createSurfaceRuntimeFixture();
113
113
  const events = [];
114
114
  const loginComponent = {};
115
+ const pinia = { id: "pinia-instance" };
116
+ const implicitPinia = { id: "implicit-vue-global-pinia" };
115
117
  class ExampleClientProvider {
116
118
  static id = "example.client";
117
119
  register(app) {
118
120
  events.push("register");
119
121
  app.instance("example.value", 42);
122
+ app.instance("example.pinia", app.make("jskit.client.pinia"));
120
123
  }
121
124
  boot() {
122
125
  events.push("boot");
@@ -179,6 +182,14 @@ test("bootClientModules registers descriptor and clientRoutes with providers onl
179
182
  }
180
183
  }
181
184
  ],
185
+ app: {
186
+ config: {
187
+ globalProperties: {
188
+ $pinia: implicitPinia
189
+ }
190
+ }
191
+ },
192
+ pinia,
182
193
  router,
183
194
  surfaceRuntime,
184
195
  surfaceMode: "all",
@@ -194,6 +205,8 @@ test("bootClientModules registers descriptor and clientRoutes with providers onl
194
205
  assert.equal(router.routes[1].path, "/auth/login");
195
206
  assert.equal(router.routes[1].component, loginComponent);
196
207
  assert.equal(result.runtimeApp.make("example.value"), 42);
208
+ assert.equal(result.runtimeApp.make("example.pinia"), pinia);
209
+ assert.notEqual(result.runtimeApp.make("example.pinia"), implicitPinia);
197
210
  });
198
211
 
199
212
  test("bootClientModules does not auto-discover providers from module exports", async () => {
@@ -108,6 +108,7 @@ async function bootstrapClientShellApp({
108
108
  rootComponent,
109
109
  appConfig = {},
110
110
  appPlugins = [],
111
+ pinia = null,
111
112
  router,
112
113
  bootClientModules,
113
114
  surfaceRuntime,
@@ -158,6 +159,7 @@ async function bootstrapClientShellApp({
158
159
 
159
160
  const clientBootstrap = await bootClientModules({
160
161
  app,
162
+ pinia,
161
163
  router,
162
164
  surfaceRuntime,
163
165
  surfaceMode,
@@ -85,6 +85,7 @@ test("bootstrapClientShellApp boots modules, reinstalls fallback route, and moun
85
85
  const logs = [];
86
86
  const surfaceRuntime = createSurfaceRuntimeFixture();
87
87
  const plugin = { name: "vuetify-like-plugin" };
88
+ const pinia = { id: "pinia-instance" };
88
89
  const fallbackRoute = {
89
90
  name: "not-found",
90
91
  path: "/:pathMatch(.*)*",
@@ -140,10 +141,12 @@ test("bootstrapClientShellApp boots modules, reinstalls fallback route, and moun
140
141
  }
141
142
  },
142
143
  appPlugins: [plugin],
144
+ pinia,
143
145
  router,
144
146
  bootClientModules: async (context) => {
145
147
  calls.push("bootClientModules");
146
148
  assert.equal(context.app, app);
149
+ assert.equal(context.pinia, pinia);
147
150
  assert.equal(context.router, router);
148
151
  assert.equal(typeof context.logger.debug, "function");
149
152
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/kernel",
3
- "version": "0.1.37",
3
+ "version": "0.1.38",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "typebox": "^1.0.81"
@@ -9,8 +9,21 @@ function registerBootstrapPayloadContributor(app, token, factory) {
9
9
 
10
10
  function resolveBootstrapPayloadContributors(scope) {
11
11
  return resolveTaggedEntries(scope, "jskit.runtime.bootstrap.payloadContributors")
12
- .map((entry) => normalizeContributorEntry(entry))
13
- .filter(Boolean);
12
+ .map((entry, index) => ({
13
+ contributor: normalizeContributorEntry(entry),
14
+ index
15
+ }))
16
+ .filter((entry) => Boolean(entry.contributor))
17
+ .sort((left, right) => {
18
+ const leftOrder = Number.isFinite(left.contributor?.order) ? Number(left.contributor.order) : 0;
19
+ const rightOrder = Number.isFinite(right.contributor?.order) ? Number(right.contributor.order) : 0;
20
+ if (leftOrder !== rightOrder) {
21
+ return leftOrder - rightOrder;
22
+ }
23
+
24
+ return left.index - right.index;
25
+ })
26
+ .map((entry) => entry.contributor);
14
27
  }
15
28
 
16
29
  async function resolveBootstrapPayload(scope, context = {}) {
@@ -87,6 +87,58 @@ test("resolveBootstrapPayload applies contributors in deterministic token order"
87
87
  });
88
88
  });
89
89
 
90
+ test("resolveBootstrapPayload honors explicit contributor order before token order", async () => {
91
+ const app = createContainer();
92
+ const calls = [];
93
+
94
+ registerBootstrapPayloadContributor(app, "test.bootstrap.alpha", () => ({
95
+ contributorId: "alpha",
96
+ order: 200,
97
+ contribute({ payload }) {
98
+ calls.push({
99
+ contributorId: "alpha",
100
+ payload
101
+ });
102
+ return {
103
+ alpha: true
104
+ };
105
+ }
106
+ }));
107
+
108
+ registerBootstrapPayloadContributor(app, "test.bootstrap.zeta", () => ({
109
+ contributorId: "zeta",
110
+ order: 100,
111
+ contribute({ payload }) {
112
+ calls.push({
113
+ contributorId: "zeta",
114
+ payload
115
+ });
116
+ return {
117
+ zeta: true
118
+ };
119
+ }
120
+ }));
121
+
122
+ const payload = await resolveBootstrapPayload(app);
123
+
124
+ assert.deepEqual(calls, [
125
+ {
126
+ contributorId: "zeta",
127
+ payload: {}
128
+ },
129
+ {
130
+ contributorId: "alpha",
131
+ payload: {
132
+ zeta: true
133
+ }
134
+ }
135
+ ]);
136
+ assert.deepEqual(payload, {
137
+ zeta: true,
138
+ alpha: true
139
+ });
140
+ });
141
+
90
142
  test("resolveBootstrapPayload ignores non-object contributions", async () => {
91
143
  const app = createContainer();
92
144