datocms-plugin-sdk 3.0.0-alpha.0 → 3.0.1-alpha.0

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/manifest.json CHANGED
@@ -3127,6 +3127,16 @@
3127
3127
  "lineNumber": 99
3128
3128
  },
3129
3129
  "type": "SemanticColorTokensTheme"
3130
+ },
3131
+ "colorScheme": {
3132
+ "comment": {
3133
+ "markdownText": "The appearance color scheme the host CMS is currently using. Resolved —\n`'system'` is already expanded to `'light'` or `'dark'` by the host.\n\nThe SDK runtime reflects this onto `document.documentElement` as\n`data-theme=\"light\"` / `data-theme=\"dark\"` so plugin CSS can branch\nwith `[data-theme=\"dark\"] { … }` selectors. For non-CSS decisions\n(choosing a logo asset, a syntax-highlighting preset, …) branch on\n`ctx.colorScheme` directly."
3134
+ },
3135
+ "location": {
3136
+ "filePath": "src/ctx/base.ts",
3137
+ "lineNumber": 111
3138
+ },
3139
+ "type": "'light' | 'dark'"
3130
3140
  }
3131
3141
  }
3132
3142
  },
@@ -3142,7 +3152,7 @@
3142
3152
  },
3143
3153
  "location": {
3144
3154
  "filePath": "src/ctx/base.ts",
3145
- "lineNumber": 109
3155
+ "lineNumber": 121
3146
3156
  },
3147
3157
  "type": "Partial<Record<string, ItemType>>"
3148
3158
  },
@@ -3152,7 +3162,7 @@
3152
3162
  },
3153
3163
  "location": {
3154
3164
  "filePath": "src/ctx/base.ts",
3155
- "lineNumber": 116
3165
+ "lineNumber": 128
3156
3166
  },
3157
3167
  "type": "Partial<Record<string, Field>>"
3158
3168
  },
@@ -3162,7 +3172,7 @@
3162
3172
  },
3163
3173
  "location": {
3164
3174
  "filePath": "src/ctx/base.ts",
3165
- "lineNumber": 123
3175
+ "lineNumber": 135
3166
3176
  },
3167
3177
  "type": "Partial<Record<string, Fieldset>>"
3168
3178
  },
@@ -3172,7 +3182,7 @@
3172
3182
  },
3173
3183
  "location": {
3174
3184
  "filePath": "src/ctx/base.ts",
3175
- "lineNumber": 130
3185
+ "lineNumber": 142
3176
3186
  },
3177
3187
  "type": "Partial<Record<string, User>>"
3178
3188
  },
@@ -3182,7 +3192,7 @@
3182
3192
  },
3183
3193
  "location": {
3184
3194
  "filePath": "src/ctx/base.ts",
3185
- "lineNumber": 137
3195
+ "lineNumber": 149
3186
3196
  },
3187
3197
  "type": "Partial<Record<string, SsoUser>>"
3188
3198
  }
@@ -3203,7 +3213,7 @@
3203
3213
  },
3204
3214
  "location": {
3205
3215
  "filePath": "src/ctx/base.ts",
3206
- "lineNumber": 341
3216
+ "lineNumber": 353
3207
3217
  },
3208
3218
  "type": "(itemTypeId: string) => Promise<Field[]>"
3209
3219
  },
@@ -3214,7 +3224,7 @@
3214
3224
  },
3215
3225
  "location": {
3216
3226
  "filePath": "src/ctx/base.ts",
3217
- "lineNumber": 360
3227
+ "lineNumber": 372
3218
3228
  },
3219
3229
  "type": "(itemTypeId: string) => Promise<Fieldset[]>"
3220
3230
  },
@@ -3225,7 +3235,7 @@
3225
3235
  },
3226
3236
  "location": {
3227
3237
  "filePath": "src/ctx/base.ts",
3228
- "lineNumber": 377
3238
+ "lineNumber": 389
3229
3239
  },
3230
3240
  "type": "() => Promise<Field[]>"
3231
3241
  },
@@ -3236,7 +3246,7 @@
3236
3246
  },
