mnfst 0.5.297 → 0.5.299

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,7 +2,7 @@
2
2
 
3
3
  (function () {
4
4
 
5
- const MANIFEST_BUILD_VERSION = '0.5.297';
5
+ const MANIFEST_BUILD_VERSION = '0.5.299';
6
6
 
7
7
  /* Manifest Data Sources - Appwrite Integration */
8
8
 
package/lib/manifest.d.ts CHANGED
@@ -728,7 +728,7 @@ export type ManifestDirective =
728
728
  | 'x-icon' | 'x-svg' | 'x-markdown' | 'x-code' | 'x-code-group'
729
729
  | 'x-toast' | 'x-tooltip' | 'x-carousel' | 'x-virtual' | 'x-computed' | 'x-defer'
730
730
  | 'x-chart' | 'x-date' | 'x-color' | 'x-colorpicker' | 'x-combobox'
731
- | 'x-export' | 'x-import' | 'x-pay' | 'x-files' | 'x-data-files'
731
+ | 'x-export' | 'x-import' | 'x-pay'
732
732
  | 'x-edit' | 'x-rich-text' | 'x-submit';
733
733
 
734
734
  /** Detail of the `submit:sent` / `submit:error` events an `x-submit` form dispatches. */
@@ -2,7 +2,7 @@
2
2
 
3
3
  (function () {
4
4
 
5
- const MANIFEST_BUILD_VERSION = '0.5.297';
5
+ const MANIFEST_BUILD_VERSION = '0.5.299';
6
6
 
7
7
  /* Manifest Data Sources - Configuration */
8
8
 
@@ -5160,11 +5160,6 @@ function createArrayProxyWithRoute(arrayTarget, dataSourceName = null, reloadDat
5160
5160
 
5161
5161
  // Symbol.iterator needed for Alpine's x-for
5162
5162
  if (key === Symbol.iterator) {
5163
- const manifest = window.ManifestDataConfig?.getManifest?.();
5164
- const ds = manifest?.data?.[dataSourceName];
5165
- const isStorageBucket = ds && window.ManifestDataConfig?.getAppwriteBucketId?.(ds);
5166
- if (isStorageBucket) {
5167
- }
5168
5163
  const iterator = target[Symbol.iterator].bind(target);
5169
5164
  // Restore Function.prototype for Alpine's instanceof checks
5170
5165
  if (iterator && typeof iterator === 'function') {
@@ -10901,1030 +10896,6 @@ if (!window.ManifestDataProxies) {
10901
10896
  window.ManifestDataProxies.registerXMagicMethod = registerXMagicMethod;
10902
10897
  window.ManifestDataProxies.clearNestedProxyCacheForDataSource = clearNestedProxyCacheForDataSource;
10903
10898
 
10904
- /* Manifest Data Sources - Directives */
10905
- // x-files / x-data-files: reactive file arrays for a table entry
10906
- function registerFilesDirective() {
10907
- if (typeof Alpine === 'undefined') {
10908
- const checkAlpine = setInterval(() => {
10909
- if (typeof Alpine !== 'undefined') {
10910
- clearInterval(checkAlpine);
10911
- registerFilesDirective();
10912
- }
10913
- }, 10);
10914
- setTimeout(() => clearInterval(checkAlpine), 5000);
10915
- return;
10916
- }
10917
-
10918
- // Walk up to the nearest parent x-for template
10919
- function findParentXFor(el) {
10920
- let current = el;
10921
- while (current) {
10922
- if (current.tagName === 'TEMPLATE' && current.hasAttribute('x-for')) {
10923
- return current;
10924
- }
10925
- // Also check parent element
10926
- current = current.parentElement;
10927
- if (current && current.tagName === 'TEMPLATE' && current.hasAttribute('x-for')) {
10928
- return current;
10929
- }
10930
- }
10931
- return null;
10932
- }
10933
-
10934
- // "item in $x.source" -> "item"
10935
- function extractLoopItemName(xForExpression) {
10936
- const match = xForExpression.match(/^(\w+)\s+in\s+/);
10937
- return match ? match[1] : null;
10938
- }
10939
-
10940
- Alpine.directive('files', (el, { expression, modifiers }, { effect, evaluateLater, cleanup }) => {
10941
-
10942
- // A bare identifier is a data-source name (string literal), not an expression
10943
- const isPlainIdentifier = expression && /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(expression.trim());
10944
-
10945
- const evaluate = isPlainIdentifier
10946
- ? (callback) => {
10947
- const value = expression.trim();
10948
- callback(value);
10949
- }
10950
- : evaluateLater(expression); // Evaluate as normal expression
10951
-
10952
- const evaluateField = el.hasAttribute('x-files-field')
10953
- ? evaluateLater(el.getAttribute('x-files-field'))
10954
- : null;
10955
-
10956
- let tableName = null;
10957
- let entryId = null;
10958
- let entry = null;
10959
- let fileField = 'fileIds'; // Default field name
10960
- let files = [];
10961
- let loadingFiles = false;
10962
- let filesError = null;
10963
- let lastFileIds = null;
10964
- let unwatch = null;
10965
- let handleFileDeleted = null;
10966
- let isProcessing = false; // Guard to prevent infinite loops
10967
- let waitingForDataSource = null; // Track which data source we're waiting for
10968
-
10969
- // Seed scope state synchronously (before Alpine evaluates expressions),
10970
- // not in an effect, so the variables exist on first evaluation.
10971
- let scope;
10972
- try {
10973
- scope = Alpine.$data(el);
10974
- } catch (e) {
10975
- scope = null; // not ready — seed in the effect instead
10976
- }
10977
-
10978
- if (scope) {
10979
- if (!('files' in scope)) {
10980
- scope.files = [];
10981
- }
10982
- if (!('loadingFiles' in scope)) {
10983
- scope.loadingFiles = false;
10984
- }
10985
- if (!('filesError' in scope)) {
10986
- scope.filesError = null;
10987
- }
10988
- // Sync local variables with scope
10989
- files = scope.files;
10990
- loadingFiles = scope.loadingFiles;
10991
- filesError = scope.filesError;
10992
- } else {
10993
- // If scope not ready, initialize in effect
10994
- // But we still need to set them on the element's data context
10995
- // Use Alpine's reactive system
10996
- setTimeout(() => {
10997
- try {
10998
- const delayedScope = Alpine.$data(el);
10999
- if (delayedScope) {
11000
- if (!('files' in delayedScope)) {
11001
- delayedScope.files = [];
11002
- }
11003
- if (!('loadingFiles' in delayedScope)) {
11004
- delayedScope.loadingFiles = false;
11005
- }
11006
- if (!('filesError' in delayedScope)) {
11007
- delayedScope.filesError = null;
11008
- }
11009
- }
11010
- } catch (e) {
11011
- // Ignore
11012
- }
11013
- }, 0);
11014
- }
11015
-
11016
- // Get $x from Alpine magic methods
11017
- const getX = () => {
11018
- try {
11019
- return Alpine.$data(el).$x;
11020
- } catch {
11021
- return null;
11022
- }
11023
- };
11024
-
11025
- // Resolve entry from expression value
11026
- const resolveEntry = async (value) => {
11027
-
11028
- // Pattern 1: Explicit tuple (tableName, entryId)
11029
- if (Array.isArray(value) && value.length === 2) {
11030
- return {
11031
- tableName: value[0],
11032
- entryId: value[1]?.$id || value[1],
11033
- entry: null
11034
- };
11035
- }
11036
-
11037
- // Pattern 2: Entry object with $id
11038
- if (value && typeof value === 'object' && value.$id) {
11039
- // Try to detect table name from $x data sources
11040
- const $x = getX();
11041
- if ($x) {
11042
- // Filter out internal Vue/React properties
11043
- const internalProps = ['__v_isRef', '__v_isReadonly', '__v_isShallow', '__v_raw', '__v_isReactive'];
11044
- for (const [dsName, dsData] of Object.entries($x)) {
11045
- // Skip internal properties
11046
- if (internalProps.includes(dsName) || dsName.startsWith('__')) {
11047
- continue;
11048
- }
11049
- if (Array.isArray(dsData) && dsData.some(item => item.$id === value.$id)) {
11050
- return {
11051
- tableName: dsName,
11052
- entryId: value.$id,
11053
- entry: value
11054
- };
11055
- }
11056
- }
11057
- }
11058
- // Fallback: assume entry object but need table name
11059
- return {
11060
- tableName: null,
11061
- entryId: value.$id,
11062
- entry: value
11063
- };
11064
- }
11065
-
11066
- // Pattern 3: Data source name (string) - walk up DOM for loop context
11067
- if (typeof value === 'string') {
11068
- // Filter out internal properties
11069
- const internalProps = ['__v_isRef', '__v_isReadonly', '__v_isShallow', '__v_raw', '__v_isReactive'];
11070
- if (internalProps.includes(value) || value.startsWith('__')) {
11071
- return null; // Don't treat internal properties as data sources
11072
- }
11073
-
11074
- const $x = getX();
11075
- const $xKeys = $x ? Object.keys($x).filter(k => !k.startsWith('__')) : [];
11076
- if (!$x || !$x[value]) {
11077
- // Data source not loaded yet - return null to retry later
11078
- // The effect will re-run when $x[value] becomes available
11079
- return null; // Data source doesn't exist yet
11080
- }
11081
-
11082
- // Try to find parent x-for template
11083
- const parentTemplate = findParentXFor(el);
11084
- if (parentTemplate) {
11085
- const xForExpr = parentTemplate.getAttribute('x-for');
11086
- const loopItemName = extractLoopItemName(xForExpr);
11087
-
11088
- if (loopItemName) {
11089
- // Get loop item from current scope (Alpine sets it in the scope of elements inside x-for)
11090
- const currentScope = Alpine.$data(el);
11091
- const scopeKeys = currentScope ? Object.keys(currentScope).filter(k => !k.startsWith('__')) : [];
11092
- if (currentScope && currentScope[loopItemName]) {
11093
- const loopItem = currentScope[loopItemName];
11094
- return {
11095
- tableName: value,
11096
- entryId: loopItem.$id,
11097
- entry: loopItem
11098
- };
11099
- } else {
11100
- }
11101
- }
11102
- }
11103
-
11104
- // If no loop context found, return null (can't determine entry)
11105
- return null;
11106
- }
11107
-
11108
- return null;
11109
- };
11110
-
11111
- const loadFiles = async () => {
11112
- if (!tableName || !entryId) {
11113
- return;
11114
- }
11115
-
11116
- const $x = getX();
11117
- if (!$x?.assets || typeof $x.assets.$filesFor !== 'function') {
11118
- setTimeout(loadFiles, 100);
11119
- return;
11120
- }
11121
-
11122
- loadingFiles = true;
11123
- if (scope) scope.loadingFiles = true;
11124
-
11125
- try {
11126
- const loadedFiles = await $x.assets.$filesFor(tableName, entryId);
11127
- files = loadedFiles;
11128
- if (scope) {
11129
- scope.files = files;
11130
- scope.loadingFiles = false;
11131
- scope.filesError = null;
11132
- }
11133
- loadingFiles = false;
11134
- filesError = null;
11135
- } catch (err) {
11136
- console.error('[x-files] loadFiles: Error loading files:', err);
11137
- filesError = err.message || 'Failed to load files';
11138
- if (scope) {
11139
- scope.filesError = filesError;
11140
- scope.loadingFiles = false;
11141
- }
11142
- loadingFiles = false;
11143
- }
11144
- };
11145
-
11146
- effect(() => {
11147
- // Ensure scope variables are initialized in effect (runs immediately)
11148
- const currentScope = Alpine.$data(el);
11149
- if (currentScope) {
11150
- if (!('files' in currentScope)) {
11151
- currentScope.files = [];
11152
- }
11153
- if (!('loadingFiles' in currentScope)) {
11154
- currentScope.loadingFiles = false;
11155
- }
11156
- if (!('filesError' in currentScope)) {
11157
- currentScope.filesError = null;
11158
- }
11159
- // Update local refs
11160
- files = currentScope.files;
11161
- loadingFiles = currentScope.loadingFiles;
11162
- filesError = currentScope.filesError;
11163
- }
11164
-
11165
- // Evaluate file field name if specified
11166
- let currentFileField = 'fileIds';
11167
- if (evaluateField) {
11168
- evaluateField(fieldValue => {
11169
- if (fieldValue && typeof fieldValue === 'string') {
11170
- currentFileField = fieldValue;
11171
- fileField = currentFileField;
11172
- }
11173
- });
11174
- }
11175
-
11176
- // First, evaluate the expression to get the value
11177
- evaluate((value) => {
11178
- // Guard against infinite loops
11179
- if (isProcessing) {
11180
- return;
11181
- }
11182
-
11183
-
11184
- // For string values (data source names), access $x[value] in effect to make Alpine track it
11185
- if (typeof value === 'string') {
11186
- const $x = getX();
11187
- // Access $x[value] here so Alpine tracks it and re-runs effect when it changes
11188
- // This must be done synchronously in the effect, not in a promise
11189
- const dataSource = $x?.[value];
11190
- // Check if it's an array or array-like (proxy might wrap an array)
11191
- const isArrayLike = dataSource && (
11192
- Array.isArray(dataSource) ||
11193
- (typeof dataSource.length === 'number' && dataSource.length >= 0)
11194
- );
11195
- const hasData = isArrayLike && dataSource.length > 0;
11196
-
11197
- if (!$x || !dataSource || !isArrayLike || !hasData) {
11198
- // If we're already waiting for this data source, don't log again (prevents spam)
11199
- if (waitingForDataSource !== value) {
11200
- waitingForDataSource = value;
11201
-
11202
- // Set up a watch that will trigger when data becomes available
11203
- const scope = Alpine.$data(el);
11204
- if (scope && $x) {
11205
- // Watch the length property - when it changes from 0 to > 0, we'll process
11206
- let unwatchLengthFn = null;
11207
- try {
11208
- unwatchLengthFn = scope.$watch(`$x.${value}.length`, (newLength) => {
11209
- if (newLength > 0 && waitingForDataSource === value) {
11210
- waitingForDataSource = null;
11211
- if (unwatchLengthFn && typeof unwatchLengthFn === 'function') {
11212
- unwatchLengthFn();
11213
- unwatchLengthFn = null;
11214
- }
11215
- // The effect will re-run now that we've cleared the flag
11216
- }
11217
- });
11218
- } catch (e) {
11219
- // $watch might not be available or might fail
11220
- console.warn('[x-files] Failed to set up watch:', e);
11221
- }
11222
-
11223
- // Clean up watch on cleanup
11224
- if (unwatchLengthFn) {
11225
- cleanup(() => {
11226
- if (unwatchLengthFn && typeof unwatchLengthFn === 'function') {
11227
- try {
11228
- unwatchLengthFn();
11229
- } catch (e) {
11230
- // Ignore cleanup errors
11231
- }
11232
- }
11233
- });
11234
- }
11235
- }
11236
- }
11237
- return; // Wait for data source to load - effect will re-run when $x[value] changes
11238
- }
11239
-
11240
- // Data source is ready - clear waiting flag
11241
- if (waitingForDataSource === value) {
11242
- waitingForDataSource = null;
11243
- }
11244
- }
11245
-
11246
- // Mark as processing to prevent re-entry
11247
- isProcessing = true;
11248
-
11249
- // Now resolve the entry (async)
11250
- resolveEntry(value).then((resolved) => {
11251
-
11252
- if (!resolved) {
11253
- // Couldn't resolve entry - might be waiting for data
11254
- return;
11255
- }
11256
-
11257
- const newTableName = resolved.tableName;
11258
- const newEntryId = resolved.entryId;
11259
- const newEntry = resolved.entry;
11260
-
11261
- // Check if anything changed
11262
- if (newTableName === tableName && newEntryId === entryId && currentFileField === fileField) {
11263
- return; // No change
11264
- }
11265
-
11266
- // Cleanup previous watchers/listeners
11267
- if (unwatch && typeof unwatch === 'function') {
11268
- unwatch();
11269
- }
11270
- if (handleFileDeleted) {
11271
- window.removeEventListener('manifest:file-deleted', handleFileDeleted);
11272
- }
11273
-
11274
- tableName = newTableName;
11275
- entryId = newEntryId;
11276
- entry = newEntry;
11277
- fileField = currentFileField;
11278
-
11279
-
11280
- if (!tableName || !entryId) {
11281
- return;
11282
- }
11283
-
11284
- // Initial load
11285
- loadFiles();
11286
-
11287
- // Get current fileIds from entry or table
11288
- const $x = getX();
11289
- if (entry && entry[fileField]) {
11290
- lastFileIds = JSON.stringify(entry[fileField] || []);
11291
- } else if ($x && $x[tableName]) {
11292
- const tableData = $x[tableName];
11293
- if (Array.isArray(tableData)) {
11294
- const currentEntry = tableData.find(item => item.$id === entryId);
11295
- if (currentEntry && currentEntry[fileField]) {
11296
- lastFileIds = JSON.stringify(currentEntry[fileField] || []);
11297
- }
11298
- }
11299
- }
11300
-
11301
- // Watch the table array for fileIds changes
11302
- const scope = Alpine.$data(el);
11303
- if (scope) {
11304
- unwatch = scope.$watch(`$x.${tableName}`, (tableData) => {
11305
- if (!tableData || !Array.isArray(tableData)) return;
11306
-
11307
- const currentEntry = tableData.find(item => item.$id === entryId);
11308
- if (!currentEntry) return;
11309
-
11310
- const currentFileIds = JSON.stringify(currentEntry[fileField] || []);
11311
-
11312
- // Refresh if fileIds actually changed and not already loading
11313
- if (currentFileIds !== lastFileIds && !loadingFiles) {
11314
- const $x = getX();
11315
- if ($x?.assets && typeof $x.assets.$filesFor === 'function') {
11316
- lastFileIds = currentFileIds;
11317
- loadFiles();
11318
- }
11319
- }
11320
- });
11321
- }
11322
-
11323
- // Listen for file deletion events for instant UI updates
11324
- handleFileDeleted = (e) => {
11325
- const fileId = e.detail?.fileId;
11326
- if (!fileId) return;
11327
-
11328
- // Check if this file is in our file list
11329
- const fileInList = files.some(f => f.$id === fileId);
11330
-
11331
- // If event specifies this table/entry, or if file is in our list (optimistic update)
11332
- const isForThisEntry = e.detail?.tableName === tableName &&
11333
- e.detail?.entryIds &&
11334
- e.detail.entryIds.includes(entryId);
11335
-
11336
- if (isForThisEntry || fileInList) {
11337
- // Optimistic update: remove file immediately for instant feedback
11338
- files = files.filter(f => f.$id !== fileId);
11339
- const scope = Alpine.$data(el);
11340
- if (scope) scope.files = files;
11341
-
11342
- // Then refresh to ensure sync (but don't wait - optimistic update already happened)
11343
- if (!loadingFiles) {
11344
- const $x = getX();
11345
- if ($x?.assets && typeof $x.assets.$filesFor === 'function') {
11346
- // Use a small delay to let the server sync, then refresh
11347
- setTimeout(() => {
11348
- if (!loadingFiles) {
11349
- loadFiles();
11350
- }
11351
- }, 200);
11352
- }
11353
- }
11354
- }
11355
- };
11356
-
11357
- window.addEventListener('manifest:file-deleted', handleFileDeleted);
11358
-
11359
- // Reset processing guard after successful setup
11360
- isProcessing = false;
11361
- }).catch((err) => {
11362
- console.error('[x-files] Error resolving entry:', err);
11363
- isProcessing = false; // Reset guard on error
11364
- });
11365
- });
11366
- });
11367
-
11368
- cleanup(() => {
11369
- if (unwatch && typeof unwatch === 'function') {
11370
- unwatch();
11371
- }
11372
- if (handleFileDeleted) {
11373
- window.removeEventListener('manifest:file-deleted', handleFileDeleted);
11374
- }
11375
- });
11376
- });
11377
-
11378
- // x-data-files="entry": provides files/loadingFiles/filesError for a table entry.
11379
- // Per-element namespace via WeakMap for full isolation.
11380
- const dataFilesNamespaces = new WeakMap();
11381
-
11382
- Alpine.directive('data-files', (el, { expression }, { effect, evaluateLater, cleanup }) => {
11383
- const evaluateEntry = evaluateLater(expression);
11384
-
11385
- let entry = null;
11386
- let entryId = null; // Track entry ID separately to avoid stale references
11387
- let tableName = 'projects'; // Default, will be detected from entry
11388
- let project = null; // Keep for backward compatibility during transition
11389
- let projectId = null; // Keep for backward compatibility during transition
11390
- let files = [];
11391
- let loadingFiles = false;
11392
- let filesError = null;
11393
- let loadTimeout = null;
11394
- let cleanupCallbacks = [];
11395
- let watchCreated = false; // Track if watch has been created to prevent duplicates
11396
-
11397
- const directiveInstanceId = `directive-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
11398
-
11399
- // Isolated reactive scope layer for this instance. Editing x-data won't
11400
- // work (Alpine never re-reads it on initialized nodes) and would pollute
11401
- // the ancestor scope — addScopeToNode attaches a fresh layer instead.
11402
- const isolatedData = Alpine.reactive({
11403
- files: [],
11404
- loadingFiles: false,
11405
- filesError: null
11406
- });
11407
- const removeIsolatedScope = Alpine.addScopeToNode(el, isolatedData);
11408
- cleanupCallbacks.push(removeIsolatedScope);
11409
-
11410
- // Merged view: files/* writes hit isolatedData (top of stack); $watch etc. resolve from ancestors
11411
- const scope = Alpine.$data(el);
11412
-
11413
- // Store reference in WeakMap for access in closures
11414
- dataFilesNamespaces.set(el, isolatedData);
11415
-
11416
- // Initialize local references
11417
- files = isolatedData.files;
11418
- loadingFiles = isolatedData.loadingFiles;
11419
- filesError = isolatedData.filesError;
11420
-
11421
- // Helper to get namespace (for consistency)
11422
- const getNamespace = () => dataFilesNamespaces.get(el) || isolatedData;
11423
-
11424
- // Debounced load function
11425
- const loadProjectFiles = async () => {
11426
- // Use projectId variable instead of project.$id to avoid stale references
11427
- const currentProjectId = projectId;
11428
-
11429
- if (!currentProjectId) {
11430
- if (scope) {
11431
- scope.loadingFiles = false;
11432
- scope.files = [];
11433
- }
11434
- return;
11435
- }
11436
-
11437
- // Always get the latest project reference from the store by ID
11438
- const store = Alpine.store('data');
11439
- const projects = store?.projects;
11440
- if (!Array.isArray(projects)) {
11441
- return;
11442
- }
11443
-
11444
- const currentProject = projects.find(p => p.$id === currentProjectId);
11445
- if (!currentProject) {
11446
- // Project was deleted - clear files and don't try to load
11447
- files = [];
11448
- if (scope) {
11449
- scope.files = [];
11450
- scope.loadingFiles = false;
11451
- scope.filesError = null;
11452
- }
11453
- filesError = null;
11454
- loadingFiles = false;
11455
- project = null;
11456
- projectId = null;
11457
- return;
11458
- }
11459
-
11460
- // Update project reference to latest from store
11461
- project = currentProject;
11462
-
11463
- // Clear existing timeout
11464
- if (loadTimeout) {
11465
- clearTimeout(loadTimeout);
11466
- }
11467
-
11468
- // Set new timeout for debouncing
11469
- loadTimeout = setTimeout(async () => {
11470
- // The fileIds sync writes only for the identity that read them
11471
- const isCurrent = window.ManifestDataProxiesFiles?.identityGuard?.('projects') || (() => true);
11472
- // Double-check project still exists before making API call using projectId
11473
- const store = Alpine.store('data');
11474
- const projects = store?.projects;
11475
- if (!Array.isArray(projects)) {
11476
- loadTimeout = null;
11477
- return;
11478
- }
11479
-
11480
- const currentProject = projects.find(p => p.$id === currentProjectId);
11481
- if (!currentProject) {
11482
- // Project was deleted while waiting - clear and exit
11483
- files = [];
11484
- if (scope) {
11485
- scope.files = [];
11486
- scope.loadingFiles = false;
11487
- scope.filesError = null;
11488
- }
11489
- filesError = null;
11490
- loadingFiles = false;
11491
- loadTimeout = null;
11492
- project = null;
11493
- projectId = null;
11494
- return;
11495
- }
11496
-
11497
- // Update project reference to latest from store
11498
- project = currentProject;
11499
-
11500
- // Set loading state - update both the namespace and scope directly
11501
- loadingFiles = true;
11502
- const ns = getNamespace();
11503
- if (ns) {
11504
- ns.loadingFiles = true;
11505
- if (scope) scope.loadingFiles = true;
11506
- }
11507
- filesError = null;
11508
- if (ns) {
11509
- ns.filesError = null;
11510
- if (scope) scope.filesError = null;
11511
- }
11512
-
11513
- try {
11514
- // Use getFilesForEntry directly - more reliable than waiting for $filesFor
11515
- const getFilesForEntry = window.ManifestDataProxiesFiles?.getFilesForEntry;
11516
- if (!getFilesForEntry) {
11517
- throw new Error('getFilesForEntry is not available');
11518
- }
11519
-
11520
- // Get bucket ID for assets from manifest
11521
- const manifest = await window.ManifestDataConfig?.ensureManifest?.();
11522
- if (!manifest?.data?.assets) {
11523
- throw new Error('Assets data source not found in manifest');
11524
- }
11525
-
11526
- const assetsConfig = manifest.data.assets;
11527
- const bucketId = window.ManifestDataConfig?.getAppwriteBucketId?.(assetsConfig);
11528
- if (!bucketId) {
11529
- throw new Error('Assets bucket ID not found');
11530
- }
11531
-
11532
- // Use currentProjectId to ensure we're loading files for the correct project
11533
- // Double-check we're using the correct project ID
11534
- if (!currentProjectId) {
11535
- return;
11536
- }
11537
-
11538
- // Verify projectId matches before calling
11539
- if (currentProjectId !== projectId) {
11540
- return;
11541
- }
11542
-
11543
- // Get the database entry's fileIds BEFORE calling getFilesForEntry
11544
- // This lets us check if the database has stale data
11545
- let databaseFileIds = null;
11546
- try {
11547
- const manifest = await window.ManifestDataConfig?.ensureManifest?.();
11548
- const tableDataSource = manifest?.data?.projects;
11549
- if (tableDataSource && window.ManifestDataConfig?.getAppwriteTableId) {
11550
- const tableId = window.ManifestDataConfig.getAppwriteTableId(tableDataSource);
11551
- const appwriteConfig = await window.ManifestDataConfig.getAppwriteConfig(tableDataSource);
11552
- if (appwriteConfig && window.ManifestDataAppwrite?.getTableRow) {
11553
- const dbEntry = await window.ManifestDataAppwrite.getTableRow(
11554
- appwriteConfig.databaseId,
11555
- tableId,
11556
- currentProjectId
11557
- );
11558
- databaseFileIds = dbEntry?.fileIds || [];
11559
- }
11560
- }
11561
- } catch (err) {
11562
- // Ignore errors - we'll just update store if needed
11563
- }
11564
-
11565
- // CRITICAL DEBUG: Verify we're using the correct projectId before calling getFilesForEntry
11566
- const loadedFiles = await getFilesForEntry('projects', currentProjectId, bucketId, 'fileIds') || [];
11567
-
11568
- // Fresh array so instances don't share references
11569
- const newFilesArray = [...loadedFiles];
11570
-
11571
- files = newFilesArray;
11572
-
11573
- const ns = getNamespace();
11574
- if (ns) {
11575
- const markedFiles = newFilesArray.map(file => ({
11576
- ...file,
11577
- _debugProjectId: currentProjectId,
11578
- _debugDirectiveId: directiveInstanceId,
11579
- _debugLoadedAt: Date.now()
11580
- }));
11581
-
11582
- // Update namespace (reactive object)
11583
- ns.files = markedFiles;
11584
- ns.loadingFiles = false;
11585
- ns.filesError = null;
11586
-
11587
- // Update scope directly (since it's isolated, no conflicts)
11588
- if (scope) {
11589
- scope.files = markedFiles;
11590
- scope.loadingFiles = false;
11591
- scope.filesError = null;
11592
- }
11593
-
11594
- // Update local references
11595
- files = markedFiles;
11596
- loadingFiles = false;
11597
- filesError = null;
11598
-
11599
- }
11600
-
11601
-
11602
- // Track what we actually loaded (Appwrite is truth, store may be stale)
11603
- const loadedFileIdsArray = loadedFiles.map(f => f.$id) || [];
11604
- lastFileIds = JSON.stringify(loadedFileIdsArray);
11605
-
11606
- // Reconcile stale fileIds in both the store and the Appwrite row
11607
- const store = Alpine.store('data');
11608
- const projects = store?.projects;
11609
- if (Array.isArray(projects)) {
11610
- const currentProject = projects.find(p => p.$id === currentProjectId);
11611
- if (currentProject) {
11612
- const storeFileIds = currentProject.fileIds || [];
11613
- const storeFileIdsArray = Array.isArray(storeFileIds) ? storeFileIds : [];
11614
- const storeFileIdsJson = JSON.stringify(storeFileIdsArray);
11615
-
11616
- // Check if store is stale (different from what we loaded)
11617
- const storeIsStale = storeFileIdsJson !== lastFileIds;
11618
-
11619
- // Check if database is stale (different from what we loaded)
11620
- const databaseFileIdsArray = Array.isArray(databaseFileIds) ? databaseFileIds : [];
11621
- const databaseFileIdsJson = JSON.stringify(databaseFileIdsArray);
11622
- const databaseIsStale = databaseFileIds && databaseFileIdsJson !== lastFileIds;
11623
-
11624
- if ((storeIsStale || databaseIsStale) && isCurrent()) {
11625
- console.warn('[Manifest Data] Store/Database fileIds is STALE - cleaning up:', {
11626
- directiveInstanceId,
11627
- projectId: currentProjectId,
11628
- storeFileIds: storeFileIdsJson,
11629
- databaseFileIds: databaseFileIdsJson,
11630
- loadedFileIds: lastFileIds,
11631
- storeIsStale,
11632
- databaseIsStale,
11633
- willSyncStore: storeIsStale,
11634
- willSyncDatabase: databaseIsStale
11635
- });
11636
-
11637
- // Update store if it's stale
11638
- if (storeIsStale) {
11639
- const updateEntryInStore = window.ManifestDataMutations?.updateEntryInStore;
11640
- if (updateEntryInStore) {
11641
- updateEntryInStore('projects', currentProjectId, { fileIds: loadedFileIdsArray });
11642
- }
11643
- }
11644
-
11645
- // Only write the DB if actually stale — avoids a
11646
- // realtime event that could overwrite our store update
11647
- if (databaseIsStale) {
11648
- try {
11649
- const manifest = await window.ManifestDataConfig?.ensureManifest?.();
11650
- const tableDataSource = manifest?.data?.projects;
11651
- if (tableDataSource && window.ManifestDataConfig?.getAppwriteTableId) {
11652
- const tableId = window.ManifestDataConfig.getAppwriteTableId(tableDataSource);
11653
- const appwriteConfig = await window.ManifestDataConfig.getAppwriteConfig(tableDataSource);
11654
-
11655
- if (appwriteConfig && window.ManifestDataAppwrite?.updateRow && isCurrent()) {
11656
- await window.ManifestDataAppwrite.updateRow(
11657
- appwriteConfig.databaseId,
11658
- tableId,
11659
- currentProjectId,
11660
- { fileIds: loadedFileIdsArray }
11661
- );
11662
- }
11663
- }
11664
- } catch (dbUpdateError) {
11665
- console.error('[Manifest Data] Failed to update Appwrite database:', dbUpdateError);
11666
- // Don't throw - store is already updated, database will sync via realtime eventually
11667
- }
11668
- }
11669
- }
11670
- }
11671
- }
11672
- } catch (err) {
11673
- // Check if error is a 404 (project not found) - handle gracefully
11674
- const isNotFound = err.message?.includes('not found') ||
11675
- err.message?.includes('could not be found') ||
11676
- err.code === 404 ||
11677
- err.response?.code === 404;
11678
-
11679
- if (isNotFound) {
11680
- // Project was deleted - silently clear files (don't show error)
11681
- files = [];
11682
- filesError = null;
11683
- if (scope) {
11684
- scope.files = [];
11685
- scope.loadingFiles = false;
11686
- scope.filesError = null;
11687
- }
11688
- } else {
11689
- // Other error - show it
11690
- console.error('[x-project-files] Error loading files:', err);
11691
- filesError = err.message || 'Failed to load files';
11692
- files = [];
11693
- if (scope) {
11694
- scope.filesError = filesError;
11695
- scope.files = files;
11696
- scope.loadingFiles = false;
11697
- }
11698
- }
11699
- } finally {
11700
- // Ensure loadingFiles is cleared
11701
- loadingFiles = false;
11702
- const ns = getNamespace();
11703
- if (ns) {
11704
- ns.loadingFiles = false;
11705
- if (scope) scope.loadingFiles = false;
11706
- }
11707
- loadTimeout = null;
11708
- }
11709
- }, 100);
11710
- };
11711
-
11712
- let lastFileIds = null;
11713
- let fileIdsWatchUnwatch = null;
11714
-
11715
- effect(() => {
11716
- evaluateEntry((value) => {
11717
- const currentProjectId = value?.$id;
11718
-
11719
- if (!currentProjectId) {
11720
- // Clear files if no project
11721
- files = [];
11722
- if (scope) {
11723
- scope.files = [];
11724
- scope.loadingFiles = false;
11725
- }
11726
- project = null;
11727
- projectId = null;
11728
- return;
11729
- }
11730
-
11731
- // Get the latest project reference from the store to avoid stale references
11732
- const store = Alpine.store('data');
11733
- const projects = store?.projects;
11734
- let latestProject = value; // Default to evaluated value
11735
-
11736
- if (Array.isArray(projects)) {
11737
- const storeProject = projects.find(p => p.$id === currentProjectId);
11738
- if (storeProject) {
11739
- latestProject = storeProject; // Use latest from store
11740
- } else {
11741
- }
11742
- }
11743
-
11744
- const previousProjectId = projectId;
11745
- const previousEntryId = entryId; // Sync with entryId
11746
- project = latestProject; // Always use latest reference
11747
- projectId = currentProjectId; // Update tracked project ID
11748
- entry = latestProject; // Sync entry
11749
- entryId = currentProjectId; // Sync entryId
11750
-
11751
- // Clean up existing fileIds watch when project ID changes
11752
- if (previousProjectId !== currentProjectId) {
11753
- if (fileIdsWatchUnwatch && typeof fileIdsWatchUnwatch === 'function') {
11754
- fileIdsWatchUnwatch();
11755
- fileIdsWatchUnwatch = null;
11756
- }
11757
- lastFileIds = null;
11758
- watchCreated = false; // Reset watch creation flag when project ID changes
11759
- }
11760
-
11761
- // Only reload if project ID changed or if we didn't have a project before
11762
- if (currentProjectId && (previousProjectId !== currentProjectId || !previousProjectId)) {
11763
- loadProjectFiles();
11764
- }
11765
-
11766
- // Watch this project's fileIds via the store (one watch per project id)
11767
- if (currentProjectId && scope && typeof scope.$watch === 'function' && !fileIdsWatchUnwatch && !watchCreated) {
11768
- watchCreated = true;
11769
- const projectId = currentProjectId; // capture for closure
11770
- let isProcessing = false;
11771
-
11772
- // Initialize lastFileIds with current value from the store to prevent false positives
11773
- const store = Alpine.store('data');
11774
- const projects = store?.projects;
11775
- if (Array.isArray(projects)) {
11776
- const currentProject = projects.find(p => p.$id === projectId);
11777
- if (currentProject) {
11778
- lastFileIds = JSON.stringify(currentProject.fileIds || []);
11779
- }
11780
- }
11781
-
11782
- // Function watch (more reliable than a string expr for nested store access);
11783
- // reads only this project's fileIds to keep reactivity narrow.
11784
- fileIdsWatchUnwatch = scope.$watch(
11785
- () => {
11786
- const store = Alpine.store('data');
11787
- const projects = store?.projects;
11788
- if (!Array.isArray(projects)) return null;
11789
-
11790
- const currentProject = projects.find(p => p.$id === projectId);
11791
- if (!currentProject) return null;
11792
-
11793
- return JSON.stringify(currentProject.fileIds || []);
11794
- },
11795
- (currentFileIdsJson) => {
11796
- // Guard against processing multiple updates simultaneously
11797
- if (isProcessing) {
11798
- return;
11799
- }
11800
-
11801
- // This callback runs whenever fileIds changes
11802
- if (currentFileIdsJson === null) {
11803
- // Project not found in store
11804
- if (scope) {
11805
- scope.files = [];
11806
- scope.loadingFiles = false;
11807
- }
11808
- return;
11809
- }
11810
-
11811
- // Compare with last known fileIds - only reload if actually changed
11812
- // Use the outer lastFileIds variable (not a local one)
11813
- if (currentFileIdsJson !== lastFileIds) {
11814
- isProcessing = true;
11815
- // Update the outer lastFileIds variable
11816
- lastFileIds = currentFileIdsJson;
11817
- // Debounce the reload to avoid multiple rapid updates
11818
- loadProjectFiles().finally(() => {
11819
- isProcessing = false;
11820
- // NOTE: lastFileIds is already updated in loadProjectFiles from loaded files (source of truth)
11821
- // Don't overwrite it with store data here, as the store might be stale
11822
- });
11823
- } else {
11824
- }
11825
- }
11826
- );
11827
-
11828
- // Mark this watch for cleanup
11829
- if (fileIdsWatchUnwatch) {
11830
- fileIdsWatchUnwatch._isFileIdsWatch = true;
11831
- cleanupCallbacks.push(() => {
11832
- if (fileIdsWatchUnwatch && typeof fileIdsWatchUnwatch === 'function') {
11833
- fileIdsWatchUnwatch();
11834
- }
11835
- });
11836
- }
11837
- }
11838
- });
11839
- });
11840
-
11841
- // Set up event listeners
11842
- let eventProcessing = false; // Guard against event-triggered reloads
11843
-
11844
- const handleProjectFilesUpdated = (e) => {
11845
- const eventProjectId = e.detail?.projectId || e.detail?.entryId;
11846
- const matches = eventProjectId === projectId;
11847
-
11848
- // Use projectId variable instead of project?.$id to avoid stale references
11849
- if (matches && !eventProcessing) {
11850
- eventProcessing = true;
11851
- // Force reload when event fires - this is a backup to the watch
11852
- loadProjectFiles().finally(() => {
11853
- eventProcessing = false;
11854
- });
11855
- }
11856
- };
11857
-
11858
- const handleFileCreated = (e) => {
11859
- const fileId = e.detail?.fileId;
11860
- const entryId = e.detail?.entryId;
11861
- const tableName = e.detail?.tableName;
11862
-
11863
- // Match on the event's entryId (store may be stale)
11864
- const matchesProject = entryId === projectId && tableName === 'projects';
11865
-
11866
- if (fileId && matchesProject && !eventProcessing) {
11867
- eventProcessing = true;
11868
- // Reload files for this project - getFilesForEntry will get the latest from Appwrite
11869
- loadProjectFiles().finally(() => {
11870
- eventProcessing = false;
11871
- });
11872
- }
11873
- };
11874
-
11875
- const handleFileDeleted = (e) => {
11876
- // Use projectId variable instead of project?.$id to avoid stale references
11877
- if (e.detail?.tableName === 'projects' && e.detail?.entryIds?.includes(projectId) && !eventProcessing) {
11878
- const fileId = e.detail?.fileId;
11879
- eventProcessing = true;
11880
- if (fileId) {
11881
- // Optimistically remove from UI
11882
- files = files.filter(f => f.$id !== fileId);
11883
- if (scope) scope.files = files;
11884
- }
11885
- // Reload to ensure consistency
11886
- loadProjectFiles().finally(() => {
11887
- eventProcessing = false;
11888
- });
11889
- }
11890
- };
11891
-
11892
- window.addEventListener('manifest:project-files-updated', handleProjectFilesUpdated);
11893
- window.addEventListener('manifest:file-created', handleFileCreated);
11894
- window.addEventListener('manifest:file-deleted', handleFileDeleted);
11895
-
11896
- cleanupCallbacks.push(() => {
11897
- window.removeEventListener('manifest:project-files-updated', handleProjectFilesUpdated);
11898
- window.removeEventListener('manifest:file-created', handleFileCreated);
11899
- window.removeEventListener('manifest:file-deleted', handleFileDeleted);
11900
- if (loadTimeout) {
11901
- clearTimeout(loadTimeout);
11902
- }
11903
- // Clean up watch when directive is destroyed
11904
- if (fileIdsWatchUnwatch && typeof fileIdsWatchUnwatch === 'function') {
11905
- fileIdsWatchUnwatch();
11906
- fileIdsWatchUnwatch = null;
11907
- }
11908
- watchCreated = false; // Reset flag on cleanup
11909
- });
11910
-
11911
- cleanup(() => {
11912
- cleanupCallbacks.forEach(cb => cb());
11913
- });
11914
- });
11915
- }
11916
-
11917
- // Auto-registration handled elsewhere; kept for reference.
11918
- // if (typeof document !== 'undefined') {
11919
- // if (typeof Alpine !== 'undefined') {
11920
- // registerFilesDirective();
11921
- // } else {
11922
- // document.addEventListener('alpine:init', () => {
11923
- // registerFilesDirective();
11924
- // });
11925
- // }
11926
- // }
11927
-
11928
10899
  /* Manifest Data Sources - Main Initialization */
11929
10900
 
11930
10901
  // A scoped query that isn't ready yet (buildAppwriteQueries returned null — see
@@ -22,7 +22,7 @@
22
22
 
23
23
  // Text an element holds in source: Alpine-rendered and generated content is left out.
24
24
  // Plugin-rendered hosts: their children are produced at runtime, not authored.
25
- const RENDERED = ['x-html', 'x-text', 'x-markdown', 'x-icon', 'x-svg', 'x-code', 'x-code-group', 'x-chart', 'x-anchors', 'x-carousel', 'x-color', 'x-colorpicker', 'x-combobox', 'x-date', 'x-defer', 'x-virtual', 'x-import', 'x-files', 'x-data-files'];
25
+ const RENDERED = ['x-html', 'x-text', 'x-markdown', 'x-icon', 'x-svg', 'x-code', 'x-code-group', 'x-chart', 'x-anchors', 'x-carousel', 'x-color', 'x-colorpicker', 'x-combobox', 'x-date', 'x-defer', 'x-virtual', 'x-import'];
26
26
  const isRendered = (el) => [...el.attributes].some(a => { const n = a.name.toLowerCase(); return RENDERED.some(r => n === r || n.startsWith(r + '.')); });
27
27
  // Elements whose content is not markup: never text-edited.
28
28
  const RAW_EDIT = new Set(['SCRIPT', 'STYLE', 'TEXTAREA', 'TITLE', 'NOSCRIPT', 'TEMPLATE', 'XMP', 'IFRAME', 'NOEMBED', 'NOFRAMES']);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "manifest.appwrite.auth.js": "sha384-gWLSeVPqCLMiUZB8MU7GqMg3x2yULFUsp8nTTZrPp/9Dlkix42rBn9yIimvwrHqZ",
3
- "manifest.appwrite.data.js": "sha384-+C9+NUQGnYQqXCYt+fb97/J0b13Vx7eLsBlBlYsG+6/Q8bfHUR2TBtOsG7+s/4OD",
3
+ "manifest.appwrite.data.js": "sha384-YkcDf74N4r8iTjP8EmY2pBH59MlDVhOj4kE5eOyEYLCidkcbjQbSPFhLrPbVCXvf",
4
4
  "manifest.appwrite.presences.js": "sha384-LINPhIPTCK+rA8zd+HPUzMSEgH6Sl2vQMEyItT97bnEE2FYGYKqjXX+CWdt6nl9z",
5
5
  "manifest.bindings.js": "sha384-lPtMf8Ykaic9gNVZKq8Scia1881ZeMAyxer3WCIkUNwwrgzGBWto1OXADUwjvORF",
6
6
  "manifest.charts.js": "sha384-cf1N+ssSR5IL2qufv8noB5QOJrSvL7J0sLKgbJmyTDl1HodQ/Bkyf/QntO6Iynvi",
@@ -11,12 +11,12 @@
11
11
  "manifest.combobox.js": "sha384-/lJo6vaxKjgnBSRs/dzkhK1dzGk3GBw8FISoNJZB70mwAVwu1k5veZyBXjOb4keS",
12
12
  "manifest.components.js": "sha384-7lu4Nw2GqpAUn63c3gYEvgfM58PYsdoPv3wzqPQfZ5bravqOY/lfE8HFKHsKflQj",
13
13
  "manifest.computed.js": "sha384-GYML/e81gQfN+iDbqhPUgny8bINCyL+SrbTofoGk4hlCnLLjv51mCv42JMqq+ku5",
14
- "manifest.data.js": "sha384-a94NfFVv/07ZCMAbhGEuftFHrYqSP/VcI/2LUrtp17kRTQm4diiM4Fazu0iMG6M6",
14
+ "manifest.data.js": "sha384-r3G5FmhJs9XFqa+zcClpHm/DsruwOV0t8WEjg6znAQ2THBXWlJBq5k42CgeEICLE",
15
15
  "manifest.datepicker.js": "sha384-EzlMwvIxlla/0BuyhAEqxN0M8TGcWIWgEIg840V0akKQQK1uY648wPWMkobvtq/o",
16
16
  "manifest.defer.js": "sha384-PRp7+dCZHnnl55rX2xrHutLrQnszHo7o5o9Tq28M/yjLZPuXDzcwQNxCdvbtCYSz",
17
17
  "manifest.device.js": "sha384-YeQaS56L8IILqrQNBSeAOLwIh5DuAOrE60cYLK1+46qJtUrXlAvqGe2j5mbV4Vq7",
18
18
  "manifest.dropdowns.js": "sha384-TlFrYVWTXvpUmGnYaAk2til4lu0p6w5YcmWWEzZAokzd2qlmoyRLLXXVuYAK/AlR",
19
- "manifest.edit.js": "sha384-8JqFgkt8KMtB8bkwDPe0ntKbOSKGwKz8MrDsEkxozKkEreS4OCE1YfJMWO3QBMZO",
19
+ "manifest.edit.js": "sha384-OLt0n9Qf6JZGcdSAyLsCzhPdwdbGIODhMzcaKANuDWsduWBfgpKmxmhjH6rBhV7/",
20
20
  "manifest.export.js": "sha384-C4W5LrGQFnSILRWoWOCliajUK6rAzNW+EliogRx72vD1cUOYScSdfzHNbjSWv5XU",
21
21
  "manifest.icons.js": "sha384-kKOINpX70YzNO3FvkV6umrmO3f0KIu0DNbwB+ej55a7y/lhU7v/myQtXL0bwCTbt",
22
22
  "manifest.localization.js": "sha384-9EDAqnI7MNCZp4Vas0RMZgceCuz9EJUi/OARm8iI+Hi4S8HF//yyVOhhhhQ+XcLq",
@@ -29,13 +29,13 @@
29
29
  "manifest.status.js": "sha384-ofu7nBnVIGZ1U1o2R9d2H3V8aEMPUCVbl5FO3gIToXqi0oa36fTviEdh5UU7Kitw",
30
30
  "manifest.submissions.js": "sha384-v9eS47ytAfTGIKAyVnbd0QWegucVS7yduvigqfsxxoqXmbaEoy0M2y+BiI4xeZBd",
31
31
  "manifest.svg.js": "sha384-qr/8H9+2cIhSXNbRWRtIdrDlTOxKlNJqwEefHvCYoiBNW/kKhPTFa109Orv/EBnb",
32
- "manifest.sw.js": "sha384-ZE4beB999SQ8tMqo9NrmqYs1sAynIYThfc6qv8JxQG2gCJavrYLa4xITK6npUgah",
32
+ "manifest.sw.js": "sha384-ArP1ycg+8Tbhimn+TqZDALqHdo9351td9SvTkshPD8tICwa34d2jDXNeud4NrxyC",
33
33
  "manifest.tabs.js": "sha384-otU09H7jnawVKQdLAYpMCd3jx00tgyPVr42D2hLIBzN5dG4se505YesavdnMqEi1",
34
34
  "manifest.tailwind.js": "sha384-yuP3LEvWU+QVjxjkZ0YhErtC9RrGmhOmHjjFjhS9obqZbp5/KTIEnSR0CXDvHE0B",
35
35
  "manifest.toasts.js": "sha384-UpOz9fAdGeGUhL0NamBg5iPepEfIy73p9HYdcxfOQC5b7CVsl7Our0skdZzaLNcC",
36
36
  "manifest.tooltips.js": "sha384-hXGp5j0s6p2kGZY/hqLPEbaUv68ca63kFCjYiZqK3DcC12mpHTBy1vz3kuApyf4p",
37
37
  "manifest.url.parameters.js": "sha384-J2aSVBOPsoqsbafHndrWLHEDpKb4AKJAoQnVmKA4gZh5P/8HHjFWHO/lkusmG84l",
38
- "manifest.utilities.js": "sha384-IT5dOFePCzbLAuVXMiXXW7lYnxVwHMfjtvn1edWEdASlNlJO60YbILm2+l+Cjm8g",
38
+ "manifest.utilities.js": "sha384-J6NZCPmeHPo12kcsUzJNJmjxX67MASCwdHUoLvV3Ty003zOi09quLrf5ghpzfw8a",
39
39
  "manifest.virtual.js": "sha384-PtIDx042i29mkxEYZH+y3whBzKgBgV01CU1XzzeEl/8TBPl9qvny4ppyXgYI5DsM",
40
40
  "manifest.js": "sha384-7+hNmvzD6OPQt6q4pZEDoqf5C8LHucIqlfKJQAAH6b4tsmvpX0viCvdYqqGOjqET"
41
41
  }
@@ -16,7 +16,7 @@
16
16
 
17
17
  // Build stamps the published version here; unstamped (dev) falls back to the
18
18
  // registration URL's `v`, then 'dev'.
19
- const BUILD_VERSION = '0.5.297';
19
+ const BUILD_VERSION = '0.5.299';
20
20
  const CACHE_PREFIX = 'mnfst-sw:';
21
21
  const META_CACHE = CACHE_PREFIX + 'meta';
22
22
  // Sized to hold a full precache.json warm-up (PRECACHE_MAX_ENTRIES server-side)
@@ -4397,6 +4397,9 @@ detectOS();
4397
4397
  function injectTailwindVariants() {
4398
4398
  try {
4399
4399
  if (document.getElementById('manifest-tailwind-variants')) return;
4400
+ // Dark follows $color's .dark class; an author's own declaration wins
4401
+ const authorDark = Array.from(document.querySelectorAll('style[type="text/tailwindcss"]'))
4402
+ .some(s => /@custom-variant\s+dark[\s({]/.test(s.textContent || ''));
4400
4403
  const style = document.createElement('style');
4401
4404
  style.id = 'manifest-tailwind-variants';
4402
4405
  style.setAttribute('type', 'text/tailwindcss');
@@ -4414,7 +4417,8 @@ function injectTailwindVariants() {
4414
4417
  '@custom-variant offline (&:where([data-online="false"] *));',
4415
4418
  '@custom-variant standalone (&:where([data-standalone] *));',
4416
4419
  '@custom-variant native (&:where([data-native] *));',
4417
- '@custom-variant web (&:where(html:not([data-native]) *));'
4420
+ '@custom-variant web (&:where(html:not([data-native]) *));',
4421
+ ...(authorDark ? [] : ['@custom-variant dark (&:where(.dark, .dark *));'])
4418
4422
  ].join('\n');
4419
4423
  (document.head || document.documentElement).appendChild(style);
4420
4424
  } catch (e) {
@@ -3160,7 +3160,8 @@ const TAILWIND_CUSTOM_VARIANTS = [
3160
3160
  '@custom-variant offline (&:where([data-online="false"] *));',
3161
3161
  '@custom-variant standalone (&:where([data-standalone] *));',
3162
3162
  '@custom-variant native (&:where([data-native] *));',
3163
- '@custom-variant web (&:where(html:not([data-native]) *));'
3163
+ '@custom-variant web (&:where(html:not([data-native]) *));',
3164
+ '@custom-variant dark (&:where(.dark, .dark *));'
3164
3165
  ].join('\n');
3165
3166
 
3166
3167
  /** Balanced-brace extraction of a top-level `@layer <name> { ... }` body —
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mnfst",
3
- "version": "0.5.297",
3
+ "version": "0.5.299",
4
4
  "private": false,
5
5
  "workspaces": [
6
6
  "templates/starter",
@@ -60,6 +60,7 @@
60
60
  "test:e2e:route-head": "node tests/e2e/route-head.e2e.mjs",
61
61
  "test:e2e:prerender-patch": "node tests/e2e/utilities-prerender-patch.e2e.mjs",
62
62
  "test:e2e:hidden-responsive": "node tests/e2e/utilities-hidden-responsive.e2e.mjs",
63
+ "test:e2e:tailwind-dark": "node tests/e2e/tailwind-dark-variant.e2e.mjs",
63
64
  "lint": "echo 'No linting configured'",
64
65
  "release:docs": "npm test && node scripts/release-bump.mjs packages/docs && cd packages/docs && npm publish --auth-type=web",
65
66
  "release:check": "node scripts/release-check.mjs"