3237
3247
  "location": {
3238
3248
  "filePath": "src/ctx/base.ts",
3239
- "lineNumber": 390
3249
+ "lineNumber": 402
3240
3250
  },
3241
3251
  "type": "() => Promise<User[]>"
3242
3252
  },
@@ -3247,7 +3257,7 @@
3247
3257
  },
3248
3258
  "location": {
3249
3259
  "filePath": "src/ctx/base.ts",
3250
- "lineNumber": 403
3260
+ "lineNumber": 415
3251
3261
  },
3252
3262
  "type": "() => Promise<SsoUser[]>"
3253
3263
  }
@@ -3266,7 +3276,7 @@
3266
3276
  },
3267
3277
  "location": {
3268
3278
  "filePath": "src/ctx/base.ts",
3269
- "lineNumber": 425
3279
+ "lineNumber": 437
3270
3280
  },
3271
3281
  "type": "(params: Record<string, unknown>) => Promise<void>"
3272
3282
  },
@@ -3277,7 +3287,7 @@
3277
3287
  },
3278
3288
  "location": {
3279
3289
  "filePath": "src/ctx/base.ts",
3280
- "lineNumber": 476
3290
+ "lineNumber": 488
3281
3291
  },
3282
3292
  "type": "(\n fieldId: string,\n changes: FieldAppearanceChange[],\n ) => Promise<void>"
3283
3293
  }
@@ -3296,7 +3306,7 @@
3296
3306
  },
3297
3307
  "location": {
3298
3308
  "filePath": "src/ctx/base.ts",
3299
- "lineNumber": 581
3309
+ "lineNumber": 593
3300
3310
  },
3301
3311
  "type": "(message: string) => Promise<void>"
3302
3312
  },
@@ -3307,7 +3317,7 @@
3307
3317
  },
3308
3318
  "location": {
3309
3319
  "filePath": "src/ctx/base.ts",
3310
- "lineNumber": 596
3320
+ "lineNumber": 608
3311
3321
  },
3312
3322
  "type": "(message: string) => Promise<void>"
3313
3323
  },
@@ -3318,7 +3328,7 @@
3318
3328
  },
3319
3329
  "location": {
3320
3330
  "filePath": "src/ctx/base.ts",
3321
- "lineNumber": 620
3331
+ "lineNumber": 632
3322
3332
  },
3323
3333
  "type": "<CtaValue = unknown>(\n toast: Toast<CtaValue>,\n ) => Promise<CtaValue | null>"
3324
3334
  }
@@ -3337,7 +3347,7 @@
3337
3347
  },
3338
3348
  "location": {
3339
3349
  "filePath": "src/ctx/base.ts",
3340
- "lineNumber": 506
3350
+ "lineNumber": 518
3341
3351
  },
3342
3352
  "type": "(itemTypeId: string) => Promise<Item | null>"
3343
3353
  },
@@ -3348,7 +3358,7 @@
3348
3358
  },
3349
3359
  "location": {
3350
3360
  "filePath": "src/ctx/base.ts",
3351
- "lineNumber": 527
3361
+ "lineNumber": 539
3352
3362
  },
3353
3363
  "type": "{\n (\n itemTypeId: string,\n options: { multiple: true; initialLocationQuery?: ItemListLocationQuery },\n ): Promise<Item[] | null>;\n (\n itemTypeId: string,\n options?: {\n multiple: false;\n initialLocationQuery?: ItemListLocationQuery;\n },\n ): Promise<Item | null>;\n }"
3354
3364
  },
@@ -3359,7 +3369,7 @@
3359
3369
  },
3360
3370
  "location": {
3361
3371
  "filePath": "src/ctx/base.ts",
3362
- "lineNumber": 559
3372
+ "lineNumber": 571
3363
3373
  },
3364
3374
  "type": "(itemId: string) => Promise<Item | null>"
3365
3375
  }
@@ -3378,7 +3388,7 @@
3378
3388
  },
3379
3389
  "location": {
3380
3390
  "filePath": "src/ctx/base.ts",
3381
- "lineNumber": 647
3391
+ "lineNumber": 659
3382
3392
  },
3383
3393
  "type": "{\n (options: { multiple: true }): Promise<Upload[] | null>;\n (options?: { multiple: false }): Promise<Upload | null>;\n }"
3384
3394
  },
@@ -3389,7 +3399,7 @@
3389
3399
  },
3390
3400
  "location": {
3391
3401
  "filePath": "src/ctx/base.ts",
3392
- "lineNumber": 675
3402
+ "lineNumber": 687
3393
3403
  },
3394
3404
  "type": "(\n uploadId: string,\n ) => Promise<(Upload & { deleted?: true }) | null>"
3395
3405
  },
@@ -3400,7 +3410,7 @@
3400
3410
  },
3401
3411
  "location": {
3402
3412
  "filePath": "src/ctx/base.ts",
3403
- "lineNumber": 703
3413
+ "lineNumber": 715
3404
3414
  },
3405
3415
  "type": "(\n /** The \"single asset\" field structure */\n fileFieldValue: FileFieldValue,\n /** Shows metadata information for a specific locale */\n locale?: string,\n ) => Promise<FileFieldValue | null>"
3406
3416
  }
@@ -3419,7 +3429,7 @@
3419
3429
  },
3420
3430
  "location": {
3421
3431
  "filePath": "src/ctx/base.ts",
3422
- "lineNumber": 734
3432
+ "lineNumber": 746
3423
3433
  },
3424
3434
  "type": "(modal: Modal) => Promise<unknown>"
3425
3435
  },
@@ -3430,7 +3440,7 @@
3430
3440
  },
3431
3441
  "location": {
3432
3442
  "filePath": "src/ctx/base.ts",
3433
- "lineNumber": 771
3443
+ "lineNumber": 783
3434
3444
  },
3435
3445
  "type": "(options: ConfirmOptions) => Promise<unknown>"
3436
3446
  }
@@ -3449,7 +3459,7 @@
3449
3459
  },
3450
3460
  "location": {
3451
3461
  "filePath": "src/ctx/base.ts",
3452
- "lineNumber": 785
3462
+ "lineNumber": 797
3453
3463
  },
3454
3464
  "type": "(path: string) => Promise<void>"
3455
3465
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datocms-plugin-sdk",
3
- "version": "3.0.0-alpha.0",
3
+ "version": "3.0.1-alpha.0",
4
4
  "description": "DatoCMS Plugin SDK",
5
5
  "keywords": [
6
6
  "datocms",
@@ -46,5 +46,5 @@
46
46
  "glob": "^11.0.0",
47
47
  "typescript": "^5.6.2"
48
48
  },
49
- "gitHead": "01c46332e40377d305c3abd262c3d1840385ec49"
49
+ "gitHead": "52e7affbf92416cbc1cde78e016a62f3ff1a95cf"
50
50
  }
package/src/connect.ts CHANGED
@@ -136,6 +136,15 @@ export type FullConnectParameters = AssetSourcesHook &
136
136
  UploadSidebarsHook &
137
137
  ValidateManualFieldExtensionParametersHook;
138
138
 
139
+ function applyColorScheme(properties: unknown): void {
140
+ if (typeof document === 'undefined') return;
141
+ const next = (properties as { colorScheme?: 'light' | 'dark' } | null)
142
+ ?.colorScheme;
143
+ if (next !== 'light' && next !== 'dark') return;
144
+ if (document.documentElement.dataset.theme === next) return;
145
+ document.documentElement.dataset.theme = next;
146
+ }
147
+
139
148
  export async function connect(
140
149
  rawConfiguration: Partial<FullConnectParameters> = {},
141
150
  ): Promise<void> {
@@ -185,6 +194,7 @@ export async function connect(
185
194
  ),
186
195
  ),
187
196
  onChange(newSettings: unknown) {
197
+ applyColorScheme(newSettings);
188
198
  if (onChangeListener) {
189
199
  onChangeListener(newSettings);
190
200
  }
@@ -212,6 +222,7 @@ export async function connect(
212
222
 
213
223
  const methods = await penpalConnection.promise;
214
224
  const initialProperties = await methods.getSettings();
225
+ applyColorScheme(initialProperties);
215
226
 
216
227
  if (initialProperties.mode === 'onBoot') {
217
228
  let currentProperties = initialProperties;
package/src/ctx/base.ts CHANGED
@@ -97,6 +97,18 @@ type ProjectProperties = {
97
97
  * system.
98
98
  */
99
99
  semanticColorTokensTheme: SemanticColorTokensTheme;
100
+
101
+ /**
102
+ * The appearance color scheme the host CMS is currently using. Resolved —
103
+ * `'system'` is already expanded to `'light'` or `'dark'` by the host.
104
+ *
105
+ * The SDK runtime reflects this onto `document.documentElement` as
106
+ * `data-theme="light"` / `data-theme="dark"` so plugin CSS can branch
107
+ * with `[data-theme="dark"] { … }` selectors. For non-CSS decisions
108
+ * (choosing a logo asset, a syntax-highlighting preset, …) branch on
109
+ * `ctx.colorScheme` directly.
110
+ */
111
+ colorScheme: 'light' | 'dark';
100
112
  };
101
113
 
102
114
  /**
package/src/manifest.ts CHANGED
@@ -3360,6 +3360,17 @@ export const manifest: Manifest = {
3360
3360
  },
3361
3361
  type: 'SemanticColorTokensTheme',
3362
3362
  },
3363
+ colorScheme: {
3364
+ comment: {
3365
+ markdownText:
3366
+ 'The appearance color scheme the host CMS is currently using. Resolved —\n`\'system\'` is already expanded to `\'light\'` or `\'dark\'` by the host.\n\nThe SDK runtime reflects this onto `document.documentElement` as\n`data-theme="light"` / `data-theme="dark"` so plugin CSS can branch\nwith `[data-theme="dark"] { … }` selectors. For non-CSS decisions\n(choosing a logo asset, a syntax-highlighting preset, …) branch on\n`ctx.colorScheme` directly.',
3367
+ },
3368
+ location: {
3369
+ filePath: 'src/ctx/base.ts',
3370
+ lineNumber: 111,
3371
+ },
3372
+ type: "'light' | 'dark'",
3373
+ },
3363
3374
  },
3364
3375
  },
3365
3376
  {
@@ -3376,7 +3387,7 @@ export const manifest: Manifest = {
3376
3387
  },
3377
3388
  location: {
3378
3389
  filePath: 'src/ctx/base.ts',
3379
- lineNumber: 109,
3390
+ lineNumber: 121,
3380
3391
  },
3381
3392
  type: 'Partial<Record<string, ItemType>>',
3382
3393
  },
@@ -3387,7 +3398,7 @@ export const manifest: Manifest = {
3387
3398
  },
3388
3399
  location: {
3389
3400
  filePath: 'src/ctx/base.ts',
3390
- lineNumber: 116,
3401
+ lineNumber: 128,
3391
3402
  },
3392
3403
  type: 'Partial<Record<string, Field>>',
3393
3404
  },
@@ -3398,7 +3409,7 @@ export const manifest: Manifest = {
3398
3409
  },
3399
3410
  location: {
3400
3411
  filePath: 'src/ctx/base.ts',
3401
- lineNumber: 123,
3412
+ lineNumber: 135,
3402
3413
  },
3403
3414
  type: 'Partial<Record<string, Fieldset>>',
3404
3415
  },
@@ -3409,7 +3420,7 @@ export const manifest: Manifest = {
3409
3420
  },
3410
3421
  location: {
3411
3422
  filePath: 'src/ctx/base.ts',
3412
- lineNumber: 130,
3423
+ lineNumber: 142,
3413
3424
  },
3414
3425
  type: 'Partial<Record<string, User>>',
3415
3426
  },
@@ -3420,7 +3431,7 @@ export const manifest: Manifest = {
3420
3431
  },
3421
3432
  location: {
3422
3433
  filePath: 'src/ctx/base.ts',
3423
- lineNumber: 137,
3434
+ lineNumber: 149,
3424
3435
  },
3425
3436
  type: 'Partial<Record<string, SsoUser>>',
3426
3437
  },
@@ -3444,7 +3455,7 @@ export const manifest: Manifest = {
3444
3455
  },
3445
3456
  location: {
3446
3457
  filePath: 'src/ctx/base.ts',
3447
- lineNumber: 341,
3458
+ lineNumber: 353,
3448
3459
  },
3449
3460
  type: '(itemTypeId: string) => Promise<Field[]>',
3450
3461
  },
@@ -3457,7 +3468,7 @@ export const manifest: Manifest = {
3457
3468
  },
3458
3469
  location: {
3459
3470
  filePath: 'src/ctx/base.ts',
3460
- lineNumber: 360,
3471
+ lineNumber: 372,
3461
3472
  },
3462
3473
  type: '(itemTypeId: string) => Promise<Fieldset[]>',
3463
3474
  },
@@ -3470,7 +3481,7 @@ export const manifest: Manifest = {
3470
3481
  },
3471
3482
  location: {
3472
3483
  filePath: 'src/ctx/base.ts',
3473
- lineNumber: 377,
3484
+ lineNumber: 389,
3474
3485
  },
3475
3486
  type: '() => Promise<Field[]>',
3476
3487
  },
@@ -3483,7 +3494,7 @@ export const manifest: Manifest = {
3483
3494
  },
3484
3495
  location: {
3485
3496
  filePath: 'src/ctx/base.ts',
3486
- lineNumber: 390,
3497
+ lineNumber: 402,
3487
3498
  },
3488
3499
  type: '() => Promise<User[]>',
3489
3500
  },
@@ -3496,7 +3507,7 @@ export const manifest: Manifest = {
3496
3507
  },
3497
3508
  location: {
3498
3509
  filePath: 'src/ctx/base.ts',
3499
- lineNumber: 403,
3510
+ lineNumber: 415,
3500
3511
  },
3501
3512
  type: '() => Promise<SsoUser[]>',
3502
3513
  },
@@ -3518,7 +3529,7 @@ export const manifest: Manifest = {
3518
3529
  },
3519
3530
  location: {
3520
3531
  filePath: 'src/ctx/base.ts',
3521
- lineNumber: 425,
3532
+ lineNumber: 437,
3522
3533
  },
3523
3534
  type: '(params: Record<string, unknown>) => Promise<void>',
3524
3535
  },
@@ -3531,7 +3542,7 @@ export const manifest: Manifest = {
3531
3542
  },
3532
3543
  location: {
3533
3544
  filePath: 'src/ctx/base.ts',
3534
- lineNumber: 476,
3545
+ lineNumber: 488,
3535
3546
  },
3536
3547
  type: '(\n fieldId: string,\n changes: FieldAppearanceChange[],\n ) => Promise<void>',
3537
3548
  },
@@ -3553,7 +3564,7 @@ export const manifest: Manifest = {
3553
3564
  },
3554
3565
  location: {
3555
3566
  filePath: 'src/ctx/base.ts',
3556
- lineNumber: 581,
3567
+ lineNumber: 593,
3557
3568
  },
3558
3569
  type: '(message: string) => Promise<void>',
3559
3570
  },
@@ -3566,7 +3577,7 @@ export const manifest: Manifest = {
3566
3577
  },
3567
3578
  location: {
3568
3579
  filePath: 'src/ctx/base.ts',
3569
- lineNumber: 596,
3580
+ lineNumber: 608,
3570
3581
  },
3571
3582
  type: '(message: string) => Promise<void>',
3572
3583
  },
@@ -3579,7 +3590,7 @@ export const manifest: Manifest = {
3579
3590
  },
3580
3591
  location: {
3581
3592
  filePath: 'src/ctx/base.ts',
3582
- lineNumber: 620,
3593
+ lineNumber: 632,
3583
3594
  },
3584
3595
  type: '<CtaValue = unknown>(\n toast: Toast<CtaValue>,\n ) => Promise<CtaValue | null>',
3585
3596
  },
@@ -3601,7 +3612,7 @@ export const manifest: Manifest = {
3601
3612
  },
3602
3613
  location: {
3603
3614
  filePath: 'src/ctx/base.ts',
3604
- lineNumber: 506,
3615
+ lineNumber: 518,
3605
3616
  },
3606
3617
  type: '(itemTypeId: string) => Promise<Item | null>',
3607
3618
  },
@@ -3614,7 +3625,7 @@ export const manifest: Manifest = {
3614
3625
  },
3615
3626
  location: {
3616
3627
  filePath: 'src/ctx/base.ts',
3617
- lineNumber: 527,
3628
+ lineNumber: 539,
3618
3629
  },
3619
3630
  type: '{\n (\n itemTypeId: string,\n options: { multiple: true; initialLocationQuery?: ItemListLocationQuery },\n ): Promise<Item[] | null>;\n (\n itemTypeId: string,\n options?: {\n multiple: false;\n initialLocationQuery?: ItemListLocationQuery;\n },\n ): Promise<Item | null>;\n }',
3620
3631
  },
@@ -3627,7 +3638,7 @@ export const manifest: Manifest = {
3627
3638
  },
3628
3639
  location: {
3629
3640
  filePath: 'src/ctx/base.ts',
3630
- lineNumber: 559,
3641
+ lineNumber: 571,
3631
3642
  },
3632
3643
  type: '(itemId: string) => Promise<Item | null>',
3633
3644
  },
@@ -3649,7 +3660,7 @@ export const manifest: Manifest = {
3649
3660
  },
3650
3661
  location: {
3651
3662
  filePath: 'src/ctx/base.ts',
3652
- lineNumber: 647,
3663
+ lineNumber: 659,
3653
3664
  },
3654
3665
  type: '{\n (options: { multiple: true }): Promise<Upload[] | null>;\n (options?: { multiple: false }): Promise<Upload | null>;\n }',
3655
3666
  },
@@ -3662,7 +3673,7 @@ export const manifest: Manifest = {
3662
3673
  },
3663
3674
  location: {
3664
3675
  filePath: 'src/ctx/base.ts',
3665
- lineNumber: 675,
3676
+ lineNumber: 687,
3666
3677
  },
3667
3678
  type: '(\n uploadId: string,\n ) => Promise<(Upload & { deleted?: true }) | null>',
3668
3679
  },
@@ -3675,7 +3686,7 @@ export const manifest: Manifest = {
3675
3686
  },
3676
3687
  location: {
3677
3688
  filePath: 'src/ctx/base.ts',
3678
- lineNumber: 703,
3689
+ lineNumber: 715,
3679
3690
  },
3680
3691
  type: '(\n /** The "single asset" field structure */\n fileFieldValue: FileFieldValue,\n /** Shows metadata information for a specific locale */\n locale?: string,\n ) => Promise<FileFieldValue | null>',
3681
3692
  },
@@ -3697,7 +3708,7 @@ export const manifest: Manifest = {
3697
3708
  },
3698
3709
  location: {
3699
3710
  filePath: 'src/ctx/base.ts',
3700
- lineNumber: 734,
3711
+ lineNumber: 746,
3701
3712
  },
3702
3713
  type: '(modal: Modal) => Promise<unknown>',
3703
3714
  },
@@ -3710,7 +3721,7 @@ export const manifest: Manifest = {
3710
3721
  },
3711
3722
  location: {
3712
3723
  filePath: 'src/ctx/base.ts',
3713
- lineNumber: 771,
3724
+ lineNumber: 783,
3714
3725
  },
3715
3726
  type: '(options: ConfirmOptions) => Promise<unknown>',
3716
3727
  },
@@ -3731,7 +3742,7 @@ export const manifest: Manifest = {
3731
3742
  },
3732
3743
  location: {
3733
3744
  filePath: 'src/ctx/base.ts',
3734
- lineNumber: 785,
3745
+ lineNumber: 797,
3735
3746
  },
3736
3747
  type: '(path: string) => Promise<void>',
3737
3748
  },